-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcb_vip_pkg.sv
737 lines (679 loc) · 24.8 KB
/
tcb_vip_pkg.sv
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
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
////////////////////////////////////////////////////////////////////////////////
// TCB (Tightly Coupled Bus) VIP (Verification IP) PacKaGe
////////////////////////////////////////////////////////////////////////////////
// Copyright 2022 Iztok Jeras
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
package tcb_vip_pkg;
import tcb_pkg::*;
////////////////////////////////////////////////////////////////////////////////
// TCB class
////////////////////////////////////////////////////////////////////////////////
class tcb_transfer_c #(
tcb_par_phy_t PHY = TCB_PAR_PHY_DEF,
type tcb_req_cmd_t = tcb_req_cmd_def_t,
type tcb_rsp_sts_t = tcb_rsp_sts_def_t
);
////////////////////////////////////////////////////////////////////////////////
// local parameters
////////////////////////////////////////////////////////////////////////////////
// byte enable width
localparam int unsigned PHY_BEW = PHY.DBW / PHY.SLW;
// transfer size width calculation
localparam int unsigned PHY_SZW_LIN = $clog2( PHY_BEW ); // linear
localparam int unsigned PHY_SZW_LOG = $clog2($clog2(PHY_BEW)+1); // logarithmic (default)
// transfer size width selection
localparam int unsigned PHY_SZW = (PHY.SIZ == TCB_LINEAR) ? PHY_SZW_LIN : PHY_SZW_LOG;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
typedef virtual tcb_if #(
.PHY (PHY),
.tcb_req_cmd_t (tcb_req_cmd_t),
.tcb_rsp_sts_t (tcb_rsp_sts_t)
) tcb_vif_t;
string MODE = "MON";
tcb_vif_t tcb;
//constructor
function new(string MODE = "MON", tcb_vif_t tcb);
this.MODE = MODE;
this.tcb = tcb;
// initialization
case (MODE)
// manager
"MAN": begin
// initialize to idle state
tcb.vld = 1'b0;
end
// monitor
"MON": begin
end
// subordinate
"SUB": begin
// initialize to idle state
tcb.rdy = 1'b0;
end
endcase
endfunction: new
////////////////////////////////////////////////////////////////////////////////
// reference data for tests
////////////////////////////////////////////////////////////////////////////////
// data organized into packed bytes
typedef logic [PHY_BEW-1:0][PHY.SLW-1:0] data_byte_t;
// created data for tests
static function automatic data_byte_t data_test_f (
input logic [PHY.SLW/2-1:0] val = 'x
);
for (int unsigned i=0; i<PHY_BEW; i++) begin
data_test_f[i] = {val, i[PHY.SLW/2-1:0]};
end
endfunction: data_test_f
////////////////////////////////////////////////////////////////////////////////
// transfer
////////////////////////////////////////////////////////////////////////////////
// TCB transfer request structure
typedef struct {
tcb_req_cmd_t cmd; // command (optional)
logic wen; // write enable
logic ndn; // endianness
logic [PHY.ABW-1:0] adr; // address
logic [PHY_SZW-1:0] siz; // logarithmic size
logic [PHY_BEW-1:0] ben; // byte enable
logic [PHY_BEW-1:0][PHY.SLW-1:0] wdt; // write data
} transfer_request_t;
// TCB transfer response structure
typedef struct {
logic [PHY_BEW-1:0][PHY.SLW-1:0] rdt; // read data
tcb_rsp_sts_t sts; // status (optional)
} transfer_response_t;
// TCB transfer structure
typedef struct {
// request/response
transfer_request_t req; // request
transfer_response_t rsp; // response
// timing idle/backpressure
int unsigned idl; // idle
int unsigned bpr; // backpressure
} transfer_t;
typedef transfer_t transfer_array_t [];
// constants
static const transfer_t TRANSFER_INIT = '{
// request
req: '{
cmd: 'x,
wen: 1'bx,
ndn: 1'bx,
adr: 'x,
siz: 'x,
ben: 'x,
wdt: 'x
},
// response
rsp: '{
rdt: 'x,
sts: 'x
},
// timing idle/backpressure
idl: 0,
bpr: 0
};
// transfer equivalence check
static function automatic logic transfer_check (
// transfer_array
input transfer_t trn_tst, // test
input transfer_t trn_ref, // reference
input transfer_t trn_msk // mask
);
//transfer_check = (trn_tst ==? (trn_ref ~^ trn_msk));
transfer_check = 1'bx;
endfunction: transfer_check
////////////////////////////////////////////////////////////////////////////////
// transfer request/response (enable pipelined transfers with full throughput)
////////////////////////////////////////////////////////////////////////////////
// transfer request driver
task automatic transfer_req_drv (
input transfer_request_t req,
input int unsigned idl,
output int unsigned bpr
);
// request timing
repeat (idl) @(posedge tcb.clk);
// drive transfer
#1;
// handshake
tcb.vld = 1'b1;
// request
tcb.req.cmd = req.cmd;
tcb.req.wen = req.wen;
tcb.req.ndn = req.ndn;
tcb.req.adr = req.adr;
tcb.req.siz = req.siz;
tcb.req.ben = req.ben;
tcb.req.wdt = req.wdt;
// backpressure
bpr = 0;
do begin
@(posedge tcb.clk);
if (~tcb.rdy) bpr++;
end while (~tcb.trn);
// drive idle/undefined
#1;
// handshake
tcb.vld = 1'b0;
// request
tcb.req.cmd = 'x;
tcb.req.wen = 'x;
tcb.req.ndn = 'x;
tcb.req.adr = 'x;
tcb.req.siz = 'x;
tcb.req.ben = 'x;
tcb.req.wdt = 'x;
endtask: transfer_req_drv
// transfer response listener
task automatic transfer_rsp_lsn (
output transfer_response_t rsp
);
// wait for response
do begin
@(posedge tcb.clk);
end while (~tcb.dly[tcb.PHY.DLY].ena);
// response
rsp.rdt = tcb.rsp.rdt;
rsp.sts = tcb.rsp.sts;
endtask: transfer_rsp_lsn
// transfer request listener
task automatic transfer_req_lsn (
output transfer_request_t req,
output int unsigned idl,
input int unsigned bpr
);
#1;
tcb.rdy = 1'b0;
// TODO: measure idle time
idl = 0;
// request
if (bpr == 0) begin
// ready
tcb.rdy = 1'b1;
// wait for transfer
do begin
@(posedge tcb.clk);
idl += tcb.vld ? 0 : 1;
end while (~tcb.trn);
end else begin
// backpressure
for (int unsigned i=0; i<bpr; i+=(tcb.vld?1:0)) begin
@(posedge tcb.clk);
idl += tcb.vld ? 0 : 1;
end
// ready
#1;
tcb.rdy = 1'b1;
// wait for transfer
do begin
@(posedge tcb.clk);
end while (~tcb.trn);
end
req.cmd = tcb.req.cmd;
req.wen = tcb.req.wen;
req.ndn = tcb.req.ndn;
req.adr = tcb.req.adr;
req.siz = tcb.req.siz;
req.ben = tcb.req.ben;
req.wdt = tcb.req.wdt;
endtask: transfer_req_lsn
// transfer response driver
task automatic transfer_rsp_drv (
input transfer_response_t rsp
);
// response
tcb.rsp.rdt = rsp.rdt;
tcb.rsp.sts = rsp.sts;
// wait for response
do begin
@(posedge tcb.clk);
end while (~tcb.dly[tcb.PHY.DLY].ena);
endtask: transfer_rsp_drv
////////////////////////////////////////////////////////////////////////////////
// transaction sequence non-blocking API
////////////////////////////////////////////////////////////////////////////////
// BUG: at DLY=0, there is a race condition between
// request/response
task automatic transfer_sequencer (
inout transfer_array_t transfer_array
);
fork
begin: fork_req
foreach (transfer_array[i]) begin
case (MODE)
"MAN": transfer_req_drv(transfer_array[i].req, transfer_array[i].idl, transfer_array[i].bpr);
"MON": transfer_req_lsn(transfer_array[i].req, transfer_array[i].idl, transfer_array[i].bpr);
"SUB": transfer_req_lsn(transfer_array[i].req, transfer_array[i].idl, transfer_array[i].bpr);
endcase
end
end: fork_req
begin: fork_rsp
foreach (transfer_array[i]) begin
case (MODE)
"MAN": transfer_rsp_lsn(transfer_array[i].rsp);
"MON": transfer_rsp_lsn(transfer_array[i].rsp);
"SUB": transfer_rsp_drv(transfer_array[i].rsp);
endcase
end
end: fork_rsp
join
endtask: transfer_sequencer
////////////////////////////////////////////////////////////////////////////////
// transaction class
////////////////////////////////////////////////////////////////////////////////
// TCB transaction request structure
typedef struct {
// request
tcb_cfg_endian_t ndn;
logic wen;
logic [PHY.ABW-1:0] adr;
logic [8-1:0][PHY.SLW-1:0] wdt;
} transaction_request_t;
// TCB transaction response structure
typedef struct {
// response
logic [8-1:0][PHY.SLW-1:0] rdt;
tcb_rsp_sts_t sts;
} transaction_response_t;
// TCB transaction structure
typedef struct {
transaction_request_t req;
transaction_response_t rsp;
} transaction_t;
// read/write request transaction of power of 2 size
static function automatic transfer_array_t transaction_request (
int unsigned siz,
// TCB transaction structure
transaction_request_t transaction_req
);
// temporary variables
int unsigned byt; // byte index
int unsigned off; // address offset
// the requested transaction is organized into transfer_array
int unsigned len;
// return transfer array
transfer_array_t transfer_array;
// number of transfer_array
len = siz / PHY_BEW + (siz % PHY_BEW ? 1 : 0);
transfer_array = new[len];
transfer_array = new[len]('{default: TRANSFER_INIT});
// check if the transfer meets size requirements
if (siz != 2**$clog2(siz)) begin
$error("ERROR: Transaction size is not power of 2.");
end
// check if the transfer meets alignment requirements
if (PHY.ALW > 0) begin
logic [PHY.ALW-1:0] adr_alw;
adr_alw = transaction_req.adr[(PHY.ALW>0?(PHY.ALW-1):0):0];
if (|adr_alw) begin
$error("ERROR: Transaction address is not aligned to supported size. adr[%d:0]=%0b", PHY.ALW-1, adr_alw);
end
end
// control and address signals
for (int unsigned i=0; i<len; i++) begin
// request optional
transfer_array[i].req.cmd = '{lck: (i == len-1) ? 1'b0 : 1'b1, default: '0};
transfer_array[i].req.wen = transaction_req.wen;
transfer_array[i].req.ndn = transaction_req.ndn;
transfer_array[i].req.adr = transaction_req.adr;
transfer_array[i].req.ben = '0;
transfer_array[i].req.siz = (PHY.SIZ == TCB_LINEAR) ? PHY_BEW : $clog2(PHY_BEW);
end
if (siz <= PHY_BEW) begin
transfer_array[0].req.siz = (PHY.SIZ == TCB_LINEAR) ? siz : $clog2( siz);
end
// data signals
for (int unsigned i=0; i<siz; i++) begin
// address offset
off = i / PHY_BEW;
// mode processor/memory
if (PHY.MOD == TCB_REFERENCE) begin
// all data bytes are LSB aligned
byt = i;
end else if (PHY.MOD == TCB_MEMORY) begin
// all data bytes are LSB aligned
byt = (i + transaction_req.adr) % PHY_BEW;
end
// order descending/ascending
if (PHY.ORD == TCB_ASCENDING) begin
byt = PHY_BEW - 1 - byt;
end
// request
transfer_array[off].req.ben[byt] = 1'b1;
// endianness
if (transaction_req.ndn == TCB_LITTLE) begin
transfer_array[off].req.wdt[byt] = transaction_req.wdt[ i];
end else begin
transfer_array[off].req.wdt[byt] = transaction_req.wdt[siz - 1 - i];
end
end
return(transfer_array);
endfunction: transaction_request
// read/write response transaction of power of 2 size
static function automatic transaction_response_t transaction_response (
int unsigned siz,
transfer_array_t transfer_array
);
// temporary variables
int unsigned byt; // byte index
int unsigned off; // address offset
// transaction response
int unsigned len;
transaction_response_t transaction_rsp = '{rdt: 'x, sts: '0};
// data signals
for (int unsigned i=0; i<siz; i++) begin
// address offset
off = i / PHY_BEW;
// mode processor/memory
if (PHY.MOD == TCB_REFERENCE) begin
// all data bytes are LSB aligned
byt = i;
end else if (PHY.MOD == TCB_MEMORY) begin
// all data bytes are LSB aligned
byt = (i + transfer_array[off].req.adr) % PHY_BEW;
end
// order descending/ascending
if (PHY.ORD == TCB_ASCENDING) begin
byt = PHY_BEW - 1 - byt;
end
// endianness
if (transfer_array[off].req.ndn == TCB_LITTLE) begin
transaction_rsp.rdt[ i] = transfer_array[off].rsp.rdt[byt];
end else begin
transaction_rsp.rdt[siz - 1 - i] = transfer_array[off].rsp.rdt[byt];
end
// response status
transaction_rsp.sts |= transfer_array[off].rsp.sts;
end
return(transaction_rsp);
endfunction: transaction_response
////////////////////////////////////////////////////////////////////////////////
// transaction
////////////////////////////////////////////////////////////////////////////////
task automatic transaction8 (
// request
input logic wen,
input logic [PHY.ABW-1:0] adr,
input logic [1-1:0][PHY.SLW-1:0] wdt,
// response
output logic [1-1:0][PHY.SLW-1:0] rdt,
output tcb_rsp_sts_t sts,
// endianness
input tcb_cfg_endian_t ndn = TCB_LITTLE
);
transfer_array_t transfer_array;
transaction_t transaction;
// request
transaction.req = '{ndn: ndn, wen: wen, adr: adr, wdt: wdt};
transfer_array = transaction_request(1, transaction.req);
// transaction
transfer_sequencer(transfer_array);
// response
transaction.rsp = transaction_response(1, transfer_array);
// cleanup
transfer_array.delete;
// outputs
rdt = transaction.rsp.rdt;
sts = transaction.rsp.sts;
endtask: transaction8
task automatic transaction16 (
// request
input logic wen,
input logic [PHY.ABW-1:0] adr,
input logic [2-1:0][PHY.SLW-1:0] wdt,
// response
output logic [2-1:0][PHY.SLW-1:0] rdt,
output tcb_rsp_sts_t sts,
// endianness
input tcb_cfg_endian_t ndn = TCB_LITTLE
);
transfer_array_t transfer_array;
transaction_t transaction;
// request
transaction.req = '{ndn: ndn, wen: wen, adr: adr, wdt: wdt};
transfer_array = transaction_request(2, transaction.req);
// transaction
transfer_sequencer(transfer_array);
// response
transaction.rsp = transaction_response(2, transfer_array);
// cleanup
transfer_array.delete;
// outputs
rdt = transaction.rsp.rdt;
sts = transaction.rsp.sts;
endtask: transaction16
task automatic transaction32 (
// request
input logic wen,
input logic [PHY.ABW-1:0] adr,
input logic [4-1:0][PHY.SLW-1:0] wdt,
// response
output logic [4-1:0][PHY.SLW-1:0] rdt,
output tcb_rsp_sts_t sts,
// endianness
input tcb_cfg_endian_t ndn = TCB_LITTLE
);
transfer_array_t transfer_array;
transaction_t transaction;
// request
transaction.req = '{ndn: ndn, wen: wen, adr: adr, wdt: wdt};
transfer_array = transaction_request(4, transaction.req);
// transaction
transfer_sequencer(transfer_array);
// response
transaction.rsp = transaction_response(4, transfer_array);
// cleanup
transfer_array.delete;
// outputs
rdt = transaction.rsp.rdt;
sts = transaction.rsp.sts;
endtask: transaction32
task automatic transaction64 (
// request
input logic wen,
input logic [PHY.ABW-1:0] adr,
input logic [8-1:0][PHY.SLW-1:0] wdt,
// response
output logic [8-1:0][PHY.SLW-1:0] rdt,
output tcb_rsp_sts_t sts,
// endianness
input tcb_cfg_endian_t ndn = TCB_LITTLE
);
transfer_array_t transfer_array;
transaction_t transaction;
// request
transaction.req = '{ndn: ndn, wen: wen, adr: adr, wdt: wdt};
transfer_array = transaction_request(8, transaction.req);
// transaction
transfer_sequencer(transfer_array);
// response
transaction.rsp = transaction_response(8, transfer_array);
// cleanup
transfer_array.delete;
// outputs
rdt = transaction.rsp.rdt;
sts = transaction.rsp.sts;
endtask: transaction64
task automatic transaction128 (
// request
input logic wen,
input logic [PHY.ABW-1:0] adr,
input logic [16-1:0][PHY.SLW-1:0] wdt,
// response
output logic [16-1:0][PHY.SLW-1:0] rdt,
output tcb_rsp_sts_t sts,
// endianness
input tcb_cfg_endian_t ndn = TCB_LITTLE
);
transfer_array_t transfer_array;
transaction_t transaction;
// request
transaction.req = '{ndn: ndn, wen: wen, adr: adr, wdt: wdt};
transfer_array = transaction_request(16, transaction.req);
// transaction
transfer_sequencer(transfer_array);
// response
transaction.rsp = transaction_response(16, transfer_array);
// cleanup
transfer_array.delete;
// outputs
rdt = transaction.rsp.rdt;
sts = transaction.rsp.sts;
endtask: transaction128
task write8 (
input logic [PHY.ABW-1:0] adr,
input logic [1-1:0][PHY.SLW-1:0] wdt,
output logic sts
);
logic [1-1:0][PHY.SLW-1:0] rdt;
transaction8(1'b1, adr, wdt, rdt, sts);
endtask: write8
task read8 (
input logic [PHY.ABW-1:0] adr,
output logic [1-1:0][PHY.SLW-1:0] rdt,
output logic sts
);
logic [1-1:0][PHY.SLW-1:0] wdt = 'x;
transaction8(1'b0, adr, wdt, rdt, sts);
endtask: read8
task check8 (
input logic [PHY.ABW-1:0] adr,
input logic [1-1:0][PHY.SLW-1:0] rdt,
input logic sts
);
logic [1-1:0][PHY.SLW-1:0] tmp_wdt = 'x;
logic [1-1:0][PHY.SLW-1:0] tmp_rdt;
logic tmp_sts;
transaction8(1'b0, adr, tmp_wdt, tmp_rdt, tmp_sts);
if (tmp_rdt !== rdt) $display("ERROR: %m: (rdt=8'h%2X) !== (dat=8'h%2X) mismatch.", tmp_rdt, rdt);
if (tmp_sts !== sts) $display("ERROR: %m: (sts=1'b%1b) !== (sts=1'b%1b) mismatch.", tmp_sts, sts);
endtask: check8
task write16 (
input logic [PHY.ABW-1:0] adr,
input logic [2-1:0][PHY.SLW-1:0] wdt,
output logic sts
);
logic [2-1:0][PHY.SLW-1:0] rdt;
transaction16(1'b1, adr, wdt, rdt, sts);
endtask: write16
task read16 (
input logic [PHY.ABW-1:0] adr,
output logic [2-1:0][PHY.SLW-1:0] rdt,
output logic sts
);
logic [4-1:0][PHY.SLW-1:0] wdt = 'x;
transaction16(1'b0, adr, wdt, rdt, sts);
endtask: read16
task check16 (
input logic [PHY.ABW-1:0] adr,
input logic [2-1:0][PHY.SLW-1:0] rdt,
input logic sts
);
logic [2-1:0][PHY.SLW-1:0] tmp_wdt = 'x;
logic [2-1:0][PHY.SLW-1:0] tmp_rdt;
logic tmp_sts;
transaction16(1'b0, adr, tmp_wdt, tmp_rdt, tmp_sts);
if (tmp_rdt !== rdt) $display("ERROR: %m: (rdt=16'h%4X) !== ref(rdt=16'h%4X) mismatch.", tmp_rdt, rdt);
if (tmp_sts !== sts) $display("ERROR: %m: (sts= 1'b%1b) !== ref(sts= 1'b%1b) mismatch.", tmp_sts, sts);
endtask: check16
task write32 (
input logic [PHY.ABW-1:0] adr,
input logic [4-1:0][PHY.SLW-1:0] wdt,
output logic sts
);
logic [4-1:0][PHY.SLW-1:0] rdt;
transaction32(1'b1, adr, wdt, rdt, sts);
endtask: write32
task read32 (
input logic [PHY.ABW-1:0] adr,
output logic [4-1:0][PHY.SLW-1:0] rdt,
output logic sts
);
logic [4-1:0][PHY.SLW-1:0] wdt = 'x;
transaction32(1'b0, adr, wdt, rdt, sts);
endtask: read32
task check32 (
input logic [PHY.ABW-1:0] adr,
input logic [4-1:0][PHY.SLW-1:0] rdt,
input logic sts
);
logic [4-1:0][PHY.SLW-1:0] tmp_wdt = 'x;
logic [4-1:0][PHY.SLW-1:0] tmp_rdt;
logic tmp_sts;
transaction32(1'b0, adr, tmp_wdt, tmp_rdt, tmp_sts);
if (tmp_rdt !== rdt) $display("ERROR: %m: (rdt=32'h%8X) !== ref(rdt=32'h%8X) mismatch.", tmp_rdt, rdt);
if (tmp_sts !== sts) $display("ERROR: %m: (sts= 1'b%1b) !== ref(sts= 1'b%1b) mismatch.", tmp_sts, sts);
endtask: check32
task write64 (
input logic [PHY.ABW-1:0] adr,
input logic [8-1:0][PHY.SLW-1:0] wdt,
output logic sts
);
logic [8-1:0][PHY.SLW-1:0] rdt;
transaction64(1'b1, adr, wdt, rdt, sts);
endtask: write64
task read64 (
input logic [PHY.ABW-1:0] adr,
output logic [8-1:0][PHY.SLW-1:0] rdt,
output logic sts
);
logic [8-1:0][PHY.SLW-1:0] wdt = 'x;
transaction64(1'b0, adr, wdt, rdt, sts);
endtask: read64
task check64 (
input logic [PHY.ABW-1:0] adr,
input logic [8-1:0][PHY.SLW-1:0] rdt,
input logic sts
);
logic [8-1:0][PHY.SLW-1:0] tmp_wdt = 'x;
logic [8-1:0][PHY.SLW-1:0] tmp_rdt;
logic tmp_sts;
transaction64(1'b0, adr, tmp_wdt, tmp_rdt, tmp_sts);
if (tmp_rdt !== rdt) $display("ERROR: %m: (rdt=64'h%16X) !== (dat=64'h%16X) mismatch.", tmp_rdt, rdt);
if (tmp_sts !== sts) $display("ERROR: %m: (sts= 1'b%01b) !== (sts= 1'b%01b) mismatch.", tmp_sts, sts);
endtask: check64
task write128 (
input logic [PHY.ABW-1:0] adr,
input logic [16-1:0][PHY.SLW-1:0] wdt,
output logic sts
);
logic [16-1:0][PHY.SLW-1:0] rdt;
transaction128(1'b1, adr, wdt, rdt, sts);
endtask: write128
task read128 (
input logic [PHY.ABW-1:0] adr,
output logic [16-1:0][PHY.SLW-1:0] rdt,
output logic sts
);
logic [16-1:0][PHY.SLW-1:0] wdt = 'x;
transaction128(1'b0, adr, wdt, rdt, sts);
endtask: read128
task check128 (
input logic [PHY.ABW-1:0] adr,
input logic [16-1:0][PHY.SLW-1:0] rdt,
input logic sts
);
logic [16-1:0][PHY.SLW-1:0] tmp_wdt = 'x;
logic [16-1:0][PHY.SLW-1:0] tmp_rdt;
logic tmp_sts;
transaction128(1'b0, adr, tmp_wdt, tmp_rdt, tmp_sts);
if (tmp_rdt !== rdt) $display("ERROR: %m: (rdt=128'h%32X) !== (dat=128'h%32X) mismatch.", tmp_rdt, rdt);
if (tmp_sts !== sts) $display("ERROR: %m: (sts= 1'b%01b) !== (sts= 1'b%01b) mismatch.", tmp_sts, sts);
endtask: check128
endclass: tcb_transfer_c
endpackage: tcb_vip_pkg