Академический Документы
Профессиональный Документы
Культура Документы
Registers
Registers are clocked sequential circuits
A register is a group of flip-flops
Each flip-flop capable of storing one bit of
information
An n-bit register
consists of n flip-flops
capable of storing n bits of information
Counters
A counter is essentially a register that goes through a
predetermined sequence of states
Counting sequence
FF0
FF1
Register
FFn-1
Combinational logic
4-bit Register
D0
Q0
REG
C
R
D1
clear
Q
Q1
C
R
D2
D0
Q0
D1
Q1
D2
Q2
D3
Q3
Q2
FD16CE
D3
D
C
clock
clear
16
Q3
D[15:0] Q[15:0]
CE
C
CLR
16
D0
clock
7
clear
Q1
Q2
Q3
D3
Q
R
D2
Q0
D1
n
R1
R2
R2 R1
clock
clock
R1
01010
11011
load
R2
01010
load
R2
R1
clock
R1 R1 + R2
9
Shift Registers
A register capable of shifting its content in
one or both directions
Flip-flops in cascade
serial
input
SI
D
C
D
C
D
C
SO
serial
output
clock
The current of n-bit shift register state can be transferred in n clock
cycles
10
Serial Mode
shift register A
clock
SO
SI
clk
clk
shift
control
clock
shift
control
clk
11
T1
shift register B
T2
T3
T4
SO
Serial Transfer
BA
Shift register A
Shift register B
initial value
After T1
After T2
After T3
After T4
clock
clk
shift
control
clk
12
T1
T2
T3
T4
shift
clock
control
clk
Serial Addition
SI
clock
shift
control
serial
input
SO
shift register A
a
b
FA
C_in
SI
SO
shift register B
D
C
13
clear
shift
control
01
00
10
01
00
00
SR-A
SR-B
C_in
14
15
A3
A2
A1
A0
clea
rclk
s1
41
MUX
3 2 1 0
s0
41
MUX
3 2 1 0
41
MUX
3 2 1 0
serial
input for
shift-left
serial
input for
shift-right
16
41
MUX
3 2 1 0
parallel inputs
Verilog Code v1
// Behavioral description of a 4-bit universal shift register
// Fig. 6.7 and Table 6.3
module Shift_Register_4_beh ( // V2001, 2005
output reg [3: 0] A_par,
// Register output
input [3: 0] I_par,
// Parallel input
input s1, s0,
// Select inputs
MSB_in, LSB_in,
// Serial inputs
CLK, Clear_b
// Clock and Clear
always @ ( posedge CLK, negedge Clear_b) // V2001, 2005
if (Clear_b == 0) A_par <= 4b0000;
else
case ({s1, s0})
2'b00: A_par <= A_par;
// No change
2'b01: A_par <= {MSB_in, A_par[3: 1]};
// Shift
right
2'b10: A_par <= {A_par[2: 0], LSB_in};
// Shift left
2'b11: A_par <= I_par;
// Parallel load of input
endcase
endmodule
17
Verilog Code v2
// Behavioral description of a 4-bit universal shift register
// Fig. 6.7 and Table 6.3
module Shift_Register_4_beh ( // V2001, 2005
output reg [3: 0] A_par,
// Register output
input [3: 0] I_par,
// Parallel input
input s1, s0,
// Select inputs
MSB_in, LSB_in,
// Serial inputs
CLK, Clear_b
// Clock and Clear
always @ ( posedge CLK, negedge Clear_b) // V2001, 2005
if (Clear_b == 0) A_par <= 4b0000;
else
case ({s1, s0})
19
s1
s0
No change
Shift right
Shift left
Parallel load
Register operation
Counters
Classification
1. Synchronous counters
2. Ripple counters
20
21
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
Idea:
count
T
C
logic-1
clear
22
A2
T
C
A1
T
C
A0
A3
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
10
1 0 1 0
11
1 0 1 1
12
1 1 0 0
13
1 1 0 1
14
1 1 1 0
15
1 1 1 1
0 0 0 0
count
D
C
clear
A1
A2
A3
D
C
Q
R
D
C
A0
D
C
count
logic-1
clear
23
A1
A2
A3
T
C
Q
R
T
C
A0
T
C
Synchronous Counters
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1
0
1
0
Count_enabl
e
C
K
A1
A2
A3
C
K
J
C
K
J
C
K
25
clock
Polarity of the
clock is not
essential
to next
stage
Timing of Synchronous
Counters
clock
A0
A1
A2
A3
26
A0
A1
A2
A3
27
27
For example:
Next state:
28
1 1 0 0
0 0 0
1 1 1
1 1 0
1 0 1
1 0 0
0 1 1
0 1 0
0 0 1
0 0 0
down
A0
A1
A2
T
C
T
C
The circuit
29
clock
A0
A1
A2
C
K
D1
J
C
K
D2
J
C
K
clock
clear
30
carry
output
31
clear
clock
load
Count
Function
clear to 0
load inputs
count up
no change
Other Counters
Ring Counter
shift
right
initial value
1000
T0
T1
T2
T3
Usage
Timing signals control the sequence of operations in a digital
system
32
Ring Counter
Sequence of timing signals
clock
T0
T1
T2
T3
33
Ring Counter
To generate 2n timing signals,
we need a shift register with ? flip-flops
T1
T2
T3
2x4
decoder
count
34
2-bit counter
Cost:
2 flip-flops
2-to-4 line decoder
Cost in general case:
n flip-flops
n-to-2n line decoder
2n n-input AND gates
n NOT gates
Johnson Counter
A k-bit ring counter can generate k
distinguishable states
The number of states can be doubled if
the shift register is connected as a
switch-tail ring counter
D
C
clock
35
X
X
D
C
Y
Y
Johnson Counter
Count sequence and required decoding
sequence
number
Flip-flop outputs
X
S0 = XT
S1 = XY
S2 = YZ
S3 = ZT
S4 = XT
S6 = YZ
S7 = ZT
36
Output
S5 = XY
Johnson Counter
Decoding circuit
S0
S1
D
C
clock
37
S2
S3
D
C
S4
D
C
S5
S6
D
C
S7
1000
0001
0011
38
0111
1100
0010
1110
0101
1111
1011
1001
0100
1010
0110
1101
Correction
0000
1000
0001
0011
39
0111
1100
0010
1110
0101
1111
1011
1001
0100
1010
0110
1101
Johnson Counter
Present State
40
Next State
K-Maps
ZT
ZT
XY
00
01
11
10
00
01
11
10
X(t+1) = T
XY
01
11
10
01
11
10
41
11
10
11
10
00
Y(t+1) = XY + XZ + XT
ZT
00
00
01
01
ZT
XY
00
Z(t+1) = Y
XY
11
1
10
1
01
11
10
00
00
01
T(t+1) = Z
X(t+1) = T
Z(t+1) = Y
Y(t+1) = XY + XZ + XT
T(t+1) = Z
DY = X(Y+Z+T)
D
C
clock
42
D
C
D
C
D
C