16 0 registers counters
TRANSCRIPT
![Page 1: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/1.jpg)
Registers and Counters
![Page 2: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/2.jpg)
Overview• Parallel Load Register• Shift Registers
Serial Load Serial Addition
• Shift Register with Parallel Load• Bidirectional Shift Register
2
![Page 3: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/3.jpg)
Registers and Counters• An n-bit register = n flip-flops • Capable of storing n bits of binary
information.• A counter is an FSM that goes
through a predetermined sequence of states upon the application of clock pulses.
3
![Page 4: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/4.jpg)
4-Bit Register
4
![Page 5: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/5.jpg)
Register with parallel load
5
![Page 6: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/6.jpg)
Shift Register
6
![Page 7: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/7.jpg)
Serial data transfer
7
Serial transfer of information from register A Serial transfer of information from register A to register Bto register B
![Page 8: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/8.jpg)
Serial addition using shift registers
• The two binary numbers to be added serially are stored in two shift registers.
• The sum bit on the S output of the full adder is transferred into the result register A.
8
![Page 9: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/9.jpg)
Serial vs. parallel addition• The parallel adder is a combinational
circuit, whereas the serial adder is a sequential circuit.
• The parallel adder has n full adders whereas the serial adder requires only one full adder.
• The serial circuit takes n clock cycles to complete an addition.
• The serial adder, although it is n times slower, is n times smaller in space.
9
![Page 10: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/10.jpg)
Shift register with parallel load
10
![Page 11: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/11.jpg)
Shift register with parallel load
11
ShiftShift LoadLoad OperationOperation00 00 NothingNothing00 11 Load parallelLoad parallel11 XX Shift Q0 Shift Q0 Q1, Q1 Q1, Q1Q2…Q2…
![Page 12: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/12.jpg)
Bidirectional shift register
12
SS11SS00 ActionAction0000 NothingNothing0101 Shift downShift down1010 Shift upShift up1111 Parallel Parallel
loadload
![Page 13: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/13.jpg)
Bidirectional Shift Register
13
![Page 14: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/14.jpg)
Counters
• A counter is a sequential circuit that goes through a predetermined sequence of states upon the application of clock pulses.
• Counters are categorized as: Synchronous Counter:
All FFs receive the common clock pulse, and the change of state is determined from the present state.
Ripple Counters: The FF output transition serves as a source for triggering other FFs. No common clock.
14
![Page 15: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/15.jpg)
Synchronous Binary Counters
• The design procedure for a binary counter is the same as any other synchronous sequential circuit.
• Most efficient implementations usually use T-FFs or JK-FFs. We will examine JK and D flip-flop designs.
15
![Page 16: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/16.jpg)
16
J-K Flip Flop Design of a 4-bit Binary Up Counter
Synchronous Binary Counters:
![Page 17: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/17.jpg)
17
J-K Flip Flop Design of a Binary Up Counter (cont.)
Synchronous Binary Counters
![Page 18: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/18.jpg)
18
J-K Flip Flop Design of a Binary Up Counter (cont.)
Synchronous Binary Counters
![Page 19: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/19.jpg)
19
J-K Flip Flop Design of a Binary Up Counter (cont.)
Synchronous Binary Counters
![Page 20: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/20.jpg)
20
J-K Flip Flop Design of a Binary Up Counter (cont.)
Synchronous Binary Counters
JQ0 = 1KQ0 = 1
JQ1 = Q0KQ1 = Q0
JQ2 = Q0 Q1KQ2 = Q0 Q1
JQ3 = Q0 Q1 Q2KQ3 = Q0 Q1 Q2
J
KC
J
KC
J
KC
J
KC
CLK
logic 1 Q0
Q1
Q2
Q3
![Page 21: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/21.jpg)
21
J-K Flip Flop Design of a Binary Up Counter with EN and CO
Synchronous Binary Counters:
EN = enable control signal, when 0 counter remains in the same state, when 1 it counts
CO = carry output signal, used to extend the counter to more stages
JQ0 = 1 · ENKQ0 = 1 · ENJQ1 = Q0 · ENKQ1 = Q0 · ENJQ2 = Q0 Q1 · ENKQ2 = Q0 Q1 · ENJQ3 = Q0 Q1 Q2 · ENKQ3 = Q0 Q1 Q2 · ENC0 = Q0 Q1 Q2 Q3 · EN
![Page 22: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/22.jpg)
PJF22
4-bit Upward Synchronous Binary Counter in HDL - Simulation
![Page 23: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/23.jpg)
Counter with Parallel Load• Add path for input data
enabled for Load = 1• Add logic to:
disable count logic for Load = 1 disable feedback from outputs
for Load = 1 enable count logic for Load = 0
and Count = 1• The resulting function table:
PJF 23
D0 D
C
Q0
D1 D
C
Q1
D2 D
C
Q2
D3 D
C
Q3
Load
Count
Clock
CarryOutput CO
LoadLoad CounCountt
ActionAction
00 00 Hold Stored ValueHold Stored Value00 11 Count Up Stored Count Up Stored
ValueValue11 XX Load DLoad D
![Page 24: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/24.jpg)
Counting Modulo 7: Detect 7 and Asynchronously Clear
• A synchronous 4-bit binary counterwith an asynchronous Clear isused to make a Modulo7 counter.
• Use the Clear feature todetect the count 7 andclear the count to 0. Thisgives a count of 0, 1, 2, 3, 4,5, 6, 7(short)0, 1, 2, 3, 4, 5,6, 7(short)0, etc.
• DON’T DO THIS! Referred to as a “suicide” counter! (Count “7” is “killed,” but the designer’s job may be dead as well!)
24
Clock0
D3 Q3D2 Q2
D1 Q1
D0 Q0
CLEAR
CPLOAD
![Page 25: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/25.jpg)
Counting Modulo 7: Synchronously Load on Terminal Count of 6
• A synchronous 4-bit binarycounter with a synchronousload and an asynchronousclear is used to make a Modulo 7 counter
• Use the Load feature todetect the count "6" andload in "zero". This givesa count of 0, 1, 2, 3, 4, 5, 6,0, 1, 2, 3, 4, 5, 6, 0, ...
• Using don’t cares for statesabove 0110, detection of 6 can be done with Load = Q4 Q2
25
D3 Q3D2 Q2D1 Q1D0 Q0
CLEAR
CPLOAD
Clock
0000
Reset
![Page 26: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/26.jpg)
Counting Modulo 6: Synchronously Preset 9 on Reset and
Load 9 on Terminal Count 14
• A synchronous, 4-bit binarycounter with a synchronousLoad is to be used to make aModulo 6 counter.
• Use the Load feature topreset the count to 9 onReset and detection ofcount 14.
• This gives a count of 9, 10, 11, 12, 13, 14, 9, 10, 11, 12, 13, 14, 9, …• If the terminal count is 15 detection is usually built in as Carry Out
(CO)
26
Clock
D3 Q3D2 Q2D1 Q1D0 Q0
CLEAR
CPLOAD
00
1
1
Reset
1
![Page 27: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/27.jpg)
Ripple Counter • How does it work?
When there is a positive edge on the clock inputof A, A complements
The clock input for flip-flop B is the complementedoutput of flip-flop A
When flip A changesfrom 1 to 0, there is apositive edge on theclock input of Bcausing B tocomplement
PJF - 27
Reset
Clock
D
D
CR
CR
B
A
CP
BA
0 1 2 3 0 1
![Page 28: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/28.jpg)
Example (cont.)
28
![Page 29: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/29.jpg)
Ripple Counter (continued)• The arrows show the
cause-effect relation-ship from the priorslide =>
• The correspondingsequence of states =>(B,A) = (0,0),
• Each additional bit, C, D, …behaves like bit B, changing half as frequently as the bit before it.
• For 3 bits: (C,B,A) = (0,0,0), (0,0,1), (0,1,0), (0,1,1),(1,0,0), (1,0,1), (1,1,0), (1,1,1), (0,0,0), …
29
(1,0),(0,1), (0,1), …(0,0),(1,1),
CP
BA
0 1 2 3 0 1
![Page 30: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/30.jpg)
Ripple Counter (continued)• Starting with C = B = A = 1, equivalent to (C,B,A) =
7 base 10, the next clock increments the count to (C,B,A) = 0 base 10. In fine timing detail:The clock to output delay
tPHL causes an increasingdelay from clock edge foreach stage transition.
Thus, the count “ripples”from least to mostsignificant bit.
For n bits, total worst casedelay is n tPHL.
30
CP
A
B
C
tPHL
tPHL
tpHL
![Page 31: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/31.jpg)
Example: A 4-bit Upward Counting Ripple Counter
31
Recall...
Less SignificantBit output is Clockfor Next Significant Bit!(Clock is active low)
![Page 32: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/32.jpg)
A 4-bit Downward Counting Ripple Counter
• Use direct Set (S) signals instead of direct Reset (R), in order to start at 1111.
• Alternative designs: Change edge-triggering to positive Connect the complement output of each FF
to the C input of the next FF in the sequence.
32
![Page 33: 16 0 Registers Counters](https://reader036.vdocuments.net/reader036/viewer/2022062316/577cce021a28ab9e788d1349/html5/thumbnails/33.jpg)
P333
Simulation …