diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index fe9f6c592..83ed651b9 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vvp_process.c,v 1.78 2003/01/27 00:14:37 steve Exp $" +#ident "$Id: vvp_process.c,v 1.79 2003/02/03 01:09:20 steve Exp $" #endif # include "vvp_priv.h" @@ -1316,6 +1316,8 @@ static int show_system_task_call(ivl_statement_t net) fprintf(vvp_out, ", $stime"); else if (strcmp("$realtime", ivl_expr_name(expr)) == 0) fprintf(vvp_out, ", $realtime"); + else if (strcmp("$simtime", ivl_expr_name(expr)) == 0) + fprintf(vvp_out, ", $simtime"); else fprintf(vvp_out, ", ?%s?", ivl_expr_name(expr)); continue; @@ -1565,6 +1567,9 @@ int draw_func_definition(ivl_scope_t scope) /* * $Log: vvp_process.c,v $ + * Revision 1.79 2003/02/03 01:09:20 steve + * Allow $display of $simtime. + * * Revision 1.78 2003/01/27 00:14:37 steve * Support in various contexts the $realtime * system task. diff --git a/vvp/compile.cc b/vvp/compile.cc index a2480f25e..a8d3e6c36 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: compile.cc,v 1.151 2003/02/01 05:50:04 steve Exp $" +#ident "$Id: compile.cc,v 1.152 2003/02/03 01:09:20 steve Exp $" #endif # include "arith.h" @@ -450,6 +450,12 @@ void compile_vpi_lookup(vpiHandle *handle, char*label) return; } + if (strcmp(label, "$simtime") == 0) { + *handle = vpip_sim_time(0); + free(label); + return; + } + struct vpi_handle_resolv_list_s*res = new struct vpi_handle_resolv_list_s; @@ -1513,6 +1519,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag, /* * $Log: compile.cc,v $ + * Revision 1.152 2003/02/03 01:09:20 steve + * Allow $display of $simtime. + * * Revision 1.151 2003/02/01 05:50:04 steve * Make $time and $realtime available to $display uniquely. * diff --git a/vvp/vpi_time.cc b/vvp/vpi_time.cc index 11e882c77..f5a2e39d4 100644 --- a/vvp/vpi_time.cc +++ b/vvp/vpi_time.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_time.cc,v 1.11 2003/02/02 02:14:14 steve Exp $" +#ident "$Id: vpi_time.cc,v 1.12 2003/02/03 01:09:20 steve Exp $" #endif # include "vpi_priv.h" @@ -39,6 +39,8 @@ */ static int vpi_time_precision = 0; +static struct __vpiSystemTime global_simtime; + void vpip_time_to_timestruct(struct t_vpi_time*ts, vvp_time64_t ti) { ts->low = ti & 0xFFFFFFFF; @@ -142,7 +144,7 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp) = reinterpret_cast(ref); unsigned long x, num_bits; vvp_time64_t simtime = schedule_simtime(); - int units = rfp->scope->time_units; + int units = rfp->scope? rfp->scope->time_units : vpi_time_precision; /* Calculate the divisor needed to scale the simulation time (in time_precision units) to time units of the scope. */ @@ -228,11 +230,22 @@ static const struct __vpirt vpip_system_realtime_rt = { 0 }; +/* + * Create a handle to represent a call to $time/$stime/$simtime. The + * $time and $stime system functions return a value scaled to a scope, + * and the $simtime returns the unscaled time. + */ vpiHandle vpip_sim_time(struct __vpiScope*scope) { - scope->scoped_time.base.vpi_type = &vpip_system_time_rt; - scope->scoped_time.scope = scope; - return &scope->scoped_time.base; + if (scope) { + scope->scoped_time.base.vpi_type = &vpip_system_time_rt; + scope->scoped_time.scope = scope; + return &scope->scoped_time.base; + } else { + global_simtime.base.vpi_type = &vpip_system_time_rt; + global_simtime.scope = 0; + return &global_simtime.base; + } } vpiHandle vpip_sim_realtime(struct __vpiScope*scope) @@ -255,6 +268,9 @@ void vpip_set_time_precision(int pre) /* * $Log: vpi_time.cc,v $ + * Revision 1.12 2003/02/03 01:09:20 steve + * Allow $display of $simtime. + * * Revision 1.11 2003/02/02 02:14:14 steve * Proper rounding of scaled integer time. *