|
小弟不才,用三段输出锁存式状态机 写一个序列检测程序,检测101序列。我的状态可能有冗余,暂时不要关心这些~我想问的是,为什么报错,程序如下
module sq_scan (
input dat,clk,rst_n,
output reg led);
parameter S0 = 4'b 0001,
S1 = 4'b 0010,
S2 = 4'b 0100,
S3 = 4'b 1000;
reg [3:0] state,next;
always @(posedge clk or negedge rst_n)
if (!rst_n) state <= S0 ;
else state <= next;
always @(state or dat)begin /Error (10028): Can't resolve multiple constant drivers for net "led" at sq_scan.v(14)
next = 4'bx;
led = 1'b0;
case(state)
S0: if(dat) next = S1;
else next = S0;
S1: if(dat) next = S1;
else next = S2;
S2: if(dat) next = S3;
else next = S0;
S3: if(dat) next = S1;
else next = S2;
endcase
end
always @(posedge clk or negedge rst_n)
if (!rst_n) begin
led <= 1'b0;
end
else begin
case (next)
S0,S1,S2: led <= 1'b0 ;
S3 : led <= 1'b1;
endcase
end
endmodule
程序老是报错,错误已经标注在报错行的后面了。可是我觉得那句always就应该把涉及状态转变的变量都作为敏感变量啊?请大侠指点一二 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|