From 08e6bf2e27ad9b358a2d9036cdc78882d87c8f0b Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 26 Jul 2000 03:53:11 +0000 Subject: [PATCH] Make simulation precision available to VPI. --- t-vvm.cc | 7 ++++++- vpi/vpi_user.h | 7 ++++++- vvm/vpi_priv.c | 20 +++++++++++++++++++- vvm/vpi_priv.h | 10 +++++++++- vvm/vpi_simulation.c | 11 ++++++++++- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/t-vvm.cc b/t-vvm.cc index 4f3597914..eaf9a5f09 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-vvm.cc,v 1.162 2000/07/14 06:12:57 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.163 2000/07/26 03:53:11 steve Exp $" #endif # include @@ -922,6 +922,8 @@ void target_vvm::start_design(ostream&os, const Design*mod) init_code << "{" << endl; init_code << " vpip_init_simulation();" << endl; + init_code << " vpip_time_scale(" + << mod->get_precision() << ");" << endl; start_code << "static void design_start()" << endl; start_code << "{" << endl; } @@ -3086,6 +3088,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.163 2000/07/26 03:53:11 steve + * Make simulation precision available to VPI. + * * Revision 1.162 2000/07/14 06:12:57 steve * Move inital value handling from NetNet to Nexus * objects. This allows better propogation of inital diff --git a/vpi/vpi_user.h b/vpi/vpi_user.h index ea0b08849..12cfd38d6 100644 --- a/vpi/vpi_user.h +++ b/vpi/vpi_user.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_user.h,v 1.18 2000/05/31 01:32:16 steve Exp $" +#ident "$Id: vpi_user.h,v 1.19 2000/07/26 03:53:12 steve Exp $" #endif #ifdef __cplusplus @@ -133,6 +133,8 @@ typedef struct t_vpi_value { #define vpiName 2 #define vpiFullName 3 #define vpiSize 4 +#define vpiTimeUnit 11 +#define vpiTimePrecision 12 #define vpiConstType 43 # define vpiDecConst 1 # define vpiRealConst 2 @@ -246,6 +248,9 @@ extern void (*vlog_startup_routines[])(); /* * $Log: vpi_user.h,v $ + * Revision 1.19 2000/07/26 03:53:12 steve + * Make simulation precision available to VPI. + * * Revision 1.18 2000/05/31 01:32:16 steve * typ vpiRealType. * diff --git a/vvm/vpi_priv.c b/vvm/vpi_priv.c index 63524bb4e..701ed4459 100644 --- a/vvm/vpi_priv.c +++ b/vvm/vpi_priv.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_priv.c,v 1.7 2000/05/07 18:20:08 steve Exp $" +#ident "$Id: vpi_priv.c,v 1.8 2000/07/26 03:53:12 steve Exp $" #endif # include "vpi_priv.h" @@ -111,11 +111,26 @@ int vpi_free_object(vpiHandle ref) return 0; } +static int vpip_get_global(int property) +{ + switch (property) { + case vpiTimePrecision: + return vpip_simulation_obj.time_precision; + + default: + assert(0); + return -1; + } +} + int vpi_get(int property, vpiHandle ref) { if (property == vpiType) return ref->vpi_type->type_code; + if (ref == 0) + return vpip_get_global(property); + if (ref->vpi_type->vpi_get_ == 0) return -1; @@ -219,6 +234,9 @@ void vpi_register_systf(const struct t_vpi_systf_data*systf) /* * $Log: vpi_priv.c,v $ + * Revision 1.8 2000/07/26 03:53:12 steve + * Make simulation precision available to VPI. + * * Revision 1.7 2000/05/07 18:20:08 steve * Import MCD support from Stephen Tell, and add * system function parameter support to the IVL core. diff --git a/vvm/vpi_priv.h b/vvm/vpi_priv.h index 39c9997ef..912770e0c 100644 --- a/vvm/vpi_priv.h +++ b/vvm/vpi_priv.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_priv.h,v 1.21 2000/05/18 03:27:32 steve Exp $" +#ident "$Id: vpi_priv.h,v 1.22 2000/07/26 03:53:12 steve Exp $" #endif /* @@ -340,11 +340,16 @@ struct vpip_simulation { /* List of simulation cycles, starting with the next time. */ struct vpip_simulation_cycle*sim; int going_flag; + + /* This is the precision of the simulation clock. It may be + used by the run time to scale time values. */ + short time_precision; }; extern struct vpip_simulation vpip_simulation_obj; extern void vpip_init_simulation(); +extern void vpip_time_scale(int precision); extern void vpip_simulation_run(); /* @@ -379,6 +384,9 @@ extern int vpip_finished(); /* * $Log: vpi_priv.h,v $ + * Revision 1.22 2000/07/26 03:53:12 steve + * Make simulation precision available to VPI. + * * Revision 1.21 2000/05/18 03:27:32 steve * Support writing scalars and vectors to signals. * diff --git a/vvm/vpi_simulation.c b/vvm/vpi_simulation.c index 29fb03fbb..3e6125392 100644 --- a/vvm/vpi_simulation.c +++ b/vvm/vpi_simulation.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_simulation.c,v 1.2 2000/02/23 02:56:56 steve Exp $" +#ident "$Id: vpi_simulation.c,v 1.3 2000/07/26 03:53:12 steve Exp $" #endif # include "vpi_priv.h" @@ -70,6 +70,12 @@ void vpip_init_simulation() cur->delay = 0; cur->next = cur->prev = cur; vpip_simulation_obj.sim = cur; + vpip_simulation_obj.time_precision = 0; +} + +void vpip_time_scale(int precision) +{ + vpip_simulation_obj.time_precision = precision; } vpiHandle vpip_sim_time() @@ -195,6 +201,9 @@ void vpip_simulation_run() /* * $Log: vpi_simulation.c,v $ + * Revision 1.3 2000/07/26 03:53:12 steve + * Make simulation precision available to VPI. + * * Revision 1.2 2000/02/23 02:56:56 steve * Macintosh compilers do not support ident. *