diff options
Diffstat (limited to 'src/grt')
-rw-r--r-- | src/grt/grt-cvpi.c | 237 | ||||
-rw-r--r-- | src/grt/grt-vpi.adb | 8 | ||||
-rw-r--r-- | src/grt/grt-vpi.ads | 8 | ||||
-rw-r--r-- | src/grt/vpi_thunk.c | 216 | ||||
-rw-r--r-- | src/grt/vpi_thunk.h | 61 | ||||
-rw-r--r-- | src/grt/vpi_user.h | 925 |
6 files changed, 1311 insertions, 144 deletions
diff --git a/src/grt/grt-cvpi.c b/src/grt/grt-cvpi.c index 6f8420dbf..e122e1b4c 100644 --- a/src/grt/grt-cvpi.c +++ b/src/grt/grt-cvpi.c @@ -25,103 +25,53 @@ #include <stdio.h> #include <stdlib.h> -//----------------------------------------------------------------------------- -// VPI callback functions -typedef void *vpiHandle, *p_vpi_time, *p_vpi_value; -typedef struct t_cb_data s_cb_data, *p_cb_data; +/* Define PLI_PROTOTYPES so that vpi_user.h do not import functions. */ +#define PLI_PROTOTYPES +#define PROTO_PARAMS(params) params +#define XXTERN extern + +#include "vpi_user.h" +#include "vpi_thunk.h" + +/* Extension of a shared library. */ +#if defined (WINNT) +#define DSO_EXT ".dll" +#elif defined (__APPLE__) +#define DSO_EXT ".dylib" +#else +#define DSO_EXT ".so" +#endif -//----------------------------------------------------------------------------- -// vpi thunking a la Icarus Verilog -#include <stdarg.h> -typedef void *s_vpi_time, *p_vpi_vlog_info, *p_vpi_error_info; -#define VPI_THUNK_MAGIC (0x87836BA5) -struct t_vpi_systf_data; -void vpi_register_systf (const struct t_vpi_systf_data*ss); -void vpi_vprintf (const char*fmt, va_list ap); -unsigned int vpi_mcd_close (unsigned int mcd); -char * vpi_mcd_name (unsigned int mcd); -unsigned int vpi_mcd_open (char *name); -unsigned int vpi_mcd_open_x (char *name, char *mode); -int vpi_mcd_vprintf (unsigned int mcd, const char*fmt, va_list ap); -int vpi_mcd_fputc (unsigned int mcd, unsigned char x); -int vpi_mcd_fgetc (unsigned int mcd); -vpiHandle vpi_register_cb (p_cb_data data); -int vpi_remove_cb (vpiHandle ref); -void vpi_sim_vcontrol (int operation, va_list ap); -vpiHandle vpi_handle (int type, vpiHandle ref); -vpiHandle vpi_iterate (int type, vpiHandle ref); -vpiHandle vpi_scan (vpiHandle iter); -vpiHandle vpi_handle_by_index (vpiHandle ref, int index); -void vpi_get_time (vpiHandle obj, s_vpi_time*t); -int vpi_get (int property, vpiHandle ref); -char* vpi_get_str (int property, vpiHandle ref); -void vpi_get_value (vpiHandle expr, p_vpi_value value); -vpiHandle vpi_put_value (vpiHandle obj, p_vpi_value value, - p_vpi_time when, int flags); -int vpi_free_object (vpiHandle ref); -int vpi_get_vlog_info (p_vpi_vlog_info vlog_info_p); -int vpi_chk_error (p_vpi_error_info info); -vpiHandle vpi_handle_by_name (char *name, vpiHandle scope); - -typedef struct { - int magic; - void (*vpi_register_systf) (const struct t_vpi_systf_data*ss); - void (*vpi_vprintf) (const char*fmt, va_list ap); - unsigned int (*vpi_mcd_close) (unsigned int mcd); - char* (*vpi_mcd_name) (unsigned int mcd); - unsigned int (*vpi_mcd_open) (char *name); - unsigned int (*vpi_mcd_open_x) (char *name, char *mode); - int (*vpi_mcd_vprintf) (unsigned int mcd, const char*fmt, va_list ap); - int (*vpi_mcd_fputc) (unsigned int mcd, unsigned char x); - int (*vpi_mcd_fgetc) (unsigned int mcd); - vpiHandle (*vpi_register_cb) (p_cb_data data); - int (*vpi_remove_cb) (vpiHandle ref); - void (*vpi_sim_vcontrol) (int operation, va_list ap); - vpiHandle (*vpi_handle) (int type, vpiHandle ref); - vpiHandle (*vpi_iterate) (int type, vpiHandle ref); - vpiHandle (*vpi_scan) (vpiHandle iter); - vpiHandle (*vpi_handle_by_index)(vpiHandle ref, int index); - void (*vpi_get_time) (vpiHandle obj, s_vpi_time*t); - int (*vpi_get) (int property, vpiHandle ref); - char* (*vpi_get_str) (int property, vpiHandle ref); - void (*vpi_get_value) (vpiHandle expr, p_vpi_value value); - vpiHandle (*vpi_put_value) (vpiHandle obj, p_vpi_value value, - p_vpi_time when, int flags); - int (*vpi_free_object) (vpiHandle ref); - int (*vpi_get_vlog_info) (p_vpi_vlog_info vlog_info_p); - int (*vpi_chk_error) (p_vpi_error_info info); - vpiHandle (*vpi_handle_by_name) (char *name, vpiHandle scope); -} vpi_thunk, *p_vpi_thunk; - -int vpi_register_sim(p_vpi_thunk tp); - -static vpi_thunk thunkTable = -{ VPI_THUNK_MAGIC, - vpi_register_systf, - vpi_vprintf, - vpi_mcd_close, - vpi_mcd_name, - vpi_mcd_open, - 0, //vpi_mcd_open_x, - 0, //vpi_mcd_vprintf, - 0, //vpi_mcd_fputc, - 0, //vpi_mcd_fgetc, - vpi_register_cb, - vpi_remove_cb, - 0, //vpi_sim_vcontrol, - vpi_handle, - vpi_iterate, - vpi_scan, - vpi_handle_by_index, - vpi_get_time, - vpi_get, - vpi_get_str, - vpi_get_value, - vpi_put_value, - vpi_free_object, - vpi_get_vlog_info, - vpi_chk_error, - vpi_handle_by_name +extern PLI_INT32 vpi_control_np (int op, int status); + +static vpi_thunk __ghdl_vpi_thunk_v1 = +{ + vpi_register_systf, + vpi_vprintf, + vpi_mcd_close, + vpi_mcd_name, + vpi_mcd_open, + 0, //vpi_mcd_open_x, + 0, //vpi_mcd_vprintf, + 0, //vpi_mcd_fputc, + 0, //vpi_mcd_fgetc, + vpi_register_cb, + vpi_remove_cb, + 0, //vpi_sim_vcontrol, + vpi_handle, + vpi_iterate, + vpi_scan, + vpi_handle_by_index, + vpi_get_time, + vpi_get, + vpi_get_str, + vpi_get_value, + vpi_put_value, + vpi_free_object, + vpi_get_vlog_info, + vpi_chk_error, + vpi_handle_by_name, + vpi_control_np }; //----------------------------------------------------------------------------- @@ -183,19 +133,17 @@ module_error (void) int loadVpiModule (const char* modulename) { + static const char libghdlvpi_name[] = "@executable_path/libghdlvpi" DSO_EXT; + static void *libghdlvpi_mod; + static const char * const vpitablenames[] = { "_vlog_startup_routines", // with leading underscore: MacOSX "vlog_startup_routines" // w/o leading underscore: Linux }; - static const char * const vpithunknames[] = - { - "_vpi_register_sim", // with leading underscore: MacOSX - "vpi_register_sim" // w/o leading underscore: Linux - }; int i; - void* vpimod; + void *vpimod; fprintf (stderr, "loading VPI module '%s'\n", modulename); @@ -203,48 +151,50 @@ loadVpiModule (const char* modulename) if (vpimod == NULL) { - const char *msg; - - msg = module_error (); + const char *msg = module_error (); fprintf (stderr, "%s\n", msg == NULL ? "unknown dlopen error" : msg); return -1; } - for (i = 0; i < 2; i++) // try with and w/o leading underscores + /* Try to load the libghdlvpi library and set the thunk. + No need to load the library several times. */ + if (libghdlvpi_mod == NULL) { - void* vpithunk; - void* vpitable; - - vpitable = module_symbol (vpimod, vpitablenames[i]); - vpithunk = module_symbol (vpimod, vpithunknames[i]); - - if (vpithunk) + libghdlvpi_mod = module_open (libghdlvpi_name); + if (libghdlvpi_mod != NULL) { - typedef int (*funT)(p_vpi_thunk tp); - funT regsim; + vpi_thunk **vpi_thunk_ptr; - regsim = (funT)vpithunk; - regsim (&thunkTable); - } - else - { - // this is not an error, as the register-mechanism - // is not standardized + for (i = 0; i < 2; i++) + { + vpi_thunk_ptr = module_symbol (libghdlvpi_mod, &"_VPI_THUNK"[i]); + + if (vpi_thunk_ptr != NULL) + { + *vpi_thunk_ptr = &__ghdl_vpi_thunk_v1; + break; + } + } + if (vpi_thunk_ptr == NULL) + fprintf (stderr, "warning: VPI_THUNK not found in %s\n", + libghdlvpi_name); } + } + + for (i = 0; i < 2; i++) // try with and w/o leading underscores + { + void *vpitable = module_symbol (vpimod, &"_vlog_startup_routines"[i]); if (vpitable) { - unsigned int tmp; - //extern void (*vlog_startup_routines[])(); + unsigned int j; typedef void (*vlog_startup_routines_t)(void); vlog_startup_routines_t *vpifuns; vpifuns = (vlog_startup_routines_t*)vpitable; - for (tmp = 0; vpifuns[tmp]; tmp++) - { - vpifuns[tmp](); - } + for (j = 0; vpifuns[j]; j++) + vpifuns[j](); fprintf (stderr, "VPI module loaded!\n"); return 0; // successfully registered VPI module @@ -254,21 +204,36 @@ loadVpiModule (const char* modulename) return -1; // failed to register VPI module } -void -vpi_vprintf (const char*fmt, va_list ap) +PLI_INT32 +vpi_vprintf (char *fmt, va_list ap) { - vprintf (fmt, ap); + return vprintf (fmt, ap); } -void -vpi_printf (const char *fmt, ...) +PLI_INT32 +vpi_printf (char *fmt, ...) { va_list params; + PLI_INT32 res; va_start (params, fmt); - vprintf (fmt, params); + res = vprintf (fmt, params); va_end (params); + + return res; } -//----------------------------------------------------------------------------- -// end of file +PLI_INT32 +vpi_control (int op, ...) +{ + va_list params; + int status; + PLI_INT32 res; + + va_start (params, op); + status = va_arg (params, int); + res = vpi_control_np (op, status); + va_end (params); + + return res; +} diff --git a/src/grt/grt-vpi.adb b/src/grt/grt-vpi.adb index b6742d092..7b62dae65 100644 --- a/src/grt/grt-vpi.adb +++ b/src/grt/grt-vpi.adb @@ -1532,8 +1532,7 @@ package body Grt.Vpi is return 0; end vpi_mcd_open; - -- void vpi_register_systf(const struct t_vpi_systf_data*ss) - procedure vpi_register_systf(aSs: System.Address) + function vpi_register_systf (aSs: System.Address) return vpiHandle is pragma Unreferenced (aSs); begin @@ -1541,6 +1540,7 @@ package body Grt.Vpi is Trace_Start ("vpi_register_systf"); Trace_Newline; end if; + return null; end vpi_register_systf; -- int vpi_remove_cb(vpiHandle ref) @@ -1618,7 +1618,7 @@ package body Grt.Vpi is return Err_Status; end vpi_chk_error; - function vpi_control (Op : Integer; Status : Integer) return Integer is + function vpi_control_np (Op : Integer; Status : Integer) return Integer is begin if Flag_Trace then Trace_Start ("vpi_control ("); @@ -1637,7 +1637,7 @@ package body Grt.Vpi is when others => return 0; end case; - end vpi_control; + end vpi_control_np; ------------------------------------------------------------------------------ -- * * * G H D L h o o k s * * * * * * * * * * * * * * * * * * * * * * * diff --git a/src/grt/grt-vpi.ads b/src/grt/grt-vpi.ads index a669632ca..3c8911e1d 100644 --- a/src/grt/grt-vpi.ads +++ b/src/grt/grt-vpi.ads @@ -269,8 +269,8 @@ package Grt.Vpi is return vpiHandle; pragma Export (C, vpi_put_value, "vpi_put_value"); - -- void vpi_register_systf(const struct t_vpi_systf_data*ss) - procedure vpi_register_systf (aSs : Address); + -- vpiHandle vpi_register_systf(const struct t_vpi_systf_data*ss) + function vpi_register_systf (aSs : Address) return vpiHandle; pragma Export (C, vpi_register_systf, "vpi_register_systf"); -- int vpi_remove_cb(vpiHandle ref) @@ -301,8 +301,8 @@ package Grt.Vpi is function vpi_chk_error (Info : p_vpi_error_info) return Integer; pragma Export (C, vpi_chk_error); - function vpi_control (Op : Integer; Status : Integer) return Integer; - pragma Export (C, vpi_control); + function vpi_control_np (Op : Integer; Status : Integer) return Integer; + pragma Export (C, vpi_control_np); ------------------------------------------------------------------------------- -- * * * G H D L h o o k s * * * * * * * * * * * * * * * * * * * * * * * diff --git a/src/grt/vpi_thunk.c b/src/grt/vpi_thunk.c new file mode 100644 index 000000000..bab1b7fad --- /dev/null +++ b/src/grt/vpi_thunk.c @@ -0,0 +1,216 @@ +/* GHDL Run Time (GRT) - VPI thunks + Copyright (C) 2016 Tristan Gingold & Patrick Lehmann + + GHDL is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. + + GHDL is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + As a special exception, if other files instantiate generics from this + unit, or you link this unit with other files to produce an executable, + this unit does not by itself cause the resulting executable to be + covered by the GNU General Public License. This exception does not + however invalidate any other reasons why the executable file might be + covered by the GNU Public License. +*/ +#include <stdarg.h> + +/* Define PLI_PROTOTYPES so that vpi_user.h do not import functions. */ +#define PLI_PROTOTYPES +#define PROTO_PARAMS(params) params +#define XXTERN extern + +#include "vpi_thunk.h" + +// the function pointer table +vpi_thunk *VPI_THUNK; + +// stub functions for VPI +vpiHandle +vpi_register_systf (s_vpi_systf_data *s) +{ + return VPI_THUNK->vpi_register_systf (s); +} + +int +vpi_vprintf (char *fmt, va_list ap) +{ + return VPI_THUNK->vpi_vprintf (fmt, ap); +} + +unsigned int +vpi_mcd_close (unsigned int mcd) +{ + return VPI_THUNK->vpi_mcd_close (mcd); +} + +char * +vpi_mcd_name (unsigned int mcd) +{ + return VPI_THUNK->vpi_mcd_name (mcd); +} + +unsigned int +vpi_mcd_open (char *name) +{ + return VPI_THUNK->vpi_mcd_open (name); +} + +unsigned int +vpi_mcd_open_x (char *name, char *mode) +{ + return VPI_THUNK->vpi_mcd_open_x (name, mode); +} + +int +vpi_mcd_vprintf (unsigned int mcd, char *fmt, va_list ap) +{ + return VPI_THUNK->vpi_mcd_vprintf (mcd, fmt, ap); +} + +int +vpi_mcd_fputc (unsigned int mcd, unsigned char x) +{ + return VPI_THUNK->vpi_mcd_fputc (mcd, x); +} + +int +vpi_mcd_fgetc (unsigned int mcd) +{ + return VPI_THUNK->vpi_mcd_fgetc (mcd); +} + +vpiHandle +vpi_register_cb (p_cb_data data) +{ + return VPI_THUNK->vpi_register_cb (data); +} + +int +vpi_remove_cb (vpiHandle ref) +{ + return VPI_THUNK->vpi_remove_cb (ref); +} + +void +vpi_sim_vcontrol (int operation, va_list ap) +{ + return VPI_THUNK->vpi_sim_vcontrol (operation, ap); +} + +vpiHandle +vpi_handle (int type, vpiHandle ref) +{ + return VPI_THUNK->vpi_handle (type, ref); +} + +vpiHandle +vpi_iterate (int type, vpiHandle ref) +{ + return VPI_THUNK->vpi_iterate (type, ref); +} + +vpiHandle +vpi_scan (vpiHandle iter) +{ + return VPI_THUNK->vpi_scan (iter); +} + +vpiHandle +vpi_handle_by_index (vpiHandle ref, int index) +{ + return VPI_THUNK->vpi_handle_by_index (ref, index); +} + +void +vpi_get_time (vpiHandle obj, s_vpi_time *t) +{ + return VPI_THUNK->vpi_get_time (obj, t); +} + +int +vpi_get (int property, vpiHandle ref) +{ + return VPI_THUNK->vpi_get (property, ref); +} + +char * +vpi_get_str (int property, vpiHandle ref) +{ + return VPI_THUNK->vpi_get_str (property, ref); +} + +void +vpi_get_value (vpiHandle expr, p_vpi_value value) +{ + return VPI_THUNK->vpi_get_value (expr, value); +} + +vpiHandle +vpi_put_value (vpiHandle obj, p_vpi_value value, p_vpi_time when, int flags) +{ + return VPI_THUNK->vpi_put_value (obj, value, when, flags); +} + +int +vpi_free_object (vpiHandle ref) +{ + return VPI_THUNK->vpi_free_object (ref); +} + +int +vpi_get_vlog_info (p_vpi_vlog_info vlog_info_p) +{ + return VPI_THUNK->vpi_get_vlog_info (vlog_info_p); +} + +int +vpi_chk_error (p_vpi_error_info info) +{ + return VPI_THUNK->vpi_chk_error (info); +} + +vpiHandle +vpi_handle_by_name (char *name, vpiHandle scope) +{ + return VPI_THUNK->vpi_handle_by_name (name, scope); +} + + +int +vpi_printf (char *fmt, ...) +{ + va_list params; + PLI_INT32 res; + + va_start (params, fmt); + res = VPI_THUNK->vpi_vprintf (fmt, params); + va_end (params); + + return res; +} + +int +vpi_control (int op, ...) +{ + va_list params; + int status; + PLI_INT32 res; + + va_start (params, op); + status = va_arg (params, int); + res = VPI_THUNK->vpi_control_np (op, status); + va_end (params); + + return res; +} diff --git a/src/grt/vpi_thunk.h b/src/grt/vpi_thunk.h new file mode 100644 index 000000000..e8c36f843 --- /dev/null +++ b/src/grt/vpi_thunk.h @@ -0,0 +1,61 @@ +/* GHDL Run Time (GRT) - VPI thunks + Copyright (C) 2003 - 2016 Tristan Gingold & Felix Bertram + + GHDL is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. + + GHDL is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + As a special exception, if other files instantiate generics from this + unit, or you link this unit with other files to produce an executable, + this unit does not by itself cause the resulting executable to be + covered by the GNU General Public License. This exception does not + however invalidate any other reasons why the executable file might be + covered by the GNU Public License. +*/ + +/* VPI thunk is a GHDL structure used to interface between DLL/DSO and + GRT. This is in particular needed on Windows where undefined references + in DLL are not supported. */ + +#include "vpi_user.h" + +typedef struct { + vpiHandle (*vpi_register_systf) (p_vpi_systf_data data); + int (*vpi_vprintf) (char *fmt, va_list ap); + PLI_UINT32 (*vpi_mcd_close) (PLI_UINT32 mcd); + char* (*vpi_mcd_name) (PLI_UINT32 mcd); + PLI_UINT32 (*vpi_mcd_open) (char *name); + PLI_UINT32 (*vpi_mcd_open_x) (char *name, char *mode); + int (*vpi_mcd_vprintf) (PLI_UINT32 mcd, char *fmt, va_list ap); + int (*vpi_mcd_fputc) (PLI_UINT32 mcd, unsigned char x); + int (*vpi_mcd_fgetc) (PLI_UINT32 mcd); + vpiHandle (*vpi_register_cb) (p_cb_data data); + int (*vpi_remove_cb) (vpiHandle ref); + void (*vpi_sim_vcontrol) (int operation, va_list ap); + vpiHandle (*vpi_handle) (int type, vpiHandle ref); + vpiHandle (*vpi_iterate) (int type, vpiHandle ref); + vpiHandle (*vpi_scan) (vpiHandle iter); + vpiHandle (*vpi_handle_by_index)(vpiHandle ref, int index); + void (*vpi_get_time) (vpiHandle obj, s_vpi_time*t); + int (*vpi_get) (int property, vpiHandle ref); + char* (*vpi_get_str) (int property, vpiHandle ref); + void (*vpi_get_value) (vpiHandle expr, p_vpi_value value); + vpiHandle (*vpi_put_value) (vpiHandle obj, p_vpi_value value, + p_vpi_time when, int flags); + int (*vpi_free_object) (vpiHandle ref); + int (*vpi_get_vlog_info) (p_vpi_vlog_info vlog_info_p); + int (*vpi_chk_error) (p_vpi_error_info info); + vpiHandle (*vpi_handle_by_name) (char *name, vpiHandle scope); + int (*vpi_control_np) (int op, int status); +} vpi_thunk, *p_vpi_thunk; diff --git a/src/grt/vpi_user.h b/src/grt/vpi_user.h new file mode 100644 index 000000000..f5f169521 --- /dev/null +++ b/src/grt/vpi_user.h @@ -0,0 +1,925 @@ +/******************************************************************************* + * vpi_user.h + * + * IEEE 1364-2005 Verilog HDL Programming Language Interface (PLI) + * + * This file contains the constant definitions, structure definitions, and + * routine declarations used by the Verilog PLI procedural interface VPI + * access routines. + * + ******************************************************************************/ + +/******************************************************************************* + * NOTE: the constant values 1 through 299 are reserved for use in this + * vpi_user.h file. + ******************************************************************************/ + +#ifndef VPI_USER_H +#define VPI_USER_H + +#include <stdarg.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*----------------------------------------------------------------------------*/ +/*----------------------------- Portability Help -----------------------------*/ +/*----------------------------------------------------------------------------*/ + +/* Sized variables */ + +#ifndef PLI_TYPES +#define PLI_TYPES +typedef int PLI_INT32; +typedef unsigned int PLI_UINT32; +typedef short PLI_INT16; +typedef unsigned short PLI_UINT16; +typedef char PLI_BYTE8; +typedef unsigned char PLI_UBYTE8; +#endif + +/* Use to export a symbol */ + +#if defined (_MSC_VER) +#ifndef PLI_DLLISPEC +#define PLI_DLLISPEC __declspec(dllimport) +#define VPI_USER_DEFINED_DLLISPEC 1 +#endif +#else +#ifndef PLI_DLLISPEC +#define PLI_DLLISPEC +#endif +#endif + +/* Use to import a symbol */ + +#if defined (_MSC_VER) +#ifndef PLI_DLLESPEC +#define PLI_DLLESPEC __declspec(dllexport) +#define VPI_USER_DEFINED_DLLESPEC 1 +#endif +#else +#ifndef PLI_DLLESPEC +#define PLI_DLLESPEC +#endif +#endif + +/* Use to mark a function as external */ + +#ifndef PLI_EXTERN +#define PLI_EXTERN +#endif + +/* Use to mark a variable as external */ + +#ifndef PLI_VEXTERN +#define PLI_VEXTERN extern +#endif + +#ifndef PLI_PROTOTYPES +#define PLI_PROTOTYPES +#define PROTO_PARAMS(params) params + +/* object is defined imported by the application */ + +#define XXTERN PLI_EXTERN PLI_DLLISPEC + +/* object is exported by the application */ + +#define EETERN PLI_EXTERN PLI_DLLESPEC +#endif + +/********************************** TYPEDEFS **********************************/ + +/*typedef PLI_UINT32 *vpiHandle; */ +typedef void *vpiHandle; + +/******************************** OBJECT TYPES ********************************/ + +#define vpiAlways 1 /* always construct */ +#define vpiAssignStmt 2 /* quasi-continuous assignment */ +#define vpiAssignment 3 /* procedural assignment */ +#define vpiBegin 4 /* block statement */ +#define vpiCase 5 /* case statement */ +#define vpiCaseItem 6 /* case statement item */ +#define vpiConstant 7 /* numerical constant or literal string */ +#define vpiContAssign 8 /* continuous assignment */ +#define vpiDeassign 9 /* deassignment statement */ +#define vpiDefParam 10 /* defparam */ +#define vpiDelayControl 11 /* delay statement (e.g. #10) */ +#define vpiDisable 12 /* named block disable statement */ +#define vpiEventControl 13 /* wait on event, e.g. @e */ +#define vpiEventStmt 14 /* event trigger, e.g. ->e */ +#define vpiFor 15 /* for statement */ +#define vpiForce 16 /* force statement */ +#define vpiForever 17 /* forever statement */ +#define vpiFork 18 /* fork-join block */ +#define vpiFuncCall 19 /* HDL function call */ +#define vpiFunction 20 /* HDL function */ +#define vpiGate 21 /* primitive gate */ +#define vpiIf 22 /* if statement */ +#define vpiIfElse 23 /* if-else statement */ +#define vpiInitial 24 /* initial construct */ +#define vpiIntegerVar 25 /* integer variable */ +#define vpiInterModPath 26 /* intermodule wire delay */ +#define vpiIterator 27 /* iterator */ +#define vpiIODecl 28 /* input/output declaration */ +#define vpiMemory 29 /* behavioral memory */ +#define vpiMemoryWord 30 /* single word of memory */ +#define vpiModPath 31 /* module path for path delays */ +#define vpiModule 32 /* module instance */ +#define vpiNamedBegin 33 /* named block statement */ +#define vpiNamedEvent 34 /* event variable */ +#define vpiNamedFork 35 /* named fork-join block */ +#define vpiNet 36 /* scalar or vector net */ +#define vpiNetBit 37 /* bit of vector net */ +#define vpiNullStmt 38 /* a semicolon. Ie. #10 ; */ +#define vpiOperation 39 /* behavioral operation */ +#define vpiParamAssign 40 /* module parameter assignment */ +#define vpiParameter 41 /* module parameter */ +#define vpiPartSelect 42 /* part-select */ +#define vpiPathTerm 43 /* terminal of module path */ +#define vpiPort 44 /* module port */ +#define vpiPortBit 45 /* bit of vector module port */ +#define vpiPrimTerm 46 /* primitive terminal */ +#define vpiRealVar 47 /* real variable */ +#define vpiReg 48 /* scalar or vector reg */ +#define vpiRegBit 49 /* bit of vector reg */ +#define vpiRelease 50 /* release statement */ +#define vpiRepeat 51 /* repeat statement */ +#define vpiRepeatControl 52 /* repeat control in an assign stmt */ +#define vpiSchedEvent 53 /* vpi_put_value() event */ +#define vpiSpecParam 54 /* specparam */ +#define vpiSwitch 55 /* transistor switch */ +#define vpiSysFuncCall 56 /* system function call */ +#define vpiSysTaskCall 57 /* system task call */ +#define vpiTableEntry 58 /* UDP state table entry */ +#define vpiTask 59 /* HDL task */ +#define vpiTaskCall 60 /* HDL task call */ +#define vpiTchk 61 /* timing check */ +#define vpiTchkTerm 62 /* terminal of timing check */ +#define vpiTimeVar 63 /* time variable */ +#define vpiTimeQueue 64 /* simulation event queue */ +#define vpiUdp 65 /* user-defined primitive */ +#define vpiUdpDefn 66 /* UDP definition */ +#define vpiUserSystf 67 /* user defined system task or function */ +#define vpiVarSelect 68 /* variable array selection */ +#define vpiWait 69 /* wait statement */ +#define vpiWhile 70 /* while statement */ + +/********************** object types added with 1364-2001 *********************/ + +#define vpiAttribute 105 /* attribute of an object */ +#define vpiBitSelect 106 /* Bit-select of parameter, var select */ +#define vpiCallback 107 /* callback object */ +#define vpiDelayTerm 108 /* Delay term which is a load or driver */ +#define vpiDelayDevice 109 /* Delay object within a net */ +#define vpiFrame 110 /* reentrant task/func frame */ +#define vpiGateArray 111 /* gate instance array */ +#define vpiModuleArray 112 /* module instance array */ +#define vpiPrimitiveArray 113 /* vpiprimitiveArray type */ +#define vpiNetArray 114 /* multidimensional net */ +#define vpiRange 115 /* range declaration */ +#define vpiRegArray 116 /* multidimensional reg */ +#define vpiSwitchArray 117 /* switch instance array */ +#define vpiUdpArray 118 /* UDP instance array */ +#define vpiContAssignBit 128 /* Bit of a vector continuous assignment */ +#define vpiNamedEventArray 129 /* multidimensional named event */ + +/********************** object types added with 1364-2005 *********************/ + +#define vpiIndexedPartSelect 130 /* Indexed part-select object */ +#define vpiGenScopeArray 133 /* array of generated scopes */ +#define vpiGenScope 134 /* A generated scope */ +#define vpiGenVar 135 /* Object used to instantiate gen scopes */ + +/*********************************** METHODS **********************************/ +/**************** methods used to traverse 1 to 1 relationships ***************/ + +#define vpiCondition 71 /* condition expression */ +#define vpiDelay 72 /* net or gate delay */ +#define vpiElseStmt 73 /* else statement */ +#define vpiForIncStmt 74 /* increment statement in for loop */ +#define vpiForInitStmt 75 /* initialization statement in for loop */ +#define vpiHighConn 76 /* higher connection to port */ +#define vpiLhs 77 /* left-hand side of assignment */ +#define vpiIndex 78 /* index of var select, bit-select, etc. */ +#define vpiLeftRange 79 /* left range of vector or part-select */ +#define vpiLowConn 80 /* lower connection to port */ +#define vpiParent 81 /* parent object */ +#define vpiRhs 82 /* right-hand side of assignment */ +#define vpiRightRange 83 /* right range of vector or part-select */ +#define vpiScope 84 /* containing scope object */ +#define vpiSysTfCall 85 /* task function call */ +#define vpiTchkDataTerm 86 /* timing check data term */ +#define vpiTchkNotifier 87 /* timing check notifier */ +#define vpiTchkRefTerm 88 /* timing check reference term */ + +/************* methods used to traverse 1 to many relationships ***************/ + +#define vpiArgument 89 /* argument to (system) task/function */ +#define vpiBit 90 /* bit of vector net or port */ +#define vpiDriver 91 /* driver for a net */ +#define vpiInternalScope 92 /* internal scope in module */ +#define vpiLoad 93 /* load on net or reg */ +#define vpiModDataPathIn 94 /* data terminal of a module path */ +#define vpiModPathIn 95 /* Input terminal of a module path */ +#define vpiModPathOut 96 /* output terminal of a module path */ +#define vpiOperand 97 /* operand of expression */ +#define vpiPortInst 98 /* connected port instance */ +#define vpiProcess 99 /* process in module */ +#define vpiVariables 100 /* variables in module */ +#define vpiUse 101 /* usage */ + +/******** methods which can traverse 1 to 1, or 1 to many relationships *******/ + +#define vpiExpr 102 /* connected expression */ +#define vpiPrimitive 103 /* primitive (gate, switch, UDP) */ +#define vpiStmt 104 /* statement in process or task */ + +/************************ methods added with 1364-2001 ************************/ + +#define vpiActiveTimeFormat 119 /* active $timeformat() system task */ +#define vpiInTerm 120 /* To get to a delay device's drivers. */ +#define vpiInstanceArray 121 /* vpiInstance arrays */ +#define vpiLocalDriver 122 /* local drivers (within a module */ +#define vpiLocalLoad 123 /* local loads (within a module */ +#define vpiOutTerm 124 /* To get to a delay device's loads. */ +#define vpiPorts 125 /* Module port */ +#define vpiSimNet 126 /* simulated net after collapsing */ +#define vpiTaskFunc 127 /* HDL task or function */ + +/************************ methods added with 1364-2005 ************************/ + +#define vpiBaseExpr 131 /* Indexed part-select's base expression */ +#define vpiWidthExpr 132 /* Indexed part-select's width expression */ + +/********************************* PROPERTIES *********************************/ +/************************** generic object properties *************************/ + +#define vpiUndefined -1 /* undefined property */ +#define vpiType 1 /* type of object */ +#define vpiName 2 /* local name of object */ +#define vpiFullName 3 /* full hierarchical name */ +#define vpiSize 4 /* size of gate, net, port, etc. */ +#define vpiFile 5 /* File name in which the object is used*/ +#define vpiLineNo 6 /* line number where the object is used */ + +/***************************** module properties ******************************/ + +#define vpiTopModule 7 /* top-level module (boolean) */ +#define vpiCellInstance 8 /* cell (boolean) */ +#define vpiDefName 9 /* module definition name */ +#define vpiProtected 10 /* source protected module (boolean) */ +#define vpiTimeUnit 11 /* module time unit */ +#define vpiTimePrecision 12 /* module time precision */ +#define vpiDefNetType 13 /* default net type */ +#define vpiUnconnDrive 14 /* unconnected port drive strength */ +#define vpiHighZ 1 /* No default drive given */ +#define vpiPull1 2 /* default pull1 drive */ +#define vpiPull0 3 /* default pull0 drive */ +#define vpiDefFile 15 /* File name where the module is defined*/ +#define vpiDefLineNo 16 /* line number for module definition */ +#define vpiDefDelayMode 47 /* Default delay mode for a module */ +#define vpiDelayModeNone 1 /* no delay mode specified */ +#define vpiDelayModePath 2 /* path delay mode */ +#define vpiDelayModeDistrib 3 /* distributed delay mode */ +#define vpiDelayModeUnit 4 /* unit delay mode */ +#define vpiDelayModeZero 5 /* zero delay mode */ +#define vpiDelayModeMTM 6 /* min:typ:max delay mode */ +#define vpiDefDecayTime 48 /* Default decay time for a module */ + +/*************************** port and net properties **************************/ + +#define vpiScalar 17 /* scalar (boolean) */ +#define vpiVector 18 /* vector (boolean) */ +#define vpiExplicitName 19 /* port is explicitly named */ +#define vpiDirection 20 /* direction of port: */ +#define vpiInput 1 /* input */ +#define vpiOutput 2 /* output */ +#define vpiInout 3 /* inout */ +#define vpiMixedIO 4 /* mixed input-output */ +#define vpiNoDirection 5 /* no direction */ +#define vpiConnByName 21 /* connected by name (boolean) */ + +#define vpiNetType 22 /* net subtypes: */ +#define vpiWire 1 /* wire net */ +#define vpiWand 2 /* wire-and net */ +#define vpiWor 3 /* wire-or net */ +#define vpiTri 4 /* three-state net */ +#define vpiTri0 5 /* pull-down net */ +#define vpiTri1 6 /* pull-up net */ +#define vpiTriReg 7 /* tri state reg net */ +#define vpiTriAnd 8 /* three-state wire-and net */ +#define vpiTriOr 9 /* three-state wire-or net */ +#define vpiSupply1 10 /* supply 1 net */ +#define vpiSupply0 11 /* supply zero net */ +#define vpiNone 12 /* no default net type (1364-2001) */ +#define vpiUwire 13 /* unresolved wire net (1364-2005) */ + +#define vpiExplicitScalared 23 /* explicitly scalared (boolean) */ +#define vpiExplicitVectored 24 /* explicitly vectored (boolean) */ +#define vpiExpanded 25 /* expanded vector net (boolean) */ +#define vpiImplicitDecl 26 /* implicitly declared net (boolean) */ +#define vpiChargeStrength 27 /* charge decay strength of net */ + +/* Defined as part of strengths section. +#define vpiLargeCharge 0x10 +#define vpiMediumCharge 0x04 +#define vpiSmallCharge 0x02 +*/ + +#define vpiArray 28 /* variable array (boolean) */ +#define vpiPortIndex 29 /* Port index */ + +/************************ gate and terminal properties ************************/ + +#define vpiTermIndex 30 /* Index of a primitive terminal */ +#define vpiStrength0 31 /* 0-strength of net or gate */ +#define vpiStrength1 32 /* 1-strength of net or gate */ +#define vpiPrimType 33 /* prmitive subtypes: */ +#define vpiAndPrim 1 /* and gate */ +#define vpiNandPrim 2 /* nand gate */ +#define vpiNorPrim 3 /* nor gate */ +#define vpiOrPrim 4 /* or gate */ +#define vpiXorPrim 5 /* xor gate */ +#define vpiXnorPrim 6 /* xnor gate */ +#define vpiBufPrim 7 /* buffer */ +#define vpiNotPrim 8 /* not gate */ +#define vpiBufif0Prim 9 /* zero-enabled buffer */ +#define vpiBufif1Prim 10 /* one-enabled buffer */ +#define vpiNotif0Prim 11 /* zero-enabled not gate */ +#define vpiNotif1Prim 12 /* one-enabled not gate */ +#define vpiNmosPrim 13 /* nmos switch */ +#define vpiPmosPrim 14 /* pmos switch */ +#define vpiCmosPrim 15 /* cmos switch */ +#define vpiRnmosPrim 16 /* resistive nmos switch */ +#define vpiRpmosPrim 17 /* resistive pmos switch */ +#define vpiRcmosPrim 18 /* resistive cmos switch */ +#define vpiRtranPrim 19 /* resistive bidirectional */ +#define vpiRtranif0Prim 20 /* zero-enable resistive bidirectional */ +#define vpiRtranif1Prim 21 /* one-enable resistive bidirectional */ +#define vpiTranPrim 22 /* bidirectional */ +#define vpiTranif0Prim 23 /* zero-enabled bidirectional */ +#define vpiTranif1Prim 24 /* one-enabled bidirectional */ +#define vpiPullupPrim 25 /* pullup */ +#define vpiPulldownPrim 26 /* pulldown */ +#define vpiSeqPrim 27 /* sequential UDP */ +#define vpiCombPrim 28 /* combinational UDP */ + +/**************** path, path terminal, timing check properties ****************/ + +#define vpiPolarity 34 /* polarity of module path... */ +#define vpiDataPolarity 35 /* ...or data path: */ +#define vpiPositive 1 /* positive */ +#define vpiNegative 2 /* negative */ +#define vpiUnknown 3 /* unknown (unspecified) */ + +#define vpiEdge 36 /* edge type of module path: */ +#define vpiNoEdge 0x00 /* no edge */ +#define vpiEdge01 0x01 /* 0 -> 1 */ +#define vpiEdge10 0x02 /* 1 -> 0 */ +#define vpiEdge0x 0x04 /* 0 -> x */ +#define vpiEdgex1 0x08 /* x -> 1 */ +#define vpiEdge1x 0x10 /* 1 -> x */ +#define vpiEdgex0 0x20 /* x -> 0 */ +#define vpiPosedge (vpiEdgex1 | vpiEdge01 | vpiEdge0x) +#define vpiNegedge (vpiEdgex0 | vpiEdge10 | vpiEdge1x) +#define vpiAnyEdge (vpiPosedge | vpiNegedge) + +#define vpiPathType 37 /* path delay connection subtypes: */ +#define vpiPathFull 1 /* ( a *> b ) */ +#define vpiPathParallel 2 /* ( a => b ) */ + +#define vpiTchkType 38 /* timing check subtypes: */ +#define vpiSetup 1 /* $setup */ +#define vpiHold 2 /* $hold */ +#define vpiPeriod 3 /* $period */ +#define vpiWidth 4 /* $width */ +#define vpiSkew 5 /* $skew */ +#define vpiRecovery 6 /* $recovery */ +#define vpiNoChange 7 /* $nochange */ +#define vpiSetupHold 8 /* $setuphold */ +#define vpiFullskew 9 /* $fullskew -- added for 1364-2001 */ +#define vpiRecrem 10 /* $recrem -- added for 1364-2001 */ +#define vpiRemoval 11 /* $removal -- added for 1364-2001 */ +#define vpiTimeskew 12 /* $timeskew -- added for 1364-2001 */ + +/**************************** expression properties ***************************/ + +#define vpiOpType 39 /* operation subtypes: */ +#define vpiMinusOp 1 /* unary minus */ +#define vpiPlusOp 2 /* unary plus */ +#define vpiNotOp 3 /* unary not */ +#define vpiBitNegOp 4 /* bitwise negation */ +#define vpiUnaryAndOp 5 /* bitwise reduction and */ +#define vpiUnaryNandOp 6 /* bitwise reduction nand */ +#define vpiUnaryOrOp 7 /* bitwise reduction or */ +#define vpiUnaryNorOp 8 /* bitwise reduction nor */ +#define vpiUnaryXorOp 9 /* bitwise reduction xor */ +#define vpiUnaryXNorOp 10 /* bitwise reduction xnor */ +#define vpiSubOp 11 /* binary subtraction */ +#define vpiDivOp 12 /* binary division */ +#define vpiModOp 13 /* binary modulus */ +#define vpiEqOp 14 /* binary equality */ +#define vpiNeqOp 15 /* binary inequality */ +#define vpiCaseEqOp 16 /* case (x and z) equality */ +#define vpiCaseNeqOp 17 /* case inequality */ +#define vpiGtOp 18 /* binary greater than */ +#define vpiGeOp 19 /* binary greater than or equal */ +#define vpiLtOp 20 /* binary less than */ +#define vpiLeOp 21 /* binary less than or equal */ +#define vpiLShiftOp 22 /* binary left shift */ +#define vpiRShiftOp 23 /* binary right shift */ +#define vpiAddOp 24 /* binary addition */ +#define vpiMultOp 25 /* binary multiplication */ +#define vpiLogAndOp 26 /* binary logical and */ +#define vpiLogOrOp 27 /* binary logical or */ +#define vpiBitAndOp 28 /* binary bitwise and */ +#define vpiBitOrOp 29 /* binary bitwise or */ +#define vpiBitXorOp 30 /* binary bitwise xor */ +#define vpiBitXNorOp 31 /* binary bitwise xnor */ +#define vpiBitXnorOp vpiBitXNorOp /* added with 1364-2001 */ +#define vpiConditionOp 32 /* ternary conditional */ +#define vpiConcatOp 33 /* n-ary concatenation */ +#define vpiMultiConcatOp 34 /* repeated concatenation */ +#define vpiEventOrOp 35 /* event or */ +#define vpiNullOp 36 /* null operation */ +#define vpiListOp 37 /* list of expressions */ +#define vpiMinTypMaxOp 38 /* min:typ:max: delay expression */ +#define vpiPosedgeOp 39 /* posedge */ +#define vpiNegedgeOp 40 /* negedge */ +#define vpiArithLShiftOp 41 /* arithmetic left shift (1364-2001) */ +#define vpiArithRShiftOp 42 /* arithmetic right shift (1364-2001) */ +#define vpiPowerOp 43 /* arithmetic power op (1364-2001) */ + +#define vpiConstType 40 /* constant subtypes: */ +#define vpiDecConst 1 /* decimal integer */ +#define vpiRealConst 2 /* real */ +#define vpiBinaryConst 3 /* binary integer */ +#define vpiOctConst 4 /* octal integer */ +#define vpiHexConst 5 /* hexadecimal integer */ +#define vpiStringConst 6 /* string literal */ +#define vpiIntConst 7 /* HDL integer constant (1364-2001) */ + +#define vpiBlocking 41 /* blocking assignment (boolean) */ +#define vpiCaseType 42 /* case statement subtypes: */ +#define vpiCaseExact 1 /* exact match */ +#define vpiCaseX 2 /* ignore X's */ +#define vpiCaseZ 3 /* ignore Z's */ +#define vpiNetDeclAssign 43 /* assign part of decl (boolean) */ + +/************************** task/function properties **************************/ + +#define vpiFuncType 44 /* HDL function & system function type */ +#define vpiIntFunc 1 /* returns integer */ +#define vpiRealFunc 2 /* returns real */ +#define vpiTimeFunc 3 /* returns time */ +#define vpiSizedFunc 4 /* returns an arbitrary size */ +#define vpiSizedSignedFunc 5 /* returns sized signed value */ + +/** alias 1364-1995 system function subtypes to 1364-2001 function subtypes ***/ + +#define vpiSysFuncType vpiFuncType +#define vpiSysFuncInt vpiIntFunc +#define vpiSysFuncReal vpiRealFunc +#define vpiSysFuncTime vpiTimeFunc +#define vpiSysFuncSized vpiSizedFunc + +#define vpiUserDefn 45 /*user defined system task/func(boolean)*/ +#define vpiScheduled 46 /* object still scheduled (boolean) */ + +/*********************** properties added with 1364-2001 **********************/ + +#define vpiActive 49 /* reentrant task/func frame is active */ +#define vpiAutomatic 50 /* task/func obj is automatic */ +#define vpiCell 51 /* configuration cell */ +#define vpiConfig 52 /* configuration config file */ +#define vpiConstantSelect 53 /* (boolean) bit-select or part-select + indices are constant expressions */ +#define vpiDecompile 54 /* decompile the object */ +#define vpiDefAttribute 55 /* Attribute defined for the obj */ +#define vpiDelayType 56 /* delay subtype */ +#define vpiModPathDelay 1 /* module path delay */ +#define vpiInterModPathDelay 2 /* intermodule path delay */ +#define vpiMIPDelay 3 /* module input port delay */ +#define vpiIteratorType 57 /* object type of an iterator */ +#define vpiLibrary 58 /* configuration library */ +#define vpiMultiArray 59 /* Object is a multidimensional array */ +#define vpiOffset 60 /* offset from LSB */ +#define vpiResolvedNetType 61 /* net subtype after resolution, returns + same subtypes as vpiNetType */ +#define vpiSaveRestartID 62 /* unique ID for save/restart data */ +#define vpiSaveRestartLocation 63 /* name of save/restart data file */ +#define vpiValid 64 /* reentrant task/func frame is valid */ +#define vpiSigned 65 /* TRUE for vpiIODecl and any object in + the expression class if the object + has the signed attribute */ +#define vpiLocalParam 70 /* TRUE when a param is declared as a + localparam */ +#define vpiModPathHasIfNone 71 /* Mod path has an ifnone statement */ + +/*********************** properties added with 1364-2005 **********************/ + +#define vpiIndexedPartSelectType 72 /* Indexed part-select type */ +#define vpiPosIndexed 1 /* +: */ +#define vpiNegIndexed 2 /* -: */ +#define vpiIsMemory 73 /* TRUE for a one-dimensional reg array */ + +/*************** vpi_control() constants (added with 1364-2001) ***************/ + +#define vpiStop 66 /* execute simulator's $stop */ +#define vpiFinish 67 /* execute simulator's $finish */ +#define vpiReset 68 /* execute simulator's $reset */ +#define vpiSetInteractiveScope 69 /* set simulator's interactive scope */ + +/**************************** I/O related defines *****************************/ + +#define VPI_MCD_STDOUT 0x00000001 + +/*************************** STRUCTURE DEFINITIONS ****************************/ + +/******************************* time structure *******************************/ + +typedef struct t_vpi_time +{ + PLI_INT32 type; /* [vpiScaledRealTime, vpiSimTime, + vpiSuppressTime] */ + PLI_UINT32 high, low; /* for vpiSimTime */ + double real; /* for vpiScaledRealTime */ +} s_vpi_time, *p_vpi_time; + +/* time types */ + +#define vpiScaledRealTime 1 +#define vpiSimTime 2 +#define vpiSuppressTime 3 + +/****************************** delay structures ******************************/ + +typedef struct t_vpi_delay +{ + struct t_vpi_time *da; /* pointer to user allocated array of + delay values */ + PLI_INT32 no_of_delays; /* number of delays */ + PLI_INT32 time_type; /* [vpiScaledRealTime, vpiSimTime, + vpiSuppressTime] */ + PLI_INT32 mtm_flag; /* true for mtm values */ + PLI_INT32 append_flag; /* true for append */ + PLI_INT32 pulsere_flag; /* true for pulsere values */ +} s_vpi_delay, *p_vpi_delay; + +/***************************** value structures *******************************/ + +/* vector value */ + +#ifndef VPI_VECVAL /* added in 1364-2005 */ +#define VPI_VECVAL + +typedef struct t_vpi_vecval +{ + /* following fields are repeated enough times to contain vector */ + PLI_INT32 aval, bval; /* bit encoding: ab: 00=0, 10=1, 11=X, 01=Z */ +} s_vpi_vecval, *p_vpi_vecval; + +#endif + +/* strength (scalar) value */ + +typedef struct t_vpi_strengthval +{ + PLI_INT32 logic; /* vpi[0,1,X,Z] */ + PLI_INT32 s0, s1; /* refer to strength coding below */ +} s_vpi_strengthval, *p_vpi_strengthval; + +/* strength values */ + +#define vpiSupplyDrive 0x80 +#define vpiStrongDrive 0x40 +#define vpiPullDrive 0x20 +#define vpiWeakDrive 0x08 +#define vpiLargeCharge 0x10 +#define vpiMediumCharge 0x04 +#define vpiSmallCharge 0x02 +#define vpiHiZ 0x01 + +/* generic value */ + +typedef struct t_vpi_value +{ + PLI_INT32 format; /* vpi[[Bin,Oct,Dec,Hex]Str,Scalar,Int,Real,String, + Vector,Strength,Suppress,Time,ObjType]Val */ + union + { + PLI_BYTE8 *str; /* string value */ + PLI_INT32 scalar; /* vpi[0,1,X,Z] */ + PLI_INT32 integer; /* integer value */ + double real; /* real value */ + struct t_vpi_time *time; /* time value */ + struct t_vpi_vecval *vector; /* vector value */ + struct t_vpi_strengthval *strength; /* strength value */ + PLI_BYTE8 *misc; /* ...other */ + } value; +} s_vpi_value, *p_vpi_value; + +/* value formats */ + +#define vpiBinStrVal 1 +#define vpiOctStrVal 2 +#define vpiDecStrVal 3 +#define vpiHexStrVal 4 +#define vpiScalarVal 5 +#define vpiIntVal 6 +#define vpiRealVal 7 +#define vpiStringVal 8 +#define vpiVectorVal 9 +#define vpiStrengthVal 10 +#define vpiTimeVal 11 +#define vpiObjTypeVal 12 +#define vpiSuppressVal 13 + +/* delay modes */ + +#define vpiNoDelay 1 +#define vpiInertialDelay 2 +#define vpiTransportDelay 3 +#define vpiPureTransportDelay 4 + +/* force and release flags */ + +#define vpiForceFlag 5 +#define vpiReleaseFlag 6 + +/* scheduled event cancel flag */ + +#define vpiCancelEvent 7 + +/* bit mask for the flags argument to vpi_put_value() */ + +#define vpiReturnEvent 0x1000 + +/* scalar values */ + +#define vpi0 0 +#define vpi1 1 +#define vpiZ 2 +#define vpiX 3 +#define vpiH 4 +#define vpiL 5 +#define vpiDontCare 6 +/* +#define vpiNoChange 7 Defined under vpiTchkType, but + can be used here. +*/ + +/*********************** system task/function structure ***********************/ + +typedef struct t_vpi_systf_data +{ + PLI_INT32 type; /* vpiSysTask, vpiSysFunc */ + PLI_INT32 sysfunctype; /* vpiSysTask, vpi[Int,Real,Time,Sized, + SizedSigned]Func */ + PLI_BYTE8 *tfname; /* first character must be '$' */ + PLI_INT32 (*calltf)(PLI_BYTE8 *); + PLI_INT32 (*compiletf)(PLI_BYTE8 *); + PLI_INT32 (*sizetf)(PLI_BYTE8 *); /* for sized function callbacks only */ + PLI_BYTE8 *user_data; +} s_vpi_systf_data, *p_vpi_systf_data; + +#define vpiSysTask 1 +#define vpiSysFunc 2 + +/* the subtypes are defined under the vpiFuncType property */ + +/****************** Verilog execution information structure *******************/ + +typedef struct t_vpi_vlog_info +{ + PLI_INT32 argc; + PLI_BYTE8 **argv; + PLI_BYTE8 *product; + PLI_BYTE8 *version; +} s_vpi_vlog_info, *p_vpi_vlog_info; + +/*********************** PLI error information structure **********************/ + +typedef struct t_vpi_error_info +{ + PLI_INT32 state; /* vpi[Compile,PLI,Run] */ + PLI_INT32 level; /* vpi[Notice,Warning,Error,System,Internal] */ + PLI_BYTE8 *message; + PLI_BYTE8 *product; + PLI_BYTE8 *code; + PLI_BYTE8 *file; + PLI_INT32 line; +} s_vpi_error_info, *p_vpi_error_info; + +/* state when error occurred */ + +#define vpiCompile 1 +#define vpiPLI 2 +#define vpiRun 3 + +/* error severity levels */ + +#define vpiNotice 1 +#define vpiWarning 2 +#define vpiError 3 +#define vpiSystem 4 +#define vpiInternal 5 + +/**************************** callback structures *****************************/ + +/* normal callback structure */ + +typedef struct t_cb_data +{ + PLI_INT32 reason; /* callback reason */ + PLI_INT32 (*cb_rtn)(struct t_cb_data *); /* call routine */ + vpiHandle obj; /* trigger object */ + p_vpi_time time; /* callback time */ + p_vpi_value value; /* trigger object value */ + PLI_INT32 index; /* index of the memory word or + var select that changed */ + PLI_BYTE8 *user_data; +} s_cb_data, *p_cb_data; + +/****************************** CALLBACK REASONS ******************************/ +/***************************** Simulation related *****************************/ + +#define cbValueChange 1 +#define cbStmt 2 +#define cbForce 3 +#define cbRelease 4 + +/******************************** Time related ********************************/ + +#define cbAtStartOfSimTime 5 +#define cbReadWriteSynch 6 +#define cbReadOnlySynch 7 +#define cbNextSimTime 8 +#define cbAfterDelay 9 + +/******************************* Action related *******************************/ + +#define cbEndOfCompile 10 +#define cbStartOfSimulation 11 +#define cbEndOfSimulation 12 +#define cbError 13 +#define cbTchkViolation 14 +#define cbStartOfSave 15 +#define cbEndOfSave 16 +#define cbStartOfRestart 17 +#define cbEndOfRestart 18 +#define cbStartOfReset 19 +#define cbEndOfReset 20 +#define cbEnterInteractive 21 +#define cbExitInteractive 22 +#define cbInteractiveScopeChange 23 +#define cbUnresolvedSystf 24 + +/**************************** Added with 1364-2001 ****************************/ + +#define cbAssign 25 +#define cbDeassign 26 +#define cbDisable 27 +#define cbPLIError 28 +#define cbSignal 29 + +/**************************** FUNCTION DECLARATIONS ***************************/ + +/* callback related */ + +XXTERN vpiHandle vpi_register_cb PROTO_PARAMS((p_cb_data cb_data_p)); +XXTERN PLI_INT32 vpi_remove_cb PROTO_PARAMS((vpiHandle cb_obj)); +XXTERN void vpi_get_cb_info PROTO_PARAMS((vpiHandle object, + p_cb_data cb_data_p)); +XXTERN vpiHandle vpi_register_systf PROTO_PARAMS((p_vpi_systf_data + systf_data_p)); +XXTERN void vpi_get_systf_info PROTO_PARAMS((vpiHandle object, + p_vpi_systf_data + systf_data_p)); + +/* for obtaining handles */ + +XXTERN vpiHandle vpi_handle_by_name PROTO_PARAMS((PLI_BYTE8 *name, + vpiHandle scope)); +XXTERN vpiHandle vpi_handle_by_index PROTO_PARAMS((vpiHandle object, + PLI_INT32 indx)); + +/* for traversing relationships */ + +XXTERN vpiHandle vpi_handle PROTO_PARAMS((PLI_INT32 type, + vpiHandle refHandle)); +XXTERN vpiHandle vpi_handle_multi PROTO_PARAMS((PLI_INT32 type, + vpiHandle refHandle1, + vpiHandle refHandle2, + ... )); +XXTERN vpiHandle vpi_iterate PROTO_PARAMS((PLI_INT32 type, + vpiHandle refHandle)); +XXTERN vpiHandle vpi_scan PROTO_PARAMS((vpiHandle iterator)); + +/* for processing properties */ + +XXTERN PLI_INT32 vpi_get PROTO_PARAMS((PLI_INT32 property, + vpiHandle object)); +XXTERN PLI_BYTE8 *vpi_get_str PROTO_PARAMS((PLI_INT32 property, + vpiHandle object)); + +/* delay processing */ + +XXTERN void vpi_get_delays PROTO_PARAMS((vpiHandle object, + p_vpi_delay delay_p)); +XXTERN void vpi_put_delays PROTO_PARAMS((vpiHandle object, + p_vpi_delay delay_p)); + +/* value processing */ + +XXTERN void vpi_get_value PROTO_PARAMS((vpiHandle expr, + p_vpi_value value_p)); +XXTERN vpiHandle vpi_put_value PROTO_PARAMS((vpiHandle object, + p_vpi_value value_p, + p_vpi_time time_p, + PLI_INT32 flags)); + +/* time processing */ + +XXTERN void vpi_get_time PROTO_PARAMS((vpiHandle object, + p_vpi_time time_p)); + +/* I/O routines */ + +XXTERN PLI_UINT32 vpi_mcd_open PROTO_PARAMS((PLI_BYTE8 *fileName)); +XXTERN PLI_UINT32 vpi_mcd_close PROTO_PARAMS((PLI_UINT32 mcd)); +XXTERN PLI_BYTE8 *vpi_mcd_name PROTO_PARAMS((PLI_UINT32 cd)); +XXTERN PLI_INT32 vpi_mcd_printf PROTO_PARAMS((PLI_UINT32 mcd, + PLI_BYTE8 *format, + ...)); +XXTERN PLI_INT32 vpi_printf PROTO_PARAMS((PLI_BYTE8 *format, + ...)); + +/* utility routines */ + +XXTERN PLI_INT32 vpi_compare_objects PROTO_PARAMS((vpiHandle object1, + vpiHandle object2)); +XXTERN PLI_INT32 vpi_chk_error PROTO_PARAMS((p_vpi_error_info + error_info_p)); +XXTERN PLI_INT32 vpi_free_object PROTO_PARAMS((vpiHandle object)); +XXTERN PLI_INT32 vpi_get_vlog_info PROTO_PARAMS((p_vpi_vlog_info + vlog_info_p)); + +/* routines added with 1364-2001 */ + +XXTERN PLI_INT32 vpi_get_data PROTO_PARAMS((PLI_INT32 id, + PLI_BYTE8 *dataLoc, + PLI_INT32 numOfBytes)); +XXTERN PLI_INT32 vpi_put_data PROTO_PARAMS((PLI_INT32 id, + PLI_BYTE8 *dataLoc, + PLI_INT32 numOfBytes)); +XXTERN void *vpi_get_userdata PROTO_PARAMS((vpiHandle obj)); +XXTERN PLI_INT32 vpi_put_userdata PROTO_PARAMS((vpiHandle obj, + void *userdata)); +XXTERN PLI_INT32 vpi_vprintf PROTO_PARAMS((PLI_BYTE8 *format, + va_list ap)); +XXTERN PLI_INT32 vpi_mcd_vprintf PROTO_PARAMS((PLI_UINT32 mcd, + PLI_BYTE8 *format, + va_list ap)); +XXTERN PLI_INT32 vpi_flush PROTO_PARAMS((void)); +XXTERN PLI_INT32 vpi_mcd_flush PROTO_PARAMS((PLI_UINT32 mcd)); +XXTERN PLI_INT32 vpi_control PROTO_PARAMS((PLI_INT32 operation, + ...)); +XXTERN vpiHandle vpi_handle_by_multi_index PROTO_PARAMS((vpiHandle obj, + PLI_INT32 num_index, + PLI_INT32 *index_array)); + +/****************************** GLOBAL VARIABLES ******************************/ + +PLI_VEXTERN PLI_DLLESPEC void (*vlog_startup_routines[])(); + + /* array of function pointers, last pointer should be null */ + +#undef PLI_EXTERN +#undef PLI_VEXTERN + +#ifdef VPI_USER_DEFINED_DLLISPEC +#undef VPI_USER_DEFINED_DLLISPEC +#undef PLI_DLLISPEC +#endif +#ifdef VPI_USER_DEFINED_DLLESPEC +#undef VPI_USER_DEFINED_DLLESPEC +#undef PLI_DLLESPEC +#endif + +#ifdef PLI_PROTOTYPES +#undef PLI_PROTOTYPES +#undef PROTO_PARAMS +#undef XXTERN +#undef EETERN +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* VPI_USER_H */ |