diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index a1bf24e22..183c49fc3 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ident "$Id: vvp_net.cc,v 1.1 2004/12/11 02:31:30 steve Exp $" +#ident "$Id: vvp_net.cc,v 1.2 2004/12/15 17:16:08 steve Exp $" # include "vvp_net.h" # include @@ -249,6 +249,7 @@ vvp_fun_signal::vvp_fun_signal(unsigned wid) { vpi_callbacks = 0; continuous_assign_active_ = false; + force_active_ = false; } /* @@ -273,7 +274,10 @@ void vvp_fun_signal::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit) break; case 2: // Force value - assert(0); + force_active_ = true; + force_ = bit; + vvp_send_vec4(ptr.ptr()->out, force_); + run_vpi_callbacks(); break; default: @@ -287,6 +291,17 @@ void vvp_fun_signal::deassign() continuous_assign_active_ = false; } +void vvp_fun_signal::release(vvp_net_ptr_t ptr, bool net) +{ + force_active_ = false; + if (net) { + vvp_send_vec4(ptr.ptr()->out, bits_); + run_vpi_callbacks(); + } else { + bits_ = force_; + } +} + /* * The signal functor takes commands as long values to port-3. This * method interprets those commands. @@ -299,6 +314,12 @@ void vvp_fun_signal::recv_long(vvp_net_ptr_t ptr, long bit) case 1: // deassign command deassign(); break; + case 2: // release/net + release(ptr, true); + break; + case 3: // release/reg + release(ptr, false); + break; default: assert(0); break; @@ -313,7 +334,10 @@ void vvp_fun_signal::recv_long(vvp_net_ptr_t ptr, long bit) vvp_bit4_t vvp_fun_signal::value(unsigned idx) const { - return bits_.value(idx); + if (force_active_) + return force_.value(idx); + else + return bits_.value(idx); } /* **** vvp_scaler_t methods **** */ @@ -485,6 +509,9 @@ vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b) /* * $Log: vvp_net.cc,v $ + * Revision 1.2 2004/12/15 17:16:08 steve + * Add basic force/release capabilities. + * * Revision 1.1 2004/12/11 02:31:30 steve * Rework of internals to carry vectors through nexus instead * of single bits. Make the ivl, tgt-vvp and vvp initial changes diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index ea4531987..4162cfc8d 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ident "$Id: vvp_net.h,v 1.1 2004/12/11 02:31:30 steve Exp $" +#ident "$Id: vvp_net.h,v 1.2 2004/12/15 17:16:08 steve Exp $" # include @@ -348,8 +348,8 @@ class vvp_fun_part : public vvp_net_fun_t { /* vvp_fun_signal * This node is the place holder in a vvp network for signals, - * including nets for various sort. The output from a signal is always - * a vector5, use drivers if the context needs vector8 values. + * including nets of various sort. The output from a signal is always + * a vector4, use drivers if the context needs vector8 values. * * If the signal is a net (i.e. a wire or tri) then this node will * have an input that is the data source. The data source will connect @@ -360,7 +360,7 @@ class vvp_fun_part : public vvp_net_fun_t { * %assign statements will write through port-0 * * In any case, behavioral code is able to read the value that this - * node last propagated, by using the size(). That is important + * node last propagated, by using the value() method. That is important * functionality of this node. * * Continuous assignments are made through port-1. When a value is @@ -369,6 +369,32 @@ class vvp_fun_part : public vvp_net_fun_t { * off again. Writing into this port can be done in behavioral code * using the %cassign/v instruction, or can be done by the network by * hooking the output of a vvp_net_t to this port. + * + * Force assignments are made through port-2. When a value is written + * here, force mode is activated. In force mode, port-0 data (or + * port-1 data if in continuous assign mode) is tracked but not + * propagated. The force value is propagated and is what is readable + * through the value method. + * + * Port-3 is a command port, intended for use by procedural + * instructions. The client must write long values to this port to + * invoke the command of interest. The command values are: + * + * 1 -- deassign + * The deassign command takes the node out of continuous + * assignment mode. The output value is unchanged, and force + * mode, if active, remains in effect. + * + * 2 -- release/net + * The release/net command takes the node out of force mode, + * and propagates the tracked port-0 value to the signal + * output. This acts like a release of a net signal. + * + * 3 -- release/reg + * The release/reg command is similar to the release/net + * command, but the port-0 value is not propagated. Changes + * to port-0 (or port-1 if continuous assing is active) will + * propagate starting at the next input change. */ class vvp_fun_signal : public vvp_net_fun_t { @@ -384,6 +410,7 @@ class vvp_fun_signal : public vvp_net_fun_t { // Commands void deassign(); + void release(vvp_net_ptr_t port, bool net); public: struct __vpiCallback*vpi_callbacks; @@ -392,12 +419,18 @@ class vvp_fun_signal : public vvp_net_fun_t { vvp_vector4_t bits_; bool continuous_assign_active_; + vvp_vector4_t force_; + bool force_active_; + private: void run_vpi_callbacks(); }; /* * $Log: vvp_net.h,v $ + * Revision 1.2 2004/12/15 17:16:08 steve + * Add basic force/release capabilities. + * * Revision 1.1 2004/12/11 02:31:30 steve * Rework of internals to carry vectors through nexus instead * of single bits. Make the ivl, tgt-vvp and vvp initial changes