Professional Documents
Culture Documents
Sequential logic
• Latches
• Flip-flops
• Counters
time
time
low
1
1
Is this a stable state?
Andrew H. Fagg: Embedded
Yes! 7
Real-Time Systems: Sequential
Logic
NAND Latch
What happens with S is set to 0?
0
0->?
1->?
1
1->0
1
Q becomes 1 (thus S ‘sets’ Q)
Andrew H. Fagg: Embedded 9
Real-Time Systems: Sequential
Logic
NAND Latch
Now S is set 1 – what happens?
1
1->?
0->?
1
0->1
1
So Q and Q’ retain a memory of past state!
Andrew H. Fagg: Embedded 11
Real-Time Systems: Sequential
Logic
NAND Latch
Now set R to 0 – what happens?
1
1->?
0->?
0
0->1
0
The state flips back (Q is ‘reset’)
Andrew H. Fagg: Embedded 13
Real-Time Systems: Sequential
Logic
NAND Latch
Finally: set R to 1 – what happens?
1
0->?
1->?
1
1->1
1
Q and Q’ do not change state
Andrew H. Fagg: Embedded 15
Real-Time Systems: Sequential
Logic
Timing Diagram Representation
Q
?
Q’
Q’
S
When S returns to high –
R both Q and Q’ remain in
the same state
Q
Q’
Q
?
Q’
R
Q and Q’ flip
state
Q
Q’
Q’
Q
No change in Q and Q’
Q’
0 1 1
1
0 0
1
Note that the meaning of S & R has been inverted
Andrew H. Fagg: Embedded 28
Real-Time Systems: Sequential
Logic
R-S Flip Flop
Clock goes high
0 1 1
0 0
0->1 1 1
1
0 0->1
1->0
No change in Q and Q’
Andrew H. Fagg: Embedded 29
Real-Time Systems: Sequential
Logic
R-S Flip Flop
Clock goes low again
0 1 1
0 0
1->0 1 1
1
0 1->0
0->1
Still no change in Q and Q’
Andrew H. Fagg: Embedded 30
Real-Time Systems: Sequential
Logic
R-S Flip Flop
S goes high
0->1 1 1
0 0
0 1 1
1
0 0
1
Nothing in the circuit changes
Andrew H. Fagg: Embedded 31
Real-Time Systems: Sequential
Logic
R-S Flip Flop
Now: clock goes high
1 1->0 1
0->1 0
0->1 1->0 1
1
0 0->1
1->0
The state of the first latch changes
Andrew H. Fagg: Embedded 32
Real-Time Systems: Sequential
Logic
R-S Flip Flop
Now: clock goes low
1 0->1 1->0
1 0->1
1->0 0 1->0
1
0 1
0->1
The state of the second latch changes!
Andrew H. Fagg: Embedded 33
Real-Time Systems: Sequential
Logic
R-S Flip Flop
Timing Diagram Representation
Q What do Q and Q’
do?
Q’
Andrew H. Fagg: Embedded 47
Real-Time Systems: Sequential
Logic
Clocked R-S Latch
Q
Clock triggers flip
Q’
Andrew H. Fagg: Embedded 48
Real-Time Systems: Sequential
Logic
Clocked R-S Latch
Q
R triggers reset
Q’
Andrew H. Fagg: Embedded 49
Real-Time Systems: Sequential
Logic
Clocked R-S Latch
Q S triggers set
Q’
Andrew H. Fagg: Embedded 50
Real-Time Systems: Sequential
Logic
Clocked R-S Latch
Q What happens to
Q and Q’?
Q’
Andrew H. Fagg: Embedded 53
Real-Time Systems: Sequential
Logic
R-S Flip Flop
R
State change only
C on downward
edge of the clock
Q
Q’
Andrew H. Fagg: Embedded 54
Real-Time Systems: Sequential
Logic
R-S Flip Flop
State change happens at a very precise time
But:
• We must guarantee that R and S are
never high at the same time
• We would like to be able to store the
high/low state of a single line
1 0
1
1
1 0 1 1
1
1 0 1
0
Andrew H. Fagg: Embedded 59
Real-Time Systems: Sequential
Logic
D-Type Flip Flop
Clock transitions from high to low
1 0->1 1 1->0
1->0
1 0 1
0->1
Andrew H. Fagg: Embedded 60
Real-Time Systems: Sequential
Logic
D-Type Flip Flop
Clock transition -> ‘set’ of the slave latch
1 0->1 1 1->0 1
1->0
1 0 1 0
0->1
Andrew H. Fagg: Embedded 61
Real-Time Systems: Sequential
Logic
D-Type Flip Flop
D=0 results in a ‘reset’ of the latch
0 1
1
0
0 1
0 1
1
0 1 1
0
Andrew H. Fagg: Embedded 63
Real-Time Systems: Sequential
Logic
D-Type Flip Flop
Clock transitions from high to low results in a
‘reset’ of the slave latch
0 1
0 1 0
1->0
1 1
0->1 1->0
0->1
Andrew H. Fagg: Embedded 64
Real-Time Systems: Sequential
Logic
D Flip Flop
What happens to
Q Q and Q’?
Q’
Andrew H. Fagg: Embedded 65
Real-Time Systems: Sequential
Logic
D Flip Flop
What happens to
Q Q and Q’?
Q’
Andrew H. Fagg: Embedded 66
Real-Time Systems: Sequential
Logic
D Flip Flop
What happens to
Q Q and Q’?
Q’
Andrew H. Fagg: Embedded 67
Real-Time Systems: Sequential
Logic
D Flip Flop
No change
in state
Q
Q’
Andrew H. Fagg: Embedded 68
Real-Time Systems: Sequential
Logic
D Flip Flops
Clock
CLK
If a boolean variable
can only encode two
different values, how
do we represent a
larger number of
values?
N −1
i
value = ∑ Bi * 2
i =0
while(value ≠ 0)
{
i +1 i
Find i suchthat 2 > value ≥ 2
Bi ← 1
i
value ← value − 2
}
Andrew H. Fagg: Embedded 83
Real-Time Systems: Sequential
Logic
Binary Counter
How would we build a B2 B1 B0
circuit that counts the 0 0 0
number of clock ticks 0 0 1
that have gone by? 0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Andrew H. Fagg: Embedded 84
Real-Time Systems: Sequential
Logic
Binary Counter
How would we build a B2 B1 B0
circuit that counts the 0 0 0
number of clock ticks 0 0 1
that have gone by?
0 1 0
Insight:
• B1 changes state at half 0 1 1
the frequency that B0 1 0 0
does 1 0 1
• B2 changes state at half 1 1 0
the frequency of B1
1 1 1
Andrew H. Fagg: Embedded 85
Real-Time Systems: Sequential
Logic
Ripple Counter
The carry “ripples” down the chain …