Lecture 5
Lecture 5
Sequential Circuits
Store Q…
A
B Y
B B
A A
Y Y
time time
T T+1
Feedback Circuit Example (AND)
▪ Let’s analyze it
A
Q
QT QT+1
A QT QT+1 A QT QT+1
Stuck
at 0 0 0 0 0 0 0
0 1 0 0 1 1 Stuck as 1
1 0 0 1 0 1
1 1 1 1 1 1
Feedback behaviour
▪ NAND behaviour ▪ NOR behaviour
A QT QT+1 A QT QT+1
0 0 1 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 0
Q
Latches
Q Q
B B
0 0 0 1 0 1
Hold
0 0 1 0 1 0
0 1 X X 0 1 Reset
1 0 X X 1 0 Set
1 1 X X 0 0 Forbidden
Question #3 R
Q
▪ Complete the truth table
Don’t-care inputs allowed.
Q
▪ And name the 4 possible S
0 0 0 1 0 1
Hold
0 0 1 0 1 0
0 1 X X 0 1 Reset
1 0 X X 1 0 Set
1 1 X X 0 0 Forbidden
Summary: S’R’ and SR latches
S R QT QT QT+1 QT+1
0 0 X X 1 1 Forbidden state S Q
0 1 X X 1 0 Set Q to 1
SR-latch 1 0 X X 0 1 Reset Q to 0 R Q
1 1 0 1 0 1
1 1 1 0 1 0
Maintain Q
“set” and “reset”
S R QT QT QT+1 QT+1 cannot be both true!
0 0 0 1 0 1
SR-latch 0 0 1 0 1 0
Maintain Q
S Q
0 1 X X 0 1 Reset Q to 0
1 0 X X 1 0 Set Q to 1
1 1 X X 0 0 Forbidden state R Q
12
Question #4
Q
Clocks
time
1 second
Clocked/Gated latches
▪ Positive edge: D Q
triggered on rising edge of the
C
clock Q
▪ Negative edge: D Q
triggered on falling edge of
C
the clock Q
Flip-flops
▪ For input to propagate to
output, it takes each of the CLK
latches to be active once.
▪ First latch changes on “flip”.
▪ Output can only change
upon “flop”, which is CLK
basically the falling edge of
the clock signal
▪ At most one change per
clock cycle
Flip-flops
▪ We have:
D flip-flops (most common type!)
SR flip-flops
T flip-flops (for “toggle”)
JK flip-flops
Week 5: Sequential
Circuit Design
Part A: registers
Assembly Language
Processors
Arithmetic Finite State
Logic Units Machines
Devices Flip-flops
Circuits
Gates
Transistors
We are here
Assembly Language
Processors
Arithmetic Finite State
Logic Units Machines
Devices Flip-flops
Circuits
Gates
Transistors
Circuits using flip-flops
▪ Now that we know Inputs
Combinational
Outputs
D0 Q D1 Q D2 Q D15 Q
…
Q Q Q Q
Clk
Q Q Q Q
Clk
Q Q Q Q
Clk
Shift registers
▪ Illustration: shifting in 0101010101010101
1 0 1 0
SI D0 Q D1 Q D2 Q D15 Q
Q Q Q Q
Clk
D0 D1 D2 D3
D Q D Q D Q D Q
Q Q Q Q
Clk
Load registers
▪ D flip-flop with enable: controls when the
flip-flop is allowed to load D :
When EN = 1, D2 is whatever D is → load D
When EN = 0, D2 is whatever Q is → maintain Q
EN
D2 Q D Q
D EN
Clk Q Q
Load registers
▪ D flip-flop with enable: controls when the
flip-flop is allowed to load D :
When EN = 1, D2 is whatever D is → load D
When EN = 0, D2 is whatever Q is → maintain Q
EN
0 D Q D Q
D 1 EN
Clk Q Q
Load registers
D0 D1 D2 D3
D Q D Q D Q D Q
EN EN EN EN
Q Q Q Q
Write
Clk
PCI PCIe
▪ Parallel ▪ Serial
▪ Many pins ▪ Fewer pins… yet faster
Memory Hierarchy
▪ In computer architecture, registers are
the first level in the memory hierarchy.
• registers
▪ The CPU’s most local, fastest storage
30+ of them on-chip.
• cache
▪ They are the memory units that the
CPU interacts with directly for
• RAM
computation.
Anything else is too far, and is mediated
by registers. • disk
37
▪ What else can we build?
Week 5, part B: Counters
Idea for A Counter
▪ Load register + Ripple Carry Adder
n
n
adder register
n
…00001
Clk
Idea for A Counter
▪ Example: 4-bit counter
0 0 0 1
X3 Y3 X2 Y2 X1 Y1 X0 Y0
1
4-bit adder
S3 S2 S1 S0
D Q D Q D Q D Q
EN EN EN EN
Q Q Q Q
Write
Clk
Idea for A Counter
▪ Will this work?
n
n
adder register
n
…00001
Clk
T Q T Q T Q T Q
Q Q Q Q
Counters
1
Q0 Q1 Q2 Q3
T Q T Q T Q T Q
Q Q Q Q
T Q T Q T Q T Q
C
▪ Timing diagram Q Q Q Q
Q0
Q1
Q2
Q3
Counters 1
Q0 Q1 Q2 Q3
T Q T Q T Q T Q
C
▪ Timing diagram Q Q Q Q
Q0 0 1 0 1 0 1 0 1 0
Q1 0 0 1 1 0 0 1 1 0
Q2 0 0 0 0 1 1 1 1 0
Q3 0 0 0 0 0 0 0 0 1
Counters 1
Q0 Q1 Q2 Q3
T Q T Q T Q T Q
C
▪ Timing diagram Q Q Q Q
Q= 0 1 2 3 4 5 6 7 8
Q0 0 1 0 1 0 1 0 1 0
Q1 0 0 1 1 0 0 1 1 0
Q2 0 0 0 0 1 1 1 1 0
Q3 0 0 0 0 0 0 0 0 1
Counters 1
Q0 Q1 Q2 Q3
T Q T Q T Q T Q
C
▪ Timing diagram Q Q Q Q
Q0
Q1
Q2
Q3
Counters
1
Q0 Q1 Q2 Q3
T Q T Q T Q T Q
Q Q Q Q
T Q T Q
T Q T Q Q2 Q3
Q0 Q1
Q Q
Q Q
Clk
https://www.youtube.com/watch?v=_0kGZhUE5D0
When load is high,
Counters with Load read from Ri instead
of toggling
Load
Write
R0 R1
1 1
D Q 0 D Q
0
Q Q
Clk
Clear