Finite State Machines - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Finite State Machines

Description:

Finite State Machines Prof. Sirer COMP 303 Ko University – PowerPoint PPT presentation

Number of Views:125
Avg rating:3.0/5.0
Slides: 25
Provided by: corn110
Category:

less

Transcript and Presenter's Notes

Title: Finite State Machines


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 lt0011101gt
  • e lt0111110gt
  • l lt0010110gt
  • o lt1110111gt

5
HELLObox State Diagram
S0
S1
S2
S3
S4
lt0011101gt H
lt0111110gt E
lt0010110gt L
lt 0010110 gt L
lt1110111gt O
  • Determine the transitions
  • label all edges (transitions) with the inputs
    that cause them, unlabeled edges are
    unconditional transitions
  • show start state

6
HELLObox State Table
  • Build state table
  • rote encoding of the state diagram

CurrentState NextState Output
S0 S1 0011101
S1 S2 0111110
S2 S3 0010110
S3 S4 0010110
S4 S0 1110111
7
HELLObox State Assignment 1
  • 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

Current State NextState Output
000 001 0011101
001 010 0111110
010 011 0010110
011 100 0010110
100 000 1110111
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

combinational circuit
flip-flops
9
HELLObox State Assignment 2
  • 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

Current State NextState Output
00111010 01111100 0011101
01111100 00101100 0111110
00101100 00101101 0010110
00101101 11101110 0010110
11101110 00111010 1110111
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

combinational circuit
flip-flops
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

a
H
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)

0
1
0 1
1
0 1
0 1
0
0 1
S0
S1
S2
S3
S4
S5
001100
010100
100110
100001
100010
110100
20
FSM Serial Adder
  • Add two input bit streams
  • streams are sent with least-significant-bit (lsb)
    first

10110
00101
01111
21
FSM State Diagram
00/1
00/0
S0
S1
11/1
11/0
10/1
01/1
10/0
01/0
  • 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

22
Serial Adder State Table
a b state z next state
0 0 S0 0 S0
0 1 S0 1 S0
1 0 S0 1 S0
1 1 S0 0 S1
0 0 S1 1 S0
0 1 S1 0 S1
1 0 S1 0 S1
1 1 S1 1 S1
  • Write down all input and state combinations

23
Serial Adder State Assignment
a b s z s
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 0 1
0 0 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 1
  • Two states, so 1-bit is sufficient
  • A single flip-flop will encode the state

24
Serial Adder Circuit
a
  • Equations
  • z abs abs abs abs
  • s abs abs abs abs

z
combinational logic
b
s
s
Q
D
clk
Write a Comment
User Comments (0)
About PowerShow.com