Feedback and Flip-Flops
Philipp Koehn
7 September 2019
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 The Story So Far 1
• We can encode numbers
• We can do calculation
• ... but it’s all a bit static
• How about a counter? → this requires "memory"
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 2
feedback
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 A Strange Contraption 3
- +
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Let’s Turn It On 4
- +
Electricity is on → this opens the normally closed key
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Let’s Turn It On 5
- +
Electricity is off → this closes the normally closed key
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 What Do We Have? 6
• A Buzzer
• A Clock
• An Oscillator
NOT
(symbol)
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Oscillator 7
• Period of oscillator
• Frequency: cycles per second
• Unit: 1 cycle per second: 1 Hertz
• Modern computes: Billions of Hertz = Gigahertz (GHz) Heinrich Hertz 1857--1894
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 8
flip flop
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Another Contraption 9
NOR V NOR OUT
V
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Closing Upper Key 10
NOR V NOR OUT
V
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Opening Upper Key 11
NOR V NOR OUT
V
Same key configuration as initially But: Now OUT is on --- we remembered the key turn
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Closing Lower Key 12
NOR V NOR OUT
V
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Opening Lower Key 13
NOR V NOR OUT
V
Back to initial state
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Memory 14
• We have memory -- called Reset-Set Flip-Flop
• Truth table
UPPER LOWER OUT 0 0 OUT 0 1 0 1 0 1 1 1 Illegal
• UPPER = SET
• LOWER = RESET
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Re-Arranged 15
S NOR
NOR Q R
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Symmetric 16
S NOR Q
NOR Q R
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Truth Table 17
S R Q Q¯ 1 0 1 0 0 1 0 1 0 0 Q Q¯ 1 1 Illegal
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 18
d-type flip flop
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Vision 19
• Control bit ("clock") – on = write to memory – off = read from memory
• Data bit – data item to be written
• Output – current state of the memory
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Replace Set/Reset with Data 20
DATA NOR Q NOT
NOR Q
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Add Control Bit ("Clock") 21
DATA AND NOR Q NOT
CLOCK NOR Q AND
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 D-Type Flip-Flop 22
• Also called D-type latch
• Circuit latches on one bit of memory and keeps it around
• Truth table
Data Clock Q Q¯ 0 1 0 1 1 1 1 0 X 0 Q Q¯
• Can also build these for multiple data bits
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 23
accumulative adder
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Design Goal 24
• Adder has initially value 0
• Adding a number → value increases
• Resetting → value goes back to 0
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Ingredients 25
A7 A6 A5 A4 A3 A2 A1 A0 B7 B6 B5 B4 B3 B2 B1 B0
CO 8-BIT ADDER CI S7 S6 S5 S4 S3 S2 S1 S0
D7 D6 D5 D4 D3 D2 D1 D0
CLK 8-BIT LATCH Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Ingredients 26
8 8 A B CO 8-BIT ADDER CI S 8
8 D CLK 8-BIT LATCH Q 8
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Building an Accumulative Adder 27
0
8
• Latch: current sum CLOCK CLK D 8-BIT LATCH Q • Clock on → set it to 0 8
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Building an Accumulative Adder 28
0
8
• Adder CLOCK CLK D 8-BIT LATCH Q IN • Combines 8 8
– current value A B 8-BIT ADDER – selected input CO S CI
8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Building an Accumulative Adder 29
0
8
• Can we pass output CLOCK CLK D 8-BIT LATCH directly to latch? Q IN
8 8 Concerns • A B 8-BIT ADDER – select between 0 and sum CO S CI
– only stored when clock on 8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Building an Accumulative Adder 30
0 8 8
Clear A B 2-1 SELECTOR S 8 • 2-1 selector CLOCK CLK D 8-BIT LATCH Q IN • Either uses 0 or sum 8 8
A B • Built with AND gates 8-BIT ADDER CO S CI
8 • Still have runaway feedback loop... OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Building an Accumulative Adder 31
0 8 8
Clear A B • Two Latches 2-1 SELECTOR S – one to store the sum 8 CLOCK1 CLK D – one to store input to adder 8-BIT LATCH QS • Clock 1 8 CLOCK2 CLK D 8-BIT LATCH – carry out addition Q IN
– store result 8 8
A B • Clock 2 8-BIT ADDER CO S CI – transfer to set up next addition 8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Building an Accumulative Adder 32
0 8 8
Clear A B • Combine the clocks 2-1 SELECTOR S Add 8 • Pressing the add key CLK D 8-BIT LATCH NOT – carry out addition QS – store result in upper latch 8 CLK D 8-BIT LATCH IN • Release the add key Q 8 8 – transfer to lower latch A B – set up next addition 8-BIT ADDER CO S CI
8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 What Else? 33
0 8 8
Clear A B 2-1 SELECTOR S • Remember the oscillator? Add 8 CLK D NOT 8-BIT LATCH NOT QS 8
CLK D 8-BIT LATCH Q IN
8 8
A B 8-BIT ADDER CO S CI
8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 What Else? 34
0 8 8
Clear A B 2-1 SELECTOR S 8
NOT CLK D 8-BIT LATCH NOT QS 8
CLK D 8-BIT LATCH Q IN
• Each cycle of oscillator: 8 8
A B keeps adding 8-BIT ADDER CO S CI
8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 What Else? 35
0 8 8
Clear A B 2-1 SELECTOR S 8
NOT CLK D 8-BIT LATCH NOT QS 8
CLK D 8-BIT LATCH Q IN
• We have something interesting here 8 8
A B 8-BIT ADDER CO S CI
8
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 36
edge triggered flip-flop
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 D-Type Latch 37
D Q LATCH CLK Q
• When clock is on, save data
• "Level-triggered"
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 D-Type Latch 38
D Q D Q LATCH LATCH NOT CLK Q CLK Q
• "Edge-triggered": changes value, when switched from 0 to 1
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Edge Triggered D-Type Latch 39
D Q > CLK Q
Symbol
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Truth Table 40
Data Clock Q Q¯ 0 ↑ 0 1 1 ↑ 1 0 X 0 Q Q¯
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 41
ripple counter
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Oscillator and Latch 42
D Q NOT > CLK Q
Data Clock Q Q¯ 1 0 0 1 1 ↑ 1 0 0 1 1 0 0 0 1 0 0 ↑ 0 1 1 1 0 1 1 0 0 1
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Oscillator and Latch 43
D Q NOT > CLK Q
Data Clock Q Q¯ 1 0 0 1 1 ↑ 1 0 0 1 1 0 0 0 1 0 0 ↑ 0 1 1 1 0 1 1 0 0 1
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Halving of Frequency 44
Data Clock Q Q¯ 1 0 0 1 1 ↑ 1 0 0 1 1 0 0 0 1 0 0 ↑ 0 1 1 1 0 1 1 0 0 1
IN
OUT
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Multiple Bits 45
OUT0 OUT1 OUT2 OUT3 NOT D Q D Q D Q NOT > CLK Q > CLK Q > CLK Q
OUT0
OUT1
OUT2
OUT3
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019 Ripple Counter 46
OUT0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
OUT1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
OUT2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
OUT3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Philipp Koehn Computer Systems Fundamental: Feedback and Flip-Flops 7 September 2019