Use functions instead of macros for VPI routine redirection in Windows.
This commit is contained in:
parent
3f1253039a
commit
9fb952ed72
|
|
@ -42,7 +42,7 @@ else
|
|||
INCLUDE_PATH = -I. -I.. -I$(srcdir) -I$(srcdir)/..
|
||||
endif
|
||||
|
||||
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ -DIVL_VPI_MODULE @PICFLAG@
|
||||
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ @PICFLAG@
|
||||
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
* This may change in the future once I have thought about it more. */
|
||||
#define IVERILOG_VPI_CC "@IVLCC@"
|
||||
#define IVERILOG_VPI_CXX "@IVLCXX@"
|
||||
#define IVERILOG_VPI_CFLAGS " @IVLCFLAGS@ -DIVL_VPI_MODULE"
|
||||
#define IVERILOG_VPI_CXXFLAGS " @IVLCXXFLAGS@ -DIVL_VPI_MODULE"
|
||||
#define IVERILOG_VPI_CFLAGS " @IVLCFLAGS@"
|
||||
#define IVERILOG_VPI_CXXFLAGS " @IVLCXXFLAGS@"
|
||||
#define IVERILOG_VPI_LDFLAGS "@SHARED@"
|
||||
#define IVERILOG_VPI_LDLIBS "-lveriuser@SUFFIX@ -lvpi@SUFFIX@"
|
||||
#define IVERILOG_SUFFIX "@SUFFIX@"
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
# These are the variables used for compiling files
|
||||
CC="@IVCC@"
|
||||
CXX=@IVCXX@
|
||||
CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@ -DIVL_VPI_MODULE"
|
||||
CXXFLAGS="@PIC@ @IVCXXFLAGS@ -I@INCLUDEDIR@ -DIVL_VPI_MODULE"
|
||||
CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@"
|
||||
CXXFLAGS="@PIC@ @IVCXXFLAGS@ -I@INCLUDEDIR@"
|
||||
|
||||
SUFFIX=@SUFFIX@
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ LDRELOCFLAGS = @LDRELOCFLAGS@
|
|||
|
||||
LDTARGETFLAGS = @LDTARGETFLAGS@
|
||||
|
||||
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ -DICARUS_VPI_CONST=const -DIVL_VPI_MODULE @PICFLAG@
|
||||
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ -DICARUS_VPI_CONST=const @PICFLAG@
|
||||
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
|
||||
|
||||
A = a_close.o a_compare_handles.o a_configure.o a_fetch_argc.o \
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ else
|
|||
INCLUDE_PATH = -I. -I.. -I$(srcdir) -I$(srcdir)/..
|
||||
endif
|
||||
|
||||
CPPFLAGS = $(INCLUDE_PATH) @file64_support@ @CPPFLAGS@ @DEFS@ -DICARUS_VPI_CONST=const -DIVL_VPI_MODULE @PICFLAG@
|
||||
CPPFLAGS = $(INCLUDE_PATH) @file64_support@ @CPPFLAGS@ @DEFS@ -DICARUS_VPI_CONST=const @PICFLAG@
|
||||
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
|
||||
CXXFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CXX@ @CXXFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
|
|
|||
264
vpi/libvpi.c
264
vpi/libvpi.c
|
|
@ -20,8 +20,270 @@
|
|||
#if defined(__MINGW32__) || defined (__CYGWIN32__)
|
||||
|
||||
#include "vpi_user.h"
|
||||
#include <assert.h>
|
||||
|
||||
vpip_routines_s*vpip_routines = 0;
|
||||
static vpip_routines_s*vpip_routines = 0;
|
||||
|
||||
// callback related
|
||||
|
||||
vpiHandle vpi_register_cb(p_cb_data data)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->register_cb(data);
|
||||
}
|
||||
PLI_INT32 vpi_remove_cb(vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->remove_cb(ref);
|
||||
}
|
||||
|
||||
vpiHandle vpi_register_systf(const struct t_vpi_systf_data*ss)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->register_systf(ss);
|
||||
}
|
||||
void vpi_get_systf_info(vpiHandle obj, p_vpi_systf_data data)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->get_systf_info(obj, data);
|
||||
}
|
||||
|
||||
// for obtaining handles
|
||||
|
||||
vpiHandle vpi_handle_by_name(const char*name, vpiHandle scope)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->handle_by_name(name, scope);
|
||||
}
|
||||
vpiHandle vpi_handle_by_index(vpiHandle ref, PLI_INT32 idx)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->handle_by_index(ref, idx);
|
||||
}
|
||||
|
||||
// for traversing relationships
|
||||
|
||||
vpiHandle vpi_handle(PLI_INT32 type, vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->handle(type, ref);
|
||||
}
|
||||
vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->iterate(type, ref);
|
||||
}
|
||||
vpiHandle vpi_scan(vpiHandle iter)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->scan(iter);
|
||||
}
|
||||
|
||||
// for processing properties
|
||||
|
||||
PLI_INT32 vpi_get(int property, vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->get(property, ref);
|
||||
}
|
||||
char*vpi_get_str(PLI_INT32 property, vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->get_str(property, ref);
|
||||
}
|
||||
|
||||
// delay processing
|
||||
|
||||
void vpi_get_delays(vpiHandle expr, p_vpi_delay delays)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->get_delays(expr, delays);
|
||||
}
|
||||
void vpi_put_delays(vpiHandle expr, p_vpi_delay delays)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->put_delays(expr, delays);
|
||||
}
|
||||
|
||||
// value processing
|
||||
|
||||
void vpi_get_value(vpiHandle expr, p_vpi_value value)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->get_value(expr, value);
|
||||
}
|
||||
vpiHandle vpi_put_value(vpiHandle obj, p_vpi_value value, p_vpi_time when, PLI_INT32 flags)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->put_value(obj, value, when, flags);
|
||||
}
|
||||
|
||||
// time processing
|
||||
|
||||
void vpi_get_time(vpiHandle obj, s_vpi_time*t)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->get_time(obj, t);
|
||||
}
|
||||
|
||||
// data processing
|
||||
|
||||
void*vpi_get_userdata(vpiHandle obj)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->get_userdata(obj);
|
||||
}
|
||||
PLI_INT32 vpi_put_userdata(vpiHandle obj, void*data)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->put_userdata(obj, data);
|
||||
}
|
||||
|
||||
// I/O routines
|
||||
|
||||
PLI_UINT32 vpi_mcd_open(char*name)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->mcd_open(name);
|
||||
}
|
||||
PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->mcd_close(mcd);
|
||||
}
|
||||
PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->mcd_flush(mcd);
|
||||
}
|
||||
char*vpi_mcd_name(PLI_UINT32 mcd)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->mcd_name(mcd);
|
||||
}
|
||||
PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, const char*fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
assert(vpip_routines);
|
||||
PLI_INT32 rv = vpip_routines->mcd_vprintf(mcd, fmt, ap);
|
||||
va_end(ap);
|
||||
return rv;
|
||||
}
|
||||
PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->mcd_vprintf(mcd, fmt, ap);
|
||||
}
|
||||
|
||||
PLI_INT32 vpi_flush(void)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->flush();
|
||||
}
|
||||
PLI_INT32 vpi_printf(const char*fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
assert(vpip_routines);
|
||||
PLI_INT32 rv = vpip_routines->vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return rv;
|
||||
}
|
||||
PLI_INT32 vpi_vprintf(const char*fmt, va_list ap)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->vprintf(fmt, ap);
|
||||
}
|
||||
|
||||
// utility routines
|
||||
|
||||
PLI_INT32 vpi_chk_error(p_vpi_error_info info)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->chk_error(info);
|
||||
}
|
||||
PLI_INT32 vpi_compare_objects(vpiHandle obj1, vpiHandle obj2)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->compare_objects(obj1, obj2);
|
||||
}
|
||||
PLI_INT32 vpi_free_object(vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->free_object(ref);
|
||||
}
|
||||
PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info info)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->get_vlog_info(info);
|
||||
|
||||
}
|
||||
|
||||
// control routines
|
||||
|
||||
void vpi_control(PLI_INT32 operation, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, operation);
|
||||
assert(vpip_routines);
|
||||
vpip_routines->vcontrol(operation, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
void vpi_sim_control(PLI_INT32 operation, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, operation);
|
||||
assert(vpip_routines);
|
||||
vpip_routines->vcontrol(operation, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
// proposed standard extensions
|
||||
|
||||
PLI_INT32 vpi_fopen(const char*name, const char*mode)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->fopen(name, mode);
|
||||
}
|
||||
FILE*vpi_get_file(PLI_INT32 fd)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->get_file(fd);
|
||||
}
|
||||
|
||||
// Icarus extensions
|
||||
|
||||
s_vpi_vecval vpip_calc_clog2(vpiHandle arg)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
return vpip_routines->calc_clog2(arg);
|
||||
}
|
||||
void vpip_count_drivers(vpiHandle ref, unsigned idx, unsigned counts[4])
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->count_drivers(ref, idx, counts);
|
||||
}
|
||||
void vpip_format_strength(char*str, s_vpi_value*value, unsigned bit)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->format_strength(str, value, bit);
|
||||
}
|
||||
void vpip_make_systf_system_defined(vpiHandle ref)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->make_systf_system_defined(ref);
|
||||
}
|
||||
void vpip_mcd_rawwrite(PLI_UINT32 mcd, const char*buf, size_t count)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->mcd_rawwrite(mcd, buf, count);
|
||||
}
|
||||
void vpip_set_return_value(int value)
|
||||
{
|
||||
assert(vpip_routines);
|
||||
vpip_routines->set_return_value(value);
|
||||
}
|
||||
|
||||
DLLEXPORT void vpip_set_callback(vpip_routines_s*routines)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ void vpip_format_strength(char*, s_vpi_value*, unsigned) { }
|
|||
void vpip_make_systf_system_defined(vpiHandle) { }
|
||||
void vpip_mcd_rawwrite(PLI_UINT32, const char*, size_t) { }
|
||||
void vpip_set_return_value(int) { }
|
||||
void vpi_vcontrol(PLI_INT32, va_list) { }
|
||||
|
||||
|
||||
/* When a module registers a system function, extract and save the return
|
||||
|
|
@ -208,17 +209,14 @@ vpip_routines_s vpi_routines = {
|
|||
.mcd_close = vpi_mcd_close,
|
||||
.mcd_flush = vpi_mcd_flush,
|
||||
.mcd_name = vpi_mcd_name,
|
||||
.mcd_printf = vpi_mcd_printf,
|
||||
.mcd_vprintf = vpi_mcd_vprintf,
|
||||
.flush = vpi_flush,
|
||||
.printf = vpi_printf,
|
||||
.vprintf = vpi_vprintf,
|
||||
.chk_error = vpi_chk_error,
|
||||
.compare_objects = vpi_compare_objects,
|
||||
.free_object = vpi_free_object,
|
||||
.get_vlog_info = vpi_get_vlog_info,
|
||||
.control = vpi_control,
|
||||
.sim_control = vpi_sim_control,
|
||||
.vcontrol = vpi_vcontrol,
|
||||
.fopen = vpi_fopen,
|
||||
.get_file = vpi_get_file,
|
||||
.calc_clog2 = vpip_calc_clog2,
|
||||
|
|
|
|||
57
vpi_user.h
57
vpi_user.h
|
|
@ -706,17 +706,14 @@ typedef struct {
|
|||
PLI_UINT32 (*mcd_close)(PLI_UINT32);
|
||||
PLI_INT32 (*mcd_flush)(PLI_UINT32);
|
||||
char* (*mcd_name)(PLI_UINT32);
|
||||
PLI_INT32 (*mcd_printf)(PLI_UINT32, const char*, ...);
|
||||
PLI_INT32 (*mcd_vprintf)(PLI_UINT32, const char*, va_list);
|
||||
PLI_INT32 (*flush)(void);
|
||||
PLI_INT32 (*printf)(const char*, ...);
|
||||
PLI_INT32 (*vprintf)(const char*, va_list);
|
||||
PLI_INT32 (*chk_error)(p_vpi_error_info);
|
||||
PLI_INT32 (*compare_objects)(vpiHandle, vpiHandle);
|
||||
PLI_INT32 (*free_object)(vpiHandle);
|
||||
PLI_INT32 (*get_vlog_info)(p_vpi_vlog_info info) ;
|
||||
void (*control)(PLI_INT32, ...);
|
||||
void (*sim_control)(PLI_INT32, ...);
|
||||
void (*vcontrol)(PLI_INT32, va_list);
|
||||
PLI_INT32 (*fopen)(const char*, const char*);
|
||||
FILE* (*get_file)(PLI_INT32);
|
||||
s_vpi_vecval(*calc_clog2)(vpiHandle);
|
||||
|
|
@ -729,58 +726,6 @@ typedef struct {
|
|||
|
||||
extern DLLEXPORT void vpip_set_callback(vpip_routines_s*routines);
|
||||
|
||||
/*
|
||||
* IVL_VPI_MODULE should be defined when compiling a VPI module to route
|
||||
* all VPI routine calls through the jump table.
|
||||
*/
|
||||
#ifdef IVL_VPI_MODULE
|
||||
|
||||
extern vpip_routines_s*vpip_routines;
|
||||
|
||||
#define vpi_register_cb(...) vpip_routines->register_cb(__VA_ARGS__)
|
||||
#define vpi_remove_cb(...) vpip_routines->remove_cb(__VA_ARGS__)
|
||||
#define vpi_register_systf(...) vpip_routines->register_systf(__VA_ARGS__)
|
||||
#define vpi_get_systf_info(...) vpip_routines->get_systf_info(__VA_ARGS__)
|
||||
#define vpi_handle_by_name(...) vpip_routines->handle_by_name(__VA_ARGS__)
|
||||
#define vpi_handle_by_index(...) vpip_routines->handle_by_index(__VA_ARGS__)
|
||||
#define vpi_handle(...) vpip_routines->handle(__VA_ARGS__)
|
||||
#define vpi_iterate(...) vpip_routines->iterate(__VA_ARGS__)
|
||||
#define vpi_scan(...) vpip_routines->scan(__VA_ARGS__)
|
||||
#define vpi_get(...) vpip_routines->get(__VA_ARGS__)
|
||||
#define vpi_get_str(...) vpip_routines->get_str(__VA_ARGS__)
|
||||
#define vpi_get_delays(...) vpip_routines->get_delays(__VA_ARGS__)
|
||||
#define vpi_put_delays(...) vpip_routines->put_delays(__VA_ARGS__)
|
||||
#define vpi_get_value(...) vpip_routines->get_value(__VA_ARGS__)
|
||||
#define vpi_put_value(...) vpip_routines->put_value(__VA_ARGS__)
|
||||
#define vpi_get_time(...) vpip_routines->get_time(__VA_ARGS__)
|
||||
#define vpi_get_userdata(...) vpip_routines->get_userdata(__VA_ARGS__)
|
||||
#define vpi_put_userdata(...) vpip_routines->put_userdata(__VA_ARGS__)
|
||||
#define vpi_mcd_open(...) vpip_routines->mcd_open(__VA_ARGS__)
|
||||
#define vpi_mcd_close(...) vpip_routines->mcd_close(__VA_ARGS__)
|
||||
#define vpi_mcd_flush(...) vpip_routines->mcd_flush(__VA_ARGS__)
|
||||
#define vpi_mcd_name(...) vpip_routines->mcd_name(__VA_ARGS__)
|
||||
#define vpi_mcd_printf(...) vpip_routines->mcd_printf(__VA_ARGS__)
|
||||
#define vpi_mcd_vprintf(...) vpip_routines->mcd_vprintf(__VA_ARGS__)
|
||||
#define vpi_flush(...) vpip_routines->flush(__VA_ARGS__)
|
||||
#define vpi_printf(...) vpip_routines->printf(__VA_ARGS__)
|
||||
#define vpi_vprintf(...) vpip_routines->vprintf(__VA_ARGS__)
|
||||
#define vpi_chk_error(...) vpip_routines->chk_error(__VA_ARGS__)
|
||||
#define vpi_compare_objects(...) vpip_routines->compare_objects(__VA_ARGS__)
|
||||
#define vpi_free_object(...) vpip_routines->free_object(__VA_ARGS__)
|
||||
#define vpi_get_vlog_info(...) vpip_routines->get_vlog_info(__VA_ARGS__)
|
||||
#define vpi_control(...) vpip_routines->control(__VA_ARGS__)
|
||||
#define vpi_sim_control(...) vpip_routines->sim_control(__VA_ARGS__)
|
||||
#define vpi_fopen(...) vpip_routines->fopen(__VA_ARGS__)
|
||||
#define vpi_get_file(...) vpip_routines->get_file(__VA_ARGS__)
|
||||
#define vpip_calc_clog2(...) vpip_routines->calc_clog2(__VA_ARGS__)
|
||||
#define vpip_count_drivers(...) vpip_routines->count_drivers(__VA_ARGS__)
|
||||
#define vpip_format_strength(...) vpip_routines->format_strength(__VA_ARGS__)
|
||||
#define vpip_make_systf_system_defined(...) vpip_routines->make_systf_system_defined(__VA_ARGS__)
|
||||
#define vpip_mcd_rawwrite(...) vpip_routines->mcd_rawwrite(__VA_ARGS__)
|
||||
#define vpip_set_return_value(...) vpip_routines->set_return_value(__VA_ARGS__)
|
||||
|
||||
#endif // IVL_VPI_MODULE
|
||||
|
||||
#endif // defined(__MINGW32__) || defined (__CYGWIN32__)
|
||||
|
||||
EXTERN_C_END
|
||||
|
|
|
|||
|
|
@ -1659,17 +1659,14 @@ vpip_routines_s vpi_routines = {
|
|||
.mcd_close = vpi_mcd_close,
|
||||
.mcd_flush = vpi_mcd_flush,
|
||||
.mcd_name = vpi_mcd_name,
|
||||
.mcd_printf = vpi_mcd_printf,
|
||||
.mcd_vprintf = vpi_mcd_vprintf,
|
||||
.flush = vpi_flush,
|
||||
.printf = vpi_printf,
|
||||
.vprintf = vpi_vprintf,
|
||||
.chk_error = vpi_chk_error,
|
||||
.compare_objects = vpi_compare_objects,
|
||||
.free_object = vpi_free_object,
|
||||
.get_vlog_info = vpi_get_vlog_info,
|
||||
.control = vpi_control,
|
||||
.sim_control = vpi_sim_control,
|
||||
.vcontrol = vpi_sim_vcontrol,
|
||||
.fopen = vpi_fopen,
|
||||
.get_file = vpi_get_file,
|
||||
.calc_clog2 = vpip_calc_clog2,
|
||||
|
|
|
|||
Loading…
Reference in New Issue