P
Paul Marciano
Guest
Hi, another dumb question:
Text books describe Mealy and Moore state machines and all academic
examples I've seen use explicit next_state registers with a construct
similar to:
always @(posedge clk)
state <= next_state;
However, all real verilog I've seen uses a single state register,
assigned in contexts such as:
reg [...] state;
always @(...)
case (state)
`STATE_1: begin
if (foo)
begin
outputs <= values;
state <= `STATE_2;
end
...
end
`STATE_2: begin
if (bar)
begin
outputs <= values;
state <= `STATE_3;
end
...
end
....
endcase
Is there a preferred real-world style to state machine coding, or is it
just down to the engineer?
(yes, this is a really really dumb question - please humor me)
Thanks,
Paul.
Text books describe Mealy and Moore state machines and all academic
examples I've seen use explicit next_state registers with a construct
similar to:
always @(posedge clk)
state <= next_state;
However, all real verilog I've seen uses a single state register,
assigned in contexts such as:
reg [...] state;
always @(...)
case (state)
`STATE_1: begin
if (foo)
begin
outputs <= values;
state <= `STATE_2;
end
...
end
`STATE_2: begin
if (bar)
begin
outputs <= values;
state <= `STATE_3;
end
...
end
....
endcase
Is there a preferred real-world style to state machine coding, or is it
just down to the engineer?
(yes, this is a really really dumb question - please humor me)
Thanks,
Paul.