0
architecture beh of pwm is 
begin
type lutable is array (1 to 64) of integer range 0 to 4000;
-----------------------------------------------tables for FULL STEPPING.
constant full_pwm1_1: lutable := (  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  
                                            3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  
                                            3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  
                                            3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900);
variable ds1_1: integer range 0 to 4000;        --Duty Cycle Variables for PWM1_1
variable c_full,c_half,c_quat,c_eigh,c_sixt: integer range 1 to 64;

process(gclk)
begin
case selectline is 
when "001" =>                    --------------------FULL STEPPING
            if dir='1' then--------------------direction selection
                    ds1_1 := full_pwm1_1(c_full);

我没有提到的所有其他变量都被定义为整数,具有适当的范围,并且都在语法上定义。

但我得到了一个“未定义的符号”错误,而且还有 full_pwm1_1 常量。如果有人可以帮助我并验证数组声明和实例化是否正确?

4

2 回答 2

1

在“架构”行和“开始”行之间写入类型和常量声明,例如:

architecture beh of pwm is 
   type lutable is array (1 to 64) of integer range 0 to 4000;
   constant full_pwm1_1: lutable := (  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  
                                        3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  
                                        3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  
                                        3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900,  3900,0,0,3900);

   ...
begin

   ...

在“process”和“begin”之间写变量声明,例如

process(gclk)    
    variable ds1_1: integer range 0 to 4000;        --Duty Cycle Variables for PWM1_1
    variable c_full,c_half,c_quat,c_eigh,c_sixt: integer range 1 to 64;
begin
    ...

或将 ds1_1 等声明为信号,例如:

...
   signal ds1_1: integer range 0 to 4000;        --Duty Cycle Variables for PWM1_1
   signal c_full,c_half,c_quat,c_eigh,c_sixt: integer range 1 to 64;
...
begin
    ...
    process(gclk)
       ...
于 2013-06-21T07:49:09.290 回答
1

你的类型和常量声明必须architecturebegin.

此外,您不能在本节中包含变量 - 它们必须是

  • 普通变量,在一个process
  • 共享变量...必须是一种protected类型,而不是普通类型
于 2013-06-22T19:49:31.420 回答