The Moore state machine is a finite state machine whose output values depend on the current state.
The Moore state machine output will have the n+1 states for n inputs. For example, if the input has 2 states then it will produce 3 output states.
THE MOORE STATE MACHINE OF 11:
The Moore state machine for 11. It has three states S0, S1, S2. The output will be '1' when it enters to state S2 and the remaining state outputs are '0'.
// The inputs and outputs are declared here
module moore_sequence_11(input CLK,RST,DIN, output reg DOUT);
parameter [1:0]S0 = 2'b00;
parameter [1:0]S1 = 2'b01;
parameter [1:0]S2 = 2'b10;
reg [1:0]PS;
reg [1:0]NS;
// Moore state machine is designed using asynchronous
always @(posedge CLK or negedge RST)
begin
if(RST)
PS <= S0;
else
PS <= NS;
end
always @(PS, DIN)
begin
case(PS)
// For the state S0
S0:if(DIN)
begin
NS = S1;
DOUT = 1'b0;
end
else
begin
NS = S0;
DOUT = 1'b0;
end
// For the state S1
S1:if(DIN)
begin
NS = S2;
DOUT = 1'b0;
end
else
begin
NS = S0;
DOUT = 1'b0;
end
// For the state S2
S2:if(DIN)
begin
NS = S1;
DOUT = 1'b1;
end
else
begin
NS = S0;
DOUT = 1'b1;
end
endcase
end
endmodule
OUTPUT WAVEFORM:
The output values are tested by forcing the input manually.
when the CLK input is high, rst is low, and based on din the output will be high. When the rst pin is high the output will be zero.
The input is given as 0,0,1,1,1,0.