From 3ef65d12989d606b806f7f288cb4c7941d00ab1d Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 13 Jun 2003 19:10:45 +0000 Subject: [PATCH] Properly manage real variables in subscopes. --- Module.h | 7 +++++-- elab_scope.cc | 30 ++++++++++++++++++++++++++---- pform.cc | 10 +++++++--- pform_dump.cc | 7 +++++-- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Module.h b/Module.h index 5d93eaf34..b4c161910 100644 --- a/Module.h +++ b/Module.h @@ -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.30 2003/03/06 04:37:12 steve Exp $" +#ident "$Id: Module.h,v 1.31 2003/06/13 19:10:45 steve Exp $" #endif # include @@ -107,7 +107,7 @@ class Module : public LineInfo { mapevents; /* Keep a table of datum variables declared in the module. */ - mapdatum; + mapdatum; /* These are the timescale for this module. The default is set by the `timescale directive. */ @@ -163,6 +163,9 @@ class Module : public LineInfo { /* * $Log: Module.h,v $ + * Revision 1.31 2003/06/13 19:10:45 steve + * Properly manage real variables in subscopes. + * * Revision 1.30 2003/03/06 04:37:12 steve * lex_strings.add module names earlier. * diff --git a/elab_scope.cc b/elab_scope.cc index eb624e013..2331f7768 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -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.21 2003/05/30 02:55:32 steve Exp $" +#ident "$Id: elab_scope.cc,v 1.22 2003/06/13 19:10:46 steve Exp $" #endif # include "config.h" @@ -221,7 +221,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const (*et).second->elaborate_scope(des, scope); } - for (map::const_iterator cur = datum.begin() + for (map::const_iterator cur = datum.begin() ; cur != datum.end() ; cur ++ ) { (*cur).second->elaborate_scope(des, scope); @@ -351,13 +351,32 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const } } +/* + * Elaborate the datum within the module. This variable make be + * within a subscope (i.e. a function or task) so use the components + * of the name to find the precise scope where this item goes. + */ void PData::elaborate_scope(Design*des, NetScope*scope) const { - assert(hname_.component_count() == 1); + NetScope*sub_scope = scope; + for (unsigned idx = 0 ; idx < (hname_.component_count()-1); idx += 1) { + sub_scope = sub_scope->child(hname_.peek_name(idx)); + + if (sub_scope == 0) { + cerr << get_line() << ": internal error: " + << "Could not find sub-scope " + << hname_.peek_name(idx) << " of " + << hname_ << " in module " << scope->name() + << endl; + des->errors += 1; + return; + } + } + const char*basename = hname_.peek_tail_name(); NetVariable*tmp = new NetVariable(lex_strings.add(basename)); tmp->set_line(*this); - scope->add_variable(tmp); + sub_scope->add_variable(tmp); } /* @@ -515,6 +534,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const /* * $Log: elab_scope.cc,v $ + * Revision 1.22 2003/06/13 19:10:46 steve + * Properly manage real variables in subscopes. + * * Revision 1.21 2003/05/30 02:55:32 steve * Support parameters in real expressions and * as real expressions, and fix multiply and diff --git a/pform.cc b/pform.cc index 26ed0b0cb..908046017 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.cc,v 1.114 2003/06/13 00:27:09 steve Exp $" +#ident "$Id: pform.cc,v 1.115 2003/06/13 19:10:46 steve Exp $" #endif # include "config.h" @@ -610,10 +610,11 @@ void pform_make_events(list*names, const char*fn, unsigned ln) static void pform_make_datum(const char*name, const char*fn, unsigned ln) { - PData*datum = new PData(hname_t(name)); + hname_t hname = hier_name(name); + PData*datum = new PData(hname); datum->set_file(fn); datum->set_lineno(ln); - pform_cur_module->datum[name] = datum; + pform_cur_module->datum[hname] = datum; } void pform_make_reals(list*names, const char*fn, unsigned ln) @@ -1469,6 +1470,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.115 2003/06/13 19:10:46 steve + * Properly manage real variables in subscopes. + * * Revision 1.114 2003/06/13 00:27:09 steve * Task/functions can have signed ports. * diff --git a/pform_dump.cc b/pform_dump.cc index 27ac30d0d..b019ce9f5 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform_dump.cc,v 1.79 2003/02/27 06:45:11 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.80 2003/06/13 19:10:46 steve Exp $" #endif # include "config.h" @@ -761,7 +761,7 @@ void Module::dump(ostream&out) const << ev->get_line() << endl; } - for (map::const_iterator cur = datum.begin() + for (map::const_iterator cur = datum.begin() ; cur != datum.end() ; cur ++ ) { PData*tmp = (*cur).second; out << " real " << tmp->name() << "; // " @@ -863,6 +863,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.80 2003/06/13 19:10:46 steve + * Properly manage real variables in subscopes. + * * Revision 1.79 2003/02/27 06:45:11 steve * specparams as far as pform. *