









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Digital DesignCopyright © 2006Frank Vahid
Slides to accompany the textbook
Digital Design
, First Edition,
by Frank Vahid, John Wiley and Sons Publishers, 2007.
http://www.ddvahid.com
Modified by Jay Brockman, University of Notre Dame, 2007
Copyright © 2007
Frank Vahid
Instructors of courses requiring Vahid's Digital Design textbook (published by John Wiley and Sons) have permission to modify and use these slides for customary course-related activities,subject to keeping this copyright notice in place and unmodified. These slides may be posted as unanimated pdf versions on publicly-accessible course websites.. PowerPoint source (or pdfwith animations) may
not
be posted to publicly-accessible websites, but may be posted for students on internal protected sites or distributed directly to students by other electronic means.
Instructors may make printouts of the slides available to students for a reasonable photocopying charge, without incurring royalties. Any other use requires explicit permission. Instructorsmay obtain PowerPoint source or obtain special use permissions from Wiley – see http://www.ddvahid.com for information.
Digital DesignCopyright © 2006Frank Vahid
Output depends not just on present inputs (as incombinational circuit), but on past sequence of inputs
Stores bits, also known as having “state”
Simple example: a circuit that counts up in binary
Design a new building block, a
flip-flop
, that stores
one bit
Combine that block to build multi-bit storage – a register
Describe the sequential behavior using a
finite state
machine
Convert a finite state machine to a
controller
sequential circuit having a register and combinationallogic
si
ez
ansis
Combinational
digital circuit
a b
a b
Must know sequence of
past inputs to
know output
Sequential
digital circuit
Note: Slides with animation are denoted with a small red "a" near the animated items
Digital DesignCopyright © 2006Frank Vahid
Stays on
after button released
Q
Call
Cancel
a
a
Bit
Storage
Blue light
Call
button Cancel
button
Bit
Storage
Blue light
Call
button Cancel
button
Bit
Storage
Blue light
Call
button Cancel
button
Jay Brockman, 2007
Feedback-Based Storage
How do you get the data in and out?
Jay Brockman, 2007
MUX Based Latches
Q
D
1 0 clk
Positive Latch
Q
D
0 1 clk
Negative Latch
Q = !clk & Q
| clk & D
Q = clk & Q
| !clk & D
feedback
transparent when the
clock is low
transparent when the
clock is high
feedback
Change the stored value by cutting the feedback loop
[Adapted from Mary Jane Irwin and Vijay Narananan, adaptation of Rabaey’s
Digital Integrated Circuits
, ©2002, J. Rabaey et al.]
SR Latch
disallowed
0
0
1
1
reset
1
0
1
0
set
0
1
0
1
memory
!Q
Q
0
0
!Q
Q
R
S
S R
!Q Q
[Adapted from Mary Jane Irwin and Vijay Narananan, adaptation of Rabaey’s
Digital Integrated Circuits
, ©2002, J. Rabaey et al.]
Digital DesignCopyright © 2006Frank Vahid
Example Using SR Latch for Bit Storage
SR latch can serve as bitstorage in previous exampleof flight-attendant call button
Q stays 1 even after Call=
But, there’s a problem...
Call
but t on
Blue light
Cancelbut t on
Bit
Storage
Blue lig
ht
Call
but ton
Cancel but ton
Digital DesignCopyright © 2006Frank Vahid
Problem with Level-Sensitive D Latch
D latch still has problem (as does SR latch)
Clk_A -- signal may travel through multiple latches
Clk_B -- signal may travel through fewer latches
Can we design bit storage that only stores a value on the rising edge ofa clock signal?
D
Q
D
Q
D
Q
D4 C
C
C
C
Q
Y
Clk Clk_A
Clk_B
Clk
rising edges
Digital DesignCopyright © 2006Frank Vahid
D Flip-Flop
Flip-flop
: Bit storage that stores on clock edge, not level
One design -- master-servant
Two latches, output of first goes to input of second, masterlatch has inverted clock signal
So master loaded when C=0, then servant when C=
When C changes from 0 to 1, master disabled, servantloaded with value that was at D just before C changed -- i.e.,value at D during rising edge of C
Clk
rising edges
Note:Hundreds ofdifferent flip-flop designsexist
Master Slave Based ET Flipflop
Q
D
1 0
Q
0 1
Slave
Master
Q
D
clk 1 0
Q
clk
0 1
Slave
Master
clk
Q
D Q
clock
D FF
Q
D
clk = 0 transparent
hold
clk = 0
→
1
hold
transparent
[Adapted from Mary Jane Irwin and Vijay Narananan, adaptation of Rabaey’s
Digital Integrated Circuits
, ©2002, J. Rabaey et al.]
Digital DesignCopyright © 2006Frank Vahid
D Flip-Flop
D
Q’
Q
Q’
D
Q
Symbol for rising-edge
triggered D flip-flop
Symbol for falling-edge
triggered D flip-flop
Clk
rising edges
Clk
falling edges
Internal design: Justinvert servant clockrather than master
The trianglemeans clockinput, edgetriggered
Digital DesignCopyright © 2006Frank Vahid
D Flip-Flop
Solves problem of not knowing through how many latches a signaltravels when C=
In figure below, signal travels through exactly one flip-flop, for Clk_A orClk_B
Why? Because on rising edge of Clk, all four flip-flops are loadedsimultaneously -- then all four no longer pay attention to their input, until thenext rising edge. Doesn’t matter how long Clk is 1.
D
Q
D
Q
D
Q
D
Q
Y
Clk
Clk_A
Clk_B
Tw ol atches
insideeach
flip-flop
Digital DesignCopyright © 2006Frank Vahid
D Latch vs. D Flip-Flop
Latch is level-sensitive: Stores D when C=
Flip-flop is edge triggered: Stores D when C changes from0 to 1
redundant
Comparing behavior of latch and flip-flop:
Clk
Q (D latch)
Q (D flip-flop)
Digital DesignCopyright © 2006Frank Vahid
Flight-Attendant Call Button Using D Flip-Flop
D flip-flop will store bit
Inputs are Call, Cancel, and present valueof D flip-flop, Q
Truth table shown below
Preserve value: ifQ=0, make D=0; ifQ=1, make D=1Cancel -- makeD=0Call -- make D=1Let’s give priorityto Call -- makeD=
Call
but tonCancelbut ton
Flight
attendant
call-button
system
Bluelight
D
Q’
Q
Clk
Call
but ton
Cancel but ton
Bluelight
Call
Cancel
Q
Digital DesignCopyright © 2006Frank Vahid
Basic Register
Typically, we store multi-bit items
Register
: multiple flip-flops sharing clock signal
No need to think of latches or flip-flops
But now you know what’s inside a register
I
I
I1 I
Q3 Q2 Q1 Q
reg(4)
Digital DesignCopyright © 2006Frank Vahid
Describing Behavior of Sequential Circuit: FSM
Finite-State Machine (FSM)
behavior of sequential circuit
Akin to Boolean equations forcombinational behavior
among states
Example: Make x changetoggle (0 to 1, or 1 to 0) everyclock cycle
Two states: “Off” (x=0), and“On” (x=1)
Transition from Off to On, orOn to Off, on rising clock edge
Arrow with no starting statepoints to initial state (whencircuit first starts)
Outputs: x
On
Off x=
x=
clk
clk
Digital DesignCopyright © 2006Frank Vahid
FSM Example: 0,1,1,1,repeat
Want 0, 1, 1, 1, 0, 1, 1, 1, ...
Can describe as FSM
edge to next state
Digital DesignCopyright © 2006Frank Vahid
Extend FSM to Three-Cycles High Laser Timer
Four states
Wait in “Off” state while b is0 (b’)
When b is 1 (and risingclock edge), transition toOn
transition to On2, then On3,which also set x=
So x=1 for three cycles afterbutton pressed
Digital DesignCopyright © 2006Frank Vahid
FSM Simplification: Rising Clock Edges Implicit
Showing rising clock on everytransition: cluttered
edge has rising clock, even if notshown
without
a rising edge
We don’t consider suchasynchronous FSMs -- lesscommon, and advanced topic
Only consider
synchronous
FSMs -- rising edge on
every
transition
Note: Transition with no associated condition thustransistions to next state on next clock cycle
On
On
On
Off
x=
x=
x=0 x=
b’
b
Inputs: b; Outputs: x
Inputs: b; Outputs: x
a
Digital DesignCopyright © 2006Frank Vahid
FSM Definition
FSM consists of
Ex: {Off, On1, On2, On3}
Ex: Inputs: {b}, Outputs: {x}
Ex: “Off”
Describes next states
Ex: Has 5 transitions
Sets outputs while in states
Ex: x=0, x=1, x=1, and x=
Inputs: b; Outputs: x
On
On
On
Off
x=
x=
x=0 x=
b’
b
We often draw FSM graphically,
known as
state diagram
Can also use table (state table), or
textual languages
typo
Digital DesignCopyright © 2006Frank Vahid
FSM Example: Secure Car Key
Many new car keys includetiny computer chip
computer (under engine hood)requests identifier from key
If not, computer shuts off car
FSM
ID (a=1)
Digital DesignCopyright © 2006Frank Vahid
FSM Example: Secure Car Key (cont.)
Nice feature of FSM
for different input sequence
and output values for differentinput waveforms
r=
r=
r=
r=
Wait
r=
Inputs: a; Outputs: r
a’
a
Wait
Wait
Wait Wait
clk
Inputs
Outputs
State
a
r
clk
Inputs
a
Wait
Wait
Wait
Output
State
r
Q: Determine states and r value forgiven input waveform:
a
Digital DesignCopyright © 2006Frank Vahid
FSM Example: Code Detector
Unlock door (u=1) only whenbuttons pressed in sequence:
start, then red, blue, green, red
Input from each button:
s, r, g, b
Also, output
a
indicates that
some colored button pressed
FSM
Wait for start (s=1) in “Wait”
Once started (“Start”)
If see red, go to “Red1”
Then, if see blue, go to “Blue”
Then, if see green, go to“Green”
Then, if see red, go to “Red2”
Wrong button at any step, returnto “Wait”, without opening door
Q: Can you trick this FSM to open the door,without knowing the code?
A: Yes, hold all buttons simultaneously
a
a
a
Digital DesignCopyright © 2006Frank Vahid
Controller Design: Laser Timer Example (cont)
Step 4: Create state table
Combinational
logic
State register
s
s
n1n
x
b clk
inputs
outputs
a
Digital DesignCopyright © 2006Frank Vahid
Controller Design: Laser Timer Example (cont)
Step 5: Implementcombinational logic
Combinational
logic
State register
s
s
n1 n
x
b clk
inputs
outputs
a
x = s1 + s
n1 = s1’s0b’ + s1’s0b + s1s0’b’ + s1s0’bn1 = s1’s0 + s1s0’n0 = s1’s0’b + s1s0’b’ + s1s0’bn0 = s1’s0’b + s1s0’
Digital DesignCopyright © 2006Frank Vahid
Controller Design: Laser Timer Example (cont)
Step 5: Implementcombinational logic (cont)
a
x = s1 + s0n1 = s1’s0 + s1s0’n0 = s1’s0’b + s1s0’
Combinational
logic
State register
s
s
n1n
x
b clk
inputs
outputs
n1 n
s
s
clk
Combinational Logic
State register
b
FSMoutputs
FSMinputs
x
Digital DesignCopyright © 2006Frank Vahid
Understanding the Controller’s Behavior
s
s
b
x
n1 n
x=
x=
x=
b
01
10
11
On
On
Off
On
00
0
0
0 00 0
b’
0
0 0
0
0
x=
0
00
clk
clk
Inputs:
Outputs:
0 1
1
0
b 1
0 01 0
s
s
b
x n1 n
x=
x=
x=
b’
01
10
11
On
On
Off
On
clk
b x
00
0
0
x=
0
00
state=
state=
s
s
b
x n1 n
x=
x=
x=
x=
b
b’
01
00
10
11
On
On
Off
On
1
1 1 0
011 00 0
clk
0
1
0
1
state=
a
Digital DesignCopyright © 2006Frank Vahid
Example: Seq. Circuit to FSM
(Reverse Engineering)
State register
FSMoutputs
FSMinputs
What does thiscircuit do?
Work backwards
y=s1’z = s1s0’n1=(s1 xor s0)xn0=(s1’*s0’)x
a
Pick any state names you want
A D
B C
states
Outputs:y, z
A D
B
yz=
yz=
yz=
yz=
C
stateswithoutputs
A D
B
yz=
yz=
yz=
yz=
C
Inputs: x; Outputs:y, z
x’ x’
x’
x
x
x
states withoutputs andtransitions
Digital DesignCopyright © 2006Frank Vahid
Controller Example: Sequence Generator
Want generate sequence 0001, 0011, 1100, 1000, (repeat)
Each value for one clock cycle
Common, e.g., to create pattern in 4 lights, or control magnets of a “stepper motor”
00
01
11 10
A
B
D
wxyz=
wxyz=
wxyz=
wxyz=
C
Inputs: none; Outputs: w,x,y,z
clk
State register
wx y
z
FSMoutputs
n
s
s
n
w = s1x = s1s0’y = s1’s0z = s1’n1 = s1 xor s0n0 = s0’
a
wxyz=
wxyz=
wxyz=
wxyz=
Inputs: none; Outputs: w,x,y,z
Combinational
logic
n
s
s
n
clk
State register
wxy
z
Digital DesignCopyright © 2006Frank Vahid
Controller Example: Secure Car Key
(from earlier example)
K
K
K
K
r=
r=
r=
r=
Wait
r=
Inputs: a; Outputs: r
a’
a
FSM
Combinational
logic
s
s
s
n
r
a
n1n
clk
State register
FSM
inputs
outputs
a
r=
r=
r=
r=
r=
Inputs: a; Outputs: r
Step 3
a
Digital DesignCopyright © 2006Frank Vahid
Controller Example:
Button Press Synchronizer
Want simple sequential circuit that converts button press tosingle cycle duration, regardless of length of time thatbutton actually pressed
like the button in the laser timer controller
cycle
cycle
cycle
cycle
clk
Inputs:
Outputs:
bi
bo
bi
bo
Digital DesignCopyright © 2006Frank Vahid
Simplifying Notations
FSMs
implicitly assigned 0
Sequential circuits
inputs connected to sameexternal clock
clk
a a
a
Digital DesignCopyright © 2006Frank Vahid
More on Flip-Flops and Controllers
Other flip-flop types
Æ
J, R
Æ
K)
But when JK=11, toggles
1
Æ
0, 0
Æ
1
Toggles on every rising clock edge
Today, minimizing logic to such extent is not as important
D flip-flops are thus by far the most common
Digital DesignCopyright © 2006Frank Vahid
Non-Ideal Flip-Flop Behavior
Can’t change flip-flop input too close to clockedge
Setup time: time that D must be stable
before
edge
Else, stable value not present at internal latch
Hold time: time that D must be held stable
after
edge
Else, new value doesn’t have time to loop aroundand stabilize in internal latch
clk
clk
setup time
hold time
S R
D C
u
D latch
Q’ Q
1
2
3
4
5
6
7
C DS u R Q’
Q
Digital DesignCopyright © 2006Frank Vahid
Metastability
Violating setup/hold time can lead to badsituation known as
metastable
state
Metastable state: Any flip-flop state otherthan stable 1 or 0
Eventually settles to one or other, but wedon’t know which
For internal circuits, we can make sureobserve setup time
But what if input comes from external(asynchronous) source, e.g., buttonpress?
Partial solution
Insert synchronizer flip-flop forasynchronous input
Special flip-flop with very small setup/holdtime
Doesn’t completely prevent metastability
clk
D Q
setup time
violation
metastable
state
ai ai
synchronizer
a
Digital DesignCopyright © 2006Frank Vahid
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 adesign that won’t ever be metastable. We can just minimize the mean timebetween failure (MTBF) -- a number often given along with a circuit
Digital DesignCopyright © 2006Frank Vahid
Flip-Flop Set and Reset Inputs
Some flip-flops haveadditional inputs
on next clock edge
next clock edge
immediately (not dependent onclock edge)
Example timing diagram shown
immediately
Q’
AR AS
D
Q
cycle 1
cycle 2
cycle 3
cycle 4
clk
Digital DesignCopyright © 2006Frank Vahid
Initial State of a Controller
All our FSMs had initial state
did not
with reset/set inputs
Shown circuit initializes flip-flops to 01
is 1 during power up of circuit
By electronic circuit design
Inputs: x; Outputs: b
On
On
On
Off
x=
x=
x=0 x=
b’
b
State register
clk
reset
s
s
n1 n
b
x
Combinational
logic
Digital DesignCopyright © 2006Frank Vahid
Glitching
Glitch: Temporary values on outputs that appear soon afterinput changes, before stable new output values
Designer must determine whether glitching outputs maypose a problem
Delays output by one clock cycle, but may be OK