I was playing around with Xilinx FIFO IP block and there are some things that I cannot explain in the following output :
`define wrclk_period 20 ;
`define rdclk_period 10 ;
module testbench;
reg rst;
reg wr_clk ;
reg rd_clk ;
reg [7:0] din ;
reg wr_en ;
reg rd_en ;
wire [7:0] dout ;
wire full ;
wire empty ;
fifo_generator_0 FG0(rst,wr_clk,rd_clk,din,wr_en,rd_en,dout,full,empty) ;
initial wr_clk = 1 ;
always #10 wr_clk = ~wr_clk ;
initial rd_clk = 1 ;
always #5 rd_clk = ~rd_clk ;
integer i,j ;
initial begin
rst = 1 ;
#10
din = 0 ;
wr_en = 0 ;
rd_en = 0 ;
rst = 0 ;
#`wrclk_period ;
rst = 1 ;
#`wrclk_period ;
rst = 0 ;
#60;
for(i= 0 ; i<=5 ; i = i+1 ) begin
wr_en = 1 ;
din = i ;
#`wrclk_period ;
end
wr_en = 0 ;
#`wrclk_period ;
#`rdclk_period ;
for( j= 0 ; j<=5 ; j = j+1 ) begin
rd_en = 1 ;
#`rdclk_period ;
end
rd_en = 0 ;
#`rdclk_period ;
$stop ;
end
endmodule
1) Question 1: The output variable full is high in the beginning . Why is this the case ?
2) Question 2 : Why do we miss the data 1 in the dout ? I can see 2,3,4,5 but 1 does not show up .
3) After rd_en is set to 1 , the dout change from 3 to 4 takes 2 clock cycles while the change from 2 to 3 happens at the immediate next posedge of the read clock ?