xilinx FPGA FIFO IP核的使用(VHDL&ISE)

这篇具有很好参考价值的文章主要介绍了xilinx FPGA FIFO IP核的使用(VHDL&ISE)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.新建工程和ip核文件

common clock builtin fifo,fpga开发

common clock builtin fifo,fpga开发

下图显示了一个典型的写操作。拉高WR_EN,导致在WR_CLK的下一个上升边缘发生写入操作。因为FIFO未满,所以WR_ACK输出1,确认成功的写入操作。当只有一个附加的单词可以写入FIFO时,FIFO会拉高ALMOST_FULL标志。当ALMOST_FULL拉高之后,一个附加的写入将导致FIFO拉高FULL。当FULL拉高之后发生写入时,WR_ACK就会为0表示溢出。一旦执行了一个或多个读取操作,FIFO将拉低FULL,并且数据可以成功地写入FIFO,之后WR_ACK也会相应拉高表示溢出取消。

common clock builtin fifo,fpga开发

本节描述了FIFO读取操作的行为和相关联的状态标志。当断言读取启用且FIFO不为空时,将从输出总线(DOUT)上的FIFO中读取数据,并断言有效标志(有效)。如果FIFO被连续读取而没有被写入,则FIFO将排空。当FIFO不为空时,读取操作将会成功。当FIFO为空且请求读取时,将忽略读取操作,断言下流标志,且FIFO的状态没有变化(下FIFO是非破坏性的)

读写使用一个时钟时,当写操作和读取操作同时发生时,写操作被接受,读取操作被忽略。

对于Virtex-4 FPGA内置的FIFO实现,全信号有一个额外的延迟周期。使用写确认来验证成功或可编程满的早期指示。

Virtex-4 FPGA内置的FIFO实现在FULL标志上显示了一个额外的延迟周期

Common Clock FIFO: Block RAM and Distributed RAM此实现可选地支持首字切换

下图说明了一个FIFO的功能实现,使用块RAM或公共RAM的分布式RAM用于内存。所有信号都同步到单个时钟输入(CLK)。这个设计实现了写和读取指针的计数器,用于计算状态标志的逻辑。另外,还有一个可选的同步(SRST)或异步(RST)复位信号。

common clock builtin fifo,fpga开发

 Common Clock FIFO: Shift Registers

此实现仅在Virtex-4 FPGA和更新的架构中可用。

说明了使用移位寄存器配置公共时钟的FIFO的功能实现。所有操作都同步到同一时钟输入(CLK)。这个设计实现了一个写和读指针和逻辑的上/下计数器,用于计算状态标志的逻辑。

common clock builtin fifo,fpga开发

 Common Clock (CLK), Built-in FIFO(独立时钟,内置fifo)

此实现可选地支持第一个字的故障切换

FIFO生成器支持使用内置的FIFO原语的FIFO内核。这为用户提供了使用内置的FIFO的能力,而只需要一个时钟接口。具有内置FIFO的公共时钟配置的行为与具有内置FIFO的独立时钟配置相同,除了所有操作都与公共时钟(CLK)有关。

Independent Clocks (RD_CLK, WR_CLK), Block RAM

此实现可选地支持非对称读/写端口和第一个字的故障切换

说明了一个配置了独立时钟的FIFO的功能实现。这个实现使用块RAM或分布式RAM用于内存,用于写和读指针的计数器,二进制代码和灰度代码之间的转换用于跨时钟域的同步,以及用于计算状态标志的逻辑。

common clock builtin fifo,fpga开发

 该FIFO被设计为支持一个独立的读时钟(RD_CLK)和写时钟(WR_CLK);换句话说,RD_CLK和WR_CLK之间的频率或相位没有必要的关系。下表总结了FIFO接口信号,它们仅在各自的时钟域中有效

common clock builtin fifo,fpga开发

 对于使用独立时钟的FIFO核心,写操作和读取操作与状态标志之间的时间关系受到两个时钟之间关系的影响。例如,写入空FIFO和断空之间的时间由写时钟和读时钟之间的相位和频率关系决定。

我选择了读写独立时钟,配置成内部fifo

common clock builtin fifo,fpga开发

 read mode

