/***************************************************************************
 * sv_vpi_user.h
 *
 * Accellera SystemVerilog VPI extensions.
 *
 * This file contains the constant definitions, structure definitions, and
 * routine declarations used by the Verilog PLI procedural interface VPI
 * access routines.
 *
 **************************************************************************/

#ifndef SV_VPI_USER_H
#define SV_VPI_USER_H

#include <vpi_user.h>

#ifdef __cplusplus
extern "C" {
#endif
}

/****************************** OBJECT TYPES ******************************/
#define vpiPackage 500
#define vpiInterface 501
#define vpiProgram 502
#define vpiInterfaceArray 503
#define vpiProgramArray 504
#define vpiTypespec 505
#define vpiModport 506
#define vpiInterfaceTfDecl 507
#define vpiRefObj 508
#define vpiVarBitVar         vpiRegBit
#define vpiLongIntVar 509
#define vpiShortIntVar 510
#define vpiIntVar 511
#define vpiShortRealVar 512
#define vpiByteVar 513
#define vpiClassVar 514
#define vpiStringVar 515
#define vpiEnumVar 516
#define vpiStructVar 517
#define vpiUnionVar 518
#define vpiBitVar 519
#define vpiLogicVar          vpiRegVar
#define vpiArrayVar          vpiRegArray
#define vpiLongIntTypespec 520
#define vpiShortRealTypespec 521
#define vpiByteTypespec 522
#define vpiShortIntTypespec 523
#define vpiIntTypespec 524
#define vpiClassTypespec 525
#define vpiStringTypespec 526
#define vpiVarBitTypespec 527
#define vpiEnumTypespec 528
#define vpiEnumConst 529
#define vpiIntegerTypespec 530
#define vpiTimeTypespec 531
#define vpiRealTypespec 532
#define vpiStructTypespec 533
#define vpiUnionTypespec 534
#define vpiBitTypespec 535
#define vpiLogicTypespec 536
#define vpiArrayTypespec 537
#define vpiVoidTypespec 538
#define vpiMemberTypespec 539
#define vpiClockingBlock 540
#define vpiClockingIODecl 541
#define vpiClassDefn 542
#define vpiConstraint 543
#define vpiConstraintOrdering 544
#define vpiConstraintDist 545
#define vpiDistItem 546
#define vpiAliasStmt 547
#define vpiThread 548
#define vpiMethodFuncCall 549
#define vpiMethodTaskCall 550
#define vpiAssertProperty 551
#define vpiAssumeProperty 552
#define vpiCoverProperty 553
#define vpiDisableCondition 554
#define vpiClockingEvent 555
#define vpiPropertyDecl 556
#define vpiPropertySpec 557
#define vpiPropertyExpr 558
#define vpiMulticlockSequenceExpr 559
#define vpiClockedSeq 560
#define vpiPropertyInst 561
#define vpiSequenceDecl 562
#define vpiSequenceSpec 563
#define vpiActualArgExpr 564
#define vpiSequenceInst 565
#define vpiImmediateAssert 566
#define vpiReturn 567
#define vpiAnyPattern 568
#define vpiTaggedPattern 569
#define vpiStructPattern 570
#define vpiDoWhile 571
#define vpiOrderedWait 572
#define vpiWaitFork 573
#define vpiDisableFork 574
#define vpiExpectStmt 575
#define vpiForeachStmt 576
#define vpiFinal 577


/******************************** METHODS *********************************/
/************* methods used to traverse 1 to 1 relationships **************/
#define vpiInterfaceConn 500
#define vpiTypedefAlias 501
#define vpiBaseTypespec 502
#define vpiElemTypespec 503
#define vpiDefInputSkew 504
#define vpiDefOutputSkew 505
#define vpiSkew 506
#define vpiBaseClass 507
#define vpiActualDefn 508
#define vpiLhs 509
#define vpiRhs 510
#define vpiOrigin 511
#define vpiPrefix 512
#define vpiWith 513
#define vpiSuccessStmt 514
#define vpiFailStmt 515
#define vpiProperty 516



/************ methods used to traverse 1 to many relationships ************/
#define vpiTypedef 517
#define vpiDefaultClocking 518
#define vpiInstance 519
#define vpiImport 520
#define vpiDerivedClasses 521
#define vpiMethods 522
#define vpiSolveBefore 523
#define vpiSolveAfter 524
#define vpiWeight 525
#define vpiWaitingProcesses 526
#define vpiMessages 527
#define vpiMembers 528
#define vpiLoopVars 529



/************************ generic object properties ***********************/
#define vpiTop 530
#define vpiUnit 531
#define vpiAccessType 532
#define vpiForkJoin 533
#define vpiExtern 534
#define vpiDPIExtern 535
#define vpiDPIImport 536
#define vpiArrayType 537
#define vpiDynamicArray 538
#define vpiQueueArray 539
#define vpiStaticArray 540
#define vpiIsRandomized 541
#define vpiRandType 542
#define vpiVpiRand 543
#define vpiRandC 544
#define vpiNotRand 545
#define vpiConstantVar 546
#define vpiMember 547
#define vpiVisibility 548
#define vpiPublic 549
#define vpiProtected 550
#define vpiPrivate 551
#define vpiPacked 552
#define vpiTagged 553
#define vpiRef 554
#define vpiDefaultSkew 555
#define vpiVirtual 556
#define vpiUserDefined 557
#define vpiIsConstraintEnabled 558
#define vpiClassType 559
#define vpiMailbox 560
#define vpiSemaphore 561
#define vpiAssociativeArray 562
#define vpiIndexTypespec 563
#define vpiMethod 564
#define vpiValid 565
#define vpiActive 566
#define vpiIsClockInferred 567
#define vpiUniqueQualifier 568
#define vpiPriorityQualifier 569
#define vpiTaggedQualifier 570
#define vpiNullConst 571
#define vpiOneStepConst 572
#define VpiAlwaysType 573
#define vpiAlwaysComb 574
#define vpiAlwaysFF 575
#define vpiAlwaysLatch 576

/******************************** Operators *******************************/
#define vpiEqualDist 577                      /* constraint equal distribution operator */
#define vpiDivDist 578                        /* constraint divided distribution operator */

#define vpiImplyOp 579                        /* -> implication operator */
#define vpiNonOverlapImplyOp 580              /* |=> non-overlapped implication */
#define vpiOverlapImplyOp 581                 /* |-> overlapped implication operator */
#define vpiUnaryCycleDelayOp 582              /* binary cycle delay (##) operator */
#define vpiCycleDelayOp 583                   /* binary cycle delay (##) operator */
#define vpiIntersectOp 584                    /* intersection operator */
#define vpiFirstMatchOp 585                   /* first_match operator */
#define vpiThroughoutOp 586                   /* throught operator */
#define vpiWithinOp 587                       /* within operator */
#define vpiRepeatOp 588                       /* [*=] non-consecutive repetition */
#define vpiConsecutiveRepeatOp 589            /* [*] consecutive repetition */
#define vpiGotoRepeatOp 590                   /* [*->] goto repetition */

#define vpiPostIncOp 591                      /* ++ post-increment */
#define vpiPreIncOp 592                       /* ++ pre-increment */
#define vpiPostDecOp 593                      /* -- post-decrement */
#define vpiPreDecOp 594                       /* -- pre-decrement */

#define vpiMatchOp 595                        /* match() operator */
#define vpiCastOp 596                         /* type`() operator */
#define vpiIffOp 597                          /* iff operator */
#define vpiWildEqOp 598                       /* =?= operator */
#define vpiWildNeqOp 599                      /* !?= operator */

#define vpiStreamLROp 600                     /* the left-to-right streaming {>>} operator */
#define vpiStreamRLOp 601                     /* the right-to-left streaming {<<} operator */

#define vpiMatchedOp 602                      /* the .matched sequence operation */
#define vpiEndedOp 603                        /* the .ended sequence operation */

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

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

/**************************** CALLBACK REASONS ****************************/
#define cbStartOfThread 500                  /* callback on thread creation */
#define cbEndOfThread   501                  /* callback on thread termination */
#define cbEnterThread   502                  /* callback on re-entering thread */
#define cbStartOfFrame  503                  /* callback on frame creation */
#define cbEndOfFrame    504                  /* callback on frame exit */
#define cbTypeChange    505                  /* callback on variable type/size change */

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


/******************************************************************************/
/******************************************************************************/

/******************************* Coverage VPI *********************************/
/* coverage has been assigned the numeric range 650-699 */

/* coverage control */
#define vpiCoverageStart  650
#define vpiCoverageStop  651
#define vpiCoverageReset 652
#define vpiCoverageCheck 653
#define vpiCoverageMerge 654
#define vpiCoverageSave 655
/* coverage type properties */
#define vpiAssertCoverage 656
#define vpiFsmStateCoverage 657
#define vpiStatementCoverage 658
#define vpiToggleCoverage 659
/* Coverage status properties */
#define vpiCovered 660
#define vpiCoverMax 661
#define vpiCoveredCount 662
/* Assertion-specific coverage status properties */
#define vpiAssertAttemptCovered 663
#define vpiAssertSuccessCovered 664
#define vpiAssertFailureCovered 665
/* FSM-specific coverage status properties */
#define vpiFsmStates 667
#define vpiFsmStateExpression 668
/* FSM handle types */ 
#define vpiFsm 669
#define vpiFsmHandle 670

/******************************************************************************/
/******************************************************************************/

/******************************** Assertion VPI *******************************/
/* assertions have been assigned the numeric range 700-799 */

/* assertion types */
#define vpiSequenceType			701
#define vpiAssertType			702
#define vpiCoverType			703
#define vpiPropertyType			704
#define vpiImmediateAssertType		705

/* assertion callback types */
#define cbAssertionStart 700
#define cbAssertionSuccess 701
#define cbAssertionFailure 702
#define cbAssertionStepSuccess 703
#define cbAssertionStepFailure 704
#define cbAssertionDisable 705
#define cbAssertionEnable 706
#define cbAssertionReset 707
#define cbAssertionKill 708
#define cbAssertionSysInitialized 709
#define cbAssertionSysStart 710
#define cbAssertionSysStop 711
#define cbAssertionSysEnd 712
#define cbAssertionSysReset 713

/* Assertion control constants */
#define vpiAssertionDisable 730
#define vpiAssertionEnable 731
#define vpiAssertionReset 732
#define vpiAssertionKill 733
#define vpiAssertionEnableStep 734
#define vpiAssertionDisableStep 735
#define vpiAssertionClockSteps 736
#define vpiAssertionSysStart 737
#define vpiAssertionSysStop 738
#define vpiAssertionSysEnd 739
#define vpiAssertionSysReset 740

/* Assertion related structs and types */
typedef struct t_vpi_source_info {
    PLI_BYTE8 *fileName;
    PLI_INT32 startLine;
    PLI_INT32 startColumn;
    PLI_INT32 endLine;
    PLI_INT32 endColumn;
} s_vpi_source_info, *p_vpi_source_info;

typedef struct t_vpi_assertion_info {
    PLI_BYTE8 *assertName;                    /* name of assertion */
    vpiHandle instance;                       /* instance containing assertion */
    PLI_BYTE8 defname;                        /* name of module/interface containing assertion */
    vpiHandle clock;                          /* clocking expression */
    PLI_INT32 assertionType;                  /* vpiSequenceType, vpiAssertType, vpiCoverType,
                                                 vpiPropertyType, vpiImmediateAssertType */
    s_vpi_source_info sourceInfo;
} s_vpi_assertion_info, *p_vpi_assertion_info;

typedef struct t_vpi_assertion_step_info {
    PLI_INT32 matched_expression_count;
    vpiHandle *matched_exprs;                 /* array of expressions */
    p_vpi_source_info *exprs_source_info;     /* array of source info */
    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 */
    );

/* assertion specific VPI functions */
PLI_INT32 vpi_get_assertion_info (assert_handle, p_vpi_assertion_info);

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 */
    );


/******************************************************************************/
/******************************************************************************/

/*************** Reader VPI ***********************/
/* reader VPI has been assigned the numeric range 800-899 */

/********** Reader types ***********/
#define vpiTrvsObj 	     800              /* Data traverse object */
#define vpiCollection	     810              /* Collection of VPI handle	*/
#define vpiObjCollection     811              /* Collection of traversable design objs      */
#define vpiTrvsCollection    812              /* Collection of vpiTrvsObjs	       */

/********* Reader methods *********/

/* Check */
#define vpiIsLoaded 	     820              /* Object data is loaded check */
#define vpiHasDataVC	     821              /* Traverse object has at least one VC	at some point 
                                               * in time in the database check */
#define vpiHasVC	     822              /* Has VC at specific time check */ 
#define vpiHasNoValue	     823              /* Has no value at specific time check */
#define vpiBelong	     824              /* Belongs to extension check */

/* Access */
#define vpiAccessLimitedInteractive  830      /* Interactive	access */
#define vpiAccessInteractive	     831      /* interactive with history access */
#define vpiAccessPostProcess	     832      /* Database access */
/* Member of a collection */
#define vpiMember		     840      /* Member of a collection */
/* Iteration on instances for loaded */
#define vpiDataLoaded		     850      /* Use in vpi_iterate() */

/* Control Traverse/Check Time */
#define vpiMinTime                   860      /* Min time  */
#define vpiMaxTime		     864      /* Max time  */
#define vpiPrevVC 		     868      /* Previous Value Change (VC) */
#define vpiNextVC 		     870      /* Next Value Change (VC) */
#define vpiTime		 	     874      /* Time jump */

/********** routines **********/

PLI_INT32 vpi_load_extension PROTO_PARAMS((PLI_BYTE8 *extension_name, ...)) /* In its general form */
     
/********** Reader routines **********/
PLI_INT32 vpi_load_extension PROTO_PARAMS((PLI_BYTE8 *extension_name, 
					   PLI_BYTE8 *name,
					   vpiType mode, ...)) /* for the reader extension */
     
PLI_INT32 vpi_close PROTO_PARAMS((PLI_INT32 tool, vpiType prop, PLI_BYTE8* name));
PLI_INT32 vpi_load_init PROTO_PARAMS((vpiHandle objCollection, vpiHandle scope, PLI_INT32 level));
PLI_INT32 vpi_load PROTO_PARAMS((vpiHandle h));
PLI_INT32 vpi_unload PROTO_PARAMS((vpiHandle h));
vpiHandle vpi_create PROTO_PARAMS((vpiType prop, vpiHandle h, vpiHandle obj));
vpiHandle vpi_goto PROTO_PARAMS((vpiType prop, vpiHandle obj, p_vpi_time time_p, PLI_INT32 *ret_code));
vpiHandle vpi_filter PROTO_PARAMS((vpiHandle h, PLI_INT32 ft, PLI_INT32 flag));


#ifdef __cplusplus
}
#endif

#endif

