Skip to content

Commit

Permalink
Detect muxing Vz as a bufufN.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Jul 15, 2000
1 parent 42e4ff4 commit 2a08824
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 10 deletions.
82 changes: 81 additions & 1 deletion cprop.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: cprop.cc,v 1.12 2000/06/25 19:59:41 steve Exp $" #ident "$Id: cprop.cc,v 1.13 2000/07/15 05:13:43 steve Exp $"
#endif #endif


# include "netlist.h" # include "netlist.h"
Expand All @@ -41,6 +41,7 @@ struct cprop_functor : public functor_t {
virtual void lpm_add_sub(Design*des, NetAddSub*obj); virtual void lpm_add_sub(Design*des, NetAddSub*obj);
virtual void lpm_ff(Design*des, NetFF*obj); virtual void lpm_ff(Design*des, NetFF*obj);
virtual void lpm_logic(Design*des, NetLogic*obj); virtual void lpm_logic(Design*des, NetLogic*obj);
virtual void lpm_mux(Design*des, NetMux*obj);
}; };


void cprop_functor::lpm_add_sub(Design*des, NetAddSub*obj) void cprop_functor::lpm_add_sub(Design*des, NetAddSub*obj)
Expand Down Expand Up @@ -226,6 +227,82 @@ void cprop_functor::lpm_logic(Design*des, NetLogic*obj)
} }
} }


/*
* This detects the case where the mux selects between a value an
* Vz. In this case, replace the device with a bufif with the sel
* input used to enable the output.
*/
void cprop_functor::lpm_mux(Design*des, NetMux*obj)
{
if (obj->size() != 2)
return;
if (obj->sel_width() != 1)
return;

/* If the first input is all constant Vz, then replace the
NetMux with an array of BUFIF1 devices, with the enable
connected to the select input. */
bool flag = true;
for (unsigned idx = 0 ; idx < obj->width() ; idx += 1) {
if (! link_drivers_constant(obj->pin_Data(idx, 0))) {
flag = false;
break;
}

if (driven_value(obj->pin_Data(idx, 0)) != verinum::Vz) {
flag = false;
break;
}
}

if (flag) {
for (unsigned idx = 0 ; idx < obj->width() ; idx += 1) {
NetLogic*tmp = new NetLogic(des->local_symbol(obj->name()),
3, NetLogic::BUFIF1);

connect(obj->pin_Result(idx), tmp->pin(0));
connect(obj->pin_Data(idx,1), tmp->pin(1));
connect(obj->pin_Sel(0), tmp->pin(2));
des->add_node(tmp);
}

count += 1;
delete obj;
return;
}

/* If instead the second input is all constant Vz, replace the
NetMux with an array of BUFIF0 devices. */
flag = true;
for (unsigned idx = 0 ; idx < obj->width() ; idx += 1) {
if (! link_drivers_constant(obj->pin_Data(idx, 1))) {
flag = false;
break;
}

if (driven_value(obj->pin_Data(idx, 1)) != verinum::Vz) {
flag = false;
break;
}
}

if (flag) {
for (unsigned idx = 0 ; idx < obj->width() ; idx += 1) {
NetLogic*tmp = new NetLogic(des->local_symbol(obj->name()),
3, NetLogic::BUFIF1);

connect(obj->pin_Result(idx), tmp->pin(0));
connect(obj->pin_Data(idx,0), tmp->pin(1));
connect(obj->pin_Sel(0), tmp->pin(2));
des->add_node(tmp);
}

count += 1;
delete obj;
return;
}
}

/* /*
* This functor looks to see if the constant is connected to nothing * This functor looks to see if the constant is connected to nothing
* but signals. If that is the case, delete the dangling constant and * but signals. If that is the case, delete the dangling constant and
Expand Down Expand Up @@ -286,6 +363,9 @@ void cprop(Design*des)


/* /*
* $Log: cprop.cc,v $ * $Log: cprop.cc,v $
* Revision 1.13 2000/07/15 05:13:43 steve
* Detect muxing Vz as a bufufN.
*
* Revision 1.12 2000/06/25 19:59:41 steve * Revision 1.12 2000/06/25 19:59:41 steve
* Redesign Links to include the Nexus class that * Redesign Links to include the Nexus class that
* carries properties of the connected set of links. * carries properties of the connected set of links.
Expand Down
30 changes: 24 additions & 6 deletions elab_net.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elab_net.cc,v 1.41 2000/07/08 04:59:20 steve Exp $" #ident "$Id: elab_net.cc,v 1.42 2000/07/15 05:13:43 steve Exp $"
#endif #endif


# include "PExpr.h" # include "PExpr.h"
Expand Down Expand Up @@ -996,9 +996,15 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
unsigned midx = sig->sb_to_idx(mval->as_long()); unsigned midx = sig->sb_to_idx(mval->as_long());
unsigned lidx = sig->sb_to_idx(lval->as_long()); unsigned lidx = sig->sb_to_idx(lval->as_long());


/* This is a part select, create a new NetNet object
that connects to just the desired parts of the
identifier. Make sure the NetNet::Type is compatible
with the sig type. */

if (midx >= lidx) { if (midx >= lidx) {
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path), NetNet*tmp = new NetNet(scope, des->local_symbol(path),
midx-lidx+1); sig->type(), midx-lidx+1);
tmp->local_flag(true);
if (tmp->pin_count() > sig->pin_count()) { if (tmp->pin_count() > sig->pin_count()) {
cerr << get_line() << ": bit select out of " cerr << get_line() << ": bit select out of "
<< "range for " << sig->name() << endl; << "range for " << sig->name() << endl;
Expand All @@ -1011,8 +1017,10 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
sig = tmp; sig = tmp;


} else { } else {
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path), NetNet*tmp = new NetNet(scope, des->local_symbol(path),
lidx-midx+1); sig->type(), midx-lidx+1);
tmp->local_flag(true);

