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

时间:2025-09-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个周期的延迟。

      审核编辑:彭静
猜您喜欢

薄膜电阻作为电子元器件中的重要组成部分,因其性能稳定、精度高而被应用于各类电子设备中。Uniohnm(厚声)作为知名的薄膜电阻品牌,其产品在市场上享有较高的声誉...
2014-11-05 17:36:19

人体综合测试仪是高科技设备,应用于健康管理和体检领域。通过多项参数的综合测量,为用户提供全面的身体健康状况分析。主要参数包括体重、体脂率、肌肉量、水分含量、基础...
2010-04-10 00:00:00

贴片电阻是电子电路中不可或缺的元件,其规格参数表是选择合适电阻的关键。参数表通常包含以下几个重要方面:首先是阻值,它决定了电阻对电流的阻碍作用,通常以欧姆(Ω)...
2025-04-14 15:02:06

贴片圆螺母是常用于电子设备和机械结构中的连接件,其规格和尺寸直接影响到产品的性能和稳定性。贴片圆螺母的规格主要包括螺纹直径、螺纹类型、外径和高度等。常见的螺纹直...
2015-04-02 00:00:00

劳保手套是专为保护双手而设计的安全防护装备,应用于工业、建筑、化工等领域。主要用于防止手部在工作过程中受到外界环境的伤害,如划伤、刺伤、化学品侵蚀以及高温或低温...
2012-06-09 00:00:00

刀片/弹片接触电池连接器因其独特的设计和优越的性能,成为现代电子设备中不可少的组件。这种连接器具备优异的电导性能,能够有效降低接触电阻,提高电流传输效率,确保设...
2023-01-29 00:00:00

是否曾遇到过这样的情形:按下笔记本电脑的电源按钮,电源指示灯亮起,但屏幕却一片漆黑?这种情况让人倍感困惑,但通过了解一些潜在原因及解决方法,您可以迅速找回笔记本...
2024-11-29 00:00:00

电阻器作为电子元件中的基础部件,其性能直接影响到整个电路的稳定性和可靠性。防硫化电阻因其优异的抗硫化性能,尤其适用于恶劣环境中的电子设备。顺络(Sunlord)...
2012-11-18 05:23:30

电路保护成为保障设备安全运行的重要环节。自恢复保险丝(Polyfuse)作为智能保护元件,因其独特的性能和的应用受到了业界的高度关注。本文将围绕“驭舵自恢复保险...
2022-10-24 17:48:30

理解贴片电阻的命名规则对于选择合适的元件至关重要。本文以风华贴片电阻为例,简要解析其命名规则。风华贴片电阻通常采用三位或四位数字表示阻值。例如,「102」表示1...
2024-11-26 11:29:33