2015-03-24 20:44:03 -04:00
|
|
|
|
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-04-23 17:53:22 -04:00
|
|
|
reset, 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
|
|
|
|
|
|
|
parameter DW = 104;
|
|
|
|
parameter AW = 2;
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-23 17:53:22 -04:00
|
|
|
|
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
|
|
|
//##########
|
|
|
|
input reset;
|
|
|
|
input wr_clk; //write clock
|
2015-04-23 17:53:22 -04:00
|
|
|
input rd_clk; //read clock
|
|
|
|
|
|
|
|
//##########
|
|
|
|
//# FIFO WRITE
|
|
|
|
//##########
|
|
|
|
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-04-23 17:53:22 -04:00
|
|
|
input rd_en;
|
|
|
|
output [DW-1:0] dout;
|
|
|
|
output empty;
|
2015-04-27 11:15:06 -04:00
|
|
|
output valid;
|
2015-04-23 17:53:22 -04:00
|
|
|
|
2015-04-27 11:15:06 -04:00
|
|
|
|
|
|
|
reg valid;
|
|
|
|
|
2015-04-23 17:53:22 -04:00
|
|
|
`ifdef TARGET_CLEAN
|
2015-04-14 23:56:00 -04:00
|
|
|
//Wires
|
2015-04-23 17:53:22 -04:00
|
|
|
wire [DW/8-1:0] wr_vec;
|
2015-04-14 23:56:00 -04:00
|
|
|
wire [AW:0] wr_rd_gray_pointer;
|
|
|
|
wire [AW:0] rd_wr_gray_pointer;
|
|
|
|
wire [AW:0] wr_gray_pointer;
|
|
|
|
wire [AW:0] rd_gray_pointer;
|
|
|
|
wire [AW-1:0] rd_addr;
|
|
|
|
wire [AW-1:0] wr_addr;
|
2015-03-24 20:44:03 -04:00
|
|
|
|
|
|
|
|
2015-04-23 17:53:22 -04:00
|
|
|
assign wr_vec[DW/8-1:0] = {(DW/8){wr_en}};
|
2015-04-27 11:15:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
//Valid data in FIFO
|
|
|
|
always @ (posedge rd_clk)
|
|
|
|
valid <= rd_en;
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
memory_dp #(.DW(DW),.AW(AW)) memory_dp (
|
|
|
|
// Outputs
|
2015-04-23 17:53:22 -04:00
|
|
|
.rd_data (dout[DW-1:0]),
|
2015-04-14 23:56:00 -04:00
|
|
|
// Inputs
|
|
|
|
.wr_clk (wr_clk),
|
2015-04-23 17:53:22 -04:00
|
|
|
.wr_en (wr_vec[DW/8-1:0]),
|
2015-04-14 23:56:00 -04:00
|
|
|
.wr_addr (wr_addr[AW-1:0]),
|
2015-04-23 17:53:22 -04:00
|
|
|
.wr_data (din[DW-1:0]),
|
2015-04-14 23:56:00 -04:00
|
|
|
.rd_clk (rd_clk),
|
|
|
|
.rd_en (1'b1),
|
|
|
|
.rd_addr (rd_addr[AW-1:0]));
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
//Read State Machine
|
|
|
|
fifo_empty_block #(.AW(AW)) fifo_empty_block(
|
|
|
|
// Outputs
|
2015-04-23 18:56:49 -04:00
|
|
|
.rd_fifo_empty (empty),
|
2015-04-14 23:56:00 -04:00
|
|
|
.rd_addr (rd_addr[AW-1:0]),
|
|
|
|
.rd_gray_pointer(rd_gray_pointer[AW:0]),
|
|
|
|
// Inputs
|
|
|
|
.reset (reset),
|
|
|
|
.rd_clk (rd_clk),
|
|
|
|
.rd_wr_gray_pointer(rd_wr_gray_pointer[AW:0]),
|
2015-04-23 17:53:22 -04:00
|
|
|
.rd_read (rd_en));
|
2015-04-14 23:56:00 -04:00
|
|
|
|
|
|
|
//Write State Machine
|
|
|
|
fifo_full_block #(.AW(AW)) fifo_full_block(
|
|
|
|
// Outputs
|
2015-04-23 18:56:49 -04:00
|
|
|
.wr_fifo_prog_full(prog_full),
|
|
|
|
.wr_fifo_full (full),
|
2015-04-14 23:56:00 -04:00
|
|
|
.wr_addr (wr_addr[AW-1:0]),
|
|
|
|
.wr_gray_pointer (wr_gray_pointer[AW:0]),
|
|
|
|
// Inputs
|
|
|
|
.reset (reset),
|
|
|
|
.wr_clk (wr_clk),
|
|
|
|
.wr_rd_gray_pointer(wr_rd_gray_pointer[AW:0]),
|
2015-04-23 18:56:49 -04:00
|
|
|
.wr_write (wr_en));
|
2015-04-14 23:56:00 -04:00
|
|
|
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
synchronizer #(.DW(AW+1)) rd2wr_sync (.out (wr_rd_gray_pointer[AW:0]),
|
|
|
|
.in (rd_gray_pointer[AW:0]),
|
2015-04-15 16:33:20 -04:00
|
|
|
.reset (reset),
|
2015-04-14 23:56:00 -04:00
|
|
|
.clk (wr_clk));
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
|
|
|
|
synchronizer #(.DW(AW+1)) wr2rd_sync (.out (rd_wr_gray_pointer[AW:0]),
|
|
|
|
.in (wr_gray_pointer[AW:0]),
|
2015-04-15 16:33:20 -04:00
|
|
|
.reset (reset),
|
2015-04-14 23:56:00 -04:00
|
|
|
.clk (rd_clk));
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
|
2015-04-23 18:56:49 -04:00
|
|
|
|
2015-04-23 17:53:22 -04:00
|
|
|
`elsif TARGET_XILINX
|
2015-04-14 23:56:00 -04:00
|
|
|
|
2015-04-23 17:53:22 -04:00
|
|
|
//insert generate FIFO
|
|
|
|
|
|
|
|
`endif // `ifdef TARGET_CLEAN
|
|
|
|
|
2015-03-24 20:44:03 -04:00
|
|
|
endmodule // fifo_async
|
2015-04-14 23:56:00 -04:00
|
|
|
// Local Variables:
|
|
|
|
// verilog-library-directories:("." "../../common/hdl")
|
|
|
|
// End:
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Adapteva, Inc.
|
|
|
|
Contributed by Andreas Olofsson, Roman Trogan <support@adapteva.com>
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2015-03-24 20:44:03 -04:00
|
|
|
|
2015-04-14 23:56:00 -04:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program (see the file COPYING). If not, see
|
|
|
|
<http://www.gnu.org/licenses/>.
|
|
|
|
*/
|