Add put_value with transport delay.
This commit is contained in:
parent
76295ac873
commit
78a2ef04a9
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_priv.cc,v 1.36 2003/04/27 04:19:24 steve Exp $"
|
||||
#ident "$Id: vpi_priv.cc,v 1.37 2003/05/02 04:29:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -254,10 +254,11 @@ char* vpi_get_str(int property, vpiHandle ref)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int time_units_from_handle(vpiHandle obj)
|
||||
int vpip_time_units_from_handle(vpiHandle obj)
|
||||
{
|
||||
struct __vpiSysTaskCall*task;
|
||||
struct __vpiScope*scope;
|
||||
struct __vpiSignal*signal;
|
||||
|
||||
if (obj == 0)
|
||||
return vpip_get_time_precision();
|
||||
|
|
@ -271,6 +272,11 @@ static int time_units_from_handle(vpiHandle obj)
|
|||
scope = (struct __vpiScope*)obj;
|
||||
return scope->time_units;
|
||||
|
||||
case vpiNet:
|
||||
case vpiReg:
|
||||
signal = (struct __vpiSignal*)obj;
|
||||
return signal->scope->time_units;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ERROR: vpi_get_time called with object "
|
||||
"handle type=%u\n", obj->vpi_type->type_code);
|
||||
|
|
@ -292,7 +298,7 @@ void vpi_get_time(vpiHandle obj, s_vpi_time*vp)
|
|||
break;
|
||||
|
||||
case vpiScaledRealTime:
|
||||
units = time_units_from_handle(obj);
|
||||
units = vpip_time_units_from_handle(obj);
|
||||
vp->real = pow(10, vpip_get_time_precision() - units);
|
||||
vp->real *= schedule_simtime();
|
||||
break;
|
||||
|
|
@ -631,6 +637,9 @@ extern "C" void vpi_control(int operation, ...)
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.cc,v $
|
||||
* Revision 1.37 2003/05/02 04:29:57 steve
|
||||
* Add put_value with transport delay.
|
||||
*
|
||||
* Revision 1.36 2003/04/27 04:19:24 steve
|
||||
* Support vpiScaledRealTime.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_priv.h,v 1.53 2003/04/23 03:09:25 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.54 2003/05/02 04:29:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -354,6 +354,8 @@ vpiHandle vpip_sim_realtime(struct __vpiScope*scope);
|
|||
extern int vpip_get_time_precision(void);
|
||||
extern void vpip_set_time_precision(int pres);
|
||||
|
||||
extern int vpip_time_units_from_handle(vpiHandle obj);
|
||||
|
||||
extern void vpip_time_to_timestruct(struct t_vpi_time*ts, vvp_time64_t ti);
|
||||
extern vvp_time64_t vpip_timestruct_to_time(const struct t_vpi_time*ts);
|
||||
|
||||
|
|
@ -415,6 +417,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.54 2003/05/02 04:29:57 steve
|
||||
* Add put_value with transport delay.
|
||||
*
|
||||
* Revision 1.53 2003/04/23 03:09:25 steve
|
||||
* VPI Access to named events.
|
||||
*
|
||||
|
|
@ -437,67 +442,5 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
|
|||
*
|
||||
* Revision 1.47 2003/02/09 23:33:26 steve
|
||||
* Spelling fixes.
|
||||
*
|
||||
* Revision 1.46 2003/02/01 05:50:04 steve
|
||||
* Make $time and $realtime available to $display uniquely.
|
||||
*
|
||||
* Revision 1.45 2003/01/27 00:14:37 steve
|
||||
* Support in various contexts the $realtime
|
||||
* system task.
|
||||
*
|
||||
* Revision 1.44 2003/01/26 18:16:22 steve
|
||||
* Add %cvt/ir and %cvt/ri instructions, and support
|
||||
* real values passed as arguments to VPI tasks.
|
||||
*
|
||||
* Revision 1.43 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.42 2003/01/09 04:09:44 steve
|
||||
* Add vpi_put_userdata
|
||||
*
|
||||
* Revision 1.41 2002/12/21 00:55:58 steve
|
||||
* The $time system task returns the integer time
|
||||
* scaled to the local units. Change the internal
|
||||
* implementation of vpiSystemTime the $time functions
|
||||
* to properly account for this. Also add $simtime
|
||||
* to get the simulation time.
|
||||
*
|
||||
* Revision 1.40 2002/08/12 01:35:09 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
* Revision 1.39 2002/07/09 03:24:37 steve
|
||||
* Dynamic resizevpi result buf in more places.
|
||||
*
|
||||
* Revision 1.38 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.37 2002/06/21 04:58:55 steve
|
||||
* Add support for special integer vectors.
|
||||
*
|
||||
* Revision 1.36 2002/05/19 05:18:16 steve
|
||||
* Add callbacks for vpiNamedEvent objects.
|
||||
*
|
||||
* Revision 1.35 2002/05/18 02:34:11 steve
|
||||
* Add vpi support for named events.
|
||||
*
|
||||
* Add vpi_mode_flag to track the mode of the
|
||||
* vpi engine. This is for error checking.
|
||||
*
|
||||
* Revision 1.34 2002/05/17 04:12:19 steve
|
||||
* Rewire vpiMemory and vpiMemoryWord handles to
|
||||
* support proper iteration of words, and the
|
||||
* vpiIndex value.
|
||||
*
|
||||
* Revision 1.33 2002/05/11 04:39:35 steve
|
||||
* Set and get memory words by string value.
|
||||
*
|
||||
* Revision 1.32 2002/05/03 15:44:11 steve
|
||||
* Add vpiModule iterator to vpiScope objects.
|
||||
*
|
||||
* Revision 1.31 2002/04/20 04:33:23 steve
|
||||
* Support specified times in cbReadOnlySync, and
|
||||
* add support for cbReadWriteSync.
|
||||
* Keep simulation time in a 64bit number.
|
||||
*/
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_signal.cc,v 1.55 2003/04/12 18:56:57 steve Exp $"
|
||||
#ident "$Id: vpi_signal.cc,v 1.56 2003/05/02 04:29:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -27,7 +27,9 @@
|
|||
|
||||
# include "vpi_priv.h"
|
||||
# include "functor.h"
|
||||
# include "schedule.h"
|
||||
# include "statistics.h"
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
|
|
@ -466,11 +468,16 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
|
|||
*/
|
||||
|
||||
static void functor_poke(struct __vpiSignal*rfp, unsigned idx,
|
||||
unsigned val, unsigned str)
|
||||
unsigned val, unsigned str, unsigned long dly =0)
|
||||
{
|
||||
vvp_ipoint_t ptr = vvp_fvector_get(rfp->bits,idx);
|
||||
functor_t fu = functor_index(ptr);
|
||||
fu->put_ostr(val, str, true);
|
||||
|
||||
if (dly > 0) {
|
||||
schedule_assign(ptr, val, dly);
|
||||
} else {
|
||||
functor_t fu = functor_index(ptr);
|
||||
fu->put_ostr(val, str, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void signal_put_stringval(struct __vpiSignal*rfp, unsigned wid,
|
||||
|
|
@ -508,14 +515,42 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
{
|
||||
unsigned wid;
|
||||
struct __vpiSignal*rfp;
|
||||
unsigned long dly = 0;
|
||||
|
||||
assert((ref->vpi_type->type_code==vpiNet)
|
||||
|| (ref->vpi_type->type_code==vpiReg));
|
||||
|
||||
rfp = (struct __vpiSignal*)ref;
|
||||
|
||||
/* XXXX delays are not yet supported. */
|
||||
assert(flags == vpiNoDelay);
|
||||
switch (flags) {
|
||||
case vpiNoDelay:
|
||||
dly = 0;
|
||||
break;
|
||||
|
||||
case vpiPureTransportDelay:
|
||||
switch (when->type) {
|
||||
case vpiScaledRealTime:
|
||||
dly = (unsigned)(when->real *
|
||||
(pow(10,
|
||||
vpip_time_units_from_handle(ref) -
|
||||
vpip_get_time_precision())));
|
||||
break;
|
||||
case vpiSimTime:
|
||||
assert (when->high == 0); // Only 32 bit delays for now
|
||||
dly = when->low;
|
||||
break;
|
||||
default:
|
||||
dly = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "signal_put_value: delay type %u not implemented.",
|
||||
flags);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
wid = (rfp->msb >= rfp->lsb)
|
||||
? (rfp->msb - rfp->lsb + 1)
|
||||
|
|
@ -532,7 +567,7 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
|
||||
long val = vp->value.integer;
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
functor_poke(rfp, idx, val&1, (val&1)? St1 : St0);
|
||||
functor_poke(rfp, idx, val&1, (val&1)? St1 : St0, dly);
|
||||
val >>= 1;
|
||||
}
|
||||
break;
|
||||
|
|
@ -541,16 +576,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
case vpiScalarVal:
|
||||
switch (vp->value.scalar) {
|
||||
case vpi0:
|
||||
functor_poke(rfp, 0, 0, St0);
|
||||
functor_poke(rfp, 0, 0, St0, dly);
|
||||
break;
|
||||
case vpi1:
|
||||
functor_poke(rfp, 0, 1, St1);
|
||||
functor_poke(rfp, 0, 1, St1, dly);
|
||||
break;
|
||||
case vpiX:
|
||||
functor_poke(rfp, 0, 2, StX);
|
||||
functor_poke(rfp, 0, 2, StX, dly);
|
||||
break;
|
||||
case vpiZ:
|
||||
functor_poke(rfp, 0, 3, HiZ);
|
||||
functor_poke(rfp, 0, 3, HiZ, dly);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -566,16 +601,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
int bit = (aval&1) | ((bval<<1)&2);
|
||||
switch (bit) {
|
||||
case 0: /* zero */
|
||||
functor_poke(rfp,idx, 0, St0);
|
||||
functor_poke(rfp,idx, 0, St0, dly);
|
||||
break;
|
||||
case 1: /* one */
|
||||
functor_poke(rfp,idx, 1, St1);
|
||||
functor_poke(rfp,idx, 1, St1, dly);
|
||||
break;
|
||||
case 2: /* z */
|
||||
functor_poke(rfp,idx, 3, HiZ);
|
||||
functor_poke(rfp,idx, 3, HiZ, dly);
|
||||
break;
|
||||
case 3: /* x */
|
||||
functor_poke(rfp,idx, 2, StX);
|
||||
functor_poke(rfp,idx, 2, StX, dly);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -592,16 +627,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
|
||||
switch (val) {
|
||||
case 0: /* zero */
|
||||
functor_poke(rfp,idx, 0, St0);
|
||||
functor_poke(rfp,idx, 0, St0, dly);
|
||||
break;
|
||||
case 1: /* one */
|
||||
functor_poke(rfp,idx, 1, St1);
|
||||
functor_poke(rfp,idx, 1, St1, dly);
|
||||
break;
|
||||
case 2: /* x */
|
||||
functor_poke(rfp,idx, 2, StX);
|
||||
functor_poke(rfp,idx, 2, StX, dly);
|
||||
break;
|
||||
case 3: /* z */
|
||||
functor_poke(rfp,idx, 3, HiZ);
|
||||
functor_poke(rfp,idx, 3, HiZ, dly);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -621,16 +656,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
|
||||
switch (val) {
|
||||
case 0: /* zero */
|
||||
functor_poke(rfp,idx, 0, St0);
|
||||
functor_poke(rfp,idx, 0, St0, dly);
|
||||
break;
|
||||
case 1: /* one */
|
||||
functor_poke(rfp,idx, 1, St1);
|
||||
functor_poke(rfp,idx, 1, St1, dly);
|
||||
break;
|
||||
case 2: /* x */
|
||||
functor_poke(rfp,idx, 2, StX);
|
||||
functor_poke(rfp,idx, 2, StX, dly);
|
||||
break;
|
||||
case 3: /* z */
|
||||
functor_poke(rfp,idx, 3, HiZ);
|
||||
functor_poke(rfp,idx, 3, HiZ, dly);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -650,16 +685,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
|
||||
switch (val) {
|
||||
case 0: /* zero */
|
||||
functor_poke(rfp,idx, 0, St0);
|
||||
functor_poke(rfp,idx, 0, St0, dly);
|
||||
break;
|
||||
case 1: /* one */
|
||||
functor_poke(rfp,idx, 1, St1);
|
||||
functor_poke(rfp,idx, 1, St1, dly);
|
||||
break;
|
||||
case 2: /* x */
|
||||
functor_poke(rfp,idx, 2, StX);
|
||||
functor_poke(rfp,idx, 2, StX, dly);
|
||||
break;
|
||||
case 3: /* z */
|
||||
functor_poke(rfp,idx, 3, HiZ);
|
||||
functor_poke(rfp,idx, 3, HiZ, dly);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -676,16 +711,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
|
||||
switch (bits[idx]) {
|
||||
case 0: /* zero */
|
||||
functor_poke(rfp,idx, 0, St0);
|
||||
functor_poke(rfp,idx, 0, St0, dly);
|
||||
break;
|
||||
case 1: /* one */
|
||||
functor_poke(rfp,idx, 1, St1);
|
||||
functor_poke(rfp,idx, 1, St1, dly);
|
||||
break;
|
||||
case 2: /* x */
|
||||
functor_poke(rfp,idx, 2, StX);
|
||||
functor_poke(rfp,idx, 2, StX, dly);
|
||||
break;
|
||||
case 3: /* z */
|
||||
functor_poke(rfp,idx, 3, HiZ);
|
||||
functor_poke(rfp,idx, 3, HiZ, dly);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -695,6 +730,7 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
|
|||
}
|
||||
|
||||
case vpiStringVal:
|
||||
assert(dly == 0);
|
||||
signal_put_stringval(rfp, wid, vp->value.str);
|
||||
break;
|
||||
|
||||
|
|
@ -799,6 +835,9 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
|
|||
|
||||
/*
|
||||
* $Log: vpi_signal.cc,v $
|
||||
* Revision 1.56 2003/05/02 04:29:57 steve
|
||||
* Add put_value with transport delay.
|
||||
*
|
||||
* Revision 1.55 2003/04/12 18:56:57 steve
|
||||
* Add vpoiScalarVal support for signals.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue