CENG 342 Digital Systems Shift Registers Larry Pyeatt SDSM&T - - PowerPoint PPT Presentation

ceng 342 digital systems
SMART_READER_LITE
LIVE PREVIEW

CENG 342 Digital Systems Shift Registers Larry Pyeatt SDSM&T - - PowerPoint PPT Presentation

CENG 342 Digital Systems Shift Registers Larry Pyeatt SDSM&T Compare Two Circuits What is the difference between these two circuits? What are their functions? d q d q d q d q I 3 I 2 I 1 I 0 clk clk clk clk R Q 3 Q 2 Q 1 Q


slide-1
SLIDE 1

CENG 342 – Digital Systems

Shift Registers Larry Pyeatt

SDSM&T

slide-2
SLIDE 2

Compare Two Circuits

What is the difference between these two circuits? What are their functions?

d q rst clk d q rst clk d q rst clk d q rst clk I3 I2 I1 I0 Q3 Q2 Q1 Q0 R d q rst clk d q rst clk d q rst clk d q rst clk In Out Q3 Q2 Q1 Q0 R In Out

slide-3
SLIDE 3

Basic Shift Register

Free-running shift register: the simplest shift register that shift 1 bit to right or left in each clock cycle. No control signal is required. N-bit free-running shift-right register: serial mode (one input and one output, the register is shifted in the same direction) Example: 4-bit shift-right register

d q clk d q clk d q clk d q clk In Out Q4 Q1 Q2 Q3

In Out Q1 Q2 Q3 Q4 t0 1 U U U U t1 1 U U U t2 1 1 U U t3 1 1 1 U t4 1 1 1 1 t5 1 1 1 t6 1 1 1 t7 1 1

slide-4
SLIDE 4

Implementation

It can be implemented as a sequential circuit with a 4-bit D register.

d q rst clk 1-bit right shifter Output Logic reset clk d q

1 4 4 4 1

slide-5
SLIDE 5

VHDL Implementation

1 library ieee; 2 use ieee.std_logic_1164.all; 3 4 entity free_run_shift_reg is 5

generic(N: integer := 4);

6

port(

7

clk, reset: in std_logic;

8

s_in: in std_logic;-- one bit

9

s_out: out std_logic--one bit

10

);

11 end free_run_shift_reg; 13 architecture arch of free_run_shift_reg is 14

signal r_reg: std_logic_vector(N-1 downto 0);

15

signal r_next: std_logic_vector(N-1 downto 0);

16 begin 17

  • - register

18

process(clk,reset)

19

begin

20

if (reset=’1’) then

21

r_reg <= (others=>’0’);

22

elsif (clk’event and clk=’1’) then

23

r_reg <= r_next;

24

end if;

25

end process;

26 27

  • - next-state logic

28

r_next <= s_in & r_reg(N-1 downto 1);

29 30

  • - output

31

s_out <= r_reg(0);

32 end arch;

slide-6
SLIDE 6

Universal Shift Register

A register capable of shifting in one direction is a unidirectional shift register. A bidirectional shift register is able to shift in both directions. A universal shift register can load parallel data, shift left, shift right, or simply retain its contents.

A 2-bit control signal is used to determine the specific operation at each clock cycle. Function Table for universal shift register: Control Operation No change 1 Shift Left 1 Shift Right 1 1 Parallel load

slide-7
SLIDE 7

Universal Shift Register – Block diagram

d q rst clk

4 4

11 01 10 00

4 4 4 4 1 4 4 2 4 1

1-bit right shifter shifter 1-bit left q control d reset clk d3 d0

slide-8
SLIDE 8

VHDL Implementation – Part 1

1 library ieee; 2 use ieee.std_logic_1164.all; 3 4 entity univ_shift_reg is 5

generic(N: integer := 4);

6

port(

7

clk, reset: in std_logic;

8

ctrl: in std_logic_vector(1 downto 0);

9

d: in std_logic_vector(N-1 downto 0);

10

q: out std_logic_vector(N-1 downto 0)

11

);

12 end univ_shift_reg;

slide-9
SLIDE 9

VHDL Implementation – Part 2

14 architecture arch of univ_shift_reg is 15

signal r_reg: std_logic_vector(N-1 downto 0);

16

signal r_next: std_logic_vector(N-1 downto 0);

17 begin 18

  • - register

19

process(clk,reset)

20

begin

21

if (reset=’1’) then

22

r_reg <= (others=>’0’);

23

elsif (clk’event and clk=’1’) then

24

r_reg <= r_next;

25

end if;

26

end process;

27

  • - next-state logic

28

with ctrl select

29

r_next <= r_reg when "00", --no op

30

r_reg(N-2 downto 0) & d(0) when "01", --shift left and insert d(0)

31

d(N-1) & r_reg(N-1 downto 1) when "10",--shift right and insert d(N-1)

32

d when others; -- load

33

  • - output

34

q <= r_reg;

35 end arch;