Chapter 3 - Sequential Logic Design - Controllers
Chapter 3 - Sequential Logic Design - Controllers
January 5, 2025
3.1
Introduction
Sequential circuit 1
• Output depends not just on present inputs (as in a
Combinational
1
0 F
combinational circuit), but on past sequence of inputs b digital circuit
Stores bits, also known as having “state”
• Simple example: a circuit that counts up in binary
In this chapter, we will: 1
a
• Design a new building block, a flip-flop, that stores one bit 0 Sequential ? F
b digital circuit
• Combine that block to build multi-bit storage – a register
si
• Describe the sequential behavior using a finite state ansis Must know
machine
sequence of
• Convert a finite state machine to a controller – a past inputs to
sequential circuit having a register and combinationalelogic know output
z
Note: Slides with animation are denoted with a small red "a" near the animated items
2
1
2025-01-05
3.2
implement
Call this? Q 2. Call button released – light stays on
Cancel
a
Call Blue light
Doesn’t work. Q=1 when Call=1, but button Bit
doesn’t stay 1 when Call returns to 0 Cancel Storage
button
Need some form of “feedback” in the circuit
3. Cancel button pressed – light turns off
1
S
0
1
t
0
1
Q
0
4
2
2025-01-05
R (reset)
S=0 S=0 S=1 S=0
t t t t Recall…
1 1 0 0 0
0 0 1 1 1
0
1
1 1 0 0
0 Q 0 Q 1 Q 1 Q ecall
R
X ... 0
1
S
0
R1
0 a
t 1
0
1
Q
0
6
3
2025-01-05
1
Q may oscillate. Then, because one path will be t
0
slightly longer than the other, Q will eventually 1
settle to 1 or 0 – but we don’t know which. Q
0
1
Y
Q 0
Y R
1
S
The longer path from X to R than to S causes SR=11 for 0
short time – could be long enough to cause oscillation SR = 11
1
R
0
8
4
2025-01-05
...S1R1 never = 11
9
10
5
2025-01-05
Clocks
11
Level-Sensitive D Latch
SR latch requires careful D
D latch
occurs C
that burden 1
• InsertedD 0inverter ensures R
always opposite of S
D Q’
1
C C Q
0
1
S D latch symbol
0
1
R
0
1
Q
0
12
6
2025-01-05
C1 C2 C3 C4
Clk
Clk_A Clk_B
13
D Flip-Flop
Flip-flop: Bit storage that stores on clock edge, not level rising edges
One design -- master-servant Clk
• Two latches, output of first goes to input of second, master latch
has inverted clock signal
Note:
• So master loaded when C=0, then servant when C=1 Hundreds of
• When C changes from 0 to 1, master disabled, servant loaded with different flip-
flop designs
value that was at D just before C changed -- i.e., value at D during exist
rising edge of C
Clk
D flip-flop
D latch D latch D/Dm
D Q’
Dm Qm Ds Qs’
Cm
Q
Cm Cs Qs Qm/Ds
master servant Cs
Clk Qs
14
7
2025-01-05
D Flip-Flop
15
D Flip-Flop
Solves problem of not knowing through how many latches a signal travels when
C=1
• In figure below, signal travels through exactly one flip-flop, for Clk_A or Clk_B
• Why? Because on rising edge of Clk, all four flip-flops are loaded simultaneously --
then all four no longer pay attention to their input, until the next rising edge.
Doesn’t matter how long Clk is 1.
Y D1 Q1 D2 Q2 D3 Q3 D4 Q4 T each
inside
fli w
pTwo olatches
l
-flop at inside
eachches
flip-flop
Clk
Clk_A Clk_B
16
8
2025-01-05
D3 4 5 6
Q (D latch) 7 8
Q (D flip-flop) 9 10
17
18
9
2025-01-05
Feature: S=1 sets Q Feature: S and R only have Feature: SR can’t be 11 if D is Feature: Only loads D value
to 1, R=1 resets Q to effect when C=1. We can stable before and while C=1, present at rising clock edge, so
0. Problem: SR=11 design outside circuit so and will be 11 for only a brief values can’t propagate to other
yield undefined Q. SR=11 never happens when glitch even if D changes while flip-flops during same clock cycle.
C=1. Problem: avoiding C=1. Problem: C=1 too long Tradeoff: uses more gates
SR=11 can be a burden. propagates new values internally than D latch, and
through too many latches: requires more external gates than
too short may not enable a SR – but gate count is less of an
store. issue today.
Basic Register
Typically, we store multi-bit items
• e.g., storing a 4-bit binary number
Register: multiple flip-flops sharing clock signal
• From this point, we’ll use registers for bit storage
No need to think of latches or flip-flops
But now you know what’s inside a register
I3 I2 I1 I0
4-bit register
D D D D I3 I2 I1 I0
Q Q Q Q reg(4)
clk Q3 Q2 Q1 Q0
Q3 Q2 Q1 Q0
20
10
2025-01-05
x4 a4 a3 a2 a1 a0 b4 b3 b2 b1 b0 c4 c3 c2 c1 c0
re x3
tu x2
ra TemperatureHistoryStorage
x1
sensor
empe x0
t
timer
C
(In practice, we would actually avoid connecting the timer output
C to a clock input, instead only connecting an oscillator output to a clock input.)
21
x4...x0 15 18 20 21 21 22 24 24 24 25 25 26 26 26 27 27 27 27
Ra 0 18 21 24 25 26 27
Rb 0 0 18 21 24 25 26
Rc 0 0 0 18 21 24 25
22
11
2025-01-05
3.3
Finite-State Machines (FSMs) and
Controllers
Want sequential circuit with b Controller
laser
particular behavior over time x
clk
23
24
12
2025-01-05
25
• Transition on rising State Off On1 On2 On3 Off On1 On2 On3 Off
26
13
2025-01-05
b is 0 (b’) b*clk ^
When b is 1 (and rising x=1 clk ^ x=1 clk ^ x=1
On1
• Sets x=1 clk
27
28
14
2025-01-05
FSM Definition
FSM consists of Inputs: b; Outputs: x
• Set of states x=0
29
30
15
2025-01-05
Wait
• Can evaluate output r=0
a a’
input
Inputs
a
waveforms Inputs
a
Outputs Output a
r r
31
• Wait for start (s=1) in “Wait” u=0 s s’ ar’ ab’ ag’ ar’
• Once started (“Start”) a
32
16
2025-01-05
Start
a’
u=0
ar
ab ag ar
Red1 Blue Green Red2
a’ a’ a’
u=0 u=0 u=0 u=1 Note: small problem still
remains; we’ll discuss later
33
outputs
outputs
inputs
b x FSM
FSM
FSM
Combinational n1
logic
inputs
outputs
I O
FSM
n0
FSM
Combinational
logic s1 s0
S clk State register
a m
m-bit m
clk
state register
N
General version
34
17
2025-01-05
3.4
Controller Design
Five step controller design process
35
Step 2: Create
a
b
x=1 x=1 x=1
architecture 01 On1 10 On2 11 On3
b x FSM
FSM
FSM
36
18
2025-01-05
outputs
inputs
FSM
x
FSM
b
Combinational n1
logic
n0
s1 s0
clk State register
37
x
FSM
combinational logic
Combinational n1
logic
n0
a
s1 s0
clk State register
38
19
2025-01-05
outputs
combinational logic
inputs
FSM
x
FSM
b
Combinational
FSM inputs n1
(cont)
logic n1 a
n0
s1 s0
clk State register
n0
s1 s0
x = s1 + s0
n1 = s1’s0 + s1s0’
n0 = s1’s0’b + s1s0’
39
b x b x b x
0 0 0
0 0 0 1 0 0 1 1 1
0 0 1
n1 n1 n1
0 0 1
0 0 0 a
0 1 0
n0 n0 n0
0 1 0
0 0 0
s1 s0 s1 s0 s1 s0
clk clk clk
0 0 0 0 0 1
0 0 0 1 1 0
Inputs:
b
Outputs:
x
40
20
2025-01-05
Controller Example:
Button Press Synchronizer
cycle1 cycle2 cycle3 cycle4
clk
Inputs:
bi
Button press
bi bo
synchronizer Outputs:
controller
bo
41
Controller Example:
Button Press Synchronizer (cont)
outputs
bi bo
inputs
FSM
w
Inputs: none; Outputs: w,x,y,z x Inputs: none; Outputs: w,x,y,z
wxyz=0001 wxyz=1000 y
Combinational z wxyz=0001 wxyz=1000
logic
A D n1 A D
n0 00 11
s1 s0
State register 01 10
B C clk B C
wxyz=0011 wxyz=1100 wxyz=0011 wxyz=1100
Step 1: Create FSM Step 2: Create architecture Step 3: Encode states
w
w = s1 x FSM outputs
x = s1s0’ y
y = s1’s0
z
z = s1’
a
n1 = s1 xor s0
n0 = s0’
n0 n1
s1 s0
clk State register
Step 4: Create state table
Step 5: Create combinational circuit
43
a
K1 K2 K3 K4
r=1 r=1 r=0 r=1
a r outputs
Combinational FSM
FSM
inputs n2
Step 2
logic
n1
n0
s2 s1 s0
clk State register
Inputs: a; Outputs: r
000
r=0 a’
a
Step 3
44
22
2025-01-05
n0=(s1’*s0’)x
z Outputs: y, z
FSM inputs
A B states
n1 yz=10 yz=10
with
D C outputs
n0 yz=00 yz=01
s1 s0
Inputs: x; Outputs: y, z
State register
clk x
x’ A B yz=10
yz=10 x’ x
Work backwards D x’ C yz=01
yz=00
Pick any state names you want x
states with
outputs and
transitions
45
46
23
2025-01-05
47
Simplifying Notations
FSMs
a=0 a=0
b=1 b=0 a
c=0 c=1
• Assume unassigned clk a
output implicitly
assigned 0 b=1 c=1
Sequential circuits
• Assume unconnected a
49
3.5
50
25
2025-01-05
D
Setup time violation
D latch C
D
S hold time
D 1
Q’ S
C 2
u
3 4
Q R
u R 7
Q’ Leads to oscillation!
Q 5 6
51
Metastability clk
Partial solution
• Insert synchronizer flip-flop for asynchronous
input
Special flip-flop with very small setup/hold a
time ai
52
26
2025-01-05
Metastability
One flip-flop doesn’t completely solve problem
How about adding more synchronizer flip-flops?
• Helps, but just decreases probability of metastability
So how solve completely?
• Can’t! May be unsettling to new designers. But we just can’t guarantee a design
that won’t ever be metastable. We can just minimize the mean time between
failure (MTBF) -- a number often given along with a circuit
synchronizers
53
additional inputs Q Q
Q
• Synchronous reset: clears AR AS
R
Q to 0 immediately (not AR
dependent on clock edge)
Example timing diagram Q
shown
• Asynchronous set: set Q
to 1 immediately
54
27
2025-01-05
of circuit D Q’ D Q’
55
Glitching
Glitch: Temporary values on outputs that appear soon after
input changes, before stable new output values
Designer must determine whether glitching outputs may
pose a problem
• If so, may consider adding flip-flops to outputs
Delays output by one clock cycle, but may be OK
56
28
2025-01-05
57
Chapter Summary
Sequential circuits
• Have state
Created robust bit-storage device: D flip-flop
• Put several together to build register, which we used to hold state
Defined FSM formal model to describe sequential behavior
• Using solid mathematical models -- Boolean equations for
combinational circuit, and FSMs for sequential circuits -- is very
important.
Defined 5-step process to convert FSM to sequential circuit
• Controller
So now we know how to build the class of sequential circuits
known as controllers
58
29
2025-01-05
Q&A
January 5, 2025
30