diff --git a/vvp/vpi_bit.cc b/vvp/vpi_bit.cc index b6585d3b1..de26216fb 100644 --- a/vvp/vpi_bit.cc +++ b/vvp/vpi_bit.cc @@ -97,8 +97,6 @@ static int bit_get(int code, vpiHandle ref) case vpiVector: // A bit is not a vector return 0; -// FIXME: Do we need a _vpiFromThr or _vpiNexusID case? - default: fprintf(stderr, "VPI error: unknown bit_get property %d.\n", 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); assert(rfp); - (void) vp; - (void) flags; - fprintf(stderr, "Sorry: vpi_put_value() for %s type %s is not " - "implemented\n", vpi_get_str(vpiFullName, ref), - vpi_get_str(vpiType, ref)); + struct __vpiSignal*parent = rfp->get_parent(); + assert(parent); - // FIXME: Put the value to the net or reg bit. - - return ref; + return parent->put_bit_value(rfp, vp, flags); } @@ -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) { 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? //{ return bit_iterate(code, this); } diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 44ed61ab8..301b8989c 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -346,6 +346,7 @@ struct __vpiSignal : public __vpiHandle { unsigned width() const; vpiHandle get_index(int index); 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(); struct __vpiBit*bits; diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index ea85aef57..7c707223d 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -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(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) { struct __vpiSignal*rfp = dynamic_cast<__vpiSignal*>(ref);