《電子技術(shù)應(yīng)用》
您所在的位置:首頁(yè) > 模擬設(shè)計(jì) > 其他 > 入門:Xilinx SRL16E如何實(shí)現(xiàn)16移位寄存器

入門:Xilinx SRL16E如何實(shí)現(xiàn)16移位寄存器

2022-08-30
來(lái)源:FPGA設(shè)計(jì)論壇
關(guān)鍵詞: XilinxSRL16E 寄存器

  在做FPGA的開(kāi)發(fā)過(guò)程中經(jīng)常會(huì)使用到移位寄存器,一般我們使用移位寄存器的目的都是為了將某個(gè)信號(hào)進(jìn)行打拍,使得時(shí)序符合我們的需求。最常見(jiàn)的一種打拍方法就是在process過(guò)程語(yǔ)句中對(duì)信號(hào)進(jìn)行移位(在verilog中是在always過(guò)程中進(jìn)行移位)。但是這里我給大家介紹一下SRL6E,這個(gè)是Xilinx提供的一個(gè)原語(yǔ),顧名思義,這是一個(gè)可以最大實(shí)現(xiàn)16位移位寄存的移位寄存器。

  需要注意的是,SRL16E原語(yǔ)在不同的器件中表現(xiàn)形式可能稍有區(qū)別,下面是在Kintex-7系列器件中的SRL16E原語(yǔ):

  --使用原語(yǔ)時(shí),需要加上這兩句

  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

  --以下時(shí)=是SRL16E原語(yǔ)

  SRL16E_inst : SRL16E

  generic map (

  INIT => X“0000”)--對(duì)寄存器進(jìn)行初始化

  port map (

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

  A0 => A0,     -- Select[0] input--四個(gè)地址輸入端口

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

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

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

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

  CLK => CLK,   -- Clock input   --時(shí)鐘端口

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

  );

  -- End of SRL16E_inst instanTIaTIon

  這里主要對(duì)地址進(jìn)行一下說(shuō)明。地址A3A2A1A0表明要對(duì)輸入數(shù)據(jù)進(jìn)行多少移位。如果是A3A2A1A0=“0000”,說(shuō)明是對(duì)D端口輸入數(shù)據(jù)進(jìn)行1位移位,也就是說(shuō)對(duì)D端口輸入的數(shù)據(jù)進(jìn)行一個(gè)周期的延遲。如果是A3A2A1A0=“1111”,說(shuō)明是對(duì)D端口輸入數(shù)據(jù)進(jìn)行16位移位。

  下面舉一個(gè)例子來(lái)說(shuō)明:

  這是源程序,因?yàn)锳3A2A1A0=“0011”,所以主要是對(duì)輸入數(shù)據(jù)進(jìn)行4個(gè)周期的延遲。

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

  -- 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

 ?。?/p>

  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;

  這是仿真文件:

  仿真文件中的輸入數(shù)據(jù)是一個(gè)周期的單脈沖。

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

  -- 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;

  仿真波形:

  輸入數(shù)據(jù)是data_in,輸出是data_out,可以看到對(duì)輸入數(shù)據(jù)進(jìn)行了4個(gè)周期的延遲。

b59cd768-25b8-11ed-ba43-dac502259ad0.png



更多信息可以來(lái)這里獲取==>>電子技術(shù)應(yīng)用-AET<<

mmexport1621241704608.jpg

本站內(nèi)容除特別聲明的原創(chuàng)文章之外,轉(zhuǎn)載內(nèi)容只為傳遞更多信息,并不代表本網(wǎng)站贊同其觀點(diǎn)。轉(zhuǎn)載的所有的文章、圖片、音/視頻文件等資料的版權(quán)歸版權(quán)所有權(quán)人所有。本站采用的非本站原創(chuàng)文章及圖片等內(nèi)容無(wú)法一一聯(lián)系確認(rèn)版權(quán)者。如涉及作品內(nèi)容、版權(quán)和其它問(wèn)題,請(qǐng)及時(shí)通過(guò)電子郵件或電話通知我們,以便迅速采取適當(dāng)措施,避免給雙方造成不必要的經(jīng)濟(jì)損失。聯(lián)系電話:010-82306118;郵箱:aet@chinaaet.com。