Lecture Notes on Sequential Logic Design | ECE 474A, Study notes of Electrical and Electronics Engineering

Material Type: Notes; Professor: Lysecky; Class: Computer-Aided Logic Design; Subject: Electrical & Computer Engr; University: University of Arizona; Term: Unknown 2006;

Typology: Study notes

Pre 2010

Uploaded on 08/30/2009

koofers-user-ead-1
koofers-user-ead-1 🇺🇸

10 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Digital Design
Copyright ©2006
Frank Vahid
ECE 474a/575a
Susan Lysecky 1of 64
ECE 474A/57A
Computer-Aided Logic Design
Lecture 4
Sequential Logic Design
Digital Design
Copyright ©2006
Frank Vahid
ECE 474a/575a
Susan Lysecky 2of 64
Sequential Circuits
Output based on inputs as well as previous
inputs (state)
Previously learned how to store data which
can store “state” of circuit (Registers)
Two categories of sequential circuits
Synchronous – clock used to control
operation of circuit
Asynchronous – no clock
We’ll focus on synchronous sequential
circuits
A sequential circuit that controls Boolean
outputs based on Boolean inputs and a
specific time-ordered behavior is often
called a controller
Controller
clk
bx
Sequential Circuit Design (Controllers)
Digital Design
Copyright ©2006
Frank Vahid
ECE 474a/575a
Susan Lysecky 3of 64
Controller
x
b
clk
laser
patient
Want sequential circuit with
particular behavior over time
Example: Laser timer
When button pressed (b=1),
output x=1 (turn laser on) for 3
clock cycles
How? Let’s try three flip-flops
b=1 gets stored in first D flip-flop
Then 2nd flip-flop on next cycle,
then 3rd flip-flop on next
OR the three flip-flop outputs, so
x should be 1 for three cycles
DQ DQ DQ
clk
b
x
Example System: Laser Timer Controller
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Lecture Notes on Sequential Logic Design | ECE 474A and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

1 of 64

ECE 474A/57A

Computer-Aided Logic Design

Lecture 4

Sequential Logic Design

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

2 of 64

ƒ Sequential Circuits

ƒ Output based on inputs as well as previous

inputs (state)

ƒ Previously learned how to store data which

can store “state” of circuit (Registers)

ƒ Two categories of sequential circuits

ƒ Synchronous – clock used to control

operation of circuit

ƒ Asynchronous – no clock

ƒ We’ll focus on synchronous sequential

circuits A sequential circuit that controls Boolean

outputs based on Boolean inputs and a specific time-ordered behavior is often called a controller

Controller

clk

b x

Sequential Circuit Design (Controllers)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

3 of 64

Controller x

b

clk

laser

patient

ƒ Want sequential circuit with

particular behavior over time

ƒ Example: Laser timer

ƒ When button pressed (b=1),

output x=1 (turn laser on) for 3

clock cycles

ƒ How? Let’s try three flip-flops

ƒ b=1 gets stored in first D flip-flop

ƒ Then 2nd flip-flop on next cycle,

then 3rd flip-flop on next

ƒ OR the three flip-flop outputs, so

x should be 1 for three cycles

D Q D Q D Q

clk

b

x

Example System: Laser Timer Controller

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

4 of 64

ƒ Does this work correctly?

ƒ What happens if we press the button

again while x=1?

ƒ Laser remains on for another 3 clock cycles

ƒ Trial and error is not a good design

method

ƒ Will we be able to “guess” a circuit that

works for other desired behavior?

ƒ Pulsing an output for 1 cycle every 10 cycles ƒ Detecting the sequence 1, 3, 5 in binary on a 3-bit input

ƒ Circuit built by guessing may have

undesired behavior

ƒ Laser timer example of multiple button presses

D Q1 D Q2 D Q

clk

b

x

b Q1 Q2 Q3 x

time0 1 0 0 0 0

time1 0 1 0 0 1

