Skip to content

Commit

Permalink
Catch module instantiation arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Feb 18, 2000
1 parent 2cba0a5 commit 5b52c38
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 27 deletions.
41 changes: 40 additions & 1 deletion PGate.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) #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 #endif


# include "PGate.h" # include "PGate.h"
Expand Down Expand Up @@ -110,8 +110,47 @@ void PGBuiltin::set_range(PExpr*msb, PExpr*lsb)
lsb_ = lsb; lsb_ = lsb;
} }


PGModule::PGModule(const string&type, const string&name, svector<PExpr*>*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<PExpr*>*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<PExpr*>*o)
{
assert(overrides_ == 0);
overrides_ = o;
}

void PGModule::set_parameters(named<PExpr*>*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 $ * $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 * Revision 1.5 1999/09/14 01:50:35 steve
* Handle gates without delays. * Handle gates without delays.
* *
Expand Down
31 changes: 15 additions & 16 deletions PGate.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) #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 #endif


# include "svector.h" # include "svector.h"
Expand Down Expand Up @@ -156,30 +156,22 @@ class PGModule : public PGate {
// If the binding of ports is by position, this constructor // If the binding of ports is by position, this constructor
// builds everything all at once. // builds everything all at once.
explicit PGModule(const string&type, const string&name, explicit PGModule(const string&type, const string&name,
svector<PExpr*>*pins) svector<PExpr*>*pins);
: PGate(name, pins), type_(type), overrides_(0), pins_(0),
npins_(0), parms_(0), nparms_(0) { }


// If the binding of ports is by name, this constructor takes // If the binding of ports is by name, this constructor takes
// the bindings and stores them for later elaboration. // the bindings and stores them for later elaboration.
explicit PGModule(const string&type, const string&name, explicit PGModule(const string&type, const string&name,
named<PExpr*>*pins, unsigned npins) named<PExpr*>*pins, unsigned npins);
: PGate(name, 0), type_(type), overrides_(0), pins_(pins),
npins_(npins), parms_(0), nparms_(0) { }




// Parameter overrides can come as an ordered list, or a set // Parameter overrides can come as an ordered list, or a set
// of named expressions. // of named expressions.
void set_parameters(svector<PExpr*>*o) void set_parameters(svector<PExpr*>*o);
{ assert(overrides_ == 0); overrides_ = o; } void set_parameters(named<PExpr*>*pa, unsigned npa);

void set_parameters(named<PExpr*>*pa, unsigned npa)
{ assert(parms_ == 0);
assert(overrides_ == 0);
parms_ = pa;
nparms_ = 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 dump(ostream&out) const;
virtual void elaborate(Design*, const string&path) const; virtual void elaborate(Design*, const string&path) const;
Expand All @@ -194,12 +186,19 @@ class PGModule : public PGate {
named<PExpr*>*parms_; named<PExpr*>*parms_;
unsigned nparms_; 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_mod_(Design*, Module*mod, const string&path) const;
void elaborate_udp_(Design*, PUdp *udp, const string&path) const; void elaborate_udp_(Design*, PUdp *udp, const string&path) const;
}; };


/* /*
* $Log: PGate.h,v $ * $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 * Revision 1.12 2000/01/09 05:50:48 steve
* Support named parameter override lists. * Support named parameter override lists.
* *
Expand Down
1 change: 1 addition & 0 deletions README.txt
Expand Up @@ -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): especially testing from many people, including (in alphabetical order):


Eric Aardoom <eric_aardoom@yahoo.com> Eric Aardoom <eric_aardoom@yahoo.com>
Stephan I. Boettcher <stephan@nevis.columbia.edu>
Ed Carter <r47652@email.sps.mot.com> Ed Carter <r47652@email.sps.mot.com>
Larry Doolittle <LRDoolittle@lbl.gov> Larry Doolittle <LRDoolittle@lbl.gov>
Guy Hutchison <ghutchis@pacbell.net> Guy Hutchison <ghutchis@pacbell.net>
Expand Down
12 changes: 11 additions & 1 deletion elaborate.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) #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 #endif


/* /*
Expand Down Expand Up @@ -394,6 +394,13 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
return; 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()); NetScope*my_scope = des->make_scope(path, NetScope::MODULE, get_name());
const string my_name = my_scope -> name(); const string my_name = my_scope -> name();


Expand Down Expand Up @@ -2003,6 +2010,9 @@ Design* elaborate(const map<string,Module*>&modules,


/* /*
* $Log: elaborate.cc,v $ * $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 * Revision 1.143 2000/02/14 00:11:11 steve
* Mark the line numbers of NetCondit nodes. * Mark the line numbers of NetCondit nodes.
* *
Expand Down
29 changes: 22 additions & 7 deletions pform.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) #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 #endif


# include "compiler.h" # include "compiler.h"
Expand Down Expand Up @@ -303,12 +303,15 @@ void pform_makegates(PGBuiltin::Type type,


/* /*
* A module is different from a gate in that there are different * 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, static void pform_make_modgate(const string&type,
const string&name, const string&name,
struct parmvalue_t*overrides, struct parmvalue_t*overrides,
svector<PExpr*>*wires, svector<PExpr*>*wires,
PExpr*msb, PExpr*lsb,
const string&fn, unsigned ln) const string&fn, unsigned ln)
{ {
if (name == "") { if (name == "") {
Expand All @@ -321,6 +324,7 @@ static void pform_make_modgate(const string&type,
PGModule*cur = new PGModule(type, name, wires); PGModule*cur = new PGModule(type, name, wires);
cur->set_file(fn); cur->set_file(fn);
cur->set_lineno(ln); cur->set_lineno(ln);
cur->set_range(msb,lsb);


if (overrides && overrides->by_name) { if (overrides && overrides->by_name) {
unsigned cnt = overrides->by_name->count(); unsigned cnt = overrides->by_name->count();
Expand All @@ -345,6 +349,7 @@ static void pform_make_modgate(const string&type,
const string&name, const string&name,
struct parmvalue_t*overrides, struct parmvalue_t*overrides,
svector<portname_t*>*bind, svector<portname_t*>*bind,
PExpr*msb, PExpr*lsb,
const string&fn, unsigned ln) const string&fn, unsigned ln)
{ {
if (name == "") { if (name == "") {
Expand All @@ -365,6 +370,7 @@ static void pform_make_modgate(const string&type,
PGModule*cur = new PGModule(type, name, pins, npins); PGModule*cur = new PGModule(type, name, pins, npins);
cur->set_file(fn); cur->set_file(fn);
cur->set_lineno(ln); cur->set_lineno(ln);
cur->set_range(msb,lsb);


if (overrides && overrides->by_name) { if (overrides && overrides->by_name) {
unsigned cnt = overrides->by_name->count(); unsigned cnt = overrides->by_name->count();
Expand Down Expand Up @@ -402,16 +408,22 @@ void pform_make_modgates(const string&type,
lgate cur = (*gates)[idx]; lgate cur = (*gates)[idx];


if (cur.parms_by_name) { 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); cur.file, cur.lineno);


} else if (cur.parms) { } else if (cur.parms) {
pform_make_modgate(type, cur.name, overrides, cur.parms, cur.file, pform_make_modgate(type, cur.name, overrides,
cur.lineno); cur.parms,
cur.range[0], cur.range[1],
cur.file, cur.lineno);
} else { } else {
svector<PExpr*>*wires = new svector<PExpr*>(0); svector<PExpr*>*wires = new svector<PExpr*>(0);
pform_make_modgate(type, cur.name, overrides, wires, cur.file, pform_make_modgate(type, cur.name, overrides,
cur.lineno); wires,
cur.range[0], cur.range[1],
cur.file, cur.lineno);
} }
} }


Expand Down Expand Up @@ -808,6 +820,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,


/* /*
* $Log: pform.cc,v $ * $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 * Revision 1.52 2000/01/09 05:50:49 steve
* Support named parameter override lists. * Support named parameter override lists.
* *
Expand Down
18 changes: 16 additions & 2 deletions pform_dump.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) #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 #endif


/* /*
Expand Down Expand Up @@ -307,7 +307,18 @@ void PGModule::dump(ostream&out) const
out << ") "; 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_) { if (pins_) {
out << "." << pins_[0].name << "("; out << "." << pins_[0].name << "(";
if (pins_[0].parm) out << *pins_[0].parm; if (pins_[0].parm) out << *pins_[0].parm;
Expand Down Expand Up @@ -691,6 +702,9 @@ void PUdp::dump(ostream&out) const


/* /*
* $Log: pform_dump.cc,v $ * $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 * Revision 1.47 2000/01/09 20:37:57 steve
* Careful with wires connected to multiple ports. * Careful with wires connected to multiple ports.
* *
Expand Down

0 comments on commit 5b52c38

Please sign in to comment.