FSM Files DSD Verilog
FSM Files DSD Verilog
CHAPTER 5 Machines
TEAM DSD @ SCHOOL OF
ELECTRONICS &
COMMUNICATION
CONTENTS
Moore
machine
Moore
machine
SCHOOL OF ELECTRONICS & COMMUNICATION ENGINEERING 6
IS IT MEALY OR MOORE MACHINE?
Mealy machine
Moore
machine
Moore
machine
Mealy
SCHOOL OF ELECTRONICS & COMMUNICATION ENGINEERING 12
STATE ENCODING
Common FSM encoding options:
• One-hot code
• Binary code
• Gray code
• Random code
One-hot encoding
• usually used in FPGA-based designs
S0 0 S1 1 S2 0 S3 1 S4
1
0 0 0 0 1
0
0
always@(posedge clk)
begin
if (reset) cst <= S0;
else cst <= nst;
end
endmodule
SCHOOL OF ELECTRONICS & COMMUNICATION ENGINEERING 17
A 0101 SEQUENCE DETECTOR:
MOORE MACHINE
S2: begin y=1'b0;
if (din == 1'b1) nst = S0;
else nst = S3; end
S3: begin y=1'b0;
if (din == 1'b1) nst = S4;
else nst = S1; end
S4: begin y=1'b1;
if (din == 1'b1) nst = S0;
else nst = S3; end
default: nst = S0;
endcase
end
always@(posedge clk)
begin
Test Bench: if (reset) cst <= S0;
data = 11'b10101001010; else cst <= nst;
end
for (i = 0; i<11; i=i+1)
endmodule
#10 din = data[i];
SCHOOL OF ELECTRONICS & COMMUNICATION ENGINEERING 18
A 0101 SEQUENCE DETECTOR:
MEALY MACHINE
0/0
1/0
0/0
0/0 1/0
S0 S1 S2 S3
1/1
1/0
0/0
Moor
e
Mealy