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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [rtl/] [verilog/] [generic_fifo.v] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "generic_fifo.v"                                  ////
4
////                                                              ////
5
////  This file is part of the "10GE MAC" project                 ////
6
////  http://www.opencores.org/cores/xge_mac/                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - A. Tanguay (antanguay@opencores.org)                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38 5 antanguay
`include "defines.v"
39 2 antanguay
 
40
module generic_fifo(
41
 
42
    wclk,
43
    wrst_n,
44
    wen,
45
    wdata,
46
    wfull,
47
    walmost_full,
48
 
49
    rclk,
50
    rrst_n,
51
    ren,
52
    rdata,
53
    rempty,
54
    ralmost_empty
55
);
56
 
57
//---
58
// Parameters
59
 
60
parameter DWIDTH = 32;
61
parameter AWIDTH = 3;
62
parameter RAM_DEPTH = (1 << AWIDTH);
63
parameter REGISTER_READ = 0;
64
parameter EARLY_READ = 0;
65
parameter CLOCK_CROSSING = 1;
66
parameter ALMOST_EMPTY_THRESH = 1;
67
parameter ALMOST_FULL_THRESH = RAM_DEPTH-2;
68
parameter MEM_TYPE = `MEM_AUTO_SMALL;
69
 
70
//---
71
// Ports
72
 
73
input          wclk;
74
input          wrst_n;
75
input          wen;
76
input  [DWIDTH-1:0] wdata;
77
output         wfull;
78
output         walmost_full;
79
 
80
input          rclk;
81
input          rrst_n;
82
input          ren;
83
output [DWIDTH-1:0] rdata;
84
output         rempty;
85
output         ralmost_empty;
86
 
87
// Wires
88
 
89
wire             mem_wen;
90
wire [AWIDTH:0]  mem_waddr;
91
 
92
wire             mem_ren;
93
wire [AWIDTH:0]  mem_raddr;
94
 
95
 
96
generic_fifo_ctrl #(.AWIDTH (AWIDTH),
97 20 antanguay
                    .RAM_DEPTH (RAM_DEPTH),
98 2 antanguay
                    .EARLY_READ (EARLY_READ),
99
                    .CLOCK_CROSSING (CLOCK_CROSSING),
100
                    .ALMOST_EMPTY_THRESH (ALMOST_EMPTY_THRESH),
101
                    .ALMOST_FULL_THRESH (ALMOST_FULL_THRESH)
102
                    )
103
  ctrl0(.wclk (wclk),
104
        .wrst_n (wrst_n),
105
        .wen (wen),
106
        .wfull (wfull),
107
        .walmost_full (walmost_full),
108 20 antanguay
 
109 2 antanguay
        .mem_wen (mem_wen),
110
        .mem_waddr (mem_waddr),
111
 
112
        .rclk (rclk),
113
        .rrst_n (rrst_n),
114
        .ren (ren),
115
        .rempty (rempty),
116
        .ralmost_empty (ralmost_empty),
117
 
118
        .mem_ren (mem_ren),
119
        .mem_raddr (mem_raddr)
120
        );
121
 
122
 
123
generate
124
    if (MEM_TYPE == `MEM_AUTO_SMALL) begin
125
 
126
        generic_mem_small #(.DWIDTH (DWIDTH),
127
                            .AWIDTH (AWIDTH),
128
                            .RAM_DEPTH (RAM_DEPTH),
129
                            .REGISTER_READ (REGISTER_READ)
130
                            )
131
          mem0(.wclk (wclk),
132
               .wrst_n (wrst_n),
133 20 antanguay
               .wen (mem_wen),
134
               .waddr (mem_waddr[AWIDTH-1:0]),
135 2 antanguay
               .wdata (wdata),
136 20 antanguay
 
137 2 antanguay
               .rclk (rclk),
138
               .rrst_n (rrst_n),
139
               .ren (mem_ren),
140
               .roen (ren),
141 20 antanguay
               .raddr (mem_raddr[AWIDTH-1:0]),
142 2 antanguay
               .rdata (rdata)
143
               );
144
 
145
    end
146
 
147
    if (MEM_TYPE == `MEM_AUTO_MEDIUM) begin
148
 
149
        generic_mem_medium #(.DWIDTH (DWIDTH),
150
                             .AWIDTH (AWIDTH),
151
                             .RAM_DEPTH (RAM_DEPTH),
152
                             .REGISTER_READ (REGISTER_READ)
153
                             )
154
          mem0(.wclk (wclk),
155
               .wrst_n (wrst_n),
156 20 antanguay
               .wen (mem_wen),
157
               .waddr (mem_waddr[AWIDTH-1:0]),
158 2 antanguay
               .wdata (wdata),
159 20 antanguay
 
160 2 antanguay
               .rclk (rclk),
161
               .rrst_n (rrst_n),
162
               .ren (mem_ren),
163 5 antanguay
               .roen (ren),
164 20 antanguay
               .raddr (mem_raddr[AWIDTH-1:0]),
165 2 antanguay
               .rdata (rdata)
166
               );
167
 
168
    end
169
 
170
endgenerate
171
 
172
endmodule

powered by: WebSVN 2.1.0

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