读取模式仅在选择块RAM或分布式RAM FIFOs时可用。对内置FIFOs的支持仅适用于Kintex-7、Virtex-7、Virtex-6和Virtex-5的FPGA实现。

标准FIFO实现了具有标准延迟的FIFO,而不使用输出寄存器。

第一字下降直通FIFO实现了一个具有注册输出的FIFO。

Built-in FIFO Options
在标准的fifo模式下,当没有读使能时,dout是不会有输出的,但是如果使用模式,我测试了,在没有读写使能的前提下,任然会输出第一个读数,并且会早于读使能。
common clock builtin fifo,fpga开发
--------------------------------------------------------------------------------
-- Company: 
-- Engineer:
--
-- Create Date:   14:37:40 09/01/2022
-- Design Name:   
-- Module Name:   F:/ISE/trigger/fifo/fifo_tb.vhd
-- Project Name:  fifo
-- Target Device:  
-- Tool versions:  
-- Description:   
-- 
-- VHDL Test Bench Created by ISE for module: fifo
-- 
-- Dependencies:
-- 
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes: 
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation 
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
 use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
 
ENTITY fifo_tb IS
END fifo_tb;
 
ARCHITECTURE behavior OF fifo_tb IS 
 
    -- Component Declaration for the Unit Under Test (UUT)
 
   COMPONENT fifo
  PORT (
    rst : IN STD_LOGIC;
    wr_clk : IN STD_LOGIC;
    rd_clk : IN STD_LOGIC;
    din : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    wr_en : IN STD_LOGIC;
    rd_en : IN STD_LOGIC;
    dout : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);
    full : OUT STD_LOGIC;
    almost_full : OUT STD_LOGIC;
    wr_ack : OUT STD_LOGIC;
    overflow : OUT STD_LOGIC;
    empty : OUT STD_LOGIC;
    almost_empty : OUT STD_LOGIC;
    valid : OUT STD_LOGIC;
    underflow : OUT STD_LOGIC;
    rd_data_count : OUT STD_LOGIC_VECTOR(8 DOWNTO 0);
    wr_data_count : OUT STD_LOGIC_VECTOR(8 DOWNTO 0)
  );
END COMPONENT;
    

   --Inputs
   signal rst : std_logic := '0';
   signal wr_clk : std_logic := '0';
   signal rd_clk : std_logic := '0';
   signal din : std_logic_vector(17 downto 0) := (others => '0');
   signal wr_en : std_logic := '0';
   signal rd_en : std_logic := '0';

 	--Outputs
   signal dout : std_logic_vector(17 downto 0):= (others => '0');
   signal full : std_logic:= '0';
   signal empty : std_logic:= '0';
   signal valid : std_logic:= '0';
   signal underflow : std_logic:= '0';

    signal rd_data_count : std_logic_vector(8 downto 0):= (others => '0');
    signal wr_data_count : std_logic_vector(8 downto 0):= (others => '0');
   signal almost_full : std_logic:= '0';
   signal wr_ack : std_logic:= '0';
   signal overflow : std_logic:= '0';
   signal almost_empty : std_logic:= '0';
   
    
   -- Clock period definitions
   constant wr_clk_period : time := 10 ns;
   constant rd_clk_period : time := 10 ns;
 
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: fifo PORT MAP (
    rst => rst,
    wr_clk => wr_clk,
    rd_clk => rd_clk,
    din => din,
    wr_en => wr_en,
    rd_en => rd_en,
    dout => dout,
    full => full,
    almost_full => almost_full,
    wr_ack => wr_ack,
    overflow => overflow,
    empty => empty,
    almost_empty => almost_empty,
    valid => valid,
    underflow => underflow,
    rd_data_count => rd_data_count,
    wr_data_count => wr_data_count
  );

   -- Clock process definitions
   wr_clk_process :process
   begin
		wr_clk <= '0';
		wait for wr_clk_period/2;
		wr_clk <= '1';
		wait for wr_clk_period/2;
   end process;
 
   rd_clk_process :process
   begin
		rd_clk <= '0';
		wait for rd_clk_period/2;
		rd_clk <= '1';
		wait for rd_clk_period/2;
   end process;
 


   -- Stimulus process
   stim_proc: process
   begin		
     rst <= '1';
    wr_en <= '0';
    rd_en <= '0'; 
    din <= (others => '0');
      wait for wr_clk_period;
    rst <= '0';
    wait for wr_clk_period*5;
    
    wr_en <= '1'; 
     din <= "00"&X"1203";
     wait for wr_clk_period;
     wr_en <= '0';
      wait for wr_clk_period*10;
      
      rd_en <= '1';   
      
      wr_en <= '1'; 
      din <= "00"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
     rd_en <= '0';
      wait for wr_clk_period*10;
      
      rd_en <= '1';  
      wr_en <= '1'; 
      din <= "10"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
     rd_en <= '0';
      wait for wr_clk_period*10;
      
      rd_en <= '1';  
      wr_en <= '1'; 
      din <= "01"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
     rd_en <= '0';
      wait for wr_clk_period*10;
      -- insert stimulus here 

      wait;
   end process;

