Adapted from Dr. Bassam Kahhaleh’ Slides by Prof. Iyad Jafar
Digital Logic
0907231
0
Chapter 7
Registers and Counters
1
Outline
2
Registers
3
Registers
4
Registers
D
Q
R
Reset
D
Q
R
D
Q
R
D
Q
R
CLK
I0
I1
I2
I3
A0
A1
A2
A3
5
Registers
D
Q
R
Reset
D
Q
R
D
Q
R
D
Q
R
CLK
I0
I1
I2
I3
A0
A1
A2
A3
CLK
I3
I2
I1
I0
A3
A2
A1
A0
Note: New data has to go in with every clock
6
Registers with Parallel Load
LD | Q(t+1) |
0 | Q(t) |
1 | D |
D3
D2
D1
D0
Q3
Q2
Q1
Q0
LD
4-bit Register
7
Registers with Parallel Load
D
Q
CLK
I0
A0
D
Q
I1
A1
D
Q
I2
A2
D
Q
I3
A3
Load
Delays the Clock
D3
D2
D1
D0
Q3
Q2
Q1
Q0
LD
4-bit Register
8
Registers with Parallel Load
D
Q
CLK
I0
A0
D
Q
I1
A1
D
Q
I2
A2
D
Q
I3
A3
Load
MUX
I0
I1
Y
S
MUX
I0
I1
Y
S
MUX
I0
I1
Y
S
MUX
I0
I1
Y
S
9
Shift Registers
10
Remember! Shift Left Operation
| | | |
| | | |
| | | |
| | | |
1
0
1
0
1
0
1
0
1
1
0
0
0
0
x
x
11
Remember! Logical Shift Right Operation
| | | |
| | | |
| | | |
| | | |
1
0
1
0
1
0
1
0
0
1
1
0
0
0
x
x
12
Remember! Arithmetic Shift Right Operation
| | | |
| | | |
| | | |
| | | |
1
0
1
0
1
0
1
1
1
1
1
1
1
1
x
x
13
Shift Registers
Serial�Input
Serial�Output
D
Q
D
Q
D
Q
D
Q
CLK
SI
SO
A
B
C
D
Parallel Output
14
Shift Registers
D
Q
D
Q
D
Q
D
Q
CLK
SI
SO
Q3
SI
Q2
Q1
Q0
CLK
Q3
Q2
Q1
Q0
15
Universal Shift Register
D
Q
D
Q
D
Q
D
Q
16
Universal Shift Register
D
Q
D
Q
D
Q
D
Q
MUX
I3 I2 I1 I0
Y
S1�S0
Q3
Q2
Q1
Q0
D1
S1�S0
CLK
CLR
D0
D2
D3
SI for SR
SI for SL
17
Universal Shift Register
Q3
Q2
Q1
Q0
D3
D2
D1
D0
S1
S0
USR
CLR
SRin
SLin
Mode Control | Register Operation | |
S1 | S0 | |
0 | 0 | No change |
0 | 1 | Shift right |
1 | 0 | Shift left |
1 | 1 | Parallel load |
18
Real Stuff
19
Counters
20
Counters
21
Types of Counter
Synchronous
Ripple
22
Example 1 – 4-bit Ripple Counter
T
Q
CLR
T
Q
CLR
T
Q
CLR
T
Q
CLR
Q3
Q2
Q1
Q0
CLK
CLR
23
Example 1 - 4-bit Ripple Counter
Q3 | Q2 | Q1 | Q0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 0 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 0 |
1 | 0 | 1 | 1 |
1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 |
1 | 1 | 1 | 0 |
1 | 1 | 1 | 1 |
24
Example 1 - 4-bit Ripple Counter
T
Q
CLR
T
Q
CLR
T
Q
CLR
T
Q
CLR
Q3
Q2
Q1
Q0
CLK
CLR
1
1
1
1
CLK
Q0
Q1
Q2
Q3
Delay accumulates towards the MSB
0
1
2
3
4
5
6
7
8
9
25
Example 1 - 4-bit Ripple Counter Using D FFs
D
Q
Q
D
Q
Q
D
Q
Q
D
Q
Q
Q3
Q2
Q1
Q0
CLK
CLK
Q0
Q1
Q2
Q3
0
1
2
3
4
5
6
7
8
9
26
Real Stuff
27
Example 2
28
Example 2
29
Example 3 - Synchronous 4-bit Binary Counter
Q3 | Q2 | Q1 | Q0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 0 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 0 |
1 | 0 | 1 | 1 |
1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 |
1 | 1 | 1 | 0 |
1 | 1 | 1 | 1 |
Design a 4-bit synchronous binary counter using JK FFs. The counter has an enable input to pause/resume counting.
30
Example 3 - Synchronous 4-bit Binary Counter
J
Q
Q
K
CLK
Enable
Q3
Q2
Q1
Q0
J
Q
Q
K
J
Q
Q
K
J
Q
Q
K
To Next Stage
31
Example 4 - Up-Down Binary Counter
T
Q
Q
Up
T
Q
Q
T
Q
Q
T
Q
Q
Q3
Q2
Q1
Q0
Down
CLK
Design a 4-bit synchronous binary counter using T FFs. The counter has two inputs; up and down, to control counting order.
32
Binary Counter with Parallel Load
Q3
Q2
Q1
Q0
LD
I3
I2
I1
I0
Count
CLR | LD | Count | Q(t+1) |
0 | x | x | 0 |
1 | 0 | 0 | Q(t) |
1 | 0 | 1 | Q(t)+1 |
1 | 1 | x | I |
CLR
Usually Asynchronous Clear
33
Example 5
Q3
Q2
Q1
Q0
LD
I3
I2
I1
I0
Count
CLR
0
0
0
0
A3
A2
A1
A0
1
CLK
Count
The following counter can count 0,1,2, … 15, 0, 1, … . Modify it to
count up to 10 only.
Can you think of a different approach? How about using the CLR input?
34
Example 5
Q3
Q2
Q1
Q0
LD
I3
I2
I1
I0
Count
CLR
0
0
0
0
A3
A2
A1
A0
1
CLK
Count
The following counter can count 0,1,2, … 15, 0, 1, … . Modify it to
count up to 10 only.
Can you think of a different approach? How about using the CLR input?
35