Documentation, and excessive inlines.

This commit is contained in:
steve 2002-08-07 00:54:20 +00:00
parent 693e9e5ad0
commit ea779ac7dd
3 changed files with 98 additions and 49 deletions

View File

@ -18,30 +18,37 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: force.cc,v 1.5 2002/03/17 03:23:11 steve Exp $"
#ident "$Id: force.cc,v 1.6 2002/08/07 00:54:20 steve Exp $"
#endif
# include "codes.h"
# include "force.h"
# include <stdio.h>
# include <assert.h>
inline bool functor_s::disable(vvp_ipoint_t ptr)
/*
* This functor method turns off the output of the functor by setting
* an inhibit flag. While this flag is set, the functor is not
* supposed to set its output or propagate values.
*/
bool functor_s::disable(vvp_ipoint_t ptr)
{
bool r = inhibit;
inhibit = 1;
return r;
}
inline bool functor_s::enable(vvp_ipoint_t ptr)
bool functor_s::enable(vvp_ipoint_t ptr)
{
bool r = inhibit;
inhibit = 0;
if (r) {
if (get_str() != get_ostr())
if (get_str() != get_ostr()) {
propagate(true);
else
} else {
assert(get() == get_oval());
}
}
return r;
}
@ -64,6 +71,9 @@ void force_functor_s::set(vvp_ipoint_t i, bool push,
static bool release_force(vvp_ipoint_t itgt, functor_t tgt)
{
// Given the ipointer to the target functor, look for a force
// functor that is saving this output value in its input
// 3. That is the functor that is forcing me.
vvp_ipoint_t *ref = &tgt->out;
while (*ref) {
functor_t fofu = functor_index(*ref);
@ -86,6 +96,12 @@ static bool release_force(vvp_ipoint_t itgt, functor_t tgt)
return false;
}
/*
* The %force instruction causes the referenced force functor[s] to
* interpose themselves in front of the precompiled target
* functors. The operand of the %force is the label of the force
* functor, and the width of the functor array.
*/
bool of_FORCE(vthread_t thr, vvp_code_t cp)
{
unsigned wid = cp->bit_idx[0];
@ -102,21 +118,37 @@ bool of_FORCE(vthread_t thr, vvp_code_t cp)
ff->active = 1;
// tgt is the functor who's output I plan to force. The
// compiler stored the target pointer is the out pointer
// of the force functor. (The out pointer is not
// otherwise used.)
vvp_ipoint_t itgt = fofu->out;
functor_t tgt = functor_index(itgt);
// This turns OFF the target functor's output
// driver. If it is already off, then detach the
// previous force before continuing.
if (tgt->disable(itgt))
release_force(itgt, tgt);
// Link the functor as the first functor driven by the
// target. This allows the functor to track the unforced
// drive value, and also aids in releasing the force.
fofu->port[3] = tgt->out;
tgt->out = ipoint_make(ifofu, 3);
// Set the value to cause the overridden functor to take
// on its forced value.
fofu->set(ifofu, false, fofu->get_oval(), fofu->get_ostr());
}
return true;
}
/*
* The %release instruction causes any force functors driving the
* target functor to be released.
*/
bool of_RELEASE(vthread_t thr, vvp_code_t cp)
{
vvp_ipoint_t itgt = cp->iptr;
@ -236,6 +268,9 @@ bool of_DEASSIGN(vthread_t thr, vvp_code_t cp)
/*
* $Log: force.cc,v $
* Revision 1.6 2002/08/07 00:54:20 steve
* Documentation, and excessive inlines.
*
* Revision 1.5 2002/03/17 03:23:11 steve
* Force the push flags to be explicit.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: functor.cc,v 1.39 2002/07/05 02:50:58 steve Exp $"
#ident "$Id: functor.cc,v 1.40 2002/08/07 00:54:20 steve Exp $"
#endif
# include "functor.h"
@ -30,6 +30,8 @@
# include <malloc.h>
#endif
# include <stdio.h>
/*
* Functors are created as the source design is read in. Each is
* assigned an ipoint_t address starting from 1. The design is
@ -138,6 +140,54 @@ functor_s::~functor_s()
{
}
/*
* This method sets the saved output value, bits and strength, then
* propagates that value to the connected inputs.
*/
void functor_s::propagate(unsigned val, unsigned str, bool push)
{
cval = val;
cstr = str;
vvp_ipoint_t idx = out;
while (idx) {
functor_t idxp = functor_index(idx);
idxp->set(idx, push, val, str);
idx = idxp->port[ipoint_port(idx)];
}
#if defined(WITH_DEBUG)
if (break_flag)
breakpoint();
#endif
}
void functor_s::put_ostr(unsigned val, unsigned str, bool push)
{
if (str != get_ostr() || val != get_oval()) {
unsigned char ooval = oval;
ostr = str;
oval = val;
/* If output is inhibited (by a .force functor) then
this is as far as we go. */
if (inhibit)
return;
unsigned del;
if (delay)
del = vvp_delay_get(delay, ooval, val);
else
del = 0;
if (push && del == 0) {
propagate(push);
}
else
schedule(del);
}
}
// Special infrastructure functor types
extra_outputs_functor_s::~extra_outputs_functor_s()
@ -203,6 +253,9 @@ void functor_s::debug_print(vvp_ipoint_t fnc)
/*
* $Log: functor.cc,v $
* Revision 1.40 2002/08/07 00:54:20 steve
* Documentation, and excessive inlines.
*
* Revision 1.39 2002/07/05 02:50:58 steve
* Remove the vpi object symbol table after compile.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: functor.h,v 1.46 2002/05/19 05:18:16 steve Exp $"
#ident "$Id: functor.h,v 1.47 2002/08/07 00:54:20 steve Exp $"
#endif
# include "pointers.h"
@ -219,53 +219,11 @@ inline void functor_s::put(vvp_ipoint_t ptr, unsigned val)
ival = (ival & imask) | ((val & 3) << (2*pp));
}
inline void functor_s::propagate(unsigned val, unsigned str, bool push)
{
cval = val;
cstr = str;
vvp_ipoint_t idx = out;
while (idx) {
functor_t idxp = functor_index(idx);
idxp->set(idx, push, val, str);
idx = idxp->port[ipoint_port(idx)];
}
#if defined(WITH_DEBUG)
if (break_flag)
breakpoint();
#endif
}
inline void functor_s::propagate(bool push)
{
propagate(get_oval(), get_ostr(), push);
}
inline void functor_s::put_ostr(unsigned val, unsigned str, bool push)
{
if (str != get_ostr() || val != get_oval()) {
unsigned char ooval = oval;
ostr = str;
oval = val;
if (inhibit)
return;
unsigned del;
if (delay)
del = vvp_delay_get(delay, ooval, val);
else
del = 0;
if (push && del == 0) {
propagate(push);
}
else
schedule(del);
}
}
inline void functor_s::put_oval(unsigned val, bool push)
{
unsigned char str;
@ -394,6 +352,9 @@ extern vvp_fvector_t vvp_fvector_continuous_new(unsigned size, vvp_ipoint_t p);
/*
* $Log: functor.h,v $
* Revision 1.47 2002/08/07 00:54:20 steve
* Documentation, and excessive inlines.
*
* Revision 1.46 2002/05/19 05:18:16 steve
* Add callbacks for vpiNamedEvent objects.
*