diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 42f59072b..7ce7dcd78 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_priv.cc,v 1.2 2001/03/19 01:55:38 steve Exp $" +#ident "$Id: vpi_priv.cc,v 1.3 2001/04/03 03:46:14 steve Exp $" #endif # include "vpi_priv.h" @@ -43,7 +43,12 @@ static int vpip_get_global(int property) { switch (property) { + case vpiTimePrecision: + fprintf(stderr, "vpi warning: vpiTimePrecision not supported\n"); + return 0; + default: + fprintf(stderr, "vpi error: bad global property: %d\n", property); assert(0); return -1; } @@ -71,9 +76,13 @@ char* vpi_get_str(int property, vpiHandle ref) return (ref->vpi_type->vpi_get_str_)(property, ref); } -void vpi_get_time(vpiHandle obj, s_vpi_time*t) +void vpi_get_time(vpiHandle obj, s_vpi_time*vp) { - assert(0); + // XXXX Cheat. Ignore timescale for the scope. + + vp->type = vpiSimTime; + vp->high = 0; + vp->low = schedule_simtime(); } void vpi_get_value(vpiHandle expr, s_vpi_value*vp) @@ -161,6 +170,10 @@ void vpi_sim_control(int operation, ...) /* * $Log: vpi_priv.cc,v $ + * Revision 1.3 2001/04/03 03:46:14 steve + * VPI access time as a decimal string, and + * stub vpi access to the scopes. + * * Revision 1.2 2001/03/19 01:55:38 steve * Add support for the vpiReset sim control. * diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index 4fe6c548f..fc54a6b7a 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_scope.cc,v 1.2 2001/03/21 05:13:03 steve Exp $" +#ident "$Id: vpi_scope.cc,v 1.3 2001/04/03 03:46:14 steve Exp $" #endif # include "compile.h" @@ -26,6 +26,49 @@ # include # include +static char* scope_get_str(int code, vpiHandle obj) +{ + struct __vpiScope*ref = (struct __vpiScope*)obj; + + + assert((obj->vpi_type->type_code == vpiModule) + || (obj->vpi_type->type_code == vpiNamedBegin) + || (obj->vpi_type->type_code == vpiTask)); + + switch (code) { + case vpiFullName: + return ref->name; + default: + assert(0); + return 0; + } +} + +static vpiHandle module_iter(int code, vpiHandle obj) +{ + struct __vpiScope*ref = (struct __vpiScope*)obj; + assert((obj->vpi_type->type_code == vpiModule) + || (obj->vpi_type->type_code == vpiNamedBegin) + || (obj->vpi_type->type_code == vpiTask) + || (obj->vpi_type->type_code == vpiFunction)); + + switch (code) { + case vpiInternalScope: + return 0; + } + return 0; +} + +static const struct __vpirt vpip_scope_rt = { + vpiModule, + 0, + scope_get_str, + 0, + 0, + 0, + module_iter +}; + static struct __vpiScope*current_scope = 0; static void attach_to_scope_(struct __vpiScope*scope, vpiHandle obj) @@ -53,6 +96,7 @@ void compile_scope_decl(char*label, char*name, char*parent) { struct __vpiScope*scope = (struct __vpiScope*) malloc(sizeof(struct __vpiScope)); + scope->base.vpi_type = &vpip_scope_rt; scope->name = name; scope->intern = 0; scope->nintern = 0; @@ -90,6 +134,10 @@ void vpip_attach_to_current_scope(vpiHandle obj) /* * $Log: vpi_scope.cc,v $ + * Revision 1.3 2001/04/03 03:46:14 steve + * VPI access time as a decimal string, and + * stub vpi access to the scopes. + * * Revision 1.2 2001/03/21 05:13:03 steve * Allow var objects as vpiHandle arguments to %vpi_call. * diff --git a/vvp/vpi_time.cc b/vvp/vpi_time.cc index 36215c075..9de1782e8 100644 --- a/vvp/vpi_time.cc +++ b/vvp/vpi_time.cc @@ -17,11 +17,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_time.cc,v 1.1 2001/03/31 19:00:44 steve Exp $" +#ident "$Id: vpi_time.cc,v 1.2 2001/04/03 03:46:14 steve Exp $" #endif # include "vpi_priv.h" # include "schedule.h" +# include # include static struct __vpiSystemTime { @@ -31,6 +32,7 @@ static struct __vpiSystemTime { static void timevar_get_value(vpiHandle ref, s_vpi_value*vp) { + static char buf_obj[128]; assert(ref == &time_handle.base); switch (vp->format) { @@ -43,6 +45,14 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp) vp->format = vpiTimeVal; break; + case vpiDecStrVal: + sprintf(buf_obj, "%lu", schedule_simtime()); + vp->value.str = buf_obj; + break; + + default: + fprintf(stderr, "vpi_time: unknown format: %d\n", vp->format); + assert(0); } } @@ -65,6 +75,10 @@ vpiHandle vpip_sim_time(void) /* * $Log: vpi_time.cc,v $ + * Revision 1.2 2001/04/03 03:46:14 steve + * VPI access time as a decimal string, and + * stub vpi access to the scopes. + * * Revision 1.1 2001/03/31 19:00:44 steve * Add VPI support for the simulation time. *