dld lecture 26 finite state machine design procedure
TRANSCRIPT
![Page 1: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/1.jpg)
DLDLecture 26
Finite State Machine Design Procedure
![Page 2: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/2.jpg)
Overview
° Design of systems that input flip flops and combinational logic
° Specifications start with a word description
° Create a state table to indicate next states
° Convert next states and outputs to output and flip flop input equations
• Reduce logic expressions using truth tables
° Draw resulting circuits.
![Page 3: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/3.jpg)
Concept of the State MachineComputer Hardware = Datapath + Control
RegistersCombinational Functional Units (e.g., ALU)Busses
FSM generating sequencesof control signals Instructs datapath what to do next
Qualifiers
Control
Control
Datapath
State
ControlSignalOutputs
QualifiersandInputs
![Page 4: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/4.jpg)
CombinationalLogic
Storage Elements
Outputs
State OutputsState Inputs
Inputs
°Divide circuit into combinational logic and state°Localize feedback loops and make it easy to break cycles°Implementation of storage elements leads to various forms of sequential logic
Concept of the State Machine
![Page 5: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/5.jpg)
Designing Finite State Machines
° Specify the problem with words
° (e.g. Design a circuit that detects three consecutive 1 inputs)
° Assign binary values to states
° Develop a state table
° Use K-maps to simplify expressions
° Flip flop input equations and output equations
° Create appropriate logic diagram
° Should include combinational logic and flip flops
![Page 6: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/6.jpg)
Example: Detect 3 Consecutive 1 inputs
° State S0 : zero 1s detected
° State S1 : one 1 detected
° State S2 : two 1s detected
° State S3 : three 1s detected
0
° Note that each state has 2 output arrows
° Two bits needed to encode state
![Page 7: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/7.jpg)
State Table for Sequence Detector
° Sequence of outputs, inputs, and flip flop states enumerated in state table
° Present state indicates current value of flip flops
° Next state indicates state after next rising clock edge
° Output is output value on current clock edge
Present State
Next State
A B x A B y
0 0 0 0 0 0
0 0 1 0 1 00 1 0 0 0 00 1 1 1 0 01 0 0 0 0 0
1 0 1 1 1 01 1 0 0 0 11 1 1 1 1 1
OutputInput
° S0 = 00
° S1 = 01
° S2 = 10
° S3 = 11
![Page 8: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/8.jpg)
Finding Expressions for Next State and Output Value° Create K-map directly from state table (3
columns = 3 K-maps)
° Minimize K-maps to find SOP representations
° Separate circuit for each next state and output value
![Page 9: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/9.jpg)
Circuit for Consecutive 1s Detector
° Note location of state flip flops
° Output value (y) is function of state
° This is a Moore machine.
![Page 10: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/10.jpg)
![Page 11: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/11.jpg)
Concept of the State Machine
Example: Odd Parity Checker
Even [0]
Odd [1]
Reset
0
0
1 1
Assert output whenever input bit stream has odd # of 1's
StateDiagram
Present State Even Even Odd Odd
Input 0 1 0 1
Next State Even Odd Odd Even
Output 0 0 1 1
Symbolic State Transition Table
Output 0 0 1 1
Next State 0 1 1 0
Input 0 1 0 1
Present State 0 0 1 1
Encoded State Transition Table
° Note: Present state and output are the same value
° Moore machine
![Page 12: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/12.jpg)
Concept of the State Machine
Example: Odd Parity Checker
Next State/Output Functions
NS = PS xor PI; OUT = PS
D FF Implementation
Timing Behavior: Input 1 0 0 1 1 0 1 0 1 1 1 0
Clk
Output
Input 1 0 0 1 1 0 1 0 1 1 1 0
1 1 0 1 0 0 1 1 0 1 1 1
NSPS
PI
![Page 13: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/13.jpg)
Concept of the State Machine
Example: Odd Parity Checker
Next State/Output Functions
NS = PS xor PI; OUT = PS
D
R
Q
Q
Input
CLK PS/Output
\Reset
NS
D FF Implementation
Timing Behavior: Input 1 0 0 1 1 0 1 0 1 1 1 0
Clk
Output
Input 1 0 0 1 1 0 1 0 1 1 1 0
1 1 0 1 0 0 1 1 0 1 1 1
NSPS
PI
![Page 14: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/14.jpg)
Mealy and Moore Machines
Solution 1: (Mealy)0/0
Even
Odd
1/11/0
0/1
0Even
11
0
Reset[0]
Odd [1]
Output
InputOutput
Input
Transition Arc
Output is dependent only on current state
O/P is dependenton current state andinput in Mealy
Solution 2: (Moore)
Mealy Machine: Output is associated with the state transition- Appears before the state transition is completed (by the next clock pulse).
Moore Machine: Output is associatedwith the state-Appears after the state transition takes place.
![Page 15: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/15.jpg)
Vending Machine FSM
Step 1. Specify the problemStep 1. Specify the problemStep 1. Specify the problemStep 1. Specify the problem
Deliver package of gum after 15 cents deposited
Single coin slot for dimes, nickels
No change
Design the FSM using combinational logic and flip flops
![Page 16: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/16.jpg)
![Page 17: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/17.jpg)
Vending Machine FSM
State DiagramState DiagramState DiagramState Diagram
Reuse statesReuse stateswhenever possiblewhenever possible
Reuse statesReuse stateswhenever possiblewhenever possible
Symbolic State TableSymbolic State Table
![Page 18: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/18.jpg)
Vending Machine FSM
State EncodingState EncodingState EncodingState Encoding How many flip-flops are needed?
![Page 19: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/19.jpg)
Vending Machine FSM
Determine F/F implementationDetermine F/F implementationDetermine F/F implementationDetermine F/F implementation
K-map for OpenK-map for D0 K-map for D1
Q1 Q0D N
Q1
Q0
D
N
Q1 Q0D N
Q1
Q0
D
N
Q1 Q0D N
Q1
Q0
D
N
![Page 20: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/20.jpg)
D Q
QR
D Q
QR
Q0
N
N
Q0
Q1
N
Q1
D
D0
D1 Q1
OPEN
D
0Q
NCLK
CLK
Vending machine FSM implementation based on D flip-flops(Moore).
0Q
1Q
Q1
Q0
Reset
Reset
Minimized Implementation
![Page 21: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/21.jpg)
![Page 22: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/22.jpg)
Count Sequence Design Procedure
Complex Count Sequence
Step 1: Derive the State Transition DiagramCount sequence: 000, 010, 011, 101, 110
![Page 23: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/23.jpg)
More Complex Count Sequence
Design Procedure
![Page 24: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/24.jpg)
Complex Count Sequence
Design Procedure
![Page 25: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/25.jpg)
Complex Count Sequence
Design Procedure
![Page 26: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/26.jpg)
Design Procedure
Complex Count Sequence
![Page 27: DLD Lecture 26 Finite State Machine Design Procedure](https://reader034.vdocument.in/reader034/viewer/2022052414/56649f445503460f94c64bb7/html5/thumbnails/27.jpg)
Design Procedure
Complex Count Sequence