Verilog Structural View of a FSM
module FSM (CLK, in, out); input CLK; input in; output out; reg out; // state variable reg [1:0] state; // local variable reg [1:0] next_state; always @(posedge CLK) // registers state = next_state;
always @(state or in) // Compute next-state and output logic whenever state or inputs change. // (i.e. put equations here for next_state[1:0]) // Make sure every local variable has an assignment in this block!endmodule
General view of a finite state machine in verilog