-
Notifications
You must be signed in to change notification settings - Fork 1
/
cl_fpgarr_defs.svh
662 lines (644 loc) · 37.1 KB
/
cl_fpgarr_defs.svh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
`ifndef CL_FPGARR_DEFS
`define CL_FPGARR_DEFS
////////////////////////////////////////////////////////////////////////////////
// MACROS
// 1. DEBUG_ILA: allow ILA instances to be synthesized
// 2. DEBUG_INTERCONNECT: switch to pcim_pchk axi interconnect, work in both
// simulation and synthesis
// 3. SIMULATION_AVOID_X: enforce alignment padding to be all zero in simulation
// 4. WRITEBACK_DEBUG: print out record and validate writeback in simulation
// 5. DEBUG_MERGE_TREE_STRUCTURE: print out verbose merge tree structure
// details, normally used to debug the sv-part of the treegen.
// 6. TEST_REPLAY: Connect record trace writeback directly to replay trace
// readback. Used in test_rr_parse_replay_trace unit test.
// 7. EXPORT_MERGE_TREE_INFO: Export the leaf nodes of the merge tree. These
// info will be used to auto-gen the merge tree structure via the script
// `cl_fpgarr_treegen.py`
// 8. EXPORT_MERGE_TREE_INFO_FILE: Specify the output file of the tree info.
// (default is 'tree.info.txt')
////////////////////////////////////////////////////////////////////////////////
// register pipeline related configuration
parameter RECORDER_PIPE_DEPTH=4;
parameter MERGETREE_OUT_QUEUE_NSTAGES=1;
parameter REPLAYER_PIPE_DEPTH=4;
parameter CSR_PIPE_DEPTH=2;
parameter RECORD_FIFO_DEPTH=128;
parameter REPLAY_FIFO_DEPTH=32;
// Please refer to the documentation in `happenbefore_encoder.sv` to understand
// the parameter PCIM_PENDING_AW_W_THRESHOLD.
// In brief, it controls the buffer that is reserved to avoid pcim interconnect
// deadlock
parameter PCIM_PENDING_AW_W_THRESHOLD = 40;
// index allocation of AXI channels
//// For logging from master to slave
parameter LOGB_AW=0;
parameter LOGB_W=1;
parameter LOGB_AR=2;
//// For logging from slave to master
parameter LOGB_R=0;
parameter LOGB_B=1;
//// For logging the transaction-end of all channels
parameter LOGE_AW=0;
parameter LOGE_W=1;
parameter LOGE_AR=2;
parameter LOGE_B=3;
parameter LOGE_R=4;
// RR_CHANNEL_WIDTH_BITS should be long enough to encode the max amount of
// data to log for a single channel
parameter RR_CHANNEL_WIDTH_BITS=32;
parameter RR_CHANNEL_NAME_BITS=32*8;
// This is a workaround for vcs non-local function call.
// the function GET_OFFSET should be a constant function bound to a specific
// instance of rr_logging_bus_t
`define DEF_GET_OFFSET(fname, channel_widths) \
function automatic int fname (int idx); \
fname = 0; \
for (int i=0; i < idx; i=i+1) \
fname += channel_widths[i]; \
endfunction
// This is to reuse the function definition of getting the sum of a certain
// range of a parameter array.
// fname: function name
// aname: array name
// idx_b: the index to begin sum
// idx_e: the index to end sum (non-inclusive, i.e. sum of [idx_b..idx_e))
`define DEF_SUM_WIDTH(fname, aname, idx_b, idx_e) \
function automatic int fname; \
fname = 0; \
for (int i=idx_b; i < idx_e; i=i+1) \
fname += aname[i]; \
endfunction
// This is to reuse the function definition of getting the total length of
// a logging unit (fixed-length logb plus loge, and variable-length logb data)
// This is mainly used to parse one logging unit at a time from the backend
// storage This helper function can tell how long a logging unit is.
//
// This function decodes the valid bitmap of logb_valid and aims to finish
// LOGB_CHANNEL_CNT constant additions in a cycle.
`define DEF_GET_LEN(fname, LOGB_CHANNEL_CNT, OFFSET_WIDTH, CHANNEL_WIDTHS) \
function automatic [OFFSET_WIDTH-1:0] fname \
(logic [LOGB_CHANNEL_CNT-1:0] logb_bitmap); \
fname = LOGB_CHANNEL_CNT + LOGE_CHANNEL_CNT; \
for (int i=0; i < LOGB_CHANNEL_CNT; i=i+1) \
if (logb_bitmap[i]) \
fname += OFFSET_WIDTH'(CHANNEL_WIDTHS[i]); \
endfunction
// macro utility to connect verilog wire signals to systemverilog interfaces
// b for bus, m for master, s for slave
// bus signals are accessed via `b.Xvalid`
// wire signals are accessed via name concatenation of m, s, pfx and field names
// pfx is prefix
// TODO: seperate rr axi bus definition and remove wid
// TODO: pcis Xid is just 6bit
`define AXI_MSTR_WIRE2BUS(b, m, s, pfx) \
rr_axi_bus_t b(); \
assign b.awid = m``_``s``pfx``awid; \
assign b.awaddr = m``_``s``pfx``awaddr; \
assign b.awlen = m``_``s``pfx``awlen; \
assign b.awsize = m``_``s``pfx``awsize; \
assign b.awvalid = m``_``s``pfx``awvalid; \
assign s``_``m``pfx``awready = b.awready; \
\
assign b.wid = 0; /*TODO: get rid of wid*/ \
assign b.wdata = m``_``s``pfx``wdata; \
assign b.wstrb = m``_``s``pfx``wstrb; \
assign b.wlast = m``_``s``pfx``wlast; \
assign b.wvalid = m``_``s``pfx``wvalid; \
assign s``_``m``pfx``wready = b.wready; \
\
assign s``_``m``pfx``bid = b.bid; \
assign s``_``m``pfx``bresp = b.bresp; \
assign s``_``m``pfx``bvalid = b.bvalid; \
assign b.bready = m``_``s``pfx``bready; \
\
assign b.arid = m``_``s``pfx``arid; \
assign b.araddr = m``_``s``pfx``araddr; \
assign b.arlen = m``_``s``pfx``arlen; \
assign b.arsize = m``_``s``pfx``arsize; \
assign b.arvalid = m``_``s``pfx``arvalid; \
assign s``_``m``pfx``arready = b.arready; \
\
assign s``_``m``pfx``rid = b.rid; \
assign s``_``m``pfx``rdata = b.rdata; \
assign s``_``m``pfx``rresp = b.rresp; \
assign s``_``m``pfx``rlast = b.rlast; \
assign s``_``m``pfx``rvalid = b.rvalid; \
assign b.rready = m``_``s``pfx``rready
`define AXI_SLV_WIRE2BUS(b, m, s, pfx) \
rr_axi_bus_t b(); \
assign m``_``s``pfx``awid = b.awid; \
assign m``_``s``pfx``awaddr = b.awaddr; \
assign m``_``s``pfx``awlen = b.awlen; \
assign m``_``s``pfx``awsize = b.awsize; \
assign m``_``s``pfx``awvalid = b.awvalid; \
assign b.awready = s``_``m``pfx``awready; \
\
/*assign b.wid = 0; TODO: get rid of wid*/ \
assign m``_``s``pfx``wdata = b.wdata; \
assign m``_``s``pfx``wstrb = b.wstrb; \
assign m``_``s``pfx``wlast = b.wlast; \
assign m``_``s``pfx``wvalid = b.wvalid; \
assign b.wready = s``_``m``pfx``wready; \
\
assign b.bid = s``_``m``pfx``bid; \
assign b.bresp = s``_``m``pfx``bresp; \
assign b.bvalid = s``_``m``pfx``bvalid; \
assign m``_``s``pfx``bready = b.bready; \
\
assign m``_``s``pfx``arid = b.arid; \
assign m``_``s``pfx``araddr = b.araddr; \
assign m``_``s``pfx``arlen = b.arlen; \
assign m``_``s``pfx``arsize = b.arsize; \
assign m``_``s``pfx``arvalid = b.arvalid; \
assign b.arready = s``_``m``pfx``arready; \
\
assign b.rid = s``_``m``pfx``rid; \
assign b.rdata = s``_``m``pfx``rdata; \
assign b.rresp = s``_``m``pfx``rresp; \
assign b.rlast = s``_``m``pfx``rlast; \
assign b.rvalid = s``_``m``pfx``rvalid; \
assign m``_``s``pfx``rready = b.rready
`define AXIL_MSTR_WIRE2BUS(b, m, s, pfx) \
rr_axi_lite_bus_t b(); \
assign b.awaddr = m``_``s``pfx``awaddr; \
assign b.awvalid = m``_``s``pfx``awvalid; \
assign s``_``m``pfx``awready = b.awready; \
\
assign b.wdata = m``_``s``pfx``wdata; \
assign b.wstrb = m``_``s``pfx``wstrb; \
assign b.wvalid = m``_``s``pfx``wvalid; \
assign s``_``m``pfx``wready = b.wready; \
\
assign s``_``m``pfx``bresp = b.bresp; \
assign s``_``m``pfx``bvalid = b.bvalid; \
assign b.bready = m``_``s``pfx``bready; \
\
assign b.araddr = m``_``s``pfx``araddr; \
assign b.arvalid = m``_``s``pfx``arvalid; \
assign s``_``m``pfx``arready = b.arready; \
\
assign s``_``m``pfx``rdata = b.rdata; \
assign s``_``m``pfx``rresp = b.rresp; \
assign s``_``m``pfx``rvalid = b.rvalid; \
assign b.rready = m``_``s``pfx``rready
`define AXIL_SLV_WIRE2BUS(b, m, s, pfx) \
rr_axi_lite_bus_t b(); \
assign m``_``s``pfx``awaddr = b.awaddr; \
assign m``_``s``pfx``awvalid = b.awvalid; \
assign b.awready = s``_``m``pfx``awready; \
\
assign m``_``s``pfx``wdata = b.wdata; \
assign m``_``s``pfx``wstrb = b.wstrb; \
assign m``_``s``pfx``wvalid = b.wvalid; \
assign b.wready = s``_``m``pfx``wready; \
\
assign b.bresp = s``_``m``pfx``bresp; \
assign b.bvalid = s``_``m``pfx``bvalid; \
assign m``_``s``pfx``bready = b.bready; \
\
assign m``_``s``pfx``araddr = b.araddr; \
assign m``_``s``pfx``arvalid = b.arvalid; \
assign b.arready = s``_``m``pfx``arready; \
\
assign b.rdata = s``_``m``pfx``rdata; \
assign b.rresp = s``_``m``pfx``rresp; \
assign b.rvalid = s``_``m``pfx``rvalid; \
assign m``_``s``pfx``rready = b.rready
`define AXI_CONNECT_BUS2WIRE(b, m, s, pfx) \
.m``_``s``pfx``awid(b.awid), \
.m``_``s``pfx``awaddr(b.awaddr), \
.m``_``s``pfx``awlen(b.awlen), \
.m``_``s``pfx``awsize(b.awsize), \
.m``_``s``pfx``awvalid(b.awvalid), \
.s``_``m``pfx``awready(b.awready), \
\
/*assign b.wid = 0; wid is skipped*/ \
.m``_``s``pfx``wdata(b.wdata), \
.m``_``s``pfx``wstrb(b.wstrb), \
.m``_``s``pfx``wlast(b.wlast), \
.m``_``s``pfx``wvalid(b.wvalid), \
.s``_``m``pfx``wready(b.wready), \
\
.s``_``m``pfx``bid(b.bid), \
.s``_``m``pfx``bresp(b.bresp), \
.s``_``m``pfx``bvalid(b.bvalid), \
.m``_``s``pfx``bready(b.bready), \
\
.m``_``s``pfx``arid(b.arid), \
.m``_``s``pfx``araddr(b.araddr), \
.m``_``s``pfx``arlen(b.arlen), \
.m``_``s``pfx``arsize(b.arsize), \
.m``_``s``pfx``arvalid(b.arvalid), \
.s``_``m``pfx``arready(b.arready), \
\
.s``_``m``pfx``rid(b.rid), \
.s``_``m``pfx``rdata(b.rdata), \
.s``_``m``pfx``rresp(b.rresp), \
.s``_``m``pfx``rlast(b.rlast), \
.s``_``m``pfx``rvalid(b.rvalid), \
.m``_``s``pfx``rready(b.rready)
`define AXIL_CONNECT_BUS2WIRE(b, m, s, pfx) \
.m``_``s``pfx``awaddr(b.awaddr), \
.m``_``s``pfx``awvalid(b.awvalid), \
.s``_``m``pfx``awready(b.awready), \
\
.m``_``s``pfx``wdata(b.wdata), \
.m``_``s``pfx``wstrb(b.wstrb), \
.m``_``s``pfx``wvalid(b.wvalid), \
.s``_``m``pfx``wready(b.wready), \
\
.s``_``m``pfx``bresp(b.bresp), \
.s``_``m``pfx``bvalid(b.bvalid), \
.m``_``s``pfx``bready(b.bready), \
\
.m``_``s``pfx``araddr(b.araddr), \
.m``_``s``pfx``arvalid(b.arvalid), \
.s``_``m``pfx``arready(b.arready), \
\
.s``_``m``pfx``rdata(b.rdata), \
.s``_``m``pfx``rresp(b.rresp), \
.s``_``m``pfx``rvalid(b.rvalid), \
.m``_``s``pfx``rready(b.rready)
`define AXI_CONNECT_M_TO_S(m, s) \
assign s.awid = m.awid; \
assign s.awaddr = m.awaddr; \
assign s.awlen = m.awlen; \
assign s.awsize = m.awsize; \
assign s.awvalid = m.awvalid; \
assign m.awready = s.awready; \
assign s.wid = m.wid; \
assign s.wdata = m.wdata; \
assign s.wstrb = m.wstrb; \
assign s.wlast = m.wlast; \
assign s.wvalid = m.wvalid; \
assign m.wready = s.wready; \
assign m.bid = s.bid; \
assign m.bresp = s.bresp; \
assign m.bvalid = s.bvalid; \
assign s.bready = m.bready; \
assign s.arid = m.arid; \
assign s.araddr = m.araddr; \
assign s.arlen = m.arlen; \
assign s.arsize = m.arsize; \
assign s.arvalid = m.arvalid; \
assign m.arready = s.arready; \
assign m.rid = s.rid; \
assign m.rdata = s.rdata; \
assign m.rresp = s.rresp; \
assign m.rlast = s.rlast; \
assign m.rvalid = s.rvalid; \
assign s.rready = m.rready
`define AXIL_CONNECT_M_TO_S(m, s) \
assign s.awaddr = m.awaddr; \
assign s.awvalid = m.awvalid; \
assign m.awready = s.awready; \
assign s.wdata = m.wdata; \
assign s.wstrb = m.wstrb; \
assign s.wvalid = m.wvalid; \
assign m.wready = s.wready; \
assign m.bresp = s.bresp; \
assign m.bvalid = s.bvalid; \
assign s.bready = m.bready; \
assign s.araddr = m.araddr; \
assign s.arvalid = m.arvalid; \
assign m.arready = s.arready; \
assign m.rdata = s.rdata; \
assign m.rresp = s.rresp; \
assign m.rvalid = s.rvalid; \
assign s.rready = m.rready
// Conditionally perform casting for record/replay the given interface ID
// The cast is between types that shares the same axi-like fields.
// Do nothing when that interface ID is disabled
`define RR_AXI_CONNECT_M_TO_S(m, s, intfid) \
`ifndef RR_DEL_``intfid \
/* rr_axi_m is the type-casted master intf */ \
rr_axi_bus_t intfid``_rr_axi_m(); \
/* rr_axi_s is the type-casted slave intf */ \
rr_axi_bus_t intfid``_rr_axi_s(); \
`AXI_CONNECT_M_TO_S(m, intfid``_rr_axi_m); \
`AXI_CONNECT_M_TO_S(intfid``_rr_axi_s, s); \
`endif
// RR CSRS
////////////////////////////////////////////////////////////////////////////////
// !!!!!!!!!!!!!!!!!!!!!!!! ATTENTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ALWAYS update (increase) this RR_CSR_VERSION_INT after making changes to CSR
// address allocation
// format: YYYY_MM_DD_HH
parameter int RR_CSR_VERSION_INT = 2022032701;
////////////////////////////////////////////////////////////////////////////////
// Debug CSR configurations
`undef DEBUG_RECORD_CSR
`undef DEBUG_PCHK_CSR
// for DEBUG_PCHK_CSR
`ifdef SYNTH_DEBUG_INTERCONNECT
`define DEBUG_PCHK_CSR
`endif
`undef DEBUG_REPLAY_CSR
function automatic int GET_RR_CSR_CNT();
// basic CSR
GET_RR_CSR_CNT = 23;
`ifdef DEBUG_RECORD_CSR
GET_RR_CSR_CNT = GET_RR_CSR_CNT + 47;
`endif
`ifdef DEBUG_PCHK_CSR
GET_RR_CSR_CNT = GET_RR_CSR_CNT + 21;
`endif
`ifdef DEBUG_REPLAY_CSR
GET_RR_CSR_CNT = GET_RR_CSR_CNT + 10;
`endif
`ifdef COUNT_DDR
GET_RR_CSR_CNT = GET_RR_CSR_CNT + 20;
`endif
GET_RR_CSR_CNT = 2**$clog2(GET_RR_CSR_CNT);
endfunction
////////////////////////////////////////////////////////////////////////////////
parameter int RR_CSR_CNT = GET_RR_CSR_CNT();
parameter int RR_CSR_ADDR_WIDTH = $clog2(RR_CSR_CNT);
typedef enum bit [RR_CSR_ADDR_WIDTH-1:0] {
// BUF_ADDR and BUF_SIZE are the address and size of a buffer in CPU-side
// memory. The address should be physical addresses. To tell the writeback
// module about a new buffer, the software need to write the address and
// size of the buffer to BUF_ADDR and BUF_SIZE, and write 1 to one of the
// *_BUF_UPDATE registers.
BUF_ADDR_HI, // 0
BUF_ADDR_LO, // 1
BUF_SIZE_HI, // 2
BUF_SIZE_LO, // 3
RECORD_BUF_UPDATE, // 4
REPLAY_BUF_UPDATE, // 5
// Software needs to write 1 to RECORD_FORCE_FINISH after the computation
// is done. Writing to this CSR would flush the last packet to the memory.
// Before writing this CSR, it's recommanded for the software to sleep for
// a few microseconds.
RECORD_FORCE_FINISH, // 6
REPLAY_START, // 7, currently not used
RR_MODE, // 8
RR_STATE_LO, // 9, 4 bytes reserved to align RECORD_BITS
// *_BITS are used to tell how many bits is recorded or needs to be replayed.
// Software need to write this before replay, and read it back after record.
RECORD_BITS_HI, // 10
RECORD_BITS_LO, // 11
REPLAY_BITS_HI, // 12
REPLAY_BITS_LO, // 13
VALIDATE_BUF_UPDATE, // 14
RR_STATE_HI, // 15, 4 bytes recerved to align VALIDATE_BITS
VALIDATE_BITS_HI, // 16
VALIDATE_BITS_LO, // 17
// The real-time number of bits has been replayed
RT_REPLAY_BITS_HI, // 18
RT_REPLAY_BITS_LO, // 19
RR_TRACE_FIFO_ASSERT, // 20
RR_CSR_VERSION, // 21
RR_ON_THE_FLY_BALANCE, // 22
INT_BUF_UPDATE, // 23
`ifdef DEBUG_RECORD_CSR
// gefei dbg_csr
RR_WB_RECORD_DBG_BITS_NON_ALIGNED_HI,
RR_WB_RECORD_DBG_BITS_NON_ALIGNED_LO,
RR_WB_RECORD_DBG_BITS_FIFO_WR_CNT,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_pcim_R,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_sda_AW,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_bar1_W,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_ocl_AR,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_pcis_AW,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_ocl_AW,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_ocl_W,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_bar1_AW,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_pcis_W,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_pcis_B,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_pcis_AR,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_sda_AR,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_sda_W,
RR_WB_RECORD_DBG_BITS_CHPKT_CNT_bar1_AR,
// mjc dbg_csr
RR_RECORD_IN_PKT_CNT_HI,
RR_RECORD_IN_PKT_CNT_LO,
RR_RECORD_OUT_PKT_CNT_HI,
RR_RECORD_OUT_PKT_CNT_LO,
RR_RECORD_IN_BITS_CNT_HI,
RR_RECORD_IN_BITS_CNT_LO,
RR_RECORD_OUT_BITS_CNT_HI,
RR_RECORD_OUT_BITS_CNT_LO,
RR_RECORD_IN_FIFO_OUT_PKT_CNT_HI,
RR_RECORD_IN_FIFO_OUT_PKT_CNT_LO,
RR_RECORD_IN_FIFO_OUT_ORIG_BITS_CNT_HI,
RR_RECORD_IN_FIFO_OUT_ORIG_BITS_CNT_LO,
RR_RECORD_IN_FIFO_OUT_ALIGNED_BITS_CNT_HI,
RR_RECORD_IN_FIFO_OUT_ALIGNED_BITS_CNT_LO,
RR_WB_AW_TRANS_CNT_HI,
RR_WB_AW_TRANS_CNT_LO,
RR_WB_W_TRANS_CNT_HI,
RR_WB_W_TRANS_CNT_LO,
RR_WB_B_TRANS_CNT_HI,
RR_WB_B_TRANS_CNT_LO,
RT_RECORD_UNHANDLED_SIZE_HI,
RT_RECORD_UNHANDLED_SIZE_LO,
RT_CURRENT_RECORD_UNHANDLED_SIZE_HI,
RT_CURRENT_RECORD_UNHANDLED_SIZE_LO,
RT_LEFTOVER_SIZE_HI,
RT_LEFTOVER_SIZE_LO,
RT_RECORD_CURR_HI,
RT_RECORD_CURR_LO,
RR_AXI_STATUS_HI,
RR_AXI_STATUS_LO,
`endif // DEBUG_RECORD_CSR
`ifdef COUNT_DDR
RR_DDR_COUNTER_A_AW,
RR_DDR_COUNTER_A_W,
RR_DDR_COUNTER_A_AR,
RR_DDR_COUNTER_A_R,
RR_DDR_COUNTER_A_B,
RR_DDR_COUNTER_B_AW,
RR_DDR_COUNTER_B_W,
RR_DDR_COUNTER_B_AR,
RR_DDR_COUNTER_B_R,
RR_DDR_COUNTER_B_B,
RR_DDR_COUNTER_C_AW,
RR_DDR_COUNTER_C_W,
RR_DDR_COUNTER_C_AR,
RR_DDR_COUNTER_C_R,
RR_DDR_COUNTER_C_B,
RR_DDR_COUNTER_D_AW,
RR_DDR_COUNTER_D_W,
RR_DDR_COUNTER_D_AR,
RR_DDR_COUNTER_D_R,
RR_DDR_COUNTER_D_B,
`endif // COUNT_DDR
`ifdef DEBUG_PCHK_CSR
// pcim pchk csrs
RR_PCIM_PCHK_ASSERTED,
RR_LOGGING_WB_PCHK_P0,
RR_LOGGING_WB_PCHK_P1,
RR_LOGGING_WB_PCHK_P2,
RR_LOGGING_WB_PCHK_P3,
RR_LOGGING_WB_PCHK_P4,
RR_VALIDATION_WB_PCHK_P0,
RR_VALIDATION_WB_PCHK_P1,
RR_VALIDATION_WB_PCHK_P2,
RR_VALIDATION_WB_PCHK_P3,
RR_VALIDATION_WB_PCHK_P4,
RR_CL_PCIM_PCHK_P0,
RR_CL_PCIM_PCHK_P1,
RR_CL_PCIM_PCHK_P2,
RR_CL_PCIM_PCHK_P3,
RR_CL_PCIM_PCHK_P4,
RR_SH_PCIM_PCHK_P0,
RR_SH_PCIM_PCHK_P1,
RR_SH_PCIM_PCHK_P2,
RR_SH_PCIM_PCHK_P3,
RR_SH_PCIM_PCHK_P4,
`endif // DEBUG_PCHK_CSR
`ifdef DEBUG_REPLAY_CSR
RR_REPLAY_AR_TRANS_CNT,
RR_REPLAY_R_TRANS_CNT,
RR_REPLAY_IN_FIFO_IN_CNT,
RR_REPLAY_IN_FIFO_OUT_CNT,
RR_REPLAY_OUT_FIFO_IN_CNT,
RR_REPLAY_OUT_FIFO_OUT_CNT,
RR_TRACE_SPLIT_DBG_CSR_P0,
RR_TRACE_SPLIT_DBG_CSR_P1,
RR_TRACE_SPLIT_DBG_CSR_P2,
RR_TRACE_SPLIT_DBG_CSR_P3,
`endif // DEBUG_REPLAY_CSR
RR_CSR_LAST_DONT_USE = RR_CSR_CNT - 1
} rr_csr_enum;
`define RR_CSR_ADDR(idx) (idx << 2)
package AWSF1_INTF_RRCFG;
// PLACEMENT_VEC for runtime loge_valid crossbar
// From aws-fpga doc:
// MID SLR:
// CL_SH_DDR
// BAR1
// PCIM
// BOTTOM SLR:
// PCIS
// OCL
// DDR STAT3
// MID/BOTTOM
// DDR STAT0
// DDR STAT1
// SDA
enum int { SDA=0, OCL, BAR1, PCIM, PCIS, DDRC, APP_AXIM, NUM_INTF} INTF_ORDER;
parameter int LOGE_PER_AXI = 5;
// NOTE: The PLACEMENT_VEC array is moved to scripts/cl_fpgarr_autogrouping.py
// to avoid vivado segfault
// It is used to specify the phyiscal distance between interfaces, so that a
// proper number of registers can be inserted automatically
endpackage
// The alignment of packets
`ifndef OVERRIDE_PACKET_ALIGNMENT
parameter int PACKET_ALIGNMENT = 8;
`else
parameter int PACKET_ALIGNMENT = `OVERRIDE_PACKET_ALIGNMENT;
`endif
parameter logic [63:0] PACKET_ALIGNMENT_SHIFT = $clog2(PACKET_ALIGNMENT);
parameter logic [63:0] PACKET_ALIGNMENT_MASK = 64'(PACKET_ALIGNMENT) - 1;
// GET_ALIGNED_SIZE is to align constant parameters
`define GET_ALIGNED_SIZE(size) (((size - 1) / PACKET_ALIGNMENT + 1) * PACKET_ALIGNMENT)
// GET_ALIGNED_SIZE_W is to align known-width variables
// It uses more efficient bit ops.
`define GET_ALIGNED_SIZE_W(width, size) \
(((size) + width'(PACKET_ALIGNMENT) - 1) & (~(width'(PACKET_ALIGNMENT) - 1)))
`define GET_FORCE_ALIGNED_SIZE(size) (size & ~PACKET_ALIGNMENT_MASK)
`define GET_FORCE_ALIGNED_FRAME(size) (size >> PACKET_ALIGNMENT_SHIFT)
`define IS_ALIGNED_SIZE(size) ((size & PACKET_ALIGNMENT_MASK) == 0)
// AXI_ID configuration
parameter SHELL_PCIM_AXI_ID_WIDTH = 16;
parameter int PCIM_INTERCONNECT_AXI_ID_WIDTH = 14;
parameter int CL_PCIM_AXI_ID_WIDTH = 13;
// MAX_PCIM_WR_BURSTS are the max number of outstanding write transactions allowed on
// the pcim axi bus. This is not documented in aws readme.
// The bursts of pcis is documented though.
// Note that the pcim interconnect is also configured to support this much
// bursts in its crossbar for all interfaces.
parameter int MAX_PCIM_WR_BURSTS = 32;
parameter int MAX_PCIM_AWID_WIDTH = $clog2(MAX_PCIM_WR_BURSTS);
// MAX_PCIM_RD_BURSTS is similar to MAX_PCIM_WR_BURSTS, but for read trasactions
parameter int MAX_PCIM_RD_BURSTS = 32;
parameter int MAX_PCIM_ARID_WIDTH = $clog2(MAX_PCIM_RD_BURSTS);
// A wrapper around lib_pipe to encapsulate a packed struct
`define LIB_PIPE_PACKED_STRUCT(typename, varname, suffix, _clk, _rstn, NSTAGES)\
typename varname``suffix; \
lib_pipe #(.WIDTH($bits(typename)), .STAGES(NSTAGES)) \
pipe``_``varname(.clk(_clk), .rst_n(_rstn), \
.in_bus(varname), .out_bus(varname``suffix))
// Automate registering interfaces for RR
`define REG_AXI_MSTR_INTF_RR(pre_record, post_record, intf_id, intf_str) \
`ifdef RR_TRACE_``intf_id \
`AXI_MSTR_LOGGING_BUS(rr_``intf_id``_SH2CL_logging_bus, intf_str); \
`AXI_SLV_LOGGING_BUS(rr_``intf_id``_CL2SH_logging_bus, intf_str); \
rr_axi_bus_t intf_id``_to_record(); \
axi_recorder intf_id``_recorder ( \
.clk(clk), \
.sync_rst_n(rstn), \
.S(post_record), \
.M(intf_id``_to_record), \
.log_M2S(rr_``intf_id``_SH2CL_logging_bus), \
.log_S2M(rr_``intf_id``_CL2SH_logging_bus) \
); \
localparam intf_id``_LOGE_INTF_IDX = RR_TRACKED_LOGE_INTF_IDX[intf_id]; \
`AXI_MSTR_REPLAY_BUS(rr_``intf_id``_replay_bus, REPLAY_NLOGE); \
rr_axi_bus_t intf_id``_replay(); \
axi_mstr_replayer #(RR_NUM_TRACKED_AXI, LOGE_PER_AXI, \
intf_id``_LOGE_INTF_IDX, 0, 0, 0, 0) intf_id``_replayer ( \
.clk(clk), .sync_rst_n(rstn), \
.rbus(rr_``intf_id``_replay_bus), \
.outM(intf_id``_replay), \
.i_rt_loge_valid(rt_loge_valid_dist[intf_id``_LOGE_INTF_IDX]) \
); \
rr_axi_rt_loge #(LOGE_PER_AXI) rt_loge_``intf_id ( \
.in(post_record), \
.o_rt_loge_valid(rt_loge_valid_agg[intf_id``_LOGE_INTF_IDX]) \
); \
rr_axi_mstr_sel intf_id``_sel ( \
.sel(rr_mode_csr.replayEn), \
.inAS(pre_record), \
.inBS(intf_id``_replay), \
.outM(intf_id``_to_record) \
); \
`elsif RR_FUSE_``intf_id \
`AXI_CONNECT_M_TO_S(pre_record, post_record); \
`elsif RR_DEL_``intf_id \
`else \
$error("Is the interface %s configured correctly?", intf_str); \
`endif
`define REG_AXIL_MSTR_INTF_RR(pre_record, post_record, intf_id, intf_str) \
`ifdef RR_TRACE_``intf_id \
`AXIL_MSTR_LOGGING_BUS(rr_``intf_id``_SH2CL_logging_bus, intf_str); \
`AXIL_SLV_LOGGING_BUS(rr_``intf_id``_CL2SH_logging_bus, intf_str); \
rr_axi_lite_bus_t intf_id``_to_record(); \
axil_recorder intf_id``_recorder ( \
.clk(clk), \
.sync_rst_n(rstn), \
.S(post_record), \
.M(intf_id``_to_record), \
.log_M2S(rr_``intf_id``_SH2CL_logging_bus), \
.log_S2M(rr_``intf_id``_CL2SH_logging_bus) \
); \
localparam intf_id``_LOGE_INTF_IDX = RR_TRACKED_LOGE_INTF_IDX[intf_id]; \
`AXIL_MSTR_REPLAY_BUS(rr_``intf_id``_replay_bus, REPLAY_NLOGE); \
rr_axi_lite_bus_t intf_id``_replay(); \
axil_mstr_replayer #(RR_NUM_TRACKED_AXI, LOGE_PER_AXI, \
intf_id``_LOGE_INTF_IDX) intf_id``_replayer ( \
.clk(clk), .sync_rst_n(rstn), \
.rbus(rr_``intf_id``_replay_bus), \
.outM(intf_id``_replay), \
.i_rt_loge_valid(rt_loge_valid_dist[intf_id``_LOGE_INTF_IDX]) \
); \
rr_axil_rt_loge #(LOGE_PER_AXI) rt_loge_``intf_id ( \
.in(post_record), \
.o_rt_loge_valid(rt_loge_valid_agg[intf_id``_LOGE_INTF_IDX]) \
); \
rr_axil_mstr_sel intf_id``_sel ( \
.sel(rr_mode_csr.replayEn), \
.inAS(pre_record), \
.inBS(intf_id``_replay), \
.outM(intf_id``_to_record) \
); \
`elsif RR_FUSE_``intf_id \
`AXIL_CONNECT_M_TO_S(pre_record, post_record); \
`elsif RR_DEL_``intf_id \
`else \
$error("Is the interface %s configured correctly?", intf_str); \
`endif
`endif // CL_FPGARR_DEFS