Professional Documents
Culture Documents
EECS 150 - Components and Design Techniques For Digital Systems
EECS 150 - Components and Design Techniques For Digital Systems
David Culler
Electrical Engineering and Computer Sciences
University of California, Berkeley
http://www.eecs.berkeley.edu/~culler
http://www-inst.eecs.berkeley.edu/~cs150
Traversing Digital Design
EECS150 wks 6 - 15
EE 40 CS61C
Types of Latches
• We have focused on D-flips
– D latch => D FlipFlop => Registers (ld, clr)
– Most commonly used today (CMOS, FPGA)
• Many other types of latches
– RS, JK, T
– Should be familiar with these too
• Opportunity to look much more closely at timing
behavior
Clock
Example – ring oscillator
A B C D E X
A (=X) 0 1
B 1
C 0
D 1
E 0
option feedback
output Tsu Th
X1 Z1
X2 Z2
• switching •
• network •
• •
Xn Zn
Simplest Circuits with Feedback
"1"
"stored value"
"0"
• How to get a new value into the memory cell?
– Selectively break feedback path
– Load new value into cell
"remember"
D Q
• Level-sensitive latch
– holds value when clock is low a b
– Transparent when clock is high D Q D Q
period
Two-phase non-overlapping clocks
• Sequential elements a b
partition into two classes D Q c/l D Q
D
clk
Q
• Construct D flipflop from
setup time clock to Q delay two D latches
clk clk’
clk clk’
clk’ clk
clk’ clk
Latches vs FlipFlips
• Level sensitive vs edge triggered
• Very different design methodologies for correct use
• Both are clocked, but latch is asynchronous
– Output can change while clock is high
Clk
Q
FF
Q
Latch
Asynchronous R-S Latch
• Cross-coupled NOR gates
– Similar to inverter pair, with capability to force output to 0 (reset=1)
or 1 (set=1)
1 0
R Q
Q
R
S Q'
S
0 1
• Cross-coupled NAND gates
– Similar to inverter pair, with capability to force output to 0 (reset=0)
or 1 (set=0)
S' Q
Q
S'
R'
Q'
R'
State Behavior of R-S latch
• Transition Table characteristic equation
Q(t+) = S + R’ Q(t)
S(t) R(t) Q(t) Q(t+)
0 0 0 0
hold R Q
0 0 1 1
0 1 0 0
reset
0 1 1 0
1 0 0 1 S Q'
set
1 0 1 1
1 1 0 X not allowed S
1 1 1 X 0 0 X 1
Q(t) 1 0 X 1
R
R Q
SR=10
SR=00 SR=00
SR=01 SR=10
S Q' Q Q' SR=01 Q Q'
0 1 1 0
SR=01 SR=10
SR=11
• State Diagram
Q Q'
– States: possible values 0 0
SR=11 SR=11
– Transitions: changes
based on inputs SR=00
SR=00 SR=11
SR=01 SR=10
R Q
S Q'
R
S
Q
\Q
Observed R-S Latch Behavior
• Very difficult to observe R-S latch in the 1-1 state
– One of R or S usually changes first
• Ambiguously returns to state 0-1 or 1-0
– A so-called "race condition"
– Or non-deterministic transition
SR=10
SR=00 SR=00
SR=01 SR=10
Q Q' SR=01 Q Q'
0 1 1 0
SR=01 SR=10
SR=11
Q Q'
SR=11 0 0 SR=11
SR=00 SR=00
Announcements
• Great early check-offs
– About 2/3s of class signed up.
– Excellent projects on Monday.
– If you signed up and we didn’t get to you, check off at regular time, but
get 10% anyways (using frozen files)
• Issues on CP3? – today is deadline to talk to us
– “borrowed” or “provided” solutions
– Engineer’s code of ethics: always state sources of work
» Credit where it is due, protect yourself, protect your employer
• EECS in the NEWS
– Towards quantum computing
– 5-7 bit devices have been built
– Fundamental algorithmic differences
» Factoring large prime numbers
– Computational view of quantum theory
» New undergrad course vazirani
Kubiatowicz
Gated R-S Latch
• Control when R and S
inputs matter
– Otherwise, the slightest R' R
glitch on R or S while Q
enable is low could cause
enable'
change in value stored
Q'
– Ensure R & S stable S'
before utilized (to avoid S
transient R=1, S=1)
Set Reset
100
S'
R'
enable'
Q
Q'
Towards a Synchronous Design
• Controlling an R-S latch with a clock
– Can't let R and S change while clock is active (allowing R and S
to pass)
– Only have half of clock period for signal changes to propagate
– Signals must be stable for the other half of clock period
R' R
Q
clock'
Q'
S' S
stable changing stable changing stable
R' and S'
clock
JK Flip Flops
1 0
D’ D Act as inverters
D’
0
R 0 Q
D’
0
R 0 Q
Clk=1
S
D0
1
0 01
D D’
11 0
D-FF Behavior when CLK=1
clk
D’ Du 0->1
1->0
Du’ 0 D
R
Q D’
Clk=1
Q’
S Du
Dl
R=Du’
0
S=Dl
D D’
1->0
0->1 Q
Q’
Change in D propagate through lower and upper latch, but R=S=0, isolating slave
Behavior when CLK 1->0
clk
D’ Du 1
Du’ 0 D
R
Q D’
Q->1
Clk=1
1->0 Q’
S Du
Q’->0
Dl 0->1 R=Du’
0
S=Dl
D D’
0
1 Q
Q’
Falling edge allows latched D to propagate to output latch
D-FF; behavior when CLK==0
0
D’ D D->~D’=D
• Lower output 0
• Upper latch retains
D’
old D
R
Q • RS unchanged
Clk=0
Q’
S
D
R’=Q=old D
new D D’
D’->0
new D old D
D’
0
0
R
Q
Clk=0
1
S
10
D0
1 1
0
D D’
0
Edge-Triggered Flip-Flops (cont’d)
• Positive edge-triggered
– Inputs sampled on rising edge; outputs change after rising edge
• Negative edge-triggered flip-flops
– Inputs sampled on falling edge; outputs change after falling edge
100
D
CLK
Qpos
Qpos' positive edge-triggered FF
Qneg
negative edge-triggered FF
Qneg'
Timing Methodologies
Tsu Th data
D Q D Q
input
clock clock
Q0 Q1
IN D Q D Q OUT
CLK
100
IN
Q0
Q1
CLK
Cascading Edge-triggered Flip-Flops
(cont’d)
• Why this works
– Propagation delays exceed hold times
– Clock width constraint exceeds setup time
– This guarantees following stage will latch current value before
it changes to new value
In
Tsu Tsu
timing constraints
4ns 4ns
Q0 guarantee proper
operation of
Tp Tp
3ns 3ns cascaded components
Q1
Th Th
2ns 2ns
Clock Skew
• The problem
– Correct behavior assumes next state of all storage elements
determined by all storage elements at the same time
– This is difficult in high-performance systems because time for
clock to arrive at flip-flop is comparable to delays through logic
– Effect of skew on cascaded flip-flops:
100
In
CLK1 is a delayed
Q0 version of CLK0
Q1
CLK0
CLK1
original state: IN = 0, Q0 = 1, Q1 = 1
due to skew, next state becomes: Q0 = 0, Q1 = 0, and not Q0 = 0, Q1 = 1
clock input
option feedback
output
Where does this breakdown?
• Interfacing to the physical world
• Can’t tell it “not to change near the clock edge”
Digital
Abstraction
Example Problems
Clocked Synchronizer
Synchronous
System
Async Q0 Async Q0
D Q Input D Q D Q
Input
Clock Clock
Q1 D Q Q1
D Q
Clock Clock
In
In is asynchronous and
fans out to D0 and D1
Q0
one FF catches the
signal, one does not
Q1
inconsistent state may
be reached!
CLK
Metastability
horrible example
• In worst cast, cannot bound time for FF to
In ?
decide if inputs can change right on the D Q
edge
– Circuit has a metastable balance point
logic 0 logic 1
Practical Solution
Synchronizer
Async Q0 Q1
D Q D Q D Q
Input
Clock Clock
• Series of synchronizers
– each reduces the chance of getting stuck (exponentially)
• Make P(metastability) < P(device failure)
• Oversample and then low pass
Metastability throughout the ages