0
IF (((SW(17) = '0') OR ((SW(17) = '1') AND (SW(16) = '0'))) OR ((SW(17) = 1) AND (SW(16) = 0) AND (SW(14) = 1)) AND (tempCounter = 1)) THEN
           next_state <= STATE1;
           resetTempCounter <= '1';
        ELSE
           next_state <= STATE0;
        END IF;

上面的代码会引发语法错误。我检查了括号,我认为这不是问题。我最初打破了排长队,并认为这是问题所在,但事实并非如此。我还应该通知您,代码在流程语句中,这不是问题所在。

错误

错误 (10500):Lab4b.vhd(241) 靠近文本“AND”的 VHDL 语法错误;期待“)”或“,”

错误 (10500):Lab4b.vhd(244) 靠近文本“ELSE”的 VHDL 语法错误;期待“end”,或“(”,或标识符(“else”是保留关键字),或顺序语句

我对 VHDL 编程相当陌生,所以请多多包涵,感谢您的帮助。

4

3 回答 3

0

假设它SW被声明为 abit_vector或 an STD_LOGIC_VECTOR,你的比较运算符就搞错了:记住bitSTD_LOGIC都是真正的枚举类型,由模仿“真实”的值组成,而不是整数(在这种情况下0,and1将是一个有效的选择) .

因此,在这种情况下,您需要做的就是在 and 周围添加撇号01检查这是否有效(也假设这tempCounter是一个STD_LOGICbit类型的信号):

(((SW(17) = '0') OR ((SW(17) = '1') AND (SW(16) = '0'))) OR ((SW(17) = '1') AND (SW(16) = '0') AND (SW(14) = '1')) AND (tempCounter = '1'))
于 2013-03-29T20:47:41.160 回答
0

让我以不同的方式写你的陈述来说明问题:

A = ((SW(17) = '0') OR ((SW(17) = '1') AND (SW(16) = '0')))
B = ((SW(17) = '1') AND (SW(16) = '0') AND (SW(14) = '1'))
C = (tempCounter = '1')

你现在有:

if A or B and C then
   ...

这个问题可以通过写来解决,例如:

if (A or B) and C then
   ...

或者

if A or (B and C) then
   ...
于 2013-03-29T21:31:45.820 回答
0

重新格式化线路,问题更容易发现......

IF (((SW(17) = '0') OR ((SW(17) = '1') AND (SW(16) = '0'))) 
 OR ((SW(17) = 1) AND (SW(16) = 0) AND (SW(14) = 1))
 AND (tempCounter = 1)) THEN

In one place, SW(17) = '0' - this is a std_logic or bit value. correct.
In another, SW(17) = 1 - this is an integer, ... not so much.

I believe that too many brackets deducts from clarity, I would reduce

(((SW(17) = '0') OR ((SW(17) = '1') AND (SW(16) = '0'))) 
 ... )

to

((SW(17) = '0' OR (SW(17) = '1' AND SW(16) = '0')) 
 ... )

to reduce confusion a little. Who knows, with a bit less clutter you might have spotted the simple typos yourself?

于 2013-03-30T10:04:16.967 回答