1. 程式人生 > >使用Xilinx FIFO IP核的總結(一)

使用Xilinx FIFO IP核的總結(一)

FIFO IP核的總結(一)
第一次使用Vivado中的FIFO generator,同步FIFO的常用埠也就10個左右:
CLK;
srst:復位埠
讀相關:
dout:FIFO資料輸出(output);
empty:讀空(output),empty為1,表明FIFO內無資料;
Vaild:讀有效(output):等到rd_en拉高後的下一個上升沿置1
rd_en:讀使能(input)
寫相關:
din:FIFO資料輸入(input)
wr_en:寫使能(input)
Full:寫滿(output)full為1,資料寫入將丟失
wr_ack:寫成功/握手訊號(output),等到wr_en拉高後的下一個上升沿置1。

//下面是頂層code,裡面例化了一個FIFO generator IP核:
`timescale 1ns / 1ps
 module FIFO_test(clk, srst, din, wr_en, rd_en, dout, full, wr_ack, empty, 
  valid);
  input clk;
  input srst;
  input [3:0]din;
  input wr_en;
  input rd_en;
  output [3:0]dout;
  output full;
  output wr_ack;
  output empty;
  output valid;

fifo_generator_0 fifo_use (.clk(clk),.srst(srst),.din(din),.wr_en(wr_en),.wr_ack(wr_ack),.full(full),.dout(dout),.empty(empty),.valid(valid),.rd_en(rd_en));

endmodule

//相應的test_bench code:

module tb_FIFO_test();
reg clk,srst;
reg [3:0] din;
reg wr_en;
reg rd_en;
wire [3:0]dout;
wire full;
wire wr_ack;
wire empty;
wire valid;

initial
begin
    clk=0;
    srst=0;
    din=4'd0;
    wr_en=0;
    rd_en=0;
    #10;
    srst=1;
    #10;
    
    repeat(16)
    begin
    wr_en=1;
    #20;
    wr_en=0;
    #20;
    din=din+1'b1;
    end
    
    repeat(16)
    begin
    rd_en=1;
    #20;
    rd_en=0;
    #20;
    end
    
end

always #5 clk=~clk;

FIFO_test fifo_tb (.clk(clk),.srst(srst),.din(din),.wr_en(wr_en),.wr_ack(wr_ack),.full(full),.dout(dout),.empty(empty),.valid(valid),.rd_en(rd_en));

 

Xilinx FIFO 模擬總結 https://blog.csdn.net/RuningBigCat/article/