Add support for vpi_put_value for vpiBit

This commit is contained in:
Cary R 2020-05-31 10:48:44 -07:00
parent 7eb0efd424
commit 1fefa8eb1b
3 changed files with 31 additions and 10 deletions

View File

@ -97,8 +97,6 @@ static int bit_get(int code, vpiHandle ref)
case vpiVector: // A bit is not a vector case vpiVector: // A bit is not a vector
return 0; return 0;
// FIXME: Do we need a _vpiFromThr or _vpiNexusID case?
default: default:
fprintf(stderr, "VPI error: unknown bit_get property %d.\n", fprintf(stderr, "VPI error: unknown bit_get property %d.\n",
code); code);
@ -192,16 +190,11 @@ static vpiHandle bit_put_value(vpiHandle ref, s_vpi_value*vp, int flags)
{ {
struct __vpiBit*rfp = bit_from_handle(ref); struct __vpiBit*rfp = bit_from_handle(ref);
assert(rfp); assert(rfp);
(void) vp;
(void) flags;
fprintf(stderr, "Sorry: vpi_put_value() for %s type %s is not " struct __vpiSignal*parent = rfp->get_parent();
"implemented\n", vpi_get_str(vpiFullName, ref), assert(parent);
vpi_get_str(vpiType, ref));
// FIXME: Put the value to the net or reg bit. return parent->put_bit_value(rfp, vp, flags);
return ref;
} }
@ -231,6 +224,7 @@ vpiHandle __vpiBit::as_bit_t::vpi_put_value(p_vpi_value val, int flags)
vpiHandle __vpiBit::as_bit_t::vpi_handle(int code) vpiHandle __vpiBit::as_bit_t::vpi_handle(int code)
{ return bit_get_handle(code, this); } { return bit_get_handle(code, this); }
// FIXME: How are delayed put values handled?
//vpiHandle __vpiBit::as_bit_t::vpi_iterate(int code) // FIXME: Is this needed? //vpiHandle __vpiBit::as_bit_t::vpi_iterate(int code) // FIXME: Is this needed?
//{ return bit_iterate(code, this); } //{ return bit_iterate(code, this); }

View File

@ -346,6 +346,7 @@ struct __vpiSignal : public __vpiHandle {
unsigned width() const; unsigned width() const;
vpiHandle get_index(int index); vpiHandle get_index(int index);
void get_bit_value(struct __vpiBit*bit, p_vpi_value vp); void get_bit_value(struct __vpiBit*bit, p_vpi_value vp);
vpiHandle put_bit_value(struct __vpiBit*bit, p_vpi_value vp, int flags);
void make_bits(); void make_bits();
struct __vpiBit*bits; struct __vpiBit*bits;

View File

@ -780,6 +780,32 @@ void __vpiSignal::get_bit_value(struct __vpiBit*bit, p_vpi_value vp)
}; };
} }
vpiHandle __vpiSignal::put_bit_value(struct __vpiBit*bit, p_vpi_value vp, int flags)
{
unsigned index = bit->get_norm_index();
vvp_net_ptr_t dest(node, 0);
vvp_vector4_t val = vec4_from_vpi_value(vp, 1);
if ((flags == vpiForceFlag) || (flags == vpiReleaseFlag)) {
fprintf(stderr, "Sorry: vpi_put_value() for %s does not "
"currently support force/release.\n",
bit->as_bit.vpi_get_str(vpiFullName));
return NULL;
}
if ((get_type_code() == vpiNet) &&
!dynamic_cast<vvp_island_port*>(node->fun)) {
node->send_vec4_pv(val, index, 1, width(),
vthread_get_wt_context());
} else {
vvp_send_vec4_pv(dest, val, index, 1, width(),
vthread_get_wt_context());
}
// This is not a scheduled event so there is no event to return
return NULL;
}
static vpiHandle signal_index(int idx, vpiHandle ref) static vpiHandle signal_index(int idx, vpiHandle ref)
{ {
struct __vpiSignal*rfp = dynamic_cast<__vpiSignal*>(ref); struct __vpiSignal*rfp = dynamic_cast<__vpiSignal*>(ref);