Support delayed/non-blocking assignment to reals and others.

This commit is contained in:
steve 2004-05-19 03:26:24 +00:00
parent 896f1b0de1
commit a7ae8adf9b
11 changed files with 150 additions and 93 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: codes.h,v 1.64 2003/07/03 20:03:36 steve Exp $"
#ident "$Id: codes.h,v 1.65 2004/05/19 03:26:24 steve Exp $"
#endif
@ -43,6 +43,7 @@ extern bool of_ASSIGN(vthread_t thr, vvp_code_t code);
extern bool of_ASSIGN_D(vthread_t thr, vvp_code_t code);
extern bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t code);
extern bool of_ASSIGN_V0(vthread_t thr, vvp_code_t code);
extern bool of_ASSIGN_WR(vthread_t thr, vvp_code_t code);
extern bool of_ASSIGN_X0(vthread_t thr, vvp_code_t code);
extern bool of_BLEND(vthread_t thr, vvp_code_t code);
extern bool of_BREAKPOINT(vthread_t thr, vvp_code_t code);
@ -168,6 +169,9 @@ extern vvp_code_t codespace_null(void);
/*
* $Log: codes.h,v $
* Revision 1.65 2004/05/19 03:26:24 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.64 2003/07/03 20:03:36 steve
* Remove the vvp_cpoint_t indirect code pointer.
*

View File

@ -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.170 2003/09/04 20:26:31 steve Exp $"
#ident "$Id: compile.cc,v 1.171 2004/05/19 03:26:24 steve Exp $"
#endif
# include "arith.h"
@ -92,6 +92,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%assign/d", of_ASSIGN_D, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%assign/m",of_ASSIGN_MEM,3,{OA_MEM_PTR,OA_BIT1, OA_BIT2} },
{ "%assign/v0",of_ASSIGN_V0,3,{OA_FUNC_PTR,OA_BIT1, OA_BIT2} },
{ "%assign/wr",of_ASSIGN_WR,3,{OA_VPI_PTR,OA_BIT1, OA_BIT2} },
{ "%assign/x0",of_ASSIGN_X0,3,{OA_FUNC_PTR,OA_BIT1, OA_BIT2} },
{ "%blend", of_BLEND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%breakpoint", of_BREAKPOINT, 0, {OA_NONE, OA_NONE, OA_NONE} },
@ -1547,6 +1548,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
/*
* $Log: compile.cc,v $
* Revision 1.171 2004/05/19 03:26:24 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.170 2003/09/04 20:26:31 steve
* Add $push flag for threads.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com)
*
* $Id: opcodes.txt,v 1.53 2003/06/18 03:55:19 steve Exp $
* $Id: opcodes.txt,v 1.54 2004/05/19 03:26:24 steve Exp $
*/
@ -82,6 +82,11 @@ by index register 3. Bit address zero is the LSB of the first memory
word.
* %assign/wr <vpi-label>, <delay>, <index>
This instruction causes a non-blocking assign of the indexed value to
the real object addressed by the <vpi-label> label.
* %assign/x0 <var-label>, <delay>, <bit>
This does a non-blocking assignment to a functor, similar to the

View File

