Professional Documents
Culture Documents
FSM Design
Mealy Machines
The FSM should output a 1 when the sequence is detected, and a 0 otherwise.
This is another example of a sequence detector.
Input:
011101011011101
Output:
000100000000100
State Diagram
ECE 331 - Digital Systems Design 6
State Diagram
Output is a function of the present state and the input (Mealy Machine)
8
The choice of Flip-Flop determines the complexity of the combinational logic required in the design of the state machine.
SR Flip-Flop
JK Flip-Flop
Q+ = S + R'.Q
Q+ = J.Q' + K'.Q
D Flip-Flop
T Flip-Flop
Q+ = D
Q+ = T '.Q + T.Q'
10
11
Karnaugh Maps
ECE 331 - Digital Systems Design 12
Karnaugh Maps
ECE 331 - Digital Systems Design 13
Circuit Diagram
ECE 331 - Digital Systems Design 14
15
Q+ +
Excitation Table
16
17
Karnaugh Maps
ECE 331 - Digital Systems Design 18
Circuit Diagram
ECE 331 - Digital Systems Design 19
Input (w): 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1
Output (z): 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0
21
State Diagram
ECE 331 - Digital Systems Design 22
Input (w): 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1
Output (z): 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0
24
State Diagram
ECE 331 - Digital Systems Design 25
Input (w): 0 1 0 0 1 1 0 1 0 1 1 1 0 1 1
Output (z): 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0
27
State Diagram
ECE 331 - Digital Systems Design 28
29
FSMs in VHDL
VHDL does not define a standard method for describing a Finite State Machine. Consequently, there is more than one way to describe a given FSM.
30
FSMs in VHDL
Example #1
31
w = 0
A = 0 z w = 0 w = 0
B = 0 z
w = 1
C = 1 z
w = 1
: IN : OUT
STD_LOGIC ; STD_LOGIC ) ;
33
7 ARCHITECTURE Behavior OF moore IS VHDL compiler automatically 8 TYPE State_type IS (A, B, C) ; determines the correct number 9 SIGNAL y : State_type ; of state flip-flops required. 10 BEGIN 11 PROCESS ( Resetn, Clock ) Sensitivity list 12 BEGIN Reset is asynchronous 13 IF Resetn = '0' THEN 14 y <= A ; 15 ELSIF (Clock'EVENT AND Clock = '1') THEN 16 CASE y IS Positive edge-triggered 17 WHEN A => 18 IF w = '0' THEN 19 y <= A ; 20 ELSE The Case statement describes 21 y <= B ; the behavior of the FSM. 22 END IF ; 23 WHEN B => Each When clause represents 24 IF w = '0' THEN one state in the FSM. 25 y <= A ; 26 ELSE 27 y <= C ; The When clauses correspond 28 END IF ; to the states in the state diagram. 29 WHEN C => 30 IF w = '0' THEN 31 y <= A ; 32 ELSE 33 y <= C ; 34 END IF ; 35 END CASE ; 36 END IF ; 37 END PROCESS ; 38 z <= '1' WHEN y = C ELSE '0' ; Output specified. 39 END Behavior ;
34
FSMs in VHDL
Example #2
35
Reset w = 1 = 0 z w = 0 = 0 z w = 1 = 1 z
w = 0 = 0 z
36
IN OUT
STD_LOGIC ; STD_LOGIC ) ;
37
ARCHITECTURE Behavior OF mealy IS VHDL compiler automatically TYPE State_type IS (A, B) ; determines the correct number SIGNAL y : State_type ; of state flip-flops required. BEGIN PROCESS ( Resetn, Clock ) Sensitivity list BEGIN IF Resetn = '0' THEN Reset is asynchronous y represents the y <= A ; state flip-flops ELSIF (Clock'EVENT AND Clock = '1') THEN CASE y IS WHEN A => Positive edge-triggered Process statement IF w = '0' THEN y <= A ; describes the FSM ELSE y <= B ; as a sequential circuit. END IF ; This Case statement describes WHEN B => the behavior of the FSM. IF w = '0' THEN y <= A ; ELSE y <= B ; END IF ; END CASE ; END IF ; END PROCESS ;
PROCESS ( y, w ) BEGIN CASE y IS WHEN A => Why is the output z <= '0' ; described in a separate WHEN B => Process statement? z <= w ; END CASE ; END PROCESS ; END Behavior ;
38
Acknowledgments
The slides used in this lecture were taken, with permission, from those provided by McGraw-Hill for Fundamentals of Digital Logic with VHDL Design (3rd Edition). They are the property of and are copyrighted by McGraw-Hill Higher Education.
39