[an error occurred while processing this directive]
|
module fifo
(
input ainit, wr_clk, rd_clk, wr_en, rd_en,
input [7:0] din ,
output wire full, empty,
output wire [5:0] count,
output reg [7:0] dout
);
reg [7:0] fifo_reg [63:0] ;
reg [5:0] wr_cnt, rd_cnt ;
initial begin wr_cnt = 8'd0 ; rd_cnt = 8'd0 ; end
assign full = (count == 6'd63); assign empty = (count == 8'd0);
assign count = wr_cnt - rd_cnt ;
always @(posedge wr_clk, posedge ainit) if (ainit) wr_cnt <= 6'd0 ;
else if (wr_en & ~full) wr_cnt <= wr_cnt + 1 ;
always @(posedge rd_clk, posedge ainit) if (ainit) rd_cnt <= 6'd0 ;
else if (rd_en & ~empty) rd_cnt <= rd_cnt + 1 ;
always @(posedge wr_clk) if (wr_en & ~full) fifo_reg[wr_cnt] <= din ;
always @(posedge rd_clk) if (rd_en) begin if (empty) dout <= 8'd0 ; else dout <= fifo_reg[rd_cnt] ; end
endmodule
E-mail: info@telesys.ru