@ -27,7 +27,7 @@
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_memory.cc,v 1.22 2003/02/09 23:33:26 steve Exp $"
#ident "$Id: vpi_memory.cc,v 1.23 2004/05/19 03:30:46 steve Exp $"
#endif
# include "vpi_priv.h"
@ -233,8 +233,7 @@ static int memory_word_get(int code, vpiHandle ref)
}
}
static vpiHandle memory_word_put(vpiHandle ref, p_vpi_value val,
p_vpi_time tim, int flags)
static vpiHandle memory_word_put(vpiHandle ref, p_vpi_value val)
{
struct __vpiMemoryWord*rfp = (struct __vpiMemoryWord*)ref;
assert(ref->vpi_type->type_code==vpiMemoryWord);
@ -586,6 +585,9 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
/*
* $Log: vpi_memory.cc,v $
* Revision 1.23 2004/05/19 03:30:46 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.22 2003/02/09 23:33:26 steve
* Spelling fixes.
*

View File

@ -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.45 2004/02/18 17:52:00 steve Exp $"
#ident "$Id: vpi_priv.cc,v 1.46 2004/05/19 03:26:24 steve Exp $"
#endif
# include "vpi_priv.h"
@ -391,14 +391,55 @@ void vpi_get_value(vpiHandle expr, s_vpi_value*vp)
vp->format = vpiSuppressVal;
}
struct vpip_put_value_event : vvp_gen_event_s {
vpiHandle handle;
s_vpi_value value;
};
static void vpip_put_value_callback(vvp_gen_event_t eobj, unsigned char)
{
vpip_put_value_event*put = (vpip_put_value_event*)eobj;
put->handle->vpi_type->vpi_put_value_ (put->handle, &put->value);
}
vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
s_vpi_time*tp, PLI_INT32 flags)
s_vpi_time*when, PLI_INT32 flags)
{
assert(obj);
if (obj->vpi_type->vpi_put_value_)
return (obj->vpi_type->vpi_put_value_)(obj, vp, tp, flags);
else
if (obj->vpi_type->vpi_put_value_ == 0)
return 0;
if (flags != vpiNoDelay) {
vvp_time64_t dly;
switch (when->type) {
case vpiScaledRealTime:
dly = (vvp_time64_t)(when->real *
(pow(10,
vpip_time_units_from_handle(obj) -
vpip_get_time_precision())));
break;
case vpiSimTime:
dly = vpip_timestruct_to_time(when);
break;
default:
dly = 0;
break;
}
vpip_put_value_event*put = new vpip_put_value_event;
put->handle = obj;
put->value = *vp;
put->run = &vpip_put_value_callback;
schedule_generic(put, 0, dly, false);
return 0;
}
(obj->vpi_type->vpi_put_value_)(obj, vp);
return 0;
}
vpiHandle vpi_handle(PLI_INT32 type, vpiHandle ref)
@ -646,6 +687,9 @@ extern "C" void vpi_control(PLI_INT32 operation, ...)
/*
* $Log: vpi_priv.cc,v $
* Revision 1.46 2004/05/19 03:26:24 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.45 2004/02/18 17:52:00 steve
* PRototypes match the standard.
*

View File

@ -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.56 2003/06/17 19:17:42 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.57 2004/05/19 03:26:24 steve Exp $"
#endif
# include "vpi_user.h"
@ -74,7 +74,7 @@ struct __vpirt {
int (*vpi_get_)(int, vpiHandle);
char* (*vpi_get_str_)(int, vpiHandle);
void (*vpi_get_value_)(vpiHandle, p_vpi_value);
vpiHandle (*vpi_put_value_)(vpiHandle, p_vpi_value, p_vpi_time, int);
vpiHandle (*vpi_put_value_)(vpiHandle, p_vpi_value);
/* These methods follow references. */
vpiHandle (*handle_)(int, vpiHandle);
@ -418,6 +418,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
/*
* $Log: vpi_priv.h,v $
* Revision 1.57 2004/05/19 03:26:24 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.56 2003/06/17 19:17:42 steve
* Remove short int restrictions from vvp opcodes.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_real.cc,v 1.8 2003/03/13 04:59:21 steve Exp $"
#ident "$Id: vpi_real.cc,v 1.9 2004/05/19 03:26:25 steve Exp $"
#endif
# include "vpi_priv.h"
@ -119,8 +119,7 @@ static void real_var_get_value(vpiHandle ref, s_vpi_value*vp)
}
}
static vpiHandle real_var_put_value(vpiHandle ref, p_vpi_value vp,
p_vpi_time, int)
static vpiHandle real_var_put_value(vpiHandle ref, p_vpi_value vp)
{
assert(ref->vpi_type->type_code == vpiRealVar);
@ -179,6 +178,9 @@ vpiHandle vpip_make_real_var(const char*name)
/*
* $Log: vpi_real.cc,v $
* Revision 1.9 2004/05/19 03:26:25 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.8 2003/03/13 04:59:21 steve
* Use rbufs instead of static buffers.
*

View File

@ -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.61 2004/03/09 03:11:02 steve Exp $"
#ident "$Id: vpi_signal.cc,v 1.62 2004/05/19 03:26:25 steve Exp $"
#endif
/*
@ -534,48 +534,16 @@ static void signal_put_stringval(struct __vpiSignal*rfp, unsigned wid,
}
}
static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
p_vpi_time when, int flags)
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;
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)
: (rfp->lsb - rfp->msb + 1);
@ -591,7 +559,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, dly);
functor_poke(rfp, idx, val&1, (val&1)? St1 : St0, 0);
val >>= 1;
}
break;
@ -600,16 +568,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, dly);
functor_poke(rfp, 0, 0, St0, 0);
break;
case vpi1:
functor_poke(rfp, 0, 1, St1, dly);
functor_poke(rfp, 0, 1, St1, 0);
break;
case vpiX:
functor_poke(rfp, 0, 2, StX, dly);
functor_poke(rfp, 0, 2, StX, 0);
break;
case vpiZ:
functor_poke(rfp, 0, 3, HiZ, dly);
functor_poke(rfp, 0, 3, HiZ, 0);
break;
default:
assert(0);
@ -625,16 +593,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, dly);
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, dly);
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* z */
functor_poke(rfp,idx, 3, HiZ, dly);
functor_poke(rfp,idx, 3, HiZ, 0);
break;
case 3: /* x */
functor_poke(rfp,idx, 2, StX, dly);
functor_poke(rfp,idx, 2, StX, 0);
break;
}
}
@ -651,16 +619,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
switch (val) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, dly);
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, dly);
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* x */
functor_poke(rfp,idx, 2, StX, dly);
functor_poke(rfp,idx, 2, StX, 0);
break;
case 3: /* z */
functor_poke(rfp,idx, 3, HiZ, dly);
functor_poke(rfp,idx, 3, HiZ, 0);
break;
}
}
@ -680,16 +648,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
switch (val) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, dly);
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, dly);
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* x */
functor_poke(rfp,idx, 2, StX, dly);
functor_poke(rfp,idx, 2, StX, 0);
break;
case 3: /* z */
functor_poke(rfp,idx, 3, HiZ, dly);
functor_poke(rfp,idx, 3, HiZ, 0);
break;
}
}
@ -709,16 +677,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
switch (val) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, dly);
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, dly);
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* x */
functor_poke(rfp,idx, 2, StX, dly);
functor_poke(rfp,idx, 2, StX, 0);
break;
case 3: /* z */
functor_poke(rfp,idx, 3, HiZ, dly);
functor_poke(rfp,idx, 3, HiZ, 0);
break;
}
}
@ -735,16 +703,16 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
switch (bits[idx]) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, dly);
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, dly);
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* x */
functor_poke(rfp,idx, 2, StX, dly);
functor_poke(rfp,idx, 2, StX, 0);
break;
case 3: /* z */
functor_poke(rfp,idx, 3, HiZ, dly);
functor_poke(rfp,idx, 3, HiZ, 0);
break;
}
}
@ -754,7 +722,6 @@ 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;
@ -859,6 +826,9 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
/*
* $Log: vpi_signal.cc,v $
* Revision 1.62 2004/05/19 03:26:25 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.61 2004/03/09 03:11:02 steve
* Get vpiModule of signals.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_tasks.cc,v 1.26 2004/02/18 02:51:59 steve Exp $"
#ident "$Id: vpi_tasks.cc,v 1.27 2004/05/19 03:30:46 steve Exp $"
#endif
/*
@ -141,16 +141,12 @@ static const struct __vpirt vpip_systask_rt = {
* bits and set into the thread space bits that were selected at
* compile time.
*/
static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value vp,
p_vpi_time t, int flags)
static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value vp)
{
assert(ref->vpi_type->type_code == vpiSysFuncCall);
struct __vpiSysTaskCall*rfp = (struct __vpiSysTaskCall*)ref;
/* delays are not allowed. */
assert(flags == vpiNoDelay);
assert(rfp->vbit >= 4);
switch (vp->format) {
@ -242,15 +238,12 @@ static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value vp,
return 0;
}
static vpiHandle sysfunc_put_real_value(vpiHandle ref, p_vpi_value vp,
p_vpi_time t, int flags)
static vpiHandle sysfunc_put_real_value(vpiHandle ref, p_vpi_value vp)
{
assert(ref->vpi_type->type_code == vpiSysFuncCall);
struct __vpiSysTaskCall*rfp = (struct __vpiSysTaskCall*)ref;
/* delays are not allowed. */
assert(flags == vpiNoDelay);
/* Make sure this is a real valued function. */
assert(rfp->vwid == -vpiRealConst);
@ -487,6 +480,9 @@ void* vpi_get_userdata(vpiHandle ref)
/*
* $Log: vpi_tasks.cc,v $
* Revision 1.27 2004/05/19 03:30:46 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.26 2004/02/18 02:51:59 steve
* Fix type mismatches of various VPI functions.
*

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_vthr_vector.cc,v 1.19 2004/02/20 01:52:25 steve Exp $"
#ident "$Id: vpi_vthr_vector.cc,v 1.20 2004/05/19 03:30:46 steve Exp $"
#endif
/*
@ -302,17 +302,13 @@ static void vthr_vec_get_value(vpiHandle ref, s_vpi_value*vp)
/*
* The put_value method writes the value into the vector.
*/
static vpiHandle vthr_vec_put_value(vpiHandle ref, s_vpi_value*vp,
p_vpi_time when, int flags)
static vpiHandle vthr_vec_put_value(vpiHandle ref, s_vpi_value*vp)
{
assert((ref->vpi_type->type_code==vpiNet)
|| (ref->vpi_type->type_code==vpiReg));
struct __vpiVThrVec*rfp = (struct __vpiVThrVec*)ref;
/* XXXX delays are not yet supported. */
assert(flags == vpiNoDelay);
unsigned wid = rfp->wid;
switch (vp->format) {
@ -524,6 +520,9 @@ vpiHandle vpip_make_vthr_word(unsigned base, const char*type)
/*
* $Log: vpi_vthr_vector.cc,v $
* Revision 1.20 2004/05/19 03:30:46 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.19 2004/02/20 01:52:25 steve
* vpiStringVal does not include leading nulls.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.cc,v 1.117 2003/11/10 20:19:32 steve Exp $"
#ident "$Id: vthread.cc,v 1.118 2004/05/19 03:26:25 steve Exp $"
#endif
# include "config.h"
@ -557,6 +557,31 @@ bool of_ASSIGN_V0(vthread_t thr, vvp_code_t cp)
return true;
}
/*
* This is %assign/wr <vpi-label>, <delay>, <index>
*
* This assigns (after a delay) a value to a real variable. Use the
* vpi_put_value function to do the assign, with the delay written
* into the vpiInertialDelay carrying the desired delay.
*/
bool of_ASSIGN_WR(vthread_t thr, vvp_code_t cp)
{
unsigned delay = cp->bit_idx[0];
s_vpi_time del;
del.type = vpiSimTime;
vpip_time_to_timestruct(&del, schedule_simtime() + delay);
struct __vpiHandle*tmp = cp->handle;
t_vpi_value val;
val.format = vpiRealVal;
val.value.real = thr->words[cp->bit_idx[1]].w_real;
vpi_put_value(tmp, &val, &del, vpiInertialDelay);
return true;
}
bool of_ASSIGN_X0(vthread_t thr, vvp_code_t cp)
{
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx[1]);
@ -2760,6 +2785,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.118 2004/05/19 03:26:25 steve
* Support delayed/non-blocking assignment to reals and others.
*
* Revision 1.117 2003/11/10 20:19:32 steve
* Include config.h
*