always语句下如果有判断语句if,那么if语句中的条件必须有always中的敏感变量。
否则错误提示为:Error (10200): Verilog HDL Conditional Statement error at ……: cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct
比如 always@(posedge CLK or negedge RSTn)
表明在clk上升沿或r_est下降沿这两个敏感事件发生时always语句块得以触发;而always中的if条件语句必须至少有一个条件指向其中一个敏感事件(边界标识符);所以写成“if(r_est)...else...”就会出错。
可以将 always@(posedge CLK or negedge RSTn) 改为 always@(posedge CLK or posedge RSTn) 编译就没问题了。
错误原因:
CAUSE: In a conditional statement at the specified location in a Verilog Design File (.v), you specified a condition that Quartus II Integrated Synthesis cannot use to classify the edges in the enclosing always construct's event control. When an event control contains multiple edges, Quartus II Integrated Synthesis distinguishes the asynchronous control signals from the clock by analyzing the conditional statements in the always construct. For example, the following code fragment contains an always construct whose event control contains three edges---two asynchronous resets and a clock.
always @ (posedge clk or posedge rst1 or posedge rst2) begin if ( rst1 || rst2 ) q <= 1'b0; else q <= d;endQuartus II Integrated Synthesis uses the if condition to identify the two asynchronous resets and, by implication, the clock. For edge classification, Quartus II Integrated Synthesis requires that a condition fall into one of two categories. It can refer to a single edge identifier (to match posedge events) or its complement (to match negedge events), for example, rst1, !rst1, rst1 == 1'b1, rst1 == 1'b0. It can also OR two or more expressions that each refer to a single edge identifier or its complement, for example, (rst1 || rst2), (!rst1 || !rst2). You can receive this error if your condition tests for the wrong polarity, or if it tests for the value of a variable that is not an edge in the event control. For example, to match a posedge rst event, the condition must be rst or rst = 1'b1.Finally, you can receive this error if you are attempting to use a single condition expression to test for both an asynchronous reset/set and a synchronous reset/set condition. The following code fragment contains an example of an illegal condition expression: always @ (posedge clk or posedge rst) begin if ( rst || sync_rst ) q <= 1'b0; else q <= d;endQuartus II Integrated Synthesis generates this error message when compiling this design because it cannot match sync_rst to an edge on the sensitivity list.原因:……指定了一个条件,Quartus II 综合器不能够将该条件用于在封闭的always结构的事件控制中对边界进行区分。当一个事件控制中包含多重边界,Quartus II 综合器通过分析always结构中的条件语句来对时钟和异步控制信号加以区分。
Quartus II 综合器采用if条件来鉴别两个异步reset信号,并隐含地鉴别了clock信号。为了分类的需要,Quartus II 综合器需要有一个条件落入两个类别之一。它可以指向一个单独的边界标识符(以匹配posedge事件)或它的补语(以匹配negedge事件),例如, rst1, !rst1, rst1 == 1'b1, rst1 == 1'b0。它也可以是OR两个或更多的表达式,其中每一个指向一个单独的边界标识符或它的补语……
当你的条件测试发现错误极性,或者它测试变量的值,但该值在事件控制中并不是一个边界时,你会接到这个错误。例如,为了匹配一个posedge rst事件,条件必须是rst或rst = 1'b1。