EECS 465 Digital Systems Lecture Notes 5 Sequential





![Reset State=0 Even 0 0/0 Reset State=0 Even [0] 1/1 1/0 1 1 State=1 Reset State=0 Even 0 0/0 Reset State=0 Even [0] 1/1 1/0 1 1 State=1](https://slidetodoc.com/presentation_image/799dc0d638ac495c7672d5228ad4be36/image-6.jpg)

















- Slides: 23
EECS 465: Digital Systems Lecture Notes # 5 Sequential Circuit (Finite-State Machine) Design SHANTANU DUTT Department of Electrical Engineering and Computer Science University of Illinois, Chicago Phone: (312) 355 -1314: e-mail: dutt@eecs. uic. edu URL: http: //www. eecs. uic. edu/~dutt 1
Finite State Machine (FSM) Design • FSMs are different from counters in the sense that they have external I/Ps, and state transitions are dependent on these I/Ps and the current state. • Example : Problem Statement There is a bit-serial I/P line. Design an FSM that outputs a ‘ 0’ if an even # of 1’s have been received on the I/P line and the outputs a ‘ 1’ otherwise. Note : If a synchronous sequential circuit is being designed, the counting of the # of 1 s occur every clock cycle. x O/p y FSM CLK x # of 1 s even (0) odd (1) even (2) odd (3) 2
• First determine the # of useful information classes required to solve the problem. • In this case, only 2 classes of information is required: whether an even # of 1 s have been received, or an odd # of 1 s have been received Solution 1: (Mealy) Solution 2: (Moore) 0 0/0 Reset Even Transition Arc Input 1/1 1/0 Odd Reset Output Even Output [0] O/P is dependent on current state and input in Mealy 0/1 Mealy Machine: Output is associated with the state transition, and appears before the state transition is completed (by the next clock pulse). 1 1 Odd [1] 0 Input Output is dependent only on current state Moore Machine: Output is associated with the state and hence appears after the state transition take place. 3
External I/Ps External O/Ps m 1 Comb. Logic n m 2 FFs Output Logic m 2 CLK t+ FFs n CLK External Outputs Moore Machine Model Mealy Machine Model t Next State Comb. Logic n even odd n Time t : Even I/P External I/Ps m 1 = propagation delay of logic of Mealy M/C t+TCLK+ 2 Even Odd O/P=1 x=1 (Moore) (Mealy) O/P=0 2 = propagation delay of O/P logic unit of Moore M/C 4
State Transition Table (Even-Parity Checker) Even State: 0 ; Odd State: 1; Next State Present State Input A x A+ 0 0 1 1 0 1 0 1 1 0 Input variables to comb. logic DA= A x ; TA= x y 1 = A for Moore y 2 = A x for Mealy State Variable A Mealy O/P Moore O/P y 1 y 2 0 0 1 1 D-FF Excit. T-FF Excit. DA 0 1 1 0 TA 0 1 1 0 0 1 Output functions y 2 x N. S. & O/P Logic Q A FF x N. S. Logic Or Q DA CLK A O/P Logic FFs DA y 1 5
Reset State=0 Even 0 0/0 Reset State=0 Even [0] 1/1 1/0 1 1 State=1 Odd N. S. Logic x State=1 Odd [1] Q 0/1 Q Mealy 0 D- FF D Moore CLK S. T. is complete. Assume single bit state information stored in a D-FF State Transition is occurring CLK S. T. is complete. x D even Q (state) y 2 (Mealy O/P) y 1 Moore O/P) odd even odd 6
Moore M/C Implementation a) D-FF 0 D x=1 Q R CLK A y 2 b) T-FF x T CLK Q Q R A y 2 Q Reset Moore O/P is synchronized with clock. Mealy M/C Implementation y 1 0 1 D x=1 CLK Q R A x T CLK R Q Reset a) D-FF Q y 1 Q Reset b) T-FF Mealy O/P is not synchronized with clock. 7
Difference Between Mealy and Moore Machine (1) (2) (3) (4) Mealy O/Ps depend on the present state and present I/Ps The O/P change asyn -chronously with the enabling clock edge A counter is not a Mealy machine A Mealy machine will have the same # or fewer states than a Moore machine Moore O/Ps depend only on the present state Since the O/Ps change when the state changes, and the state change is synchronous with the enabling clock edge, O/Ps change synchronously with this clock edge A counter is a Moore machine 8
Another example: A simple vending machine Here is how the control is supposed to work. The vending machine delivers a package of gum after it has received 15 cents in coins. The machine has a single coin slot that accepts nickels and dimes, one coin at a time. A mechanical sensor indicates to the control whether a dime or a nickel has been inserted into the coin slot. The controller’s output causes a single package of gum to be released down a chute to the customer. One further specification: We will design our machine so it does not give change. A customer who pays with two dimes is out 5 cents! Coin Sensor Reset Vending Machine FSM Open Gum Release Mechanism CLK Vending Machine block diagram States: 0 C 5 C 10 C 15 C 9
— The figure below show the Moore and Mealy machine state transition diagrams. Reset / 0 Reset 0 cent [0] Reset / 0 5 cent [0] N 10 cent [0] N+D 15 cent [1] Moore machine 0 cent N/0 N D Reset )/0 D 5 cent D/0 D/1 N/0 10 cent N+D/1 15 cent Mealy machine Moore and Mealy machine state diagrams for the vending machine FSM 10
—State transition table for Moore and Mealy M/C. (Next state also gives D-FF excitation). Present State Q 1 Q 2 0 0 0 1 1 Inputs Next State D 0 0 1 1 Q 1 + Q 2 + 0 0 0 1 1 0 x x 0 1 1 x x 1 1 1 x x N 0 1 0 1 Moore Output Mealy Output Open 0 0 0 x 1 1 1 x Open 0 0 0 x 0 0 1 x 0 1 1 x 1 1 1 x Encoded vending machine state transition table. Q+ = D Q Q+ 0 0 0 1 1 D 0 1 11
Implementation using D-FFs Q 1 Q 0 00 01 11 10 00 0 0 1 1 01 0 1 1 11 x x 10 1 1 DN Q 1 Q 0 00 01 11 10 00 0 1 1 01 1 0 1 x x 1 1 10 0 1 K-map for D 1 DN Q 1 Q 0 00 01 11 10 00 0 0 1 01 0 0 1 0 x x 11 x x 1 1 10 0 0 1 0 DN K-map for Open (Moore) K-map for D 0 Q 1 Q 0 D 1 = Q 1 + D + Q 0·N Moore OPEN = Q 1·Q 0 + D·Q 1 + N·Q 1 Mealy 00 01 11 10 00 0 0 1 1 DN 11 x x 10 0 1 1 1 K-map for Open (Mealy) 12
Q 1 D Q 0 N D CLK Q R Q 1 Q OPEN Reset N Q 0 D Q 1 N CLK Q R Similarly, a Mealy implementation; only the OPEN function changes. Q 0 Q Reset Q 1 D Vending machine FSM implementation based on D flip-flops(Moore). 13
Implementation using J-K FFS Q 1 Q 2 0 0 J-K Excitation D N Q 1 + Q 2 + J 1 K 1 J 0 K 0 Q Q+ 0 0 0 x 0 1 0 x 1 x 0 0 1 0 1 x 0 1 1 1 x x x 1 0 0 0 1 0 x x 0 1 1 0 1 x x 1 1 0 1 1 1 x x 0 1 1 x x x 1 0 0 0 1 0 x 0 1 1 1 x 0 1 x 1 0 1 1 x 0 1 x 1 1 x x x 1 1 0 0 1 1 x 0 0 1 1 1 x 0 1 0 1 1 x x x Remapped next-state functions for the vending machine example. J 0 1 x x 14 K x x 1 0
Q 1 Q 0 00 01 11 10 00 0 0 x x 01 0 1 x 11 x x 10 1 1 DN Q 1 Q 0 00 01 11 10 00 x x 0 0 x 01 x x 0 0 x x 11 x x x 10 x x 0 0 DN K-map for J 1 Q 1 Q 0 00 DN 00 01 0 1 01 11 K-map for K 1 10 Q 1 Q 0 DN 00 01 11 10 x x 0 00 x 0 0 x x x 1 01 x 1 0 x 11 x x x x 10 0 x x 1 10 x 0 0 x K-map for J 0 K-map for K 0 K-maps for J-K flip-flop implementation of vending machine. J 1 = D + Q 0·N K 1 = 0 15
N Q 0 CLK D J Q K R Q Q 1 OPEN N Q 1 D CLK N J Q K R Q Q 0 Reset J-K flip-flop implementation for the vending machine example (Moore). Similarly, a Mealy implementation; only the OPEN function changes. 16
Basic Steps in the FSM Design Procedure 1. Understand the problem and the different information classes (minimal number) required to solve it. 2. Convert these information classes into distinct states, and determine the state transition diagram of the FSM. 3. Encode states in binary, and obtain state transition table and FF excitation for desired FF type. 4. Minimize the FF input functions (using K-Maps, for example) and implement the FSM using these FFs and logic gates (or MUXes) that implement the FF’s input functions. 17
FSM Word Problem 1: • Design a system that outputs a ‘ 1’ whenever it receives a multiple of 3 # of 1’s (i. e. , 0, 3, 6, 9, etc. # of 1’s) on a serial input line x. — Relevant information classes needed to solve the problem: (A) A multiple of 3 # is received. (B) A non-multiple of 3 # is received. Questions to consider: (1) How do we go from (A) (B) Ans. : If a ‘ 1’ is received (2) How do we go from (B) (A) Ans. : Not clear. Need to split up (B) further into (B 1): 3 y+1 # of 1’s received. Where y is an integer 0. (B 2): 3 y+2 # of 1’s received. 18
Note: (A): is 3 y+0 = 3 y # of 1’s received. • Now the transitions between the 3 classes of information is clear: (A) (B 1) (B 2) (A) 1 received • Hence these classes of information can be considered states of the required as states of the required FSM: These 3 states can be represented by 3 y+I, i = 0, 1, 2 00 Reset 0/1 i=0 Output Input 0 Reset i=0 [1] 0/0 1/1 10 01 i=1 1/0 i=2 0/0 Mealy Machine 1 1 0 i=1 [0] i=2 [0] 1 0 19 Moore Machine
FSM Word Problem 2: • Design a system that outputs a ‘ 1’ whenever it receives: (a) A multiple of 3 # of 1’s AND (b) A non-zero even # of 0’s # of 1’s E. g. , ((0, 2) , (3, 4) , (6, 2) , ···) # of 0’s — Relevant classes of information: - For # of 1’s: 3 y+i, i = 0, 1, 2 [3 classes] - For # of 0’s: 2 z+j, j = 0, 1 For j = 0, we need to distinguish between zero (z = 0) and non-zero (z > 0) # of 0’s - Thus we have 3 classes: 2 z+0, z = 0 ( 0 ) 2 z+0, z > 0 ( non-zero even ) 2 z+1 ( odd ) 20
The relevant # of 1’s can be represented by i = { 0, 1, 2 } ( # of 1’s = 3 y+i ) — The relevant # of 0’s can be represented by j= { 00 , 0>0 , 1 } ( # of 0’s = 2 z+j ) where the subscript of the 0 indicates whether z=0 or z>0. — Since at any point time, a certain # of 1’s and # of 0’s will have been received, the state of the system will be given by a combination of relevant # of 1’s and # of 0’s. — There are 9 combinations: { 0, 1, 2, } X { 00, 0>0, 1 } = (0, 00), (0, 0>0), (0, 1), (1, 00), (1, 0>0), (1, 1), (2, 00), (2, 0>0), (2, 1) # of 1’s # of 0’s Cartesian Product 21
(0, 00) (0, 0>0) (1, 00) (0, 1) (2, 00) (1, 1) (2, 1) (1, 0>0) (2, 0>0) 22
Note: 0>0 2 z+j, j = 0 z>0 Reset (0, 00) 1/0 0/0 1/0 (0, 0>0) (1, 00) 1/0 0/0 0/1 1/0 (0, 1) (2, 00) 0/0 1/0 (1, 1) 0/0 1/0 0/0 (2, 1) (1, 0>0) 0/0 1/1 1/0 0/0 (2, 0>0) 1/0 23