Xilinx SRL16E如何实现16移位寄存器

时间:2025-07-12  作者:Diven  阅读:0

     在做FPGA的开发过程中经常会使用到移位寄存器,一般我们使用移位寄存器的目的都是为了将某个信号进行打拍,使得时序符合我们的需求。最常见的打拍方法就是在process过程语句中对信号进行移位(在verilog中是在always过程中进行移位)。但是这里我给大家介绍一下SRL6E,这个是Xilinx提供的一个原语,顾名思义,这是一个可以最大实现16位移位寄存的移位寄存器。

Xilinx SRL16E如何实现16移位寄存器

      需要注意的是,SRL16E原语在不同的器件中表现形式可能稍有区别,下面是在Kintex-7系列器件中的SRL16E原语:

--使用原语时,需要加上这两句

Library UNISIM;  

use UNISIM.vcomponents.all;

   -- SRL16E: 16-bit shift register LUT with clock enable operating on posedge of clock (Mapped to SlICeM LUT6)

   --        Kintex-7

   -- Xilinx HDL Language Template, version 2017.4

--以下时=是SRL16E原语

   SRL16E_inst : SRL16E

   generIC map (

      INIT => X"0000")--对寄存器进行初始化

   port map (

      Q => Q,       -- SRL data output--寄存器输出端口

      A0 => A0,     -- Select[0] input--四个地址输入端口

      A1 => A1,     -- Select[1] input

      A2 => A2,     -- Select[2] input

      A3 => A3,     -- Select[3] input

      CE => CE,     -- Clock enable input--寄存器使能端口

      CLK => CLK,   -- Clock input   --时钟端口

      D => D        -- SRL data input--寄存器输入端口

   );

   -- End of SRL16E_inst instantiation

这里主要对地址进行一下说明。地址A3A2A1A0表明要对输入数据进行多少移位。如果是A3A2A1A0=“0000”,说明是对D端口输入数据进行1位移位,也就是说对D端口输入的数据进行一个周期的延迟。如果是A3A2A1A0=“1111”,说明是对D端口输入数据进行16位移位。

下面举一个例子来说明:

这是源程序,因为A3A2A1A0=“0011”,所以主要是对输入数据进行4个周期的延迟。

----------------------------------------------------------------------------------

-- Company: 

-- Engineer: 

-- 

-- Create Date: 2018/12/10 1605

-- Design Name: 

-- Module Name: srl16e_test - Behavioral

-- Project Name: 

-- Target Devices: 

-- Tool Versions: 

-- Description: 

-- 

-- Dependencies: 

-- 

-- Revision:

-- Revision 0.01 - File Created

-- Additional Comments:

-- 

----------------------------------------------------------------------------------

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

Library UNISIM;

use UNISIM.vcomponents.all;

-- Uncomment the following library declaration if using

-- arithmetic functions with Signed or Unsigned values

--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating

-- any Xilinx leaf cells in this code.

--library UNISIM;

--use UNISIM.VComponents.all;

entity srl16e_test is

  Port (

        clk     : in    std_logic;

        data_in : in    std_logic;

        data_out: out   std_logic

         );

end srl16e_test;

architecture Behavioral of srl16e_test is

signal  q  : std_logic:='0';

signal  d  : std_logic:='0';

begin

   SRL16E_inst : SRL16E

generic map (

   INIT => X"0000")

port map (

   Q => q,       -- SRL data output

   A0 => '1',     -- Select[0] input

   A1 => '1',     -- Select[1] input

   A2 => '0',     -- Select[2] input

   A3 => '0',     -- Select[3] input

   CE => '1',     -- Clock enable input

   CLK => clk,   -- Clock input

   D => d        -- SRL data input

);

d <= data_in;

data_out <= q;

end Behavioral;

这是仿真文件:

仿真文件中的输入数据是一个周期的单脉冲。

----------------------------------------------------------------------------------

-- Company: 

-- Engineer: 

-- 

-- Create Date: 2018/12/10 1615

-- Design Name: 

-- Module Name: tb_srl16e - Behavioral

