C
Chih-Hsu Yen
Guest
Typically, the text book told to program a FSM as follows:
always @( posedge clk )
begin
if ( reset )
cur_state <= S0;
else
cur_state <= next_state;
end
always @( cur_state or ..... )
begin
case ( cur_state )
S0: begin statement1; next_state = S1; end
S1: begin statement2; next_state = S2; end
.
.
.
endcase
end
However, if there have feedback assignments in next_state combination, e.g.,
enable = ~ enable, counter = counter + 1.
Could the FSM be programed as follows or have others alternative ways to
solve the combinational loop problems??
always @( reset or next_state )
begin
if ( reset )
cur_state <= S0;
else
cur_state <= next_state;
end
always @( posedge clk )
begin
case ( cur_state )
S0: begin statement1; next_state = S1; end
S1: begin statement2; next_state = S2; end
.
.
.
endcase
end
always @( posedge clk )
begin
if ( reset )
cur_state <= S0;
else
cur_state <= next_state;
end
always @( cur_state or ..... )
begin
case ( cur_state )
S0: begin statement1; next_state = S1; end
S1: begin statement2; next_state = S2; end
.
.
.
endcase
end
However, if there have feedback assignments in next_state combination, e.g.,
enable = ~ enable, counter = counter + 1.
Could the FSM be programed as follows or have others alternative ways to
solve the combinational loop problems??
always @( reset or next_state )
begin
if ( reset )
cur_state <= S0;
else
cur_state <= next_state;
end
always @( posedge clk )
begin
case ( cur_state )
S0: begin statement1; next_state = S1; end
S1: begin statement2; next_state = S2; end
.
.
.
endcase
end