From f4ed0e35af4458cb3a30c59c451f3af681c4b4ba Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 5 Nov 2000 06:05:59 +0000 Subject: [PATCH] Handle connectsion to internally unconnected modules (PR#38) --- Module.cc | 16 ++++++++++++++-- Module.h | 8 +++++++- elaborate.cc | 30 +++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Module.cc b/Module.cc index 488320b99..67878013b 100644 --- a/Module.cc +++ b/Module.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: Module.cc,v 1.12 2000/05/16 04:05:15 steve Exp $" +#ident "$Id: Module.cc,v 1.13 2000/11/05 06:05:59 steve Exp $" #endif # include "Module.h" @@ -68,10 +68,19 @@ unsigned Module::port_count() const return ports_.count(); } +/* + * Return the array of PEIdent object that are at this port of the + * module. If the port is internally unconnected, return an empty + * array. + */ const svector& Module::get_port(unsigned idx) const { assert(idx < ports_.count()); - return ports_[idx]->expr; + + if (ports_[idx]) + return ports_[idx]->expr; + else + return svector(); } unsigned Module::find_port(const string&name) const @@ -125,6 +134,9 @@ const list& Module::get_behaviors() const /* * $Log: Module.cc,v $ + * Revision 1.13 2000/11/05 06:05:59 steve + * Handle connectsion to internally unconnected modules (PR#38) + * * Revision 1.12 2000/05/16 04:05:15 steve * Module ports are really special PEIdent * expressions, because a name can be used diff --git a/Module.h b/Module.h index 18d545e1d..9497abd3f 100644 --- a/Module.h +++ b/Module.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: Module.h,v 1.20 2000/07/22 22:09:03 steve Exp $" +#ident "$Id: Module.h,v 1.21 2000/11/05 06:05:59 steve Exp $" #endif # include @@ -124,7 +124,10 @@ class Module { private: const string name_; + /* This is an array of port descriptors, which is in turn a + named array of PEident pointers. */ svector ports_; + map wires_; list gates_; list behaviors_; @@ -139,6 +142,9 @@ class Module { /* * $Log: Module.h,v $ + * Revision 1.21 2000/11/05 06:05:59 steve + * Handle connectsion to internally unconnected modules (PR#38) + * * Revision 1.20 2000/07/22 22:09:03 steve * Parse and elaborate timescale to scopes. * diff --git a/elaborate.cc b/elaborate.cc index 7fb70c823..ad5f06702 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) && !defined(macintosh) -#ident "$Id: elaborate.cc,v 1.195 2000/10/28 00:51:42 steve Exp $" +#ident "$Id: elaborate.cc,v 1.196 2000/11/05 06:05:59 steve Exp $" #endif /* @@ -467,20 +467,29 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const // the pins, elaborate the expressions attached to them, and // bind them to the port of the elaborated module. + // This can get rather complicated because the port can be + // unconnected (meaning an empty paramter is passed) connected + // to a concatenation, or connected to an internally + // unconnected port. + for (unsigned idx = 0 ; idx < pins->count() ; idx += 1) { - // Skip unconnected module ports. + + // Skip unconnected module ports. This happens when a + // null parameter is passed in. if ((*pins)[idx] == 0) continue; - // Inside the module, the port is one or more signals, - // that were already elaborated. List all those signals, - // and I will connect them up later. + // Inside the module, the port is zero or more signals + // that were already elaborated. List all those signals + // and the NetNet equivilents. svector mport = rmod->get_port(idx); svectorprts (mport.count()); + // Count the internal pins of the port. unsigned prts_pin_count = 0; for (unsigned ldx = 0 ; ldx < mport.count() ; ldx += 1) { PEIdent*pport = mport[ldx]; + assert(pport); prts[ldx] = pport->elaborate_port(des, my_scope); if (prts[ldx] == 0) continue; @@ -489,6 +498,13 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const prts_pin_count += prts[ldx]->pin_count(); } + // If I find that the port in unconnected inside the + // module, then there is nothing to connect. Skip the + // paramter. + if (prts_pin_count == 0) { + continue; + } + NetNet*sig = (*pins)[idx]->elaborate_net(des, path, prts_pin_count, 0, 0, 0); @@ -500,6 +516,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const assert(sig); + // Check that the parts have matching pin counts. If // not, they are different widths. Note that idx is 0 // based, but users count parameter positions from 1. @@ -2283,6 +2300,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.196 2000/11/05 06:05:59 steve + * Handle connectsion to internally unconnected modules (PR#38) + * * Revision 1.195 2000/10/28 00:51:42 steve * Add scope to threads in vvm, pass that scope * to vpi sysTaskFunc objects, and add vpi calls