Lecture Notes Shift Register
Lecture Notes Shift Register
Learning Outcomes
After learning this chapter, students should be able to;
Identify the basic forms of data movement in shift registers.
2
Introduction
Register – one or more flip-flops used to store or hold data.
Shift registers
- A group of flip-flops used to shift/transfer data from flip-flop to flip-flop.
- They are generally provided with a Clear or Reset connection so that they
can be "SET" or "RESET" as required.
3
Introduction (continue)
Shift register has 2 basic functions such as;
◦ Data storage
◦ Data movement
Therefore, 0 is stored
5
Data Movement
Shift capability permits data movement within the register or into or out of
the register when trigger by clock pulse
For example, various data movement of four 4-bit registers with direction
indicated by arrows
Data in
Serial in/shift right/serial out Serial in/shift left/serial out Parallel in/serial out
Data in
Data in
6
SISO Shift Register
The serial in/serial out shift register accepts data serially – that is, one bit at
a time on a single line.
Each clock pulse will move an input bit to the next flip-flop. Figure 1 shows
5-bit SISO shift register.
C C C C C
CLK
Figure 1
7
SISO Shift Register (Continue)
Each clock pulse will move an input bit to the next flip-
flop. For example, a 1 is shown as it moves across.
C C C C C
CLCLKK
SISO Shift Register (continue)
Example: To shift 1011 in a 4-bit serial-in serial-out register starting
with LSB. The register is initially reset.
Q0 Q1 Q2 Q3
CLK 1 2 3 4 5 6 7 8
Data inp ut 1 1 0 1 0 0 0 0
Q0 1 0
Q1 0 0
Q2 1 0
Q3 1 0
Data bits stored Data bits CLEAR
after 4 clock after 8 clock
pulses pulses
SISO Shift Register (continue..)
Eg: To shift 101 starting with LSB
11
SISO Shift Register (continue..)
12
SISO Shift Register (continue..)
CLK 1 2 3 4 5 6
Data input 1 0 1 0 0 0
Q0 1 0
Q1 0 0
Q2 1 0
13
Exercise 1 (SISO)-Tutorial 4 no.6
Show the states of the 5-bit register for the specified data input and
clock waveforms.Assume that the register is initially cleared (all 0s).
Show the states of the 5-bit register in Figure 4.6 for the specified data
input and clock waveforms.Assume that the register is initially cleared
(all 0s).
Figure 4.6
Answer Exercise 1
CLK
Data
inputs 1 1 0 1 0
Q0 0
Q1 1
Q2 0
Q3 1
Q4 1
Figure 4.7
Answer Exercise 2
0 1 1 0
LSB
0 1 1 0
Q0 Q1 Q2 Q3 Data in
0 1 1 1 1
CLK
Q0 1 0 1 1 0
2nd clock pulse 1 1 0 1 1 1 1
Q1 1 1 0 1 1
The difference is the way in which the data bits are taken out of the
register; in the parallel output register.
Once all bits are store, the bits are shifted out simultaneously
CLK
Q0 Q1 Q2 Q3
CLK
Figure 2
Q0 Q1 Q2 Q3
18
SIPO Shift Register (continue)
CCLLK
SIPO Shift Register (continue)
CLK 1 2 3 4 5
1
Q0 0
Q1 0 1
Q2 0 0
Q3 0 1
20
SIPO Shift Register (continue..)
Example: Timing waveform for 4-bit SIPO shift register when data bits
0110 is entered. The register initially contains all 1’s.
CLK
Data in 0 1 1 0
(LSB)
Q0
0
Q1
1
Q2
1
Q3
0 (LSB)
All data bits are
stored and shifted
out after 4 clock
pulses
21
Exercise 1 (SIPO)
Show the states of the 4 bit register (SRG 4) for the data input
and clock waveforms in the figure below.The register initially
contains all 0’s.
Data input
D SRG 4
CLK CLK
Data in 0 1 1 1
Q0 Q1 Q2 Q3
Answer Exercise 1 (SIPO)
CLK 1 2 3 4
Data in 0 1 1 1
Q0 0 0 1 1 1
Q1 0 0 0 1 1
Q2 0 0 0 0 1
Q3 0 0 0 0 0
All data bits
are stored and
shifted out
after 4 clock
pulses
PISO Shift Register
Data bits are entered parallel on the same time and data bits are shifted out in a
single line. Example of IC: 74HC165, 74HC195.
D0, D1, D2 and D3 are parallel inputs where, D0 is MSB and D3 is LSB.
To write data in, the mode control line is taken to LOW and the data is clocked in.
The data can be shifted when the mode control line is HIGH as SHIFT is active high.
D0 D1 D2 D3 Data in
SHIFT/LOAD D0 D1 D2 D3
G1 G5 G2 G6 G3 G7 G4 SHIFT/LOAD SRG 4
Serial data out
CLK
Serial
D D D D
data out
C C C C
24
PISO Shift Register (continue..)
Example: Timing waveform for 4-bit PISO shift register when data bits
D0D1D2D3 = 0101 is entered. Assume D input remains a 1.
CLK 1 2 3 4 5
SHIFT/LOAD
Q0 0 1
25
PISO Shift Register (continue..)
SHIFT/LOA SRG 4
D
Serial data
out
CLK
CLK 1 2 3 4 5 6
SHIFT/LOAD
Figure 4.8
Answer Exercise 1
CLK 1 2 3 4 5 6
SHIFT/LOAD
Q0 1 0
Example, Figure 4 shows 4-bits PIPO shift register inserted with D0=1, D1=0, D2=1
and D3=0.
Parallel data inputs
CLK 1 2 3
D0 D1 D2 D3 D0 1 0 0
D3 0 0 0
Q0 1 0 0
CLK
Parallel Q1 0 0 0
outputs
Q0 Q1 Q2 Q3
Q2 1 0 0
Capable to shift data bits either left or right. Example of IC: 74HC194
Use gate logic that enables the transfer of a data bit a stage to the next stage
to the left or right.
Example, Figure 5 shows 4-bit bidirectional shift register.
If the signal RIGHT/LEFT is 1, serial data bits will enter into FF0 and move
to the right , otherwise it will be entered into FF3 and move to the left.
Figure 5
30
Bidirectional Shift Register (continue..)
Example: Timing waveform for 4-bit bidirectional assume that initial value
for Q0 = 1, Q1 = 1, Q2 = 0 and Q3 = 1 and the serial data-input line is LOW.
RIGHT/LEFT
(right) (left) (right) (left)
CLK
Q0 1 0 0 0 1 1 0 0 0 1
Q1 1 1 0 1 1 0 1 0 1 0
Q2 0 1 1 1 0 0 0 1 0 0
Q3 1 0 1 0 0 0 0 0 0 0
31
Shift register’s IC
33
74HC195 (Continue)
74HC1945 block diagram D0 D1 D2 D3
SH/LD (9)
CLR (1)
CLK (10)
Q0 Q1 Q2 Q3
→ When SH/LD’ is LOW, the data on the parallel inputs are entered
synchronously on the positive transition of the clock.
→ When SH/LD’ is HIGH,stored data will shift right (Q0 to Q3)
synchronously with the clock.
→ Inputs J and K’ are the serial data inputs to the first stage of the register
(Q0). Q3 can be used for serial output data.
→ The active-LOW clear input is asynchronous.
34
74HC195 (Continue)
1 2 3 4 5 6 7 8 9 10 11 12
CLR
J 1 0 0 0 0 0 0 0 0
Serial
inputs
K 1 0 0 0 0 0 0 0 0
SH/LD
D0 1
Parallel D1
0
data
inputs
D2 1
D3 0
Q0 0 1 0 0 0 0 1 0 0 0 0
Q1 0 0 1 0 0 0 0 1 0 0 0
Parallel
outputs
Q2
0 0 0 1 0 0 1 0 1 0 0
Q3 0 0 0 0 1 0 0 1 0 1 0
Clear Load
35
Exercise (74HC195)
For the 74HC195 4 bit shift register shown in
Figure 1,determine all the output of Q in Figure
2. Assume register is initially clear. (Page 172)
D0 D1 D2 D3
SH/LD (9)
CLR (1)
CLK (10)
Q0 Q1 Q2 Q3
Figure 1
36
CLK 1 2 3 4 5 6 7 8 9 10
SH/LD
CLR
D0
D1
D2
D3
Figure 2
37
Answer Exercise (74HC195)
CLK 1 2 3 4 5 6 7 8 9 10
J 1 0
K 0 0
SH/LD
CLR
D0 0 0 0 0 1 1 0 0
D1 1 1 1 1 0 0 0 0
D2 0 1 1 1 1 0 0 0
D3 0 0 0 0 0 0 1 1
Q0 0 1 0 0 0 0 1 0 1 0 0
Q1 0 0 1 1 1 1 0 1 0 0 0
Q2 0 0 0 1 1 1 1 0 0 0 0
Q3 0 0 0 0 0 0 0 1 0 1 1
39
Johnson counter
Produce 2n modulus counter where n is the number of stages
The complement of the last stage is feedback to the input of first flip-flop
The Johnson counter is useful when you need a sequence that changes by only
one bit at a time but it has a limited number of states (2n, where n = number of
stages).
Q3 Q3
CLK
40
Johnson counter
CLK
41
Shift Register Counters (Continue)
CLOCK PULSE Q0 Q1 Q2 Q3
0 0 0 0 0
1 1 0 0 0
2 1 1 0 0
3 1 1 1 0
4 1 1 1 1
5 0 1 1 1
6 0 0 1 1
7 0 0 0 1
42
Shift Register Counters (continue..)
CLK 1 2 3 4 5 6 7 8
Q0
Q1
Q2
Q3
43
Shift Register Counters (continue..)
Johnson counter
Redrawing the same Johnson counter (without the clock
shown) illustrates why it is sometimes called as a “twisted-
ring” counter.
FF0
J0 Q0
“twist” C
K0 Q0
Q3
Q3
K1
Q1
J1
Q3
Q3
FF1
FF3
Q1
C
J3
K3
Shift Register Counters (continue..)
Example 2: 5 bit Johnson counter
2n = 2 x 5 = 10 stages
Q4
CLK
CLOCK PULSE Q0 Q1 Q2 Q3 Q4
0 0 0 0 0 0
1 1 0 0 0 0
2 1 1 0 0 0
3 1 1 1 0 0
4 1 1 1 1 0
5 1 1 1 1 1
6 0 1 1 1 1
7 0 0 1 1 1
8 0 0 0 1 1
9 0 0 0 0 1
Figure: 5 bit Johnson sequence
45
Exercise
UsingT flip-flops with negative-going
triggered (NGT) clock,draw a circuits
diagram including timing diagram for a
MOD-8 Johnson counter with an initial
state of all “0’s”.
46
Shift Register Counters (continue..)
The ring counter
Produce n modulus counter where n is the number of stages
The ring counter can also be implemented with either D flip-flops or J-K flip-
flops.
CLK
CLK
47
Shift Register Counters (continue..)
PRE
FF0 FF1 FF2 FF3
Q0 Q1 Q2 Q3
D D D D
CLR
CLK
48
Shift Register Counters (continue..)
Clock Pulse Q0 Q1 Q2 Q3
0 1 0 0 0
1 0 1 0 0
2 0 0 1 0
3 0 0 0 1
49
Shift Register Counters (continue..)
Timing waveform for 4-bit ring counter which initially reset all flip-flop
except FF0
CLK 1 2 3 4 5
Q0 0 1 0 0 0 1
Q1 0 0 1 0 0 0
Q2 0 0 0 1 0 0
Q3 0 0 0 0 1 0
50
Shift Register Counters (continue..)
Ring counter
Redrawing the Ring counter (without the clock shown)
shows why it is a “ring”.
FF0
K0
the desired pattern (usually a Q0
Q3
Q3
K1
fewer states than a Johnson
Q1
J1
Q3
Q3
FF1
FF3
Q1
C
counter (n, where n = number of
J3
K3
flip-flops.
Example:
An 8-bit serial in/serial out shift register has a 40 MHz clock. What is the
total delay through the register?
Solution: A SRG 8 Q7
Data in B Data out
CLK C Q7
40 MHz
The delay for each clock
is 1/40 MHz = 25 ns
CLK
Data in
The total delay is
8 x 25 ns = 200 ns Data out
td
52
Shift Register Applications (continue..)
2. Serial to parallel converter
All computers process data in parallel form but must
communicate with external devices that send/receive data in
serial form → the requirement for serial to parallel converter
Example of serial form: USB (Universal Serial Bus) is used to
connect keyboards, printers, scanners to the computer.
Refer page 503
Microprocessor External
UART Serial data in
system device
(printer, communications
system, etc.)
53
Shift Register Applications (continue..)
4. Keyboard Encoder
❑ The keyboard encoder is an example of where a
ring counter is used in a small system to encode a
key press.
❑ Two 74HC195 shift registers are connected as an
8-bit ring counter preloaded with a single 0. As
the 0 circulate in the ring counter, it “scans” the
keyboard looking for any row that has a key
closure. When one is found, a corresponding
column line is connected to that row line.
❑ The combination of the unique column and row
lines identifies the key. The schematic is shown
on the following slide…
54
Power on LOAD
SH/LD +VCC
Ring counter
D0 D1 D2 D3 D4 D5 D6 D7
J J
K SRG 4 K SRG 4
CLK 74HC195 74HC195
(5 kHz) C C +V
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
Clock inhibit
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
ROW encoder COLUMN encoder
74HC147 74HC147
1 2 4 1 2 4
Switch closure
Q Q D0 D1 D2 D3 D4 D5
C
Key code register
74HC174
C C
Q0 Q1 Q2 Q3 Q4 Q5
Q
One-shots To ROM