time2 1 0 1 0 1

time3 0 1 0 1 1

time4 0 0 1 0 1

time5 0 0 0 1 1

time6 0 0 0 0 0

Does the Laser Timer Controller Really Work?

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

5 of 64

ƒ Designing sequence circuits

ƒ Need a formal way to describe

desired circuit behavior

ƒ Combinational Circuits have

Boolean equations or truth table

ƒ Well-defined process to convert

that behavior to a circuit

x1 x2 F 0 1 0 1 0 1 0 1

0 0 1 1 0 0 1 1

0 0 0 0 1 1 1 1

x 0 0 0 1 1 1 1 0

F = x1x3’ + x1x2’ + x1’x2x

F

x

x x

x x

x

x

Need a Better Way to Design Sequential Circuits

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

6 of 64

Outputs: x

Off On

x=0 x=

clk^

clk^

Off On^ Off On^ Off On Off On

cycle 1

Off On Off On

clk cycle 2^ cycle 3^ cycle 4

state

x

Outputs:

ƒ State Diagram or Finite-State

Machine (FSM)

ƒ A way to describe desired behavior of

sequential circuit

ƒ List states, and transitions among

states

ƒ Example: Make x toggle (0 to 1, or 1

to 0) every clock cycle

ƒ Two states

ƒ Off (x=0) ƒ On (x=1)

ƒ Transition from Off to On, or On to

Off, on rising clock edge

ƒ Arrow with no starting state points to

initial state (when circuit first starts)

** clk^ denotes rising edge of the clock

Describing Behavior of Sequential Circuit: FSM

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

10 of 64

ƒ Many new car keys include tiny

computer chip

ƒ When car starts, car’s computer

(under engine hood) requests

identifier from key

ƒ Key transmits identifier

ƒ If not, computer shuts off car

ƒ FSM

ƒ Wait until computer requests ID

(a=1)

ƒ Transmit ID (in this case, 1101)

K1 K2 K3 K

r=1 r=1 r=0 r=

Wait

r=

a a’

Outputs: r

Inputs: a

FSM Example: Secure Car Key

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

11 of 64

Wait Wait K1 K2 K3 K4 Wait Wait Outputs

State

r

Q: Determine states and r value for given input waveform:

clk Inputs a

clk Inputs a

ƒ Nice feature of FSM

ƒ Can evaluate output behavior for

different input sequence

ƒ Timing diagrams show states and

output values for different input

waveforms

K1 K2 K3 K

r=1 r=1 r=0 r=

Wait

r=

a a’

Outputs: r

Inputs: a

Wait Wait K1 K2 K3 K4 Wait Output

State

r

K

FSM Example: Secure Car Key (cont.)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

12 of 64

Start

Red Green Blue

s

r g b a

Door lock

u

Code Detector

ƒ Unlock door only when buttons

pressed in sequence:

ƒ start, then red, blue, green, red

ƒ Input

ƒ Each button indicates when pressed

ƒ s, r, g, b

ƒ Extra input to indicate some colored

button pressed

ƒ a

ƒ Output

ƒ Door unlocked when u = 1

FSM Example: Code Detector Description

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

13 of 64

Q: Can you trick this FSM to open the door, without knowing the code?

A: Yes, hold all buttons simultaneously

Red

ar

u=

Inputs: s,r,g,b,a; Outputs: u

ƒ FSM to detect S, R, B, G, R

ƒ Wait for Start (s=1) ƒ Once start button pressed check for correct sequence ƒ If Red pressed, go to “Red1” ƒ Then, if Blue pressed, go to “Blue” ƒ Then, if Green pressed, go to “Green” ƒ Then, if Red pressed, go to “Red2” ƒ Correct sequence detected ƒ Open the door (u=1) ƒ Return to Wait ƒ Wrong button at any step, return to “Wait”, without opening door

Start Red Green Blue

s r g b a

