状态机要写成3段式的(这是最标准的写法),即
……
//build the state
flops
always @(posedge clk or negedge
rst_n)
……
current_state <= next_state;
……
//state machine
always @
(current_state or ...)
……
case(current_state)
……
S1:
if
...
next_state
= S2;
……
……
//outputs logic
block
always @(current_state or …)
//default
value
a = 1’b0;
b = 1’b0;
c = 1’b0;
……
case(current_state)
S1:
a = 1'b0;
S2:
b = 1'b1;
S3:
c = 1'b1;
default:
……
endcase
……