END;

common clock builtin fifo,fpga开发

 先写再读,而且是写一个之后就开始读,并且读写频率一样,所以仿真结果就是写一次读一次

--------------------------------------------------------------------------------
-- Company: 
-- Engineer:
--
-- Create Date:   14:37:40 09/01/2022
-- Design Name:   
-- Module Name:   F:/ISE/trigger/fifo/fifo_tb.vhd
-- Project Name:  fifo
-- Target Device:  
-- Tool versions:  
-- Description:   
-- 
-- VHDL Test Bench Created by ISE for module: fifo
-- 
-- Dependencies:
-- 
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes: 
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation 
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
 use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
 
ENTITY fifo_tb IS
END fifo_tb;
 
ARCHITECTURE behavior OF fifo_tb IS 
 
    -- Component Declaration for the Unit Under Test (UUT)
 
   COMPONENT fifo
  PORT (
    rst : IN STD_LOGIC;
    wr_clk : IN STD_LOGIC;
    rd_clk : IN STD_LOGIC;
    din : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    wr_en : IN STD_LOGIC;
    rd_en : IN STD_LOGIC;
    dout : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);
    full : OUT STD_LOGIC;
    almost_full : OUT STD_LOGIC;
    wr_ack : OUT STD_LOGIC;
    overflow : OUT STD_LOGIC;
    empty : OUT STD_LOGIC;
    almost_empty : OUT STD_LOGIC;
    valid : OUT STD_LOGIC;
    underflow : OUT STD_LOGIC;
    rd_data_count : OUT STD_LOGIC_VECTOR(8 DOWNTO 0);
    wr_data_count : OUT STD_LOGIC_VECTOR(8 DOWNTO 0)
  );
END COMPONENT;
    

   --Inputs
   signal rst : std_logic := '0';
   signal wr_clk : std_logic := '0';
   signal rd_clk : std_logic := '0';
   signal din : std_logic_vector(17 downto 0) := (others => '0');
   signal wr_en : std_logic := '0';
   signal rd_en : std_logic := '0';

 	--Outputs
   signal dout : std_logic_vector(17 downto 0):= (others => '0');
   signal full : std_logic:= '0';
   signal empty : std_logic:= '0';
   signal valid : std_logic:= '0';
   signal underflow : std_logic:= '0';

    signal rd_data_count : std_logic_vector(8 downto 0):= (others => '0');
    signal wr_data_count : std_logic_vector(8 downto 0):= (others => '0');
   signal almost_full : std_logic:= '0';
   signal wr_ack : std_logic:= '0';
   signal overflow : std_logic:= '0';
   signal almost_empty : std_logic:= '0';
   
    
   -- Clock period definitions
   constant wr_clk_period : time := 10 ns;
   constant rd_clk_period : time := 10 ns;
 
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: fifo PORT MAP (
    rst => rst,
    wr_clk => wr_clk,
    rd_clk => rd_clk,
    din => din,
    wr_en => wr_en,
    rd_en => rd_en,
    dout => dout,
    full => full,
    almost_full => almost_full,
    wr_ack => wr_ack,
    overflow => overflow,
    empty => empty,
    almost_empty => almost_empty,
    valid => valid,
    underflow => underflow,
    rd_data_count => rd_data_count,
    wr_data_count => wr_data_count
  );

   -- Clock process definitions
   wr_clk_process :process
   begin
		wr_clk <= '0';
		wait for wr_clk_period/2;
		wr_clk <= '1';
		wait for wr_clk_period/2;
   end process;
 
   rd_clk_process :process
   begin
		rd_clk <= '0';
		wait for rd_clk_period/2;
		rd_clk <= '1';
		wait for rd_clk_period/2;
   end process;
 


   -- Stimulus process
   stim_proc: process
   begin		
     rst <= '1';
    wr_en <= '0';
    rd_en <= '0'; 
    din <= (others => '0');
      wait for wr_clk_period;
    rst <= '0';
    wait for wr_clk_period*5;
    
    wr_en <= '1'; 
     din <= "00"&X"1203";
     wait for wr_clk_period;
     wr_en <= '0';
      wait for wr_clk_period*3;
      
      rd_en <= '1';   
      
      wr_en <= '1'; 
      din <= "00"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
    
      wait for wr_clk_period*3;
      
   
      wr_en <= '1'; 
      din <= "10"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
  
      wait for wr_clk_period*3;
      
    
      wr_en <= '1'; 
      din <= "01"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
  
      wait for wr_clk_period*3;
      -- insert stimulus here 

      wait;
   end process;