Doorlock

u DetectorCode

ar’ ab’ ag’ ar’

Start a’ u=

s

Blue

ab

a’ u=

a’

Red u=

ar

Green

ag

a’ u=

Wait u=0 s

FSM Example: Code Detector FSM

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

14 of 64

Note: small problem still remains; we’ll discuss later

ƒ Update transition conditions

ƒ Detect if wrong button pressed, returns to “Wait”

Red

ar

u=

Inputs: s,r,g,b,a; Outputs: u

Start u=

s

Blue

ab

a’ u=

a’

Red

u=

ar

Green

ag

a’ u=

Wait u=0 ar ’ ab ’ ag ’ ar ’

a’

s’

Improved FSM for Code Detector

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

15 of 64

ƒ FSM or state diagram

ƒ Graphical representation

ƒ Formal method to describe sequential

circuits

ƒ State Table

ƒ Textual Representation

ƒ How do we implement a sequential

circuit?

ƒ Standard Controller architecture

ƒ Need to store state ƒ State register (encoded state) ƒ Need to determine next state ƒ Current state and external input to combinational logic ƒ Need to determine output ƒ Current state input to combinational logic

On1 On2 On

Off

x=1 x=1 x=

x= b’

b

x

clk State register

n

n

Combinational logic

s1 s

b

FSM inputs FSM outputs

Controller architecture for laser timer example

Graphical and Textual Sequential Circuit

Descriptions

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

19 of 64

ƒ State Table

ƒ Next state

ƒ Based on current state and FSM input what is the next state?

ƒ FSM Output

ƒ Output depends on current state only (Moore FSM) ƒ For each state we are currently in, what is the output?

On1 On2 On

Off

x=1 x=1 x=

x=

b’

b

Inputs Outputs s1 s0 b n1 n0 x 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

Off

On

On

On

00

(^01 10 )

