Академический Документы
Профессиональный Документы
Культура Документы
Shift Registers
In general, a shift register is characterized by the following control and data signals,
which are fully recognized by XST.
● clock
● serial input
● asynchronous set/reset
● synchronous set/reset
● synchronous/asynchronous parallel load
● clock enable
● serial or parallel output. The shift register output mode may be:
❍ serial: only the contents of the last flip-flop are accessed by the rest of
the circuit
❍ parallel: the contents of one or several flip-flops, other than the last
There are different ways to describe shift registers. For example, in VHDL you can
use:
● concatenation operator
shreg <= shreg (6 downto 0) & SI;
● "for loop" construct
for i in 0 to 6 loop
shreg(i+1) <= shreg(i);
end loop;
shreg(0) <= SI;
● predefined shift operators; for example, SLL or SRL
FPGAs:
Note: Synchronous and asynchronous control signals are not available in the SLRC16x
primitives.
SRL16 and SRLC16 support only LEFT shift operation for a limited number of IO
signals.
● clock
● clock enable
● serial data in
● serial data out
This means that if your shift register does have, for instance, a synchronous
parallel load, no SRL16 is implemented. XST uses specific internal processing
which enables it to produce the best final results.
The XST log file reports recognized shift registers when it can be implemented
using SRL16.
Log File
The XST log file reports the type and size of recognized shift registers during the
Macro Recognition step.
...
Synthesizing Unit <shift>.
Related source file is shift_registers_1.vhd.
Found 8-bit shift register for signal
<tmp<7>>.
Summary:
inferred 1 Shift register(s).
Unit <shift> synthesized.
==============================
HDL Synthesis Report
Macro Statistics
# Shift Registers : 1
8-bit shift register : 1
==============================
...
Related Constraints
A related constraint is SHREG_EXTRACT.
The following table shows pin definitions for an 8-bit shift-left register with a positive-
edge clock, a serial in and a serial out.
IO
Description
Pins
Positive-Edge
C
Clock
SI Serial In
SO Serial Output
VHDL Code
Following is the VHDL code for an 8-bit shift-left register with a positive-edge clock,
a serial in and a serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI : in std_logic;
SO : out std_logic);
end shift;
architecture archi of shift is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C)
begin
if (C'event and C='1') then
for i in 0 to 6 loop
tmp(i+1) <= tmp(i);
end loop;
tmp(0) <= SI;
end if;
end process;
SO <= tmp(7);
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a positive-edge
clock, serial in and serial out.
The following table shows pin definitions for an 8-bit shift-left register with a
negative-edge clock, a clock enable, a serial in and a serial out.
IO
Description
Pins
C Negative-Edge Clock
SI Serial In
SO Serial Output
VHDL Code
Following is the VHDL code for an 8-bit shift-left register with a negative-edge
clock, a clock enable, a serial in and a serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI, CE : in std_logic;
SO : out std_logic);
end shift;
architecture archi of shift is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C)
begin
if (C'event and C='0') then
if (CE='1') then
for i in 0 to 6 loop
tmp(i+1) <= tmp(i);
end loop;
tmp(0) <= SI;
end if;
end if;
end process;
SO <= tmp(7);
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a negative-edge
clock, a clock enable, a serial in and a serial out.
SRL16.
The following table shows pin definitions for an 8-bit shift-left register with a positive-
edge clock, an asynchronous clear, a serial in and a serial out.
IO
Description
Pins
C Positive-Edge Clock
SI Serial In
SO Serial Output
VHDL Code
Following is the VHDL code for an 8-bit shift-left register with a positive-edge clock,
an asynchronous clear, a serial in and a serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI, CLR : in std_logic;
SO : out std_logic);
end shift;
architecture archi of shift is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C, CLR)
begin
if (CLR='1') then
tmp <= (others => '0');
elsif (C'event and C='1') then
tmp <= tmp(6 downto 0) & SI;
end if;
end process;
SO <= tmp(7);
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a positive-edge
clock, asynchronous clear, serial in and serial out.
The following table shows pin definitions for an 8-bit shift-left register with a positive-
edge clock, a synchronous set, a serial in and a serial out.
IO
Description
Pins
C Positive-Edge Clock
SI Serial In
SO Serial Output
VHDL Code
Following is the VHDL code for an 8-bit shift-left register with a positive-edge clock,
a synchronous set, a serial in and a serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI, S : in std_logic;
SO : out std_logic);
end shift;
architecture archi of shift is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C, S)
begin
if (C'event and C='1') then
if (S='1') then
tmp <= (others => '1');
else
tmp <= tmp(6 downto 0) & SI;
end if;
end if;
end process;
SO <= tmp(7);
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a positive-edge
clock, a synchronous set, a serial in and a serial out.
assign SO = tmp[7];
endmodule
The following table shows pin definitions for an 8-bit shift-left register with a positive-
edge clock, a serial in and a parallel out.
IO
Description
Pins
Positive-Edge
C
Clock
SI Serial In
VHDL Code
Following is the VHDL code for an 8-bit shift-left register with a positive-edge clock,
a serial in and a parallel out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI : in std_logic;
PO : out std_logic_vector(7 downto 0));
end shift;
architecture archi of shift is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C)
begin
if (C'event and C='1') then
tmp <= tmp(6 downto 0)& SI;
end if;
end process;
PO <= tmp;
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a positive-edge
clock, a serial in and a parallel out.
The following table shows pin definitions for an 8-bit shift-left register with a positive-
edge clock, an asynchronous parallel load, a serial in and a serial out.
IO
Description
Pins
C Positive-Edge Clock
SI Serial In
SO Serial Output
VHDL Code
Following is VHDL code for an 8-bit shift-left register with a positive-edge clock, an
asynchronous parallel load, a serial in and a serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI, ALOAD : in std_logic;
D : in std_logic_vector(7 downto 0);
SO : out std_logic);
end shift;
architecture archi of shift is
signal tmp : std_logic_vector(7 downto 0);
begin
process (C, ALOAD, D)
begin
if (ALOAD='1') then
tmp <= D;
elsif (C'event and C='1') then
tmp <= tmp(6 downto 0) & SI;
end if;
end process;
SO <= tmp(7);
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a positive-edge
clock, an asynchronous parallel load, a serial in and a serial out.
The following table shows pin definitions for an 8-bit shift-left register with a positive-
edge clock, a synchronous parallel load, a serial in and a serial out.
IO
Description
Pins
C Positive-Edge Clock
SI Serial In
SO Serial Output
VHDL Code
Following is the VHDL code for an 8-bit shift-left register with a positive-edge clock,
synchronous parallel load, serial in and serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI, SLOAD : in std_logic;
D : in std_logic_vector(7 downto 0);
SO : out std_logic);
end shift;
architecture archi of shift is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C)
begin
Verilog Code
Following is the Verilog code for an 8-bit shift-left register with a positive-edge
clock, a synchronous parallel load, a serial in and a serial out.
The following table shows pin definitions for an 8-bit shift-left/shift-right register with
a positive-edge clock, a serial in and a serial out.
IO Pins Description
C Positive-Edge Clock
SI Serial In
VHDL Code
Following is the VHDL code for an 8-bit shift-left/shift-right register with a positive-
edge clock, a serial in and a serial out.
library ieee;
use ieee.std_logic_1164.all;
entity shift is
port(
C, SI, LEFT_RIGHT : in std_logic;
PO : out std_logic_vector(7 downto 0));
end shift;
architecture archi of shift is
signal tmp : std_logic_vector(7 downto 0);
begin
process (C)
begin
if (C'event and C='1') then
if (LEFT_RIGHT='0') then
tmp <= tmp(6 downto 0) & SI;
else
tmp <= SI & tmp(7 downto 1);
end if;
end if;
end process;
PO <= tmp;
end archi;
Verilog Code
Following is the Verilog code for an 8-bit shift-left/shift-right register with a positive-
edge clock, a serial in and a serial out.
www.
xilinx.
com
1-800-
255-
7778