Cache calculated driven value.

This commit is contained in:
steve 2002-06-25 01:33:22 +00:00
parent 73cca6ec39
commit 9fc4e1eddd
8 changed files with 93 additions and 41 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: cprop.cc,v 1.36 2002/06/24 01:49:38 steve Exp $"
#ident "$Id: cprop.cc,v 1.37 2002/06/25 01:33:22 steve Exp $"
#endif
# include "config.h"
@ -65,7 +65,7 @@ void cprop_functor::lpm_add_sub(Design*des, NetAddSub*obj)
// adder. These will be eliminated later.
while ((obj->width() > 1)
&& obj->pin_DataA(0).nexus()->drivers_constant()
&& (driven_value(obj->pin_DataA(0)) == verinum::V0)) {
&& (obj->pin_DataA(0).nexus()->driven_value() == verinum::V0)) {
NetAddSub*tmp = 0;
tmp = new NetAddSub(obj->scope(), obj->name(), obj->width()-1);
@ -90,7 +90,7 @@ void cprop_functor::lpm_add_sub(Design*des, NetAddSub*obj)
// Now do the same thing on the B side.
while ((obj->width() > 1)
&& obj->pin_DataB(0).nexus()->drivers_constant()
&& (driven_value(obj->pin_DataB(0)) == verinum::V0)) {
&& (obj->pin_DataB(0).nexus()->driven_value() == verinum::V0)) {
NetAddSub*tmp = 0;
tmp = new NetAddSub(obj->scope(), obj->name(), obj->width()-1);
@ -164,8 +164,8 @@ void cprop_functor::lpm_compare_eq_(Design*des, NetCompare*obj)
continue;
if (! obj->pin_DataB(idx).nexus()->drivers_constant())
continue;
if (driven_value(obj->pin_DataA(idx)) ==
driven_value(obj->pin_DataB(idx)))
if (obj->pin_DataA(idx).nexus()->driven_value() ==
obj->pin_DataB(idx).nexus()->driven_value())
continue;
NetConst*zero = new NetConst(scope, obj->name(), verinum::V0);
@ -315,7 +315,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
continue;
}
if (driven_value(obj->pin(idx)) == verinum::V1) {
if (obj->pin(idx).nexus()->driven_value()==verinum::V1) {
obj->pin(idx).unlink();
top -= 1;
if (idx < top) {
@ -326,7 +326,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
continue;
}
if (driven_value(obj->pin(idx)) != verinum::V0) {
if (obj->pin(idx).nexus()->driven_value() != verinum::V0) {
idx += 1;
xs += 1;
continue;
@ -462,7 +462,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
continue;
}
if (driven_value(obj->pin(idx)) == verinum::V0) {
if (obj->pin(idx).nexus()->driven_value() == verinum::V0) {
obj->pin(idx).unlink();
top -= 1;
if (idx < top) {
@ -473,7 +473,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
continue;
}
if (driven_value(obj->pin(idx)) != verinum::V1) {
if (obj->pin(idx).nexus()->driven_value() != verinum::V1) {
idx += 1;
continue;
}
@ -593,7 +593,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
continue;
}
if (driven_value(obj->pin(idx)) == verinum::V0) {
if (obj->pin(idx).nexus()->driven_value() == verinum::V0) {
obj->pin(idx).unlink();
top -= 1;
if (idx < top) {
@ -623,7 +623,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
continue;
}
if (driven_value(obj->pin(idx)) == verinum::V1) {
if (obj->pin(idx).nexus()->driven_value() == verinum::V1) {
if (one == 0) {
one = idx;
ones += 1;
@ -684,7 +684,7 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
unsigned save;
if (! obj->pin(1).nexus()->drivers_constant())
save = 1;
else if (driven_value(obj->pin(1)) != verinum::V1)
else if (obj->pin(1).nexus()->driven_value() != verinum::V1)
save = 1;
else
save = 2;
@ -782,7 +782,7 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj)
break;
}
if (driven_value(obj->pin_Data(idx, 0)) != verinum::Vz) {
if (obj->pin_Data(idx, 0).nexus()->driven_value() != verinum::Vz) {
flag = false;
break;
}
@ -814,7 +814,7 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj)
break;
}
if (driven_value(obj->pin_Data(idx, 1)) != verinum::Vz) {
if (obj->pin_Data(idx, 1).nexus()->driven_value() != verinum::Vz) {
flag = false;
break;
}
@ -949,6 +949,9 @@ void cprop(Design*des)
/*
* $Log: cprop.cc,v $
* Revision 1.37 2002/06/25 01:33:22 steve
* Cache calculated driven value.
*
* Revision 1.36 2002/06/24 01:49:38 steve
* Make link_drive_constant cache its results in
* the Nexus, to improve cprop performance.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: link_const.cc,v 1.13 2002/06/24 01:49:39 steve Exp $"
#ident "$Id: link_const.cc,v 1.14 2002/06/25 01:33:22 steve Exp $"
#endif
# include "config.h"
@ -101,13 +101,29 @@ bool Nexus::drivers_constant() const
return true;
}
verinum::V driven_value(const Link&lnk)
verinum::V Nexus::driven_value() const
{
verinum::V val = lnk.get_init();
switch (driven_) {
case V0:
return verinum::V0;
case V1:
return verinum::V1;
case Vx:
return verinum::Vx;
case Vz:
return verinum::Vz;
case VAR:
assert(0);
break;
case NO_GUESS:
break;
}
const Nexus*nex = lnk.nexus();
for (const Link*cur = nex->first_nlink()
; cur ; cur = cur->next_nlink()) {
const Link*cur = list_;
verinum::V val = verinum::Vz;
for (cur = list_ ; cur ; cur = cur->next_) {
const NetConst*obj;
const NetNet*sig;
@ -116,19 +132,41 @@ verinum::V driven_value(const Link&lnk)
} else if (sig = dynamic_cast<const NetNet*>(cur->get_obj())) {
if (sig->type() == NetNet::SUPPLY0)
if (sig->type() == NetNet::SUPPLY0) {
driven_ = V0;
return verinum::V0;
if (sig->type() == NetNet::SUPPLY1)
}
if (sig->type() == NetNet::SUPPLY1) {
driven_ = V1;
return verinum::V1;
}
}
}
/* Cache the result. */
switch (val) {
case verinum::V0:
driven_ = V0;
break;
case verinum::V1:
driven_ = V1;
break;
case verinum::Vx:
driven_ = Vx;
break;
case verinum::Vz:
driven_ = Vz;
break;
}
return val;
}
/*
* $Log: link_const.cc,v $
* Revision 1.14 2002/06/25 01:33:22 steve
* Cache calculated driven value.
*
* Revision 1.13 2002/06/24 01:49:39 steve
* Make link_drive_constant cache its results in
* the Nexus, to improve cprop performance.

View File

@ -88,10 +88,12 @@ to build properly.
This, believe it or not, should be the easy part:
$ make
$ /usr/bin/make
It could take a while. Now is a good time to go get some coffee or
take a tea break.
take a tea break. I suggest using the complete path to make, because
the mingw version will not know how to execute the /usr/bin/install
program.
* Install Icarus Verilog
@ -106,7 +108,7 @@ window.
When you are ready, install like this:
$ make install
$ /usr/bin/make STRIP=/usr/bin/strip.exe install
This is part of what the configure program did for you. The Makefiles
now know to put the files under the D:\iverilog (or whatever directory

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.246 2002/06/24 01:49:39 steve Exp $"
#ident "$Id: netlist.h,v 1.247 2002/06/25 01:33:22 steve Exp $"
#endif
/*
@ -251,6 +251,10 @@ class Nexus {
are no drivers at all. */
bool drivers_constant() const;
/* Given the nexus has constant drivers, this method returns
the value that has been driven. */
verinum::V driven_value() const;
void* t_cookie() const;
void* t_cookie(void*) const;
@ -2937,6 +2941,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.247 2002/06/25 01:33:22 steve
* Cache calculated driven value.
*
* Revision 1.246 2002/06/24 01:49:39 steve
* Make link_drive_constant cache its results in
* the Nexus, to improve cprop performance.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netmisc.h,v 1.13 2002/06/24 01:49:39 steve Exp $"
#ident "$Id: netmisc.h,v 1.14 2002/06/25 01:33:22 steve Exp $"
#endif
# include "netlist.h"
@ -33,13 +33,6 @@
extern NetExpr*pad_to_width(NetExpr*expr, unsigned wid);
extern NetNet*pad_to_width(Design*des, NetNet*n, unsigned w);
/*
* This function returns the value of the constant driving this link,
* or Vz if there is no constant. The results of this function are
* only meaningful if link_drivers_constant(lnk) == true.
*/
extern verinum::V driven_value(const Link&lnk);
/*
* In some cases the lval is accessible as a pointer to the head of
* a list of NetAssign_ objects. This function returns the width of
@ -57,6 +50,9 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe);
/*
* $Log: netmisc.h,v $
* Revision 1.14 2002/06/25 01:33:22 steve
* Cache calculated driven value.
*
* Revision 1.13 2002/06/24 01:49:39 steve
* Make link_drive_constant cache its results in
* the Nexus, to improve cprop performance.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: syn-rules.y,v 1.21 2002/06/08 23:42:46 steve Exp $"
#ident "$Id: syn-rules.y,v 1.22 2002/06/25 01:33:22 steve Exp $"
#endif
# include "config.h"
@ -226,7 +226,7 @@ static void make_initializer(Design*des, NetProcTop*top, NetAssignBase*asn)
for (unsigned idx = 0 ; idx < asn->l_val(0)->lwidth() ; idx += 1) {
verinum::V bit = driven_value(rsig->bit(idx));
verinum::V bit = rsig->bit(idx).nexus()->driven_value();
Nexus*nex = asn->l_val(0)->sig()->pin(idx).nexus();
for (Link*cur = nex->first_nlink()

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.cc,v 1.87 2002/06/24 01:49:39 steve Exp $"
#ident "$Id: t-dll.cc,v 1.88 2002/06/25 01:33:22 steve Exp $"
#endif
# include "config.h"
@ -1030,7 +1030,7 @@ void dll_target::lpm_clshift(const NetCLShift*net)
if (net->pin_Direction().is_linked()) {
assert( net->pin_Direction().nexus()->drivers_constant() );
verinum::V dir = driven_value(net->pin_Direction());
verinum::V dir = net->pin_Direction().nexus()->driven_value();
switch (dir) {
case verinum::V0:
break;
@ -1950,6 +1950,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
* Revision 1.88 2002/06/25 01:33:22 steve
* Cache calculated driven value.
*
* Revision 1.87 2002/06/24 01:49:39 steve
* Make link_drive_constant cache its results in
* the Nexus, to improve cprop performance.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: xnfio.cc,v 1.21 2002/06/24 01:49:39 steve Exp $"
#ident "$Id: xnfio.cc,v 1.22 2002/06/25 01:33:22 steve Exp $"
#endif
# include "config.h"
@ -323,7 +323,7 @@ bool xnfio_f::compare_sideb_const(Design*des, NetCompare*dev)
if (! dev->pin_DataB(idx).nexus()->drivers_constant())
return false;
side.set(idx, driven_value(dev->pin_DataB(idx)));
side.set(idx, dev->pin_DataB(idx).nexus()->driven_value());
}
/* Handle the special case of comparing A to 0. Use an N-input
@ -363,6 +363,9 @@ void xnfio(Design*des)
/*
* $Log: xnfio.cc,v $
* Revision 1.22 2002/06/25 01:33:22 steve
* Cache calculated driven value.
*
* Revision 1.21 2002/06/24 01:49:39 steve
* Make link_drive_constant cache its results in
* the Nexus, to improve cprop performance.