














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 / 22
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 64
Lecture 4
Sequential Logic Design
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
2 of 64
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
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
Laser remains on for another 3 clock cycles
Pulsing an output for 1 cycle every 10 cycles Detecting the sequence 1, 3, 5 in binary on a 3-bit input
Laser timer example of multiple button presses
clk
b
x
Does the Laser Timer Controller Really Work?
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
5 of 64
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
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
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
10 of 64
If not, computer shuts off car
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
clk Inputs a
clk Inputs a
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
s, r, g, b
a
FSM Example: Code Detector Description
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
13 of 64
Red
ar
u=
Inputs: s,r,g,b,a; Outputs: u
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
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
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
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
20 of 64
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
21 of 64
Three states, need 2-bits for unique encoding
Don’t forget state!
Current state and FSM inputs
Given current state and FSM input, where do we go?
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
Unused
Outputs: z
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
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
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!
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
AND each condition pair, should be 0
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
ar
No other buttons should be pressed - 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
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
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
33 of 64
Representations of Finite State Machines
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
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’ 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
clk
State register
Combinational Logic
S
clk
State register
Next State Logic
FSM Output Logic
Moore FSM
Next state logic – function of present state and FSM inputs
Output logic - function of present state only
clk
State register
Next State Logic
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
clk
State register
Next State Logic
FSM Output Logic
clk
Inputs: enough State:
Outputs: clear d
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
clk
State register
Next State Logic
FSM Output Logic
clk
Inputs: enough State:
Outputs: clear d
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’
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=
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
46 of 64
w = 0, stay put w = 1, start swap with R3 = R R2out = 1, R3in = 1
w = 0/1, set R2 = R R1out = 1, R2in = 1
w = 0/1, set R1 = R R3out = 1, R1in = 1
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
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
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
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
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
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
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
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
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
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
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
Digital Design Copyright © 2006 Frank Vahid
ECE 474a/575a Susan Lysecky
60 of 64
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’
a=
b
a=
a=
b’ b S
b / a = 1
b’ / a = 1
Converting a Moore to a Mealy FSMs Example