diff --git a/Module.h b/Module.h index d9dd0e2c3..5741a37b7 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) -#ident "$Id: Module.h,v 1.8 1999/08/04 02:13:02 steve Exp $" +#ident "$Id: Module.h,v 1.9 1999/08/23 16:48:39 steve Exp $" #endif # include @@ -64,6 +64,14 @@ class Module { into this map. */ mapparameters; + /* Parameters may be overridden at instantiation time; + the overrides do not contain explicit parameter names, + but rather refer to parameters in the order they + appear in the instantiated module. Therefore a + list of names in module-order is needed to pass from + a parameter-index to its name. */ + list param_names; + const string&get_name() const { return name_; } void add_gate(PGate*gate); @@ -85,7 +93,7 @@ class Module { const list& get_behaviors() const { return behaviors_; } void dump(ostream&out) const; - bool elaborate(Design*, const string&path) const; + bool elaborate(Design*, const string&path, svector*overrides_) const; private: const string name_; @@ -105,6 +113,10 @@ class Module { /* * $Log: Module.h,v $ + * Revision 1.9 1999/08/23 16:48:39 steve + * Parameter overrides support from Peter Monta + * AND and XOR support wide expressions. + * * Revision 1.8 1999/08/04 02:13:02 steve * Elaborate module ports that are concatenations of * module signals. diff --git a/PGate.h b/PGate.h index 61f4e713e..376a9c08b 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.8 1999/08/01 21:18:55 steve Exp $" +#ident "$Id: PGate.h,v 1.9 1999/08/23 16:48:39 steve Exp $" #endif # include "svector.h" @@ -150,8 +150,8 @@ 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), pins_(0), npins_(0) { } + svector*overrides, svector*pins) + : PGate(name, pins), type_(type), overrides_(overrides), pins_(0), npins_(0) { } // If the binding of ports is by name, this constructor takes // the bindings and stores them for later elaboration. @@ -160,8 +160,8 @@ class PGModule : public PGate { PExpr* parm; }; explicit PGModule(const string&type, const string&name, - bind_t*pins, unsigned npins) - : PGate(name, 0), type_(type), pins_(pins), npins_(npins) { } + svector*overrides, bind_t*pins, unsigned npins) + : PGate(name, 0), type_(type), overrides_(overrides), pins_(pins), npins_(npins) { } virtual void dump(ostream&out) const; @@ -169,6 +169,7 @@ class PGModule : public PGate { private: string type_; + svector*overrides_; bind_t*pins_; unsigned npins_; @@ -178,6 +179,10 @@ class PGModule : public PGate { /* * $Log: PGate.h,v $ + * Revision 1.9 1999/08/23 16:48:39 steve + * Parameter overrides support from Peter Monta + * AND and XOR support wide expressions. + * * Revision 1.8 1999/08/01 21:18:55 steve * elaborate rise/fall/decay for continuous assign. * diff --git a/README.txt b/README.txt index bc1f84619..5bb6f9548 100644 --- a/README.txt +++ b/README.txt @@ -292,6 +292,7 @@ especially testing from many people, including (in alphabetical order): Larry Doolittle Ales Hvezda James Lee + Peter Monta Stefan Petersen Jason Schonberg Stuart Sutherland diff --git a/elaborate.cc b/elaborate.cc index cc855c265..871878845 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.71 1999/08/18 04:00:02 steve Exp $" +#ident "$Id: elaborate.cc,v 1.72 1999/08/23 16:48:39 steve Exp $" #endif /* @@ -463,7 +463,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const // elaboration causes the module to generate a netlist with // the ports represented by NetNet objects. I will find them // later. - rmod->elaborate(des, my_name); + rmod->elaborate(des, my_name, overrides_); // Now connect the ports of the newly elaborated designs to // the expressions that are the instantiation parameters. Scan @@ -643,29 +643,35 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path, switch (op_) { case '^': // XOR - assert(lsig->pin_count() == 1); - assert(rsig->pin_count() == 1); - gate = new NetLogic(des->local_symbol(path), 3, NetLogic::XOR); - connect(gate->pin(1), lsig->pin(0)); - connect(gate->pin(2), rsig->pin(0)); - osig = new NetNet(des->local_symbol(path), NetNet::WIRE); + assert(lsig->pin_count() == rsig->pin_count()); + osig = new NetNet(des->local_symbol(path), NetNet::WIRE, + lsig->pin_count()); osig->local_flag(true); - connect(gate->pin(0), osig->pin(0)); + for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) { + gate = new NetLogic(des->local_symbol(path), 3, + NetLogic::XOR); + connect(gate->pin(1), lsig->pin(idx)); + connect(gate->pin(2), rsig->pin(idx)); + connect(gate->pin(0), osig->pin(idx)); + des->add_node(gate); + } des->add_signal(osig); - des->add_node(gate); break; case '&': // AND - assert(lsig->pin_count() == 1); - assert(rsig->pin_count() == 1); - gate = new NetLogic(des->local_symbol(path), 3, NetLogic::AND); - connect(gate->pin(1), lsig->pin(0)); - connect(gate->pin(2), rsig->pin(0)); - osig = new NetNet(des->local_symbol(path), NetNet::WIRE); + assert(lsig->pin_count() == rsig->pin_count()); + osig = new NetNet(des->local_symbol(path), NetNet::WIRE, + lsig->pin_count()); osig->local_flag(true); - connect(gate->pin(0), osig->pin(0)); + for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) { + gate = new NetLogic(des->local_symbol(path), 3, + NetLogic::AND); + connect(gate->pin(1), lsig->pin(idx)); + connect(gate->pin(2), rsig->pin(idx)); + connect(gate->pin(0), osig->pin(idx)); + des->add_node(gate); + } des->add_signal(osig); - des->add_node(gate); break; case '|': // Bitwise OR @@ -1941,7 +1947,7 @@ NetProc* PWhile::elaborate(Design*des, const string&path) const return loop; } -bool Module::elaborate(Design*des, const string&path) const +bool Module::elaborate(Design*des, const string&path, svector*overrides_) const { bool result_flag = true; @@ -1955,6 +1961,19 @@ bool Module::elaborate(Design*des, const string&path) const des->set_parameter(pname, expr); } + // Override parameters + // FIXME: need to check if too many overrides given + // FIXME: need to release the replaced expression. + + if (overrides_) { + list::const_iterator cur = param_names.begin(); + for (unsigned idx = 0 ; idx < overrides_->count(); idx += 1, cur++) { + string pname = path + "." + (*cur); + NetExpr*expr = (*overrides_)[idx]->elaborate_expr(des, path); + des->set_parameter(pname, expr); + } + } + // Get all the explicitly declared wires of the module and // start the signals list with them. const list&wl = get_wires(); @@ -2037,7 +2056,7 @@ Design* elaborate(const map&modules, modlist = &modules; udplist = &primitives; - bool rc = rmod->elaborate(des, root); + bool rc = rmod->elaborate(des, root, (svector*)0); modlist = 0; udplist = 0; @@ -2051,6 +2070,10 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.72 1999/08/23 16:48:39 steve + * Parameter overrides support from Peter Monta + * AND and XOR support wide expressions. + * * Revision 1.71 1999/08/18 04:00:02 steve * Fixup spelling and some error messages. * diff --git a/parse.y b/parse.y index 47ba586f9..b7c29bdda 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: parse.y,v 1.58 1999/08/03 04:48:51 steve Exp $" +#ident "$Id: parse.y,v 1.59 1999/08/23 16:48:39 steve Exp $" #endif # include "parse_misc.h" @@ -990,12 +990,8 @@ module_item { pform_makegates($1, $2, $3); } | IDENTIFIER delay_opt gate_instance_list ';' - { pform_make_modgates($1, $3); + { pform_make_modgates($1, $2, $3); delete $1; - if ($2) { - yyerror(@2, "Sorry, parameter override not supported."); - delete $2; - } } | K_assign delay_opt lavalue '=' expression ';' { PGAssign*tmp = pform_make_pgassign($3, $5, $2); diff --git a/pform.cc b/pform.cc index b73460ff1..e55023b5b 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.37 1999/08/03 04:14:49 steve Exp $" +#ident "$Id: pform.cc,v 1.38 1999/08/23 16:48:39 steve Exp $" #endif # include "compiler.h" @@ -296,6 +296,7 @@ void pform_makegates(PGBuiltin::Type type, */ static void pform_make_modgate(const string&type, const string&name, + svector*overrides, svector*wires, const string&fn, unsigned ln) { @@ -306,7 +307,7 @@ static void pform_make_modgate(const string&type, return; } - PGate*cur = new PGModule(type, name, wires); + PGate*cur = new PGModule(type, name, overrides, wires); cur->set_file(fn); cur->set_lineno(ln); pform_cur_module->add_gate(cur); @@ -314,6 +315,7 @@ static void pform_make_modgate(const string&type, static void pform_make_modgate(const string&type, const string&name, + svector*overrides, svector*bind, const string&fn, unsigned ln) { @@ -332,27 +334,29 @@ static void pform_make_modgate(const string&type, pins[idx].parm = curp->parm; } - PGate*cur = new PGModule(type, name, pins, npins); + PGate*cur = new PGModule(type, name, overrides, pins, npins); cur->set_file(fn); cur->set_lineno(ln); pform_cur_module->add_gate(cur); } -void pform_make_modgates(const string&type, svector*gates) +void pform_make_modgates(const string&type, + svector*overrides, + svector*gates) { for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) { lgate cur = (*gates)[idx]; if (cur.parms_by_name) { - pform_make_modgate(type, cur.name, cur.parms_by_name, + pform_make_modgate(type, cur.name, overrides, cur.parms_by_name, cur.file, cur.lineno); } else if (cur.parms) { - pform_make_modgate(type, cur.name, cur.parms, cur.file, + pform_make_modgate(type, cur.name, overrides, cur.parms, cur.file, cur.lineno); } else { svector*wires = new svector(0); - pform_make_modgate(type, cur.name, wires, cur.file, + pform_make_modgate(type, cur.name, overrides, wires, cur.file, cur.lineno); } } @@ -573,6 +577,7 @@ void pform_set_net_range(list*names, const svector*range) void pform_set_parameter(const string&name, PExpr*expr) { pform_cur_module->parameters[name] = expr; + pform_cur_module->param_names.push_back(name); } void pform_set_port_type(list*names, NetNet::PortType pt) @@ -655,6 +660,10 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.38 1999/08/23 16:48:39 steve + * Parameter overrides support from Peter Monta + * AND and XOR support wide expressions. + * * Revision 1.37 1999/08/03 04:14:49 steve * Parse into pform arbitrarily complex module * port declarations. diff --git a/pform.h b/pform.h index fe7ec40d6..d2cb54f0f 100644 --- a/pform.h +++ b/pform.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: pform.h,v 1.27 1999/08/03 04:14:49 steve Exp $" +#ident "$Id: pform.h,v 1.28 1999/08/23 16:48:39 steve Exp $" #endif # include "netlist.h" @@ -141,7 +141,9 @@ extern void pform_makegates(PGBuiltin::Type type, svector*delay, svector*gates); -extern void pform_make_modgates(const string&type, svector*gates); +extern void pform_make_modgates(const string&type, + svector*overrides, + svector*gates); /* Make a continuous assignment node, with optional bit- or part- select. */ extern PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, @@ -167,6 +169,10 @@ extern void pform_dump(ostream&out, Module*mod); /* * $Log: pform.h,v $ + * Revision 1.28 1999/08/23 16:48:39 steve + * Parameter overrides support from Peter Monta + * AND and XOR support wide expressions. + * * Revision 1.27 1999/08/03 04:14:49 steve * Parse into pform arbitrarily complex module * port declarations. diff --git a/pform_dump.cc b/pform_dump.cc index 7ec2d6933..a1a2f9324 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.34 1999/08/03 04:49:13 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.35 1999/08/23 16:48:39 steve Exp $" #endif /* @@ -268,7 +268,16 @@ void PGBuiltin::dump(ostream&out) const void PGModule::dump(ostream&out) const { - out << " " << type_ << " " << get_name() << "("; + out << " " << type_ << " "; + if (overrides_) { + out << "#("; + out << *((*overrides_)[0]); + for (unsigned idx = 1 ; idx < overrides_->count() ; idx += 1) { + out << "," << *((*overrides_)[idx]); + } + out << ") "; + } + out << get_name() << "("; if (pins_) { out << "." << pins_[0].name << "(" << *pins_[0].parm << ")"; for (unsigned idx = 1 ; idx < npins_ ; idx += 1) { @@ -619,6 +628,10 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.35 1999/08/23 16:48:39 steve + * Parameter overrides support from Peter Monta + * AND and XOR support wide expressions. + * * Revision 1.34 1999/08/03 04:49:13 steve * Proper port type names. *