From c33b0c22623392c697ba5ce79af46ed0fc45f7df Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 6 Aug 1999 04:05:28 +0000 Subject: [PATCH] Handle scope of parameters. --- BUGS.txt | 33 ++++++++++++++++++++++----------- elaborate.cc | 19 ++++++++++++++++--- eval.cc | 7 +++++-- netlist.cc | 36 +++++++++++++++++++++++++++++------- netlist.h | 7 +++++-- 5 files changed, 77 insertions(+), 25 deletions(-) diff --git a/BUGS.txt b/BUGS.txt index 781d7e172..04fa0cf55 100644 --- a/BUGS.txt +++ b/BUGS.txt @@ -5,12 +5,13 @@ Before I can fix an error, I need to understand what the problem is. Try to explain what is wrong and why you think it is wrong. Please try to include sample code that demonstrates the problem. Include a description of what ivl does that is wrong, and what you expect should -happen. +happen. And include the command line flags passed to the compiler to make +the error happen. (This is often overlooked, and sometimes important.) * The Compiler Doesn't Compile -If the tools don't compile, I need to know about the compilation tools -you are using. Specifically, I need to know: +If the Icarus Verilog don't compile, I need to know about the +compilation tools you are using. Specifically, I need to know: - Operating system and processor type, - Compiler w/ version, @@ -18,7 +19,7 @@ you are using. Specifically, I need to know: - anything else you think relevent. Be aware that I do not have at my disposal a porting lab. I have the -alpha on my desk, and the Linux/Intel box with logic analyzer and +alpha on my desk, and the Linux/Intel box with a logic analyzer and 'scope hanging off it. * The Compiler Crashes @@ -103,7 +104,11 @@ module may not be needed as long as the ``-s '' switch is given. So when you send a test case, ask yourself "Can poor overworked Steve -invoke the error without any Verilog other then what is included?" +invoke the error without any Verilog other then what is included?" And +while we are at it, please place a copyright notice in your test +program and include a GPL license statement if you can. Your test +program may find its way into the test suite, and the notices will +make it all nice and legal. HOW TO SEND PATCHES @@ -111,12 +116,12 @@ Bug reports with patches are very welcome, especially if they are formatted such that I can inspect them, decide that they are obviously correct, and apply them without worry. -I prefer context or unified diffs as emitted by diff from GNU -diffutils. Human beings can read such things, and they are resilient -to changing originals. A good set of flags to diff are ``diff -cNB''. -With such diffs, I can look at the changes you are offering and -probably tell at a glance that they are plausible. Then I can use -patch(1) to apply them. Or I can apply them by hand. +I prefer context diffs as emitted by diff from GNU diffutils. Human +beings can read such things, and they are resilient to changing +originals. A good set of flags to diff are ``diff -cNB''. With such +diffs, I can look at the changes you are offering and probably tell at +a glance that they are plausible. Then I can use patch(1) to apply +them. Or I can apply them by hand. However, if you send patches, *please* tell me what this patch is supposed to accomplish, and if appropriate include a test program that @@ -135,3 +140,9 @@ then falls under the "otherwise noted" category. I must insist that any copyright material submitted for inclusion include the GPL license notice as shown in the rest of the source. + +$Id: BUGS.txt,v 1.2 1999/08/06 04:05:28 steve Exp $ +$Log: BUGS.txt,v $ +Revision 1.2 1999/08/06 04:05:28 steve + Handle scope of parameters. + diff --git a/elaborate.cc b/elaborate.cc index 36dc23b82..541ba20e3 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.68 1999/08/05 04:58:57 steve Exp $" +#ident "$Id: elaborate.cc,v 1.69 1999/08/06 04:05:28 steve Exp $" #endif /* @@ -1035,7 +1035,7 @@ NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const // If the identifier name a paramter name, then return // the expression that it represents. - if (const NetExpr*ex = des->get_parameter(name)) + if (const NetExpr*ex = des->find_parameter(path, text_)) return ex->dup_expr(); // If the identifier names a signal (a register or wire) @@ -1698,10 +1698,20 @@ NetProc* PCallTask::elaborate_usr(Design*des, const string&path) const continue; /* Elaborate the parameter expression as a net so that - it can be used as an l-value. */ + it can be used as an l-value. Then check that the + parameter width match up. */ NetNet*val = parms_[idx]->elaborate_net(des, path); assert(val); + if (val->pin_count() != port->pin_count()) { + cerr << get_line() << ": Expression " << idx+1 << + " width (" << val->pin_count() << + ") does not match task port width (" << + port->pin_count() << ")." << endl; + des->errors += 1; + continue; + } + assert(val->pin_count() == port->pin_count()); /* Make an expression out of the actual task port. */ @@ -2041,6 +2051,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.69 1999/08/06 04:05:28 steve + * Handle scope of parameters. + * * Revision 1.68 1999/08/05 04:58:57 steve * Allow integers as register lvalues. * diff --git a/eval.cc b/eval.cc index 798289c4b..7a72c1f57 100644 --- a/eval.cc +++ b/eval.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: eval.cc,v 1.4 1999/07/17 19:51:00 steve Exp $" +#ident "$Id: eval.cc,v 1.5 1999/08/06 04:05:28 steve Exp $" #endif # include "PExpr.h" @@ -59,7 +59,7 @@ verinum* PEBinary::eval_const(const Design*des, const string&path) const verinum* PEIdent::eval_const(const Design*des, const string&path) const { assert(msb_ == 0); - const NetExpr*expr = des->get_parameter(path + "." + text_); + const NetExpr*expr = des->find_parameter(path, text_); if (expr == 0) return 0; const NetEConst*eval = dynamic_cast(expr); assert(eval); @@ -79,6 +79,9 @@ verinum* PETernary::eval_const(const Design*, const string&) const /* * $Log: eval.cc,v $ + * Revision 1.5 1999/08/06 04:05:28 steve + * Handle scope of parameters. + * * Revision 1.4 1999/07/17 19:51:00 steve * netlist support for ternary operator. * diff --git a/netlist.cc b/netlist.cc index 66ff9d225..9bb230676 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.cc,v 1.51 1999/08/01 21:48:11 steve Exp $" +#ident "$Id: netlist.cc,v 1.52 1999/08/06 04:05:28 steve Exp $" #endif # include @@ -980,6 +980,7 @@ bool NetEUnary::set_width(unsigned w) bool flag = true; switch (op_) { case '~': + case '-': flag = expr_->set_width(w); break; case '&': @@ -1326,13 +1327,31 @@ void Design::set_parameter(const string&key, NetExpr*expr) parameters_[key] = expr; } -const NetExpr* Design::get_parameter(const string&key) const +/* + * Find a parameter from within a specified context. If the name is + * not here, keep looking up until I run out of up to look at. + */ +const NetExpr* Design::find_parameter(const string&path, + const string&name) const { - map::const_iterator cur = parameters_.find(key); - if (cur == parameters_.end()) - return 0; - else - return (*cur).second; + string root = path; + + for (;;) { + string fulname = root + "." + name; + map::const_iterator cur + = parameters_.find(fulname); + + if (cur != parameters_.end()) + return (*cur).second; + + unsigned pos = root.rfind('.'); + if (pos > root.length()) + break; + + root = root.substr(0, pos); + } + + return 0; } string Design::get_flag(const string&key) const @@ -1552,6 +1571,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*)) /* * $Log: netlist.cc,v $ + * Revision 1.52 1999/08/06 04:05:28 steve + * Handle scope of parameters. + * * Revision 1.51 1999/08/01 21:48:11 steve * set width of procedural r-values when then * l-value is a memory word. diff --git a/netlist.h b/netlist.h index c1019ed8e..68f02247e 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.h,v 1.54 1999/08/01 21:48:11 steve Exp $" +#ident "$Id: netlist.h,v 1.55 1999/08/06 04:05:28 steve Exp $" #endif /* @@ -1328,7 +1328,7 @@ class Design { // PARAMETERS void set_parameter(const string&, NetExpr*); - const NetExpr*get_parameter(const string&name) const; + const NetExpr*find_parameter(const string&path, const string&name) const; // SIGNALS void add_signal(NetNet*); @@ -1440,6 +1440,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.55 1999/08/06 04:05:28 steve + * Handle scope of parameters. + * * Revision 1.54 1999/08/01 21:48:11 steve * set width of procedural r-values when then * l-value is a memory word.