From 9d6392fda949b7fd36e63763d0afb827ac1aa97d Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 18 Nov 1999 03:52:19 +0000 Subject: [PATCH] Turn NetTmp objects into normal local NetNet objects, and add the nodangle functor to clean up the local symbols generated by elaboration and other steps. --- Makefile.in | 4 +-- elaborate.cc | 29 ++++++++++++++----- functor.cc | 10 +++++-- main.cc | 11 ++++++-- netlist.cc | 13 ++++++++- netlist.h | 14 +++++---- nodangle.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ verilog.sh | 2 +- xnf.txt | 7 ++++- 9 files changed, 149 insertions(+), 21 deletions(-) create mode 100644 nodangle.cc diff --git a/Makefile.in b/Makefile.in index 46f811f50..322de4c43 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.27 1999/11/02 04:55:34 steve Exp $" +#ident "$Id: Makefile.in,v 1.28 1999/11/18 03:52:19 steve Exp $" # # SHELL = /bin/sh @@ -66,7 +66,7 @@ distclean: clean rm -f Makefile TT = t-null.o t-verilog.o t-vvm.o t-xnf.o -FF = nobufz.o propinit.o sigfold.o synth.o xnfio.o xnfsyn.o +FF = nobufz.o nodangle.o propinit.o sigfold.o synth.o xnfio.o xnfsyn.o O = main.o cprop.o design_dump.o elaborate.o elab_expr.o elab_net.o \ emit.o eval.o eval_tree.o expr_synth.o functor.o \ diff --git a/elaborate.cc b/elaborate.cc index f7ad995d6..09deabd36 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: elaborate.cc,v 1.123 1999/11/10 02:52:24 steve Exp $" +#ident "$Id: elaborate.cc,v 1.124 1999/11/18 03:52:19 steve Exp $" #endif /* @@ -771,7 +771,9 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path, unsigned lidx = sig->sb_to_idx(lval->as_long()); if (midx >= lidx) { - NetTmp*tmp = new NetTmp(midx-lidx+1); + NetTmp*tmp = new NetTmp(des->local_symbol(path), + midx-lidx+1); + des->add_signal(tmp); if (tmp->pin_count() > sig->pin_count()) { cerr << get_line() << ": bit select out of " << "range for " << sig->name() << endl; @@ -784,7 +786,9 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path, sig = tmp; } else { - NetTmp*tmp = new NetTmp(lidx-midx+1); + NetTmp*tmp = new NetTmp(des->local_symbol(path), + lidx-midx+1); + des->add_signal(tmp); assert(tmp->pin_count() <= sig->pin_count()); for (unsigned idx = lidx ; idx >= midx ; idx -= 1) connect(tmp->pin(idx-midx), sig->pin(idx)); @@ -809,7 +813,8 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path, des->errors += 1; idx = 0; } - NetTmp*tmp = new NetTmp(1); + NetTmp*tmp = new NetTmp(des->local_symbol(path), 1); + des->add_signal(tmp); connect(tmp->pin(0), sig->pin(idx)); sig = tmp; } @@ -862,7 +867,9 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const unsigned lidx = sig->sb_to_idx(lval->as_long()); if (midx >= lidx) { - NetTmp*tmp = new NetTmp(midx-lidx+1); + NetTmp*tmp = new NetTmp(des->local_symbol(path), + midx-lidx+1); + des->add_signal(tmp); if (tmp->pin_count() > sig->pin_count()) { cerr << get_line() << ": bit select out of " << "range for " << sig->name() << endl; @@ -875,7 +882,9 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const sig = tmp; } else { - NetTmp*tmp = new NetTmp(lidx-midx+1); + NetTmp*tmp = new NetTmp(des->local_symbol(path), + lidx-midx+1); + des->add_signal(tmp); assert(tmp->pin_count() <= sig->pin_count()); for (unsigned idx = lidx ; idx >= midx ; idx -= 1) connect(tmp->pin(idx-midx), sig->pin(idx)); @@ -900,7 +909,8 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const des->errors += 1; idx = 0; } - NetTmp*tmp = new NetTmp(1); + NetTmp*tmp = new NetTmp(des->local_symbol(path), 1); + des->add_signal(tmp); connect(tmp->pin(0), sig->pin(idx)); sig = tmp; } @@ -2335,6 +2345,11 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.124 1999/11/18 03:52:19 steve + * Turn NetTmp objects into normal local NetNet objects, + * and add the nodangle functor to clean up the local + * symbols generated by elaboration and other steps. + * * Revision 1.123 1999/11/10 02:52:24 steve * Create the vpiMemory handle type. * diff --git a/functor.cc b/functor.cc index 2c88ce50f..debf6d3aa 100644 --- a/functor.cc +++ b/functor.cc @@ -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.3 1999/11/01 02:07:40 steve Exp $" +#ident "$Id: functor.cc,v 1.4 1999/11/18 03:52:19 steve Exp $" #endif # include "functor.h" @@ -45,8 +45,9 @@ void Design::functor(functor_t*fun) if (signals_) { NetNet*cur = signals_->sig_next_; do { + NetNet*tmp = cur->sig_next_; fun->signal(this, cur); - cur = cur->sig_next_; + cur = tmp; } while (cur != signals_->sig_next_); } @@ -81,6 +82,11 @@ void NetFF::functor_node(Design*des, functor_t*fun) /* * $Log: functor.cc,v $ + * Revision 1.4 1999/11/18 03:52:19 steve + * Turn NetTmp objects into normal local NetNet objects, + * and add the nodangle functor to clean up the local + * symbols generated by elaboration and other steps. + * * Revision 1.3 1999/11/01 02:07:40 steve * Add the synth functor to do generic synthesis * and add the LPM_FF device to handle rows of diff --git a/main.cc b/main.cc index 9871037d9..68c1c4ea7 100644 --- a/main.cc +++ b/main.cc @@ -19,7 +19,7 @@ const char COPYRIGHT[] = * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: main.cc,v 1.24 1999/11/01 02:07:40 steve Exp $" +#ident "$Id: main.cc,v 1.25 1999/11/18 03:52:19 steve Exp $" #endif const char NOTICE[] = @@ -81,6 +81,7 @@ extern void propinit(Design*des); extern void sigfold(Design*des); extern void synth(Design*des); extern void nobufz(Design*des); +extern void nodangle(Design*des); extern void xnfio(Design*des); extern void xnfsyn(Design*des); @@ -91,7 +92,8 @@ static struct net_func_map { } func_table[] = { { "cprop", &cprop }, { "nobufz", &nobufz }, - { "propinit", &propinit }, + { "nodangle",&nodangle }, + { "propinit",&propinit }, { "sigfold", &sigfold }, { "synth", &synth }, { "xnfio", &xnfio }, @@ -279,6 +281,11 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.25 1999/11/18 03:52:19 steve + * Turn NetTmp objects into normal local NetNet objects, + * and add the nodangle functor to clean up the local + * symbols generated by elaboration and other steps. + * * Revision 1.24 1999/11/01 02:07:40 steve * Add the synth functor to do generic synthesis * and add the LPM_FF device to handle rows of diff --git a/netlist.cc b/netlist.cc index ebf7c3e80..ce3dae1e8 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.cc,v 1.86 1999/11/14 23:43:45 steve Exp $" +#ident "$Id: netlist.cc,v 1.87 1999/11/18 03:52:19 steve Exp $" #endif # include @@ -346,6 +346,12 @@ unsigned NetNet::sb_to_idx(long sb) const return lsb_ - sb; } +NetTmp::NetTmp(const string&name, unsigned npins) +: NetNet(name, IMPLICIT, npins) +{ + local_flag(true); +} + NetProc::NetProc() : next_(0) { @@ -2342,6 +2348,11 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*)) /* * $Log: netlist.cc,v $ + * Revision 1.87 1999/11/18 03:52:19 steve + * Turn NetTmp objects into normal local NetNet objects, + * and add the nodangle functor to clean up the local + * symbols generated by elaboration and other steps. + * * Revision 1.86 1999/11/14 23:43:45 steve * Support combinatorial comparators. * diff --git a/netlist.h b/netlist.h index b1f76524a..c0bc66785 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.h,v 1.88 1999/11/14 23:43:45 steve Exp $" +#ident "$Id: netlist.h,v 1.89 1999/11/18 03:52:19 steve Exp $" #endif /* @@ -599,14 +599,13 @@ class NetEConst : public NetExpr { /* * The NetTmp object is a network that is only used momentarily by - * elaboration to carry links around. A completed netlist cannot have - * any of these within. This is a kind of wire, so it is NetNet type. + * elaboration to carry links around. A completed netlist should not + * have any of these within. This is a kind of wire, so it is NetNet type. */ class NetTmp : public NetNet { public: - explicit NetTmp(unsigned npins =1) - : NetNet("@", IMPLICIT, npins) { } + explicit NetTmp(const string&name, unsigned npins =1); }; @@ -1938,6 +1937,11 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.89 1999/11/18 03:52:19 steve + * Turn NetTmp objects into normal local NetNet objects, + * and add the nodangle functor to clean up the local + * symbols generated by elaboration and other steps. + * * Revision 1.88 1999/11/14 23:43:45 steve * Support combinatorial comparators. * diff --git a/nodangle.cc b/nodangle.cc new file mode 100644 index 000000000..3cfdc41ee --- /dev/null +++ b/nodangle.cc @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999Stephen Williams (steve@icarus.com) + * + * This source code is free software; you can redistribute it + * and/or modify it in source code form under the terms of the GNU + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined(WINNT) +#ident "$Id: nodangle.cc,v 1.1 1999/11/18 03:52:20 steve Exp $" +#endif + +/* + * This functor scans the design looking for dangling objects and + * excess local signals. These deletions are not necessarily required + * for proper functioning of anything, but they can clean up the + * appearance of design files that are generated. + */ +# include "functor.h" +# include "netlist.h" + +class nodangle_f : public functor_t { + public: + void signal(Design*des, NetNet*sig); +}; + + +void nodangle_f::signal(Design*des, NetNet*sig) +{ + if (! sig->local_flag()) + return; + + /* Check to see if there is some significant signal connected + to every pin of this signal. */ + unsigned significant_flags = 0; + for (unsigned idx = 0 ; idx < sig->pin_count() ; idx += 1) { + NetObj::Link&lnk = sig->pin(idx); + for (NetObj::Link*cur = lnk.next_link() + ; cur != &lnk ; cur = cur->next_link()) { + NetNet*cursig = dynamic_cast(cur->get_obj()); + if (cursig == 0) + continue; + if (cursig->local_flag()) + continue; + significant_flags += 1; + break; + } + } + + /* If every pin is connected to another significant signal, + then I can delete this one. */ + if (significant_flags == sig->pin_count()) + delete sig; +} + +void nodangle(Design*des) +{ + nodangle_f fun; + des->functor(&fun); +} + +/* + * $Log: nodangle.cc,v $ + * Revision 1.1 1999/11/18 03:52:20 steve + * Turn NetTmp objects into normal local NetNet objects, + * and add the nodangle functor to clean up the local + * symbols generated by elaboration and other steps. + * + */ + diff --git a/verilog.sh b/verilog.sh index 61ce4bfd6..ba2afb500 100644 --- a/verilog.sh +++ b/verilog.sh @@ -78,7 +78,7 @@ fi case "$target" in vvm) targetSuffix="" ;; xnf) targetSuffix=".xnf" - functors="-Fsynth -Fsigfold -Fxnfio" ;; + functors="-Fsynth -Fnodangle -Fxnfio" ;; *) targetSuffix=".$target" ;; esac diff --git a/xnf.txt b/xnf.txt index bbbfad6be..6a7aad325 100644 --- a/xnf.txt +++ b/xnf.txt @@ -102,7 +102,7 @@ line. The code generator needs to know the type of part to generate code for, so the ``-fpart='' flag is also needed. For example, to generate code for the 4010E the command line might start out as: - ivl -txnf -fpart=4010e -Fsynth -Fsigfold -Fxnfio [...] + ivl -txnf -fpart=4010e -Fsynth -Fnodangle -Fxnfio [...] Icarus Verilog includes the functions ``synth'' and ``xnfio'' to perform transformations and optimizations on the design before code is @@ -176,6 +176,11 @@ IBUF, NOT gates cannot be absorbed as in the OPAD case. $Log: xnf.txt,v $ + Revision 1.9 1999/11/18 03:52:20 steve + Turn NetTmp objects into normal local NetNet objects, + and add the nodangle functor to clean up the local + symbols generated by elaboration and other steps. + Revision 1.8 1999/11/06 04:51:42 steve Support writing some XNF things into an NCF file.