input N,D,G10,G15,Return;
output [3:0] LED;
reg [3:0] LED;
reg [1:0] STATE;
initial LED = 4'b0001;
parameter S0 = 2'b00, S1=2'b01, S2=2'b10, S3=2'b11;
always@(posedge N)
begin
case(STATE)
S0 : STATE = S1;
S1 : STATE = S2;
S2 : STATE = S3;
S3 : STATE = S3;
default:STATE = S0;
endcase
end
always@(posedge D)
begin
case(STATE)
S0 : STATE = S2;
S1 : STATE = S3;
S2 : STATE = S2;
S3 : STATE = S3;
endcase
end
always@(posedge G10)
begin
case(STATE)
S0 : STATE = S0;
S1 : STATE = S1;
S2 : STATE = S0;
S3 : STATE = S1;
endcase
end
always@(posedge G15)
begin
case(STATE)
S0 : STATE = S0;
S1 : STATE = S1;
S2 : STATE = S2;
S3 : STATE = S0;
endcase
end
always@(posedge Return)
begin
case(STATE)
S0 : STATE = S0;
S1 : STATE = S0;
S2 : STATE = S0;
S3 : STATE = S0;
endcase
end
always@(STATE)
begin
case(STATE)
S0 : LED <= 4'b0001;
S1 : LED <= 4'b0010;
S2 : LED <= 4'b0100;
S3 : LED <= 4'b1000;
default:LED <= 4'b0001;
endcase
end
마이크로 프로세서 하다보면 하게되는 스테이트머신중에 자판기 구문인데요
N 넣으면 스테이트 하나올리고 D넣으면 2개올리고 초과하는것에 대해서는 신경쓰지않구요
잘 돌아가는것처럼 보이는데 문제가 처음 N이 들어갈때 LED가 0010이 되야되는데 무반응... 뒤에 N에는 되는데 앞에껀 왜그럴까요..