ISE下的FIFO IP核有Standard FIFO和First-word-Fall-Through两种模式,相对于标准模式FWFT(First-word-Fall-Through)可以不需要读命令,自动的将最新数据放在dout上。
接下来分别对两种模式下的FIFO进行仿真,testbench如下
1 1 module fifo_test; 2 2 3 3 // Inputs 4 4 reg rst; 5 5 reg wr_clk; 6 6 reg rd_clk; 7 7 reg [15:0] din; 8 8 reg wr_en; 9 9 reg rd_en; 1010 1111 // Outputs 1212 wire [7:0] dout; 1313 wire full; 1414 wire empty; 1515 wire [13:0] rd_data_count; 1616 1717 // Instantiate the Unit Under Test (UUT) 1818 write_fifo uut ( 1919 .rst(rst), 2020 .wr_clk(wr_clk), 2121 .rd_clk(rd_clk), 2222 .din(din), 2323 .wr_en(wr_en), 2424 .rd_en(rd_en), 2525 .dout(dout), 2626 .full(full), 2727 .empty(empty), 2828 .rd_data_count(rd_data_count) 2929 ); 3030 3131 always #5 wr_clk = ~wr_clk; 3232 always #5 rd_clk = ~rd_clk; 3333 3434 3535 initial begin 3636 // Initialize Inputs 3737 rst = 0; 3838 wr_clk = 0; 3939 rd_clk = 0; 4040 din = 0; 4141 wr_en = 0; 4242 rd_en = 0; 4343 4444 // Wait 100 ns for global reset to finish 4545 #100; 4646 din = 8193; 4747 wr_en = 1; 4848 repeat(8192) 4949 #10 din = din - 1; 5050 #10 5151 wr_en = 0; 5252 #100 5353 rd_en = 1; 5454 #163840 5555 rd_en = 0; 5656 #10; 5757 $stop; 5858 5959 6060 // Add stimulus here 6161 6262 end 6363 6464 endmodule
两次仿真FIFO的配置都一样,写位宽为16,写深度为8192,读位宽为8,读深度为16384.


图一为标准FIFO的仿真截图,图二为FWFT模式的仿真截图
图二中在读信号有效之前,dout即输出了最新的数据。
另外需要注意的有:
1,FIFO的实际有效深度为理论深度减。。
2,FIFO中的rd_data_count信号指示的是FIFO前几拍时的状态,即在连续写入2个数据时,rd_data_count依然为0.