Skip to content

Commit

Permalink
parameter keys are per_strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Feb 20, 2004
1 parent b5b0226 commit 1295058
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 138 deletions.
7 changes: 5 additions & 2 deletions Module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: Module.cc,v 1.22 2004/02/18 17:11:54 steve Exp $"
#ident "$Id: Module.cc,v 1.23 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -88,7 +88,7 @@ const svector<PEIdent*>& Module::get_port(unsigned idx) const
return zero;
}

unsigned Module::find_port(const string&name) const
unsigned Module::find_port(const char*name) const
{
assert(name != "");
for (unsigned idx = 0 ; idx < ports.count() ; idx += 1) {
Expand Down Expand Up @@ -149,6 +149,9 @@ const list<PProcess*>& Module::get_behaviors() const

/*
* $Log: Module.cc,v $
* Revision 1.23 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.22 2004/02/18 17:11:54 steve
* Use perm_strings for named langiage items.
*
Expand Down
15 changes: 9 additions & 6 deletions Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: Module.h,v 1.33 2004/02/18 17:11:54 steve Exp $"
#ident "$Id: Module.h,v 1.34 2004/02/20 06:22:56 steve Exp $"
#endif

# include <list>
Expand Down Expand Up @@ -57,7 +57,7 @@ class Module : public LineInfo {
the port. */
public:
struct port_t {
string name;
perm_string name;
svector<PEIdent*> expr;
};

Expand All @@ -77,8 +77,8 @@ class Module : public LineInfo {
PExpr*lsb;
bool signed_flag;
};
map<string,param_expr_t>parameters;
map<string,param_expr_t>localparams;
map<perm_string,param_expr_t>parameters;
map<perm_string,param_expr_t>localparams;


/* specparams are simpler then other params, in that they have
Expand All @@ -98,7 +98,7 @@ class Module : public LineInfo {
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;
list<perm_string> param_names;

/* This is an array of port descriptors, which is in turn a
named array of PEident pointers. */
Expand Down Expand Up @@ -131,7 +131,7 @@ class Module : public LineInfo {

unsigned port_count() const;
const svector<PEIdent*>& get_port(unsigned idx) const;
unsigned find_port(const string&) const;
unsigned find_port(const char*name) const;

// Find a wire by name. This is used for connecting gates to
// existing wires, etc.
Expand Down Expand Up @@ -166,6 +166,9 @@ class Module : public LineInfo {

/*
* $Log: Module.h,v $
* Revision 1.34 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.33 2004/02/18 17:11:54 steve
* Use perm_strings for named langiage items.
*
Expand Down
19 changes: 14 additions & 5 deletions PExpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: PExpr.cc,v 1.33 2003/01/27 05:09:17 steve Exp $"
#ident "$Id: PExpr.cc,v 1.34 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -161,13 +161,19 @@ bool PEIdent::is_constant(Module*mod) const
{
if (mod == 0) return false;

{ map<string,Module::param_expr_t>::const_iterator cur;
cur = mod->parameters.find(path_.peek_name(0));
/* This is a work-around for map not matching < even when
there is a perm_string operator that can do the comprare.
The real fix is to make the path_ carry perm_strings. */
perm_string tmp = perm_string::literal(path_.peek_name(0));

{ map<perm_string,Module::param_expr_t>::const_iterator cur;
cur = mod->parameters.find(tmp);
if (cur != mod->parameters.end()) return true;
}

{ map<string,Module::param_expr_t>::const_iterator cur;
cur = mod->localparams.find(path_.peek_name(0));
{ map<perm_string,Module::param_expr_t>::const_iterator cur;
cur = mod->localparams.find(tmp);
if (cur != mod->localparams.end()) return true;
}

Expand Down Expand Up @@ -256,6 +262,9 @@ bool PEUnary::is_constant(Module*m) const

/*
* $Log: PExpr.cc,v $
* Revision 1.34 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.33 2003/01/27 05:09:17 steve
* Spelling fixes.
*
Expand Down
7 changes: 5 additions & 2 deletions design_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: design_dump.cc,v 1.146 2004/02/18 17:11:54 steve Exp $"
#ident "$Id: design_dump.cc,v 1.147 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -717,7 +717,7 @@ void NetScope::dump(ostream&o) const

/* Dump the parameters for this scope. */
{
map<string,param_expr_t>::const_iterator pp;
map<perm_string,param_expr_t>::const_iterator pp;
for (pp = parameters.begin()
; pp != parameters.end() ; pp ++) {
o << " parameter ";
Expand Down Expand Up @@ -1079,6 +1079,9 @@ void Design::dump(ostream&o) const

/*
* $Log: design_dump.cc,v $
* Revision 1.147 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.146 2004/02/18 17:11:54 steve
* Use perm_strings for named langiage items.
*
Expand Down
9 changes: 6 additions & 3 deletions elab_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_expr.cc,v 1.83 2004/01/21 04:57:40 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.84 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -605,8 +605,8 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
NetEConstParam if possible. */
NetEConst*ctmp = dynamic_cast<NetEConst*>(tmp);
if (ctmp != 0) {
const char*name
= lex_strings.add(path_.peek_tail_name());
perm_string name
= lex_strings.make(path_.peek_tail_name());
NetEConstParam*ptmp
= new NetEConstParam(found_in, name, ctmp->value());
delete tmp;
Expand Down Expand Up @@ -977,6 +977,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const

/*
* $Log: elab_expr.cc,v $
* Revision 1.84 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.83 2004/01/21 04:57:40 steve
* Generate error when missing concatenation operands.
*
Expand Down
15 changes: 10 additions & 5 deletions elab_pexpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_pexpr.cc,v 1.20 2003/05/30 02:55:32 steve Exp $"
#ident "$Id: elab_pexpr.cc,v 1.21 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"

# include "PExpr.h"
# include "compiler.h"
# include "util.h"

# include <iostream>
Expand Down Expand Up @@ -136,19 +137,20 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
if (path.peek_name(0))
pscope = des->find_scope(scope, path);

const NetExpr*ex = pscope->get_parameter(name);
perm_string perm_name = lex_strings.make(name);
delete name;

const NetExpr*ex = pscope->get_parameter(perm_name);
if (ex == 0) {
cerr << get_line() << ": error: identifier ``" << path_ <<
"'' is not a parameter in " << scope->name() << "." << endl;
des->errors += 1;
delete name;
return 0;
}

NetExpr*res = new NetEParam(des, pscope, hname_t(name));
NetExpr*res = new NetEParam(des, pscope, perm_name);
res->set_line(*this);
assert(res);
delete name;

assert(idx_ == 0);
if (msb_ && lsb_) {
Expand Down Expand Up @@ -229,6 +231,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const

/*
* $Log: elab_pexpr.cc,v $
* Revision 1.21 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.20 2003/05/30 02:55:32 steve
* Support parameters in real expressions and
* as real expressions, and fix multiply and
Expand Down
13 changes: 8 additions & 5 deletions elab_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_scope.cc,v 1.29 2004/02/19 07:06:57 steve Exp $"
#ident "$Id: elab_scope.cc,v 1.30 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -57,7 +57,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
// the pform and just place a NetEParam placeholder in the
// place of the elaborated expression.

typedef map<string,param_expr_t>::const_iterator mparm_it_t;
typedef map<perm_string,param_expr_t>::const_iterator mparm_it_t;
typedef map<hname_t,PExpr*>::const_iterator hparm_it_t;


Expand Down Expand Up @@ -308,8 +308,8 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
// passed. It is built up by the ordered overrides or named
// overrides.

typedef map<string,PExpr*>::const_iterator mparm_it_t;
map<string,PExpr*> replace;
typedef map<perm_string,PExpr*>::const_iterator mparm_it_t;
map<perm_string,PExpr*> replace;


// Positional parameter overrides are matched to parameter
Expand All @@ -319,7 +319,7 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const

if (overrides_) {
assert(parms_ == 0);
list<string>::const_iterator cur = mod->param_names.begin();
list<perm_string>::const_iterator cur = mod->param_names.begin();
unsigned idx = 0;
for (;;) {
if (idx >= overrides_->count())
Expand Down Expand Up @@ -549,6 +549,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const

/*
* $Log: elab_scope.cc,v $
* Revision 1.30 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.29 2004/02/19 07:06:57 steve
* LPM, logic and Variables have perm_string names.
*
Expand Down
22 changes: 10 additions & 12 deletions eval_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: eval_tree.cc,v 1.59 2003/10/31 02:47:11 steve Exp $"
#ident "$Id: eval_tree.cc,v 1.60 2004/02/20 06:22:56 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -1124,8 +1124,7 @@ NetExpr* NetEParam::eval_tree()
return 0;

assert(scope_);
assert(name_.peek_name(1) == 0);
const NetExpr*expr = scope_->get_parameter(name_.peek_name(0));
const NetExpr*expr = scope_->get_parameter(name_);
if (expr == 0) {
cerr << get_line() << ": internal error: Unable to match "
<< "parameter " << name_ << " in scope "
Expand All @@ -1142,17 +1141,15 @@ NetExpr* NetEParam::eval_tree()
// return the constant value.
if (NetEConst*tmp = dynamic_cast<NetEConst*>(nexpr)) {
verinum val = tmp->value();
const char*name = lex_strings.add(name_.peek_name(0));
NetEConstParam*ptmp = new NetEConstParam(scope_, name, val);
NetEConstParam*ptmp = new NetEConstParam(scope_, name_, val);
ptmp->set_line(*this);
delete nexpr;
return ptmp;
}

if (NetECReal*tmp = dynamic_cast<NetECReal*>(nexpr)) {
verireal val = tmp->value();
const char*name = lex_strings.add(name_.peek_name(0));
NetECRealParam*ptmp = new NetECRealParam(scope_, name, val);
NetECRealParam*ptmp = new NetECRealParam(scope_, name_, val);
ptmp->set_line(*this);
delete nexpr;
return ptmp;
Expand All @@ -1171,7 +1168,7 @@ NetExpr* NetEParam::eval_tree()

// The result can be saved as the value of the parameter for
// future reference, and return a copy to the caller.
scope_->replace_parameter(name_.peek_name(0), res);
scope_->replace_parameter(name_, res);

/* Return as a result a NetEConstParam or NetECRealParam
object, depending on the type of the expression. */
Expand All @@ -1190,8 +1187,7 @@ NetExpr* NetEParam::eval_tree()
assert(tmp);

verinum val = tmp->value();
const char*name = lex_strings.add(name_.peek_name(0));
NetEConstParam*ptmp = new NetEConstParam(scope_, name, val);
NetEConstParam*ptmp = new NetEConstParam(scope_, name_, val);

return ptmp;
}
Expand All @@ -1208,8 +1204,7 @@ NetExpr* NetEParam::eval_tree()
assert(tmp);

verireal val = tmp->value();
const char*name = lex_strings.add(name_.peek_name(0));
NetECRealParam*ptmp = new NetECRealParam(scope_, name, val);
NetECRealParam*ptmp = new NetECRealParam(scope_, name_, val);

return ptmp;
}
Expand Down Expand Up @@ -1515,6 +1510,9 @@ NetEConst* NetEUReduce::eval_tree()

/*
* $Log: eval_tree.cc,v $
* Revision 1.60 2004/02/20 06:22:56 steve
* parameter keys are per_strings.
*
* Revision 1.59 2003/10/31 02:47:11 steve
* NetEUReduce has its own dup_expr method.
*
Expand Down
Loading

0 comments on commit 1295058

Please sign in to comment.