Académique Documents
Professionnel Documents
Culture Documents
Registers
Objectives A register is a memory device that can be used to
This section deals with some simple and useful sequential store more than one bit of information.
circuits. Its objectives are to: A register is usually realized as several flip-flops with
Introduce registers as multi-bit storage devices. common control signals that control the movement of
Introduce counters by adding logic to registers data to and from the register.
implementing the functional capability to increment and/or Common refers to the property that the control signals
decrement their contents. apply to all flip-flops in the same way
Define shift registers and show how they can be used to
A register is a generalization of a flip-flop. Where a flip-
implement counters that use the one-hot code. flop stores one bit, a register stores several bits
Reading Assignment The main operations on a register are the same as for any
Counters: Chapter 7, Sections 7.8 through 7.11 in Brown & storage devices, namely
Vranesic. Load or Store: Put new data into the register
Verilog
description of counters: Chapter 7, Sections 7.13 in Read: Retrieve the data stored in the register (usually without
Brown & Vranesic. changing the stored data
Elec 326 11.1 Registers & Counters Elec 326 11.2 Registers & Counters
D0 D Q Q0
Control Signals module reg1 (STO, CLR, D, Q);
Q parameter n = 16;
When they are asserted, they initiate an action in the CLR
register input STO, CLR;
input [n-1:0] D;
Asynchronous Control Signals cause the action to take output [n-1:0] Q;
D1 D Q Q1
place immediately reg [n-1:0] Q;
Synchronous Control Signals must be asserted during a Q
CLR always @(posedge STO or negedge CLR)
clock assertion to have an effect
if (CLR ==0) Q <= 0;
Examples else Q <= D;
On the following three registers, which control signals are Dn-1 D Q Qn-1 endmodule
asynchronous and which are synchronous? How are the
control signals asserted? STO Q
CLR
CLR
Elec 326 11.3 Registers & Counters Elec 326 11.4 Registers & Counters
1
D0 J Q Q0 D Q Q0
D0
K Q Q
D1 J Q Q1
D Q Q1
K Q D1
Q
D n-1 J Q Qn-1
K Q
D Q Qn-1
LD Dn-1
Q
LD
CLR
CLK CLR
OE CLK
OE
Elec 326 11.5 Registers & Counters Elec 326 11.6 Registers & Counters
endmodule
Elec 326 11.7 Registers & Counters Elec 326 11.8 Registers & Counters
2
Example: 3-bit binary counter: Example: 3-bit binary up/down counter
000 0 1
001 000 001 00 0 1 11 0 01
0 1
010 00 1 0 00 0 10
001 010 1 2
plus 01 0 0 01 0 11
011 010 011 2 3 01 1 0 10 1 00
100 011 100 3 4 10 0 0 11 1 01
1 0 1 minus 100 101 4 5 10 1 1 00 1 10
110 101 110 5 6 11 0 1 01 1 11
111 110 111 6 7 11 1 1 10 0 00
000 111 000 7 0 TransistionTable
•
•
Transistion Table State Table
•
K Q
J Q
K Q
J Q
K Q
J Q
K Q
CK
Qi toggles on every clock cycle where Qj = 1, for i > j ≥ 0 Binary Up Counter
Elec 326 11.11 Registers & Counters Elec 326 11.12 Registers & Counters
3
Design of a Binary Down Counter
Elec 326 11.13 Registers & Counters Elec 326 11.14 Registers & Counters
CK CK
Q2 Q2
Q1 Q1
tPFF tPFF
Q0 = JK1 Q0 = JK1
tPG tPG
JK2 JK2
tPG tPG
JK3 JK3
tsu tsu
TW ≥ tPFF + (n-2)tPG + tsu (for n≥2) TW ≥ tPFF + tPG + tsu (for n≥3)
Elec 326 11.15 Registers & Counters Elec 326 11.16 Registers & Counters
4
Verilog description of the 74x163
Asynchronous Counters
1 J Q 1 J Q 1 J Q 1 J Q module V74x163 (CLK, CLR_L, LD_L, ENP, ENT, D, Q, RCO);
CK input CLK, CLR_L, LD_L, ENP, ENT;
1 K Q 1 K Q 1 K Q 1 K Q
input [3:0] D;
Typical MSI counter chip output RCO;
74LS163
output [3:0] Q;
reg [3:0] Q;
CLR
LD QA reg RCO;
ENP QB
ENT QC
A QD always @(posedge CLK)
B
C RCO if (CLR_L == 0) Q <= 4'b0000;
D
else if (LD_L == 0) Q <= D;
LD and CLR are synchronous else if (ENT & ENP) Q <= Q +1;
LD asserted during the rising edge of the clock loads the register from
always @(Q or ENT)
ABCD.
if (Q == 15 && ENT == 1) RCO = 1;
CLR asserted during the rising edge of the clock clears the counter else RCO = 0;
CLR overrides LD
LD overrides EN endmodule
RCO = QD•QC • QB • QA • ENT, used for cascading chips
Elec 326 11.17 Registers & Counters Elec 326 11.18 Registers & Counters
endmodule
Elec 326 11.19 Registers & Counters Elec 326 11.20 Registers & Counters
5
Design of Mod n Counters Decoding Binary Counter States
Mod 6 Up Counter 74LS163 Y0 /S0
CK
Y1 /S1 Q0
CLK Y2 /S2
CLR QA A Q1
CK QB Y3 /S3
1 LD QA B
QC Y4 /S4 Q2
Q0 1 ENP QB C
Y5 /S5
1 ENT QC /S6 /S0
Q1 Y6
A QD Y7 /S7
B /S1
Q2 C RCO
/CLR D /S2
0 1 2 3 4 5 0 1 2
Elec 326 11.21 Registers & Counters Elec 326 11.22 Registers & Counters
Elec 326 11.23 Registers & Counters Elec 326 11.24 Registers & Counters
6
Verilog Description Of A Shift Register Ring Counters
module shift4 (D, LD, LI, Ck, Q);
input [3:0] D;
input LD, LI, Ck;
output [3:0] Q;
reg [3:0] Q;
endmodule
Elec 326 11.25 Registers & Counters Elec 326 11.26 Registers & Counters
Elec 326 11.27 Registers & Counters Elec 326 11.28 Registers & Counters
7
Self-Correcting Johnson Counter 11.4. Design with MSI Components (Counters)
Approach
The state diagram of a counter is essentially a cycle.
Whenever a state diagram is close to a cycle, with only a
few other edges, it can be realized using a counter by
adding logic to take care of the transitions that are not in
Odd Length Johnson Counter the cycle.
The following control inputs on counters are useful:
ENABLE: Asserted to cause the counter to count in its natural
0000 1000 1100 1110
count sequence. Deasserted to cause the counter to hold its current
state.
CLEAR: Used to realize a count sequence that is not a power of
0001 0011 0111
two and for initialization.
LOAD: Used to modify the natural count sequence by forcing the
This counter is also self-correcting counter to a given state.
Elec 326 11.29 Registers & Counters Elec 326 11.30 Registers & Counters
Example: X'
Y
0 6
X Z
Elec 326 11.31 Registers & Counters Elec 326 11.32 Registers & Counters
8
Example:
11.5. Tips & Tricks
X0' X1'•X2' X3' X4' X5' X6•x7'
Don't use asynchronous counters, especially if the
INIT 0
X0
1
X1
2
X3
3
X4
4
X5
5
X7
6
clock period is close to the flip-flop propagation
delay.
X1'•X2
X6•X7' Don't build mod n counters from binary counters with
1 asynchronous clears.
Comment: A state table for this diagram would have 7 rows and 256
columns
Elec 326 11.33 Registers & Counters Elec 326 11.34 Registers & Counters
11.7. Review
Register control signals and assertions.
Binary counters and their operations.
Reset, Load, Output Enable.
Counter timing; maximum clock frequency.
Mod-n counters
Synchronous vs. asynchronous load and reset signals.
Shift registers and shift register counters.
Ring counters, Johnson counters, etc
Self-correcting counters
Counter realization of sequential circuits