librstb 0.1.1

Write HDL-Testbenches in Rust.
Documentation
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
/***************************************************************************
* sv_vpi_user.h
*
* SystemVerilog VPI extensions.
*
* This file contains the constant definitions, structure definitions, and
* routine declarations used by the SystemVerilog Verification Procedural
* Interface (VPI) access routines.
*
***************************************************************************/

/***************************************************************************
* NOTE:
* The constant values 600 through 999 are reserved for use in this file.
* - the range 600-749 is reserved for SV VPI model extensions
* - the range 750-779 is reserved for the Coverage VPI
* - the range 800-899 is reserved for future use
* Overlaps in the numerical ranges are permitted for different categories
* of identifiers; e.g.
* - object types
* - properties
* - callbacks
**************************************************************************/

#ifndef SV_VPI_USER_H
#define SV_VPI_USER_H

#include <vpi_user.h>

#ifdef __cplusplus
extern "C" {
#endif

/****************************** OBJECT TYPES ******************************/
#define vpiPackage                            600
#define vpiInterface                          601
#define vpiProgram                            602
#define vpiInterfaceArray                     603
#define vpiProgramArray                       604
#define vpiTypespec                           605
#define vpiModport                            606
#define vpiInterfaceTfDecl                    607
#define vpiRefObj                             608
#define vpiTypeParameter                      609

/* variables */
#define vpiVarBit                             vpiRegBit
#define vpiLongIntVar                         610
#define vpiShortIntVar                        611
#define vpiIntVar                             612
#define vpiShortRealVar                       613
#define vpiByteVar                            614
#define vpiClassVar                           615
#define vpiStringVar                          616
#define vpiEnumVar                            617
#define vpiStructVar                          618
#define vpiUnionVar                           619
#define vpiBitVar                             620
#define vpiLogicVar                           vpiReg
#define vpiArrayVar                           vpiRegArray
#define vpiClassObj                           621
#define vpiChandleVar                         622
#define vpiPackedArrayVar                     623
#define vpiVirtualInterfaceVar                728

/* typespecs */
#define vpiLongIntTypespec                    625
#define vpiShortRealTypespec                  626
#define vpiByteTypespec                       627
#define vpiShortIntTypespec                   628
#define vpiIntTypespec                        629
#define vpiClassTypespec                      630
#define vpiStringTypespec                     631
#define vpiChandleTypespec                    632
#define vpiEnumTypespec                       633
#define vpiEnumConst                          634
#define vpiIntegerTypespec                    635
#define vpiTimeTypespec                       636
#define vpiRealTypespec                       637
#define vpiStructTypespec                     638
#define vpiUnionTypespec                      639
#define vpiBitTypespec                        640
#define vpiLogicTypespec                      641
#define vpiArrayTypespec                      642
#define vpiVoidTypespec                       643
#define vpiTypespecMember                     644
#define vpiPackedArrayTypespec                692
#define vpiSequenceTypespec                   696
#define vpiPropertyTypespec                   697
#define vpiEventTypespec                      698

#define vpiClockingBlock                      650
#define vpiClockingIODecl                     651
#define vpiClassDefn                          652
#define vpiConstraint                         653
#define vpiConstraintOrdering                 654

#define vpiDistItem                           645
#define vpiAliasStmt                          646
#define vpiThread                             647
#define vpiMethodFuncCall                     648
#define vpiMethodTaskCall                     649

/* concurrent assertions */
#define vpiAssert                             686
#define vpiAssume                             687
#define vpiCover                              688
#define vpiRestrict                           901

#define vpiDisableCondition                   689
#define vpiClockingEvent                      690

/* property decl, spec */
#define vpiPropertyDecl                       655
#define vpiPropertySpec                       656
#define vpiPropertyExpr                       657
#define vpiMulticlockSequenceExpr             658
#define vpiClockedSeq                         659
#define vpiClockedProp                        902
#define vpiPropertyInst                       660
#define vpiSequenceDecl                       661
#define vpiCaseProperty                       662 /* property case */
#define vpiCasePropertyItem                   905 /* property case item */
#define vpiSequenceInst                       664
#define vpiImmediateAssert                    665
#define vpiImmediateAssume                    694
#define vpiImmediateCover                     695
#define vpiReturn                             666
/* pattern */
#define vpiAnyPattern                         667
#define vpiTaggedPattern                      668
#define vpiStructPattern                      669
/* do .. while */
#define vpiDoWhile                            670
/* waits */
#define vpiOrderedWait                        671
#define vpiWaitFork                           672
/* disables */
#define vpiDisableFork                        673
#define vpiExpectStmt                         674
#define vpiForeachStmt                        675
#define vpiReturnStmt                         691
#define vpiFinal                              676
#define vpiExtends                            677
#define vpiDistribution                       678
#define vpiSeqFormalDecl                      679
#define vpiPropFormalDecl                     699
#define vpiArrayNet                           vpiNetArray
#define vpiEnumNet                            680
#define vpiIntegerNet                         681
#define vpiLogicNet                           vpiNet
#define vpiTimeNet                            682
#define vpiStructNet                          683
#define vpiBreak                              684
#define vpiContinue                           685
#define vpiPackedArrayNet                     693
#define vpiConstraintExpr                     747
#define vpiElseConst                          748
#define vpiImplication                        749
#define vpiConstrIf                           738
#define vpiConstrIfElse                       739
#define vpiConstrForEach                      736
#define vpiLetDecl                            903
#define vpiLetExpr                            904

/******************************** METHODS *********************************/
/************* methods used to traverse 1 to 1 relationships **************/
#define vpiActual                             700

#define vpiTypedefAlias                       701

#define vpiIndexTypespec                      702
#define vpiBaseTypespec                       703
#define vpiElemTypespec                       704

#define vpiInputSkew                          706
#define vpiOutputSkew                         707
#define vpiGlobalClocking                     708
#define vpiDefaultClocking                    709
#define vpiDefaultDisableIff                  710

#define vpiOrigin                             713
#define vpiPrefix                             714
#define vpiWith                               715

#define vpiProperty                           718

#define vpiValueRange                         720
#define vpiPattern                            721
#define vpiWeight                             722
#define vpiConstraintItem                     746

/************ methods used to traverse 1 to many relationships ************/
#define vpiTypedef                            725
#define vpiImport                             726
#define vpiDerivedClasses                     727
#define vpiInterfaceDecl vpiVirtualInterfaceVar /* interface decl deprecated */

#define vpiMethods                            730
#define vpiSolveBefore                        731
#define vpiSolveAfter                         732

#define vpiWaitingProcesses                   734

#define vpiMessages                           735
#define vpiLoopVars                           737

#define vpiConcurrentAssertions               740
#define vpiMatchItem                          741
#define vpiMember                             742
#define vpiElement                            743

/************* methods used to traverse 1 to many relationships ***************/
#define vpiAssertion                          744

/*********** methods used to traverse both 1-1 and 1-many relations ***********/
#define vpiInstance                           745

/**************************************************************************/
/************************ generic object properties ***********************/
/**************************************************************************/

#define vpiTop                                600

#define vpiUnit                               602
#define vpiJoinType                           603
#define vpiJoin                            0
#define vpiJoinNone                        1
#define vpiJoinAny                         2
#define vpiAccessType                         604
#define vpiForkJoinAcc                     1
#define vpiExternAcc                       2
#define vpiDPIExportAcc                    3
#define vpiDPIImportAcc                    4

#define vpiArrayType                          606
#define vpiStaticArray                     1
#define vpiDynamicArray                    2
#define vpiAssocArray                      3
#define vpiQueueArray                      4
#define vpiArrayMember                        607

#define vpiIsRandomized                       608
#define vpiLocalVarDecls                      609
#define vpiOpStrong                           656 /* strength of temporal operator */
#define vpiRandType                           610
#define vpiNotRand                         1
#define vpiRand                            2
#define vpiRandC                           3
#define vpiPortType                           611
#define vpiInterfacePort                   1
#define vpiModportPort                     2
/* vpiPort is also a port type. It is defined in vpi_user.h */

#define vpiConstantVariable                   612
#define vpiStructUnionMember                  615

#define vpiVisibility                         620
#define vpiPublicVis                       1
#define vpiProtectedVis                    2
#define vpiLocalVis                        3

/* Return values for vpiConstType property */
#define vpiOneStepConst                    9
#define vpiUnboundedConst                 10
#define vpiNullConst                      11

#define vpiAlwaysType                         624
#define vpiAlwaysComb                      2
#define vpiAlwaysFF                        3
#define vpiAlwaysLatch                     4

#define vpiDistType                           625
#define vpiEqualDist                       1 /* constraint equal distribution */
#define vpiDivDist                         2 /* constraint divided distribution */

#define vpiPacked                             630
#define vpiTagged                             632
#define vpiRef                             6 /* Return value for vpiDirection property */
#define vpiVirtual                            635
#define vpiHasActual                          636
#define vpiIsConstraintEnabled                638
#define vpiSoft                               639


#define vpiClassType                          640
#define vpiMailboxClass                    1
#define vpiSemaphoreClass                  2
#define vpiUserDefinedClass                3
#define vpiProcessClass                    4
#define vpiMethod                             645
#define vpiIsClockInferred                    649
#define vpiIsDeferred                         657
#define vpiIsFinal                            658
#define vpiIsCoverSequence                    659
#define vpiQualifier                          650
#define vpiNoQualifier                     0
#define vpiUniqueQualifier                 1
#define vpiPriorityQualifier               2
#define vpiTaggedQualifier                 4
#define vpiRandQualifier                   8
#define vpiInsideQualifier                16

#define vpiInputEdge                          651 /* returns vpiNoEdge, vpiPosedge,
                                                     vpiNegedge */
#define vpiOutputEdge                         652 /* returns vpiNoEdge, vpiPosedge,
                                                     vpiNegedge */
#define vpiGeneric                            653

/* Compatibility-mode property and values (object argument == NULL) */
#define vpiCompatibilityMode                  654
#define vpiMode1364v1995                   1
#define vpiMode1364v2001                   2
#define vpiMode1364v2005                   3
#define vpiMode1800v2005                   4
#define vpiMode1800v2009                   5

#define vpiPackedArrayMember                  655
#define vpiStartLine                          661
#define vpiColumn                             662
#define vpiEndLine                            663
#define vpiEndColumn                          664

/* memory allocation scheme for transient objects */
#define vpiAllocScheme                        658
#define vpiAutomaticScheme                 1
#define vpiDynamicScheme                   2
#define vpiOtherScheme                     3

#define vpiObjId                              660

#define vpiDPIPure                            665
#define vpiDPIContext                         666
#define vpiDPICStr                            667
#define vpiDPI                             1
#define vpiDPIC                            2
#define vpiDPICIdentifier                     668

/******************************** Operators *******************************/
#define vpiImplyOp                        50 /* -> implication operator */
#define vpiNonOverlapImplyOp              51 /* |=> nonoverlapped implication */
#define vpiOverlapImplyOp                 52 /* |-> overlapped implication operator */
#define vpiAcceptOnOp                     83 /* accept_on operator */
#define vpiRejectOnOp                     84 /* reject_on operator */
#define vpiSyncAcceptOnOp                 85 /* sync_accept_on operator */
#define vpiSyncRejectOnOp                 86 /* sync_reject_on operator */
#define vpiOverlapFollowedByOp            87 /* overlapped followed_by operator */
#define vpiNonOverlapFollowedByOp         88 /* nonoverlapped followed_by operator */
#define vpiNexttimeOp                     89 /* nexttime operator */
#define vpiAlwaysOp                       90 /* always operator */
#define vpiEventuallyOp                   91 /* eventually operator */
#define vpiUntilOp                        92 /* until operator */
#define vpiUntilWithOp                    93 /* until_with operator */

#define vpiUnaryCycleDelayOp              53 /* binary cycle delay (##) operator */
#define vpiCycleDelayOp                   54 /* binary cycle delay (##) operator */
#define vpiIntersectOp                    55 /* intersection operator */
#define vpiFirstMatchOp                   56 /* first_match operator */
#define vpiThroughoutOp                   57 /* throughout operator */
#define vpiWithinOp                       58 /* within operator */
#define vpiRepeatOp                       59 /* [=] nonconsecutive repetition */
#define vpiConsecutiveRepeatOp            60 /* [*] consecutive repetition */
#define vpiGotoRepeatOp                   61 /* [->] goto repetition */

#define vpiPostIncOp                      62 /* ++ post-increment */
#define vpiPreIncOp                       63 /* ++ pre-increment */
#define vpiPostDecOp                      64 /* -- post-decrement */
#define vpiPreDecOp                       65 /* -- pre-decrement */

#define vpiMatchOp                        66 /* match() operator */
#define vpiCastOp                         67 /* type'() operator */
#define vpiIffOp                          68 /* iff operator */
#define vpiWildEqOp                       69 /* ==? operator */
#define vpiWildNeqOp                      70 /* !=? operator */

#define vpiStreamLROp                     71 /* left-to-right streaming {>>} operator */
#define vpiStreamRLOp                     72 /* right-to-left streaming {<<} operator */

#define vpiMatchedOp                      73 /* the .matched sequence operation */
#define vpiTriggeredOp                    74 /* the .triggered sequence operation */
#define vpiAssignmentPatternOp            75 /* '{} assignment pattern */
#define vpiMultiAssignmentPatternOp       76 /* '{n{}} multi assignment pattern */
#define vpiIfOp                           77 /* if operator */
#define vpiIfElseOp                       78 /* if/else operator */
#define vpiCompAndOp                      79 /* Composite and operator */
#define vpiCompOrOp                       80 /* Composite or operator */
#define vpiImpliesOp                      94 /* implies operator */
#define vpiInsideOp                       95 /* inside operator */
#define vpiTypeOp                         81 /* type operator */
#define vpiAssignmentOp                   82 /* Normal assignment */

/*********************** task/function properties ***********************/
#define vpiOtherFunc                       6 /* returns other types; for property vpiFuncType */
/* vpiValid,vpiValidTrue,vpiValidFalse are deprecated in 1800-2009 */

/*********************** value for vpiValid *****************************/
#define vpiValidUnknown                    2 /* Validity of variable is unknown */

/************************** STRUCTURE DEFINITIONS *************************/

/***************************** structure *****************************/

/**************************** CALLBACK REASONS ****************************/
#define cbStartOfThread                       600 /* callback on thread creation */
#define cbEndOfThread                         601 /* callback on thread termination */
#define cbEnterThread                         602 /* callback on reentering thread */
#define cbStartOfFrame                        603 /* callback on frame creation */
#define cbEndOfFrame                          604 /* callback on frame exit */
#define cbSizeChange                          605 /* callback on array variable size change */
#define cbCreateObj                           700 /* callback on class object creation */
#define cbReclaimObj                          701 /* callback on class object reclaimed by automatic memory management */

#define cbEndOfObject                         702 /* callback on transient object deletion */

/************************* FUNCTION DECLARATIONS **************************/


/**************************************************************************/
/*************************** Coverage VPI *********************************/
/**************************************************************************/

/* coverage control */
#define vpiCoverageStart                      750
#define vpiCoverageStOp                       751
#define vpiCoverageReset                      752
#define vpiCoverageCheck                      753
#define vpiCoverageMerge                      754
#define vpiCoverageSave                       755

/* coverage type properties */
#define vpiAssertCoverage                     760
#define vpiFsmStateCoverage                   761
#define vpiStatementCoverage                  762
#define vpiToggleCoverage                     763

/* coverage status properties */
#define vpiCovered                            765
#define vpiCoverMax                           766
#define vpiCoveredCount                       767

/* assertion-specific coverage status properties */
#define vpiAssertAttemptCovered               770
#define vpiAssertSuccessCovered               771
#define vpiAssertFailureCovered               772
#define vpiAssertVacuousSuccessCovered        773
#define vpiAssertDisableCovered               774
#define vpiAssertKillCovered                  777

/* FSM-specific coverage status properties */
#define vpiFsmStates                          775
#define vpiFsmStateExpression                 776

/* FSM handle types */
#define vpiFsm                                758
#define vpiFsmHandle                          759


/***************************************************************************/
/***************************** Assertion VPI *******************************/
/***************************************************************************/

/* assertion callback types */
#define cbAssertionStart                      606
#define cbAssertionSuccess                    607
#define cbAssertionFailure                    608
#define cbAssertionVacuousSuccess             657
#define cbAssertionDisabledEvaluation         658
#define cbAssertionStepSuccess                609
#define cbAssertionStepFailure                610
#define cbAssertionLock                       661
#define cbAssertionUnlock                     662
#define cbAssertionDisable                    611
#define cbAssertionEnable                     612
#define cbAssertionReset                      613
#define cbAssertionKill                       614
#define cbAssertionEnablePassAction           645
#define cbAssertionEnableFailAction           646
#define cbAssertionDisablePassAction          647
#define cbAssertionDisableFailAction          648
#define cbAssertionEnableNonvacuousAction     649
#define cbAssertionDisableVacuousAction       650

/* assertion "system" callback types */
#define cbAssertionSysInitialized             615
#define cbAssertionSysOn                      616
#define cbAssertionSysOff                     617
#define cbAssertionSysKill                    631
#define cbAssertionSysLock                    659
#define cbAssertionSysUnlock                  660
#define cbAssertionSysEnd                     618
#define cbAssertionSysReset                   619
#define cbAssertionSysEnablePassAction        651
#define cbAssertionSysEnableFailAction        652
#define cbAssertionSysDisablePassAction       653
#define cbAssertionSysDisableFailAction       654
#define cbAssertionSysEnableNonvacuousAction  655
#define cbAssertionSysDisableVacuousAction    656

/* assertion control constants */
#define vpiAssertionLock                      645
#define vpiAssertionUnlock                    646
#define vpiAssertionDisable                   620
#define vpiAssertionEnable                    621
#define vpiAssertionReset                     622
#define vpiAssertionKill                      623
#define vpiAssertionEnableStep                624
#define vpiAssertionDisableStep               625
#define vpiAssertionClockSteps                626
#define vpiAssertionSysLock                   647
#define vpiAssertionSysUnlock                 648
#define vpiAssertionSysOn                     627
#define vpiAssertionSysOff                    628
#define vpiAssertionSysKill                   632
#define vpiAssertionSysEnd                    629
#define vpiAssertionSysReset                  630
#define vpiAssertionDisablePassAction         633
#define vpiAssertionEnablePassAction          634
#define vpiAssertionDisableFailAction         635
#define vpiAssertionEnableFailAction          636
#define vpiAssertionDisableVacuousAction      637
#define vpiAssertionEnableNonvacuousAction    638
#define vpiAssertionSysEnablePassAction       639
#define vpiAssertionSysEnableFailAction       640
#define vpiAssertionSysDisablePassAction      641
#define vpiAssertionSysDisableFailAction      642
#define vpiAssertionSysEnableNonvacuousAction 643
#define vpiAssertionSysDisableVacuousAction   644


typedef struct t_vpi_assertion_step_info {
   PLI_INT32 matched_expression_count;
   vpiHandle *matched_exprs;        /* array of expressions */
   PLI_INT32 stateFrom, stateTo;    /* identify transition */
} s_vpi_assertion_step_info, *p_vpi_assertion_step_info;

typedef struct t_vpi_attempt_info {
   union {
      vpiHandle failExpr;
      p_vpi_assertion_step_info step;
   } detail;
   s_vpi_time attemptStartTime;     /* Time attempt triggered */
} s_vpi_attempt_info, *p_vpi_attempt_info;

/* typedef for vpi_register_assertion_cb callback function */
typedef PLI_INT32(vpi_assertion_callback_func)(
   PLI_INT32 reason,                /* callback reason */
   p_vpi_time cb_time,              /* callback time */
   vpiHandle assertion,             /* handle to assertion */
   p_vpi_attempt_info info,         /* attempt related information */
   PLI_BYTE8 *user_data             /* user data entered upon registration */
);

vpiHandle vpi_register_assertion_cb(
   vpiHandle assertion,             /* handle to assertion */
   PLI_INT32 reason,                /* reason for which callbacks needed */
   vpi_assertion_callback_func *cb_rtn,
   PLI_BYTE8 *user_data             /* user data to be supplied to cb */
);

#ifdef __cplusplus
}
#endif

#endif