END;

common clock builtin fifo,fpga开发

先写两个数据,再读,所以读出的结果就是当读使能来的时候,立马读出两个数,然后再去等待下一个数写入

  -- Stimulus process
   stim_proc: process
   begin		
     rst <= '1';
    wr_en <= '0';
    rd_en <= '0'; 
    din <= (others => '0');
      wait for wr_clk_period;
    rst <= '0';
    wait for wr_clk_period*5;
    
    wr_en <= '1'; 
     din <= "00"&X"1203";
     wait for wr_clk_period;
     wr_en <= '0';
      wait for wr_clk_period*3;
      
      
      
      wr_en <= '1'; 
      din <= "00"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
    
      wait for wr_clk_period*3;
      
    rd_en <= '1';   
      wr_en <= '1'; 
      din <= "10"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
  
      wait for wr_clk_period*3;
      
    
      wr_en <= '1'; 
      din <= "01"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
  
      wait for wr_clk_period*3;
      -- insert stimulus here 

      wait;
   end process;

common clock builtin fifo,fpga开发

这次是先使能读,然后再写,就会等数据写进去之后,数据才会读出

-- Stimulus process
   stim_proc: process
   begin		
     rst <= '1';
    wr_en <= '0';
    rd_en <= '0'; 
    din <= (others => '0');
      wait for wr_clk_period;
    rst <= '0';
    wait for wr_clk_period*5;
     rd_en <= '1';  
     wait for wr_clk_period*5;
    wr_en <= '1'; 
     din <= "00"&X"1203";
     wait for wr_clk_period;
     wr_en <= '0';
      wait for wr_clk_period*3;
      
      
      
      wr_en <= '1'; 
      din <= "00"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
    
      wait for wr_clk_period*3;
      
    
      wr_en <= '1'; 
      din <= "10"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
  
      wait for wr_clk_period*3;
      
    
      wr_en <= '1'; 
      din <= "01"&X"1103";
      wait for wr_clk_period;
     wr_en <= '0';
  
      wait for wr_clk_period*3;
      -- insert stimulus here 

      wait;
   end process;

common clock builtin fifo,fpga开发

测试结论就是,用fifo读写可以避免用rom,因为数据还没有写入时,一直读出上一次的数据,用fifo就可以在vaild为高时去读取,这样读出的数就是依次写入的数据文章来源地址https://www.toymoban.com/news/detail-772554.html

