Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / niu_ipp_unload_ctl_1ke.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_ipp_unload_ctl_1ke.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/**********************************************************
36***********************************************************
37
38 Project : Niu
39
40 File name : niu_ipp_unload_ctl_1ke.v
41
42 Module(s) name : niu_ipp_unload_ctl_1ke
43
44 Parent modules : niu_ipp.v
45
46 Child modules : niu_ipp.h
47
48 Author's name : George Chu
49
50 Date : Jan. 2004
51
52 Description : This module contains a Finite State Machine used to
53 control the ipp_unload interface protocol.
54
55 Synthesis Notes:
56
57 Modification History:
58 Date Description
59 ---- -----------
60
61************************************************************
62***********************************************************/
63
64`timescale 1ns/10ps
65
66`include "niu_ipp.h"
67
68module niu_ipp_unload_ctl_1ke (
69 ipp_ffl_dvalid_n,
70 cur_pkt_hdr_base_ptr,
71 cur_pkt_ffl_sum_info,
72 ipp_hfifo_dat_tag,
73 ipp_hfifo_dat_empty,
74 ipp_dfifo_dout_tag,
75 ipp_dmc_dat_err1,
76 sum_prt_valid,
77 dmc_ipp_dat_req,
78 pio_cksum_ena,
79 pio_full_cksum,
80 ipp_enable,
81 ippfifo_rd_wr_ptr_bypass,
82 ippfifo_rd_ptr_pio_wr_en,
83 datfifo_pio_wr_ena,
84 dfifo_rd_ptr_pio_wr_en,
85 dfifo_wt_ptr_pio_wr_en,
86 dfifo_wt_data_reg_wr_en_pls,
87 ipp_pio_wdata,
88
89 reset,
90 clk,
91
92 inc_hfifo_dat_rptr,
93 inc_hfifo_dat_rptr_d,
94 ipp_hfifo_dat_rptr,
95 ipp_hfifo_dat_tag_rd,
96 ipp_dfifo_wptr,
97 ipp_dfifo_wten,
98 ipp_dfifo_wten_2nd,
99 ipp_dfifo_rden,
100 ipp_dfifo_rptr,
101 ipp_dfifo_full,
102 wt_dfifo_1st_wd,
103 addr_status,
104 ipp_dmc_dat_ack,
105 ipp_dmc_ful_pkt,
106 ipp_full_cksum,
107 ipp_start_tcp,
108 ipp_sum_info_vld,
109 req_rd_dfifo_eop,
110 req_rd_dfifo_sop,
111 ipp_la2_opti,
112 ipp_la3_vers,
113 ip4_hdr_leng,
114 ipp_la4_prot,
115 clr_ipp_unload,
116 n_ipp_unload_idle,
117 fet_pio_tcp_ena,
118 dfifo_miss_eop,
119 dfifo_miss_sop,
120 c_unload_st
121 );
122
123input ipp_ffl_dvalid_n;
124input [6:0] cur_pkt_hdr_base_ptr;
125input [9:0] cur_pkt_ffl_sum_info;
126input [1:0] ipp_hfifo_dat_tag;
127input ipp_hfifo_dat_empty;
128input [1:0] ipp_dfifo_dout_tag;
129input ipp_dmc_dat_err1;
130input sum_prt_valid;
131input dmc_ipp_dat_req;
132input pio_cksum_ena;
133input pio_full_cksum;
134input ipp_enable;
135input ippfifo_rd_wr_ptr_bypass;
136input ippfifo_rd_ptr_pio_wr_en;
137input datfifo_pio_wr_ena;
138input dfifo_rd_ptr_pio_wr_en;
139input dfifo_wt_ptr_pio_wr_en;
140input dfifo_wt_data_reg_wr_en_pls;
141input [10:0] ipp_pio_wdata;
142
143input reset;
144input clk;
145
146output inc_hfifo_dat_rptr;
147output inc_hfifo_dat_rptr_d;
148output [6:0] ipp_hfifo_dat_rptr;
149output [1:0] ipp_hfifo_dat_tag_rd;
150output [10:0] ipp_dfifo_wptr; // addr[9:0] of 16k-byte data, 1k entries, + 1_wrap
151output ipp_dfifo_wten;
152output ipp_dfifo_wten_2nd;
153output ipp_dfifo_rden;
154output [10:0] ipp_dfifo_rptr; // addr[9:0] of 16k-byte data, 1k entries, + 1_wrap
155output ipp_dfifo_full;
156output wt_dfifo_1st_wd;
157output [11:0] addr_status;
158output ipp_dmc_dat_ack;
159output ipp_dmc_ful_pkt;
160output ipp_full_cksum;
161output ipp_start_tcp;
162output ipp_sum_info_vld;
163output req_rd_dfifo_eop;
164output req_rd_dfifo_sop;
165output [1:0] ipp_la2_opti;
166output [1:0] ipp_la3_vers;
167output [3:0] ip4_hdr_leng;
168output [1:0] ipp_la4_prot;
169
170output clr_ipp_unload;
171output n_ipp_unload_idle;
172output fet_pio_tcp_ena;
173output dfifo_miss_eop;
174output dfifo_miss_sop;
175output [4:0] c_unload_st;
176
177reg inc_hfifo_dat_rptr;
178reg inc_hfifo_dat_rptr_d;
179wire [6:0] ipp_hfifo_dat_rptr;
180wire [1:0] ipp_hfifo_dat_tag_rd;
181wire [10:0] ipp_dfifo_wptr; // addr[9:0] of 16k-byte data, 1k entries, + 1_wrap
182wire ipp_dfifo_wten;
183reg ipp_dfifo_wten_2nd;
184reg ipp_dfifo_wten_pkt;
185wire ipp_dfifo_full;
186reg wt_dfifo_1st_wd, wt_dfifo_1st_wd_d, wt_dfifo_1st_wd_d2;
187reg [11:0] addr_status;
188wire ipp_dmc_dat_ack, ipp_dmc_dat_ack_0, ipp_dmc_dat_ack_1, ipp_dmc_dat_ack_2;
189wire ipp_dmc_ful_pkt, ipp_dmc_ful_pkt_1, ipp_dmc_ful_pkt_2, n_ipp_dmc_ful_pkt_2;
190wire ipp_dmc_dat_emp_0;
191wire ipp_full_cksum;
192reg ipp_start_tcp;
193wire ipp_sum_info_vld;
194wire req_rd_dfifo_eop;
195wire req_rd_dfifo_sop;
196wire [1:0] ipp_la2_opti = cur_pkt_ffl_sum_info[1:0];
197wire [1:0] ipp_la3_vers = cur_pkt_ffl_sum_info[3:2];
198wire [3:0] ip4_hdr_leng = cur_pkt_ffl_sum_info[7:4];
199wire [1:0] ipp_la4_prot = cur_pkt_ffl_sum_info[9:8];
200
201reg clr_ipp_unload;
202wire n_ipp_unload_idle;
203wire fet_pio_tcp_ena;
204reg dfifo_miss_eop, n_dfifo_miss_eop;
205reg dfifo_miss_sop, n_dfifo_miss_sop;
206reg [4:0] c_unload_st;
207
208reg [4:0] n_unload_st;
209
210reg ipp_ffl_dvalid_n_d;
211wire start_unload_n = !ipp_ffl_dvalid_n && ipp_ffl_dvalid_n_d;
212reg start_unload;
213
214reg ipp_cksum_done_r;
215wire n_ipp_cksum_done;
216wire ipp_cksum_done;
217
218reg lod_hfifo_base_rptr;
219
220wire [6:0] n_hfifo_dat_rptr;
221reg [6:0] hfifo_dat_rptr;
222
223wire [11:0] n_addr_status;
224
225reg lod_dfifo_base_wptr;
226reg inc_ipp_dfifo_wptr;
227reg [10:0] ipp_dfifo_wptr_r;
228wire [10:0] n_addr_wt_pkt, n_addr_packet;
229reg [10:0] addr_wt_pkt, addr_packet;
230
231wire ipp_dfifo_rden;
232wire [10:0] n_ipp_dfifo_rptr; // addr[9:0] of 16k-byte data, 1k entries, + 1_wrap
233reg [10:0] ipp_dfifo_rptr; // addr[9:0] of 16k-byte data, 1k entries, + 1_wrap
234wire [10:0] dfifo_free_space;
235wire ipp_dfifo_amsful;
236
237wire ipp_dfifo_empty;
238
239wire n_ipp_dmc_dat_ack;
240
241wire ipp_dfifo_dout_eop = ipp_dfifo_dout_tag[1];
242wire ipp_dfifo_dout_sop = ipp_dfifo_dout_tag[0];
243reg ipp_dfifo_dout_eop_d;
244wire req_rd_dfifo_eop_d1, req_rd_dfifo_eop_d2;
245wire req_rd_dfifo_eops;
246
247reg [8:0] n_dfifo_pkt_count; // 1k entries, up to 16k-bytes
248reg [8:0] dfifo_pkt_count; // 1k entries, up to 16k-bytes
249wire n_ipp_dmc_ful_pkt;
250
251reg n_clr_ipp_unload;
252
253wire req_rd_dfifo_sop_d;
254wire req_rd_dfifo_sop_rise = req_rd_dfifo_sop && !req_rd_dfifo_sop_d;
255wire req_rd_dfifo_sop_rise_d;
256
257reg n_fet_pio_tcp_ena;
258wire no_cksum;
259
260wire ecc_err_force, ecc_err_force_d;
261
262wire [1:0] hfifo_dat_tag_rd;
263wire [1:0] n_hfifo_dat_tag_rd;
264reg [1:0] hfifo_dat_tag_rd_d;
265
266reg n_bad_tag_mac_sta, bad_tag_mac_sta;
267
268reg [1:0] c_dfifo_tag_st, n_dfifo_tag_st;
269
270// =============================================================================
271/* These checkers check for the transition of the state variable. */
272
273/* c_unload_st can transition from `IPP_UNLOAD_IDLE to `IPP_DFIFO_XFR_1ST */
274/* 0in state_transition -var c_unload_st -val `IPP_UNLOAD_IDLE -next `IPP_DFIFO_XFR_1ST */
275
276/* c_unload_st can transition from `IPP_DFIFO_XFR_1ST to `IPP_DFIFO_XFR_DAT */
277/* 0in state_transition -var c_unload_st -val `IPP_DFIFO_XFR_1ST -next `IPP_DFIFO_XFR_DAT */
278
279/* c_unload_st can transition from `IPP_DFIFO_XFR_DAT to `IPP_BKWT_1ST_WORD, \
280 `IPP_WAIT_HFIFO_STA, \
281 `IPP_GET_MAC_STAT, \
282 `IPP_WAIT_HFIFO_DAT */
283/* 0in state_transition -var c_unload_st -val `IPP_DFIFO_XFR_DAT -next `IPP_BKWT_1ST_WORD
284 `IPP_WAIT_HFIFO_STA
285 `IPP_GET_MAC_STAT
286 `IPP_WAIT_HFIFO_DAT */
287
288/* c_unload_st can transition from `IPP_GET_MAC_STAT to `IPP_BKWT_1ST_WORD, \
289 `IPP_DFIFO_XFR_ERR */
290/* 0in state_transition -var c_unload_st -val `IPP_GET_MAC_STAT -next `IPP_BKWT_1ST_WORD
291 `IPP_DFIFO_XFR_ERR */
292
293// geo: /* c_unload_st can transition from `IPP_WAIT_CKSUM_DON to `IPP_BKWT_1ST_WORD */
294// geo: /* 0in state_transition -var c_unload_st -val `IPP_WAIT_CKSUM_DON -next `IPP_BKWT_1ST_WORD */
295
296/* c_unload_st can transition from `IPP_BKWT_1ST_WORD to `IPP_UNLOAD_IDLE */
297/* 0in state_transition -var c_unload_st -val `IPP_BKWT_1ST_WORD -next `IPP_UNLOAD_IDLE
298 -match_by_cycle */
299
300/* c_unload_st can transition from `IPP_WAIT_HFIFO_STA to `IPP_GET_MAC_STAT */
301/* 0in state_transition -var c_unload_st -val `IPP_WAIT_HFIFO_STA -next `IPP_GET_MAC_STAT */
302
303/* c_unload_st can transition from `IPP_WAIT_HFIFO_DAT to `IPP_DFIFO_XFR_DAT */
304/* 0in state_transition -var c_unload_st -val `IPP_WAIT_HFIFO_DAT -next `IPP_DFIFO_XFR_DAT */
305
306// -----------------------------------------------------------------------------
307 always @(start_unload or
308 ipp_dfifo_full or ipp_hfifo_dat_empty or
309 inc_hfifo_dat_rptr_d or ipp_hfifo_dat_tag_rd or
310 pio_cksum_ena or fet_pio_tcp_ena or
311 ipp_la3_vers or ipp_la4_prot or
312 ipp_cksum_done or
313 c_unload_st
314 ) begin
315
316 lod_hfifo_base_rptr = 1'h0;
317 inc_hfifo_dat_rptr = 1'h0;
318 lod_dfifo_base_wptr = 1'h0;
319 ipp_dfifo_wten_2nd = 1'h0;
320 ipp_dfifo_wten_pkt = 1'h0;
321 inc_ipp_dfifo_wptr = 1'h0;
322 ipp_start_tcp = 1'h0;
323
324 wt_dfifo_1st_wd = 1'h0;
325 n_clr_ipp_unload = 1'h0;
326
327 n_bad_tag_mac_sta = 1'h0;
328
329 n_unload_st = 5'h0;
330
331 n_fet_pio_tcp_ena = fet_pio_tcp_ena;
332
333 case (c_unload_st) //synopsys parallel_case
334 /* 0in < case -default */
335
336 (`IPP_UNLOAD_IDLE):
337 begin
338 if (start_unload) begin
339 n_fet_pio_tcp_ena = pio_cksum_ena;
340 lod_hfifo_base_rptr = 1'h1;
341 inc_hfifo_dat_rptr = 1'h1;
342 lod_dfifo_base_wptr = 1'h1;
343 n_unload_st = `IPP_DFIFO_XFR_1ST;
344 end
345 else begin
346 n_fet_pio_tcp_ena = 1'h0;
347 n_unload_st = c_unload_st[4:0];
348 end
349 end
350
351 (`IPP_DFIFO_XFR_1ST):
352 if (ipp_dfifo_full)
353 begin
354 ipp_dfifo_wten_2nd = inc_hfifo_dat_rptr_d;
355 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
356 ipp_start_tcp = ((ipp_la4_prot==2'h2) || (ipp_la4_prot==2'h1)) &&
357 ((ipp_la3_vers==2'h1) || (ipp_la3_vers==2'h2)) && fet_pio_tcp_ena;
358 n_unload_st = c_unload_st[4:0];
359 end
360 else
361 begin
362 inc_hfifo_dat_rptr = 1'h1;
363 ipp_dfifo_wten_2nd = inc_hfifo_dat_rptr_d;
364 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
365 inc_ipp_dfifo_wptr = 1'h1;
366 ipp_start_tcp = ((ipp_la4_prot==2'h2) || (ipp_la4_prot==2'h1)) &&
367 ((ipp_la3_vers==2'h1) || (ipp_la3_vers==2'h2)) && fet_pio_tcp_ena;
368 n_unload_st = `IPP_DFIFO_XFR_DAT;
369 end
370
371 (`IPP_DFIFO_XFR_DAT):
372 if (ipp_dfifo_full)
373 begin
374 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
375 n_unload_st = c_unload_st[4:0];
376 end
377 else
378 begin
379 casez (ipp_hfifo_dat_tag_rd) //synopsys parallel_case
380 /* 0in < case -default */
381 (2'b?1): begin
382 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
383 inc_ipp_dfifo_wptr = 1'h1;
384 n_unload_st = `IPP_BKWT_1ST_WORD;
385 end
386 (2'b10): if (ipp_hfifo_dat_empty) begin
387 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
388 n_unload_st = `IPP_WAIT_HFIFO_STA;
389 end
390 else begin
391 inc_hfifo_dat_rptr = 1'h1;
392 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
393 inc_ipp_dfifo_wptr = 1'h1;
394 n_unload_st = `IPP_GET_MAC_STAT;
395 end
396// (2'b01): begin
397// n_unload_st = `IPP_DFIFO_XFR_ERR;
398// n_bad_tag_xfr_dat = 1'h1;
399// end
400 (2'b00): if (ipp_hfifo_dat_empty) begin
401 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
402 n_unload_st = `IPP_WAIT_HFIFO_DAT;
403 end
404 else begin
405 inc_hfifo_dat_rptr = 1'h1;
406 ipp_dfifo_wten_pkt = inc_hfifo_dat_rptr_d;
407 inc_ipp_dfifo_wptr = 1'h1;
408 n_unload_st = c_unload_st[4:0];
409 end
410 default: begin
411 n_unload_st = `IPP_UNLOAD_IDLE;
412 end
413 endcase
414 end
415
416 (`IPP_GET_MAC_STAT):
417 if (ipp_hfifo_dat_tag_rd[0])
418 begin
419 n_unload_st = `IPP_BKWT_1ST_WORD;
420 end
421 else if (ipp_hfifo_dat_empty)
422 begin
423 n_unload_st = c_unload_st[4:0]; // geo: careful, rd_ptr increase?, can it happen?
424 end
425 else
426 begin
427 n_unload_st = `IPP_DFIFO_XFR_ERR;
428 n_bad_tag_mac_sta = 1'h1;
429 end
430
431//geo (`IPP_WAIT_CKSUM_DON):
432//geo if (!ipp_dfifo_full && ipp_cksum_done)
433//geo begin
434//geo n_wt_dfifo_1st_wd = 1'h1;
435//geo n_unload_st = `IPP_BKWT_1ST_WORD;
436//geo end
437//geo else
438//geo begin
439//geo n_unload_st = c_unload_st[4:0];
440//geo end
441
442 (`IPP_BKWT_1ST_WORD):
443 if (!ipp_dfifo_full && ipp_cksum_done)
444 begin
445 wt_dfifo_1st_wd = 1'h1;
446 ipp_dfifo_wten_pkt = 1'h1;
447 n_clr_ipp_unload = 1'h1;
448 n_unload_st = `IPP_UNLOAD_IDLE;
449 end
450 else
451 begin
452 n_unload_st = c_unload_st[4:0];
453 end
454
455 (`IPP_WAIT_HFIFO_STA):
456 if (ipp_hfifo_dat_empty)
457 begin
458 n_unload_st = c_unload_st[4:0];
459 end
460 else
461 begin
462 inc_hfifo_dat_rptr = 1'h1;
463 inc_ipp_dfifo_wptr = 1'h1;
464 n_unload_st = `IPP_GET_MAC_STAT;
465 end
466
467 (`IPP_WAIT_HFIFO_DAT):
468 if (ipp_hfifo_dat_empty)
469 begin
470 n_unload_st = c_unload_st[4:0];
471 end
472 else
473 begin
474 inc_hfifo_dat_rptr = 1'h1;
475 inc_ipp_dfifo_wptr = 1'h1;
476 n_unload_st = `IPP_DFIFO_XFR_DAT;
477 end
478
479 (`IPP_DFIFO_XFR_ERR):
480 begin
481// inc_ipp_dfifo_wptr = 1'h1; // geo: how to handle it
482// n_unload_st = `IPP_UNLOAD_IDLE;
483 n_unload_st = c_unload_st[4:0];
484// synopsys translate_off
485 $display ("Warning @sim_time=%d, data_fifo missed mac_status_tag bad_tag_mac_sta=%h, hang in DFIFO_XFR_ERR!\n",
486 $stime, bad_tag_mac_sta);
487// synopsys translate_on
488 end
489
490 default: begin
491 n_unload_st = `IPP_UNLOAD_IDLE;
492 end
493 endcase
494 end
495
496// =============================================================================
497 always @(req_rd_dfifo_sop or
498 req_rd_dfifo_eops or
499 c_dfifo_tag_st
500 ) begin
501
502 n_dfifo_miss_eop = 1'h0;
503 n_dfifo_miss_sop = 1'h0;
504
505 n_dfifo_tag_st = 2'h0;
506
507 case (c_dfifo_tag_st) //synopsys parallel_case
508 /* 0in < case -default */
509
510 (`IPP_DFIFO_TAG_IDLE):
511 if (req_rd_dfifo_sop)
512 begin
513 n_dfifo_tag_st = `IPP_DFIFO_TAG_WAIT_EOP;
514 end
515 else
516 begin
517 n_dfifo_tag_st = c_dfifo_tag_st[1:0];
518 end
519
520 (`IPP_DFIFO_TAG_WAIT_EOP):
521 if (req_rd_dfifo_eops)
522 begin
523 n_dfifo_tag_st = `IPP_DFIFO_TAG_WAIT_SOP;
524 end
525 else if (req_rd_dfifo_sop)
526 begin
527 n_dfifo_miss_eop = 1'h1;
528 n_dfifo_tag_st = `IPP_DFIFO_TAG_IDLE;
529 end
530 else
531 begin
532 n_dfifo_tag_st = c_dfifo_tag_st[1:0];
533 end
534
535 (`IPP_DFIFO_TAG_WAIT_SOP):
536 if (req_rd_dfifo_sop)
537 begin
538 n_dfifo_tag_st = `IPP_DFIFO_TAG_WAIT_EOP;
539 end
540 else if (req_rd_dfifo_eops)
541 begin
542 n_dfifo_miss_sop = 1'h1;
543 n_dfifo_tag_st = `IPP_DFIFO_TAG_IDLE;
544 end
545 else
546 begin
547 n_dfifo_tag_st = c_dfifo_tag_st[1:0];
548 end
549
550 default:
551 begin
552 n_dfifo_tag_st = `IPP_DFIFO_TAG_IDLE;
553 end
554
555 endcase
556 end
557
558// =============================================================================
559 assign n_ipp_unload_idle = (n_unload_st[4:0]==`IPP_UNLOAD_IDLE);
560
561// =============================================================================
562 assign n_hfifo_dat_rptr = ippfifo_rd_wr_ptr_bypass ?
563 (ippfifo_rd_ptr_pio_wr_en ? ipp_pio_wdata[6:0] : hfifo_dat_rptr[6:0]) :
564 (inc_hfifo_dat_rptr ? ipp_hfifo_dat_rptr[6:0] + 7'h1 : ipp_hfifo_dat_rptr[6:0]);
565
566 assign ipp_hfifo_dat_rptr = lod_hfifo_base_rptr ? cur_pkt_hdr_base_ptr[6:0] :
567 hfifo_dat_rptr[6:0];
568
569 assign hfifo_dat_tag_rd = {2{inc_hfifo_dat_rptr_d}} & ipp_hfifo_dat_tag[1:0];
570 assign n_hfifo_dat_tag_rd = {2{ipp_dfifo_full}} & (hfifo_dat_tag_rd[1:0] | hfifo_dat_tag_rd_d[1:0]);
571 assign ipp_hfifo_dat_tag_rd = hfifo_dat_tag_rd[1:0] | hfifo_dat_tag_rd_d[1:0];
572
573// =============================================================================
574 assign n_addr_wt_pkt = lod_dfifo_base_wptr ? addr_packet[10:0] :
575 inc_ipp_dfifo_wptr ? (addr_wt_pkt[10:0] + 11'h1) :
576 addr_wt_pkt[10:0];
577
578 assign n_addr_packet = wt_dfifo_1st_wd ? (addr_wt_pkt[10:0] + 11'h1) :
579 addr_packet[10:0];
580
581 assign n_addr_status = wt_dfifo_1st_wd ? ({1'b0,addr_wt_pkt[10:0]}) :
582 addr_status[11:0];
583
584 assign ipp_dfifo_wptr = datfifo_pio_wr_ena ?
585 (dfifo_wt_ptr_pio_wr_en ? ipp_pio_wdata[10:0] : ipp_dfifo_wptr_r[10:0]) :
586 wt_dfifo_1st_wd ? addr_status[10:0] :
587 (addr_wt_pkt[10:0]);
588
589 assign n_ipp_dfifo_rptr = datfifo_pio_wr_ena ?
590 (dfifo_rd_ptr_pio_wr_en ? (ipp_pio_wdata[10:0]) : ipp_dfifo_rptr[10:0]) :
591 n_ipp_dmc_dat_ack ? (ipp_dfifo_rptr[10:0] + 11'h1) :
592 ipp_dfifo_rptr[10:0];
593
594 assign ipp_dfifo_rden = ipp_enable || datfifo_pio_wr_ena || reset;
595//assign ipp_dfifo_rden = 1'h1;
596
597 assign ipp_dfifo_wten = datfifo_pio_wr_ena ? dfifo_wt_data_reg_wr_en_pls :
598 ipp_dfifo_wten_pkt;
599
600 assign dfifo_free_space = (addr_wt_pkt[10] == ipp_dfifo_rptr[10]) ?
601 11'd1024 - {1'h0,(addr_wt_pkt[9:0] - ipp_dfifo_rptr[9:0])} :
602 {1'h0,(ipp_dfifo_rptr[9:0] - addr_wt_pkt[9:0])};
603
604 assign ipp_dfifo_amsful = dfifo_free_space <= 11'h1;
605
606 assign ipp_dfifo_full = ipp_dfifo_amsful;
607//assign ipp_dfifo_full = (addr_wt_pkt[10] == !ipp_dfifo_rptr[10]) && // 1k_ent,
608// (addr_wt_pkt[9:0] == ipp_dfifo_rptr[9:0]);// spare?
609
610 assign ipp_dfifo_empty = (addr_wt_pkt[10:0] == ipp_dfifo_rptr[10:0]);
611
612 assign n_ipp_dmc_dat_ack = dmc_ipp_dat_req && !ipp_dfifo_empty &&
613 (!(req_rd_dfifo_eop || req_rd_dfifo_eop_d1 || req_rd_dfifo_eop_d2));
614
615 assign req_rd_dfifo_eop = ipp_dmc_dat_ack_0 && !ipp_dmc_dat_emp_0 &&
616 ipp_dfifo_dout_eop && !ipp_dfifo_dout_eop_d;
617
618 assign req_rd_dfifo_eops = ipp_dmc_dat_ack_0 && !ipp_dmc_dat_emp_0 &&
619 ipp_dfifo_dout_eop;
620
621 assign req_rd_dfifo_sop = ipp_dmc_dat_ack_0 && !ipp_dmc_dat_emp_0 &&
622 ipp_dfifo_dout_sop;
623
624 assign ipp_dmc_dat_ack = ipp_dmc_dat_ack_2;
625 assign ipp_dmc_ful_pkt = ipp_dmc_ful_pkt_2;
626
627// =============================================================================
628 always @(req_rd_dfifo_sop_rise_d or wt_dfifo_1st_wd_d2 or
629 dfifo_pkt_count
630 ) begin
631 case ({req_rd_dfifo_sop_rise_d,wt_dfifo_1st_wd_d2}) //synopsys parallel_case
632 /* 0in < case -default */
633 (2'b11): n_dfifo_pkt_count = dfifo_pkt_count[8:0];
634 (2'b10): n_dfifo_pkt_count = dfifo_pkt_count[8:0] - 9'h1;
635 (2'b01): n_dfifo_pkt_count = dfifo_pkt_count[8:0] + 9'h1;
636 (2'b00): n_dfifo_pkt_count = dfifo_pkt_count[8:0];
637 default: n_dfifo_pkt_count = dfifo_pkt_count[8:0];
638 endcase
639 end
640
641 assign ecc_err_force = ipp_dmc_dat_ack_1 && ipp_dmc_dat_err1 || ecc_err_force_d;
642 assign n_ipp_dmc_ful_pkt = (n_dfifo_pkt_count[7:0]!=8'h0) && !n_dfifo_pkt_count[8];
643 assign n_ipp_dmc_ful_pkt_2 = ipp_dmc_ful_pkt_1 && !ecc_err_force;
644
645// =============================================================================
646 assign ipp_sum_info_vld = inc_hfifo_dat_rptr_d &&
647 ((ipp_la3_vers==2'h1) || (ipp_la3_vers==2'h2));
648
649 assign ipp_full_cksum = ((ipp_la3_vers==2'h1) || (ipp_la3_vers==2'h2)) &&
650 ((ipp_la4_prot==2'h1) || (ipp_la4_prot==2'h2)) ||
651 pio_full_cksum;
652
653 assign no_cksum = (ipp_la3_vers==2'h0) || (ipp_la3_vers==2'h3) ||
654 ((ipp_la3_vers==2'h1) || (ipp_la3_vers==2'h2)) && !fet_pio_tcp_ena ||
655 (ipp_la4_prot==2'h0) || (ipp_la4_prot==2'h3);
656
657 assign n_ipp_cksum_done = (c_unload_st!=`IPP_UNLOAD_IDLE) && (ipp_cksum_done || no_cksum);
658
659 assign ipp_cksum_done = sum_prt_valid || ipp_cksum_done_r;
660
661// =============================================================================
662 always @ (posedge clk)
663 if (reset)
664 begin
665 ipp_ffl_dvalid_n_d <= #1 1'h0;
666 start_unload <= #1 1'h0;
667 inc_hfifo_dat_rptr_d <= #1 1'h0;
668 ipp_cksum_done_r <= #1 1'h0;
669 hfifo_dat_rptr <= #1 7'h0;
670 wt_dfifo_1st_wd_d <= #1 1'h0;
671 wt_dfifo_1st_wd_d2 <= #1 1'h0;
672 ipp_dfifo_wptr_r <= #1 11'h0;
673 addr_wt_pkt <= #1 11'h1;
674 addr_status <= #1 12'h0;
675 addr_packet <= #1 11'h1;
676 ipp_dfifo_dout_eop_d <= #1 1'h0;
677 ipp_dfifo_rptr <= #1 11'h0;
678 dfifo_pkt_count <= #1 9'h0;
679 dfifo_miss_eop <= #1 1'h0;
680 dfifo_miss_sop <= #1 1'h0;
681 bad_tag_mac_sta <= #1 1'h0;
682 hfifo_dat_tag_rd_d <= #1 2'h0;
683 clr_ipp_unload <= #1 1'h0;
684 c_unload_st <= #1 5'h0;
685 c_dfifo_tag_st <= #1 2'h0;
686 end
687 else
688 begin
689 ipp_ffl_dvalid_n_d <= #1 ipp_ffl_dvalid_n;
690 start_unload <= #1 start_unload_n;
691 inc_hfifo_dat_rptr_d <= #1 inc_hfifo_dat_rptr;
692 ipp_cksum_done_r <= #1 n_ipp_cksum_done;
693 hfifo_dat_rptr <= #1 n_hfifo_dat_rptr[6:0];
694 wt_dfifo_1st_wd_d <= #1 wt_dfifo_1st_wd;
695 wt_dfifo_1st_wd_d2 <= #1 wt_dfifo_1st_wd_d;
696 ipp_dfifo_wptr_r <= #1 ipp_dfifo_wptr[10:0];
697 addr_wt_pkt <= #1 n_addr_wt_pkt[10:0];
698 addr_status <= #1 n_addr_status[11:0];
699 addr_packet <= #1 n_addr_packet[10:0];
700 ipp_dfifo_dout_eop_d <= #1 ipp_dfifo_dout_eop; // geo: correct?;
701 ipp_dfifo_rptr <= #1 n_ipp_dfifo_rptr[10:0];
702 dfifo_pkt_count <= #1 n_dfifo_pkt_count[8:0];
703 dfifo_miss_eop <= #1 (n_dfifo_miss_eop || bad_tag_mac_sta);
704 dfifo_miss_sop <= #1 (n_dfifo_miss_sop || bad_tag_mac_sta);
705 bad_tag_mac_sta <= #1 n_bad_tag_mac_sta;
706 hfifo_dat_tag_rd_d <= #1 n_hfifo_dat_tag_rd[1:0];
707 clr_ipp_unload <= #1 n_clr_ipp_unload;
708 c_unload_st <= #1 n_unload_st[4:0];
709 c_dfifo_tag_st <= #1 n_dfifo_tag_st[1:0];
710 end
711
712 ipp_reg_r_1 reg_r_1_ack0 (.di(n_ipp_dmc_dat_ack), .rs(reset), .ck(clk), .qo(ipp_dmc_dat_ack_0));
713 ipp_reg_r_1 reg_r_1_ack1 (.di(ipp_dmc_dat_ack_0), .rs(reset), .ck(clk), .qo(ipp_dmc_dat_ack_1));
714 ipp_reg_r_1 reg_r_1_ack2 (.di(ipp_dmc_dat_ack_1), .rs(reset), .ck(clk), .qo(ipp_dmc_dat_ack_2));
715
716 ipp_reg_r_1 reg_r_1_ful1 (.di(n_ipp_dmc_ful_pkt), .rs(reset), .ck(clk), .qo(ipp_dmc_ful_pkt_1));
717 ipp_reg_r_1 reg_r_1_ful2 (.di(n_ipp_dmc_ful_pkt_2), .rs(reset), .ck(clk), .qo(ipp_dmc_ful_pkt_2));
718
719 ipp_reg_r_1 reg_r_1_emp0 (.di(ipp_dfifo_empty), .rs(reset), .ck(clk), .qo(ipp_dmc_dat_emp_0));
720
721 ipp_reg_r_1 reg_r_1_sop (.di(req_rd_dfifo_sop), .rs(reset), .ck(clk), .qo(req_rd_dfifo_sop_d));
722 ipp_reg_r_1 reg_r_1_eop_d1 (.di(req_rd_dfifo_eop), .rs(reset), .ck(clk), .qo(req_rd_dfifo_eop_d1));
723 ipp_reg_r_1 reg_r_1_eop_d2 (.di(req_rd_dfifo_eop_d1), .rs(reset), .ck(clk), .qo(req_rd_dfifo_eop_d2));
724
725 ipp_reg_r_1 reg_r_1_sop_d (.di(req_rd_dfifo_sop_rise), .rs(reset), .ck(clk), .qo(req_rd_dfifo_sop_rise_d));
726
727 ipp_reg_r_1 reg_r_1_sum_en (.di(n_fet_pio_tcp_ena), .rs(reset), .ck(clk), .qo(fet_pio_tcp_ena));
728
729 ipp_reg_r_1 reg_r_1_ecc_fu (.di(ecc_err_force), .rs(reset), .ck(clk), .qo(ecc_err_force_d));
730
731`ifdef NEPTUNE
732wire [3:0] do_nad;
733wire [3:0] do_nor;
734wire [3:0] do_inv;
735wire [3:0] do_mux;
736wire [3:0] do_q;
737wire so;
738
739 nep_spare_ipp spare_ipp_0 (
740 .di_nd3 ({1'h1, 1'h1, do_q[3]}),
741 .di_nd2 ({1'h1, 1'h1, do_q[2]}),
742 .di_nd1 ({1'h1, 1'h1, do_q[1]}),
743 .di_nd0 ({1'h1, 1'h1, do_q[0]}),
744 .di_nr3 ({1'h0, 1'h0}),
745 .di_nr2 ({1'h0, 1'h0}),
746 .di_nr1 ({1'h0, 1'h0}),
747 .di_nr0 ({1'h0, 1'h0}),
748 .di_inv (do_nad[3:0]),
749 .di_mx3 ({1'h0, 1'h0}),
750 .di_mx2 ({1'h0, 1'h0}),
751 .di_mx1 ({1'h0, 1'h0}),
752 .di_mx0 ({1'h0, 1'h0}),
753 .mx_sel (do_nor[3:0]),
754 .di_reg (do_inv[3:0]),
755 .wt_ena (do_mux[3:0]),
756 .rst ({reset,reset,reset,reset}),
757 .si (1'h0),
758 .se (1'h0),
759 .clk (clk),
760 .do_nad (do_nad[3:0]),
761 .do_nor (do_nor[3:0]),
762 .do_inv (do_inv[3:0]),
763 .do_mux (do_mux[3:0]),
764 .do_q (do_q[3:0]),
765 .so (so)
766 );
767`endif
768
769endmodule //
770
771