module light(R2,R1,R0,L2,L1,L0,I3,I2,I1,clk);
input clk,I3,I2,I1;
output R2,R1,R0,L2,L1,L0;
wire[2:0] A;
assign A={I3,I2,I1};
reg R2,R1,R0,L2,L1,L0;
reg[2:0] Q;
reg[2:0] state,nextstate;
parameter state0=3'b000,state1=3'b001,
state2=3'b010,state3=3'b011,
state4=3'b100,state5=3'b101,
state6=3'b110,state7=3'b111;
always@(posedge clk)
begin //begin end
state<=nextstate;
end
always@(state)
begin
case(state)
state0:begin nextstate<=state1; end
state1:begin nextstate<=state2; end
state2:begin nextstate<=state4; end
state3:begin nextstate<=state6; end
state4:begin nextstate<=state1; end
state5:begin nextstate<=state2; end
state6:begin nextstate<=state4; end
state7:begin nextstate<=state6; end
default:;
endcase
end
always@(state)
begin
case(state)
state1:Q<=3'b110;
state2:Q<=3'b101;
state4:Q<=3'b011;
default Q<=111;
endcase
end
always@(A)
begin
case(A)
3'b000:begin R2=1;R1=1;R0=1;L2=1;L1=1;L0=1;end
3'b010:begin {R2,R1,R0}=Q;L2=1;L1=1;L0=1;end
3'b001:begin R2=1;R1=1;R0=1;{L0,L1,L2}=Q;end
3'b100:begin R2=0;R1=0;R0=0;L2=0;L1=0;L0=0;end
default:;
endcase
end
endmodule
I1,I2,I3是三个按键,R1~3 L1~3分别连发光二极管,低电平亮。想分别按键控制 R循环亮,L循环亮,全亮。状态机是做循环周期为3的唤醒计数器,但是仿真结果如下图,没有出效果,问题出在哪儿?有高手解答。谢谢!
慕容708150