工具:vivado 2019.2
实验内容:测试xilinx的FIFO IP核
实验得出的结果:
1、almost_empty/almost_full 在相应的计数器还有2个数据位的时候触发,也就是说我们在检测到这个信号的时候(需要一个时钟周期),数据计数器中已经剩下1个数据位了;同理empty/full在相应的计数器还有1个数据位的时候触发,当我们检测到信号的时候,数据计数器的可用数据位清零;
2、在写入一个数据后,相应的写数据计数器,在2个时钟周期以后完成数据更新,而读计数器在6个时钟周期以后,完成数据更新,所以我们在写完一个数据后,要进行读取的时候,需要在第7个时钟周期才能获得数据,因此为了保证数据的一致性,我们在做这种操作的时候,一定要留够足够的延时时间。
仿真图如下:
数据计数器的数据更新

触发电平的时机

做读写操作时适当添加延时,这里延时10个时钟周期,保证fifo内部完成数据状态更新

测试代码如下:
顶层模块
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
//
// Engineer: mankaichuang
// Create Date: 2020/12/01 11:21:44
// Module Name: ip_fifo
// Description: fifo顶层模块
//
//////////////////////////////////////////////////////////////////////////////////
module ip_fifo(
input sys_clk,
input sys_rst_n
);
wire almost_full;
wire almost_empty;
wire fifo_wr_en;
wire fifo_rd_en;
wire[7:0] fifo_wdata;
wire[7:0] fifo_rdata;
wire full;
wire empty;
wire [7:0] rd_data_count;
wire [7:0] wr_data_count;
fifo_write u_fifo_write(
.sys_clk (sys_clk),
.sys_rst_n (sys_rst_n),
.almost_full (almost_full),
.almost_empty (almost_empty),
.fifo_wr_en (fifo_wr_en),
.fifo_wdata (fifo_wdata)
);
fifo_read u_fifo_read(
.sys_clk

本文通过Vivado 2019.2进行实验,详细介绍了使用Xilinx FIFO IP核的过程。实验结果显示,almost_empty/almost_full 信号在剩余2个数据位时触发,empty/full在剩余1个数据位时触发。写数据计数器更新需2个时钟周期,读计数器需6个时钟周期。为确保数据一致性,建议在读写操作间添加至少10个时钟周期的延时。附带仿真图及测试代码。
最低0.47元/天 解锁文章
4194

被折叠的 条评论
为什么被折叠?



