2015-04-14 23:56:00 -04:00
|
|
|
module fifo_async
|
|
|
|
(/*AUTOARG*/
|
2015-03-24 20:44:03 -04:00
|
|
|
// Outputs
|
2015-04-27 11:15:06 -04:00
|
|
|
full, prog_full, dout, empty, valid,
|
2015-03-24 20:44:03 -04:00
|
|
|
// Inputs
|
2015-11-09 13:20:46 -05:00
|
|
|
rst, wr_clk, rd_clk, wr_en, din, rd_en
|
2015-03-24 20:44:03 -04:00
|
|
|
);
|
2015-04-14 23:56:00 -04:00
|
|
|
|
2015-11-02 16:16:10 -05:00
|
|
|
parameter DW = 104; //FIFO width
|
|
|
|
parameter DEPTH = 32; //FIFO depth
|
2015-11-04 20:01:31 -05:00
|
|
|
parameter TYPE = "XILINX";//"BASIC" or "XILINX" or "ALTERA"
|
2015-11-24 01:05:04 -05:00
|
|
|
parameter WAIT = 1; //assert random prog_full wait
|
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
//##########
|
2015-04-23 17:53:22 -04:00
|
|
|
//# RESET/CLOCK
|
2015-04-14 23:56:00 -04:00
|
|
|
//##########
|
2015-11-09 13:20:46 -05:00
|
|
|
input rst; //read/write reset
|
2015-04-14 23:56:00 -04:00
|
|
|
input wr_clk; //write clock
|
2015-04-23 17:53:22 -04:00
|
|
|
input rd_clk; //read clock
|
|
|
|
|
|
|
|
//##########
|
|
|
|
//# FIFO WRITE
|
|
|
|
//##########
|
2015-11-09 13:20:46 -05:00
|
|
|
input wr_en;
|
|
|
|
input [DW-1:0] din;
|
|
|
|
output full;
|
|
|
|
output prog_full;
|
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
//###########
|
2015-04-23 17:53:22 -04:00
|
|
|
//# FIFO READ
|
2015-04-14 23:56:00 -04:00
|
|
|
//###########
|
2015-11-09 13:20:46 -05:00
|
|
|
input rd_en;
|
2015-07-02 16:59:38 -04:00
|
|
|
output [DW-1:0] dout;
|
2015-11-09 13:20:46 -05:00
|
|
|
output empty;
|
|
|
|
output valid;
|
2015-11-04 20:01:31 -05:00
|
|
|
|
2015-11-24 01:05:04 -05:00
|
|
|
wire fifo_prog_full;
|
|
|
|
wire wait_random;
|
|
|
|
|
|
|
|
assign prog_full = fifo_prog_full | wait_random;
|
|
|
|
|
2015-11-04 20:01:31 -05:00
|
|
|
generate
|
|
|
|
if(TYPE=="BASIC") begin : basic
|
2015-11-02 16:16:10 -05:00
|
|
|
fifo_async_model
|
|
|
|
#(.DEPTH(DEPTH),
|
|
|
|
.DW(DW))
|
2015-11-09 13:20:46 -05:00
|
|
|
fifo_model (
|
2015-11-02 16:16:10 -05:00
|
|
|
/*AUTOINST*/
|
|
|
|
// Outputs
|
2015-11-09 13:20:46 -05:00
|
|
|
.full (full),
|
2015-11-24 01:05:04 -05:00
|
|
|
.prog_full (fifo_prog_full),
|
2015-11-02 16:16:10 -05:00
|
|
|
.dout (dout[DW-1:0]),
|
|
|
|
.empty (empty),
|
|
|
|
.valid (valid),
|
|
|
|
// Inputs
|
2015-11-09 13:20:46 -05:00
|
|
|
.rst (rst),
|
2015-11-02 16:16:10 -05:00
|
|
|
.wr_clk (wr_clk),
|
|
|
|
.rd_clk (rd_clk),
|
|
|
|
.wr_en (wr_en),
|
|
|
|
.din (din[DW-1:0]),
|
|
|
|
.rd_en (rd_en));
|
2015-11-04 20:01:31 -05:00
|
|
|
end
|
|
|
|
else if (TYPE=="XILINX") begin : xilinx
|
|
|
|
if((DW==104) & (DEPTH==32))
|
|
|
|
begin
|
2015-11-09 13:20:46 -05:00
|
|
|
fifo_async_104x32 fifo_async_104x32 (
|
2015-11-04 20:01:31 -05:00
|
|
|
/*AUTOINST*/
|
|
|
|
// Outputs
|
2015-11-09 13:20:46 -05:00
|
|
|
.full (full),
|
2015-11-24 01:05:04 -05:00
|
|
|
.prog_full (fifo_prog_full),
|
2015-11-04 20:01:31 -05:00
|
|
|
.dout (dout[DW-1:0]),
|
|
|
|
.empty (empty),
|
|
|
|
.valid (valid),
|
|
|
|
// Inputs
|
2015-11-09 13:20:46 -05:00
|
|
|
.rst (rst),
|
2015-11-04 20:01:31 -05:00
|
|
|
.wr_clk (wr_clk),
|
|
|
|
.rd_clk (rd_clk),
|
|
|
|
.wr_en (wr_en),
|
|
|
|
.din (din[DW-1:0]),
|
|
|
|
.rd_en (rd_en));
|
|
|
|
|
|
|
|
end // if ((DW==104) & (DEPTH==32))
|
|
|
|
end // block: xilinx
|
|
|
|
endgenerate
|
2015-11-24 01:05:04 -05:00
|
|
|
|
|
|
|
//Random wait generator
|
|
|
|
generate
|
|
|
|
if(WAIT)
|
|
|
|
begin
|
|
|
|
reg [7:0] wait_counter;
|
|
|
|
always @ (posedge wr_clk or posedge rst)
|
|
|
|
if(rst)
|
|
|
|
wait_counter[7:0] <= 'b0;
|
|
|
|
else
|
|
|
|
wait_counter[7:0] <= wait_counter+1'b1;
|
|
|
|
assign wait_random = (|wait_counter[4:0]);//(|wait_counter[3:0]);//1'b0;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
assign wait_random = 1'b0;
|
|
|
|
end // else: !if(WAIT)
|
|
|
|
endgenerate
|
|
|
|
|
2015-04-23 17:53:22 -04:00
|
|
|
|
2015-03-24 20:44:03 -04:00
|
|
|
endmodule // fifo_async
|
2015-04-14 23:56:00 -04:00
|
|
|
// Local Variables:
|
2015-11-06 16:51:57 -05:00
|
|
|
// verilog-library-directories:("." "../fpga/" "../dv")
|
2015-04-14 23:56:00 -04:00
|
|
|
// End:
|