Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_cmu_tcm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_cmu_tcm.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 ============================================
35module dmu_cmu_tcm (
36 clk,
37 rst_l,
38
39 // Debug
40 dbg2tcm_dbg_sel_a,
41 dbg2tcm_dbg_sel_b,
42 tcm2dbg_dbg_a,
43 tcm2dbg_dbg_b,
44
45 // CLU
46 cl2cm_rcd_enq,
47 cl2cm_rcd,
48 cm2cl_rcd_full,
49
50 // RMU
51 cm2rm_rcd_enq,
52 cm2rm_rcd,
53 rm2cm_rcd_full,
54
55 // CTX
56 tcm2ctx_ctx_addr,
57 tcm2ctx_ctx_rw,
58 ctx2tcm_cur_ctx,
59 tcm2ctx_ctx,
60 tcm2ctx_pkseq_addr,
61 tcm2ctx_pkseq_rw,
62 ctx2tcm_cur_pkseq,
63 tcm2ctx_pkseq,
64 tcm2ctx_lst_req,
65 ctx2tcm_lst_gnt,
66 ctx2tcm_nxlst_addr,
67 tcm2ctx_ctxlst_addr,
68 tcm2ctx_clst_rw,
69 tcm2ctx_lst,
70 ctx2tcm_cur_lst,
71 tcm2ctx_ret_req,
72 tcm2ctx_ret_addr
73 );
74
75//************************************************
76// PARAMETERS
77//************************************************
78
79// Egress Packet Record Field Widths
80// parameter CL2CM_WDTH = `FIRE_DLC_EPR_REC_WDTH; //80
81
82 parameter EPRMSB = `FIRE_DLC_EPR_MSB; // CL2CM_WDTH -1
83
84 parameter PRTYP_WDTH = `FIRE_DLC_EPR_TYP_WDTH, // 6
85 PRLEN_WDTH = `FIRE_DLC_EPR_LEN_WDTH, //10
86 PRDWBE_WDTH = `FIRE_DLC_EPR_DWBE_WDTH, // 8
87 PRADDR_WDTH = `FIRE_DLC_EPR_ADDR_WDTH, //34
88 PRSBDTAG_WDTH = `FIRE_DLC_EPR_SBDTAG_WDTH, // 5
89 PRDPTR_WDTH = `FIRE_DLC_EPR_DPTR_WDTH, // 6
90 PRPKSEQNUM_WDTH = `FIRE_DLC_EPR_PKSEQNUM_WDTH, // 5
91 PRCNTXTNUM_WDTH = `FIRE_DLC_EPR_CNTXTNUM_WDTH; // 5
92
93 parameter PRTYPMSB = PRTYP_WDTH -1,
94 PRLENMSB = PRLEN_WDTH -1,
95 PRDWBEMSB = PRDWBE_WDTH -1,
96 PRADDRMSB = PRADDR_WDTH -1,
97 PRSBDTAGMSB = PRSBDTAG_WDTH -1,
98 PRDPTRMSB = PRDPTR_WDTH -1,
99 PRPKSEQNUMMSB = PRPKSEQNUM_WDTH -1,
100 PRCNTXTNUMMSB = PRCNTXTNUM_WDTH -1;
101
102
103// Egress Retire Record Field Widths
104// parameter CM2RM_WDTH = `FIRE_DLC_ERR_REC_WDTH; //70
105
106 parameter RRMSB = `FIRE_DLC_ERR_MSB; // CM2RM_WDTH -1
107
108 parameter RRTYP_WDTH = `FIRE_DLC_ERR_TYP_WDTH, // 7
109 RRLEN_WDTH = `FIRE_DLC_ERR_LEN_WDTH, //10
110 RRFDWBE_WDTH = `FIRE_DLC_ERR_FDWBE_WDTH, // 4
111 RRLDWBE_WDTH = `FIRE_DLC_ERR_LDWBE_WDTH, // 4
112 RRADDR_WDTH = `FIRE_DLC_ERR_ADDR_WDTH, //34
113 RRSBDTAG_WDTH = `FIRE_DLC_ERR_SBDTAG_WDTH, // 5
114 RRDPTR_WDTH = `FIRE_DLC_ERR_DPTR_WDTH; // 6
115
116 parameter RRTYPMSB = RRTYP_WDTH -1,
117 RRLENMSB = RRLEN_WDTH -1,
118 RRDWBEMSB = RRFDWBE_WDTH + RRLDWBE_WDTH -1,
119 RRADDRMSB = RRADDR_WDTH -1,
120 RRSBDTAGMSB = RRSBDTAG_WDTH -1,
121 RRDPTRMSB = RRDPTR_WDTH -1;
122
123// CTX
124// parameter CTXARRAY_WDTH = 43, // Context CTX entry width
125 parameter CTXARRAY_WDTH = 44, // Context CTX entry width
126 CTXARRAYMSB = CTXARRAY_WDTH -1,
127 CTXADDRLSB = 0,
128 CTXADDR_WDTH = 5,
129 CTXADDRMSB = CTXADDRLSB + CTXADDR_WDTH -1;
130
131 parameter ORDERBITLSB = 0, //0
132 ORDERBIT_WDTH = 32,
133 ORDERBITMSB = ORDERBITLSB + ORDERBIT_WDTH -1, //31
134 ERRLSB = ORDERBITLSB + ORDERBIT_WDTH,
135 ERR_WDTH = 1, //32
136 PSEQLSB = ERRLSB + ERR_WDTH,
137 PSEQ_WDTH = 5,
138 PSEQMSB = PSEQLSB + PSEQ_WDTH -1, //37
139 PKTOTLSB = PSEQLSB + PSEQ_WDTH,
140 PKTOT_WDTH = 6,
141 PKTOTMSB = PKTOTLSB + PKTOT_WDTH -1; //42
142
143// PKSEQ
144 parameter PSEQARRAY_WDTH = 5, // Context PKSEQ entry width
145 PSEQARRAYMSB = PSEQARRAY_WDTH -1,
146 PSEQADDRLSB = 0,
147 PSEQADDR_WDTH = 5,
148 PSEQADDRMSB = PSEQADDRLSB + PSEQADDR_WDTH -1;
149
150 parameter PTRCLSTLSB = 0, //0
151 PTRCLST_WDTH = 4,
152 PTRCLSTMSB = PTRCLSTLSB + PTRCLST_WDTH -1, //3
153 CBITLSB = PTRCLSTLSB + PTRCLST_WDTH,
154 CBIT_WDTH = 1,
155 CBITMSB = CBITLSB + CBIT_WDTH -1; //4
156
157// CLST
158 parameter CLSTARRAY_WDTH = 54, // Context CLST entry width
159 CLSTARRAYMSB = CLSTARRAY_WDTH -1,
160 CLSTADDRLSB = 0,
161 CLSTADDR_WDTH = 4,
162 CLSTADDRMSB = CLSTADDRLSB + CLSTADDR_WDTH -1;
163
164 parameter CPKSEQLSB = 0,
165 CPKSEQ_WDTH = 5,
166 CPKSEQMSB = CPKSEQLSB + CPKSEQ_WDTH -1,
167 CDPTRLSB = CPKSEQLSB + CPKSEQ_WDTH,
168 CDPTR_WDTH = 6,
169 CDPTRMSB = CDPTRLSB + CDPTR_WDTH -1,
170 CSBDTAGLSB = CDPTRLSB + CDPTR_WDTH,
171 CSBDTAG_WDTH = 5,
172 CSBDTAGMSB = CSBDTAGLSB + CSBDTAG_WDTH -1,
173 CADDRLSB = CSBDTAGLSB + CSBDTAG_WDTH,
174 CADDR_WDTH = 12,
175 CADDRMSB = CADDRLSB + CADDR_WDTH -1,
176 CDWBELSB = CADDRLSB + CADDR_WDTH,
177 CDWBE_WDTH = 8,
178 CDWBEMSB = CDWBELSB + CDWBE_WDTH -1,
179 CLSTPKTLSB = CDWBELSB + CDWBE_WDTH,
180 CLSTPKT_WDTH = 1,
181 CLSTPKTMSB = CLSTPKTLSB + CLSTPKT_WDTH -1,
182 CLENLSB = CLSTPKTLSB + CLSTPKT_WDTH,
183 CLEN_WDTH = 10,
184 CLENMSB = CLENLSB + CLEN_WDTH -1,
185 CTYPLSB = CLENLSB + CLEN_WDTH,
186 CTYP_WDTH = 7,
187 CTYPMSB = CTYPLSB + CTYP_WDTH -1;
188
189 parameter RETADDRARRAY_WDTH = 17,
190 RETADDRMSB = RETADDRARRAY_WDTH -1;
191
192//************************************************
193// PORTS
194//************************************************
195
196 input clk; // The input clock
197 input rst_l; // synopsys sync_set_reset "rst_l"
198
199// TCM
200 input cl2cm_rcd_enq;
201 input [EPRMSB : 0] cl2cm_rcd;
202 output cm2cl_rcd_full;
203
204 output cm2rm_rcd_enq;
205 output [RRMSB : 0] cm2rm_rcd;
206 input rm2cm_rcd_full;
207
208 output [CTXADDRMSB :0] tcm2ctx_ctx_addr;
209 output tcm2ctx_ctx_rw;
210 input [CTXARRAYMSB : 0] ctx2tcm_cur_ctx;
211 output [CTXARRAYMSB : 0] tcm2ctx_ctx;
212
213 output [PSEQADDRMSB :0] tcm2ctx_pkseq_addr;
214 output tcm2ctx_pkseq_rw;
215 input [PSEQARRAYMSB : 0] ctx2tcm_cur_pkseq;
216 output [PSEQARRAYMSB : 0] tcm2ctx_pkseq;
217
218 output tcm2ctx_lst_req;
219 input ctx2tcm_lst_gnt;
220 input [CLSTADDRMSB :0] ctx2tcm_nxlst_addr;
221
222 output [CLSTADDRMSB :0] tcm2ctx_ctxlst_addr;
223 output tcm2ctx_clst_rw;
224 output [CLSTARRAYMSB : 0] tcm2ctx_lst;
225 input [CLSTARRAYMSB : 0] ctx2tcm_cur_lst;
226
227 output tcm2ctx_ret_req;
228 output [RETADDRMSB :0] tcm2ctx_ret_addr;
229
230// Debug
231 input [`FIRE_DLC_CMU_TCM_DS_BITS] dbg2tcm_dbg_sel_a;
232 input [`FIRE_DLC_CMU_TCM_DS_BITS] dbg2tcm_dbg_sel_b;
233 output [`FIRE_DBG_DATA_BITS] tcm2dbg_dbg_a;
234 output [`FIRE_DBG_DATA_BITS] tcm2dbg_dbg_b;
235
236
237//************************************************
238// SIGNALS
239//************************************************
240
241 wire clk;
242 wire rst_l;
243
244// Packet Record queue signals
245 wire pkmpty;
246
247// for use with debuig ports
248// wire overflow;
249// wire underflow;
250
251// Packet Record field assignments to TCM signals
252 wire [PRTYPMSB :0] pkttyp;
253 wire [PRLENMSB :0] pktlen;
254 wire [PRDWBEMSB :0] pktdwbe;
255 wire [PRADDRMSB :0] pktaddr;
256 wire [PRSBDTAGMSB :0] pkttr_tag;
257 wire [PRDPTRMSB :0] pktdptr;
258 wire [PRPKSEQNUMMSB :0] pktseq_num;
259 wire [PRCNTXTNUMMSB :0] pktcntxt_num;
260 wire [2 :0] pkt_clsts;
261
262//TCM - CTX
263 reg [CTXADDRMSB :0] tcm2ctx_ctx_addr_hld;
264 reg tcm2ctx_ctx_rw;
265 wire [CTXARRAYMSB : 0] ctx2tcm_cur_ctx;
266
267 reg [CTXARRAYMSB : 0] tcm_cur_ctx;
268 reg [CTXARRAYMSB : 0] tcm2ctx_ctx;
269
270 reg [PSEQADDRMSB :0] tcm2ctx_pkseq_addr;
271 reg tcm2ctx_pkseq_rw;
272 wire [PSEQARRAYMSB : 0] ctx2tcm_cur_pkseq;
273 reg [PSEQARRAYMSB : 0] tcm2ctx_pkseq;
274 reg tcm2ctx_lst_req;
275 wire ctx2tcm_lst_gnt;
276 wire [CLSTADDRMSB :0] ctx2tcm_nxlst_addr;
277
278 reg [CLSTADDRMSB :0] tcm2ctx_ctxlst_addr;
279 reg tcm2ctx_clst_rw;
280 reg [CLSTARRAYMSB : 0] tcm2ctx_lst;
281 wire [CLSTARRAYMSB : 0] ctx2tcm_cur_lst;
282 wire [CPKSEQMSB :0] scan_pkseq_num;
283
284 reg tcm2ctx_ret_req;
285 reg [RETADDRMSB :0] tcm2ctx_ret_addr;
286
287 wire [ORDERBITMSB :0] ctx_order_bits;
288 wire [ORDERBITMSB :0] new_order_bits;
289
290 reg cpl;
291 wire last_pkt;
292 wire pipe_mpty;
293
294 reg last_in_pkt;
295 reg last_scan_pkt;
296
297// Registers
298// Retire Record field assignments
299 reg [RRTYPMSB :0] rrtyp;
300 reg [RRLENMSB :0] rrlen;
301 reg [RRDWBEMSB :0] rrdwbe;
302 reg [RRADDRMSB :0] rraddr;
303 reg [RRSBDTAGMSB :0] rrsbdtag;
304 reg [RRDPTRMSB :0] rrdptr;
305
306 reg [RRTYPMSB :0] next_rrtyp;
307 reg [RRLENMSB :0] next_rrlen;
308 reg [RRDWBEMSB :0] next_rrdwbe;
309 reg [RRADDRMSB :0] next_rraddr;
310 reg [RRSBDTAGMSB :0] next_rrsbdtag;
311 reg [RRDPTRMSB :0] next_rrdptr;
312 reg [PRPKSEQNUMMSB :0] next_pktseq_num;
313 reg [PRCNTXTNUMMSB :0] next_pktcntxt_num;
314
315 reg [RRTYPMSB :0] pipe_rrtyp;
316 reg [RRLENMSB :0] pipe_rrlen;
317 reg [RRDWBEMSB :0] pipe_rrdwbe;
318 reg [RRADDRMSB :0] pipe_rraddr;
319 reg [RRSBDTAGMSB :0] pipe_rrsbdtag;
320 reg [RRDPTRMSB :0] pipe_rrdptr;
321 reg [PRPKSEQNUMMSB :0] pipe_pktseq_num;
322 reg [PRCNTXTNUMMSB :0] pipe_pktcntxt_num;
323 reg [2 :0] pipe_clastyp;
324
325 reg ctx_sel;
326 reg pkseq_sel;
327 reg clst_sel;
328
329 reg [CTXADDRMSB :0] ctx_relrcd;
330 reg [PSEQADDRMSB :0] pkseq_relrcd;
331 reg [CLSTADDRMSB :0] clst_relrcd;
332
333 reg [1:0] deq_state;
334 reg [1:0] deq_next;
335
336 reg [2:0] ctx_state;
337 reg [2:0] ctx_next;
338
339 reg [1:0] lst_state;
340 reg [1:0] lst_next;
341
342 reg [2:0] bld_state;
343 reg [2:0] bld_next;
344
345 reg next_rcd_enq;
346 reg [2 :0] next_clastyp;
347
348 reg xfr_strt;
349 reg frwd_pkt;
350 reg store_pkt;
351 reg next_lst_req;
352 reg do_lst;
353 reg do_pkseq;
354 reg do_ctx;
355 reg do_next_pkt;
356 reg do_next_lst;
357 reg next_ctx_addr;
358 reg stop_scan;
359 reg look_up;
360 reg scan_mode;
361 reg ld_pipe;
362 reg pipe_full;
363
364 reg cm2rm_rcd_enq;
365 reg next_deq_pipe;
366 reg next_deq_pkr;
367 reg next_gen_pkt;
368 reg next_pkvld;
369 reg hld_pkvld;
370 wire pkvld;
371 reg clear_pkvld;
372
373 reg next_clist_put;
374 reg next_ctx_ck;
375 reg ctx_ck;
376
377 reg [ORDERBITMSB :0] upd_order_bits;
378 reg [ORDERBITMSB :0] scan_order_bits;
379
380 reg tcm_is_idle;
381
382// Debug
383 reg [`FIRE_DLC_CMU_TCM_DS_BITS] dbg_sel [0:1];
384 reg [`FIRE_DBG_DATA_BITS] dbg_bus [0:1];
385 reg [`FIRE_DBG_DATA_BITS] nxt_dbg_bus [0:1];
386 integer i, k;
387
388// *************** Local Declarations *************************************
389
390 parameter DEQIDLE = 2'b00, // Idle
391 DEQ = 2'b01; // dequeue next packets
392
393 parameter CTXIDLE = 3'b000, // Context Scanner is IDLE
394 CTXSEQ = 3'b001, // look up packet sequence
395 CTXCHK = 3'b010, // check packet against context
396 CTXDIS = 3'b011, // dispatch (store,send)
397 CTXNXT = 3'b100; // look up next packet sequence
398
399 parameter LSTIDLE = 2'b00, // Packet Sequence Put Idle
400 LSTGNT = 2'b01, // Packet Sequence Put has CLIST address
401 LSTUPD = 2'b10; // write PSEQ at CLIST entry address,
402 // write PSEQ entry
403 parameter BLDIDLE = 3'b000, // Build Context Idle
404 BLDCNTX = 3'b010, // Context ops in progress
405 BLDBPAS = 3'b011; // NO context ops needed
406
407 parameter CLASCP = 3'b001,
408 CLASCPD = 3'b010,
409 CLASPIO = 3'b011,
410 CLASMDO = 3'b100,
411 CLASUSP = 3'b101;
412
413//************************************************
414// Zero In checkers
415//************************************************
416// deq_fsm
417 //0in state_transition -var deq_state -val DEQIDLE -next DEQIDLE DEQ
418 //0in state_transition -var deq_state -val DEQ -next DEQIDLE
419
420// ctx_fsm
421 //0in state_transition -var ctx_state -val CTXIDLE -next CTXIDLE CTXSEQ
422 //0in state_transition -var ctx_state -val CTXSEQ -next CTXCHK CTXIDLE
423 //0in state_transition -var ctx_state -val CTXCHK -next CTXIDLE CTXDIS
424 //0in state_transition -var ctx_state -val CTXDIS -next CTXNXT CTXIDLE CTXDIS CTXSEQ
425 //0in state_transition -var ctx_state -val CTXNXT -next CTXSEQ
426
427// lst_fsm
428 //0in state_transition -var lst_state -val LSTIDLE -next LSTIDLE LSTGNT
429 //0in state_transition -var lst_state -val LSTGNT -next LSTGNT LSTUPD
430 //0in state_transition -var lst_state -val LSTUPD -next LSTIDLE
431
432// build_crcd (pipeline staging and command record build)
433 //0in state_transition -var bld_state -val BLDIDLE -next BLDIDLE BLDBPAS BLDCNTX
434 //0in state_transition -var bld_state -val BLDCNTX -next BLDCNTX BLDIDLE
435 //0in state_transition -var bld_state -val BLDBPAS -next BLDBPAS BLDIDLE
436
437// ********** Parse Packet Record Procedures (parse_rcd)*********/
438
439// Transaction Type Decode - Context Function Encoding(typ_dcd)
440always @(pkttyp or pkt_clsts)
441 begin
442 next_clastyp = 0;
443
444 case(pkttyp) // synopsys parallel_case
445 7'b0000000, // PIO MRd
446 7'b0100000, // PIO MRd
447 7'b0000010, // PIO IO Rd
448 7'b0000100, // PIO Cfg Rd 0
449 7'b0000101, // PIO Cfg RD 1
450 7'b1000000, // PIO MWr
451 7'b1100000, // PIO MWr
452 7'b1000010, // PIO IO Wr
453 7'b1000100, // PIO Cfg Wr 0
454 7'b1000101 : next_clastyp = CLASPIO; // PIO Cfg Wr 1
455
456 7'b1111010 : next_clastyp = CLASMDO; // Mondo Rpy
457
458 7'b0001010, // DMA Cpl
459 7'b0001011 : begin
460 case (pkt_clsts) // synopsys parallel_case
461 3'b001 : next_clastyp = CLASUSP; // DMA CPLk,Unsup Cpl
462 default : next_clastyp = CLASCP;
463 endcase // case(pkt_clsts)
464 end
465
466 7'b1001010 : next_clastyp = CLASCPD; // DMA CP D
467 default : next_clastyp = 3'b111; // to satisfy vlint
468 endcase // case(pkttyp)
469 end // always @ (pkttyp)
470
471
472// Context Check
473always @( rst_l or ctx_order_bits or pipe_pktseq_num or pipe_clastyp
474 or ctx_ck)
475 if(rst_l == 1'b0) begin
476 store_pkt = 1'b0;
477 frwd_pkt = 1'b0;
478 end
479 else begin
480 case({pipe_clastyp,ctx_ck}) // synopsys parallel_case
481 {CLASCP , 1'b1},
482 {CLASCPD, 1'b1} : begin
483 if(pipe_pktseq_num == 0) begin
484 store_pkt = 1'b0;
485 frwd_pkt = 1'b1;
486 end
487 else begin
488 if ((ctx_order_bits[pipe_pktseq_num] == 1'b1)
489 && (ctx_order_bits[pipe_pktseq_num - 1'b1] == 1'b0)) begin
490 store_pkt = 1'b0;
491 frwd_pkt = 1'b1;
492 end
493 else begin
494 store_pkt = 1'b1;
495 frwd_pkt = 1'b0;
496 end
497 end // else: !if(pipe_pktseq_num == 0)
498 end // case: 1'b1
499 default : begin
500 store_pkt = 1'b0;
501 frwd_pkt = 1'b0;
502 end
503 endcase // case(ctx_ck)
504 end // else: !if(rst_l == 1'b0)
505
506
507// Order Bit updates
508always @(pipe_pktseq_num)
509 begin
510 upd_order_bits = {32{1'b1}};
511 upd_order_bits[pipe_pktseq_num] = 1'b0;
512 end
513
514always @(scan_pkseq_num)
515 begin
516 scan_order_bits = {32{1'b1}};
517 scan_order_bits[scan_pkseq_num] = 1'b0;
518 end
519
520
521// Parse Packet Record to issue Retire Records or Context ops
522// pipelined next retire record staging
523
524always @(next_clastyp or pkttyp or pktlen or pktdwbe or pktaddr or
525 pkttr_tag or pktdptr or pktseq_num or pktcntxt_num)
526 begin
527 next_rrtyp = 0;
528 next_rrlen = 0;
529 next_rrdwbe = 0;
530 next_rraddr = 0;
531 next_rrsbdtag = 0;
532 next_rrdptr = 0;
533 next_pktseq_num = 0;
534 next_pktcntxt_num = 0;
535
536 case(next_clastyp) // synopsys full_case parallel_case
537
538 CLASPIO: begin // All PIO's
539 next_rrtyp = pkttyp[PRTYPMSB :0];
540 next_rrlen = pktlen[PRLENMSB :0];
541 next_rrdwbe = pktdwbe[PRDWBEMSB :0];
542 next_rraddr = pktaddr[PRADDRMSB :0];
543 next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
544 next_rrdptr = pktdptr[PRDPTRMSB :0];
545 next_pktseq_num = 0;
546 next_pktcntxt_num = 0;
547 end
548
549 CLASMDO : begin // Mondo Rpy
550 next_rrtyp = pkttyp[PRTYPMSB :0];
551 next_rrlen = pktlen[PRLENMSB :0];
552 next_rrdwbe = pktdwbe[PRDWBEMSB :0];
553 next_rraddr = pktaddr[PRADDRMSB :0];
554 next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
555 next_rrdptr = pktdptr[PRDPTRMSB :0];
556 next_pktseq_num = 0;
557 next_pktcntxt_num = 0;
558 end
559
560 CLASCP, // DMA CP
561 CLASCPD : begin // DMA CP D
562 next_rrtyp = pkttyp[PRTYPMSB :0];
563 next_rrlen = pktlen[PRLENMSB :0];
564 next_rrdwbe = pktdwbe[PRDWBEMSB :0];
565 next_rraddr = pktaddr[PRADDRMSB :0];
566 next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
567 next_rrdptr = pktdptr[PRDPTRMSB :0];
568 next_pktseq_num = pktseq_num[PRPKSEQNUMMSB :0];
569 next_pktcntxt_num = pktcntxt_num[PRCNTXTNUMMSB :0];
570 end
571
572 CLASUSP : begin // Unsup CP
573 next_rrtyp = pkttyp[PRTYPMSB :0];
574 next_rrlen = pktlen[PRLENMSB :0];
575 next_rrdwbe = {pktdwbe[PRDWBEMSB :5],1'b1,pktdwbe[3 :0]};
576 next_rraddr = pktaddr[PRADDRMSB :0];
577 next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
578 next_rrdptr = pktdptr[PRDPTRMSB :0];
579 next_pktseq_num = pktseq_num[PRPKSEQNUMMSB :0];
580 next_pktcntxt_num = pktcntxt_num[PRCNTXTNUMMSB :0];
581 end
582
583 default begin
584 next_rrtyp = 0;
585 next_rrlen = 0;
586 next_rrdwbe = 0;
587 next_rraddr = 0;
588 next_rrsbdtag = 0;
589 next_rrdptr = 0;
590 next_pktseq_num = 0;
591 next_pktcntxt_num = 0;
592 end
593 endcase // case(next_clastyp)
594 end // always @ (next_clastyp or pkttyp or pktlen or pktdwbe or pktaddr or...
595
596// Class Type pipeline stage
597always @(posedge clk)
598 begin
599 if (rst_l == 1'b0) begin
600 scan_mode <= 0;
601 end
602 else begin
603 scan_mode <= look_up ? 1'b1 : (~stop_scan & scan_mode);
604 end
605 end
606
607always @(posedge clk)
608 if(~rst_l) begin
609 pipe_rrtyp <= {RRTYP_WDTH{1'b0}};
610 pipe_rrlen <= {RRLEN_WDTH{1'b0}};
611 pipe_rrdwbe <= {RRFDWBE_WDTH + RRLDWBE_WDTH{1'b0}};
612 pipe_rraddr <= {RRADDR_WDTH{1'b0}};
613 pipe_rrsbdtag <= {RRSBDTAG_WDTH{1'b0}};
614 pipe_rrdptr <= {RRDPTR_WDTH{1'b0}};
615 pipe_pktseq_num <= {PRPKSEQNUM_WDTH{1'b0}};
616 pipe_pktcntxt_num <= {PRCNTXTNUM_WDTH{1'b0}};
617 pipe_clastyp <= {3{1'b0}};
618 end
619 else begin
620 pipe_rrtyp <= ld_pipe ? next_rrtyp : pipe_rrtyp;
621 pipe_rrlen <= ld_pipe ? next_rrlen : pipe_rrlen;
622 pipe_rrdwbe <= ld_pipe ? next_rrdwbe : pipe_rrdwbe;
623 pipe_rraddr <= ld_pipe ? next_rraddr : pipe_rraddr;
624 pipe_rrsbdtag <= ld_pipe ? next_rrsbdtag : pipe_rrsbdtag;
625 pipe_rrdptr <= ld_pipe ? next_rrdptr : pipe_rrdptr;
626 pipe_pktseq_num <= ld_pipe ? next_pktseq_num : pipe_pktseq_num;
627 pipe_pktcntxt_num <= ld_pipe ? next_pktcntxt_num : pipe_pktcntxt_num;
628 pipe_clastyp <= ld_pipe ? next_clastyp : pipe_clastyp;
629 end // always @ (posedge clk)
630
631// Record Dequeue
632// State machine
633
634// DEQ next state
635always @(deq_state or pkmpty or pipe_full or rm2cm_rcd_full)
636 begin
637 case(deq_state) // synopsys parallel_case
638 DEQIDLE : begin
639 case(pkmpty) // synopsys full_case parallel_case
640 1'b1: deq_next = DEQIDLE;
641 1'b0: begin
642 case(pipe_full | rm2cm_rcd_full) // synopsys full_case parallel_case
643 1'b1 : deq_next = DEQIDLE;
644 1'b0 : deq_next = DEQ;
645 endcase // case(pipe_full | rm2cm_rcd_full)
646 end
647 endcase // case(pkmpty)
648 end // case: DEQIDLE
649
650 DEQ : begin
651 deq_next = DEQIDLE;
652 end // case: DEQ
653
654 default : deq_next = DEQIDLE;
655
656 endcase // case(deq_state)
657 end // always @ (deq_state or pkmpty or pipe_full)
658
659// DEQ state machine outputs
660always @(deq_state or pipe_full or pkmpty or next_clastyp or
661 rm2cm_rcd_full)
662 begin
663 case(deq_state) // synopsys parallel_case
664 DEQIDLE : begin
665 case(pkmpty) // synopsys full_case parallel_case
666 1'b1: begin
667 ld_pipe = 1'b0;
668 next_pkvld = 1'b0;
669 next_deq_pkr = 1'b0;
670 end
671 1'b0: begin
672 next_deq_pkr = 1'b0;
673 case(pipe_full | rm2cm_rcd_full) // synopsys full_case parallel_case
674 1'b1 : begin
675 ld_pipe = 1'b0;
676 next_pkvld = 1'b0;
677 end
678 1'b0 : begin
679 ld_pipe = 1'b1;
680 case(next_clastyp) // synopsys parallel_case
681 CLASUSP,
682 CLASPIO,
683 CLASMDO : next_pkvld = 1'b0;
684 CLASCP ,
685 CLASCPD : next_pkvld = 1'b1;
686 default : next_pkvld = 1'b0;
687 endcase // case(next_clastyp)
688 end
689 endcase // case(pipe_full | rm2cm_rcd_full)
690 end // case: 1'b0
691 endcase // case(pkmpty)
692 end // case: DEQIDLE
693
694 DEQ : begin
695 ld_pipe = 1'b0;
696 next_pkvld = 1'b0;
697 next_deq_pkr = 1'b1;
698 end
699
700 default: begin
701 next_deq_pkr = 1'b0;
702 ld_pipe = 1'b0;
703 next_pkvld = 1'b0;
704 end
705
706 endcase // case(deq_state)
707 end // always @ (deq_state or pipe_full or next_clastyp)
708
709// DEQ state transitions
710always @(posedge clk)
711 begin
712 if (rst_l == 1'b0)
713 deq_state <= DEQIDLE; // Synchronous Reset
714 else begin
715 deq_state <= deq_next;
716 end
717 end
718
719// Context look-up (ctx_upd fsm)
720always @(ctx_state or pkvld or store_pkt or frwd_pkt or last_in_pkt
721 or last_scan_pkt or cpl or do_pkseq or scan_mode or
722 rm2cm_rcd_full)
723 begin
724 case(ctx_state) // synopsys parallel_case
725 CTXIDLE : begin
726 case(pkvld) // synopsys full_case parallel_case
727 1'b0: ctx_next = CTXIDLE;
728 1'b1: ctx_next = CTXSEQ;
729 endcase // case(pkvld)
730 end // case: CTXIDLE
731
732 CTXSEQ : begin
733 case(scan_mode) // synopsys full_case parallel_case
734 1'b1 : begin
735 if(last_scan_pkt) ctx_next = CTXIDLE;
736 else ctx_next = CTXCHK;
737 end // case: 1'b1
738 1'b0 : ctx_next = CTXCHK;
739 endcase // case(scan_mode)
740 end // case: CTXSEQ
741
742 CTXCHK : begin
743 case(rm2cm_rcd_full) // synopsys full_case parallel_case
744 1'b1 : ctx_next = CTXCHK;
745 1'b0 : ctx_next = CTXDIS;
746 endcase // case(rm2cm_rcd_full)
747 end // case: CTXCHK
748
749 CTXDIS : begin
750 case(scan_mode) // synopsys full_case parallel_case
751 1'b0 : begin
752 case({store_pkt,frwd_pkt}) // synopsys parallel_case
753 2'b01 : begin
754 if(last_in_pkt) ctx_next = CTXIDLE;
755 else ctx_next = CTXNXT;
756 end // case: 2'b01
757 2'b10 : begin // wait for lst gnt?
758 if (do_pkseq) ctx_next = CTXIDLE;
759 else ctx_next = CTXDIS;
760 end // case: 2'b10
761 default : ctx_next = CTXIDLE;
762 endcase // case({store_pkt,frwd_pkt})
763 end // case: 1'b0
764
765 1'b1 : begin
766 case(cpl) // synopsys full_case parallel_case
767 1'b1: ctx_next = CTXSEQ;
768 1'b0: begin
769 case (pkvld) // synopsys full_case parallel_case
770 1'b1: ctx_next = CTXSEQ;
771 1'b0: ctx_next = CTXIDLE;
772 endcase // case(pkvld)
773 end
774 endcase // case(cpl)
775 end // case: 1'b1
776 endcase // case(scan_mode)
777 end // case: CTXDIS
778
779 CTXNXT : ctx_next = CTXSEQ;
780
781 default : ctx_next = CTXIDLE; // to satisfy vlint
782 endcase // case(ctx_state)
783 end // always @ (ctx_state or pkvld or store_pkt or frwd_pkt or last_in_pkt...
784
785
786// Context look-up (ctx_upd fsm)
787always @(ctx_state or pkvld or store_pkt or frwd_pkt or last_in_pkt
788 or last_scan_pkt or cpl or do_pkseq or scan_mode)
789 begin
790 case(ctx_state) // synopsys parallel_case
791 CTXIDLE : begin
792 case(pkvld) // synopsys full_case parallel_case
793 1'b0: begin
794 next_ctx_ck = 1'b0;
795 next_clist_put = 1'b0;
796 do_next_pkt = 1'b0;
797 look_up = 1'b0;
798 do_ctx = 1'b0;
799 stop_scan = 1'b0;
800 xfr_strt = 1'b0;
801 clear_pkvld = 1'b0;
802 next_ctx_addr = 1'b0;
803
804 end
805 1'b1: begin
806 next_ctx_ck = 1'b1;
807 next_clist_put = 1'b0;
808 do_next_pkt = 1'b0;
809 look_up = 1'b0;
810 do_ctx = 1'b0;
811 stop_scan = 1'b0;
812 xfr_strt = 1'b0;
813 clear_pkvld = 1'b0;
814 next_ctx_addr = 1'b0; //next_ctx_addr = 1'b1;
815 end
816 endcase // case(pkvld)
817 end // case: CTXIDLE
818
819 CTXSEQ : begin
820 next_clist_put = 1'b0;
821 do_ctx = 1'b0;
822 clear_pkvld = 1'b0;
823 case(scan_mode) // synopsys full_case parallel_case
824 1'b1 : begin
825 case(last_scan_pkt) // synopsys full_case parallel_case
826 1'b1: begin
827 next_ctx_ck = 1'b0;
828 do_next_pkt = 1'b0;
829 look_up = 1'b0;
830 xfr_strt = 1'b0;
831 stop_scan = 1'b1;
832 next_ctx_addr = 1'b0;
833 end
834 1'b0 : begin
835 next_ctx_ck = 1'b0; // next_ctx_ck = 1'b1;
836 do_next_pkt = 1'b1;
837 look_up = 1'b1;
838 stop_scan = 1'b0;
839 xfr_strt = 1'b0;
840 next_ctx_addr = 1'b0;
841 end
842 endcase // case(last_scan_pkt)
843 end // case: 1'b1
844 1'b0 : begin
845 next_ctx_ck = 1'b1;
846 do_next_pkt = 1'b1;
847 look_up = 1'b0;
848 stop_scan = 1'b0;
849 xfr_strt = 1'b0;
850 next_ctx_addr = 1'b1;
851 end
852 endcase // case(scan_mode)
853 end // case: CTXSEQ
854
855 CTXCHK : begin
856 do_ctx = 1'b0;
857 xfr_strt = 1'b0;
858 do_next_pkt = 1'b0;
859 look_up = 1'b0;
860 clear_pkvld = 1'b0;
861 next_ctx_addr = 1'b0;
862 case(scan_mode) // synopsys full_case parallel_case
863 1'b1 : next_ctx_ck = 1'b0;
864 1'b0 : next_ctx_ck = 1'b1;
865 endcase // case(scan_mode)
866
867 next_clist_put = 1'b0;
868 stop_scan = 1'b0;
869 end // case: CTXCHK
870
871 CTXDIS : begin
872 case(scan_mode) // synopsys full_case parallel_case
873 1'b0 : begin
874 next_ctx_addr = 1'b0;
875 case({store_pkt,frwd_pkt}) // synopsys parallel_case
876 2'b01 : begin
877 next_ctx_ck = 1'b1;
878 next_clist_put = 1'b0;
879 do_next_pkt = 1'b0;
880 do_ctx = 1'b1;
881 look_up = 1'b0;
882 xfr_strt = 1'b1;
883 clear_pkvld = 1'b1;
884 case(last_in_pkt) // synopsys full_case parallel_case
885 1'b1 : stop_scan = 1'b1;
886 1'b0 : stop_scan = 1'b0;
887 endcase // case(last_in_pkt)
888 end // case: 2'b01
889 2'b10 : begin // wait for lst gnt?
890 clear_pkvld = 1'b1;
891 case(cpl) // synopsys full_case parallel_case
892 1'b0 : begin
893 next_ctx_ck = 1'b1;
894 next_clist_put = 1'b1;
895 do_next_pkt = 1'b0;
896 look_up = 1'b0;
897 do_ctx = 1'b0;
898 xfr_strt = 1'b0;
899 case(do_pkseq) // synopsys full_case parallel_case
900 1'b1 : stop_scan = 1'b1;
901 1'b0 : stop_scan = 1'b0;
902 endcase // case(do_pkseq)
903 end
904 1'b1 : begin
905 next_ctx_ck = 1'b1;
906 next_clist_put = 1'b0;
907 do_next_pkt = 1'b0;
908 look_up = 1'b0;
909 do_ctx = 1'b0;
910 xfr_strt = 1'b0;
911 case(do_pkseq) // synopsys full_case parallel_case
912 1'b1 : stop_scan = 1'b1;
913 1'b0 : stop_scan = 1'b0;
914 endcase // case(do_pkseq)
915 end // case: 1'b1
916 endcase // case(cpl)
917 end // case: 2'b10
918
919 default : begin
920 next_ctx_ck = 1'b0;
921 next_clist_put = 1'b0;
922 do_next_pkt = 1'b0;
923 look_up = 1'b0;
924 do_ctx = 1'b0;
925 stop_scan = 1'b0;
926 xfr_strt = 1'b0;
927 clear_pkvld = 1'b0;
928 end
929 endcase // case({store_pkt,frwd_pkt})
930 end // case: 1'b0
931
932 1'b1 : begin
933 clear_pkvld = 1'b0;
934 case(cpl) // synopsys full_case parallel_case
935 1'b1 : begin
936 next_ctx_ck = 1'b0;
937 next_clist_put = 1'b0;
938 do_next_pkt = 1'b0;
939 do_ctx = 1'b1;
940 xfr_strt = 1'b1;
941 look_up = 1'b1;
942 stop_scan = 1'b0;
943 next_ctx_addr = 1'b0;
944 end
945 1'b0 : begin
946 next_ctx_ck = 1'b0;
947 next_clist_put = 1'b0;
948 do_next_pkt = 1'b0;
949 do_ctx = 1'b0; // do_ctx = 1'b1;
950 xfr_strt = 1'b0; // xfr_strt = 1'b1;
951 look_up = 1'b0;
952 stop_scan = 1'b1;
953 case (pkvld) // synopsys full_case parallel_case
954 1'b1: next_ctx_addr = 1'b1;
955 1'b0: next_ctx_addr = 1'b0;
956 endcase // case(pkvld)
957 end
958 endcase // case(cpl)
959 end // case: 1'b1
960 endcase // case(scan_mode)
961 end // case: CTXDIS
962
963 CTXNXT : begin
964 next_ctx_ck = 1'b0; // do not check incoming pkseq, get frm clist
965 next_clist_put = 1'b0;
966 do_next_pkt = 1'b0;
967 look_up = 1'b1;
968 do_ctx = 1'b0;
969 stop_scan = 1'b0;
970 xfr_strt = 1'b0;
971 clear_pkvld = 1'b0;
972 next_ctx_addr = 1'b0;
973 end
974
975 default : begin // to satisfy vlint
976 next_ctx_ck = 1'b0;
977 next_clist_put = 1'b0;
978 do_next_pkt = 1'b0;
979 look_up = 1'b0;
980 do_ctx = 1'b0;
981 stop_scan = 1'b0;
982 xfr_strt = 1'b0;
983 clear_pkvld = 1'b0;
984 next_ctx_addr = 1'b0;
985 end
986 endcase // case(ctx_state)
987 end // always @ (ctx_state or next_pkvld or store_pkt or frwd_pkt or last_pkt...
988
989 // CTX state transitions
990always @(posedge clk)
991 begin
992 if (rst_l == 1'b0)
993 ctx_state <= CTXIDLE; // Synchronous Reset
994 else begin
995 ctx_state <= ctx_next;
996 end
997 end
998
999
1000// CLIST Egress Packet Put FSM (lst_upd)
1001always @(lst_state or ctx2tcm_lst_gnt or next_clist_put)
1002 begin
1003 do_lst = 1'b0;
1004 do_pkseq = 1'b0;
1005 next_lst_req = 1'b0;
1006 lst_next = lst_state;
1007
1008 case(lst_state) // synopsys parallel_case
1009 LSTIDLE : begin
1010 case(next_clist_put) // synopsys full_case parallel_case
1011 1'b0: begin
1012 do_lst = 1'b0;
1013 do_pkseq = 1'b0;
1014 next_lst_req = 1'b0;
1015 lst_next = LSTIDLE;
1016 end
1017 1'b1: begin
1018 do_lst = 1'b0;
1019 do_pkseq = 1'b0;
1020 next_lst_req = 1'b1;
1021 lst_next = LSTGNT;
1022 end
1023 endcase // case(next_clist_put)
1024 end // case: LSTIDLE
1025
1026 LSTGNT : begin
1027 case(ctx2tcm_lst_gnt) // synopsys full_case parallel_case
1028 1'b0: begin
1029 do_lst = 1'b0;
1030 do_pkseq = 1'b0;
1031 next_lst_req = 1'b1;
1032 lst_next = LSTGNT;
1033 end
1034 1'b1: begin
1035 do_lst = 1'b0;
1036 do_pkseq = 1'b0;
1037 next_lst_req = 1'b0;
1038 lst_next = LSTUPD;
1039 end
1040 endcase // case(ctx2tcm_lst_gnt)
1041 end // case: LSTGNT
1042 LSTUPD : begin
1043 do_lst = 1'b1;
1044 do_pkseq = 1'b1;
1045 next_lst_req = 1'b0;
1046 lst_next = LSTIDLE;
1047 end
1048 default : begin // to satisfy vlint
1049 do_lst = 1'b0;
1050 do_pkseq = 1'b0;
1051 next_lst_req = 1'b0;
1052 lst_next = LSTIDLE;
1053 end
1054 endcase // case(lst_state)
1055 end // always @ (lst_state or ctx2tcm_lst_gnt or next_clist_put)
1056
1057
1058// LST state transitions
1059always @(posedge clk)
1060 begin
1061 if (rst_l == 1'b0)
1062 lst_state <= LSTIDLE; // Synchronous Reset
1063 else begin
1064 lst_state <= lst_next;
1065 end
1066end
1067
1068// *************** Build Context Procedures (build_cntx)*********/
1069// Packet Record Dequeue Process
1070// packet record dequeue state machine (dq_fsm)
1071
1072// Parse Schedule Record to issue Packet Records
1073// lengths are represented in DW's
1074
1075// Context Build Process (build_cntx)
1076// Transfer State machine
1077
1078// BLD next state
1079always @(bld_state or pipe_mpty or rm2cm_rcd_full or pipe_clastyp
1080 or xfr_strt or last_in_pkt or last_scan_pkt or stop_scan
1081 or scan_mode)
1082 begin
1083 case(bld_state) // synopsys full_case parallel_case
1084 BLDIDLE : begin
1085 case(pipe_mpty) // synopsys full_case parallel_case
1086 1'b1 : bld_next = BLDIDLE;
1087 1'b0 : begin
1088 case(pipe_clastyp) // synopsys parallel_case
1089 CLASUSP,
1090 CLASPIO,
1091 CLASMDO : bld_next = BLDBPAS;
1092 CLASCP ,
1093 CLASCPD : bld_next = BLDCNTX;
1094 default : bld_next = BLDIDLE;
1095 endcase // case(next_clastyp)
1096 end
1097 endcase // case(pipe_mpty)
1098 end // case: BLDDEQ
1099
1100 BLDCNTX : begin
1101 case(rm2cm_rcd_full) // synopsys full_case parallel_case
1102 1'b0 : begin
1103 case({scan_mode,xfr_strt}) // synopsys full_case parallel_case
1104 2'b00 : begin
1105 case(stop_scan) // synopsys full_case parallel_case
1106 1'b1 : bld_next = BLDIDLE;
1107 1'b0 : bld_next = BLDCNTX;
1108 endcase // case({stop_scan,pipe_mpty})
1109 end
1110 2'b01 : begin
1111 case({pipe_clastyp, last_in_pkt}) // synopsys parallel_case
1112 {CLASCP, 1'b0},
1113 {CLASCPD,1'b0} : bld_next = BLDCNTX;
1114 {CLASCP, 1'b1},
1115 {CLASCPD,1'b1} : bld_next = BLDIDLE;
1116 default : bld_next = BLDIDLE;
1117 endcase // case({pipe_clastyp, last_in_pkt})
1118 end // case: 2'b01
1119
1120 2'b10 : begin
1121 case(stop_scan) // synopsys full_case parallel_case
1122 1'b1 : bld_next = BLDIDLE;
1123 1'b0 : bld_next = BLDCNTX;
1124 endcase // case(stop_scan)
1125 end
1126 2'b11 : begin
1127 case(last_scan_pkt) // synopsys full_case parallel_case
1128 1'b1 : bld_next = BLDIDLE;
1129 1'b0 : begin
1130 case(stop_scan) // synopsys full_case parallel_case
1131 1'b1 : bld_next = BLDIDLE;
1132 1'b0 : bld_next = BLDCNTX;
1133 endcase // case(stop_scan)
1134 end
1135 endcase // case(last_scan_pkt)
1136 end
1137 endcase // case({scan_mode,xfr_strt})
1138 end // case: 1'b0
1139
1140 1'b1 : bld_next = BLDCNTX;
1141 endcase // case(rm2cm_rcd_full)
1142 end // case: BLDCNTX
1143
1144 BLDBPAS : begin
1145 case(rm2cm_rcd_full) // synopsys full_case parallel_case
1146 1'b0 : bld_next = BLDIDLE;
1147 1'b1 : bld_next = BLDBPAS;
1148 endcase // case(rm2cm_rcd_full)
1149 end // case: BLDBPAS
1150
1151 default : bld_next = BLDIDLE;
1152
1153 endcase // case(bld_state)
1154 end // always @ (bld_state or pkmpty or rm2cm_rcd_full or next_clastyp...
1155
1156// BLD state machine outputs
1157always @(bld_state or rm2cm_rcd_full or pipe_clastyp or xfr_strt
1158 or last_in_pkt or last_scan_pkt or stop_scan or scan_mode)
1159 begin
1160
1161// next_deq_pipe signal to dequeue next packet record in pipeline
1162// next_gen_pkt signal to start retire record build
1163// next_rcd_enq enqueues packet to pipeline
1164
1165 case(bld_state) // synopsys full_case parallel_case
1166 BLDIDLE : begin
1167 next_deq_pipe = 1'b0;
1168 next_gen_pkt = 1'b0;
1169 next_rcd_enq = 1'b0;
1170 end
1171 BLDCNTX : begin
1172 case(rm2cm_rcd_full) // synopsys full_case parallel_case
1173 1'b0 : begin
1174 case({scan_mode,xfr_strt}) // synopsys full_case parallel_case
1175 2'b00 : begin
1176 next_gen_pkt = 1'b0;
1177 next_rcd_enq = 1'b0;
1178 case(stop_scan) // synopsys full_case parallel_case
1179 1'b1 : next_deq_pipe = 1'b1;
1180 1'b0 : next_deq_pipe = 1'b0;
1181 endcase // case(stop_scan)
1182 end // case: 2'b00
1183
1184 2'b01 : begin
1185 case({pipe_clastyp, last_in_pkt}) // synopsys parallel_case
1186 {CLASCP, 1'b0},
1187 {CLASCPD,1'b0} : begin
1188 next_deq_pipe = 1'b1;
1189 next_rcd_enq = 1'b1;
1190 next_gen_pkt = 1'b1;
1191 end
1192 {CLASCP, 1'b1},
1193 {CLASCPD,1'b1} : begin
1194 next_deq_pipe = 1'b1;
1195 next_rcd_enq = 1'b1;
1196 next_gen_pkt = 1'b1;
1197 end
1198 default : begin
1199 next_deq_pipe = 1'b0;
1200 next_rcd_enq = 1'b0;
1201 next_gen_pkt = 1'b0;
1202 end
1203 endcase // case({pipe_clastyp, last_in_pkt})
1204 end // case: 2'b01
1205 2'b10 : begin
1206 next_rcd_enq = 1'b0;
1207 next_gen_pkt = 1'b0;
1208 next_deq_pipe = 1'b0;
1209 end
1210 2'b11 : begin
1211 case(last_scan_pkt) // synopsys full_case parallel_case
1212 1'b1 : begin
1213 next_deq_pipe = 1'b1;
1214 next_gen_pkt = 1'b1;
1215 next_rcd_enq = 1'b1;
1216 end
1217 1'b0 : begin
1218 case(stop_scan) // synopsys full_case parallel_case
1219 1'b1 : begin
1220 next_deq_pipe = 1'b1;
1221 next_gen_pkt = 1'b0;
1222 next_rcd_enq = 1'b0;
1223 end
1224 1'b0 : begin
1225 next_deq_pipe = 1'b0;
1226 next_gen_pkt = 1'b1;
1227 next_rcd_enq = 1'b1;
1228 end
1229 endcase // case(stop_scan)
1230 end
1231 endcase // case(last_scan_pkt)
1232 end
1233 endcase // case({scan_mode,xfr_strt})
1234 end // case: 1'b0
1235
1236 1'b1 : begin
1237 next_deq_pipe = 1'b0;
1238 next_gen_pkt = 1'b0;
1239 next_rcd_enq = 1'b0;
1240 end
1241 endcase // case(rm2cm_rcd_full)
1242 end // case: BLDCNTX
1243
1244 BLDBPAS : begin
1245 next_gen_pkt = 1'b0;
1246 case(rm2cm_rcd_full) // synopsys full_case parallel_case
1247 1'b0 : begin
1248 next_rcd_enq = 1'b1;
1249 next_deq_pipe = 1'b1;
1250 end
1251 1'b1 : begin
1252 next_rcd_enq = 1'b0;
1253 next_deq_pipe = 1'b0;
1254 end
1255 endcase // case(rm2cm_rcd_full)
1256 end // case: BLDBPAS
1257
1258 default : begin
1259 next_deq_pipe = 1'b0;
1260 next_gen_pkt = 1'b0;
1261 next_rcd_enq = 1'b0;
1262 end
1263 endcase // case(bld_state)
1264 end // always @ (bld_state or pkmpty or rm2cm_rcd_full or next_clastyp...
1265
1266
1267// BLD state transitions
1268always @(posedge clk)
1269 begin
1270 if (rst_l == 1'b0)
1271 bld_state <= BLDIDLE; // Synchronous Reset
1272 else begin
1273 bld_state <= bld_next;
1274 end
1275 end
1276
1277//************************************************
1278// MODULES
1279//************************************************
1280
1281dmu_cmu_tcm_pkrcd_q tcm_queue (
1282 .clk (clk),
1283 .rst_l (rst_l),
1284 .enq (cl2cm_rcd_enq),
1285 .rcd_in (cl2cm_rcd),
1286 .deq (next_deq_pkr),
1287 .typ (pkttyp),
1288 .len(pktlen),
1289 .dwbe (pktdwbe),
1290 .addr(pktaddr),
1291 .sbd_tag(pkttr_tag),
1292 .dptr(pktdptr),
1293 .cntxt_num(pktcntxt_num),
1294 .pkseq_num(pktseq_num),
1295 .full (cm2cl_rcd_full),
1296 .empty (pkmpty),
1297 .overflow(), // .overflow(overflow),
1298 .underflow() // .underflow(underflow)
1299 );
1300
1301
1302// ********************** signal registers *************************/
1303// Release records
1304
1305always @(posedge clk)
1306 begin
1307 if (!rst_l) begin
1308 ctx_sel <= 0;
1309 ctx_relrcd <= 0;
1310 pkseq_sel <= 0;
1311 pkseq_relrcd <= 0;
1312 clst_sel <= 0;
1313 clst_relrcd <= 0;
1314 end
1315 else begin
1316 case(bld_state) // synopsys parallel_case
1317 BLDIDLE : begin // BLDIDLE
1318 ctx_sel <= 0;
1319 ctx_relrcd <= ld_pipe ? pipe_pktcntxt_num : ctx_relrcd;
1320 pkseq_sel <= 0;
1321 pkseq_relrcd <= tcm2ctx_ctx[PSEQMSB : PSEQLSB];
1322 clst_sel <= 0;
1323 clst_relrcd <= 0;
1324 end
1325
1326 BLDCNTX : begin // BLDCNTX
1327 case({next_gen_pkt, scan_mode}) // synopsys parallel_case
1328 2'b10 : begin
1329 ctx_sel <= last_pkt;
1330 ctx_relrcd <= pipe_pktcntxt_num;
1331 pkseq_sel <= 1'b1;
1332 pkseq_relrcd <= tcm_cur_ctx[PSEQMSB : PSEQLSB] + pipe_pktseq_num;
1333 clst_sel <= 1'b0;
1334 clst_relrcd <= tcm2ctx_ctxlst_addr;
1335 end
1336 2'b11 : begin
1337 ctx_sel <= ctx2tcm_cur_lst[CLSTPKTMSB];
1338 ctx_relrcd <= ctx_relrcd;
1339 pkseq_sel <= 1'b1;
1340 pkseq_relrcd <= tcm2ctx_pkseq_addr; // tcm_cur_ctx[PSEQMSB : PSEQLSB] + scan_pkseq_num;
1341 clst_sel <= 1'b1;
1342 clst_relrcd <= tcm2ctx_ctxlst_addr;
1343 end
1344 default : begin
1345 ctx_sel <= ctx_sel;
1346 ctx_relrcd <= ctx_relrcd;
1347 pkseq_sel <= pkseq_sel;
1348 pkseq_relrcd <= pkseq_relrcd;
1349 clst_sel <= clst_sel;
1350 clst_relrcd <= clst_relrcd;
1351 end
1352 endcase // case({next_gen_pkt, scan_mode})
1353 end // case: BLDCNTX
1354
1355 BLDBPAS : begin // BLDBPAS
1356 ctx_sel <= ctx_sel;
1357 ctx_relrcd <= ctx_relrcd;
1358 pkseq_sel <= pkseq_sel;
1359 pkseq_relrcd <= pkseq_relrcd;
1360 clst_sel <= clst_sel;
1361 clst_relrcd <= clst_relrcd;
1362 end
1363
1364 default : begin
1365 ctx_sel <= ctx_sel;
1366 ctx_relrcd <= ctx_relrcd;
1367 pkseq_sel <= pkseq_sel;
1368 pkseq_relrcd <= pkseq_relrcd;
1369 clst_sel <= clst_sel;
1370 clst_relrcd <= clst_relrcd;
1371 end
1372 endcase // case(bld_state)
1373 end // else: !if(!rst_l)
1374 end // always @ (posedge clk)
1375
1376
1377
1378always @(posedge clk)
1379 begin
1380 if (rst_l == 1'b0) begin
1381 hld_pkvld <= 0;
1382 pipe_full <= 0;
1383
1384 ctx_ck <= 0;
1385
1386 cm2rm_rcd_enq <= 0;
1387
1388 tcm2ctx_ctx_addr_hld <= 0;
1389 tcm2ctx_ctx_rw <= 0;
1390 tcm2ctx_ctx <= 0;
1391
1392 tcm2ctx_pkseq_addr <= 0;
1393 tcm2ctx_pkseq <= 0;
1394 tcm2ctx_pkseq_rw <= 0;
1395
1396
1397 tcm2ctx_ctxlst_addr <= 0;
1398 tcm2ctx_lst <= 0;
1399 tcm2ctx_clst_rw <= 0;
1400
1401 tcm2ctx_lst_req <= 0;
1402 tcm2ctx_ctxlst_addr <= 0;
1403 tcm2ctx_lst <= 0;
1404 tcm2ctx_clst_rw <= 0;
1405
1406 do_next_lst <= 0;
1407
1408 tcm_cur_ctx <= 0;
1409
1410 last_in_pkt <= 0;
1411
1412 tcm2ctx_ret_req <= 0;
1413 tcm2ctx_ret_addr <= 0;
1414
1415 cpl <= 0;
1416
1417 end
1418
1419 else begin
1420 hld_pkvld <= next_pkvld ? 1'b1 : (~clear_pkvld & hld_pkvld);
1421 pipe_full <= ld_pipe ? 1'b1 : (~next_deq_pipe & pipe_full);
1422
1423 ctx_ck <= next_ctx_ck;
1424
1425 cm2rm_rcd_enq <= next_rcd_enq;
1426
1427 tcm2ctx_ctx_addr_hld <= (next_ctx_addr
1428 && ((pipe_clastyp == CLASCP) || (pipe_clastyp == CLASCPD))
1429 && hld_pkvld) ? pipe_pktcntxt_num
1430 : tcm2ctx_ctx_addr_hld;
1431 tcm2ctx_ctx_rw <= do_ctx;
1432
1433 tcm2ctx_ctx <= do_ctx
1434 ? (scan_mode
1435 ? {tcm_cur_ctx[CTXARRAYMSB : ERRLSB],(scan_order_bits & ctx_order_bits)}
1436 : {tcm_cur_ctx[CTXARRAYMSB : ERRLSB],new_order_bits})
1437 : tcm2ctx_ctx;
1438
1439 case(do_next_pkt) // synopsys parallel_case
1440 1'b1 : begin
1441 case ({scan_mode,store_pkt}) // synopsys parallel_case
1442 2'b11,
1443 2'b10 : tcm2ctx_pkseq_addr <= tcm2ctx_pkseq_addr + 1'b1;
1444 2'b01 : tcm2ctx_pkseq_addr <= ctx2tcm_cur_ctx[PSEQMSB : PSEQLSB] + pipe_pktseq_num;
1445 2'b00 : tcm2ctx_pkseq_addr <= ctx2tcm_cur_ctx[PSEQMSB : PSEQLSB] + pipe_pktseq_num;
1446 endcase // case({scan_mode,store_pkt})
1447 end
1448 1'b0 : tcm2ctx_pkseq_addr <= tcm2ctx_pkseq_addr;
1449 endcase // case(do_next_lst)
1450
1451 tcm2ctx_pkseq <= do_pkseq ? {1'b1, tcm2ctx_ctxlst_addr}
1452 : tcm2ctx_pkseq;
1453
1454 tcm2ctx_pkseq_rw <= do_pkseq;
1455
1456
1457 tcm2ctx_ctxlst_addr <= do_next_lst
1458 ? ctx2tcm_cur_pkseq[PTRCLSTMSB : PTRCLSTLSB]
1459 : (ctx2tcm_lst_gnt ? ctx2tcm_nxlst_addr
1460 : tcm2ctx_ctxlst_addr);
1461 tcm2ctx_lst <= do_lst ? {pipe_rrtyp,
1462 pipe_rrlen,
1463 last_in_pkt,
1464 {4'h0,pipe_rrdwbe[(PRDWBEMSB -4) :0]},
1465 pipe_rraddr[11:0],
1466 pipe_rrsbdtag,
1467 pipe_rrdptr,
1468 pipe_pktseq_num} : tcm2ctx_lst;
1469
1470 tcm2ctx_clst_rw <= do_lst;
1471
1472 tcm2ctx_lst_req <= next_lst_req;
1473
1474 do_next_lst <= do_next_pkt;
1475
1476 tcm_cur_ctx <= next_ctx_addr ? ctx2tcm_cur_ctx : tcm_cur_ctx;
1477
1478 last_in_pkt <= ((tcm_cur_ctx[PKTOTMSB :PKTOTLSB] - {1'b0,pipe_pktseq_num}) == 6'h01)
1479 ? 1'b1 : 1'b0;
1480 last_scan_pkt <= (scan_mode == 1'b1)
1481 ? (do_ctx ? ((tcm_cur_ctx[PKTOTMSB :PKTOTLSB] - {1'b0,scan_pkseq_num}) == 6'h01)
1482 : last_scan_pkt)
1483 : 1'b0;
1484 tcm2ctx_ret_req <= cm2rm_rcd_enq;
1485 tcm2ctx_ret_addr <= cm2rm_rcd_enq ? ({ctx_sel,ctx_relrcd,
1486 pkseq_sel,pkseq_relrcd,
1487 clst_sel,clst_relrcd})
1488 : tcm2ctx_ret_addr;
1489 cpl <= ctx2tcm_cur_pkseq[CBITMSB : CBITLSB];
1490
1491 end // else: !if(rst_l == 1'b0)
1492 end // always @ (posedge clk)
1493
1494// ----------------------------------------------------------------------------
1495// Debug
1496// ----------------------------------------------------------------------------
1497always @ (dbg2tcm_dbg_sel_a or dbg2tcm_dbg_sel_b)
1498 begin
1499 dbg_sel[0] = dbg2tcm_dbg_sel_a;
1500 dbg_sel[1] = dbg2tcm_dbg_sel_b;
1501 end
1502
1503always @ (dbg_sel[0] or dbg_sel[1] or next_clastyp or next_pktseq_num or
1504 frwd_pkt or store_pkt or ctx_ck or scan_mode or stop_scan or
1505 pipe_clastyp or pkmpty or pipe_full or next_pkvld or ld_pipe or
1506 next_deq_pkr or deq_state or pipe_pktseq_num or do_pkseq or
1507 last_in_pkt or ctx_state or pkvld or next_ctx_ck or tcm_is_idle or
1508 next_clist_put or do_next_pkt or look_up or do_ctx or xfr_strt or
1509 next_deq_pipe or next_gen_pkt or next_rcd_enq or rm2cm_rcd_full or
1510 bld_state or next_lst_req or do_lst or lst_state
1511 )
1512 begin
1513 for (i = 0; i < 2; i = i + 1) begin
1514 case (dbg_sel[i]) // synopsys infer_mux
1515 3'b000: nxt_dbg_bus[i] = {next_clastyp,next_pktseq_num};
1516 3'b001: nxt_dbg_bus[i] = {frwd_pkt,store_pkt,ctx_ck,scan_mode,stop_scan,pipe_clastyp};
1517 3'b010: nxt_dbg_bus[i] = {tcm_is_idle,pkmpty,pipe_full,next_pkvld,ld_pipe,next_deq_pkr,deq_state};
1518 3'b011: nxt_dbg_bus[i] = {pipe_clastyp,pipe_pktseq_num};
1519 3'b100: nxt_dbg_bus[i] = {store_pkt,do_pkseq,last_in_pkt,scan_mode,pkvld,ctx_state};
1520 3'b101: nxt_dbg_bus[i] = {pkvld,next_ctx_ck,next_clist_put,do_next_pkt,look_up,do_ctx,stop_scan,xfr_strt};
1521 3'b110: nxt_dbg_bus[i] = {1'b0,next_deq_pipe,next_gen_pkt,next_rcd_enq,rm2cm_rcd_full,bld_state};
1522 3'b111: nxt_dbg_bus[i] = {2'b00,next_lst_req,do_pkseq,do_lst,next_clist_put,lst_state};
1523 endcase // case(dbg_sel[i])
1524 end // for (i = 0; i < 2; i = i + 1)
1525 end // always @ (dbg_sel[0] or dbg_sel[1] or...
1526
1527
1528// ********************** Output Procedures ************************/
1529
1530// Debug
1531always @ (posedge clk) begin
1532 if(rst_l == 1'b0) begin
1533 for (k = 0; k < 2; k = k + 1) begin
1534 dbg_bus[k] <= 8'h00;
1535 end
1536 end
1537 else begin
1538 for (k = 0; k < 2; k = k + 1) begin
1539 dbg_bus[k] <= nxt_dbg_bus[k];
1540 end
1541 end
1542end // always @ (posedge clk)
1543
1544// Pipeline stages for next retire record packet sequence
1545// Registered outputs for Retire Record outputs
1546
1547always @(posedge clk)
1548 if(~rst_l) begin
1549 rrtyp <= {RRTYP_WDTH{1'b0}};
1550 rrlen <= {RRLEN_WDTH{1'b0}};
1551 rrdwbe <= {RRFDWBE_WDTH + RRLDWBE_WDTH{1'b0}};
1552 rraddr <= {RRADDR_WDTH{1'b0}};
1553 rrsbdtag <= {RRSBDTAG_WDTH{1'b0}};
1554 rrdptr <= {RRDPTR_WDTH{1'b0}};
1555 end
1556 else begin
1557 case(bld_state) // synopsys parallel_case
1558 BLDIDLE : begin // BLDIDLE
1559 rrtyp <= rrtyp;
1560 rrlen <= rrlen;
1561 rrdwbe <= rrdwbe;
1562 rraddr <= rraddr;
1563 rrsbdtag <= rrsbdtag;
1564 rrdptr <= rrdptr;
1565 end
1566
1567 BLDCNTX : begin // BLDCNTX
1568 case({next_gen_pkt, scan_mode}) // synopsys parallel_case
1569 2'b10 : begin
1570 rrtyp <= pipe_rrtyp;
1571 rrlen <= pipe_rrlen;
1572 rrdwbe <= ({pipe_rrdwbe[PRDWBEMSB : PRDWBEMSB -2],last_pkt
1573 ,pipe_rrdwbe[(PRDWBEMSB -4) :0]});
1574 rraddr <= pipe_rraddr;
1575 rrsbdtag <= pipe_rrsbdtag;
1576 rrdptr <= pipe_rrdptr;
1577 end
1578
1579 2'b11 : begin
1580 rrtyp <= ctx2tcm_cur_lst[CTYPMSB :CTYPLSB];
1581 rrlen <= ctx2tcm_cur_lst[CLENMSB :CLENLSB];
1582 rrdwbe <= ({{ctx2tcm_cur_lst[CDWBEMSB : CDWBEMSB -3] | {3'b0, ctx2tcm_cur_lst[CLSTPKTMSB]}},
1583 ctx2tcm_cur_lst[(CDWBEMSB -4) : CDWBELSB]});
1584 rraddr <= {22'h000000,ctx2tcm_cur_lst[CADDRMSB :CADDRLSB]};
1585 rrsbdtag <= ctx2tcm_cur_lst[CSBDTAGMSB :CSBDTAGLSB];
1586 rrdptr <= ctx2tcm_cur_lst[CDPTRMSB :CDPTRLSB];
1587 end
1588
1589 default : begin
1590 rrtyp <= rrtyp;
1591 rrlen <= rrlen;
1592 rrdwbe <= rrdwbe;
1593 rraddr <= rraddr;
1594 rrsbdtag <= rrsbdtag;
1595 rrdptr <= rrdptr;
1596 end
1597 endcase // case({next_gen_pkt, scan_mode})
1598 end // case: BLDCNTX
1599
1600 BLDBPAS : begin // BLDBPAS
1601 rrtyp <= next_rcd_enq ? pipe_rrtyp : rrtyp;
1602 rrlen <= next_rcd_enq ? pipe_rrlen : rrlen;
1603 rrdwbe <= next_rcd_enq ? pipe_rrdwbe : rrdwbe;
1604 rraddr <= next_rcd_enq ? pipe_rraddr : rraddr;
1605 rrsbdtag <= next_rcd_enq ? pipe_rrsbdtag : rrsbdtag;
1606 rrdptr <= next_rcd_enq ? pipe_rrdptr : rrdptr;
1607 end
1608 default : begin
1609 rrtyp <= rrtyp;
1610 rrlen <= rrlen;
1611 rrdwbe <= rrdwbe;
1612 rraddr <= rraddr;
1613 rrsbdtag <= rrsbdtag;
1614 rrdptr <= rrdptr;
1615 end
1616 endcase // case(bld_state)
1617 end // always @ (posedge clk)
1618
1619always @(posedge clk)
1620 begin
1621 if (rst_l == 1'b0) begin
1622 tcm_is_idle <= 1'b1;
1623 end
1624 else begin
1625 tcm_is_idle <= ((pkmpty == 1'b1) && (deq_state == DEQIDLE) &&
1626 (ctx_state == CTXIDLE) && (lst_state == LSTIDLE) &&
1627 (pipe_mpty == 1'b1) && (bld_state == BLDIDLE))
1628 ? 1'b1 : 1'b0;
1629 end
1630 end // always @ (posedge clk)
1631
1632// ***********************Assignments *****************************/
1633
1634// Signal assignments
1635 assign pkt_clsts = pktdwbe[2:0];
1636
1637 assign pipe_mpty = ~pipe_full;
1638
1639 assign pkvld = next_pkvld | hld_pkvld;
1640
1641 assign last_pkt = last_in_pkt | last_scan_pkt;
1642
1643 assign new_order_bits = (((pipe_clastyp == CLASCPD) || (pipe_clastyp == CLASCP))
1644 && (frwd_pkt == 1'b1))
1645 ? (upd_order_bits & ctx_order_bits)
1646 : ctx_order_bits;
1647
1648 assign ctx_order_bits = ctx2tcm_cur_ctx[ORDERBITMSB :ORDERBITLSB];
1649
1650 assign scan_pkseq_num = ctx2tcm_cur_lst[CPKSEQMSB :0];
1651
1652// Output assignments
1653 assign cm2rm_rcd [RRMSB :0] = { // Egress Retire Record
1654 rrtyp[RRTYPMSB :0],
1655 rrlen[RRLENMSB :0],
1656 rrdwbe[RRDWBEMSB :0],
1657 rraddr[RRADDRMSB :0],
1658 rrsbdtag[RRSBDTAGMSB :0],
1659 rrdptr[RRDPTRMSB :0]
1660 };
1661 assign tcm2ctx_ctx_addr = (next_ctx_addr
1662 && ((pipe_clastyp == CLASCP) || (pipe_clastyp == CLASCPD))
1663 && hld_pkvld) ? pipe_pktcntxt_num
1664 : tcm2ctx_ctx_addr_hld;
1665// Debug
1666 assign tcm2dbg_dbg_a = dbg_bus[0];
1667 assign tcm2dbg_dbg_b = dbg_bus[1];
1668
1669endmodule
1670