Parameter overrides support from Peter Monta

AND and XOR support wide expressions.
This commit is contained in:
steve 1999-08-23 16:48:39 +00:00
parent 0175a4fce0
commit 9eae940ebd
8 changed files with 109 additions and 44 deletions

View File

@ -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: 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 #endif
# include <list> # include <list>
@ -64,6 +64,14 @@ class Module {
into this map. */ into this map. */
map<string,PExpr*>parameters; map<string,PExpr*>parameters;
/* 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<string> param_names;
const string&get_name() const { return name_; } const string&get_name() const { return name_; }
void add_gate(PGate*gate); void add_gate(PGate*gate);
@ -85,7 +93,7 @@ class Module {
const list<PProcess*>& get_behaviors() const { return behaviors_; } const list<PProcess*>& get_behaviors() const { return behaviors_; }
void dump(ostream&out) const; void dump(ostream&out) const;
bool elaborate(Design*, const string&path) const; bool elaborate(Design*, const string&path, svector<PExpr*>*overrides_) const;
private: private:
const string name_; const string name_;
@ -105,6 +113,10 @@ class Module {
/* /*
* $Log: Module.h,v $ * $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 * Revision 1.8 1999/08/04 02:13:02 steve
* Elaborate module ports that are concatenations of * Elaborate module ports that are concatenations of
* module signals. * module signals.

15
PGate.h
View File

@ -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.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 #endif
# include "svector.h" # include "svector.h"
@ -150,8 +150,8 @@ 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*>*overrides, svector<PExpr*>*pins)
: PGate(name, pins), type_(type), pins_(0), npins_(0) { } : PGate(name, pins), type_(type), overrides_(overrides), pins_(0), npins_(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.
@ -160,8 +160,8 @@ class PGModule : public PGate {
PExpr* parm; PExpr* parm;
}; };
explicit PGModule(const string&type, const string&name, explicit PGModule(const string&type, const string&name,
bind_t*pins, unsigned npins) svector<PExpr*>*overrides, bind_t*pins, unsigned npins)
: PGate(name, 0), type_(type), pins_(pins), npins_(npins) { } : PGate(name, 0), type_(type), overrides_(overrides), pins_(pins), npins_(npins) { }
virtual void dump(ostream&out) const; virtual void dump(ostream&out) const;
@ -169,6 +169,7 @@ class PGModule : public PGate {
private: private:
string type_; string type_;
svector<PExpr*>*overrides_;
bind_t*pins_; bind_t*pins_;
unsigned npins_; unsigned npins_;
@ -178,6 +179,10 @@ class PGModule : public PGate {
/* /*
* $Log: PGate.h,v $ * $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 * Revision 1.8 1999/08/01 21:18:55 steve
* elaborate rise/fall/decay for continuous assign. * elaborate rise/fall/decay for continuous assign.
* *

View File

@ -292,6 +292,7 @@ especially testing from many people, including (in alphabetical order):
Larry Doolittle <LRDoolittle@lbl.gov> Larry Doolittle <LRDoolittle@lbl.gov>
Ales Hvezda <ahvezda@seul.org> Ales Hvezda <ahvezda@seul.org>
James Lee <jml@seva.com> James Lee <jml@seva.com>
Peter Monta <pmonta@halibut.imedia.com>
Stefan Petersen <spe@geda.seul.org> Stefan Petersen <spe@geda.seul.org>
Jason Schonberg <schon@mips.com> Jason Schonberg <schon@mips.com>
Stuart Sutherland <stuart@sutherland.com> Stuart Sutherland <stuart@sutherland.com>

View File

@ -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.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 #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 // elaboration causes the module to generate a netlist with
// the ports represented by NetNet objects. I will find them // the ports represented by NetNet objects. I will find them
// later. // later.
rmod->elaborate(des, my_name); rmod->elaborate(des, my_name, overrides_);
// Now connect the ports of the newly elaborated designs to // Now connect the ports of the newly elaborated designs to
// the expressions that are the instantiation parameters. Scan // the expressions that are the instantiation parameters. Scan
@ -643,29 +643,35 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
switch (op_) { switch (op_) {
case '^': // XOR case '^': // XOR
assert(lsig->pin_count() == 1); assert(lsig->pin_count() == rsig->pin_count());
assert(rsig->pin_count() == 1); osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
gate = new NetLogic(des->local_symbol(path), 3, NetLogic::XOR); lsig->pin_count());
connect(gate->pin(1), lsig->pin(0));
connect(gate->pin(2), rsig->pin(0));
osig = new NetNet(des->local_symbol(path), NetNet::WIRE);
osig->local_flag(true); osig->local_flag(true);
connect(gate->pin(0), osig->pin(0)); for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
des->add_signal(osig); 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_node(gate);
}
des->add_signal(osig);
break; break;
case '&': // AND case '&': // AND
assert(lsig->pin_count() == 1); assert(lsig->pin_count() == rsig->pin_count());
assert(rsig->pin_count() == 1); osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
gate = new NetLogic(des->local_symbol(path), 3, NetLogic::AND); lsig->pin_count());
connect(gate->pin(1), lsig->pin(0));
connect(gate->pin(2), rsig->pin(0));
osig = new NetNet(des->local_symbol(path), NetNet::WIRE);
osig->local_flag(true); osig->local_flag(true);
connect(gate->pin(0), osig->pin(0)); for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
des->add_signal(osig); 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_node(gate);
}
des->add_signal(osig);
break; break;
case '|': // Bitwise OR case '|': // Bitwise OR
@ -1941,7 +1947,7 @@ NetProc* PWhile::elaborate(Design*des, const string&path) const
return loop; return loop;
} }
bool Module::elaborate(Design*des, const string&path) const bool Module::elaborate(Design*des, const string&path, svector<PExpr*>*overrides_) const
{ {
bool result_flag = true; bool result_flag = true;
@ -1955,6 +1961,19 @@ bool Module::elaborate(Design*des, const string&path) const
des->set_parameter(pname, expr); 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<string>::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 // Get all the explicitly declared wires of the module and
// start the signals list with them. // start the signals list with them.
const list<PWire*>&wl = get_wires(); const list<PWire*>&wl = get_wires();
@ -2037,7 +2056,7 @@ Design* elaborate(const map<string,Module*>&modules,
modlist = &modules; modlist = &modules;
udplist = &primitives; udplist = &primitives;
bool rc = rmod->elaborate(des, root); bool rc = rmod->elaborate(des, root, (svector<PExpr*>*)0);
modlist = 0; modlist = 0;
udplist = 0; udplist = 0;
@ -2051,6 +2070,10 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $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 * Revision 1.71 1999/08/18 04:00:02 steve
* Fixup spelling and some error messages. <LRDoolittle@lbl.gov> * Fixup spelling and some error messages. <LRDoolittle@lbl.gov>
* *

View File

@ -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: 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 #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -990,12 +990,8 @@ module_item
{ pform_makegates($1, $2, $3); { pform_makegates($1, $2, $3);
} }
| IDENTIFIER delay_opt gate_instance_list ';' | IDENTIFIER delay_opt gate_instance_list ';'
{ pform_make_modgates($1, $3); { pform_make_modgates($1, $2, $3);
delete $1; delete $1;
if ($2) {
yyerror(@2, "Sorry, parameter override not supported.");
delete $2;
}
} }
| K_assign delay_opt lavalue '=' expression ';' | K_assign delay_opt lavalue '=' expression ';'
{ PGAssign*tmp = pform_make_pgassign($3, $5, $2); { PGAssign*tmp = pform_make_pgassign($3, $5, $2);

View File

@ -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.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 #endif
# include "compiler.h" # include "compiler.h"
@ -296,6 +296,7 @@ void pform_makegates(PGBuiltin::Type type,
*/ */
static void pform_make_modgate(const string&type, static void pform_make_modgate(const string&type,
const string&name, const string&name,
svector<PExpr*>*overrides,
svector<PExpr*>*wires, svector<PExpr*>*wires,
const string&fn, unsigned ln) const string&fn, unsigned ln)
{ {
@ -306,7 +307,7 @@ static void pform_make_modgate(const string&type,
return; return;
} }
PGate*cur = new PGModule(type, name, wires); PGate*cur = new PGModule(type, name, overrides, wires);
cur->set_file(fn); cur->set_file(fn);
cur->set_lineno(ln); cur->set_lineno(ln);
pform_cur_module->add_gate(cur); 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, static void pform_make_modgate(const string&type,
const string&name, const string&name,
svector<PExpr*>*overrides,
svector<portname_t*>*bind, svector<portname_t*>*bind,
const string&fn, unsigned ln) const string&fn, unsigned ln)
{ {
@ -332,27 +334,29 @@ static void pform_make_modgate(const string&type,
pins[idx].parm = curp->parm; 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_file(fn);
cur->set_lineno(ln); cur->set_lineno(ln);
pform_cur_module->add_gate(cur); pform_cur_module->add_gate(cur);
} }
void pform_make_modgates(const string&type, svector<lgate>*gates) void pform_make_modgates(const string&type,
svector<PExpr*>*overrides,
svector<lgate>*gates)
{ {
for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) { for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) {
lgate cur = (*gates)[idx]; lgate cur = (*gates)[idx];
if (cur.parms_by_name) { 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); cur.file, cur.lineno);
} else if (cur.parms) { } 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); cur.lineno);
} else { } else {
svector<PExpr*>*wires = new svector<PExpr*>(0); svector<PExpr*>*wires = new svector<PExpr*>(0);
pform_make_modgate(type, cur.name, wires, cur.file, pform_make_modgate(type, cur.name, overrides, wires, cur.file,
cur.lineno); cur.lineno);
} }
} }
@ -573,6 +577,7 @@ void pform_set_net_range(list<string>*names, const svector<PExpr*>*range)
void pform_set_parameter(const string&name, PExpr*expr) void pform_set_parameter(const string&name, PExpr*expr)
{ {
pform_cur_module->parameters[name] = expr; pform_cur_module->parameters[name] = expr;
pform_cur_module->param_names.push_back(name);
} }
void pform_set_port_type(list<string>*names, NetNet::PortType pt) void pform_set_port_type(list<string>*names, NetNet::PortType pt)
@ -655,6 +660,10 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/* /*
* $Log: pform.cc,v $ * $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 * Revision 1.37 1999/08/03 04:14:49 steve
* Parse into pform arbitrarily complex module * Parse into pform arbitrarily complex module
* port declarations. * port declarations.

10
pform.h
View File

@ -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: 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 #endif
# include "netlist.h" # include "netlist.h"
@ -141,7 +141,9 @@ extern void pform_makegates(PGBuiltin::Type type,
svector<PExpr*>*delay, svector<PExpr*>*delay,
svector<lgate>*gates); svector<lgate>*gates);
extern void pform_make_modgates(const string&type, svector<lgate>*gates); extern void pform_make_modgates(const string&type,
svector<PExpr*>*overrides,
svector<lgate>*gates);
/* Make a continuous assignment node, with optional bit- or part- select. */ /* Make a continuous assignment node, with optional bit- or part- select. */
extern PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, 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 $ * $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 * Revision 1.27 1999/08/03 04:14:49 steve
* Parse into pform arbitrarily complex module * Parse into pform arbitrarily complex module
* port declarations. * port declarations.

View File

@ -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.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 #endif
/* /*
@ -268,7 +268,16 @@ void PGBuiltin::dump(ostream&out) const
void PGModule::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_) { if (pins_) {
out << "." << pins_[0].name << "(" << *pins_[0].parm << ")"; out << "." << pins_[0].name << "(" << *pins_[0].parm << ")";
for (unsigned idx = 1 ; idx < npins_ ; idx += 1) { for (unsigned idx = 1 ; idx < npins_ ; idx += 1) {
@ -619,6 +628,10 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $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 * Revision 1.34 1999/08/03 04:49:13 steve
* Proper port type names. * Proper port type names.
* *