Presentation is loading. Please wait.

Presentation is loading. Please wait.

Finite State Machines Prof. Sirer COMP 303 Koç University.

Similar presentations


Presentation on theme: "Finite State Machines Prof. Sirer COMP 303 Koç University."— Presentation transcript:

1 Finite State Machines Prof. Sirer COMP 303 Koç University

2 Finite State Machines An electronic machine which has external inputs externally visible outputs internal state Output and next state depend on inputs current state

3 Designing an FSM Draw a state diagram Write down state transition table Assign numbers to states Determine logic equations for all flip-flops and outputs

4 A Simple Example Goal: flash hello on LEDs Inputs: clock Outputs: Just one 7-segment LED Flash “h” then “e” then “l” then “l” then “o” h = e = l = o = o0o0 o1o1 o2o2 o3o3 o4o4 o5o5 o6o6

5 HELLObox: State Diagram Determine the transitions label all edges (transitions) with the inputs that cause them, unlabeled edges are unconditional transitions show start state S0S1S2S3S4 H E L L O

6 HELLObox: State Table Current State Next State Output S0S10011101 S1S20111110 S2S30010110 S3S40010110 S4S01110111 Build state table rote encoding of the state diagram

7 HELLObox: State Assignment 1 Current State Next State Output 0000010011101 0010100111110 0100110010110 0111000010110 1000001110111 Assign bit patterns to states that would make the resulting device simple One option is shown Determine logic equations for every bit of output and next state, for every flip- flop and output

8 HELLObox #1 10 bits of information (7 outputs + 3 bits of next state) are computed by the combinatorial circuit All 10 bits have non- trivial logic equations flip-flops combinational circuit o0o0 o1o1 o2o2 o3o3 o4o4 o5o5 o6o6

9 HELLObox: State Assignment 2 Current State Next State Output 00111010011111000011101 01111100001011000111110 00101100001011010010110 00101101111011100010110 11101110001110101110111 Assign bit patterns to states that would make the resulting device simple Here, we use far more bits than necessary to simplify the combinatorial circuit

10 HELLObox #2 15 bits of information (7 outputs + 8 bits of next state) are computed by the combinatorial circuit 8 bits have non-trivial logic equations all 7 outputs are simple pass-throughs flip-flops combinational circuit o0o0 o1o1 o2o2 o3o3 o4o4 o5o5 o6o6

11 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street A sensor detects a waiting ambulance Design the light controller H a

12 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

13 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

14 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

15 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

16 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

17 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

18 A Traffic Light There is a large avenue and a Hospital ER on a side street The avenue traffic light should be green at all times Except when an ambulance is waiting on the side street H

19 A Traffic Light One input a Six outputs (AR, AO, AG, HR, HO, HG) 001100010100100110100001100010110100 0 10 & 1 0 1 S0S1S2S3S4S5

20 FSM: Serial Adder Add two input bit streams streams are sent with least-significant-bit (lsb) first …10110 …01111 …00101

21 FSM: State Diagram Two states: S0 (no carry), S1 (carry in hand) Inputs: a and b Output: z Arcs labelled with input bits a and b, and output z S0 S1 00/0 10/101/110/001/0 11/1 00/1 11/0

22 Serial Adder: State Table Write down all input and state combinations abstate z next state 00S00 01 1 10 1 11 0S1 00 1S0 01S10 10 0 11 1

23 Serial Adder: State Assignment Two states, so 1-bit is sufficient A single flip-flop will encode the state abs zs’ 00000 01010 10010 11001 00110 01101 10101 11111

24 Serial Adder: Circuit Equations z = abs + abs + abs + abs s’ = abs + abs + abs + abs clk QD z a b combinational logic s s’


Download ppt "Finite State Machines Prof. Sirer COMP 303 Koç University."

Similar presentations


Ads by Google