Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_rmu_rrm_efsm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_rmu_rrm_efsm.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_rmu_rrm_efsm (
36
37 clk,
38 rst_l,
39
40 // Inputs from CMU - Retire Record (TCM to RRM)
41 cm2rm_rcd,
42 cm2rm_rcd_enq,
43
44 // Output to CMU
45 rm2cm_rcd_full,
46
47 // Outputs to ILU - EPE Record (Egress PEC Record)
48 k2y_rcd,
49 k2y_rcd_enq,
50
51 // Input from ILU
52 y2k_rcd_deq,
53
54 // Outputs to IMU - Mondo Reply Record (RRM to IMU)
55 rm2im_rply,
56 rm2im_rply_enq,
57
58 // Input from IMU - Static CSR MEM64 Address Offset
59 im2rm_mem64_offset_reg,
60
61 // Outputs to TSB
62 rm2ts_e_trn,
63 rm2ts_e_wr_data,
64
65 // Inputs from TSB
66 ts2rm_e_rd_data,
67
68 // Input from CRU
69 cr2rm_req_id,
70
71 // Outputs to Local ETSB module
72 gen_tsb_access,
73 sr_err_last_pkt,
74
75 // Inputs from Local ETSB module
76 tsb_fsm_idle,
77 ld_epe_rcd_tsb,
78
79 // Outputs (local) for Debug Visibility
80 wrb_bcnt,
81 ilu_credit_cnt,
82 type_decode,
83 sr_err_empty,
84 e_state
85
86 );
87
88// synopsys sync_set_reset "rst_l"
89
90//############################################################################
91// PORT DECLARATIONS
92//############################################################################
93
94 //------------------------------------------------------------------------
95 // Clock and Reset Signals
96 //------------------------------------------------------------------------
97 input clk;
98 input rst_l;
99
100
101 //------------------------------------------------------------------------
102 // CMU Interface
103 //------------------------------------------------------------------------
104
105 // Egress pipeline interface - Egress RETIRE RECORD (TCM to RRM)
106 input [`FIRE_DLC_ERR_REC_WDTH-1:0] cm2rm_rcd;
107 input cm2rm_rcd_enq;
108 output rm2cm_rcd_full;
109
110 //------------------------------------------------------------------------
111 // ILU Interface
112 //------------------------------------------------------------------------
113
114 // Egress pipeline interface - EPE (Egress PEC record) (RRM to ILU)
115 output [`FIRE_DLC_EPE_REC_WDTH-1:0] k2y_rcd;
116 output k2y_rcd_enq;
117 input y2k_rcd_deq;
118
119
120 //------------------------------------------------------------------------
121 // IMU Interface
122 //------------------------------------------------------------------------
123
124 // Mondo Reply Record (RRM to IMU)
125 output [`FIRE_DLC_MRR_REC_WDTH-1:0] rm2im_rply; // 3 bit field
126 output rm2im_rply_enq;
127 input [`FIRE_DLC_SCW_MEM64_WDTH-1:0] im2rm_mem64_offset_reg; // 40 bit field
128
129
130 //------------------------------------------------------------------------
131 // TSB Interfacs
132 //------------------------------------------------------------------------
133
134 output [`FIRE_DLC_TSR_WR_DATA_WDTH-1:0] rm2ts_e_wr_data;// 48 bit Write Data
135 output [`FIRE_DLC_TSR_TRN_WDTH-1:0] rm2ts_e_trn; // 5 bit TSB trn
136 input [`FIRE_DLC_TSR_RD_DATA_WDTH-1:0] ts2rm_e_rd_data;// 48 bit Rd Data
137
138
139 //------------------------------------------------------------------------
140 // CRU Interface
141 //------------------------------------------------------------------------
142
143 input [`FIRE_PCIE_REQ_ID_WDTH-1:0] cr2rm_req_id; // FIRE's 16 bit Prog. ReqID
144
145
146 //------------------------------------------------------------------------
147 // Egress TSB FSM Interface
148 //------------------------------------------------------------------------
149
150 output gen_tsb_access; // Generate TSB Access
151 output sr_err_last_pkt; // Last Pkt bit from ERR
152 input tsb_fsm_idle; // ETSB FSM Idle
153 input ld_epe_rcd_tsb; // TSB Rd complete - Load
154
155
156 //------------------------------------------------------------------------
157 // Outputs for Debug Visibility
158 //------------------------------------------------------------------------
159
160 output [`FIRE_DLC_TSR_BYTECNT_WDTH:0] wrb_bcnt; // 13 bit field -> [12:0] to
161 // handle special case of rcving 4K
162 // request
163 output [2:0] ilu_credit_cnt; // ILU credit count - starts at 4
164 output [2:0] e_state; // 3 bit 1-hot Egress FSM
165 output [1:0] type_decode; // Transaction Type Decoder
166 output sr_err_empty; // No ERR available in Egress SR Fifo
167
168
169//############################################################################
170// PARAMETERS
171//############################################################################
172
173 // Transaction Class Type Decoder Parameter
174 parameter
175 CLASPIO = 2'b00, // PIO header - Push down Egress Pipeline
176 CLASMDO = 2'b01, // Mondo Reply - will be forked to IMU
177 CLASDMA = 2'b10, // DMA Response - NEEDS TSB Access
178 UNDEFINED = 2'b11; // For ZERO In to detect Invalid TYPE
179
180 // Egress Command Type Decoder Parameter
181
182 parameter
183 PIOMRD32 = 7'b0000000, // CLASPIO, PIO MRd - 32 bit Addr
184 PIOMRD64 = 7'b0100000, // CLASPIO, PIO MRd - 64 bit Addr
185 PIOIORD = 7'b0000010, // CLASPIO, PIO IO Rd
186 PIOCFGRD0 = 7'b0000100, // CLASPIO, PIO Cfg Rd Type 0
187 PIOCFGRD1 = 7'b0000101, // CLASPIO, PIO Cfg Rd Type 1
188 PIOIOWR = 7'b1000010, // CLASPIO, PIO IO Wr
189 PIOMWR32 = 7'b1000000, // CLASPIO, PIO MWr - 32 bit Addr
190 PIOMWR64 = 7'b1100000, // CLASPIO, PIO MWr - 64 bit Addr
191 PIOCFGWR0 = 7'b1000100, // CLASPIO, PIO Cfg Wr Type 0
192 PIOCFGWR1 = 7'b1000101, // CLASPIO, PIO Cfg Wr Type 1
193 MONDORPLY = 7'b1111010, // CLASMDO, Mondo Reply
194 DMACPL = 7'b0001010, // CLASDMA, DMA Completion wOut Data
195 DMACPLLK = 7'b0001011, // CLASDMA, DMA Cpl Lk
196 DMACPLD = 7'b1001010; // CLASDMA, DMA Cpl w Data
197
198
199
200 // Egress Control Finite State Machine Parameters
201
202 parameter
203 E_PROCESS = 0, // Process Retire RCD from TCM
204 E_FULL = 1, // Egress Pipeline Stall (DEM queue full)
205 E_TSB_RD = 2; // TSB Read Access in progress
206
207 parameter
208 NUM_STATES = 3;
209
210
211 // Egress SR FIFO (Egress Retire Records) DEPTH and WIDTH parameters
212
213 parameter
214 E_SR_DEPTH = 8, // 8 Entry FIFO per MAS 2.0 spec
215 E_SR_WIDTH = `FIRE_DLC_ERR_REC_WDTH; // currently 70 bit width
216
217
218//############################################################################
219// DECLARE Module Wires and Registers
220//############################################################################
221
222 wire sr_err_empty; // No ERR available in Egress SR Fifo
223
224
225//--------------------------------------------------
226// Internal Sub-Block Wires
227//--------------------------------------------------
228
229 // Incoming Egress Retire Record fields out of the SR fifo - 70 bit ERR record
230
231 wire [`FIRE_DLC_ERR_REC_WDTH-1:0] sr_err_dout; // Entire ERR Record
232
233 wire [`FIRE_DLC_ERR_TYP_WDTH-1:0] sr_err_type; // 7 bit Type
234 wire [`FIRE_DLC_ERR_LEN_WDTH-1:0] sr_err_len; // 10 bit Length
235 wire [`FIRE_DLC_ERR_LDWBE_WDTH-1:0] sr_err_ldwbe; // 4 bit last DWBE
236 wire [`FIRE_DLC_ERR_FDWBE_WDTH-1:0] sr_err_fdwbe; // 4 bit first DWBE
237 wire [`FIRE_DLC_ERR_ADDR_WDTH-1:0] sr_err_addr; // 34 bit Address
238 wire [`FIRE_DLC_ERR_SBDTAG_WDTH-1:0] sr_err_sbdtag; // 5 bit tag
239 wire [`FIRE_DLC_ERR_DPTR_WDTH-1:0] sr_err_dptr; // 6 bit Data Pointer
240
241 wire sr_err_last_pkt; // DMA Cpl last packet bit
242 wire sr_err_dma_cpl; // Fast decode for DMA Cpl
243 wire sr_err_pio_mem64; // Fast decode for PIO mem 64
244
245
246 // Incoming Transaction Scoreboard Read Data - Broken down into Appropriate Fields
247
248 wire [`FIRE_DLC_TSR_TC_WDTH-1:0] tsb_rd_tc; // 3 bit traffic class
249 wire [`FIRE_DLC_TSR_ATTR_WDTH-1:0] tsb_rd_attr; // 2 bit attribute
250 wire [`FIRE_DLC_TSR_BYTECNT_WDTH-1:0] tsb_rd_bcnt; // 12 bit byte count
251 wire [`FIRE_DLC_TSR_REQID_WDTH-1:0] tsb_rd_reqid; // 16 bit reqid
252 wire [`FIRE_DLC_TSR_TLPTAG_WDTH-1:0] tsb_rd_tlp_tag; // 8 bit tlp_tag
253 wire [`FIRE_DLC_TSR_ADALIGN_WDTH-1:0] tsb_rd_adalign; // 7 bit adalign field
254
255 wire tsb_rd_bcnt_fourk; // Flag for BCNT = 4K
256
257 // Outgoing Transaction Scoreboard Write Data - Just Appropriate Fields
258
259 wire [`FIRE_DLC_TSR_ADALIGN_WDTH-1:0] wrb_adalign;
260 wire [`FIRE_DLC_TSR_BYTECNT_WDTH:0] wrb_bcnt; // 13 bit field -> [12:0] to
261 // handle special case of rcving 4K
262 // request
263
264 // Outgoing PEC (EgressPEc) record fields that need to be calculated - 128 bit EPE record
265 wire [`FIRE_DLC_EPE_TC_WDTH-1:0] next_epe_tc; // 3 bit TC
266 wire [`FIRE_DLC_EPE_ATR_WDTH-1:0] next_epe_atr; // 2 bit Attribute
267 wire [`FIRE_DLC_EPE_TAG_WDTH-1:0] next_epe_tag; // 8 bit tag
268 wire [`FIRE_DLC_EPE_LDWBE_WDTH-1:0] next_epe_ldwbe; // 4 bit last DWBE
269 wire [`FIRE_DLC_EPE_FDWBE_WDTH-1:0] next_epe_fdwbe; // 4 bit last DWBE
270 wire [`FIRE_DLC_EPE_ADDR_WDTH-1:0] next_epe_addr; // 64 bit Address
271 wire [`FIRE_DLC_EPE_ADDR_WDTH-1:0] dma_addr_field; // 64 bit Address
272 wire [`FIRE_DLC_EPE_ADDR_WDTH-1:0] pio_addr_field; // 64 bit Address
273 wire [`FIRE_DLC_EPE_ADDR_WDTH-1:0] pio_mem64_addr; // 64 bit Address
274 wire [`FIRE_DLC_EPE_ADDR_WDTH-1:0] pio_mem32_addr; // 64 bit Address
275
276
277 wire retire_rcd_deq; // Dequeue Signal SR FIFO - dequeues new
278 // sr_err_dout[70:0] to EFSM module
279 wire ld_epe_rcd; // Load Enable for the RRM Record
280
281 wire no_epe_rcd_credit; // LRM has credit for IOT Rcds
282
283
284//--------------------------------------------------
285// Registers that Are Not Flops
286//--------------------------------------------------
287
288 // Output from Combinatorial Decode of sr_err_data
289 reg [1:0] type_decode; // Transaction Type Decoder
290 // PIO, Mondo Reply or DMA (TSB)
291
292 // Outputs from EFSM State Machine
293 reg ld_mdo_rply_rcd; // Mdo Rply Rcd Load Enable
294 reg ld_epe_rcd_pio; // RRM Load Enable due to PIO Rcd
295 reg gen_tsb_access; // Kicks off TSB FSM - AND loads
296 // TSB Trn pointer output!
297
298//--------------------------------------------------
299// Registers that Are Flops
300//--------------------------------------------------
301
302 // Egress FSM 1-hot state machine
303 reg [NUM_STATES-1:0] e_state, next_e_state; // 1-hot Egress FSM
304
305
306 // Egress State Machine Registered Outputs
307 reg k2y_rcd_enq, next_k2y_rcd_enq; // RRM Enqueue to TMU DEM
308 reg rm2im_rply_enq, next_rm2im_rply_enq; // MDO Rply Enqueue to IMU
309
310
311 // Outgoing EPE record field Registers to ILU - 128 bit PEC record
312 reg [`FIRE_DLC_EPE_F_WDTH-1:0] epe_f; // 2 bit F
313 reg [`FIRE_DLC_EPE_TYPE_WDTH-1:0] epe_type; // 5 bit Type
314 reg [`FIRE_DLC_EPE_TC_WDTH-1:0] epe_tc; // 3 bit TC
315 reg [`FIRE_DLC_EPE_ATR_WDTH-1:0] epe_atr; // 2 bit Attribute
316 reg [`FIRE_DLC_EPE_LEN_WDTH-1:0] epe_len; // 10 bit Length
317 reg [`FIRE_DLC_EPE_TAG_WDTH-1:0] epe_tag; // 8 bit tag
318 reg [`FIRE_DLC_EPE_LDWBE_WDTH-1:0] epe_ldwbe; // 4 bit last DWBE
319 reg [`FIRE_DLC_EPE_FDWBE_WDTH-1:0] epe_fdwbe; // 4 bit first DWBE
320 reg [`FIRE_DLC_EPE_ADDR_WDTH-1:0] epe_addr; // 34 bit Address
321 reg [`FIRE_DLC_EPE_DPTR_WDTH-1:0] epe_dptr; // 6 bit Data Pointer
322
323 // Outgoing Mondo Reply Record
324 reg [`FIRE_DLC_MRR_REC_WDTH-1:0] rm2im_rply; // 3 bit mdo rply field
325
326 // Registered Outputs to TSB
327 reg [`FIRE_DLC_TSR_TRN_WDTH-1:0] rm2ts_e_trn; // 5 bit tag to TSB
328
329 reg [`FIRE_DLC_TSR_TC_WDTH-1:0] tsb_wrb_tc; // 3 bit traffic class
330 reg [`FIRE_DLC_TSR_ATTR_WDTH-1:0] tsb_wrb_attr; // 2 bit attribute
331 reg [`FIRE_DLC_TSR_BYTECNT_WDTH-1:0] tsb_wrb_bcnt; // 12 bit writeback count
332 reg [`FIRE_DLC_TSR_REQID_WDTH-1:0] tsb_wrb_reqid; // 16 bit reqid
333 reg [`FIRE_DLC_TSR_TLPTAG_WDTH-1:0] tsb_wrb_tlp_tag; // 8 bit tlp_tag
334 reg [`FIRE_DLC_TSR_ADALIGN_WDTH-1:0] tsb_wrb_adalign; // 7 bit adalign
335
336
337 // WILL be register in INT2 - Outgoing TSB write data - need to calculate length
338 wire [`FIRE_DLC_TSR_WR_DATA_WDTH-1:0] rm2ts_e_wr_data; // 48 bit Write Data
339
340
341 // RRM <-> ILU Credit Mechanism
342 reg [2:0] ilu_credit_cnt, next_ilu_credit_cnt;
343
344
345//############################################################################
346// ZERO IN CHECKERS
347//############################################################################
348
349 //---------------------------------------------------------------------
350 // Egress Transfer Control State Machine Checkers
351 //---------------------------------------------------------------------
352
353 /*
354 0in state -var e_state
355 -val (3'b001 << E_PROCESS)
356 -next (3'b001 << E_TSB_RD)
357 (3'b001 << E_FULL)
358 */
359
360 /*
361 0in state -var e_state
362 -val (3'b001 << E_TSB_RD)
363 -next (3'b001 << E_PROCESS)
364 (3'b001 << E_FULL)
365 */
366
367 /*
368 0in state -var e_state
369 -val (3'b001 << E_FULL)
370 -next (3'b001 << E_PROCESS)
371 */
372
373 // 0in one_hot -var e_state
374
375 // 0in maximum -var ilu_credit_cnt -val 4
376
377 // 0in maximum -var type_decode -val 2
378
379
380//############################################################################
381// COMBINATORIAL LOGIC
382//############################################################################
383
384
385 //---------------------------------------------------------------------------
386 // Outgoing RRM record to TMU concatenation of Registered Fields
387 //---------------------------------------------------------------------------
388
389 assign k2y_rcd = { epe_f,
390 epe_type,
391 epe_tc,
392 epe_atr,
393 epe_len,
394 cr2rm_req_id, // epe_reqid - was 16'b0 for Fire since Root
395 epe_tag, // Complex as a Requestor and Completor
396 epe_ldwbe, // UNTIL P1731 - now programmable
397 epe_fdwbe,
398 epe_addr,
399 epe_dptr
400 };
401
402 //------------------------
403 // Outgoing TSB Write Data
404 //------------------------
405
406 assign rm2ts_e_wr_data = { tsb_wrb_tc,
407 tsb_wrb_attr,
408 tsb_wrb_bcnt,
409 tsb_wrb_reqid,
410 tsb_wrb_tlp_tag,
411 tsb_wrb_adalign
412 };
413
414
415 //---------------------------------------------------------------------------
416 // ERR Fields used to build outgoing RRM - using define file [MSB:LSB] fields
417 //---------------------------------------------------------------------------
418
419 assign sr_err_type = sr_err_dout[`FIRE_DLC_ERR_TYP]; // 7 bit TYPE field
420 assign sr_err_len = sr_err_dout[`FIRE_DLC_ERR_LEN]; // 10 bit Length
421 assign sr_err_ldwbe = sr_err_dout[`FIRE_DLC_ERR_LDWBE]; // 4 bit last DWBE
422 assign sr_err_fdwbe = sr_err_dout[`FIRE_DLC_ERR_FDWBE]; // 4 bit first DWBE
423 assign sr_err_addr = sr_err_dout[`FIRE_DLC_ERR_ADDR]; // 34 bit Addr
424 assign sr_err_sbdtag = sr_err_dout[`FIRE_DLC_ERR_SBDTAG]; // 5 bit sbdtag
425 assign sr_err_dptr = sr_err_dout[`FIRE_DLC_ERR_DPTR]; // 6 bit Data Pointer
426
427 assign sr_err_last_pkt = sr_err_ldwbe[0]; // Bit 0 of LDWBE is the
428 // DMACpl Last Packet field
429 assign sr_err_dma_cpl = ~sr_err_type[4] & sr_err_type[3]; // ERR is a DMA Cpl type
430 // fast version type_decode
431 assign sr_err_pio_mem64 = sr_err_type[5];
432
433 //--------------------------------------------------------------------------------------------
434 // Transaction Scoreboard Values Read from TSB - used to create EPE records and TSB write data
435 //--------------------------------------------------------------------------------------------
436
437 assign tsb_rd_tc = ts2rm_e_rd_data[`FIRE_DLC_TSR_TC];
438 assign tsb_rd_attr = ts2rm_e_rd_data[`FIRE_DLC_TSR_ATTR];
439 assign tsb_rd_bcnt = ts2rm_e_rd_data[`FIRE_DLC_TSR_BYTECNT];
440 assign tsb_rd_reqid = ts2rm_e_rd_data[`FIRE_DLC_TSR_REQID];
441 assign tsb_rd_tlp_tag = ts2rm_e_rd_data[`FIRE_DLC_TSR_TLPTAG];
442 assign tsb_rd_adalign = ts2rm_e_rd_data[`FIRE_DLC_TSR_ADALIGN];
443
444 assign tsb_rd_bcnt_fourk = ~|tsb_rd_bcnt;
445
446 //----------------------------------------------
447 // Dequeue signal to SR Fifo
448 //----------------------------------------------
449
450 assign retire_rcd_deq = (ld_epe_rcd_pio | ld_epe_rcd_tsb | ld_mdo_rply_rcd);
451
452
453 //----------------------------------------------
454 // Egress Retire Record Class Type Decoder Logic
455 //----------------------------------------------
456
457 always @ (sr_err_type or sr_err_empty)
458 begin
459
460 if (sr_err_empty)
461 type_decode[1:0] = CLASPIO;
462
463 else
464 case (sr_err_type) // 0in < case -default
465
466 PIOMRD32 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO MRd - 32 bit Addr
467 PIOMRD64 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO MRd - 64 bit Addr
468 PIOIORD : type_decode[1:0] = CLASPIO; // CLASPIO, PIO IO Rd
469 PIOCFGRD0 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO Cfg Rd Type 0
470 PIOCFGRD1 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO Cfg Rd Type 1
471 PIOIOWR : type_decode[1:0] = CLASPIO; // CLASPIO, PIO IO Wr
472 PIOMWR32 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO MWr - 32 bit Addr
473 PIOMWR64 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO MWr - 64 bit Addr
474 PIOCFGWR0 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO Cfg Wr Type 0
475 PIOCFGWR1 : type_decode[1:0] = CLASPIO; // CLASPIO, PIO Cfg Wr Type 1
476 MONDORPLY : type_decode[1:0] = CLASMDO; // CLASMDO, Mondo Reply
477 DMACPL : type_decode[1:0] = CLASDMA; // CLASDMA, DMA Completion wOut Data
478 DMACPLLK : type_decode[1:0] = CLASDMA; // CLASDMA, DMA Cpl Lk
479 DMACPLD : type_decode[1:0] = CLASDMA; // CLASDMA, DMA Cpl w Data
480
481 // Sero In check for Unitialized or Undefined Class Type - Check ONLY if Valid FIFO Data
482 default : type_decode[1:0] = UNDEFINED;
483
484 endcase // case
485 end // always
486
487
488//############################################################################
489// SEQUENTIAL LOGIC
490//############################################################################
491
492 //----------------------------------------------
493 // Mondo Reply Record generation
494 //----------------------------------------------
495
496 always @ (posedge clk)
497 if (~rst_l)
498 rm2im_rply <= {`FIRE_DLC_MRR_REC_WDTH{1'b0}};
499 else if (ld_mdo_rply_rcd)
500 rm2im_rply <= sr_err_fdwbe[2:0]; // 3 LSB's of FDWBE field
501 else
502 rm2im_rply <= rm2im_rply;
503
504
505 //----------------------------------------------
506 // EPE Record generation
507 //----------------------------------------------
508
509 always @ (posedge clk)
510 if (~rst_l)
511 begin
512 epe_f <= `FIRE_DLC_EPE_F_WDTH'b0;
513 epe_type <= `FIRE_DLC_EPE_TYPE_WDTH'b0;
514 epe_tc <= `FIRE_DLC_EPE_TC_WDTH'b0;
515 epe_atr <= `FIRE_DLC_EPE_ATR_WDTH'b0;
516 epe_len <= `FIRE_DLC_EPE_LEN_WDTH'b0;
517 epe_tag <= `FIRE_DLC_EPE_TAG_WDTH'b0;
518 epe_ldwbe <= `FIRE_DLC_EPE_LDWBE_WDTH'b0;
519 epe_fdwbe <= `FIRE_DLC_EPE_FDWBE_WDTH'b0;
520 epe_addr <= `FIRE_DLC_EPE_ADDR_WDTH'b0;
521 epe_dptr <= `FIRE_DLC_EPE_DPTR_WDTH'b0;
522 end
523 else if (ld_epe_rcd) // RRM Load Enable = ld_epe_rcd_pio | ld_epe_rcd_tsb
524 begin
525 epe_f <= sr_err_type[6:5]; // Taken directly from Egress Retire Record
526 epe_type <= sr_err_type[4:0]; // 7 bit TYPE field - ERR type field ALWAYS 7 bits
527 epe_tc <= next_epe_tc;
528 epe_atr <= next_epe_atr;
529 epe_len <= sr_err_len; // Calculated by PRM on ingress side-up to maxpayload
530 epe_tag <= next_epe_tag;
531 epe_ldwbe <= next_epe_ldwbe;
532 epe_fdwbe <= next_epe_fdwbe;
533 epe_addr <= next_epe_addr;
534 epe_dptr <= sr_err_dptr; //Taken directly from Egress Retire Record
535 end
536 else
537 begin
538 epe_f <= epe_f;
539 epe_type <= epe_type;
540 epe_tc <= epe_tc;
541 epe_atr <= epe_atr;
542 epe_len <= epe_len;
543 epe_tag <= epe_tag;
544 epe_ldwbe <= epe_ldwbe;
545 epe_fdwbe <= epe_fdwbe;
546 epe_addr <= epe_addr;
547 epe_dptr <= epe_dptr;
548 end
549
550
551 //-----------------------------------------------------------
552 // For Readability - will define next EPE record fields here!
553 //-----------------------------------------------------------
554
555 // RRM register Load Enable Signal - spelled out for debug - Loading RRM from ERR or TSB Rd Data
556 assign ld_epe_rcd = ld_epe_rcd_pio | ld_epe_rcd_tsb;
557
558 // Traffic Class Field - 0's for PIO's - or Read from TSB if DMA Cpl
559 assign next_epe_tc = sr_err_dma_cpl ? tsb_rd_tc :`FIRE_DLC_EPE_TC_WDTH'b0;
560
561 // Attribute Field - 0's for PIO's - or Read from TSB if DMA Cpl
562 assign next_epe_atr = sr_err_dma_cpl ? tsb_rd_attr :`FIRE_DLC_EPE_ATR_WDTH'b0;
563
564 // TLP Tag Field - maintains ERR value for PIO's - if DMA Cmpl = cpl_sts[2:0], bcm, bcnt[11:8]
565 assign next_epe_tag = sr_err_dma_cpl ? {sr_err_fdwbe[2:0],1'b0,tsb_rd_bcnt[11:8]} : {3'b000, sr_err_sbdtag};
566
567 // LDWBE Field - maintains ERR value for PIO - remaining bytecount for DMA (incl bytes in cur EPE record)
568 assign next_epe_ldwbe = sr_err_dma_cpl ? tsb_rd_bcnt[7:4] : sr_err_ldwbe;
569
570 // FDWBE Field - maintains ERR value for PIO - remaining bytecount for DMA (incl bytes in cur EPE record)
571 assign next_epe_fdwbe = sr_err_dma_cpl ? tsb_rd_bcnt[3:0] : sr_err_fdwbe;
572
573 // Address field - for PIO, need to calculate for 64 bit addressing - for DMA, Rd from TSB and calc ADALIGN
574 assign next_epe_addr = sr_err_dma_cpl ? dma_addr_field : pio_addr_field;
575
576 // Supporting Logic for EPE Record Address Field Calculations - MUXes should be built in parallel
577 // Address field if Record Type is DMA (DMA Cpl, DMA CplLk, DMA CplD)
578 assign dma_addr_field = {32'b0, tsb_rd_reqid, tsb_rd_tlp_tag, 1'b0, tsb_rd_adalign};
579
580 // Address field Record Type a PIO - (and of 64 bit or 32 bit addressing mode)
581 assign pio_addr_field = sr_err_pio_mem64 ? pio_mem64_addr : pio_mem32_addr;
582
583 // RSV bits set to 0 for debug - will experiment with synthesis using sr_err_addr fields as rsvd
584 // but since fields get shifted - mux's will still be implemented - and addtl fanout of sr_err_addr
585 assign pio_mem64_addr = {im2rm_mem64_offset_reg[39:12],
586 (im2rm_mem64_offset_reg[11:0] | sr_err_addr[33:22]),
587 sr_err_addr[21:0], 2'b00};
588
589 assign pio_mem32_addr = {28'b0, sr_err_addr, 2'b00};
590
591
592 //----------------------------------------------------------
593 // TSB index tag (TRN tag) to look up DMA Read Response Info
594 //----------------------------------------------------------
595
596 always @ (posedge clk)
597 if (~rst_l)
598 rm2ts_e_trn <= `FIRE_DLC_TSR_TRN_WDTH'b0; // Clear TSB TRN index
599 else if (gen_tsb_access) // Load Enable is the GO bit!
600 rm2ts_e_trn <= sr_err_sbdtag; // ERR sbdtag IS TSB pointer
601 else
602 rm2ts_e_trn <= rm2ts_e_trn;
603
604
605 //---------------------------------------------------------------------------
606 // TSB Write Data - Registered values that need to be written back to the TSB
607 //---------------------------------------------------------------------------
608
609 always @ (posedge clk)
610 if (~rst_l)
611 begin
612 tsb_wrb_tc <= `FIRE_DLC_TSR_TC_WDTH'b0;
613 tsb_wrb_attr <= `FIRE_DLC_TSR_ATTR_WDTH'b0;
614 tsb_wrb_bcnt <= `FIRE_DLC_TSR_BYTECNT_WDTH'b0;
615 tsb_wrb_reqid <= `FIRE_DLC_TSR_REQID_WDTH'b0;
616 tsb_wrb_tlp_tag <= `FIRE_DLC_TSR_TLPTAG_WDTH'b0;
617 tsb_wrb_adalign <= `FIRE_DLC_TSR_ADALIGN_WDTH'b0;
618 end
619 else if (ld_epe_rcd_tsb)
620 begin
621 tsb_wrb_tc <= tsb_rd_tc; // Unmodified TC field
622 tsb_wrb_attr <= tsb_rd_attr; // Unmodified Attr field
623 tsb_wrb_bcnt <= wrb_bcnt[11:0]; // Calculated wr back remaining byte count
624 tsb_wrb_reqid <= tsb_rd_reqid; // Unmodified Reqid field
625 tsb_wrb_tlp_tag <= tsb_rd_tlp_tag; // Unmodified TLP Tag field
626 tsb_wrb_adalign <= wrb_adalign; // Calculated wr back aligned address
627 end
628 else
629 begin
630 tsb_wrb_tc <= tsb_wrb_tc;
631 tsb_wrb_attr <= tsb_wrb_attr;
632 tsb_wrb_bcnt <= tsb_wrb_bcnt;
633 tsb_wrb_reqid <= tsb_wrb_reqid;
634 tsb_wrb_tlp_tag <= tsb_wrb_tlp_tag;
635 tsb_wrb_adalign <= tsb_wrb_adalign;
636 end
637
638 // Remaining Byte Count -> TSB Read Byte count less Bytes transmitted in EPE DMACplD record
639 // sr_err_addr[11:0] == Packet Record Byte Count (actual bytes transferred in Egress Retire Record
640
641 assign wrb_bcnt = {tsb_rd_bcnt_fourk, tsb_rd_bcnt[11:0]} - // wrb_bcnt is 13 bit field
642 {2'b00, sr_err_addr[10:0]}; // Max payload = 512-sr_err_addr[12:11]=0
643 // tsb_rd_bcnt - {2'b00,sr_err_addr[9:0]}
644
645 // Aligned Address - TSB Address Alignment - Address alignment of next valid DMACplD
646 assign wrb_adalign[6:0] = tsb_rd_adalign + sr_err_addr[6:0];
647
648
649
650 //--------------------------------------------------------------------------------------------
651 // ILU Credit Counter Logic - Establishes whether there is credit to enqueue EPE record to EIL
652 //--------------------------------------------------------------------------------------------
653
654 always @ (posedge clk)
655 if (~rst_l)
656 ilu_credit_cnt <= 3'b100; // Initially sized to IOT FIFO Size - 8
657 else
658 ilu_credit_cnt <= next_ilu_credit_cnt;
659
660
661 // NOTE: Need to put Zero In checker to make sure credit stays within 0 to 4 range!
662
663always @ (next_k2y_rcd_enq or y2k_rcd_deq or ilu_credit_cnt)
664 begin // Combinatorial next_ilu_credit_cnt logic
665
666 next_ilu_credit_cnt = 3'b000; // Just for initialization
667
668 case ({y2k_rcd_deq, next_k2y_rcd_enq}) // synopsys infer_mux
669
670 (2'b01) : // Enqueueing EPE record
671 next_ilu_credit_cnt = ilu_credit_cnt - 1'b1; // Decrement EIL credit
672 (2'b10) : // Dequeueing Record from EIL
673 next_ilu_credit_cnt = ilu_credit_cnt + 1'b1; // Increment EIL credit
674 (2'b00),
675 (2'b11) :
676 next_ilu_credit_cnt = ilu_credit_cnt; // Credit Count Remains the Same
677
678 endcase
679 end
680
681 // RRM <-> ILU Credit Mechanism
682 assign no_epe_rcd_credit = ~|ilu_credit_cnt;
683 // If Credit is 1-4, then OK!!
684 // If Credit is 0 - NOT ok! IOT SR full
685
686//----------------------------------------------
687// Egress State Machine Sequential Logic
688//----------------------------------------------
689
690always @ (posedge clk)
691 if (~rst_l)
692 begin
693 e_state[NUM_STATES-1:0] <= {NUM_STATES{1'b0}}; // Makes sure all OTHER bits are 0
694 e_state[E_PROCESS] <= 1'b1;
695 k2y_rcd_enq <= 1'b0;
696 rm2im_rply_enq <= 1'b0;
697 end
698 else
699 begin
700 e_state <= next_e_state;
701 k2y_rcd_enq <= next_k2y_rcd_enq;
702 rm2im_rply_enq <= next_rm2im_rply_enq;
703 end
704
705
706
707// Egress State Machine Combinatorial (Next State) Logic
708
709
710always @ ( e_state or sr_err_empty or type_decode or no_epe_rcd_credit or
711 tsb_fsm_idle or ld_epe_rcd_tsb )
712
713 begin
714 next_e_state = {NUM_STATES{1'b0}};
715 next_k2y_rcd_enq = 1'b0; // prepare to Enqueue RRM Rcd
716 next_rm2im_rply_enq = 1'b0; // prepare to Enqueue MDO Rply
717
718 ld_epe_rcd_pio = 1'b0; // ld newly formed RRM Rcd
719 ld_mdo_rply_rcd = 1'b0; // ld mondo reply Rcd
720 gen_tsb_access = 1'b0; // ld rm2ts_e_trn AND start TSB fsm
721
722 case(1'b1) // synopsys parallel_case
723 // 0in < case -full
724
725 // E_PROCESS - Data valid at output of SR fifo - FORMULATE RRM Record Depending on Type
726
727 e_state[E_PROCESS] :
728
729 if (~sr_err_empty) // Data at SR Output!
730 begin
731
732 case(type_decode) // 0in < case -full
733
734 (CLASPIO) : // PIO - formulate RRM rcd
735 begin // and advance SR FIFO
736 ld_epe_rcd_pio = 1'b1;
737 if (no_epe_rcd_credit) // Pipe Full - Wait for DEM
738 begin
739 next_e_state[E_FULL] = 1'b1;
740 next_k2y_rcd_enq = 1'b0;
741 end
742 else // Enqueue RRM record to DEM
743 begin
744 next_k2y_rcd_enq = 1'b1;
745 next_e_state[E_PROCESS] = 1'b1;
746 end
747 end
748
749 (CLASMDO) : // Fork Mondo Reply to IMU
750 begin
751 ld_mdo_rply_rcd = 1'b1;
752 next_rm2im_rply_enq = 1'b1;
753 next_e_state[E_PROCESS] = 1'b1;
754 end
755
756
757 (CLASDMA) : // DMA Reply - NEEDS TSB Access!
758 if (tsb_fsm_idle) // TSB FSM able to accept request
759 begin
760 gen_tsb_access = 1'b1;
761 next_e_state[E_TSB_RD] = 1'b1;
762 end
763 else
764 begin
765 gen_tsb_access = 1'b0;
766 next_e_state[E_PROCESS] = 1'b1; // wait for TSB FSM
767 end
768
769 endcase // ends e_state[E_PROCESS] type_decode case statement
770
771 end
772
773 else // SR is EMPTY!!! Keep Default Values
774 next_e_state[E_PROCESS] = 1'b1;
775
776
777
778 // E_TSB_RD - TSB access in process - Enqueue RRM record when data returned from TSB Rd
779
780 e_state[E_TSB_RD] :
781
782 case({ld_epe_rcd_tsb, no_epe_rcd_credit}) // synopsys infer_mux
783
784 // ld_epe_rcd_tsb occurs when
785 (2'b00), // TSB rd access is done
786 (2'b01): // TSB Rd still in progress - wait
787 begin
788 next_k2y_rcd_enq = 1'b0;
789 next_e_state[E_TSB_RD] = 1'b1;
790 end
791
792 (2'b10) : // TSB Rd done - OK to enqueue
793 begin
794 next_k2y_rcd_enq = 1'b1;
795 next_e_state[E_PROCESS] = 1'b1; // process next retire record
796 end
797
798 (2'b11) : // Ready to Enqueue but DEM full
799 begin // Can't Enqueue just yet!
800 next_k2y_rcd_enq = 1'b0;
801 next_e_state[E_FULL] = 1'b1;
802 end
803
804 endcase
805
806
807 // E_FULL - RRM record ready to be enqueued down pipeline but stalled due to DEM being FULL
808
809 e_state[E_FULL] :
810
811 if (no_epe_rcd_credit)
812 begin
813 next_k2y_rcd_enq = 1'b0;
814 next_e_state[E_FULL] = 1'b1;
815 end
816 else
817 begin
818 next_k2y_rcd_enq = 1'b1;
819 next_e_state[E_PROCESS] = 1'b1; // process next retire record
820 end
821
822 endcase // ends e_state 1 hot state machine
823
824end // ends combinatorial always block for e_fsm state machine
825
826
827
828//############################################################################
829// MODULE INSTANTIATIONS
830//############################################################################
831
832
833//---------------------------------------------------
834// Egress Retire Record FIFO = 70 * 8 = 560 registers
835//---------------------------------------------------
836
837fire_dmc_common_srfifo #(E_SR_WIDTH, E_SR_DEPTH) e_sr_fifo (
838 .clk (clk),
839 .rst_l (rst_l),
840 .enq (cm2rm_rcd_enq),
841 .data_in (cm2rm_rcd),
842 .deq (retire_rcd_deq),
843 .data_out (sr_err_dout),
844 .full (rm2cm_rcd_full),
845 .empty (sr_err_empty),
846 .overflow (),
847 .underflow ()
848 );
849
850
851endmodule