assert(tmp->pin_count() <= sig->pin_count()); assert(tmp->pin_count() <= sig->pin_count());
for (unsigned idx = lidx ; idx >= midx ; idx -= 1) for (unsigned idx = lidx ; idx >= midx ; idx -= 1)
connect(tmp->pin(idx-midx), sig->pin(idx)); connect(tmp->pin(idx-midx), sig->pin(idx));
Expand All @@ -1037,7 +1045,14 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
des->errors += 1; des->errors += 1;
idx = 0; idx = 0;
} }
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path), 1);
/* This is a bit select, create a compatible NetNet with
a single bit that links to the selected bit of the
expression. */
NetNet*tmp = new NetNet(scope, des->local_symbol(path),
sig->type(), 1);
tmp->local_flag(true);

connect(tmp->pin(0), sig->pin(idx)); connect(tmp->pin(0), sig->pin(idx));
sig = tmp; sig = tmp;
} }
Expand Down Expand Up @@ -1604,6 +1619,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,


/* /*
* $Log: elab_net.cc,v $ * $Log: elab_net.cc,v $
* Revision 1.42 2000/07/15 05:13:43 steve
* Detect muxing Vz as a bufufN.
*
* Revision 1.41 2000/07/08 04:59:20 steve * Revision 1.41 2000/07/08 04:59:20 steve
* Eleminate reduction gate for 1-bit compares. * Eleminate reduction gate for 1-bit compares.
* *
Expand Down
15 changes: 14 additions & 1 deletion functor.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: functor.cc,v 1.18 2000/05/02 00:58:12 steve Exp $" #ident "$Id: functor.cc,v 1.19 2000/07/15 05:13:43 steve Exp $"
#endif #endif


# include "functor.h" # include "functor.h"
Expand Down Expand Up @@ -67,6 +67,11 @@ void functor_t::lpm_mult(class Design*, class NetMult*)
{ {
} }


void functor_t::lpm_mux(class Design*, class NetMux*)
{
}


void NetScope::run_functor(Design*des, functor_t*fun) void NetScope::run_functor(Design*des, functor_t*fun)
{ {
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) { for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) {
Expand Down Expand Up @@ -154,6 +159,11 @@ void NetMult::functor_node(Design*des, functor_t*fun)
fun->lpm_mult(des, this); fun->lpm_mult(des, this);
} }


void NetMux::functor_node(Design*des, functor_t*fun)
{
fun->lpm_mux(des, this);
}

proc_match_t::~proc_match_t() proc_match_t::~proc_match_t()
{ {
} }
Expand Down Expand Up @@ -217,6 +227,9 @@ int proc_match_t::event_wait(NetEvWait*)


/* /*
* $Log: functor.cc,v $ * $Log: functor.cc,v $
* Revision 1.19 2000/07/15 05:13:43 steve
* Detect muxing Vz as a bufufN.
*
* Revision 1.18 2000/05/02 00:58:12 steve * Revision 1.18 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *
Expand Down
8 changes: 7 additions & 1 deletion functor.h
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: functor.h,v 1.13 2000/04/20 00:28:03 steve Exp $" #ident "$Id: functor.h,v 1.14 2000/07/15 05:13:44 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -64,6 +64,9 @@ struct functor_t {


/* This method is called for each multiplier. */ /* This method is called for each multiplier. */
virtual void lpm_mult(class Design*des, class NetMult*); virtual void lpm_mult(class Design*des, class NetMult*);

/* This method is called for each MUX. */
virtual void lpm_mux(class Design*des, class NetMux*);
}; };


struct proc_match_t { struct proc_match_t {
Expand All @@ -79,6 +82,9 @@ struct proc_match_t {


/* /*
* $Log: functor.h,v $ * $Log: functor.h,v $
* Revision 1.14 2000/07/15 05:13:44 steve
* Detect muxing Vz as a bufufN.
*
* Revision 1.13 2000/04/20 00:28:03 steve * Revision 1.13 2000/04/20 00:28:03 steve
* Catch some simple identity compareoptimizations. * Catch some simple identity compareoptimizations.
* *
Expand Down
6 changes: 5 additions & 1 deletion netlist.h
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.145 2000/07/14 06:12:57 steve Exp $" #ident "$Id: netlist.h,v 1.146 2000/07/15 05:13:44 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -690,6 +690,7 @@ class NetMux : public NetNode {


virtual void dump_node(ostream&, unsigned ind) const; virtual void dump_node(ostream&, unsigned ind) const;
virtual void emit_node(ostream&, struct target_t*) const; virtual void emit_node(ostream&, struct target_t*) const;
virtual void functor_node(Design*des, functor_t*fun);


private: private:
unsigned width_; unsigned width_;
Expand Down Expand Up @@ -2658,6 +2659,9 @@ extern ostream& operator << (ostream&, NetNet::Type);


/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.146 2000/07/15 05:13:44 steve
* Detect muxing Vz as a bufufN.
*
* Revision 1.145 2000/07/14 06:12:57 steve * Revision 1.145 2000/07/14 06:12:57 steve
* Move inital value handling from NetNet to Nexus * Move inital value handling from NetNet to Nexus
* objects. This allows better propogation of inital * objects. This allows better propogation of inital
Expand Down

0 comments on commit 2a08824

Please sign in to comment.