diff --git a/vvp/array.cc b/vvp/array.cc index 1f11b64ce..78dde4c6d 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -998,7 +998,7 @@ void array_attach_word(vvp_array_t array, unsigned long addr, vpiHandle word) if (struct __vpiSignal*sig = vpip_signal_from_handle(word)) { vvp_net_t*net = sig->node; assert(net); - vvp_fun_signal_base*fun = dynamic_cast(net->fun); + vvp_vpi_callback*fun = dynamic_cast(net->fun); assert(fun); fun->attach_as_word(array, addr); sig->is_netarray = 1; @@ -1010,7 +1010,7 @@ void array_attach_word(vvp_array_t array, unsigned long addr, vpiHandle word) if (struct __vpiRealVar*sig = (struct __vpiRealVar*)word) { vvp_net_t*net = sig->net; assert(net); - vvp_fun_signal_base*fun = dynamic_cast(net->fun); + vvp_vpi_callback*fun = dynamic_cast(net->fun); assert(fun); fun->attach_as_word(array, addr); sig->is_netarray = 1; diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index ede9ed3f0..447c1a7b6 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -171,10 +171,10 @@ void vpip_real_value_change(struct __vpiCallback*cbh, { struct __vpiRealVar*rfp = (struct __vpiRealVar*)ref; - vvp_fun_signal_real*fun - = dynamic_cast(rfp->net->fun); + vvp_vpi_callback*obj = dynamic_cast(rfp->net->fil); + assert(obj); - fun->add_vpi_callback(cbh); + obj->add_vpi_callback(cbh); } vpiHandle vpip_make_real_var(const char*name, vvp_net_t*net) diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index a3c6ca6ff..68bed491a 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -757,8 +757,8 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp, int flags) value. Instead, issue a release "command" to the signal node to cause it to release a forced value. */ if (flags == vpiReleaseFlag) { - vvp_fun_signal_base*sig - = reinterpret_cast(rfp->node->fun); + vvp_net_fil_t*sig + = reinterpret_cast(rfp->node->fil); assert(sig); vvp_net_ptr_t ptr(rfp->node, 0); @@ -1284,12 +1284,12 @@ void vpip_part_select_value_change(struct __vpiCallback*cbh, vpiHandle ref) struct __vpiPV*obj = vpip_PV_from_handle(ref); assert(obj); - vvp_fun_signal_base*sig_fun; - sig_fun = dynamic_cast(obj->net->fun); - assert(sig_fun); + vvp_vpi_callback*sig_fil; + sig_fil = dynamic_cast(obj->net->fun); + assert(sig_fil); /* Attach the __vpiCallback object to the signal. */ - sig_fun->add_vpi_callback(cbh); + sig_fil->add_vpi_callback(cbh); } #ifdef CHECK_WITH_VALGRIND diff --git a/vvp/vvp_net_sig.cc b/vvp/vvp_net_sig.cc index b3bd59b60..50f0ef2fe 100644 --- a/vvp/vvp_net_sig.cc +++ b/vvp/vvp_net_sig.cc @@ -69,21 +69,24 @@ vvp_signal_value::~vvp_signal_value() { } +#if 0 const vvp_vector4_t* vvp_fun_signal4::filter_vec4(const vvp_vector4_t&val) { return filter_mask_(val, force4_, filter4_); } - +#endif +#if 0 const vvp_vector8_t* vvp_fun_signal8::filter_vec8(const vvp_vector8_t&val) { return filter_mask_(val, force8_, filter8_); } - +#endif +#if 0 bool vvp_fun_signal_real::filter_real(double&val) { return filter_mask_(val); } - +#endif unsigned vvp_fun_signal_real::filter_size() const { return size(); @@ -93,7 +96,7 @@ unsigned vvp_fun_signal4::filter_size() const { return value_size(); } - +#if 0 void vvp_fun_signal4::force_fil_vec4(const vvp_vector4_t&val, vvp_vector2_t mask) { force_mask(mask); @@ -109,7 +112,7 @@ void vvp_fun_signal4::force_fil_vec4(const vvp_vector4_t&val, vvp_vector2_t mask } } } - +#endif void vvp_fun_signal4::force_fil_vec8(const vvp_vector8_t&val, vvp_vector2_t mask) { assert(0); @@ -129,11 +132,13 @@ void vvp_net_t::force_vec4(const vvp_vector4_t&val, vvp_vector2_t mask) void vvp_fun_signal8::force_fil_vec4(const vvp_vector4_t&val, vvp_vector2_t mask) { - force_fil_vec8(vvp_vector8_t(val,6,6), mask); + assert(0 /* XXXX force_fil_vec8(vvp_vector8_t(val,6,6), mask); */); } void vvp_fun_signal8::force_fil_vec8(const vvp_vector8_t&val, vvp_vector2_t mask) { + assert(0); +#if 0 force_mask(mask); if (force8_.size() == 0) @@ -145,6 +150,7 @@ void vvp_fun_signal8::force_fil_vec8(const vvp_vector8_t&val, vvp_vector2_t mask force8_.set_bit(idx, val.value(idx)); } +#endif } void vvp_fun_signal8::force_fil_real(double val, vvp_vector2_t mask) @@ -173,8 +179,12 @@ void vvp_fun_signal_real::force_fil_vec8(const vvp_vector8_t&val, vvp_vector2_t void vvp_fun_signal_real::force_fil_real(double val, vvp_vector2_t mask) { +#if 0 force_mask(mask); force_real_ = val; +#else + assert(0); +#endif } void vvp_net_t::force_real(double val, vvp_vector2_t mask) @@ -185,7 +195,7 @@ void vvp_net_t::force_real(double val, vvp_vector2_t mask) sig->force_fil_real(val, mask); send_real(val, 0); } - +#if 0 vvp_bit4_t vvp_fun_signal4::filtered_value(const vvp_vector4_t&val, unsigned idx) const { if (test_force_mask(idx)) @@ -193,7 +203,8 @@ vvp_bit4_t vvp_fun_signal4::filtered_value(const vvp_vector4_t&val, unsigned idx else return val.value(idx); } - +#endif +#if 0 vvp_scalar_t vvp_fun_signal8::filtered_value(const vvp_vector8_t&val, unsigned idx) const { if (test_force_mask(idx)) @@ -201,7 +212,8 @@ vvp_scalar_t vvp_fun_signal8::filtered_value(const vvp_vector8_t&val, unsigned i else return val.value(idx); } - +#endif +#if 0 const vvp_vector4_t& vvp_fun_signal4::filtered_vec4(const vvp_vector4_t&val) const { if (test_force_mask_is_zero()) @@ -214,7 +226,8 @@ const vvp_vector4_t& vvp_fun_signal4::filtered_vec4(const vvp_vector4_t&val) con } return filter4_; } - +#endif +#if 0 const vvp_vector8_t& vvp_fun_signal8::filtered_vec8(const vvp_vector8_t&val) const { if (test_force_mask_is_zero()) @@ -227,7 +240,8 @@ const vvp_vector8_t& vvp_fun_signal8::filtered_vec8(const vvp_vector8_t&val) con } return filter8_; } - +#endif +#if 0 double vvp_fun_signal_real::filtered_real(double val) const { if (test_force_mask_is_zero()) @@ -235,7 +249,7 @@ double vvp_fun_signal_real::filtered_real(double val) const return force_real_; } - +#endif /* **** vvp_fun_signal methods **** */ vvp_fun_signal_base::vvp_fun_signal_base() @@ -273,6 +287,7 @@ void vvp_fun_signal4_sa::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit, any holes in the mask so we can set those bits. */ if (assign_mask_.size() == 0) { if (needs_init_ || !bits4_.eeq(bit)) { + assert(bit.size() == bits4_.size()); bits4_ = bit; needs_init_ = false; ptr.ptr()->send_vec4(bits4_, 0); @@ -384,6 +399,7 @@ void vvp_fun_signal_base::deassign_pv(unsigned base, unsigned wid) assign_mask_ = vvp_vector2_t(); } } +#if 0 void vvp_fun_signal4_sa::release(vvp_net_ptr_t ptr, bool net) { vvp_vector2_t mask (vvp_vector2_t::FILL1, bits4_.size()); @@ -393,7 +409,8 @@ void vvp_fun_signal4_sa::release(vvp_net_ptr_t ptr, bool net) bits4_ = filtered_vec4(bits4_); release_mask(mask); } - +#endif +#if 0 void vvp_fun_signal4_sa::release_pv(vvp_net_ptr_t ptr, bool net, unsigned base, unsigned wid) { @@ -406,7 +423,7 @@ void vvp_fun_signal4_sa::release_pv(vvp_net_ptr_t ptr, bool net, bits4_ = filtered_vec4(bits4_); release_mask(mask); } - +#endif unsigned vvp_fun_signal4_sa::value_size() const { return bits4_.size(); @@ -414,7 +431,7 @@ unsigned vvp_fun_signal4_sa::value_size() const vvp_bit4_t vvp_fun_signal4_sa::value(unsigned idx) const { - return filtered_value(bits4_, idx); + assert(0 /* XXXX return filtered_value(bits4_, idx); */); } vvp_scalar_t vvp_fun_signal4_sa::scalar_value(unsigned idx) const @@ -422,9 +439,14 @@ vvp_scalar_t vvp_fun_signal4_sa::scalar_value(unsigned idx) const return vvp_scalar_t(value(idx), 6, 6); } +vvp_vector4_t vvp_fun_signal4_sa::vec4_unfiltered_value() const +{ + return bits4_; +} + vvp_vector4_t vvp_fun_signal4_sa::vec4_value() const { - return filtered_vec4(bits4_); + assert(0 /* XXXX return filtered_vec4(bits4_); */); } vvp_fun_signal4_aa::vvp_fun_signal4_aa(unsigned wid, vvp_bit4_t init) @@ -535,6 +557,11 @@ vvp_vector4_t vvp_fun_signal4_aa::vec4_value() const return *bits4; } +vvp_vector4_t vvp_fun_signal4_aa::vec4_unfiltered_value() const +{ + return vec4_value(); +} + vvp_fun_signal8::vvp_fun_signal8(unsigned wid) : bits8_(wid) { @@ -607,7 +634,7 @@ void vvp_fun_signal8::recv_vec8_pv(vvp_net_ptr_t ptr, const vvp_vector8_t&bit, break; } } - +#if 0 void vvp_fun_signal8::release(vvp_net_ptr_t ptr, bool net) { vvp_vector2_t mask (vvp_vector2_t::FILL1, bits8_.size()); @@ -623,7 +650,8 @@ void vvp_fun_signal8::release(vvp_net_ptr_t ptr, bool net) release_mask(mask); } } - +#endif +#if 0 void vvp_fun_signal8::release_pv(vvp_net_ptr_t ptr, bool net, unsigned base, unsigned wid) { @@ -641,7 +669,7 @@ void vvp_fun_signal8::release_pv(vvp_net_ptr_t ptr, bool net, release_mask(mask); } } - +#endif unsigned vvp_fun_signal8::filter_size() const { return value_size(); @@ -654,17 +682,17 @@ unsigned vvp_fun_signal8::value_size() const vvp_bit4_t vvp_fun_signal8::value(unsigned idx) const { - return filtered_value(bits8_, idx).value(); + assert(0 /* XXXX return filtered_value(bits8_, idx).value(); */); } vvp_vector4_t vvp_fun_signal8::vec4_value() const { - return reduce4(filtered_vec8(bits8_)); + assert(0 /* XXXX return reduce4(filtered_vec8(bits8_)); */); } vvp_scalar_t vvp_fun_signal8::scalar_value(unsigned idx) const { - return filtered_value(bits8_, idx); + assert(0 /* XXXX return filtered_value(bits8_, idx); */); } @@ -685,7 +713,7 @@ vvp_fun_signal_real_sa::vvp_fun_signal_real_sa() double vvp_fun_signal_real_sa::real_value() const { - return filtered_real(bits_); + assert(0 /* XXXX return filtered_real(bits_); */); } void vvp_fun_signal_real_sa::recv_real(vvp_net_ptr_t ptr, double bit, @@ -714,7 +742,7 @@ void vvp_fun_signal_real_sa::recv_real(vvp_net_ptr_t ptr, double bit, break; } } - +#if 0 void vvp_fun_signal_real_sa::release(vvp_net_ptr_t ptr, bool net) { vvp_vector2_t mask (vvp_vector2_t::FILL1, 1); @@ -727,7 +755,7 @@ void vvp_fun_signal_real_sa::release(vvp_net_ptr_t ptr, bool net) release_mask(mask); } } - +#endif void vvp_fun_signal_real_sa::release_pv(vvp_net_ptr_t ptr, bool net, unsigned base, unsigned wid) { @@ -956,8 +984,11 @@ const vvp_vector4_t* vvp_wire_vec8::filter_vec4(const vvp_vector4_t&bit) const vvp_vector8_t* vvp_wire_vec8::filter_vec8(const vvp_vector8_t&bit) { - assert(0); - return 0; + // Keep track of the value being driven from this net, even if + // it is not ultimately what survives the force filter. + bits8_ = bit; + const vvp_vector8_t*tmp = filter_mask_(bit, force8_, filter8_); + return tmp; } unsigned vvp_wire_vec8::filter_size() const diff --git a/vvp/vvp_net_sig.h b/vvp/vvp_net_sig.h index d6f530671..ea5328ed5 100644 --- a/vvp/vvp_net_sig.h +++ b/vvp/vvp_net_sig.h @@ -65,7 +65,7 @@ using namespace std; */ -class vvp_fun_signal_base : public vvp_net_fun_t, public vvp_net_fil_t { +class vvp_fun_signal_base : public vvp_net_fun_t { public: vvp_fun_signal_base(); @@ -85,7 +85,6 @@ class vvp_fun_signal_base : public vvp_net_fun_t, public vvp_net_fil_t { vvp_vector2_t assign_mask_; protected: - // This is true until at least one propagation happens. bool needs_init_; }; @@ -111,6 +110,7 @@ class vvp_signal_value { */ class vvp_fun_signal_vec : public vvp_fun_signal_base, public vvp_signal_value { public: + virtual vvp_vector4_t vec4_unfiltered_value() const =0; unsigned size() const { return value_size(); } }; @@ -127,14 +127,13 @@ class vvp_fun_signal4 : public vvp_fun_signal_vec { void force_fil_vec8(const vvp_vector8_t&val, vvp_vector2_t mask); void force_fil_real(double val, vvp_vector2_t mask); const vvp_vector4_t* filter_vec4(const vvp_vector4_t&val); + // Test the value against the filter. vvp_bit4_t filtered_value(const vvp_vector4_t&val, unsigned idx) const; const vvp_vector4_t& filtered_vec4(const vvp_vector4_t&val) const; unsigned filter_size() const; private: - vvp_vector4_t force4_; - mutable vvp_vector4_t filter4_; }; /* @@ -161,6 +160,7 @@ class vvp_fun_signal4_sa : public vvp_fun_signal4 { vvp_bit4_t value(unsigned idx) const; vvp_scalar_t scalar_value(unsigned idx) const; vvp_vector4_t vec4_value() const; + vvp_vector4_t vec4_unfiltered_value() const; // Commands void release(vvp_net_ptr_t port, bool net); @@ -198,6 +198,7 @@ class vvp_fun_signal4_aa : public vvp_fun_signal4, public automatic_hooks_s { vvp_bit4_t value(unsigned idx) const; vvp_scalar_t scalar_value(unsigned idx) const; vvp_vector4_t vec4_value() const; + vvp_vector4_t vec4_unfiltered_value() const; // Commands void release(vvp_net_ptr_t port, bool net); @@ -421,6 +422,8 @@ class vvp_wire_vec8 : public vvp_wire_base { private: unsigned width_; vvp_vector8_t bits8_; + vvp_vector8_t force8_; // the value being forced + vvp_vector8_t filter8_; // scratch space for filter_mask_ function. }; #endif diff --git a/vvp/words.cc b/vvp/words.cc index 534ec7785..9983a9976 100644 --- a/vvp/words.cc +++ b/vvp/words.cc @@ -43,7 +43,7 @@ static void __compile_var_real(char*label, char*name, } vvp_net_t*net = new vvp_net_t; net->fun = fun; - net->fil = fun; + assert(0 /* XXXX */); // Need to create a net_fil_t! net->fil = fun; define_functor_symbol(label, net); @@ -87,6 +87,7 @@ static void __compile_var(char*label, char*name, unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1; vvp_fun_signal_vec*vsig; + vvp_wire_vec4*vfil = new vvp_wire_vec4(wid); if (vpip_peek_current_scope()->is_automatic) { vsig = new vvp_fun_signal4_aa(wid); } else { @@ -94,7 +95,7 @@ static void __compile_var(char*label, char*name, } vvp_net_t*node = new vvp_net_t; node->fun = vsig; - node->fil = vsig; + node->fil = vfil; define_functor_symbol(label, node); @@ -112,7 +113,7 @@ static void __compile_var(char*label, char*name, assert(!array); if (obj) vpip_attach_to_current_scope(obj); if (!vpip_peek_current_scope()->is_automatic) - schedule_init_vector(vvp_net_ptr_t(node,0), vsig->vec4_value()); + schedule_init_vector(vvp_net_ptr_t(node,0), vsig->vec4_unfiltered_value()); } // If this is an array word, then it does not have a name, and // it is attached to the addressed array. @@ -169,15 +170,21 @@ static void __compile_net(char*label, assert(argc == 1); vvp_net_t*node = vvp_net_lookup(argv[0].text); + if (node == 0) { + cerr << "Internal error: vvp_net_lookup fails: " + << argv[0].text << endl; + } assert(node); - vvp_wire_base*vsig = net8_flag - ? dynamic_cast(new vvp_wire_vec8(wid)) - : dynamic_cast(new vvp_wire_vec4(wid,BIT4_Z)); + vvp_wire_base*vsig = dynamic_cast(node->fil); - // Assume (for now) that there is only 1 filter per node. - assert(node->fil == 0); - node->fil = vsig; + if (vsig == 0) { + vsig = net8_flag + ? dynamic_cast(new vvp_wire_vec8(wid)) + : dynamic_cast(new vvp_wire_vec4(wid,BIT4_Z)); + + node->fil = vsig; + } vpiHandle obj = 0; if (! local_flag) { @@ -227,7 +234,7 @@ static void __compile_real(char*label, char*name, vvp_fun_signal_real*fun = new vvp_fun_signal_real_sa; net->fun = fun; - net->fil = fun; + assert(0 /* Need to create a vvp_net_fil_t object: net->fil = fun; */); /* Add the label into the functor symbol table. */ define_functor_symbol(label, net);