1 |
2 |
kdv |
/*
|
2 |
|
|
* xilinx_fifo_dc.v
|
3 |
|
|
*
|
4 |
|
|
* Copyright (c) 2007 Koen De Vleeschauwer.
|
5 |
|
|
*
|
6 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
7 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
10 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
11 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
12 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
13 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
14 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
15 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
16 |
|
|
* SUCH DAMAGE.
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/*
|
20 |
|
|
* fifo with independent clock for read and write port.
|
21 |
|
|
*/
|
22 |
|
|
|
23 |
|
|
`include "timescale.v"
|
24 |
|
|
|
25 |
|
|
module xilinx_fifo_dc (
|
26 |
|
|
rst,
|
27 |
|
|
wr_clk,
|
28 |
|
|
din,
|
29 |
|
|
wr_en,
|
30 |
|
|
full,
|
31 |
|
|
wr_ack,
|
32 |
|
|
overflow,
|
33 |
|
|
prog_full,
|
34 |
|
|
rd_clk,
|
35 |
|
|
dout,
|
36 |
|
|
rd_en,
|
37 |
|
|
empty,
|
38 |
|
|
valid,
|
39 |
|
|
underflow,
|
40 |
|
|
prog_empty
|
41 |
|
|
);
|
42 |
|
|
|
43 |
|
|
parameter [8:0]dta_width=9'd8; /* Data bus width */
|
44 |
|
|
parameter [8:0]addr_width=9'd8; /* Address bus width, determines fifo size by evaluating 2^addr_width */
|
45 |
|
|
parameter [8:0]prog_thresh=9'd1; /* Programmable threshold constant for prog_empty and prog_full */
|
46 |
|
|
|
47 |
|
|
input rst; /* low active sync master reset */
|
48 |
|
|
/* read port */
|
49 |
|
|
input rd_clk; /* read clock. positive edge active */
|
50 |
|
|
output [dta_width-1:0]dout; /* data output */
|
51 |
|
|
input rd_en; /* read enable */
|
52 |
|
|
output empty; /* asserted if fifo is empty; no additional reads can be performed */
|
53 |
|
|
output valid; /* valid (read acknowledge): indicates rd_en was asserted during previous clock cycle and data was succesfully read from fifo and placed on dout */
|
54 |
|
|
output underflow; /* underflow (read error): indicates rd_en was asserted during previous clock cycle but no data was read from fifo because fifo was empty */
|
55 |
|
|
output prog_empty; /* indicates the fifo has prog_thresh entries, or less. threshold for asserting prog_empty is prog_thresh */
|
56 |
|
|
/* write port */
|
57 |
|
|
input wr_clk; /* write clock. positive edge active */
|
58 |
|
|
input [dta_width-1:0]din; /* data input */
|
59 |
|
|
input wr_en; /* write enable */
|
60 |
|
|
output full; /* asserted if fifo is full; no additional writes can be performed */
|
61 |
|
|
output overflow; /* overflow (write error): indicates wr_en was asserted during previous clock cycle but no data was written to fifo because fifo was full */
|
62 |
|
|
output wr_ack; /* write acknowledge: indicates wr_en was asserted during previous clock cycle and data was succesfully written to fifo */
|
63 |
|
|
output prog_full; /* indicates the fifo has prog_thresh free entries, or less, left. threshold for asserting prog_full is 2^addr_width - prog_thresh */
|
64 |
|
|
|
65 |
|
|
/* Writing when the fifo is full, or reading while the fifo is empty, does not destroy the contents of the fifo. */
|
66 |
|
|
|
67 |
|
|
xilinx_fifo #(
|
68 |
|
|
.ALMOST_FULL_OFFSET(prog_thresh),
|
69 |
|
|
.ALMOST_EMPTY_OFFSET(prog_thresh),
|
70 |
|
|
.DATA_WIDTH(dta_width),
|
71 |
|
|
.ADDR_WIDTH(addr_width),
|
72 |
|
|
.DO_REG(1),
|
73 |
|
|
.EN_SYN("FALSE")
|
74 |
|
|
)
|
75 |
|
|
xilinx_fifo_dc (
|
76 |
|
|
.ALMOSTEMPTY(prog_empty),
|
77 |
|
|
.ALMOSTFULL(prog_full),
|
78 |
|
|
.DO(dout),
|
79 |
|
|
.EMPTY(empty),
|
80 |
|
|
.FULL(full),
|
81 |
|
|
.RDERR(underflow),
|
82 |
|
|
.VALID(valid),
|
83 |
|
|
.WRERR(overflow),
|
84 |
|
|
.WR_ACK(wr_ack),
|
85 |
|
|
.DI(din),
|
86 |
|
|
.RDCLK(rd_clk),
|
87 |
|
|
.RDEN(rd_en),
|
88 |
|
|
.RST(rst),
|
89 |
|
|
.WRCLK(wr_clk),
|
90 |
|
|
.WREN(wr_en)
|
91 |
|
|
);
|
92 |
|
|
|
93 |
|
|
`ifdef CHECK_GENERATE
|
94 |
|
|
initial
|
95 |
|
|
$display("%m: fifo parameters: dta_width=%0d addr_width=%0d prog_thresh=%0d", dta_width, addr_width, prog_thresh);
|
96 |
|
|
`endif
|
97 |
|
|
|
98 |
|
|
endmodule
|
99 |
|
|
/* not truncated */
|