到了这里,关于xilinx FPGA FIFO IP核的使用(VHDL&ISE)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • FPGA 学习分享-- 04 FIFO核的使用(2)

    写在前面: 博主耗费了四天!!!完成了FIFO核的第二部分。 在这个部分,博主遇到了很多问题,对着代码不停修改,询问学长和老师,好在终于没有报错,可以向大家交作业了!当然,我会在本文详细的帮助大家学习FIFO核的代码编写,带着大家剖析每个部分,尽可能地通俗

    2024年02月03日
    浏览(32)
  • IP核的使用之FIFO(Vivado)

    在开始介绍 FIFO IP核 之前,我们先设想这么一个 实际场景 :FPGA内部有个16位计数器,以50MHz的频率计数,此时,我们希望随机截取计数器连续256个计数周期的值发到电脑上进行分析处理。用串口发送到电脑上。( 数据产生速率大于数据使用速率 ),此时需要使用存储器先将

    2024年01月18日
    浏览(30)
  • Xilinx FPGA未使用管脚上下拉状态配置(ISE和Vivado环境)

    ISE开发环境 ISE开发环境,可在如下Bit流文件生成选项中配置。 右键点击 Generate Programming File ,选择 Process Properties , 在弹出的窗口选择 Configuration Options-Unused Pin ,选择 Pull Down、Pull Up或者Float 。 可以看到,除了未使用管脚,一些系统管脚,比如JTAG,Program、Done管脚等等都可

    2024年02月06日
    浏览(38)
  • 基于xilinx的fifo IP核使用

            FIFO(First In First Out,即先入先出),是一种数据缓冲器,用来实现数据先入先出的读写方式。与 ROM 或 RAM 的按地址读写方式不同,FIFO 的读写遵循“先进先出”的原则,即数据按顺序写入 FIFO,先被写入的数据同样在读取的时候先被读出,所以FIFO存储器没有地址

    2024年02月08日
    浏览(30)
  • XILINX关于Adder/Subtracter加法器减法器 IP核的使用与仿真

    平台:vivado21018.3,modelsim 10.6c 芯片:xc7k325tffg900-2 (active) Adder/Subtracter IP可提供LUT和单个DSP48 slice加法/减法实现方案。Adder/Subtracter 模块可实现加法器 (A+B)、减法器 (A–B),以及可通过签名或未签名数据运行的动态可配置加法器/减法器。该功能能够以单个DSP48 slice方式实现,也

    2024年02月15日
    浏览(35)
  • Xilinx FPGA——ISE的UCF时序约束

            时序约束是我们对FPGA设计的要求和期望,例如,我们希望FPGA设计可以工作在多快的时钟频率下等等。         设计是要求 系统中的每一个时钟都进行时序约束 。         TNM是最基本的分组约束语法,其语法定义如下:          {NET|INST|PIN} \\\"net_or_pin_or_i

    2024年02月04日
    浏览(34)
  • FIFO(一) —— Quartus中FIFO IP核的学习与modelsim仿真

    1、 FIFO:(First In First Out),是有先进先出特性的缓存器,常被用于数据的缓存或者高速异步数据的交互。 2、 FIFO与普通存储器的区别在于:它没有外部读写地址线(其数据地址由内部读写指针自动加 1 完成),操作简单但不能指定某一地址。 3、主要包含两种:单时钟FIF

    2024年02月08日
    浏览(36)
  • FPGA学习笔记(二):clk IP核的使用

     1.打开VIVADO,点击IP Catalog   2. 搜索clk,选择Clocking Wizard   3. 配置参数 (1) 选择MMCM      (2) 设置主频50Mhz  (3) 设置输出的4个clk的参数,分别是50M,25M,100M,100M反相。Phase表示相位,0表示同相,180表示反相。      (3) 其他参数  4. 测试文件 其中clk_wiz的例化可参考模板。点击

    2024年02月12日
    浏览(41)
  • FPGA学习笔记(六): FIR IP核的使用

    1. 打开VIVADO,点击IP Catalog   2.搜索DDS,选择DDS Compiler,按照上节配置频率为3MHz和4MHz的DDS IP核。    这里注意不勾选Has Phase Out 这里注意不勾选Output TREADY     输出频率为3MHz 按照上述步骤,配置4MHz的DDS,同样不勾选Has Phase Out以及不勾选Output TREADY。 3. 点击IP Catalog,搜索mu

    2024年02月03日
    浏览(37)
  • FPGA学习笔记(五):DDS IP核的使用

     1. 打开VIVADO,点击IP Catalog    2.搜索DDS,选择DDS Compiler    3. 配置参数 (1) 设置主频频率 50MHz   (2) 选择sine,并且勾选Has Phase Out(相位输出)    (3) 勾选Output TREDAY  (4) 输入频率    (5) 同上述步骤,再加一个DDS IP核 4. 测试文件   5. 结果展示        

    2024年02月11日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包