Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / txfifo_load.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: txfifo_load.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35/*%W% %G%*/
36
37/*************************************************************************
38 *
39 * File Name : txfifo_load.v
40 * Author Name : John Lo
41 * Description : It contains txmac write pointer management logic and
42 * associated control logic and txfifo memory itself.
43 * Parent Module: tx_xmac
44 * Child Module:
45 * Interface Mod:
46 * Date Created :
47 *
48 * Copyright (c) 2002, Sun Microsystems, Inc.
49 * Sun Proprietary and Confidential
50 *
51 * Modification : Added opp_txmac_data,
52 * opp_txmac_ack,
53 * opp_txmac_tag,
54 * opp_txmac_stat,
55 * opp_txmac_abort registration.
56 *
57 * Synthesis Notes:
58 *
59 *************************************************************************/
60
61module txfifo_load (
62 clk,
63 tx_reset_clk,
64 opp_txmac_data,
65 opp_txmac_ack,
66 opp_txmac_tag,
67 opp_txmac_stat,
68 opp_txmac_abort,
69 txfifo_g_rd_ptr_sync,
70 txfifo_rd_ptr_txclk,
71 stfifo_g_rd_ptr_sync,
72 stfifo_rd_ptr_txclk,
73// outputs
74 txmac_opp_req,
75 txfifo_full_clk_reg,
76 txfifo_empty_clk_reg,
77 txfifo_overrun_clk,
78 txfifo_g_wr_ptr_clk,
79 txfifo_wr_ptr_clk,
80 txfifo_rd_ptr_clk,
81 stfifo_full_clk,
82 stfifo_empty_clk,
83 stfifo_overrun_clk,
84 stfifo_g_wr_ptr_clk,
85 no_crc,
86 last_byte_position,
87 txfifo_dout
88 );
89
90 input clk;
91 input tx_reset_clk;
92 input [63:0] opp_txmac_data;
93 input opp_txmac_ack;
94 input opp_txmac_tag;
95 input [3:0] opp_txmac_stat;
96 input opp_txmac_abort;
97 input [4:0] txfifo_g_rd_ptr_sync;
98 input [3:0] txfifo_rd_ptr_txclk;
99 input [4:0] stfifo_g_rd_ptr_sync;
100 input [3:0] stfifo_rd_ptr_txclk;
101// outputs
102 output txmac_opp_req;
103 output txfifo_full_clk_reg;
104 output txfifo_empty_clk_reg;
105 output txfifo_overrun_clk;
106 output [4:0] txfifo_g_wr_ptr_clk;
107 output [4:0] txfifo_wr_ptr_clk;
108 output [4:0] txfifo_rd_ptr_clk;
109 output stfifo_full_clk;
110 output stfifo_empty_clk;
111 output stfifo_overrun_clk;
112 output [4:0] stfifo_g_wr_ptr_clk;
113 output no_crc;
114 output [2:0] last_byte_position;
115 output [65:0] txfifo_dout;
116
117 wire filtered_tag_in;
118 // 10-29-2001, loj replaced opp_txma_sa_repl with opp_txmac_abort.
119 wire [65:0] txfifo_din;
120 wire [65:0] txfifo_dout;
121 // txfifo
122 wire [4:0] txfifo_g_rd_ptr_sync;
123 wire [4:0] txfifo_rd_ptr_clk;
124 wire [4:0] txfifo_g_wr_ptr_clk;
125 wire [4:0] txfifo_wr_ptr_clk;
126 wire txfifo_full_clk_reg;
127 wire txfifo_empty_clk_reg;
128 wire txfifo_full_clk;
129 wire txfifo_empty_clk;
130 // stfifo
131 wire [4:0] stfifo_rd_ptr_clk;
132 wire [3:0] stfifo_rd_ptr_txclk;
133 wire [4:0] stfifo_g_wr_ptr_clk;
134 wire [4:0] stfifo_wr_ptr_clk;
135 // internal signals
136 wire txfifo_load_rdy;
137 wire txfifo_wr_en;
138 wire [63:0] txmac_data;
139 wire [3:0] txmac_stat;
140 wire txmac_ack;
141 wire txmac_tag;
142 wire txmac_abort;
143// register all the opp to txmac signals
144 RegDff #(64) txmac_data_RegDff (.clk(clk), .din(opp_txmac_data), .qout(txmac_data));
145 RegRst #(1) txmac_ack_RegRst (.clk(clk),.reset(tx_reset_clk),.din(opp_txmac_ack), .qout(txmac_ack));
146 RegRst #(1) txmac_tag_RegRst (.clk(clk),.reset(tx_reset_clk),.din(opp_txmac_tag), .qout(txmac_tag));
147 RegDff #(4) txmac_stat_RegDff (.clk(clk), .din(opp_txmac_stat), .qout(txmac_stat));
148 RegRst #(1) txmac_abort_RegRst (.clk(clk),.reset(tx_reset_clk),.din(opp_txmac_abort),.qout(txmac_abort));
149// register output signals
150 RegRst #(1) txmac_opp_req_RegRst(.clk(clk),.reset(tx_reset_clk),.din(txfifo_load_rdy),.qout(txmac_opp_req));
151
152// start regular logic
153
154 assign filtered_tag_in = txmac_ack & txmac_tag;
155 // 10-29-2001, loj replaced opp_txma_sa_repl with txmac_abort.
156 assign txfifo_din[65:0] = {txmac_abort, // opp_txma_sa_repl,
157 filtered_tag_in,txmac_data[63:0]};
158
159/* --------------- start txfifo pointer Management ------------------ */
160
161// txfifo_overrun should never happen. Since txmac_opp_req control
162// such that it will never happen.
163 assign txfifo_wr_en = txmac_ack & ~txfifo_full_clk;
164
165// txfifo read Pointer, rd_ptr from txclk
166g2b_5bit txfifo_g_rd_ptr_g2b_5bit(.g_cnt(txfifo_g_rd_ptr_sync),
167 .b_cnt(txfifo_rd_ptr_clk));
168
169// txfifo G write Pointer, g_wr_ptr
170g_cntr_5bit txfifo_g_wr_ptr_clk_g_cntr_5bit
171 (.reset(tx_reset_clk),
172 .clk(clk),
173 .ce(txfifo_wr_en),
174 .g_cnt(txfifo_g_wr_ptr_clk));
175
176// Txfifo write Pointer
177counter_X5 txfifo_wr_ptr_clk_counter_X5(.clk(clk),.clr(tx_reset_clk),.enable(txfifo_wr_en),.count(txfifo_wr_ptr_clk));
178// txfifo write Pointer
179//g2b_5bit txfifo_g2b_5bit(.g_cnt(txfifo_g_wr_ptr_clk),
180// .b_cnt(txfifo_wr_ptr_clk));
181
182 wire [4:0] txfifo_empty_space_clk =
183 (txfifo_wr_ptr_clk[4] == txfifo_rd_ptr_clk[4]) ?
184 16 - ({1'b0,txfifo_wr_ptr_clk[3:0]} - {1'b0,txfifo_rd_ptr_clk[3:0]}):
185 ({1'b0,txfifo_rd_ptr_clk[3:0]} - {1'b0,txfifo_wr_ptr_clk[3:0]});
186
187 assign txfifo_full_clk=(txfifo_wr_ptr_clk[4]==(!txfifo_rd_ptr_clk[4])) &&
188 (txfifo_wr_ptr_clk[3:0]==txfifo_rd_ptr_clk[3:0]);
189
190 FD1 txfifo_full_clk_reg_FD1 (.D(txfifo_full_clk), .CP(clk),.Q(txfifo_full_clk_reg));
191
192 assign txfifo_empty_clk=(txfifo_wr_ptr_clk[4:0]==txfifo_rd_ptr_clk[4:0]);
193
194 FD1 txfifo_empty_clk_reg_FD1(.D(txfifo_empty_clk),.CP(clk),.Q(txfifo_empty_clk_reg));
195
196 wire txfifo_overrun_clk = txfifo_full_clk & txmac_ack;
197
198/* --------------- end of txfifo pointer Management ----------------- */
199
200//*********************************
201//***** stfifo declaration *****
202//*********************************
203
204 // txmac_stat[14]: no_crc
205 // txmac_stat[13:11]: last_byte_position
206
207// stfifo read Pointer, rd_ptr from txclk
208g2b_5bit stfifo_g_rd_ptr_clk_g2b_5bit(.g_cnt(stfifo_g_rd_ptr_sync),
209 .b_cnt(stfifo_rd_ptr_clk));
210
211// stfifo G Write Pointer, g_wr_ptr to sysclk
212g_cntr_5bit stfifo_g_wr_ptr_clk_g_cntr_5bit(
213 .reset(tx_reset_clk),
214 .clk(clk),
215 .ce(filtered_tag_in),
216 .g_cnt(stfifo_g_wr_ptr_clk));
217
218// stfifo Write Pointer
219g2b_5bit stfifo_g2b_5bit(.g_cnt(stfifo_g_wr_ptr_clk),
220 .b_cnt(stfifo_wr_ptr_clk));
221
222 wire stfifo_full_clk=(stfifo_wr_ptr_clk[4]==(!stfifo_rd_ptr_clk[4])) &&
223 (stfifo_wr_ptr_clk[3:0]==stfifo_rd_ptr_clk[3:0]);
224
225 wire stfifo_empty_clk=(stfifo_wr_ptr_clk[4:0]==stfifo_rd_ptr_clk[4:0]);
226
227 wire stfifo_overrun_clk = stfifo_full_clk & filtered_tag_in;
228
229 wire [3:0] stfifo_dout;
230 wire [2:0] last_byte_position;
231 wire no_crc;
232
233 assign no_crc = stfifo_dout[3];
234 assign last_byte_position = stfifo_dout[2:0];
235/* --------------- end of stfifo pointer Management --------------- */
236
237
238/* ----------------------- Tx Burst I/F ----------------------------- */
239
240 assign txfifo_load_rdy = txfifo_empty_space_clk > 4;
241
242
243/* --------------- txfifo memory instantiation ---------------------- */
244txfifo_memory_model txfifo_memory_model(
245 .clk(clk),
246 .reset(tx_reset_clk),
247 .wp(txfifo_wr_ptr_clk[3:0]),
248 .rp(txfifo_rd_ptr_txclk[3:0]),
249 .we(txfifo_wr_en),
250 .din(txfifo_din),
251 .dout(txfifo_dout));
252
253/* --------------- stfifo memory instantiation ---------------------- */
254stfifo_memory_model stfifo_memory_model(
255 .clk(clk),
256 .reset(tx_reset_clk),
257 .wp(stfifo_wr_ptr_clk[3:0]),
258 .rp(stfifo_rd_ptr_txclk[3:0]),
259 .we(filtered_tag_in),
260 .din(txmac_stat[3:0]),
261 .dout(stfifo_dout[3:0]));
262
263endmodule // txfifo_load
264
265
266module txfifo_memory_model (clk,reset,wp,rp,we,din,dout);
267 input clk,reset;
268 input [3:0] wp,rp;
269 input we;
270 input [65:0] din;
271 output [65:0] dout;
272
273
274reg [65:0] txfifo_mem [0:15]; // 66 bit wide 16 deep
275
276always @ (posedge clk)
277 begin
278 if (reset)
279 begin
280 txfifo_mem[0] <= 0;
281 txfifo_mem[1] <= 0;
282 txfifo_mem[2] <= 0;
283 txfifo_mem[3] <= 0;
284 txfifo_mem[4] <= 0;
285 txfifo_mem[5] <= 0;
286 txfifo_mem[6] <= 0;
287 txfifo_mem[7] <= 0;
288 txfifo_mem[8] <= 0;
289 txfifo_mem[9] <= 0;
290 txfifo_mem[10] <= 0;
291 txfifo_mem[11] <= 0;
292 txfifo_mem[12] <= 0;
293 txfifo_mem[13] <= 0;
294 txfifo_mem[14] <= 0;
295 txfifo_mem[15] <= 0;
296 end
297 else
298 begin
299 case (we) // synopsys parallel_case full_case infer_mux
300 1'b1: txfifo_mem[wp] <= din;
301 1'b0: txfifo_mem[wp] <= txfifo_mem[wp];
302 endcase // case(we)
303 end // else: !if(reset)
304 end // always @ (posedge clk)
305
306
307 assign dout = txfifo_mem[rp];
308
309endmodule // txfifo_memory_model
310
311
312module stfifo_memory_model (clk,reset,wp,rp,we,din,dout);
313 input clk;
314 input reset;
315 input [3:0] wp,rp;
316 input we;
317 input [3:0] din;
318 output [3:0] dout;
319
320
321reg [3:0] stfifo_mem [0:15]; // 4 bit wide 16 deep
322
323always @ (posedge clk)
324 begin
325 if (reset)
326 begin
327 stfifo_mem[0] <= 0;
328 stfifo_mem[1] <= 0;
329 stfifo_mem[2] <= 0;
330 stfifo_mem[3] <= 0;
331 stfifo_mem[4] <= 0;
332 stfifo_mem[5] <= 0;
333 stfifo_mem[6] <= 0;
334 stfifo_mem[7] <= 0;
335 stfifo_mem[8] <= 0;
336 stfifo_mem[9] <= 0;
337 stfifo_mem[10] <= 0;
338 stfifo_mem[11] <= 0;
339 stfifo_mem[12] <= 0;
340 stfifo_mem[13] <= 0;
341 stfifo_mem[14] <= 0;
342 stfifo_mem[15] <= 0;
343 end
344 else
345 begin
346 case (we) // synopsys parallel_case full_case infer_mux
347 1'b1: stfifo_mem[wp] <= din;
348 1'b0: stfifo_mem[wp] <= stfifo_mem[wp];
349 endcase // case(we)
350 end
351 end // always @ (posedge clk)
352
353
354
355 assign dout = stfifo_mem[rp];
356
357endmodule // stfifo_memory_model
358