Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_clu_crm_pktgen.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 | module dmu_clu_crm_pktgen | |
36 | ( | |
37 | // clock | |
38 | clk, | |
39 | rst_l, | |
40 | ||
41 | // cmu : epr port | |
42 | cl2cm_rcd, | |
43 | ||
44 | // psb : sbd access port | |
45 | cl2ps_e_trn, | |
46 | cl2ps_e_wr_data, | |
47 | psb_rd_bcnt, | |
48 | psb_rd_len, | |
49 | psb_rd_pktseq, | |
50 | psb_rd_cntxtnum, | |
51 | psb_rd_sbdtag, | |
52 | ||
53 | // cru : config packet setup | |
54 | cr2cl_bus_num, | |
55 | ||
56 | // ctm : tag return port | |
57 | crm2ctm_tag, | |
58 | ||
59 | // pkt_gen sel port | |
60 | pkt_sel, | |
61 | psb_ld, | |
62 | trn_sel, | |
63 | epr_ld, | |
64 | done_psb_rd, | |
65 | ||
66 | // dcr port | |
67 | dcr_cmd, | |
68 | dcr_ctag_typ, | |
69 | dcr_ctag_trnsnum, | |
70 | dcr_ctag_dptr, | |
71 | dcr_pktag, | |
72 | ||
73 | // pcr port | |
74 | pcr_cmd, | |
75 | pcr_addr, | |
76 | pcr_bmsk, | |
77 | pcr_ctag_trnsnum, | |
78 | //BP n2 5-24-04 | |
79 | // pcr_ctag_agntid, | |
80 | // pcr_ctag_trnsid, | |
81 | pcr_ctag_thrdid, | |
82 | ||
83 | // urr port | |
84 | urr_typ, | |
85 | urr_sbdtag, | |
86 | ||
87 | // type port | |
88 | mdo_vld, | |
89 | drd_vld, | |
90 | tdr_vld, | |
91 | pcr_typ | |
92 | ); | |
93 | ||
94 | // >>>>>>>>>>>>>>>>>>>>>>>>> Parameter Declarations <<<<<<<<<<<<<<<<<<<<<<<<< | |
95 | ||
96 | // -------------------------------------------------------- | |
97 | // DMA/INT Command Record (DCR) Field Widths | |
98 | // -------------------------------------------------------- | |
99 | ||
100 | parameter DCR_CMD_WDTH = `FIRE_J2D_DI_CMD_WDTH, | |
101 | DCR_PKTAG_WDTH = 5, | |
102 | DCTAG_DPTR_WDTH = 5, | |
103 | DCTAG_TRNSNUM_WDTH = 4; | |
104 | ||
105 | // -------------------------------------------------------- | |
106 | // PIO Command Record (PCR) Field Widths | |
107 | // -------------------------------------------------------- | |
108 | ||
109 | parameter PCR_CMD_WDTH = `FIRE_J2D_P_CMD_WDTH, | |
110 | PCR_ADDR_WDTH = `FIRE_J2D_P_ADDR_WDTH, | |
111 | PCR_BMSK_WDTH = `FIRE_J2D_P_BMSK_WDTH, | |
112 | PCTAG_TRNSNUM_WDTH = 4, | |
113 | //BP n2 5-24-04 | |
114 | // PCTAG_AGNTID_WDTH = 4, | |
115 | // PCTAG_TRNSID_WDTH = 2; | |
116 | PCTAG_THRDID_WDTH = 7; | |
117 | ||
118 | // -------------------------------------------------------- | |
119 | // PIO JBC-to-DMC Command Encoding | |
120 | // -------------------------------------------------------- | |
121 | ||
122 | parameter PWR_BLK_M64 = 4'b0000, | |
123 | PWR_BLK_M32 = 4'b0001, | |
124 | PWR_16B_M64 = 4'b0100, | |
125 | PWR_16B_M32 = 4'b0101, | |
126 | PWR_16B_IO = 4'b0110, | |
127 | PWR_16B_CFG = 4'b0111, | |
128 | PRD_BLK_M64 = 4'b1000, | |
129 | PRD_BLK_M32 = 4'b1001, | |
130 | PRD_16B_M64 = 4'b1100, | |
131 | PRD_16B_M32 = 4'b1101, | |
132 | PRD_16B_IO = 4'b1110, | |
133 | PRD_16B_CFG = 4'b1111; | |
134 | ||
135 | // -------------------------------------------------------- | |
136 | // Unsupported Request Record (URR) Type Encoding | |
137 | // -------------------------------------------------------- | |
138 | ||
139 | parameter DMA_MRD_ERR = 3'b001, | |
140 | DMA_MRD_LK = 3'b010, | |
141 | UNS_REQ = 3'b100; | |
142 | ||
143 | // -------------------------------------------------------- | |
144 | // Egress Packet Record (EPR) Type Encoding | |
145 | // -------------------------------------------------------- | |
146 | ||
147 | parameter PIO_MRD_32BIT = 7'b00_00000, | |
148 | PIO_MRD_64BIT = 7'b01_00000, | |
149 | PIO_IORD = 7'b00_00010, | |
150 | PIO_CFGRD_TYP0 = 7'b00_00100, | |
151 | PIO_CFGRD_TYP1 = 7'b00_00101, | |
152 | PIO_MWR_32BIT = 7'b10_00000, | |
153 | PIO_MWR_64BIT = 7'b11_00000, | |
154 | PIO_IOWR = 7'b10_00010, | |
155 | PIO_CFGWR_TYP0 = 7'b10_00100, | |
156 | PIO_CFGWR_TYP1 = 7'b10_00101, | |
157 | MDO_RPLY = 7'b11_11010, | |
158 | DMA_CPL = 7'b00_01010, | |
159 | DMA_CPLLK = 7'b00_01011, | |
160 | DMA_CPLD = 7'b10_01010; | |
161 | ||
162 | // -------------------------------------------------------- | |
163 | // Valid EPR Length Encodings | |
164 | // -------------------------------------------------------- | |
165 | ||
166 | parameter ONE_DW = `FIRE_DLC_EPR_LEN_WDTH'h1, | |
167 | TWO_DW = `FIRE_DLC_EPR_LEN_WDTH'h2, | |
168 | FOUR_DW = `FIRE_DLC_EPR_LEN_WDTH'h4, | |
169 | SIXTEEN_DW = `FIRE_DLC_EPR_LEN_WDTH'h10; | |
170 | ||
171 | // >>>>>>>>>>>>>>>>>>>>>>>>> Port Declarations <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
172 | ||
173 | // -------------------------------------------------------- | |
174 | // Clock Signal | |
175 | // -------------------------------------------------------- | |
176 | ||
177 | input clk; | |
178 | input rst_l; | |
179 | ||
180 | // -------------------------------------------------------- | |
181 | // CMU Interface | |
182 | // -------------------------------------------------------- | |
183 | ||
184 | // egress pkt rcd | |
185 | output [(`FIRE_DLC_EPR_REC_WDTH - 1):0] cl2cm_rcd; | |
186 | ||
187 | // -------------------------------------------------------- | |
188 | // PSB Interface | |
189 | // -------------------------------------------------------- | |
190 | ||
191 | // scoreboard access port | |
192 | output [(`FIRE_DLC_PSR_TRN_WDTH - 1):0] cl2ps_e_trn; | |
193 | output [(`FIRE_DLC_PSR_PIO_DATA_WDTH - 1):0] cl2ps_e_wr_data; | |
194 | input [(`FIRE_DLC_PSR_BYTECNT_WDTH - 1):0] psb_rd_bcnt; | |
195 | input [(`FIRE_DLC_PSR_LENGTH_WDTH - 1):0] psb_rd_len; | |
196 | input [(`FIRE_DLC_PSR_PKSEQ_WDTH - 1):0] psb_rd_pktseq; | |
197 | input [(`FIRE_DLC_PSR_CNTX_WDTH - 1):0] psb_rd_cntxtnum; | |
198 | input [(`FIRE_DLC_PSR_TRTAG_WDTH - 1):0] psb_rd_sbdtag; | |
199 | ||
200 | // -------------------------------------------------------- | |
201 | // CRU Interface | |
202 | // -------------------------------------------------------- | |
203 | ||
204 | // ----- Config Packet Setup ----- | |
205 | input [`FIRE_PCIE_BUS_NUM_BITS] cr2cl_bus_num; | |
206 | ||
207 | // -------------------------------------------------------- | |
208 | // CTM Interface | |
209 | // -------------------------------------------------------- | |
210 | ||
211 | // dma/int tag return | |
212 | output [3:0] crm2ctm_tag; | |
213 | ||
214 | // -------------------------------------------------------- | |
215 | // PktGen Control Port | |
216 | // -------------------------------------------------------- | |
217 | ||
218 | input [1:0] pkt_sel; | |
219 | input psb_ld; | |
220 | input [1:0] trn_sel; | |
221 | input epr_ld; | |
222 | input done_psb_rd; | |
223 | ||
224 | // -------------------------------------------------------- | |
225 | // DCR Port | |
226 | // -------------------------------------------------------- | |
227 | ||
228 | input [(DCR_CMD_WDTH - 1):0] dcr_cmd; | |
229 | input dcr_ctag_typ; | |
230 | input [(DCTAG_TRNSNUM_WDTH - 1):0] dcr_ctag_trnsnum; | |
231 | input [(DCTAG_DPTR_WDTH - 1):0] dcr_ctag_dptr; | |
232 | input [(DCR_PKTAG_WDTH - 1):0] dcr_pktag; | |
233 | ||
234 | // -------------------------------------------------------- | |
235 | // PCR Port | |
236 | // -------------------------------------------------------- | |
237 | ||
238 | input [(PCR_CMD_WDTH - 1):0] pcr_cmd; | |
239 | input [(PCR_ADDR_WDTH - 1):0] pcr_addr; | |
240 | input [(PCR_BMSK_WDTH - 1):0] pcr_bmsk; | |
241 | input [(PCTAG_TRNSNUM_WDTH - 1):0] pcr_ctag_trnsnum; | |
242 | // BP n2 5-24-04 | |
243 | // input [(PCTAG_AGNTID_WDTH - 1):0] pcr_ctag_agntid; | |
244 | // input [(PCTAG_TRNSID_WDTH - 1):0] pcr_ctag_trnsid; | |
245 | input [(PCTAG_THRDID_WDTH - 1):0] pcr_ctag_thrdid; | |
246 | ||
247 | // -------------------------------------------------------- | |
248 | // URR Port | |
249 | // -------------------------------------------------------- | |
250 | ||
251 | input [(`FIRE_DLC_CLU_URR_TYP_WDTH - 1):0] urr_typ; | |
252 | input [(`FIRE_DLC_CLU_URR_SBDTAG_WDTH - 1):0] urr_sbdtag; | |
253 | ||
254 | // -------------------------------------------------------- | |
255 | // Type Port | |
256 | // -------------------------------------------------------- | |
257 | ||
258 | output mdo_vld; | |
259 | output drd_vld; | |
260 | output tdr_vld; | |
261 | output pcr_typ; | |
262 | ||
263 | // >>>>>>>>>>>>>>>>>>>>>>>>> Data Type Declarations <<<<<<<<<<<<<<<<<<<<<<<<< | |
264 | ||
265 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ REGISTERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
266 | ||
267 | // ********** Flops ********** | |
268 | ||
269 | // ctm tag return | |
270 | reg [3:0] crm2ctm_tag; | |
271 | ||
272 | // epr field registers | |
273 | reg [(`FIRE_DLC_EPR_TYP_WDTH - 1):0] epr_typ; | |
274 | reg [(`FIRE_DLC_EPR_LEN_WDTH - 1):0] epr_len; | |
275 | reg [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] epr_ldwbe; | |
276 | reg [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] epr_fdwbe; | |
277 | reg [(`FIRE_DLC_EPR_ADDR_WDTH - 1):0] epr_addr; | |
278 | reg [(`FIRE_DLC_EPR_SBDTAG_WDTH - 1):0] epr_sbdtag; | |
279 | reg [(`FIRE_DLC_EPR_DPTR_WDTH - 1):0] epr_dptr; | |
280 | reg [(`FIRE_DLC_EPR_PKSEQNUM_WDTH - 1):0] epr_pkseqnum; | |
281 | reg [(`FIRE_DLC_EPR_CNTXTNUM_WDTH - 1):0] epr_cntxtnum; | |
282 | ||
283 | // psb interface registers | |
284 | reg [(`FIRE_DLC_PSR_TRN_WDTH - 1):0] cl2ps_e_trn; | |
285 | reg [(`FIRE_DLC_PSR_PIO_DATA_WDTH - 1):0] cl2ps_e_wr_data; | |
286 | ||
287 | // ********** Non-Flops ****** | |
288 | ||
289 | reg [2:0] fdwbe_2to0; | |
290 | ||
291 | // dcr pktgen field declarations | |
292 | reg [(`FIRE_DLC_EPR_TYP_WDTH - 1):0] dcr_pkt_typ; | |
293 | ||
294 | // pcr pktgen field declarations | |
295 | reg [(`FIRE_DLC_EPR_TYP_WDTH - 1):0] pcr_pkt_typ; | |
296 | reg [(`FIRE_DLC_EPR_LEN_WDTH - 1):0] pcr_pkt_len; | |
297 | reg [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] pcr_pkt_ldwbe; | |
298 | reg [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] pcr_pkt_fdwbe; | |
299 | ||
300 | // urr field declarations | |
301 | reg [(`FIRE_DLC_EPR_TYP_WDTH - 1):0] urr_pkt_typ; | |
302 | ||
303 | // epr field declarations | |
304 | reg [(`FIRE_DLC_EPR_TYP_WDTH - 1):0] nxt_epr_typ; | |
305 | reg [(`FIRE_DLC_EPR_LEN_WDTH - 1):0] nxt_epr_len; | |
306 | reg [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] nxt_epr_fdwbe; | |
307 | reg [(`FIRE_DLC_EPR_ADDR_WDTH - 1):0] nxt_epr_addr; | |
308 | reg [(`FIRE_DLC_EPR_SBDTAG_WDTH - 1):0] nxt_epr_sbdtag; | |
309 | reg [(`FIRE_DLC_EPR_DPTR_WDTH - 1):0] nxt_epr_dptr; | |
310 | ||
311 | // pcr variables | |
312 | reg pcfg_typ; | |
313 | reg [19:0] paddr_31to12; | |
314 | ||
315 | // psb interface | |
316 | reg [(`FIRE_DLC_PSR_TRN_WDTH - 1):0] nxt_psb_trn; | |
317 | ||
318 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ NETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
319 | ||
320 | // dcr field declarations | |
321 | wire [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] dcr_pkt_fdwbe; | |
322 | wire [(`FIRE_DLC_EPR_DPTR_WDTH - 1):0] dcr_pkt_dptr; | |
323 | ||
324 | // pcr pktgen field declarations | |
325 | wire [(`FIRE_DLC_EPR_ADDR_WDTH - 1):0] pcr_pkt_addr; | |
326 | wire [(`FIRE_DLC_EPR_SBDTAG_WDTH - 1):0] pcr_pkt_sbdtag; | |
327 | wire [(`FIRE_DLC_EPR_DPTR_WDTH - 1):0] pcr_pkt_dptr; | |
328 | ||
329 | // urr field declarations | |
330 | wire [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] urr_pkt_fdwbe; | |
331 | ||
332 | // epr field declarations | |
333 | wire [(`FIRE_DLC_EPR_DWBE_WDTH/2 - 1):0] nxt_epr_ldwbe; | |
334 | wire [(`FIRE_DLC_EPR_PKSEQNUM_WDTH - 1):0] nxt_epr_pkseqnum; | |
335 | wire [(`FIRE_DLC_EPR_CNTXTNUM_WDTH - 1):0] nxt_epr_cntxtnum; | |
336 | ||
337 | // dcr variables | |
338 | wire [2:0] cpl_sts; | |
339 | wire [1:0] mdo_tag; | |
340 | wire mdo_sts; | |
341 | ||
342 | // pcr variables | |
343 | wire pbmsk_dw3_vld; | |
344 | wire pbmsk_dw2_vld; | |
345 | wire pbmsk_dw1_vld; | |
346 | wire pbmsk_dw0_vld; | |
347 | ||
348 | // >>>>>>>>>>>>>>>>>>>>>>>>> 0-in Checkers <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
349 | ||
350 | /* 0in bits_on | |
351 | -var {mdo_vld, drd_vld, tdr_vld} | |
352 | -active ~`CPU.dmu.dmc.clu.crm.dcr_fifo_empty | |
353 | */ | |
354 | ||
355 | // >>>>>>>>>>>>>>>>>>>>>>>>> RTL Model <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
356 | ||
357 | // -------------------------------------------------------- | |
358 | // DCR-TO-EPR PKTGEN (DMA/MDO PROCESSING) | |
359 | // -------------------------------------------------------- | |
360 | ||
361 | // ----- Type Decode -------------------------------------------------------- | |
362 | ||
363 | // packet encoding | |
364 | always @(dcr_cmd) | |
365 | if (dcr_cmd[1]) | |
366 | dcr_pkt_typ = MDO_RPLY; | |
367 | else | |
368 | dcr_pkt_typ = DMA_CPLD; | |
369 | ||
370 | // type indicators | |
371 | assign mdo_vld = dcr_cmd[1]; | |
372 | assign drd_vld = ~dcr_cmd[1] & ~dcr_ctag_typ; | |
373 | assign tdr_vld = ~dcr_cmd[1] & dcr_ctag_typ; | |
374 | ||
375 | // ----- First DWBE Gen ----------------------------------------------------- | |
376 | ||
377 | // cpl_sts for dma cpl is always successfull -> 000 | |
378 | assign cpl_sts = 3'b000; | |
379 | ||
380 | // mdo_tag is taken from bits 2:1 of dcr_pktag field | |
381 | assign mdo_tag = dcr_pktag[1:0]; | |
382 | ||
383 | // =================================================== | |
384 | // mdo_sts info | |
385 | // | |
386 | // dcr_cmd[1:0] : 11 = int ack, 10 = int nack | |
387 | // dcr_cmd[0] differs int ack from int nack | |
388 | // | |
389 | // mdo_sts : 1 = ack, 0 = nack | |
390 | // mapping dcr_cmd[0] to mdo_sts sets mdo_sts | |
391 | // ==================================================== | |
392 | ||
393 | assign mdo_sts = dcr_cmd[0]; | |
394 | ||
395 | // formulate fdwbe[2:0] | |
396 | always @(dcr_cmd[1] or cpl_sts or mdo_tag or mdo_sts) | |
397 | if (dcr_cmd[1]) // 0 = dma, 1 = mdo | |
398 | fdwbe_2to0 = {mdo_tag, mdo_sts}; | |
399 | else | |
400 | fdwbe_2to0 = cpl_sts; | |
401 | ||
402 | // construct fdwbe : fdwbe[3] is rsv for all dcr types | |
403 | assign dcr_pkt_fdwbe = {1'b0, fdwbe_2to0}; | |
404 | ||
405 | // ----- DPTR Gen ----------------------------------------------------------- | |
406 | ||
407 | // msb of dptr indicates DOU section : 0 = dma, 1 = pio | |
408 | assign dcr_pkt_dptr = {1'b0, dcr_ctag_dptr}; | |
409 | ||
410 | // -------------------------------------------------------- | |
411 | // PCR-TO-EPR PKTGEN (PIO PROCESSING) | |
412 | // -------------------------------------------------------- | |
413 | ||
414 | // ----- Type Decode -------------------------------------------------------- | |
415 | ||
416 | // cfg typ : typ0 -> pkt_bus# == prog_bus#; typ1-> pkt_bus# != prog_bus# | |
417 | always @(cr2cl_bus_num or pcr_addr[27:20]) | |
418 | if (cr2cl_bus_num == pcr_addr[27:20]) | |
419 | pcfg_typ = 1'b0; | |
420 | else | |
421 | pcfg_typ = 1'b1; | |
422 | ||
423 | // packet encoding | |
424 | always @(pcr_cmd or pcfg_typ) | |
425 | begin | |
426 | ||
427 | // initialization | |
428 | pcr_pkt_typ = {`FIRE_DLC_EPR_TYP_WDTH{1'b0}}; | |
429 | ||
430 | case (pcr_cmd) | |
431 | ||
432 | /* 0in < case -parallel -full | |
433 | -active ~`CPU.dmu.dmc.clu.crm.pcr_fifo_empty | |
434 | */ | |
435 | ||
436 | // PIO MEM RD | |
437 | PRD_BLK_M32, | |
438 | PRD_16B_M32 : pcr_pkt_typ = PIO_MRD_32BIT; | |
439 | PRD_BLK_M64, | |
440 | PRD_16B_M64 : pcr_pkt_typ = PIO_MRD_64BIT; | |
441 | ||
442 | // PIO IO RD | |
443 | PRD_16B_IO : pcr_pkt_typ = PIO_IORD; | |
444 | ||
445 | // PIO CFG RD | |
446 | PRD_16B_CFG : | |
447 | if (pcfg_typ) | |
448 | pcr_pkt_typ = PIO_CFGRD_TYP1; | |
449 | else | |
450 | pcr_pkt_typ = PIO_CFGRD_TYP0; | |
451 | ||
452 | // PIO MEM WR | |
453 | PWR_BLK_M32, | |
454 | PWR_16B_M32 : pcr_pkt_typ = PIO_MWR_32BIT; | |
455 | PWR_BLK_M64, | |
456 | PWR_16B_M64 : pcr_pkt_typ = PIO_MWR_64BIT; | |
457 | ||
458 | // PIO IO WR | |
459 | PWR_16B_IO : pcr_pkt_typ = PIO_IOWR; | |
460 | ||
461 | // PIO CFG WR | |
462 | PWR_16B_CFG : | |
463 | if (pcfg_typ) | |
464 | pcr_pkt_typ = PIO_CFGWR_TYP1; | |
465 | else | |
466 | pcr_pkt_typ = PIO_CFGWR_TYP0; | |
467 | ||
468 | endcase | |
469 | end | |
470 | ||
471 | // type indicator | |
472 | assign pcr_typ = pcr_cmd[3]; // 0 = write, 1 = read | |
473 | ||
474 | // ----- Len & First/Last DWBE Gen ------------------------------------------ | |
475 | ||
476 | // bmsk valid dw scan | |
477 | assign pbmsk_dw3_vld = |pcr_bmsk[15:12]; | |
478 | assign pbmsk_dw2_vld = |pcr_bmsk[11:8]; | |
479 | assign pbmsk_dw1_vld = |pcr_bmsk[7:4]; | |
480 | assign pbmsk_dw0_vld = |pcr_bmsk[3:0]; | |
481 | ||
482 | // len & f/l_dwbe gen: pcr_cmd[2] -> 0 = 64 byte, 1 = 16 byte | |
483 | always @(pcr_cmd[2] or pbmsk_dw3_vld or pbmsk_dw2_vld or | |
484 | pbmsk_dw1_vld or pbmsk_dw0_vld or pcr_bmsk) | |
485 | begin | |
486 | ||
487 | // initialization | |
488 | pcr_pkt_len = {`FIRE_DLC_EPR_LEN_WDTH{1'b0}}; | |
489 | pcr_pkt_ldwbe = {`FIRE_DLC_EPR_DWBE_WDTH/2{1'b0}}; | |
490 | pcr_pkt_fdwbe = {`FIRE_DLC_EPR_DWBE_WDTH/2{1'b0}}; | |
491 | ||
492 | casez ({pcr_cmd[2], pbmsk_dw3_vld, pbmsk_dw2_vld, pbmsk_dw1_vld, | |
493 | pbmsk_dw0_vld}) | |
494 | ||
495 | /* 0in < case -parallel -full | |
496 | -active ~`CPU.dmu.dmc.clu.crm.pcr_fifo_empty | |
497 | */ | |
498 | ||
499 | // PIO64: | |
500 | // len = 16DW; fdwbe = 0xF; ldwbe = 0xF | |
501 | 5'b0_zzzz : | |
502 | begin | |
503 | pcr_pkt_len = SIXTEEN_DW; | |
504 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b1}}; | |
505 | pcr_pkt_fdwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b1}}; | |
506 | end | |
507 | ||
508 | // PIO16 | |
509 | // len = 0DW; fdwbe = 0x0; ldwbe = 0x0 | |
510 | 5'b1_0000 : | |
511 | begin | |
512 | pcr_pkt_len = ONE_DW; | |
513 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
514 | pcr_pkt_fdwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
515 | end | |
516 | ||
517 | // PIO16 | |
518 | // len = 1DW, DW0; fdwbe = jbc_bmsk[0:3]; ldwbe = 0x0 | |
519 | 5'b1_0001 : | |
520 | begin | |
521 | pcr_pkt_len = ONE_DW; | |
522 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
523 | pcr_pkt_fdwbe = {pcr_bmsk[0], pcr_bmsk[1], pcr_bmsk[2], | |
524 | pcr_bmsk[3]}; | |
525 | end | |
526 | ||
527 | // PIO16 | |
528 | // len = 1DW, DW1; fdwbe = jbc_bmsk[4:7]; ldwbe = 0x0 | |
529 | 5'b1_0010 : | |
530 | begin | |
531 | pcr_pkt_len = ONE_DW; | |
532 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
533 | pcr_pkt_fdwbe = {pcr_bmsk[4], pcr_bmsk[5], pcr_bmsk[6], | |
534 | pcr_bmsk[7]}; | |
535 | end | |
536 | ||
537 | // PIO16 | |
538 | // len = 1DW, DW2; fdwbe = jbc_bmsk[8:11]; ldwbe = 0x0 | |
539 | 5'b1_0100 : | |
540 | begin | |
541 | pcr_pkt_len = ONE_DW; | |
542 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
543 | pcr_pkt_fdwbe = {pcr_bmsk[8], pcr_bmsk[9], pcr_bmsk[10], | |
544 | pcr_bmsk[11]}; | |
545 | end | |
546 | ||
547 | // PIO16 | |
548 | // len = 1DW, DW3; fdwbe = jbc_bmsk[12:15]; ldwbe = 0x0 | |
549 | 5'b1_1000 : | |
550 | begin | |
551 | pcr_pkt_len = ONE_DW; | |
552 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
553 | pcr_pkt_fdwbe = {pcr_bmsk[12], pcr_bmsk[13], pcr_bmsk[14], | |
554 | pcr_bmsk[15]}; | |
555 | end | |
556 | ||
557 | // PIO16 | |
558 | // len = 2DW, DW01; fdwbe = jbc_bmsk[4:7]; ldwbe = jbc_bmsk[0:3] | |
559 | 5'b1_0011 : | |
560 | begin | |
561 | pcr_pkt_len = TWO_DW; | |
562 | pcr_pkt_ldwbe = {pcr_bmsk[0], pcr_bmsk[1], pcr_bmsk[2], | |
563 | pcr_bmsk[3]}; | |
564 | pcr_pkt_fdwbe = {pcr_bmsk[4], pcr_bmsk[5], pcr_bmsk[6], | |
565 | pcr_bmsk[7]}; | |
566 | end | |
567 | ||
568 | // PIO16 | |
569 | // len = 2DW, DW23; fdwbe = jbc_bmsk[12:15]; ldwbe = jbc_bmsk[8:11] | |
570 | 5'b1_1100 : | |
571 | begin | |
572 | pcr_pkt_len = TWO_DW; | |
573 | pcr_pkt_ldwbe = {pcr_bmsk[8], pcr_bmsk[9], pcr_bmsk[10], | |
574 | pcr_bmsk[11]}; | |
575 | pcr_pkt_fdwbe = {pcr_bmsk[12], pcr_bmsk[13], pcr_bmsk[14], | |
576 | pcr_bmsk[15]}; | |
577 | end | |
578 | ||
579 | // PIO16 | |
580 | // len = 4DW; fdwbe = 0xF; ldwbe = 0xF | |
581 | 5'b1_1111 : | |
582 | begin | |
583 | pcr_pkt_len = FOUR_DW; | |
584 | pcr_pkt_ldwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b1}}; | |
585 | pcr_pkt_fdwbe = {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b1}}; | |
586 | end | |
587 | ||
588 | endcase | |
589 | end | |
590 | ||
591 | // ----- Addr Gen ----------------------------------------------------------- | |
592 | ||
593 | // set addr[31:12] for cfg/non-cfg transactions | |
594 | always @(pcr_cmd[2:0] or pcr_addr[31:12]) | |
595 | if (&pcr_cmd[2:0]) | |
596 | paddr_31to12 = pcr_addr[31:12] << 4; | |
597 | else | |
598 | paddr_31to12 = pcr_addr[31:12]; | |
599 | ||
600 | // set addr[34:2] for all transactions | |
601 | assign pcr_pkt_addr = {pcr_addr[35:32], paddr_31to12, pcr_addr[11:2]}; | |
602 | ||
603 | // ----- Sbdtag Gen --------------------------------------------------------- | |
604 | ||
605 | // =================================================== | |
606 | // tlp_tag info | |
607 | // pcr_cmd[3] -> 0 = wr, 1 = rd | |
608 | // tlp_tag[4] -> 0 = rd, 1 = wr | |
609 | // | |
610 | // mapping pcr_cmd[3] to tlp_tag[4] sets the type | |
611 | // ==================================================== | |
612 | ||
613 | assign pcr_pkt_sbdtag = {~pcr_cmd[3], pcr_ctag_trnsnum}; | |
614 | ||
615 | // ----- Dptr Gen ----------------------------------------------------------- | |
616 | ||
617 | // msb of dptr indicates DOU section : 1'b0 = dma, 1'b1 = pio | |
618 | assign pcr_pkt_dptr = {2'b10, pcr_ctag_trnsnum}; | |
619 | ||
620 | // -------------------------------------------------------- | |
621 | // URR-TO-EPR PKTGEN (UNSUPPORTED REQ PROCESSING) | |
622 | // -------------------------------------------------------- | |
623 | ||
624 | // ----- Type Decode -------------------------------------------------------- | |
625 | ||
626 | // packet encoding | |
627 | always @(urr_typ) | |
628 | begin | |
629 | ||
630 | // initialization | |
631 | urr_pkt_typ = {`FIRE_DLC_EPR_TYP_WDTH{1'b0}}; | |
632 | ||
633 | case (urr_typ) | |
634 | ||
635 | /* 0in < case -parallel -full | |
636 | -active ~`CPU.dmu.dmc.clu.crm.urr_fifo_empty | |
637 | */ | |
638 | ||
639 | // CPL | |
640 | DMA_MRD_ERR, UNS_REQ : urr_pkt_typ = DMA_CPL; | |
641 | // CPLLK | |
642 | DMA_MRD_LK : urr_pkt_typ = DMA_CPLLK; | |
643 | ||
644 | endcase | |
645 | end | |
646 | ||
647 | // ----- First DWBE Gen ----------------------------------------------------- | |
648 | ||
649 | // =================================================== | |
650 | // fdwbe[2:0] = cpl_sts[2:0] | |
651 | // | |
652 | // urr_type cpl_sts | |
653 | // ---------------- ----------------------------- | |
654 | // 3'b001 -> MRDERR : 3'b100 -> completer abort | |
655 | // 3'b010 -> UR : 3'b001 -> unsupported request | |
656 | // 3'b100 -> MRDLK : 3'b001 -> unsupported request | |
657 | // | |
658 | // cpl_sts[2] = type[0] | |
659 | // cpl_sts[1] = 1'b0 | |
660 | // cpl_sts[0] = type[2] | type[1] | |
661 | // =================================================== | |
662 | ||
663 | assign urr_pkt_fdwbe = {1'b0, urr_typ[0], 1'b0, (urr_typ[2] | urr_typ[1])}; | |
664 | ||
665 | // -------------------------------------------------------- | |
666 | // EPR GEN | |
667 | // -------------------------------------------------------- | |
668 | ||
669 | // ########################################################################## | |
670 | ||
671 | // ----- select typ and fdwbe : from dcr/pcr/urr fifos ----- | |
672 | always @(pkt_sel or dcr_pkt_typ or dcr_pkt_fdwbe or pcr_pkt_typ or | |
673 | pcr_pkt_fdwbe or urr_pkt_typ or urr_pkt_fdwbe) | |
674 | begin | |
675 | ||
676 | // 1st_dwbe[3] is rsv for all dcr/urr types - only one extra mux | |
677 | ||
678 | case (pkt_sel) // synopsys infer_mux | |
679 | ||
680 | // sel dcr pkt | |
681 | 2'b00 : | |
682 | begin | |
683 | nxt_epr_typ = dcr_pkt_typ; | |
684 | nxt_epr_fdwbe = dcr_pkt_fdwbe; | |
685 | end | |
686 | ||
687 | // sel pcr pkt | |
688 | 2'b01 : | |
689 | begin | |
690 | nxt_epr_typ = pcr_pkt_typ; | |
691 | nxt_epr_fdwbe = pcr_pkt_fdwbe; | |
692 | end | |
693 | ||
694 | // sel urr pkt | |
695 | 2'b10, 2'b11 : | |
696 | begin | |
697 | nxt_epr_typ = urr_pkt_typ; | |
698 | nxt_epr_fdwbe = urr_pkt_fdwbe; | |
699 | end | |
700 | ||
701 | endcase | |
702 | end | |
703 | ||
704 | // ########################################################################## | |
705 | ||
706 | // ----- select dptr : from dcr/pcr fifos ----- | |
707 | always @(pkt_sel or dcr_pkt_dptr or pcr_pkt_dptr) | |
708 | begin | |
709 | ||
710 | case (pkt_sel) // synopsys infer_mux | |
711 | ||
712 | // sel dcr pkt | |
713 | 2'b00 : | |
714 | begin | |
715 | nxt_epr_dptr = dcr_pkt_dptr; | |
716 | end | |
717 | ||
718 | // sel pcr pkt | |
719 | 2'b01 : | |
720 | begin | |
721 | nxt_epr_dptr = pcr_pkt_dptr; | |
722 | end | |
723 | ||
724 | // sel urr pkt : dptr is rsv for all urr types | |
725 | 2'b10, 2'b11 : | |
726 | begin | |
727 | nxt_epr_dptr = {`FIRE_DLC_EPR_DPTR_WDTH{1'b0}}; | |
728 | end | |
729 | ||
730 | endcase | |
731 | end | |
732 | ||
733 | // ########################################################################## | |
734 | ||
735 | // ----- select len, addr, sbdtag : from pcr fifo or psb (dcr/urr) ----- | |
736 | always @(done_psb_rd or pcr_pkt_len or pcr_pkt_addr or pcr_pkt_sbdtag or | |
737 | psb_rd_len or psb_rd_bcnt or psb_rd_sbdtag) | |
738 | begin | |
739 | ||
740 | // addr[33:12] rsv for all dcr/urr types | |
741 | nxt_epr_addr[33:12] = pcr_pkt_addr[33:12]; | |
742 | ||
743 | case (done_psb_rd) // synopsys infer_mux | |
744 | ||
745 | // sel pcr pkt (default to pcr) | |
746 | 1'b0 : | |
747 | begin | |
748 | nxt_epr_len = pcr_pkt_len; | |
749 | nxt_epr_addr[11:0] = pcr_pkt_addr[11:0]; | |
750 | nxt_epr_sbdtag = pcr_pkt_sbdtag; | |
751 | end | |
752 | ||
753 | // note : len, sbdtag & addr[11:0] is rsv for dcr-mdo_cpl, but | |
754 | // used for other dcr types | |
755 | ||
756 | // sel dcr/urr pkt (from psb) | |
757 | 1'b1 : | |
758 | begin | |
759 | nxt_epr_len = psb_rd_len; | |
760 | nxt_epr_addr[11:0] = psb_rd_bcnt; | |
761 | nxt_epr_sbdtag = psb_rd_sbdtag; | |
762 | end | |
763 | ||
764 | endcase | |
765 | end | |
766 | ||
767 | // ########################################################################## | |
768 | ||
769 | // select ldwbe : rsv for all dcr/urr types | |
770 | assign nxt_epr_ldwbe = pcr_pkt_ldwbe; | |
771 | ||
772 | // select pkseq# and cntxt# : rsv for all pcr types and dcr-mdo_cpls | |
773 | assign nxt_epr_pkseqnum = psb_rd_pktseq; | |
774 | assign nxt_epr_cntxtnum = psb_rd_cntxtnum; | |
775 | ||
776 | // ########################################################################## | |
777 | ||
778 | // register epr fields that do not involve psb | |
779 | always @(posedge clk) | |
780 | if (~rst_l) | |
781 | begin | |
782 | epr_typ <= `FIRE_DLC_EPR_TYP_WDTH'b0; | |
783 | epr_ldwbe <= {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
784 | epr_fdwbe <= {(`FIRE_DLC_EPR_DWBE_WDTH/2){1'b0}}; | |
785 | epr_dptr <= `FIRE_DLC_EPR_DPTR_WDTH'b0; | |
786 | end | |
787 | else if (epr_ld) | |
788 | begin | |
789 | epr_typ <= nxt_epr_typ; | |
790 | epr_ldwbe <= nxt_epr_ldwbe; | |
791 | epr_fdwbe <= nxt_epr_fdwbe; | |
792 | epr_dptr <= nxt_epr_dptr; | |
793 | end | |
794 | ||
795 | // register epr fields that require psb access | |
796 | always @(posedge clk) | |
797 | if (~rst_l) | |
798 | begin | |
799 | epr_len <= `FIRE_DLC_EPR_LEN_WDTH'b0; | |
800 | epr_addr <= `FIRE_DLC_EPR_ADDR_WDTH'b0; | |
801 | epr_sbdtag <= `FIRE_DLC_EPR_SBDTAG_WDTH'b0; | |
802 | epr_pkseqnum <= `FIRE_DLC_EPR_PKSEQNUM_WDTH'b0; | |
803 | epr_cntxtnum <= `FIRE_DLC_EPR_CNTXTNUM_WDTH'b0; | |
804 | end | |
805 | else if (done_psb_rd | epr_ld) | |
806 | begin | |
807 | epr_len <= nxt_epr_len; | |
808 | epr_addr <= nxt_epr_addr; | |
809 | epr_sbdtag <= nxt_epr_sbdtag; | |
810 | epr_pkseqnum <= nxt_epr_pkseqnum; | |
811 | epr_cntxtnum <= nxt_epr_cntxtnum; | |
812 | end | |
813 | ||
814 | // output egress pkt rcd | |
815 | assign cl2cm_rcd = {epr_typ, epr_len, epr_ldwbe, epr_fdwbe, epr_addr, | |
816 | epr_sbdtag, epr_dptr, epr_pkseqnum, epr_cntxtnum}; | |
817 | ||
818 | // -------------------------------------------------------- | |
819 | // PSB INTERFACE (TRN/WRDATA) | |
820 | // -------------------------------------------------------- | |
821 | ||
822 | // next psb trn : pkt_sel -> 00 = dma, 01 = pio, 10 = urr | |
823 | always @(dcr_pktag or pcr_ctag_trnsnum or urr_sbdtag or trn_sel) | |
824 | case (trn_sel) // synopsys infer_mux | |
825 | 2'b00, | |
826 | 2'b11 : nxt_psb_trn = dcr_pktag; // dma_cpl | |
827 | 2'b01 : nxt_psb_trn = {1'b0, pcr_ctag_trnsnum}; // pio_rd | |
828 | 2'b10 : nxt_psb_trn = urr_sbdtag; // uns_req | |
829 | endcase | |
830 | ||
831 | // register psb wr_data/trn | |
832 | always @(posedge clk) | |
833 | if (~rst_l) | |
834 | begin | |
835 | cl2ps_e_wr_data <= `FIRE_DLC_PSR_PIO_DATA_WDTH'b0; | |
836 | cl2ps_e_trn <= `FIRE_DLC_PSR_TRN_WDTH'b0; | |
837 | end | |
838 | else if (psb_ld) | |
839 | begin | |
840 | //BP n2 5-24-04 | |
841 | // cl2ps_e_wr_data <= {pcr_ctag_agntid, pcr_ctag_trnsid}; | |
842 | cl2ps_e_wr_data <= {pcr_ctag_thrdid}; | |
843 | cl2ps_e_trn <= nxt_psb_trn; | |
844 | end | |
845 | ||
846 | // -------------------------------------------------------- | |
847 | // CTM INTERFACE (TAG/CREDIT RETURN) | |
848 | // -------------------------------------------------------- | |
849 | ||
850 | always @(posedge clk) | |
851 | if (~rst_l) | |
852 | begin | |
853 | crm2ctm_tag <= 4'b0; | |
854 | end | |
855 | else begin | |
856 | crm2ctm_tag <= dcr_ctag_trnsnum; | |
857 | end | |
858 | ||
859 | endmodule // dmu_clu_crm_pktgen |