Verilog程序always里有两个敏感参数,用if区分,编译出错

Verilog程序always里有两个敏感参数,用if区分,编译出错
module Procedure(en,load,clr,q,clk);

input en,load,clr,clk;
reg [2:0] q1;
output reg [2:0] q;

always @ (posedge load or posedge clr)
begin
if(en)
begin
if(clr) q1<=3'b000;
else
begin
case(q1)
3'b000:q1<=3'b001;
3'b001:q1<=3'b010;
3'b010:q1<=3'b100;
3'b100:q1<=3'b000;
default q1<=3'b000;
endcase
end
end
end

always @ (posedge clk)
q<=q1;

endmodule

---------------------------------------------------------------------

Error: Verilog HDL Conditional Statement error at Procedure.v(9): cannot match all operands in the condition expression to corresponding edges in the enclosing Always Construct's Event Control

求指教~~
其实你的这个程序在modelsim里面仿真是没有问题的,能够实现你想要的功能。
但是在某些编译环境碰局中,要求,当always的敏感变量为两个或以上时,其中一个可以作为时钟,而另外一个必须出现在always中的第一个if的条件中,否则不能综合蚂禅。在你的程序里,如果always中先对clr信号使用if,之后再在闷吵尘每个情况中判断en是否为高,那么应该就可以通过了。
祝好~
module
......

always @ (posedge clk)
begin
if(en)
begin
if(clr) q<=3'b000;
else
if (信姿迅load)
begin
case(q)
3'b000:q<=3'滑此b001;
3'b001:q<=3'b010;
3'b010:q<=3'b100;
3'b100:q<=3'b000;
default:q<=3'b000;
endcase
end
end

endmodule

begin 。册告。。。end 之类的格式自己去对齐吧。
没有遵循硬件描述的规则,乱用verilog语法。
1、使能信号不谨腊能当时钟信号用
2、default后面要加冒号
3、D触发器一虚态般有差晌源个复位端
← 上一篇: 下一篇: →