Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
CS221 Di it l D iCS221: Digital Design
Clocked R‐S, D, J‐K and T Flip‐Flop
Dr. A. Sahu
Dept of Comp. Sc. & Engg.Dept of Comp. Sc. & Engg.
Indian Institute of Technology Guwahati
OutlineOut e• Design a new building block, a flip‐flop, that
bistores one bit
• Latch Vs Flip Flop
• Master Slave Flip‐Flop
• D Flip‐Flop J‐K Flip‐Flop and T Flip‐FlopD Flip Flop, J K Flip Flop and T Flip Flop
• Combine that block to build multi‐bit storage a register– a register
Sequential CircuitSequential Circuit
xbCombinational
logicn1
n0
xbInput output
History/S /St t
s1 s0n0
clk Where to Sequence/State Store this
History
Y (t) = F (a(t),b(t), H)H is History/Sequence/State
(Memory Element)
H is History/Sequence/State
Bit Storage Using an SR Latch
• Does the circuit to the right, with cross‐coupled NOR gates, do what we want?
S (set) SR latch
p g ,– Yes! How did someone come up with that circuit?
Maybe just trial and error, a bit of insight...Q
R (reset)
S=0 S=0 S=1 S=0
0
0
1
S=0 t1 10
1
tS=0
tS=1
01
tS=0
01
001
R=1
Q
1
0 01
Q
R=0
Q
R=0
1 Q
R=0
10
1010
R
S
1t0
t10
Q
Problem with SR Latch: Race Condition• Problem: If S=1 & R=1 simultaneously and both released to 0, we don’t know what value Q will
1takeS=1
0 0t S=0
0 1t S=0
1 0t
0
10
S
R
0 0 Q0 1 Q
1 0 Q
0
0
1
1
t
R=1 R=0 R=00
1Q
Q may oscillate. Then, because one 1
t01
path will be slightly longer than the other, Q will eventually settle to 1 or 0 – but we don’t know which 1
Q0
0 but we don t know which.
Problem with SR Latch• Problem not just one of a user pressing two buttons at same time
• Can also occur even if SR inputs come from a circuit that supposedly never sets S=1 and R=1 at same time
But does due to different delays of different paths– But does, due to different delays of different paths
1
0XX S SR latch
Arbitrarycircuit
0
1
0Y
Q1
0
1
S
R
SR = 11
The longer path from X to R than to S
RY
0RThe longer path from X to R than to S
causes SR=11 for short time – could be long enough to cause oscillation
Solution: Level‐Sensitive SR LatchSolution: Level Sensitive SR Latch• Add enable input “C” as shown
– Only let S and R change when C=0Only let S and R change when C 0• Ensure circuit in front of SR never sets SR=11, except briefly due to path delays
Ch C t 1 l ft ffi i t ti f S d R t b t bl– Change C to 1 only after sufficient time for S and R to be stable– When C becomes 1, the stable S and R value passes through the two AND gates to the SR latch’s S1 R1 inputs.
S1SLevel-sensitive SR latch S
Q’
C
CQ
R
R1R
Q Level-sensitive SR latch symbol
Solution: Level‐Sensitive SR Latch
S1SX
Level-sensitive SR latch
CClk
Q
R1Y
RQ
Though SR=11 briefly...
010S
R
1
0
01
01
C
S1
a
...S1R1 never = 11
0
01
R1
Solution: Ensure, Stabilize, Store
S1SX
Level-sensitive SR latch
S1X
CCClk
Q
R1Y
RQ
EnsureStage
Stabilize StageWhen C=0
Store Stage
Never Happens SR=11
When C=0 Stabilize SR and Use when C=1 Store bit
Clocks
• Clock period: time interval between pulsespulses – Above signal: period = 20 ns
• Clock cycle: one such time interval 100 GHz 0.01 ns
PeriodFreq
– Above signal shows 3.5 clock cycles• Clock frequency: 1/period
– Above signal: frequency = 1 / 20 ns = 50
10 GHz1 GHz
100 MH
0.1 ns1 ns
10 nsAbove signal: frequency = 1 / 20 ns = 50 MHz
• 1 Hz = 1/s
100 MHz10 MHz
10 ns100 ns
Clock Signals for a Latchd k h ’ f• How do we know when it’s safe to set C=1?
– Most common solution –make C pulse up/downC 0 Safe to change X Y C 1 Must not change X Y– C=0: Safe to change X, Y C=1: Must not change X, Y
– Clock signal ‐‐ Pulsing signal used to enable latches • Because it ticks like a clockBecause it ticks like a clock
– Sequential circuit whose storage components all use clock signals: synchronous circuit
S1S
X
Level-sensitive SR latch
CClk
Q
R1Y
RQ
Level‐Sensitive D Latch• SR latch requires careful design to ensure SR=11 never occurs D
D latchensure SR=11 never occurs
• D latch relieves designer of that burden
SD
Cburden– Inserted inverter ensures R always opposite of S
C
Q
R
1
0D
C1
0 D Q’
S
R
0
1
0
1
0
1
QC
D latch symbolQ
1
0
Problem with Level‐Sensitive D Latch• D latch still has problem (as does SR latch)
– When C=1, through how many latches will a signal travel?D d f h l C 1– Depends on for how long C=1
• Clk_A ‐‐ signal may travel through multiple latches• Clk_B ‐‐ signal may travel through fewer latchesd i k h i j h i h l h– Hard to pick C that is just the right length
• Can we design bit storage that only stores a value on the rising edge of a clock signal?
D1 Q1 D2 Q2 D3 Q3 D4 Q4Y rising edges
C4C3C2C1
ClkClk
Clk_A Clk_B
Flip FlopFlip Flop
• Coin Flip : Head/Tail (1/0)• Coin Flip : Head/Tail (1/0)• Latch have either one state 0 or 1• Flip‐Flop (Both Master/Slave)
–Flip State/Flop State
Master ‐Slave D Flip‐Flop•• FlipFlip‐‐flopflop:: stores stores on clock edge, not level on clock edge, not level • Two latches, output of first goes to input of second, master latch
has inverted clock signal• So master loaded when C=0, then servant when C=1• When C changes from 0 to 1 master disabled servant loaded withWhen C changes from 0 to 1, master disabled, servant loaded with
value that was at D just before C changed ‐‐ i.e., value at D during rising edge of C
D flip-flopClk
D/DmD latch D latch
D Dm DsQm Qs’Q’
D flip-flop
Qm/Ds
CmCs Qs QCm
Cs
Qs
master servant
Clk
Thanks