-- Project Name: 

-- Target Devices: 

-- Tool Versions: 

-- Description: 

-- 

-- Dependencies: 

-- 

-- Revision:

-- Revision 0.01 - File Created

-- Additional Comments:

-- 

----------------------------------------------------------------------------------

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.NUMERIC_STD.ALL;

use IEEE.STD_LOGIC_ARITH.All;

use IEEE.STD_LOGIC_UNSIGNED.All;

-- Uncomment the following library declaration if using

-- arithmetic functions with Signed or Unsigned values

--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating

-- any Xilinx leaf cells in this code.

library UNISIM;

use UNISIM.VComponents.all;

entity tb_srl16e is

end tb_srl16e;

architecture Behavioral of tb_srl16e is

component srl16e_test 

port(

    clk : in std_logic;

    data_in : in std_logic;

    data_out : out  std_logic

    );

 end component;

 signal clk ='1';

 signal in_data : std_logic:='0';

 signal out_data: std_logic:='0';

begin

uut: srl16e_test

port map(

    clk => clk,

    data_in => in_data,

    data_out => out_data

    );

 process

 begin

    wait for 10 ns;

    clk <=  '0';

    wait for 10 ns;

    clk <=  '1';

 end process;

process

begin

in_data <= '0';

wait for 20 ns;

in_data <= '1';

wait for 20 ns;

in_data <= '0';

wait;

end process;

end Behavioral;

仿真波形:

输入数据是data_in,输出是data_out,可以看到对输入数据进行了4个周期的延迟。

      审核编辑:彭静
猜您喜欢

T型套筒扳手是常用的手动工具,应用于机械维修、汽车保养和日常家居修理等领域。基本结构由一个T型手柄和一个套筒组成,手柄的设计使得操作时能够施加更大的扭矩,从而轻...
2010-03-14 00:00:00

1、硬件设计基本原则(1)速度与面积平衡和互换原则:一个设计如果时序余量较大,所能跑的频率远高于设计要求,能可以通过模块复用来减少整个设计消耗的芯片面积,这...
2018-04-11 14:49:00

稳压二极管是重要的电子元件,应用于电路中以提供稳定的电压输出。随着时间的推移或电路的使用,稳压二极管可能会出现故障,从而影响电路的正常工作。了解如何快速检测稳压...
2025-04-06 22:00:03

在现代工业中,化学品的安全管理非常重要,尤其是在处理和储存化学品时,泄漏的风险时刻存在。了解化学品泄漏防护的规格尺寸显得尤为重要。化学品泄漏防护设备通常包括泄漏...
2019-12-28 00:00:00

电流采样电阻因其精准、可靠的性能,在各类电气设备中是非常重要的配件。而提到电流采样电阻,不得不提的一个知名品牌便是奇力新(CHILISIN)。本文将深入探讨奇力...
2019-08-03 22:11:30

二极管双向限幅电路是常见的电子电路,主要用于限制信号的幅度,保护后续电路不受过高电压的影响。应用于音频信号处理、通信系统以及其需要保护电路的场合。本文将对二极管...
2025-04-08 19:01:07

头部防护配件在我们的日常生活和工作中是非常重要的配件。无论是在建筑工地、制造业还是运动场上,头部防护配件都能有效保护我们的头部免受外界冲击和伤害。主要包括安全帽...
2009-09-22 00:00:00

称量纸是用于称量和实验室应用的重要材料,其规格尺寸通常根据不同的需求而有所不同。常见的称量纸尺寸包括10cm x 10cm、15cm x 15cm和20cm x...
2009-04-25 00:00:00

保险丝作为重要的保护元件,有着着不可替代的作用。明威作为知名的一次性保险丝品牌,其产品因质量可靠、规格齐全而受到市场青睐。本文将全面介绍明威一次性保险丝的大小规...
2022-04-11 14:32:30

具有 13 位分辨率的 ADXL345 3 轴数字加速计Analog Devices 的小型、薄片式、低功耗 ADXL345 加速计是移动设备应用的理想选择*附...
2024-12-24 09:33:00