OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [FIFOs/] [CummingsSNUG2002SJ_FIFO1/] [beh_fifo.v] - Blame information for rev 34

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
// --------------------------------------------------------------------
2
//
3
 
4
 
5
module beh_fifo (rdata, wfull, rempty, wdata,
6
winc, wclk, wrst_n, rinc, rclk, rrst_n);
7
parameter DSIZE = 8;
8
parameter ASIZE = 4;
9
output [DSIZE-1:0] rdata;
10
output wfull;
11
output rempty;
12
input [DSIZE-1:0] wdata;
13
input winc, wclk, wrst_n;
14
input rinc, rclk, rrst_n;
15
reg [ASIZE:0] wptr, wrptr1, wrptr2, wrptr3;
16
reg [ASIZE:0] rptr, rwptr1, rwptr2, rwptr3;
17
parameter MEMDEPTH = 1<<ASIZE;
18
reg [DSIZE-1:0] ex_mem [0:MEMDEPTH-1];
19
always @(posedge wclk or negedge wrst_n)
20
if (!wrst_n) wptr <= 0;
21
else if (winc && !wfull) begin
22
ex_mem[wptr[ASIZE-1:0]] <= wdata;
23
wptr <= wptr+1;
24
end
25
always @(posedge wclk or negedge wrst_n)
26
if (!wrst_n) {wrptr3,wrptr2,wrptr1} <= 0;
27
else {wrptr3,wrptr2,wrptr1} <= {wrptr2,wrptr1,rptr};
28
always @(posedge rclk or negedge rrst_n)
29
if (!rrst_n) rptr <= 0;
30
else if (rinc && !rempty) rptr <= rptr+1;
31
always @(posedge rclk or negedge rrst_n)
32
if (!rrst_n) {rwptr3,rwptr2,rwptr1} <= 0;
33
else {rwptr3,rwptr2,rwptr1} <= {rwptr2,rwptr1,wptr};
34
assign rdata = ex_mem[rptr[ASIZE-1:0]];
35
assign rempty = (rptr == rwptr3);
36
assign wfull = ((wptr[ASIZE-1:0] == wrptr3[ASIZE-1:0]) &&
37
(wptr[ASIZE] != wrptr3[ASIZE] ));
38
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.