State Table Example: Laser Timer (cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

20 of 64

ƒ How does choice of flip-flop impact

the state table?

ƒ Different ways to store a bit

ƒ D flip-flop - Input value determines output value ƒ SR flip-flop - Two inputs S (set) and R (reset) that determines output value

ƒ We only consider D flip-flop

Combinational logic

State register

s1 s

n

n

b x

clk

FSM inputs FSM outputs

S Q’ R Q

SR flip-flop

D Q’ Q

D flip-flop

S = 0, R = 0 then Q = Q S = 0, R = 1 then Q = 0 S = 1, R = 0 then Q = 1 S = 1, R = 1 is invalid

D = 1 then Q = 1 D = 0 then Q = 0

Flip-flop Choice Impacts the State Table

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

21 of 64

ƒ Given FSM, create corresponding

state table

ƒ Two consecutive inputs (w) are

equal to 1

ƒ Steps to create a state table

ƒ Encode states

ƒ Three states, need 2-bits for unique encoding

ƒ Determine inputs/outputs of FSM

ƒ Don’t forget state!

ƒ Fill in all possible input values

ƒ Current state and FSM inputs

ƒ Fill in Next state

ƒ Given current state and FSM input, where do we go?

ƒ Fill in FSM Output

00 01

10

d d d d

d d

Inputs Outputs s1 s0 w n1 n0 z 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

A
B
C

Unused

Outputs: z

A B
C

w

w’

z=

z=0 w z=

Inputs: w

w’ w’

w

State Table Example: Secure Car Key

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

22 of 64

Create an FSM (state diagram) that describes the desired behavior of the circuit

Step 1: Capture the FSM

Create the standard architecture by using a state register of appropriate width, and combinational logic with inputs being the state register bits and the FSM inputs, and outputs being the next state bits and the FSM outputs

Step 2: Create the architecture

Assign a unique binary number to each state. Each binary number representing a state is know as an encoding. Any encoding will do as long as they are unique.

Step 3: Encode the states

Create a truth table for the combinational logic such that the logic will generate the correct FSM output and next state signals. Ordering the inputs with state bits first make the truth table describe the state behavior, giving us a state table.

Step 4: Create the state table

Implement the Implement the combinational logic using any method. combinational logic

Step 5:

Step Description

(Condensed) Controller Design Process

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

23 of 64

ƒ Example: Laser Timer

ƒ Step 1: Capture the FSM

ƒ Already done

ƒ Step 2: Create architecture

ƒ Customize generic controller architecture

to our system

ƒ State Register ƒ 2-bit state register (for 4 states) ƒ s1, s0 – current state bits ƒ n1, n0 – next state bits ƒ FSM Input ƒ Button signal b ƒ FSM Output ƒ Laser control x

On1 On2 On

Off

x=1 x=1 x=

x= b’

b

x

clk State register

n

n

Combinational logic

s1 s

b

FSM inputs FSM outputs

Controller Design: Laser Timer

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

24 of 64

ƒ Step 3: Encode the states

ƒ Any encoding with each state unique

will work

ƒ Step 4: Create state table

ƒ Done this already

On1 On2 On

Off

x=1 x=1 x=

x= b’

b

00

01 10 11

Inputs Outputs s1 s0 b n1 n0 x 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

Off

On

On

On

Controller Design: Laser Timer (Cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

28 of 64

a + a’b = (a • 1) + a’b // a • 1 = a = a • (1+b) + a’b // b + 1 = 1 = a + ab + a’b = a + (a+a’)b = a + b

Fails! Might not be 1 (i.e., a=0, b=0)

a • a’b = (a • a’) • b = 0 • b = 0

OK!

ƒ Verify FSM Transition properties using

Boolean algebra

ƒ Only one condition true

ƒ AND ofeach condition pair for

transitions leaving a state

ƒ Should equal 0, proves pair can never

simultaneously be true

ƒ 1 AND 1 = 1
ƒ 1 AND 0 = 0

ƒ At least one condition true

ƒ OR ofall conditions of transitions

leaving a state

ƒ Should equal 1 , proves at least one

condition must be true

At least one true condition

Only one true condition

a

a’b

Verifying Correct Transition Properties

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

29 of 64

Fails! Means that two of Start’s transitions could be true

ƒ Recall code detector FSM

ƒ We “fixed” a problem with the transition

conditions

ƒ Do the transitions obey the two required

transition properties?

ƒ Consider transitions of stateStart

ƒ “Only one true” property

ƒ AND each condition pair, should be 0

ƒ 3 outbound transitions – look at each pair

ar • a’ = (a • a’) • r = 0 • r = 0

a’ • a(r’ + b + g) = (a’ • a) • (r’ + b + g) = 0 • (r’ + b + g) = 0

ar • a(r’ + b + g) = (a • a) • r • (r’ + b + g) = a • r • (r’ + b + g) = arr’ + arb + arg = 0 + arb + arg = arb + arg = ar (b+g)

Wait

Start

Red1 Blue Green Red

s’

a’

a’

ab ag^ ar a’ a’ u=

u=0 ar

u=0 (^) s

u=0 u=0 u=

Evidence that Pitfall is Common

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

30 of 64

ƒ What happened?

ƒ We want to go from Start to

Red1 if the red button pressed

ƒ ar

ƒ We underspecified transition

ƒ No other buttons should be pressed - arb’g’

ƒ Transition should also be

updated for

ƒ State Red1’s ab to abr’g’

ƒ State Blue’s ag to agr’b’

ƒ State Green’s ar to arb’g’

Wait

Start

Red1 Blue Green Red

s’

a’

a’

ab ag^ ar a’ a’ u=

u=0 (^) ar

u= s

u=0 u=0 u=

How Do We Fix It?

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

31 of 64

ƒ FSM Outputs

ƒ Assume unassigned output

implicitly assigned 0

ƒ Clk signal in sequential circuits

ƒ Assume unconnected clock

inputs connected to same

external clock

a= b= c=

a= b= c=

b=1 c=

clk a a

Further Simplifying Notations

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

32 of 64

Inputs: x; Outputs: b

On1 On2 On

Off

x=1 x=1 x=

x=

b’

b

ƒ All our FSMs had initial state

ƒ But our sequential circuit designs

did not

ƒ Can accomplish using flip-flops with

preset/clear inputs

ƒ Shown circuit initializes flip-flops to 01

ƒ Designer must ensure reset input is

1 during power up of circuit

ƒ By electronic circuit design

D Q

P C

D Q

State register clk

reset

s1 s

n

n

b x Combinational logic

Initial State of a Controller

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

33 of 64

Representations of Finite State Machines

ƒ Different ways to represent same

functionality

ƒ Graphical

ƒ State Table

ƒ Formal

ƒ Able to convert among different

representations

On1 On2 On

Off

x=1 x=1 x=

x= b’

b

00

01 10 11

0 0 0 1

0 0 1 0 1 0

1 1 1 1 1 1

1 1 0 0 0 0

1 1

Inputs Outputs s1 s0 b n1 n0 x 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

Off

On

On

On

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

37 of 64

ƒ Previously associated output with

current state

ƒ Moore FSM

ƒ Another type associates output with

both the state and the FSM input

(transitions)

ƒ Mealy FSM

ƒ Example: Soda dispenser

ƒ Input

ƒ enough - indicates when sufficient

money deposited

ƒ Output

ƒ d - releases a soda

ƒ clear - zeros device counting money

deposited

Moore FSM

Inputs: enough (bit) Outputs: d, clear (bit)

Wait

Disp

Init enough’

enough

d= clear=

d=

Mealy FSM

Inputs: enough (bit) Outputs: d, clear (bit)

Init Wait enough’ enough/d=

/d=0, clear=

Outputs not explicitly assigned on a transition are implicitly assigned a 0. Assignment to 0 still listed if it is key to the FSM’s behavior

Mealy vs. Moore FSM

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

38 of 64

ƒ Why does the timing change?

ƒ More detailed view of FSM implementation architecture

clk

I O

State register

Combinational Logic

S

N

clk

I
O

State register

Next State Logic

S
N

FSM Output Logic

Moore FSM

Next state logic – function of present state and FSM inputs

Output logic - function of present state only

clk

I
O

State register

Next State Logic

S
N

FSM Output Logic

Mealy FSM

Next state logic – function of present state and FSM inputs

Output logic - function of present state and FSM inputs

Moore vs. Mealy FSM - Architecture

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

39 of 64

ƒ Moore FSM

ƒ Output logic is combinational – output changes when input changes

ƒ Only input is state

clk

I
O

State register

Next State Logic

S
N

FSM Output Logic

clk

Inputs: enough State:

Outputs: clear d

I W W DI

Output changes only on rising clock edge Output remains same (at least) until next clock cycle -- minimally high/low for 1 clock cycle

Moore FSM Output Condition

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

40 of 64

ƒ Mealy FSM

ƒ Again output logic is combinational – output changes when input changes

ƒ Input is both state and FSM input I

clk

I
O

State register

Next State Logic

S
N

FSM Output Logic

clk

Inputs: enough State:

Outputs: clear d

I W WI

Output can change on rising clock edge or when FSM input changes Output can change mid-cycle if input changes, output may not stay the same for an entire clock cycle

Mealy FSM Output Condition

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

41 of 64

Inputs: b; Outputs: s1, s0, p

Time

Alarm

Date

Stpwch

b’/s1s0=00, p= b/s1s0=00, p=

b/s1s0=01, p=

b/s1s0=10, p=

b/s1s0=11, p=

b’/s1s0=01, p=

b’/s1s0=10, p=

b’/s1s0=11, p=

Inputs: b; Outputs: s1, s0, p

Time

S

Alarm

b

b

b

b

s1s0=00, p=

s1s0=00, p=

s1s0=01, p= s1s0=01, p=

s1s0=10, p=

s1s0=10, p=

s1s0=11, p=

s1s0=11, p=

S

Date

S

Stpwch

S

b’

b’

b’

b’

Mealy

Moore

A: Mealy on left, Moore on

right

  • Mealy outputs on arcs, meaning outputs are function of state AND INPUTS
  • Moore outputs in states, meaning outputs are function of state only

Q: Which is Moore, and

which is Mealy?

Which One is Which: Moore vs. Mealy

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

42 of 64

Inputs: b; Outputs: s1, s0, p

Time

Alarm

Date

Stpwch

b’/s1s0=00, p= b/s1s0=00, p=

b/s1s0=01, p=

b/s1s0=10, p=

b/s1s0=11, p=

b’/s1s0=01, p=

b’/s1s0=10, p=

b’/s1s0=11, p=

Mealy

ƒ Beeping Wristwatch

ƒ Button b

ƒ Sequences mux select liness1s0 through

00, 01, 10, and 11 ƒ Each value displays different internal register ƒ Each unique button press should cause 1-

cycle beep, withp = 1 causing the beep

ƒ Must wait for button to be released (b’)

and pushed again (b) before sequencing

ƒ Mealy pulsesp on arc

ƒ Benefit: We’ll see it requires less states

than Moore FSM

ƒ Tradeoff: Mealy FSM’s pulse onp may not

last one full cycle

Mealy FSM Example: Beeping Wristwatch

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

46 of 64

ƒ Implement as a Mealy FSM

ƒ Control signals associated with on

transitions

ƒ State A

ƒ w = 0, stay put ƒ w = 1, start swap with R3 = R ƒ R2out = 1, R3in = 1

ƒ State B

ƒ w = 0/1, set R2 = R ƒ R1out = 1, R2in = 1

ƒ State C

ƒ w = 0/1, set R1 = R ƒ R3out = 1, R1in = 1

ƒ State D

ƒ w = 0/1, indicate we are finished ƒ Done = 1

Inputs: w Outputs: R1out , R1 in, R2out , R2in, R3out , R3 in, Done

A

B

C

D

w’

/ R1out = 1, R2 (^) in = 1

/ R3out = 1, R1 (^) in = 1

/ Done = 1

w / R2out = 1, R3in = 1

Mealy FSM: Register Swap

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

47 of 64

ƒ Implementing a Mealy FSM

ƒ Same steps as a Moore FSM

ƒ Capture the FSM

ƒ Create the architecture

ƒ Encode the states

ƒ Create the state table

ƒ Derive equations for each output,

implement the combinational

logic

ƒ Key difference from Moore

ƒ FSM output are based on state

and FSM inputs

ƒ May have different value in same

state, depending on input values

Inputs: enough (bit) Outputs: d, clear (bit)

Init Wait enough’ enough/d=

/d=0, clear=

Implementing a Mealy FSM

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

48 of 64

ƒ Capture the FSM

ƒ Done!

ƒ Create the architecture

ƒ Inputs – enough

ƒ Outputs – d, clear

ƒ State register – 2 states, 1-bit

Inputs: enough (bit) Outputs: d, clear (bit)

Init Wait enough’ enough/d=

/d=0, clear=

d

clk State register

Combinational clear logic

s

enough

FSM inputs FSM outputs n

Implementing a Mealy FSM Example 1

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

49 of 64

s0 enough n0 d clear

ƒ Encode the states

ƒ Use minimum-width binary

encoding

ƒ Create the state table

ƒ This is where it differs from a

Moore implementation

ƒ FSM output are based on

state and FSM inputs

ƒ May have different value in

same state, depending on

input values

Inputs: enough (bit) Outputs: d, clear (bit)

Init Wait

enough/d=1 enough’

/d=0, clear=

0 1

Init

Wait

Inputs Outputs

Implementing a Mealy FSM Example 1 (cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

50 of 64

ƒ Implement the combinational

logic

ƒ n0 = s0’ + enough’

ƒ d = s0•enough

ƒ clear = s

s0 enough n0 d clear Init

Wait

Inputs Outputs

d

clk State register

clear

s

enough

FSM inputs n0 FSM outputs

Implementing a Mealy FSM Example 1 (cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

51 of 64

ƒ Given a Mealy FSM we can convert to a Moore FSM

ƒ Given a Moore FSM we can covert to a Mealy FSM

Inputs: w Outputs: R1out , R1 (^) in, R2out , R2 (^) in, R3out , R3in, Done

A

B

C

D

w’

R1out = 1 R2in = 1

R3out = 1 R1in = 1

E Done = 1

w wR2out = 1 R3in = 1

Inputs: w Outputs: R1out , R1 (^) in, R2out , R2in, R3out , R3 (^) in, Done

A

B

C

D

w’

/ R1out = 1, R2 (^) in = 1

/ R3out = 1, R1 (^) in = 1

/ Done = 1

w / R2out = 1, R3in = 1

Converting Between Mealy and Moore FSMs

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

55 of 64

ƒ Convert the following Mealy FSM to a Moore FSM

go to state S output ab = 00

State S What happens when start’?

S1 S

S

/ ab=

/ ab=

start’ / ab = 00

Outputs: a,b

Inputs: start

start / ab = 01

S0 (^) start’ ab = 00

S

start

ab = 01

go to state S output ab = 01

What happens when start?

Converting a Mealy to a Moore FSMs Example

(cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

56 of 64

ƒ Convert the following Mealy FSM to a Moore FSM

State S Don’t care what input start value is

S1 S

S

/ ab=

/ ab=

start’ / ab = 00

Outputs: a,b

Inputs: start

start / ab = 01

go to state S output ab = 10

S ab=

S

S0 start’

start

ab = 00

ab = 01

Converting a Mealy to a Moore FSMs Example

(cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

57 of 64

ƒ Convert the following Mealy FSM to a Moore FSM

go to state S output ab = 11

State S Don’t care what input start value is

S1 S

S

/ ab=

/ ab=

start’ / ab = 00

Outputs: a,b

Inputs: start

start / ab = 01

S1 S

S

ab=

start’

start

ab = 00

ab = 01

a ab=

S0b

State S0 already associated with ab = 00!

Replicate state, new state’s output is a = 11

Converting a Mealy to a Moore FSMs Example

(cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

58 of 64

ƒ Convert the following Mealy FSM to a Moore FSM

State S0b What happens when start’?

S1 S

S

/ ab=

/ ab=

start’ / ab = 00

Outputs: a,b

Inputs: start

start / ab = 01

S1 S

S ab=

ab=

start’

start

S0b ab = 00

ab = 01

a

go to state S output ab = 00 (this is S0a)

start’

start

go to state S output ab = 01

What happens when start?

Converting a Mealy to a Moore FSMs Example

(cont’)

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

59 of 64

ƒ Converting a Moore to a Mealy FSM

Time

b’ / a=

Alarm

b / a=

Time

b’

Alarm

b

a=

a=

What happens when b = 1? go to state alarm state alarm outputs a = 0 (make this output associated with the transition

go to state time state time outputs a = 1 (make this output associated with the transition)

State Time What happens when b = 0?

Converting a Moore to a Mealy FSMs

Template 1

Digital Design Copyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

60 of 64

ƒ Converting the following Moore FSM to a Mealy FSM

What happens when b? go to state S output a = 1

go to state S output a = 1

State S What happens when b’?

b’

S

a=

S

b

S

a=

a=

b’ b S

b / a = 1

b’ / a = 1

S

Converting a Moore to a Mealy FSMs Example