finite state machine fsm
play

Finite State Machine (FSM) Consists of: CLK State register S S - PowerPoint PPT Presentation

Finite State Machine (FSM) Consists of: CLK State register S S Next Current Stores current state State State Loads next state at clock edge Combinational logic Computes the next state Computes the outputs Next


  1. Finite State Machine (FSM) • Consists of: CLK – State register S’ S Next Current • Stores current state State State • Loads next state at clock edge – Combinational logic • Computes the next state • Computes the outputs Next State Output Logic Logic C Next C L L Outputs State Chapter 3 <41>

  2. Finite State Machines (FSMs) • Next state determined by current state and inputs • Two types of finite state machines differ in output logic: – Moore FSM: outputs depend only on current state – Mealy FSM: outputs depend on current state and inputs Moore FSM CLK next M k k N next state output inputs state outputs state logic logic Mealy FSM CLK M next k k N next output inputs state state outputs state logic logic Chapter 3 <42>

  3. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <43>

  4. FSM 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 Chapter 3 <44>

  5. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <45>

  6. FSM Black Box • Inputs: CLK , Reset , T A , T B • Outputs: L A , L B CLK Note: multiple bits for output Traffic T A L A Light T B L B Controller Reset Chapter 3 <46>

  7. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <47>

  8. FSM State Transition Diagram • Moore FSM: outputs labeled in each state • States: Circles Reset • Transitions: Arcs S0 L A : green L B : red 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 Chapter 3 <48>

  9. FSM State Transition Diagram • Moore FSM: outputs labeled in each state • States: Circles T A Reset • Transitions: Arcs T A S0 S1 L A : green L A : yellow L B : red L B : red Bravado Dining Hall L B L A T B L A Academic Ave. T A T A S3 S2 Dorms L A : red L A : red L B T B Labs L B : yellow L B : green T B Blvd. Fields T B Chapter 3 <49>

  10. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <50>

  11. FSM State Transition Table T A Reset T A S0 S1 L A : green L A : yellow L B : red L B : red Current Next State Inputs State S3 S2 L A : red L A : red L B : yellow L B : green T B T B S T A T B S' S0 0 X S0 1 X S1 X X S2 X 0 S2 X 1 S3 X X Chapter 3 <51>

  12. FSM State Transition Table T A Reset T A S0 S1 L A : green L A : yellow L B : red L B : red Current Next State Inputs State S3 S2 L A : red L A : red L B : yellow L B : green T B T B S T A T B S' S0 0 X S1 S0 1 X S0 S1 X X S2 S2 X 0 S3 S2 X 1 S2 S3 X X S0 Chapter 3 <52>

  13. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <53>

  14. FSM Encoded State Transition Table Current State Inputs Next State S 1 S 0 T A T B S' 1 S' 0 State Encoding 0 0 0 X S0 00 0 0 1 X S1 01 0 1 X X 1 0 X 0 S2 10 1 0 X 1 S3 11 1 1 X X Two bits required for 4 states T A Reset T A S0 S1 L A : green L A : yellow L B : red L B : red S3 S2 L A : red L A : red L B : yellow L B : green T B T B Chapter 3 <54>

  15. FSM Encoded State Transition Table Current State Inputs Next State S 1 S 0 T A T B S' 1 S' 0 State Encoding 0 0 0 X 0 1 S0 00 0 0 1 X 0 0 S1 01 0 1 X X 1 0 1 0 X 0 1 1 S2 10 1 0 X 1 1 0 S3 11 1 1 X X 0 0 Two bits required for 4 states T A S' 1 = S 1  S 0 Reset T A S0 S1 L A : green L A : yellow L B : red L B : red S' 0 = S 1 S 0 T A + S 1 S 0 T B S3 S2 L A : red L A : red L B : yellow L B : green T B T B Chapter 3 <55>

  16. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <56>

  17. FSM Output Table Current State Outputs Output Encoding S 1 S 0 L A 1 L A 0 L B 1 L B 0 green 00 0 0 0 1 yellow 01 1 0 red 10 1 1 Two bits required for 3 outputs T A Reset T A S0 S1 L A : green L A : yellow L B : red L B : red S3 S2 L A : red L A : red L B : yellow L B : green T B T B Chapter 3 <57>

  18. FSM Output Table Current State Outputs Output Encoding S 1 S 0 L A 1 L A 0 L B 1 L B 0 green 00 0 0 0 0 1 0 0 1 0 1 1 0 yellow 01 1 0 1 0 0 0 red 10 1 1 1 0 0 1 Two bits required for 3 outputs L A 1 = S 1 L A 0 = S 1 S 0 T A Reset T A L B 1 = S 1 S0 S1 L A : green L A : yellow L B : red L B : red L B 0 = S 1 S 0 S3 S2 L A : red L A : red L B : yellow L B : green T B T B Chapter 3 <58>

  19. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <59>

  20. FSM Schematic: State Register CLK S' 1 S 1 S' 0 S 0 r Reset state register S' 1 = S 1  S 0 L A 1 = S 1 L B 1 = S 1 S' 0 = S 1 S 0 T A + S 1 S 0 T B L A 0 = S 1 S 0 L B 0 = S 1 S 0 Chapter 3 <60>

  21. FSM Schematic: Next State Logic CLK S' 1 S 1 T A S' 0 S 0 r T B Reset S 1 S 0 inputs next state logic state register S' 1 = S 1  S 0 S' 0 = S 1 S 0 T A + S 1 S 0 T B Chapter 3 <61>

  22. FSM Schematic: Output Logic CLK L A1 S' 1 S 1 L A0 T A S' 0 S 0 L B1 r T B Reset S 1 S 0 L B0 inputs next state logic state register output logic outputs L A 1 = S 1 L B 1 = S 1 L A 0 = S 1 S 0 L B 0 = S 1 S 0 Chapter 3 <62>

  23. FSM Timing Diagram Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10 CLK Reset T A T B S' 1:0 ?? S0 (00) S1 (01) S2 (10) S3 (11) S0 (00) S1 (01) S 1:0 ?? S0 (00) S1 (01) S2 (10) S3 (11) S0 (00) L A1:0 ?? Green (00) Yellow (01) Red (10) Green (00) L B1:0 ?? Red (10) Green (00) Yellow (01) Red (10) t (sec) 0 5 10 15 20 25 30 35 40 45 T A Reset T A S0 S1 L A : green L A : yellow L B : red L B : red S3 S2 L A : red L A : red L B : yellow L B : green T B T B Chapter 3 <63>

  24. FSM State Encoding • Binary encoding: – i.e., for four states, 00, 01, 10, 11 • One-hot encoding – One state bit per state – Only one state bit HIGH at once – i.e., for 4 states, 0001, 0010, 0100, 1000 – Requires more flip-flops – Often next state and output logic is simpler Chapter 3 <64>

  25. FSM Design Procedure 1. Identify inputs and outputs 2. Sketch state transition diagram 3. Write state transition table 4. Select state encodings 5. Rewrite state transition table with state encodings 6. Write output table 7. Write Boolean equations for next state and output logic 8. Sketch the circuit schematic Chapter 3 <65>

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend