1 #ifndef VPI_USER_H 2 #define VPI_USER_H 3 /* 4 * Copyright (c) 1999-2020 Stephen Williams (steve@icarus.com) 5 * 6 * This source code is free software; you can redistribute it 7 * and/or modify it in source code form under the terms of the GNU 8 * General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 23 #if defined(__MINGW32__) || defined (__CYGWIN__) 24 # define DLLEXPORT __declspec(dllexport) 25 #else 26 # define DLLEXPORT 27 #endif 28 29 #ifdef __cplusplus 30 # define EXTERN_C_START extern "C" { 31 # define EXTERN_C_END } 32 #else 33 # define EXTERN_C_START 34 # define EXTERN_C_END 35 #endif 36 37 #ifndef __GNUC__ 38 # undef __attribute__ 39 # define __attribute__(x) 40 #endif 41 42 EXTERN_C_START 43 44 # include <stdarg.h> 45 # include <stdio.h> 46 # include <stdarg.h> 47 # include "_pli_types.h" 48 49 #ifndef ICARUS_VPI_CONST 50 #define ICARUS_VPI_CONST 51 #endif 52 #ifdef __cplusplus 53 typedef class __vpiHandle *vpiHandle; 54 #else 55 typedef struct __vpiHandle *vpiHandle; 56 #endif 57 58 /* 59 * This structure is created by the VPI application to provide hooks 60 * into the application that the compiler/simulator can access. 61 */ 62 typedef struct t_vpi_systf_data { 63 PLI_INT32 type; 64 PLI_INT32 sysfunctype; 65 const char *tfname; 66 PLI_INT32 (*calltf) (ICARUS_VPI_CONST PLI_BYTE8*); 67 PLI_INT32 (*compiletf)(ICARUS_VPI_CONST PLI_BYTE8*); 68 PLI_INT32 (*sizetf) (ICARUS_VPI_CONST PLI_BYTE8*); 69 ICARUS_VPI_CONST PLI_BYTE8 *user_data; 70 } s_vpi_systf_data, *p_vpi_systf_data; 71 72 /* The type in the above structure can have one of the following 73 values: */ 74 #define vpiSysTask 1 75 #define vpiSysFunc 2 76 77 typedef struct t_vpi_vlog_info 78 { 79 PLI_INT32 argc; 80 char **argv; 81 char *product; 82 char *version; 83 } s_vpi_vlog_info, *p_vpi_vlog_info; 84 85 86 typedef struct t_vpi_time { 87 88 /* 89 Type can be : 90 91 vpiScaledRealTime == 1 92 vpiSimTime == 2 93 vpiSuppressTime == 3 94 */ 95 96 PLI_INT32 type; 97 PLI_UINT32 high; 98 PLI_UINT32 low; 99 double real; 100 } s_vpi_time, *p_vpi_time; 101 102 #define vpiScaledRealTime 1 103 #define vpiSimTime 2 104 #define vpiSuppressTime 3 105 106 typedef struct t_vpi_vecval { 107 PLI_INT32 aval, bval; /* ab encoding: 00=0, 10=1, 11=X, 01=Z */ 108 } s_vpi_vecval, *p_vpi_vecval; 109 110 typedef struct t_vpi_strengthval { 111 PLI_INT32 logic; 112 PLI_INT32 s0, s1; 113 } s_vpi_strengthval, *p_vpi_strengthval; 114 115 /* 116 * This structure holds values that are passed back and forth between 117 * the simulator and the application. 118 */ 119 typedef struct t_vpi_value { 120 PLI_INT32 format; 121 union { 122 char *str; 123 PLI_INT32 scalar; 124 PLI_INT32 integer; 125 double real; 126 struct t_vpi_time *time; 127 struct t_vpi_vecval *vector; 128 struct t_vpi_strengthval *strength; 129 char *misc; 130 } value; 131 } s_vpi_value, *p_vpi_value; 132 133 134 /* 135 136 Conform the IEEE 1364, We add the 137 Standard vpi_delay structure to 138 enable the modpath delay values 139 140 141 Conform IEEE 1364, Pg 670 : 142 143 The "da" field of the s_vpi_delay 144 structure shall be a user allocated 145 array of "s_vpi_time" structure 146 147 The array shall store delay values returned 148 by vpi_get_delay(). The number of elements in 149 the array shall be determined by 150 151 (1) The number of delays to be retrieved 152 ( normally this is used in vpi_get_delays (..) ) 153 { 154 (1.1) Set by "no_of_delays" field 155 156 (1.2) For the primitive_object, the no_of_delays 157 shall be 2 or 3 158 159 (1.3) For path_delay object the no_of_delays shall 160 be 1,2,3,6, 12 161 162 (1.4) For timing_check_object, the no_of_delays shall 163 be match the number of limits existing in the 164 Time Check 165 166 (1.5) For intermodule_path object, the no_of_delays shall 167 be 2 or 3 168 } 169 170 171 172 173 (2) The "mtm_flag" && "pulsere_flag" 174 175 176 Normally, if you set mtm = X, pulsere = Y 177 then, you will need allocate (num * no_of_delay) 178 s_vpi_time elements for 'da' array before calling 179 the vpi_get/put_delays (..) 180 181 --------------------------------------------------------------------------- 182 | | | | 183 | mtm_flag | No of s_vpi_time array | order in which delay | 184 | pulsere_flag | element required by the | elements shall be filed | 185 | | s_vpi_delay->da | | 186 | | | | 187 |----------------|-------------------------|------------------------------| 188 | | | 1o delay da[0]--> 1o delay | 189 | mtm = false | no_of_delay | 2o delay da[1]--> 2o delay | 190 | pulere = false | | | 191 | | | | 192 |----------------|-------------------------|------------------------------| 193 | | | 1o delay da[0]--> min delay | 194 | mtm = true | | da[1]--> typ delay | 195 | pulere = false | 3*no_of_delay | da[2]--> max delay | 196 | | | 2o delay da[3]--> min delay | 197 | | | da[4]--> typ delay | 198 | | | .... | 199 |----------------|-------------------------|------------------------------| 200 | | | 1o delay da[0]--> delay | 201 | mtm = false | | da[1]--> rej limit | 202 | pulere = true | 3*no_of_delay | da[2]--> err limit | 203 | | | 2o delay da[3]--> delay | 204 | | | da[4]--> rej limit | 205 | | | .... | 206 |----------------|-------------------------|------------------------------| 207 | | | 1o delay da[0]--> min delay | 208 | mtm = true | | da[1]--> typ delay | 209 | pulere = true | 9*no_of_delay | da[2]--> max delay | 210 | | | da[3]--> min delay | 211 | | | da[4]--> typ delay | 212 | | | da[5]--> max delay | 213 | | | da[6]--> min delay | 214 | | | da[7]--> typ delay | 215 | | | da[8]--> max delay | 216 | | | 2o delay da[9]--> min delay | 217 | | | .... | 218 ------------------------------------------------------------------------- 219 220 IMPORTANT : 221 222 The delay Structure has to be allocated before passing a pointer to 223 "vpi_get_delays ( )". 224 225 */ 226 227 228 typedef struct t_vpi_delay { 229 struct t_vpi_time *da; /* Array of delay data */ 230 PLI_INT32 no_of_delays ; 231 PLI_INT32 time_type; /* vpiScaledRealTime, vpiSimTime */ 232 PLI_INT32 mtm_flag; 233 PLI_INT32 append_flag; 234 PLI_INT32 pulsere_flag; 235 } s_vpi_delay, *p_vpi_delay; 236 237 238 239 240 241 /* These are valid codes for the format of the t_vpi_value structure. */ 242 #define vpiBinStrVal 1 243 #define vpiOctStrVal 2 244 #define vpiDecStrVal 3 245 #define vpiHexStrVal 4 246 #define vpiScalarVal 5 247 #define vpiIntVal 6 248 #define vpiRealVal 7 249 #define vpiStringVal 8 250 #define vpiVectorVal 9 251 #define vpiStrengthVal 10 252 #define vpiTimeVal 11 253 #define vpiObjTypeVal 12 254 #define vpiSuppressVal 13 255 256 257 /* SCALAR VALUES */ 258 #define vpi0 0 259 #define vpi1 1 260 #define vpiZ 2 261 #define vpiX 3 262 #define vpiH 4 263 #define vpiL 5 264 #define vpiDontCare 6 265 266 /* STRENGTH VALUES */ 267 #define vpiSupplyDrive 0x80 268 #define vpiStrongDrive 0x40 269 #define vpiPullDrive 0x20 270 #define vpiLargeCharge 0x10 271 #define vpiWeakDrive 0x08 272 #define vpiMediumCharge 0x04 273 #define vpiSmallCharge 0x02 274 #define vpiHiZ 0x01 275 276 /* OBJECT CODES */ 277 #define vpiConstant 7 278 #define vpiFunction 20 279 #define vpiIntegerVar 25 280 #define vpiIterator 27 281 #define vpiMemory 29 282 #define vpiMemoryWord 30 283 #define vpiModPath 31 284 #define vpiModule 32 285 #define vpiNamedBegin 33 286 #define vpiNamedEvent 34 287 #define vpiNamedFork 35 288 #define vpiNet 36 289 #define vpiNetBit 37 290 #define vpiParameter 41 291 #define vpiPartSelect 42 292 #define vpiPathTerm 43 293 #define vpiPort 44 294 #define vpiRealVar 47 295 #define vpiReg 48 296 #define vpiRegBit 49 297 #define vpiSysFuncCall 56 298 #define vpiSysTaskCall 57 299 #define vpiTask 59 300 #define vpiTimeVar 63 301 #define vpiUdpDefn 66 302 #define vpiUserSystf 67 303 #define vpiNetArray 114 304 #define vpiIndex 78 305 #define vpiLeftRange 79 306 #define vpiParent 81 307 #define vpiRightRange 83 308 #define vpiScope 84 309 #define vpiSysTfCall 85 310 #define vpiArgument 89 311 #define vpiInternalScope 92 312 #define vpiModPathIn 95 313 #define vpiModPathOut 96 314 #define vpiVariables 100 315 #define vpiExpr 102 316 317 /********************** object types added with 1364-2001 *********************/ 318 319 #define vpiCallback 107 320 #define vpiRegArray 116 321 322 /********************** object types added with 1364-2005 *********************/ 323 324 #define vpiGenScope 134 325 326 /* PROPERTIES */ 327 #define vpiUndefined (-1) 328 #define vpiType 1 329 #define vpiName 2 330 #define vpiFullName 3 331 #define vpiSize 4 332 #define vpiFile 5 333 #define vpiLineNo 6 334 #define vpiTopModule 7 335 #define vpiCellInstance 8 336 #define vpiDefName 9 337 #define vpiTimeUnit 11 338 #define vpiTimePrecision 12 339 #define vpiDefFile 15 340 #define vpiDefLineNo 16 341 #define vpiScalar 17 342 #define vpiVector 18 343 344 #define vpiDirection 20 /* direction of port: */ 345 # define vpiInput 1 346 # define vpiOutput 2 347 # define vpiInout 3 348 # define vpiMixedIO 4 /* Not currently output */ 349 # define vpiNoDirection 5 350 351 #define vpiNetType 22 352 # define vpiWire 1 353 # define vpiWand 2 354 # define vpiWor 3 355 # define vpiTri 4 356 # define vpiTri0 5 357 # define vpiTri1 6 358 # define vpiTriReg 7 359 # define vpiTriAnd 8 360 # define vpiTriOr 9 361 # define vpiSupply1 10 362 # define vpiSupply0 11 363 #define vpiArray 28 364 #define vpiPortIndex 29 365 #define vpiEdge 36 366 # define vpiNoEdge 0x00 /* No edge */ 367 # define vpiEdge01 0x01 /* 0 --> 1 */ 368 # define vpiEdge10 0x02 /* 1 --> 0 */ 369 # define vpiEdge0x 0x04 /* 0 --> x */ 370 # define vpiEdgex1 0x08 /* x --> 1 */ 371 # define vpiEdge1x 0x10 /* 1 --> x */ 372 # define vpiEdgex0 0x20 /* x --> 0 */ 373 # define vpiPosedge (vpiEdgex1|vpiEdge01|vpiEdge0x) 374 # define vpiNegedge (vpiEdgex0|vpiEdge10|vpiEdge1x) 375 # define vpiAnyEdge (vpiPosedge|vpiNegedge) 376 #define vpiConstType 40 377 # define vpiDecConst 1 378 # define vpiRealConst 2 379 # define vpiBinaryConst 3 380 # define vpiOctConst 4 381 # define vpiHexConst 5 382 # define vpiStringConst 6 383 #define vpiFuncType 44 384 # define vpiIntFunc 1 385 # define vpiRealFunc 2 386 # define vpiTimeFunc 3 387 # define vpiSizedFunc 4 388 # define vpiSizedSignedFunc 5 389 #define vpiSysFuncType vpiFuncType 390 # define vpiSysFuncInt vpiIntFunc 391 # define vpiSysFuncReal vpiRealFunc 392 # define vpiSysFuncTime vpiTimeFunc 393 # define vpiSysFuncSized vpiSizedFunc 394 #define vpiUserDefn 45 395 #define vpiAutomatic 50 396 #define vpiConstantSelect 53 397 #define vpiSigned 65 398 #define vpiLocalParam 70 399 /* IVL private properties, also see vvp/vpi_priv.h for other properties */ 400 #define _vpiNexusId 0x1000000 401 /* used in vvp/vpi_priv.h 0x1000001 */ 402 #define _vpiDelaySelection 0x1000002 403 # define _vpiDelaySelMinimum 1 404 # define _vpiDelaySelTypical 2 405 # define _vpiDelaySelMaximum 3 406 /* used in vvp/vpi_priv.h 0x1000003 */ 407 /* used in vvp/vpi_priv.h 0x1000004 */ 408 409 /* DELAY MODES */ 410 #define vpiNoDelay 1 411 #define vpiInertialDelay 2 412 #define vpiTransportDelay 3 413 #define vpiPureTransportDelay 4 414 415 #define vpiForceFlag 5 416 #define vpiReleaseFlag 6 417 #define vpiReturnEvent 0x1000 418 419 /* VPI FUNCTIONS */ 420 extern vpiHandle vpi_register_systf(const struct t_vpi_systf_data*ss); 421 extern void vpi_get_systf_info(vpiHandle obj, p_vpi_systf_data data); 422 423 /* I/O routines */ 424 extern PLI_UINT32 vpi_mcd_open(char *name); 425 extern PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd); 426 extern char *vpi_mcd_name(PLI_UINT32 mcd); 427 extern PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, const char*fmt, ...) 428 #ifdef __MINGW32__ 429 __attribute__((format (gnu_printf,2,3))); 430 #else 431 __attribute__((format (printf,2,3))); 432 #endif 433 extern PLI_INT32 vpi_printf(const char*fmt, ...) 434 #ifdef __MINGW32__ 435 __attribute__((format (gnu_printf,1,2))); 436 #else 437 __attribute__((format (printf,1,2))); 438 #endif 439 440 extern PLI_INT32 vpi_vprintf(const char*fmt, va_list ap); 441 extern PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap); 442 443 extern PLI_INT32 vpi_flush(void); 444 extern PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd); 445 446 /* proposed extensions */ 447 /* 448 * These functions are proposed extensions to Verilog, and 449 * are described by the Verilog PLI task force as issue#347. 450 * 451 * The vpi_fopen() function is exactly the same as the $fopen system 452 * function. That is, it takes a path string and a mode string, and 453 * opens the file. The result is a 32bit value with bit 31 set, the 454 * remaining bits made up a small integer to represent the file. 455 * 456 * The vpi_get_file(fd) function takes as input a descriptor as 457 * returned by vpi_fopen or $fopen. Bit 31 must be set. The result 458 * is the C FILE* that represents the file. 459 */ 460 extern PLI_INT32 vpi_fopen(const char*name, const char*mode); 461 extern FILE *vpi_get_file(PLI_INT32 fd); 462 463 /* 464 * support for VPI callback functions. 465 */ 466 typedef struct t_cb_data { 467 PLI_INT32 reason; 468 PLI_INT32 (*cb_rtn)(struct t_cb_data*cb); 469 vpiHandle obj; 470 p_vpi_time time; 471 p_vpi_value value; 472 PLI_INT32 index; 473 ICARUS_VPI_CONST PLI_BYTE8 *user_data; 474 } s_cb_data, *p_cb_data; 475 476 #define cbValueChange 1 477 #define cbStmt 2 478 #define cbForce 3 479 #define cbRelease 4 480 #define cbAtStartOfSimTime 5 481 #define cbReadWriteSynch 6 482 #define cbReadOnlySynch 7 483 #define cbNextSimTime 8 484 #define cbAfterDelay 9 485 #define cbEndOfCompile 10 486 #define cbStartOfSimulation 11 487 #define cbEndOfSimulation 12 488 #define cbError 13 489 #define cbTchkViolation 14 490 #define cbStartOfSave 15 491 #define cbEndOfSave 16 492 #define cbStartOfRestart 17 493 #define cbEndOfRestart 18 494 #define cbStartOfReset 19 495 #define cbEndOfReset 20 496 #define cbEnterInteractive 21 497 #define cbExitInteractive 22 498 #define cbInteractiveScopeChange 23 499 #define cbUnresolvedSystf 24 500 #define cbAtEndOfSimTime 31 501 502 extern vpiHandle vpi_register_cb(p_cb_data data); 503 extern PLI_INT32 vpi_remove_cb(vpiHandle ref); 504 505 /* 506 * This function allows a vpi application to control the simulation 507 * engine. The operation parameter specifies the function to 508 * perform. The remaining parameters (if any) are interpreted by the 509 * operation. The vpi_sim_control definition (now named vpi_control) 510 * was added to P1364-2000 14 July 1999. See PLI Task Force ID: PTF-161 511 * 512 * vpiFinish - perform the $finish operation, as soon as the user 513 * function returns. This operation takes a single 514 * parameter, a diagnostic exit code. 515 * 516 * vpiStop - 517 * vpiReset - 518 * vpiSetInteractiveScope - 519 */ 520 extern void vpi_control(PLI_INT32 operation, ...); 521 /************* vpi_control() constants (added with 1364-2000) *************/ 522 #define vpiStop 66 /* execute simulator's $stop */ 523 #define vpiFinish 67 /* execute simulator's $finish */ 524 #define vpiReset 68 /* execute simulator's $reset */ 525 #define vpiSetInteractiveScope 69 /* set simulator's interactive scope */ 526 #define __ivl_legacy_vpiStop 1 527 #define __ivl_legacy_vpiFinish 2 528 529 /* vpi_sim_control is the incorrect name for vpi_control. */ 530 extern void vpi_sim_control(PLI_INT32 operation, ...); 531 532 extern vpiHandle vpi_handle(PLI_INT32 type, vpiHandle ref); 533 extern vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle ref); 534 extern vpiHandle vpi_scan(vpiHandle iter); 535 extern vpiHandle vpi_handle_by_index(vpiHandle ref, PLI_INT32 idx); 536 extern vpiHandle vpi_handle_by_name(const char*name, vpiHandle scope); 537 538 extern void vpi_get_time(vpiHandle obj, s_vpi_time*t); 539 extern PLI_INT32 vpi_get(int property, vpiHandle ref); 540 extern char *vpi_get_str(PLI_INT32 property, vpiHandle ref); 541 extern void vpi_get_value(vpiHandle expr, p_vpi_value value); 542 543 /* 544 * This function puts a value into the object referenced by the 545 * handle. This assumes that the value supports having its value 546 * written to. The time parameter specifies when the assignment is to 547 * take place. This allows you to schedule an assignment to happen in 548 * the future. 549 * 550 * The flags value specifies the delay model to use in assigning the 551 * value. This specifies how the time value is to be used. 552 * 553 * vpiNoDelay -- Set the value immediately. The p_vpi_time parameter 554 * may be NULL, in this case. This is like a blocking assignment 555 * in behavioral code. 556 * 557 * vpiInertialDelay -- Set the value using the transport delay. The 558 * p_vpi_time parameter is required and specifies when the 559 * assignment is to take place. This is like a non-blocking 560 * assignment in behavioral code. 561 */ 562 extern vpiHandle vpi_put_value(vpiHandle obj, p_vpi_value value, 563 p_vpi_time when, PLI_INT32 flags); 564 565 extern PLI_INT32 vpi_free_object(vpiHandle ref); 566 extern PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p); 567 568 /* 569 These Routines will enable the modpath vpiHandle 570 to read/write delay values 571 */ 572 extern void vpi_get_delays(vpiHandle expr, p_vpi_delay delays); 573 574 extern void vpi_put_delays(vpiHandle expr, p_vpi_delay delays); 575 576 577 /* 578 * Check to see if two handles point to the same object. 579 */ 580 extern PLI_INT32 vpi_compare_objects(vpiHandle obj1, vpiHandle obj2); 581 582 583 /* 584 * These functions support attaching user data to an instance of a 585 * system task or function. These functions only apply to 586 * vpiSysTaskCall or vpiSysFuncCall handles. 587 */ 588 extern PLI_INT32 vpi_put_userdata(vpiHandle obj, void*data); 589 extern void*vpi_get_userdata(vpiHandle obj); 590 591 /* 592 * Support for handling errors. 593 */ 594 typedef struct t_vpi_error_info { 595 PLI_INT32 state; 596 PLI_INT32 level; 597 char *message; 598 char *product; 599 char *code; 600 char *file; 601 PLI_INT32 line; 602 } s_vpi_error_info, *p_vpi_error_info; 603 604 /* error_info states */ 605 # define vpiCompile 1 606 # define vpiPLI 2 607 # define vpiRun 3 608 609 /* error_info levels */ 610 # define vpiNotice 1 611 # define vpiWarning 2 612 # define vpiError 3 613 # define vpiSystem 4 614 # define vpiInternal 5 615 616 extern PLI_INT32 vpi_chk_error(p_vpi_error_info info); 617 618 619 /* This is the table of startup routines included in each module. */ 620 extern DLLEXPORT void (*vlog_startup_routines[])(void); 621 622 623 /* 624 * ICARUS VERILOG EXTENSIONS 625 * 626 * The vpip_* functions are Icarus Verilog extensions. They are not 627 * standard VPI functions, so use these at your own risk. 628 * 629 * The vpip_format_* functions format values in string format in the 630 * manner of the $display system task. 631 */ 632 633 /* Format a scalar a la %v. The str points to a 4byte character 634 buffer. The value must be a vpiStrengthVal. */ 635 extern void vpip_format_strength(char*str, s_vpi_value*value, unsigned bit); 636 /* Set the return value to return from the vvp run time. This is 637 usually 0 or 1. This is the exit code that the vvp process 638 returns, and in distinct from the finish_number that is an 639 argument to $fatal and other severity tasks. The $fatal and 640 $finish system tasks bundled with iverilog use this function to 641 tell vvp to exit SUCCESS or FAILURE. */ 642 extern void vpip_set_return_value(int value); 643 644 extern s_vpi_vecval vpip_calc_clog2(vpiHandle arg); 645 extern void vpip_make_systf_system_defined(vpiHandle ref); 646 647 /* Perform fwrite to mcd files. This is used to write raw data, 648 which may include nulls. */ 649 extern void vpip_mcd_rawwrite(PLI_UINT32 mcd, const char*buf, size_t count); 650 651 /* Return driver information for a net bit. The information is returned 652 in the 'counts' array as follows: 653 counts[0] - number of drivers driving '0' onto the net 654 counts[1] - number of drivers driving '1' onto the net 655 counts[2] - number of drivers driving 'X' onto the net 656 counts[3] - set to 1 if the net is forced, 0 otherwise 657 The 'ref' argument should reference a net. The 'idx' argument selects 658 which bit of the net is examined. */ 659 extern void vpip_count_drivers(vpiHandle ref, unsigned idx, 660 unsigned counts[4]); 661 662 /* 663 * Stopgap fix for br916. We need to reject any attempt to pass a thread 664 * variable to $strobe or $monitor. To do this, we use some private VPI 665 * properties that are normally only used by the VVP thread cleanup code. 666 * Normally the following definitions are provided by vvp/vpi_priv.h, but 667 * for the stopgap fix we need to make them more widely available. 668 */ 669 #define BR916_STOPGAP_FIX 670 #ifdef BR916_STOPGAP_FIX 671 #define _vpiFromThr 0x1000001 672 # define _vpiNoThr 0 673 # define _vpiString 1 674 # define _vpiVThr 2 675 # define _vpiWord 3 676 # define _vpi_at_PV 4 677 # define _vpi_at_A 5 678 # define _vpi_at_APV 6 679 #endif 680 681 #if defined(__MINGW32__) || defined (__CYGWIN__) 682 /* 683 * In Linux, when loaded, a shared library can automatically bind to functions 684 * provided by its client. In Windows, a DLL can only do this statically at 685 * link time, and is then tied to a specific client. So to enable VPI modules 686 * to be used by both the compiler and the simulator, we construct a jump table 687 * for the VPI routines that we can pass down to the VPI modules. 688 */ 689 690 // Increment the version number any time vpip_routines_s is changed. 691 static const PLI_UINT32 vpip_routines_version = 1; 692 693 typedef struct { 694 vpiHandle (*register_cb)(p_cb_data); 695 PLI_INT32 (*remove_cb)(vpiHandle); 696 vpiHandle (*register_systf)(const struct t_vpi_systf_data*ss); 697 void (*get_systf_info)(vpiHandle, p_vpi_systf_data); 698 vpiHandle (*handle_by_name)(const char*, vpiHandle); 699 vpiHandle (*handle_by_index)(vpiHandle, PLI_INT32); 700 vpiHandle (*handle)(PLI_INT32, vpiHandle); 701 vpiHandle (*iterate)(PLI_INT32, vpiHandle); 702 vpiHandle (*scan)(vpiHandle); 703 PLI_INT32 (*get)(int, vpiHandle); 704 char* (*get_str)(PLI_INT32, vpiHandle); 705 void (*get_delays)(vpiHandle, p_vpi_delay); 706 void (*put_delays)(vpiHandle, p_vpi_delay); 707 void (*get_value)(vpiHandle, p_vpi_value); 708 vpiHandle (*put_value)(vpiHandle, p_vpi_value, p_vpi_time, PLI_INT32); 709 void (*get_time)(vpiHandle, s_vpi_time*); 710 void* (*get_userdata)(vpiHandle); 711 PLI_INT32 (*put_userdata)(vpiHandle, void*); 712 PLI_UINT32 (*mcd_open)(char *); 713 PLI_UINT32 (*mcd_close)(PLI_UINT32); 714 PLI_INT32 (*mcd_flush)(PLI_UINT32); 715 char* (*mcd_name)(PLI_UINT32); 716 PLI_INT32 (*mcd_vprintf)(PLI_UINT32, const char*, va_list); 717 PLI_INT32 (*flush)(void); 718 PLI_INT32 (*vprintf)(const char*, va_list); 719 PLI_INT32 (*chk_error)(p_vpi_error_info); 720 PLI_INT32 (*compare_objects)(vpiHandle, vpiHandle); 721 PLI_INT32 (*free_object)(vpiHandle); 722 PLI_INT32 (*get_vlog_info)(p_vpi_vlog_info info) ; 723 void (*vcontrol)(PLI_INT32, va_list); 724 PLI_INT32 (*fopen)(const char*, const char*); 725 FILE* (*get_file)(PLI_INT32); 726 s_vpi_vecval(*calc_clog2)(vpiHandle); 727 void (*count_drivers)(vpiHandle, unsigned, unsigned [4]); 728 void (*format_strength)(char*, s_vpi_value*, unsigned); 729 void (*make_systf_system_defined)(vpiHandle); 730 void (*mcd_rawwrite)(PLI_UINT32, const char*, size_t); 731 void (*set_return_value)(int); 732 } vpip_routines_s; 733 734 extern DLLEXPORT PLI_UINT32 vpip_set_callback(vpip_routines_s*routines, PLI_UINT32 version); 735 736 #endif // defined(__MINGW32__) || defined (__CYGWIN__) 737 738 EXTERN_C_END 739 740 #endif /* VPI_USER_H */ 741