Support put of vpiStringVal to signals.

This commit is contained in:
steve 2002-11-25 23:33:45 +00:00
parent 2001903c89
commit ef55086543
1 changed files with 46 additions and 4 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_signal.cc,v 1.49 2002/09/11 16:06:57 steve Exp $" #ident "$Id: vpi_signal.cc,v 1.50 2002/11/25 23:33:45 steve Exp $"
#endif #endif
/* /*
@ -428,9 +428,10 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
} }
default: default:
fprintf(stderr, "vvp internal error: signal_get_value: " fprintf(stderr, "vvp internal error: get_value: "
"value type %u not implemented.\n", vp->format); "value type %u not implemented."
" Signal is %s in scope %s\n",
vp->format, rfp->name, rfp->scope->name);
assert(0); assert(0);
} }
} }
@ -450,6 +451,36 @@ static void functor_poke(struct __vpiSignal*rfp, unsigned idx,
fu->put_ostr(val, str, true); fu->put_ostr(val, str, true);
} }
static void signal_put_stringval(struct __vpiSignal*rfp, unsigned wid,
const char*str)
{
unsigned idx;
const char*cp;
cp = str + strlen(str);
idx = 0;
while ((idx < wid) && (cp > str)) {
unsigned byte = *--cp;
int bit;
for (bit = 0 ; bit < 8 ; bit += 1) {
if (byte & 1)
functor_poke(rfp, idx, 1, St1);
else
functor_poke(rfp, idx, 0, St0);
byte >>= 1;
idx += 1;
}
}
while (idx < wid) {
functor_poke(rfp, 0, 0, St0);
idx += 1;
}
}
static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp, static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
p_vpi_time when, int flags) p_vpi_time when, int flags)
{ {
@ -641,7 +672,15 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
break; break;
} }
case vpiStringVal:
signal_put_stringval(rfp, wid, vp->value.str);
break;
default: default:
fprintf(stderr, "vvp internal error: put_value: "
"value type %u not implemented."
" Signal is %s in scope %s\n",
vp->format, rfp->name, rfp->scope->name);
assert(0); assert(0);
} }
@ -722,6 +761,9 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
/* /*
* $Log: vpi_signal.cc,v $ * $Log: vpi_signal.cc,v $
* Revision 1.50 2002/11/25 23:33:45 steve
* Support put of vpiStringVal to signals.
*
* Revision 1.49 2002/09/11 16:06:57 steve * Revision 1.49 2002/09/11 16:06:57 steve
* Fix wrecked rbuf in vpi_get_str of signals and memories. * Fix wrecked rbuf in vpi_get_str of signals and memories.
* *