Overview
2
Multiplexer-based transfers
n Shift registers
n
Registers
Register a collection of binary storage elements
In theory, a register is sequential logic which can be
defined by a state table
More often, think of a register as storing a vector of
binary values
Frequently used to perform simple data storage
and data movement and processing operations
In1
D Q
C
In0
D Q
CP
A1
A0
Y1
Y0
Next State
A1(t+1) A0(t+1)
For In1 In0 =
00 01 10 11
00 01 10 11
00 01 10 11
00 01 10 11
00 01 10 11
Output
(=A1 A0)
Y1
0
0
1
1
Y0
0
1
0
1
7-9
Simple Register
5
Serial
input SI
D
C
Clock
(a) Logic diagram
SRG 4
Clock
Sl
SO
(b) Symbol
Serial
output SO
Add
n
Design
Register Storage
Expectations:
Reality:
Realizing expectations:
The Load signal enables the clock signal to pass through if 1 and
prevents the clock signal from passing through if 0.
Example: For Positive Edge-Triggered or Negative Pulse
Master-Slave Flip-flop:
Clock
Load
Gated Clock to FF
7-1
D0
7-1
Q0
Clock
D0
Clock
D0
DClear
Clock
C
D1
Clear
D2
Clear
Q1
D
Q2
C
D3
D2
D
D3
Q2
R
D3
D
C
Q3
Q02
D
Q0
REG
C
D1
Q1
D2
Q2
Clear R
D0
Q0
D1 D
Q1
(b) Symbol
(a) Logic diagram
R
Load
Clock
Clock
R Clock
Load
C inputs
Q0
D1
Q1
D2
Q2
D3
Q3
(b) Symbol
C inputs (clock inputs
of flip-flops)
(c) Load control input
(a) Logic
diagram
2008
PearsonLoad
Education, Inc.
M. Morris Mano & Charles R. Kime
LOGIC ANDCCOMPUTER
DESIGN FUNDAMENTALS, 4e
inputs
Clock
Q3
Load
Clock
Q3 Symbol
(b)
D0
D3
D2
CQ2
Load
D3
Q3
ClockR
Q3
(a) Logic diagram
REG
C
D2
Clear
D1
Q1
Q1
C
R
Clear
REG
Q0
D
D1
Q0
2-to-1 Multiplexers
For Load = 0,
loads register contents
(hold current values)
For Load = 1,
loads input values
(load new values)
D Q
Load
In1
A1
Y1
D Q
C
In0
Clock
A0
Y0
EN
D
C
C
D Flip-flop with
enable
Registers with Load-Controlled
Feedback
(a)
11
EN
D
C
D
D Flip-flop with enable
(a)
D0
D
th enable
D1
D
EN
C
Q0
D1
D
EN
C
Q1
D2
D
EN
C
Q2
D3
Load
Clock
D
EN
C
Q3
D
EN
C
Q0
D1
Q1
D
(b)
2008 Pearson Education,
EN Inc.
M. Morris Mano & Charles R. Kime
C DESIGN FUNDAMENTALS, 4e
LOGIC AND COMPUTER
(a)
D0
D
EN
C
D
EN
C
D
EN
C
Q0
Q1
D2
D
EN
C
(b)
D0
(b)
Q2
D
EN
C
(c)
Registers
T 7-6
7-10
12
Shift
Function Table
TABLE 7-6
Function Table for the Register of Figure 7-10
Shift
0
0
D
C 1
Q0
Load
Serial
input
D0
Load
Operation
0
1
X
No change
Load parallel data
Shift down from Q0 to Q3
Q0
D
C
D1
Q1
D
C
Q1
Q2
D
C
SHR 4
Shift
Load
Sl
D0
D1
D2
D3
D2
Q0
Q1
Q2
Q3
D3
Q3
D
C
Clock
Q3
Shift
Load
Sl
D0
D1
D2
D3
(b) S
(b) Symbol
Q2
SH
Registers
T 7-7
TABLE 7-7
Function Table for the Register of Figure 7-7
Function Table
13Mode control
Qi
S1
S0
Register
Operation
0
0
1
1
0
1
0
1
No change
Shift down
Shift up
Parallel load
Mode S1
S1
Mode S0
S0
Qi
MUX
S1
S1
S0
S0
Left se
D
0
1
Qi
C
LSI
D0
Q0
D1
Q1
D2
Q2
D3
Q3
RSI
(b) Symbol
Qi
Qi
SHR 4
Clock
7-11
Di
Right se
Qi
D
C
Clock
(a) Logic diagram of one typical stage
2008 Pearson Education, Inc.
M. Morris Mano & Charles R. Kime
LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e
7-3
Control
inputs
Control
unit
Status signals
Datapath
Data
outputs
Control Data
outputs inputs
Register Notation
R
7 6 5 4 3 2 1 0
(a) Register R
T 7-115
15
R2
(c) Numbering of 16-bit register
8
PC (H)
0
PC (L)
TABLE 7-1
Basic Symbols for Register Transfers
Symbol
Description
Letters
(and numerals)
Parentheses
Arrow
Comma
Square brackets
Examples
Denotes a register
7-5
Conditional Transfer
7-5
K1
R1
Clock
R2
R2
t 1
Clock
K1
Clock
K1
t
R1
Load
Trans
Load
Microoperations
Logical Groupings:
Arithmetic operations
+ Addition
Subtraction
* Multiplication
/ Division
Logical operations
Logical OR
Logical AND
Logical Exclusive OR
! Not
T 7-2
19
Register Trasfers
TABLE 7-2
Textbook RTL, VHDL, and Verilog Symbols for Register Transfers
Operation
Text RTL
VHDL
Verilog
Combinational assignment
Register transfer
Addition
Subtraction
Bitwise AND
Bitwise OR
Bitwise XOR
Bitwise NOT
Shift left (logical)
Shift right (logical)
Vectors/registers
Concatenation
=
m
+
(overline)
sl
sr
A(3:0)
||
<= (concurrent)
<= (concurrent)
+
and
or
xor
not
sll
srl
A(3 down to 0)
&
assign = (nonblocking)
<= (nonblocking)
+
&
|
^
~
<<
>>
A[3:0]
{,}
Example Microoperations
Control Expressions
Example:
X K1 : R1 R1 + R2
X K1 : R1 R1 + R2 + 1
Variable K1 enables the add
or subtract operation.
If X =0, then X =1 so
X K1 = 1, activating the
addition of R1 and R2.
If X = 1, then X K1 = 1,
activating the addition of
R1 and the two's
complement of R2
(subtract).
Arithmetic Microoperations
TABLE 7-3
Arithmetic Microoperations
Symbolic
designation
Description
R0 m R1 + R2
R2 m R2
R2 m R2 + 1
R0 m R1 + R2 + 1
R1 m R1 + 1
R1 m R1 1
XK1 : R1 R1+R2+1
Overflow
output
Logical Microoperations
TABLE 7-4
Logic Microoperations
Symbolic
designation
Description
R0 m R1
R0 m R1 R2
R0 m R1 R2
R0 m R1 R2
Operation
11111010
10100000
R0 ! R1
R0 ! R1 " R2
R0 ! R1 # R2
01011010
R0 ! R1 $ R2
Shift Microoperations
TABLE 7-5
Examples of Shifts
Eight-bit examples
Type
shift left
shift right
Symbolic
designation
Source R2
After shift:
Destination R1
R1m sl R2
R1m sr R2
10011110
11100101
00111100
01110010
Note: These shifts "zero fill". Sometimes a separate flipflop is used to provide the data shifted in, or to catch
2008 Pearson Education,
Inc.
the data
shifted out.
A register
Data inputs to the register
Control input combinations to the register
Example 2: Encoded
Control inputs: S1, S0
n All possible binary combinations on S1, S0
(0,0), (0,1), (1,0), (1,1)
n
Example:
Load: A B
Shift: A sr B
Add: A A + B
Example:
Control inputs: Load, Shift, Add
n If all control inputs are 0, hold the current register state
n
input: B
Control inputs (CX, CY)
Control input combinations (0,0), (0,1) (1,0)
Register transfers:
CX : A B v A
CY : A B + A
Hold state: (0,0)
Load Control
Load = CX + CY
Hold A
CY = 1
CX = 1
Use
Example 1 Again
State Table:
Hold
Ai
CX = 0
CY = 0
Ai v Bi
Ai + Bi
CX = 1 CX = 1 CY = 1
Bi = 0 Bi = 1 Bi = 0
CY = 1
Bi = 1
0
0
0
1
0
1
1
1
1
1
1
0
Four variables give a total of 16 state table entries
By using:
Combinations of variable names and values
n Don t care conditions (for CX = CY = 1)
n
Di
CX
Ai
X X
Bi
CY
Per cell: 19
Shared decoder logic: 8
Multiplexer-Based Transfers
K1:
K2 K1: R0 R2
K2
4
R2
K1
0
S
MUX
Load
4
1
4
R1
R0
Multiplexer Approach
7-8
...
Dedicated
logic k 1
.
.
.
4
4
...
Encoder
.
.
.
.
.
.
.
.
.
Registers or
shared logic
.
.
.
0 Sm S0
.
.
. MUX
k 1
k
.
.
.
n 1
Load
4
R0
Multiplexer Approach
...
Dedicated
logic k 1
.
.
.
4
4
...
Encoder
.
.
.
.
.
.
.
.
.
Registers or
shared logic
.
.
.
0 Sm S0
.
.
. MUX
k 1
k
.
.
.
n 1
Load
4
R0
Multiplexer connected to
each register input
produces a very flexible
transfer structure =>
Characterize the
simultaneous transfers
possible with this
structure.
Select
S0 S1 S2
Load
L0 L1 L2
S
2-to-1
1 MUX
0
n
R0
Select
S
2-to-1
1 MUX
0
0
R1
SS11 S0
1 3-to-1
MUX
02
n
S
2-to-1
1 MUX
0
n
R2
(b
Multiplexer Bus
7-19
Select
S0 S1 S2
T 7-13
Load
L0 L1 L2
Select
S
0
S1
S0
2-to-1
R0 j R2
R0 j R1, R2 j R1
R0 j R1, R1 j R0
1
0
0n
1
n L2
L1
R2
0
0
1
0
Impossible
n
n
R0
Select
SS11 S0
1 3-to-1
MUX
2
0
n
n
Bus
R1
Load
Register Transfer
1 MUX
Load
L0 L1 L2
FUNDAMENTALS, 4e
L0
1
1
R2
7-20
Three-State Bus
Load
L0 L1 L2
7-20
Load
L0 L1 L2
EN
(a) Register with bidirectional
inputoutput lines and symbol
Load
L2 L1 L0
Enable
E2 E1 E0
R0
n
n
R2
n Bus
R0
Select
2
EN
3to1
MUX
R1
Bus
n
R1
n
EN
n
n
R2
R2
(b) Multiplexer
bus
EN
(c) Three-state bus using
registers with bidirectional
lines
Serial Transfers
Used
Example
Serial microoperations
Example
1: Addition
Example 2: Error-Correction for CDs
7-21
Serial Transfer
45
Shift
Clock
C
0
Register A
SRG 4
C
SO
SI
Register B
SRG 4
SO
SI
T 7-14
T1
T3
T2
T4
TABLE
7-14diagram
(b) Timing
Example of Serial Transfer
Timing
pulse
Shift Register A
Initial value
After T1
After T2
After T3
After T4
1
0
0
0
0
Example of
Serial Transfer
0
1
0
0
0
1
0
1
0
0
1
1
0
1
0
Shift Register B
0
1
1
0
1
0
0
1
1
0
1
0
0
1
1
0
1
0
0
1
Serial Microoperations
By using two shift registers for operands, a full adder, and a flip
flop (for the carry), we can add two numbers serially, starting at
the least significant bit.
Serial addition is a low cost way to add large numbers of
operands, since a tree of full adder cells can be made to any
depth, and each new level doubles the number of operands.
Other operations can be performed serially as well, such as
parity generation/checking or more complex error-check codes.
Shifting a binary number left is equivalent to multiplying by 2.
Shifting a binary number right is equivalent to dividing by 2.
Serial Adder
FA
A3 A2 A1 A0
Parallel Load
Cin
Serial
In
Sum
Cout
B3
B2 B1 B0
Parallel Load
(Clock and Load/Shift
Control not shown)
CP
Serial Adder
48
Counters
Clock connected to the flip-flop clock input on the LSB bit flip-flop
For all other bits, a flip-flop output is connected to the clock input,
thus circuit is not truly synchronous!
Output change is delayed more for each bit toward the MSB.
Resurgent because of low power consumption
Synchronous Counters
Ripple Counter
C
ha
pt
er
7Pa
rt
2
50
there is a positive
edge on the clock input
of A, A complements
The clock input for flipflop B is the complemented
output of flip-flop A
When flip A changes
from 1 to 0, there is a CP
positive edge on the
A
clock input of B
causing B to
B
complement
0
D
Clock
CR
D
CR
Reset
D
C
R
Clock pulse
D
C
R
D
C
R
D
C
R
CP
A
tPHL
tPHL
tpHL
B
C
Synchronous Counters
C
ha
pt
er
7Pa
rt
2
54
T 7-8
TABLE 7-8
Counting Sequence of Binary Counter
Upward Counting Sequence
Q3
Q2
Q1
Q0
Q3
Q2
Q1
Q0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
menterS3
D3 Q3
A2
S2
D2 Q2
A1
S1
D1 Q1
A0
S0
D0 Q0
A3
Clock
Count enable EN
Q1
Q2
EN
Carry Out
Q0
Count Enable
7-13
Q3
C
Carry
output CO
Clock
(a) Logic diagram-serial gating
CTR 4
EN
Q0
Q1
Q2
Q3
7-13
Q0
EN
Q0
Q1
7-13
Count enable EN
Carry chain
D
C
Q0
Q1
Q1
C1 C2
Q2
C2
Carry
output CO
2008 Pearson
Inc.
Symbol
forEducation,
Synchronous
Counter
M. Morris Mano & Charles R. Kime
EN
Q2
CTR 4
C1
Q1 Q2
D
Q
Replace AND carry chain with ANDs
=>
D
Q
C
C
in parallel
Q0
CO
Q0
EN(c) Symbol
Q1
Q2
Q3
CO
Q3
C3
Q3
C3 CO
CO
(b) Logic diagram-parallel gating
Other Counters
Count
D0
Load
Q0
D1
D2
Load D
Q2
Action
Q1
D3
Q3
Clock
Carry
Output CO
Ensure
Example:
Example:
Example:
The
Thesimplified
simplifiedf-f
f-finput
inputeqs:
eqs:
DDA AABB
A
DDB CC
B
DDC BBCC
C
7-16
61
ABC
ABC
Reset
Reset
000
000
110
110 011
011001
101
111
010
D
C
101
111
100
(b)
100
(b)
Clock
Reset
Clock
Reset
(a)
001
010
T 7-9
TABLE 7-9
State T able and Flip-Flop Inputs for BCD Counter
Present State
Next State
Q8
Q4
Q2
Q1
D8 = D 4 =
D2 =
Q8(t+1) Q4(t+1) Q2(t+1)
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
Output
D1 =
Q1(t+1)
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
13
11
10
6
5
3
4
66
Counting Modulo N
A BCD Counter
687-15
Clock
Load
1
(Logic 0)
Count
D0
Q0
Q0
D1
Q1
Q1
D2
Q2
Q2
D3
Q3
Q3
CO
D3
Q3
D2
Q2
D1
Q1
D0
Q0
CP
LOAD
CLEAR
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)
D3
Q3
D2
Q2
D1
Q1
D0
Q0
CP
LOAD
CLEAR
D3
Q3
D2
Q2
D1
Q1
D0
Q0
CP
LOAD
CLEAR
library ieee;
use ieee.std_logic_1164.all;
entity srg_4_r is
port(CLK, RESET, SI : in std_logic;
Q : out std_logic_vector(3 downto 0);
SO : out std_logic);
end srg_4_r;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count_4_r is
port(CLK, RESET, EN : in std_logic;
Q
: out std_logic_vector(3 downto 0);
CO
: out std_logic);
end count_4_r;