









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Lysecky; Class: Computer-Aided Logic Design; Subject: Electrical & Computer Engr; University: University of Arizona; Term: Unknown 2006;
Typology: Study notes
1 / 16
This page cannot be seen from the preview
Don't miss anything!










Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
1 of 48
Lecture 3
REVIEW - Sequential Logic Design
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
2 of 48
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 48
Off On^ Off On^ Off On Off On
cycle 1
Off On Off On
clk cycle 2^ cycle 3^ cycle 4
state
x
Outputs:
Off (x=0) On (x=1)
** clk^ denotes rising edge of the clock
Describing Behavior of Sequential Circuit: FSM
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
4 of 48
Off Off Off Off OffOn1On2 On3Off
clk
State Outputs:
Inputs:
x
b
On1 On2 On
Off
clk ^
clk ^
x=1 x=1 x=
x=
clk ^
b’•clk ^
b•clk ^
Outputs: x
Inputs: b
When button pressed (b=1), turn laser on (x=1) for 3 clock cycles
Off state Keep laser turned off While b=0 (b’), we are in a wait state When b=1 and rising clock edge (b • clk^), transition to On1 state On1 state Turns laser on (x=1) On next rising clock edge (clk^) transition to On2 state On2/On3 state Also turns laser on (x=1) Transitions on next rising clock edge
FSM Example: Three-Cycles High Laser Timer
Controller x
b
clk
laser
patient
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
5 of 48
Outputs: z
clk^ • w
clk^ • w’
z=
z=0 clk^ • w z=
Inputs: w
clk^ • w’
clk^ • w’
clk^ • w
clk
State
Inputs:
Outputs:
w
z
FSM Example: Two Inputs in a Row are One
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
6 of 48
Note: Transition with no associated condition, on next clock cycle goes to next state.
On1 On2 On
Off
clk^
clk^
x=1 x=1 x=
x=
clk^
b’•clk^
b•clk^
Outputs: x
Inputs: b
On1 On2 On
Off
x=1 x=1 x=
x= b’
b
Outputs: x
Inputs: b
FSM Simplification: Rising Clock Edges Are Implicit
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
10 of 48
Can’t store word “Off” in state register so we must encode it Ensure every state has a unique encoding We have 4 states, so we need 2 bits to uniquely identify each state
On1 On2 On
Off
x=1 x=1 x=
x=
b’
b
Inputs Outputs s1 s0 b n1 n0 x
Off^0
On1^0
On2^1
On3^1
00
(^01 10 )
State Table Example: Laser Timer (cont’)
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
11 of 48
Based on current state and FSM input what is the next state?
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
12 of 48
D flip-flop - Input value determines output value SR flip-flop - Two inputs S (set) and R (reset) that determines output value
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
13 of 48
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
14 of 48
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
15 of 48
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
19 of 48
Inputs: x; Outputs: b
On1 On2 On
Off
x=1 x=1 x=
x= b’
b
Shown circuit initializes flip-flops to 01
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
20 of 48
Representations of Finite State Machines
On1 On2 On
Off
x=1 x=1 x=
x= b’
b
00
(^01 10 )
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
21 of 48
On1 On2 On
Off
x=1 x=1 x=
x=
b’
b
Outputs: x
Inputs: b
FSM Formal Definition
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
22 of 48
On1 On2 On
Off
x=1 x=1 x=
x= b’
b
Outputs: x
Inputs: b
FSM Formal Definition – Example 1
LaserTimer = (X, Y, S, δ, λ, qo), where
X is the input alphabet
Y is the output alphabet
S = {Off, On1, On2, On3}
S is a finite set of states
δ(Off, 0) = Off, δ(Off, 1) = On δ(On1, 0) = On2, δ(On1, 1) = On δ(On2, 0) = On3, δ(On2, 1) =On δ(On3, 0) = Off, δ(On3, 1) = Off δ^ is the transition function,^ δ: X x S→S Given and input and state, what is the next state λ(Off) = 0, λ(On1) = 1, λ(On2) = 1, λ(On3) = 1 λ is the output funciton, λ: S → Y so = Off
s (^) o is the initial state
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
23 of 48
FSM Formal Definition - Example 2
x=0 x=0 x=
x=
One Two Three
Zero
ThreeOnes = (X, Y, S, δ, λ, qo), where
X = {0, 1}
Y = {0, 1}
S = {Zero, One, Two, Three}
δ(Zero, 0) = Zero, δ(Zero, 1) = One δ(One, 0) = Zero, δ(One, 1) = Two δ(Two, 0) = Zero, δ(Two, 1) = Three δ(Three, 0) = Zero, δ(Three, 1) = Three
λ(Zero) = 0, λ(One) = 0, λ(Two) = 0, λ(Three) = 1
q (^) o = Zero
Inputs: a Output: x
a’
a
a’
a
a
a’ a
a’
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
24 of 48
money deposited
deposited
Inputs: enough (bit) Outputs: d, clear (bit)
Wait
Disp
Init (^) enough’
enough
d= clear=
d=
Inputs: enough (bit) Outputs: d, clear (bit)
Init Wait
enough/d=1 enough’
/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
28 of 48
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’
Which One is Which: Moore vs. Mealy
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
29 of 48
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=
00, 01, 10, and 11 Each value displays different internal register Each unique button press should cause 1-
Mealy FSM Example: Beeping Wristwatch
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
30 of 48
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’
Moore FSM Example: Beeping Wristwatch
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
31 of 48
Inputs: enough (bit) Outputs: d, clear (bit)
Init Wait
enough/d=1 enough’
/d=0, clear=
Implementing a Mealy FSM
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
32 of 48
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
33 of 48
s0 enough n0 d clear
Inputs: enough (bit) Outputs: d, clear (bit)
Init Wait enough’ enough/d=
/d=0, clear=
(^0 )
Init
Wait
Inputs Outputs
Implementing a Mealy FSM Example 1 (cont’)
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
37 of 48
b’
S1 (^) a=
a=
What happens when bc’? go to state S output a = 1
go to state S output a = 1
State S What happens when b’?
b’ / a=
bc’ / a=1 bc / a=
What happens when bc? go to S output a = 0
State S0 already associated with a = 1!
Replicate state, new state’s output is a = 0
bc’
bc
a=
Converting a Mealy to a Moore FSMs
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
38 of 48
S1 S
S
/ ab=
/ ab=
start’ / ab = 00
Outputs: a,b
Inputs: start
start / ab = 01
Converting a Mealy to a Moore FSMs Example
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
39 of 48
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
40 of 48
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
41 of 48
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
42 of 48
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
46 of 48
go to state S output a = 1
State S We don’t care what input value b is equal to
b’
a=
b
a=
a=
b’ (^) b
b’ / a = 1
b / a = 1
b’ / a = 1 b / a = 0
/ a = 1
Converting a Moore to a Mealy FSMs Example
(cont’)
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
47 of 48
Inputs: b; Outputs: s1, s0, p
Time
Alarm
Date
Stpwch
b’/p=
b/p=
s1s0=
s1s0= b/p=
b/p=
s1s0=
b/p=
s1s0=
b’/p=
b’/p=
b’/p=
Mealy and Moore FSMs Can be Combined
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
48 of 48
Summary