lecture 8 finite state machines
play

Lecture 8: Finite State Machines And Sequential circuit Design - PowerPoint PPT Presentation

Lecture 8: Finite State Machines And Sequential circuit Design CSE 140: Components and Design Techniques for Digital Systems Diba Mirza Dept. of Computer Science and Engineering 1 University of California, San Diego Generalized Model of


  1. Lecture 8: Finite State Machines And Sequential circuit Design CSE 140: Components and Design Techniques for Digital Systems Diba Mirza Dept. of Computer Science and Engineering 1 University of California, San Diego

  2. Generalized Model of Sequential Circuits Y X S(t) CLK 2

  3. Canonical Form: Mealy and Moore Machines Mealy Machine: y i (t) = f i (X(t), S(t)) Moore Machine: y i (t) = f i (S(t)) s i (t+1) = g i (X(t), S(t)) x(t) x(t) y(t) y(t) C1 C2 C1 C2 CLK CLK S(t) S(t) Moore Machine Mealy Machine 3

  4. Differences in State Diagram: Mealy vs. Moore Machines x(t) x(t) y(t) C1 C2 y(t) C1 C2 CLK CLK S(t) S(t) Moore Machine Mealy Machine 4

  5. This Counter Design Is: A. Moore machine B. Mealy machine C. None of the above OUT1 OUT2 OUT3 D Q D Q D Q CLK "1"

  6. Life on Mars? Mars rover has a binary input x. When it receives the input sequence x(t-2, t) = 001 from its life detection sensors, it means that the it has detected life on Mars J and the output y(t) = 1, otherwise y(t) = 0 (no life on Mars L ). Implement the Life-on-Mars Pattern Recognizer! This pattern recognizer should have A. One state because it has one output B. One state because it has one input C. Two states because the input can be 0 or 1 D. More than two states because …. E. None of the above 6

  7. Life on Mars? Mars rover has a binary input x. When it receives the input sequence x(t-2, t) = 001 from its life detection sensors, it means that the it has detected life on Mars J and the output y(t) = 1, otherwise y(t) = 0 (no life on Mars L ). 7

  8. Mars Life Recognizer FSM Which of the following diagrams is a correct Mealy solution for the 001 pattern recognizer on the Mars rover? 1/1 A. 1/0 0/0 0/0 S1 S0 S2 0/0 1/0 B. 0/0 1/0 0/0 1/1 S0 S1 S2 1/0 C. Both A and B are correct 0/0 8 D. None of the above

  9. Mars Life Recognizer FFs Pattern Recognizer ‘001’ x(t) 1/1 1/0 y(t) C1 C2 0/0 0/0 S0 S1 S2 0/0 CLK S(t) 1/0 Mealy Machine What does state table need to show to design controls of C1? A. (current input x(t), current state S(t) vs. next state, S(t+1)) B. (current input, current state vs. current output y(t)) C. (current input, current state vs. current output, next state) D. None of the above 9

  10. State Diagram => State Table with State Assignment x(t) 1/1 1/0 y(t) C1 C2 0/0 0/0 S0 S1 S2 0/0 CLK S(t) 1/0 Mealy Machine State Assignment S(t)\x 0 1 S(t)\x 0 1 S0: 00 S0 S1,0 S0,0 00 01,0 00,0 S1: 01 01 10,0 00,0 S1 S2,0 S0,0 S2: 10 10 10,0 00,1 S2 S2,0 S0,1 Q 1 (t+1)Q 0 (t+1), y 10

  11. State Diagram => State Table => Excitation Table => Circuit id Q 1 Q 0 x D 1 D 0 y Q 1 (t) Q 0 (t)\x 0 1 00 01,0 00,0 000 0 0 1 0 01 10,0 00,0 001 1 0 0 0 10 10,0 00,1 010 2 1 0 0 011 x(t) 3 0 0 0 100 4 1 0 0 y(t) C1 C2 101 5 0 0 1 CLK 110 6 X X X S(t) Mealy Machine 111 7 X X X 11

  12. State Diagram => State Table => Excitation Table => Circuit Q 0 id Q 1 Q 0 x D 1 D 0 y D 1 (t): 0 2 6 4 000 0 0 1 0 0 1 X 1 001 1 3 7 5 1 0 0 0 0 0 X 0 x(t) 010 2 1 0 0 Q 1 011 3 0 0 0 D 1 (t) = x’Q 0 + x’Q 1 100 4 1 0 0 D 0 (t)= Q’ 1 Q’ 0 x’ 101 5 0 0 1 y= Q 1 x 110 6 X X X 111 7 X X X 12

  13. State Diagram => State Table => Excitation Table => Circuit Q’ 1 Q 0 D 0 Q Q’ 0 D x’ Q’ Q 1 y x’ D 1 Q D Q 0 Q’ Q 1 x x(t) y(t) C1 C2 D 1 (t) = x’Q 0 + x’Q 1 D 0 (t)= Q’ 1 Q’ 0 x’ CLK y= Q 1 x S(t) Mealy Machine 13

  14. Moore FSM for the Mars Life Recognizer Which of the following diagrams is a correct Moore solution to the ‘001’ pattern recognizer? 1/1 1/0 A. 0/0 0/0 S0 S1 S2 0/0 B. 1/0 1 0 1 1 0 0 S0 S1 S2 S3 0 0 0 1 1 0 C. Both A and B are correct 14 D. None of the above

  15. Moore Mars Life Recognizer: FF Input Specs Pattern Recognizer ‘001’ x(t) y(t) C1 C2 1 0 1 1 0 0 S0 S1 S2 S3 CLK 0 0 0 1 S(t) 1 0 Moore Machine What does state table need to show to design controls of C2? A. (current input x(t), current state S(t) vs. next state, S(t+1)) B. (current input, current state vs. current output y(t)) C. (current state vs. current output y(t) and next state) D. (current state vs. current output y(t) ) E. None of the above 15

  16. Moore Mars Life Recognizer: State Table 1 0 1 1 0 0 S0 S1 S2 S3 0 0 0 1 1 0 ID Q 1 Q 0 x D 1 D 0 y S(t)\x 0 1 000 0 0 1 0 S0 S1,0 S0,0 001 1 0 0 0 S1 S2,0 S0,0 S2 S2,0 S3,0 010 2 1 0 0 S3 S1,1 S0,1 011 3 0 0 0 Q 1 Q 0 \x 0 1 100 4 1 0 0 00 01,0 00,0 101 5 1 1 0 01 10,0 00,0 110 6 0 1 1 10 10,0 11,0 11 01,1 00,1 111 7 0 0 1 Q 1 (t+1)Q 0 (t+1), y

  17. Mars Life Recognizer: Combinational Circuit Design Q 0 D 1 (t): 0 2 6 4 0 1 0 1 1 3 7 5 0 0 0 1 x(t) id Q 1 Q 0 x D 1 D 0 y Q 1 000 0 0 1 0 Q 0 D 0 (t): 001 1 0 0 0 0 2 6 4 1 0 1 0 010 2 1 0 0 1 3 7 5 0 0 0 1 011 3 0 0 0 x(t) 100 Q 1 4 1 0 0 Q 0 y(t): 101 5 1 1 0 0 2 6 4 0 0 1 0 110 6 0 1 1 1 3 7 5 0 0 1 0 111 7 0 0 1 x(t) Q 1

  18. Mars Life Recognizer Circuit Implementation State Diagram => State Table => Excitation Table => Circuit Q 0 D 0 y Q D Q’ Q 1 D 1 Q D Q’ x(t) y(t) C1 C2 D 1 (t)= Q 1 (t)Q 0 (t)’+Q 1 (t)’Q 0 (t) x(t) D 0 (t)= Q 1 (t)’Q 0 (t)’x(t)’+ CLK Q 1 (t)Q 0 (t) x(t)’+Q 1 (t)Q 0 (t)’ x(t) S(t) y(t)= Q 1 (t)Q 0 (t) Moore Machine 18

  19. FSM Specification x(t) Q D Q’ Q 0 (t) Q Q 0 (t) D Q’ Q 1 (t) y(t) Q 1 (t) CLK 19

  20. From circuit to FSM x(t) Q D Q’ Q 0 (t) Q y(t) Q 0 (t) D Q’ Q 1 (t) Q 1 (t) CLK y(t) = Q 1 (t)Q 0 (t) Q 0 (t+1) = D 0 (t) = x(t)’ Q 0 (t)’ Q 1 (t+1) = D 1 (t) = x(t)’(Q 0 (t) + Q 1 (t)) 20

  21. Netlist ó State Table ó State Diagram ó Input Output Relation Characteristic Expression: y(t) = Q 1 (t)Q 0 (t) Q 0 (t+1) = D 0 (t) = x(t)’ Q 0 (t)’ Q 1 (t+1) = D 1 (t) = x(t)’(Q 0 (t) + Q 1 (t)) State table input x=0 x=1 PS 0 0 0 1 1 0 1 1 Q 1 (t) Q 0 (t) | (Q 1 (t+1) Q 0 (t+1), y(t)) Present State | Next State, Output 21

  22. Netlist ó State Table ó State Diagram ó Input Output Relation y(t) = Q 1 (t)Q 0 (t) Q 0 (t+1) = D 0 (t) = x(t)’ Q 0 (t)’ Q 1 (t+1) = D 1 (t) = x(t)’(Q 0 (t) + Q 1 (t)) State table State Assignment input input x=0 x=1 PS x=0 x=1 Let: PS S 0 = 00 S 1 , 0 S 0 , 0 S 0 0 0 01, 0 00, 0 S 1 = 01 S 2 , 0 S 0 , 0 S 1 0 1 10, 0 00, 0 S 2 = 10 S 3 , 0 S 0 , 0 S 2 1 0 11, 0 00, 0 S 3 = 11 S 0 , 1 S 0 , 1 S 3 1 1 00, 1 00, 1 Q 1 (t) Q 0 (t) | Q 1 (t+1) Q 0 (t+1), y(t) Remake the state table using symbols Present State | Next State, Output instead of binary code , e.g. ’00’ 22

  23. Netlist ó State Table ó State Diagram ó Input Output Relation input x=0 x=1 PS S 2 S 3 S 0 S 1 S 1 , 0 S 0 , 0 S 0 S 2 , 0 S 0 , 0 S 1 S 3 , 0 S 0 , 0 S 2 S 0 , 1 S 0 , 1 S 3 23

  24. Netlist ó State Table ó State Diagram ó Input Output Relation x/y 1 input 1 x=0 x=1 1 PS S 2 S 3 S 0 S 1 S 0 S 1 , 0 S 0 , 0 0 0 0 0 1 0 0 S 1 S 2 , 0 S 0 , 0 S 2 S 3 , 0 S 0 , 0 (0 or 1) S 3 S 0 , 1 S 0 , 1 Example: Given inputs and initial state, derive output sequence Time 0 1 2 3 4 5 Input 0 1 0 0 0 - State S0 S1 S0 S1 S2 S3 Output 0 0 0 0 0 1 24

  25. Finite State Machine Example • Traffic light controller – Traffic sensors: T A , T B (TRUE when there’s traffic) – Lights: L A , L B Bravado Dining Hall L B L A T B L A Academic Ave. T A T A Dorms L B T B Labs Blvd. Fields 25

  26. FSM Black Box • Inputs: CLK , Reset , T A , T B • Outputs: L A , L B CLK Traffic T A L A Light T B L B Controller Reset 26

  27. FSM State Transition Diagram • Moore FSM: outputs labeled in each state Bravado Dining • States: Circles Hall L B • Transitions: Arcs L A T B L A Reset Academic Ave. T A T A S0 Dorms L B T B Labs L A : green L B : red Blvd. Fields 27

  28. FSM State Transition Diagram Bravado Dining Hall • Moore FSM: outputs labeled in each state L B L A T B L A Academic Ave. T A T A Dorms L B T B Labs Blvd. T A Fields Reset T A S0 S1 L A : green L A : yellow Which of the following is true about L B : red L B : red the controller? A. The traffic light on Academic Ave (L A ) remains green as long as there is traffic on that street B. The traffic light on both avenues are green for exactly once clock S3 S2 cycle in every four clock cycles L A : red L A : red L B : yellow L B : green T B T B 28

Recommend


More recommend