diff --git a/PGate.cc b/PGate.cc index 7bb507020..4f96907e1 100644 --- a/PGate.cc +++ b/PGate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: PGate.cc,v 1.5 1999/09/14 01:50:35 steve Exp $" +#ident "$Id: PGate.cc,v 1.6 2000/02/18 05:15:02 steve Exp $" #endif # include "PGate.h" @@ -110,8 +110,47 @@ void PGBuiltin::set_range(PExpr*msb, PExpr*lsb) lsb_ = lsb; } +PGModule::PGModule(const string&type, const string&name, svector*pins) +: PGate(name, pins), type_(type), overrides_(0), pins_(0), + npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0) +{ +} + +PGModule::PGModule(const string&type, const string&name, + named*pins, unsigned npins) +: PGate(name, 0), type_(type), overrides_(0), pins_(pins), + npins_(npins), parms_(0), nparms_(0), msb_(0), lsb_(0) +{ +} + +void PGModule::set_parameters(svector*o) +{ + assert(overrides_ == 0); + overrides_ = o; +} + +void PGModule::set_parameters(named*pa, unsigned npa) +{ + assert(parms_ == 0); + assert(overrides_ == 0); + parms_ = pa; + nparms_ = npa; +} + +void PGModule::set_range(PExpr*msb, PExpr*lsb) +{ + assert(msb_ == 0); + assert(lsb_ == 0); + + msb_ = msb; + lsb_ = lsb; +} + /* * $Log: PGate.cc,v $ + * Revision 1.6 2000/02/18 05:15:02 steve + * Catch module instantiation arrays. + * * Revision 1.5 1999/09/14 01:50:35 steve * Handle gates without delays. * diff --git a/PGate.h b/PGate.h index f749126cf..49e1af895 100644 --- a/PGate.h +++ b/PGate.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: PGate.h,v 1.12 2000/01/09 05:50:48 steve Exp $" +#ident "$Id: PGate.h,v 1.13 2000/02/18 05:15:02 steve Exp $" #endif # include "svector.h" @@ -156,30 +156,22 @@ class PGModule : public PGate { // If the binding of ports is by position, this constructor // builds everything all at once. explicit PGModule(const string&type, const string&name, - svector*pins) - : PGate(name, pins), type_(type), overrides_(0), pins_(0), - npins_(0), parms_(0), nparms_(0) { } + svector*pins); // If the binding of ports is by name, this constructor takes // the bindings and stores them for later elaboration. explicit PGModule(const string&type, const string&name, - named*pins, unsigned npins) - : PGate(name, 0), type_(type), overrides_(0), pins_(pins), - npins_(npins), parms_(0), nparms_(0) { } + named*pins, unsigned npins); // Parameter overrides can come as an ordered list, or a set // of named expressions. - void set_parameters(svector*o) - { assert(overrides_ == 0); overrides_ = o; } - - void set_parameters(named*pa, unsigned npa) - { assert(parms_ == 0); - assert(overrides_ == 0); - parms_ = pa; - nparms_ = npa; - } + void set_parameters(svector*o); + void set_parameters(named*pa, unsigned npa); + // Modules can be instantiated in ranges. The parser uses this + // method to pass the range to the pform. + void set_range(PExpr*msb, PExpr*lsb); virtual void dump(ostream&out) const; virtual void elaborate(Design*, const string&path) const; @@ -194,12 +186,19 @@ class PGModule : public PGate { named*parms_; unsigned nparms_; + // Arrays of modules are give if these are set. + PExpr*msb_; + PExpr*lsb_; + void elaborate_mod_(Design*, Module*mod, const string&path) const; void elaborate_udp_(Design*, PUdp *udp, const string&path) const; }; /* * $Log: PGate.h,v $ + * Revision 1.13 2000/02/18 05:15:02 steve + * Catch module instantiation arrays. + * * Revision 1.12 2000/01/09 05:50:48 steve * Support named parameter override lists. * diff --git a/README.txt b/README.txt index 90c58ac98..948bc9045 100644 --- a/README.txt +++ b/README.txt @@ -339,6 +339,7 @@ I have received aid in the form of fixes, Verilog guidance, and especially testing from many people, including (in alphabetical order): Eric Aardoom + Stephan I. Boettcher Ed Carter Larry Doolittle Guy Hutchison diff --git a/elaborate.cc b/elaborate.cc index 0b8e9e305..7dac3b9ca 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.143 2000/02/14 00:11:11 steve Exp $" +#ident "$Id: elaborate.cc,v 1.144 2000/02/18 05:15:02 steve Exp $" #endif /* @@ -394,6 +394,13 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const return; } + if (msb_) { + cerr << get_line() << ": sorry: Module instantiation arrays " + "are not yet supported." << endl; + des->errors += 1; + return; + } + NetScope*my_scope = des->make_scope(path, NetScope::MODULE, get_name()); const string my_name = my_scope -> name(); @@ -2003,6 +2010,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.144 2000/02/18 05:15:02 steve + * Catch module instantiation arrays. + * * Revision 1.143 2000/02/14 00:11:11 steve * Mark the line numbers of NetCondit nodes. * diff --git a/pform.cc b/pform.cc index df482db53..8f5cf9cad 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: pform.cc,v 1.52 2000/01/09 05:50:49 steve Exp $" +#ident "$Id: pform.cc,v 1.53 2000/02/18 05:15:03 steve Exp $" #endif # include "compiler.h" @@ -303,12 +303,15 @@ void pform_makegates(PGBuiltin::Type type, /* * A module is different from a gate in that there are different - * constraints, and sometimes different syntax. + * constraints, and sometimes different syntax. The X_modgate + * functions handle the instantaions of modules (and UDP objects) by + * making PGModule objects. */ static void pform_make_modgate(const string&type, const string&name, struct parmvalue_t*overrides, svector*wires, + PExpr*msb, PExpr*lsb, const string&fn, unsigned ln) { if (name == "") { @@ -321,6 +324,7 @@ static void pform_make_modgate(const string&type, PGModule*cur = new PGModule(type, name, wires); cur->set_file(fn); cur->set_lineno(ln); + cur->set_range(msb,lsb); if (overrides && overrides->by_name) { unsigned cnt = overrides->by_name->count(); @@ -345,6 +349,7 @@ static void pform_make_modgate(const string&type, const string&name, struct parmvalue_t*overrides, svector*bind, + PExpr*msb, PExpr*lsb, const string&fn, unsigned ln) { if (name == "") { @@ -365,6 +370,7 @@ static void pform_make_modgate(const string&type, PGModule*cur = new PGModule(type, name, pins, npins); cur->set_file(fn); cur->set_lineno(ln); + cur->set_range(msb,lsb); if (overrides && overrides->by_name) { unsigned cnt = overrides->by_name->count(); @@ -402,16 +408,22 @@ void pform_make_modgates(const string&type, lgate cur = (*gates)[idx]; if (cur.parms_by_name) { - pform_make_modgate(type, cur.name, overrides, cur.parms_by_name, + pform_make_modgate(type, cur.name, overrides, + cur.parms_by_name, + cur.range[0], cur.range[1], cur.file, cur.lineno); } else if (cur.parms) { - pform_make_modgate(type, cur.name, overrides, cur.parms, cur.file, - cur.lineno); + pform_make_modgate(type, cur.name, overrides, + cur.parms, + cur.range[0], cur.range[1], + cur.file, cur.lineno); } else { svector*wires = new svector(0); - pform_make_modgate(type, cur.name, overrides, wires, cur.file, - cur.lineno); + pform_make_modgate(type, cur.name, overrides, + wires, + cur.range[0], cur.range[1], + cur.file, cur.lineno); } } @@ -808,6 +820,9 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.53 2000/02/18 05:15:03 steve + * Catch module instantiation arrays. + * * Revision 1.52 2000/01/09 05:50:49 steve * Support named parameter override lists. * diff --git a/pform_dump.cc b/pform_dump.cc index 11fa573cb..8ddaa757e 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: pform_dump.cc,v 1.47 2000/01/09 20:37:57 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.48 2000/02/18 05:15:03 steve Exp $" #endif /* @@ -307,7 +307,18 @@ void PGModule::dump(ostream&out) const out << ") "; } - out << get_name() << "("; + out << get_name(); + + // If the module is arrayed, print the index expressions. + if (msb_ || lsb_) { + out << "["; + if (msb_) out << *msb_; + out << ":"; + if (lsb_) out << *lsb_; + out << "]"; + } + + out << "("; if (pins_) { out << "." << pins_[0].name << "("; if (pins_[0].parm) out << *pins_[0].parm; @@ -691,6 +702,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.48 2000/02/18 05:15:03 steve + * Catch module instantiation arrays. + * * Revision 1.47 2000/01/09 20:37:57 steve * Careful with wires connected to multiple ports. *