ISE下的FIFO IP核有Standard FIFO和First-word-Fall-Through两种模式,相对于标准模式FWFT(First-word-Fall-Through)能够不须要读命令,自动的将最新数据放在dout上。spa
接下来分别对两种模式下的FIFO进行仿真,testbench以下code
1 module fifo_test; 2 3 // Inputs 4 reg rst; 5 reg wr_clk; 6 reg rd_clk; 7 reg [15:0] din; 8 reg wr_en; 9 reg rd_en; 10 11 // Outputs 12 wire [7:0] dout; 13 wire full; 14 wire empty; 15 wire [13:0] rd_data_count; 16 17 // Instantiate the Unit Under Test (UUT) 18 write_fifo uut ( 19 .rst(rst), 20 .wr_clk(wr_clk), 21 .rd_clk(rd_clk), 22 .din(din), 23 .wr_en(wr_en), 24 .rd_en(rd_en), 25 .dout(dout), 26 .full(full), 27 .empty(empty), 28 .rd_data_count(rd_data_count) 29 ); 30 31 always #5 wr_clk = ~wr_clk; 32 always #5 rd_clk = ~rd_clk; 33 34 35 initial begin 36 // Initialize Inputs 37 rst = 0; 38 wr_clk = 0; 39 rd_clk = 0; 40 din = 0; 41 wr_en = 0; 42 rd_en = 0; 43 44 // Wait 100 ns for global reset to finish 45 #100; 46 din = 8193; 47 wr_en = 1; 48 repeat(8192) 49 #10 din = din - 1; 50 #10 51 wr_en = 0; 52 #100 53 rd_en = 1; 54 #163840 55 rd_en = 0; 56 #10; 57 $stop; 58 59 60 // Add stimulus here 61 62 end 63 64 endmodule
两次仿真FIFO的配置都同样,写位宽为16,写深度为8192,读位宽为8,读深度为16384.blog
图一为标准FIFO的仿真截图,图二为FWFT模式的仿真截图it
图二中在读信号有效以前,dout即输出了最新的数据。class
另外须要注意的有:test
1,FIFO的实际有效深度为理论深度减。。module
2,FIFO中的rd_data_count信号指示的是FIFO前几拍时的状态,即在连续写入2个数据时,rd_data_count依然为0.配置