diff --git a/Makefile.in b/Makefile.in index 815655321..80127b0e9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,7 +16,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.153 2003/09/17 04:30:33 steve Exp $" +#ident "$Id: Makefile.in,v 1.154 2003/09/19 03:30:04 steve Exp $" # # SHELL = /bin/sh @@ -124,7 +124,7 @@ net_design.o net_event.o net_expr.o net_force.o net_func.o \ net_link.o net_modulo.o net_nex_input.o net_nex_output.o \ net_proc.o net_scope.o net_udp.o net_variable.o pad_to_width.o \ parse.o parse_misc.o pform.o pform_dump.o \ -set_width.o sync.o \ +set_width.o symbol_search.o sync.o \ verinum.o verireal.o target.o targets.o \ Attrib.o HName.o LineInfo.o Module.o PData.o PDelays.o PEvent.o \ PExpr.o PGate.o \ diff --git a/elab_expr.cc b/elab_expr.cc index debaf211f..42ba26ba0 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -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.80 2003/06/24 01:38:02 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.81 2003/09/19 03:30:05 steve Exp $" #endif # include "config.h" @@ -462,15 +462,22 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, bool sys_task_arg) const { assert(scope); - NetScope*found_in; + + NetNet* net = 0; + NetMemory* mem = 0; + NetVariable* var = 0; + const NetExpr*par = 0; + NetEvent* eve = 0; + + NetScope*found_in = symbol_search(des, scope, path_, + net, mem, var, par, eve); // If the identifier name is a parameter name, then return // a reference to the parameter expression. - if (const NetExpr*ex = des->find_parameter(scope, path_, found_in)) { + if (par != 0) { NetExpr*tmp; - assert(ex); - tmp = ex->dup_expr(); + tmp = par->dup_expr(); if (msb_ && lsb_) { /* If the parameter has a part select, we support @@ -606,7 +613,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, // If the identifier names a signal (a register or wire) // then create a NetESignal node to handle it. - if (NetNet*net = des->find_signal(scope, path_)) { + if (net != 0) { // If this is a part select of a signal, then make a new // temporary signal that is connected to just the @@ -730,7 +737,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, // If the identifier names a memory, then this is a // memory reference and I must generate a NetEMemory // object to handle it. - if (NetMemory*mem = des->find_memory(scope, path_)) { + if (mem != 0) { if (msb_ == 0) { // If this memory is an argument to a system task, @@ -774,8 +781,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, // If the identifier names a variable of some sort, then this // is a variable reference. - if (NetVariable*var = des->find_variable(scope, path_)) { - + if (var != 0) { NetEVariable*node = new NetEVariable(var); node->set_line(*this); return node; @@ -783,8 +789,8 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, // If the identifier is a named event. // is a variable reference. - if (NetEvent*nev = des->find_event(scope, path_)) { - NetEEvent*tmp = new NetEEvent(nev); + if (eve != 0) { + NetEEvent*tmp = new NetEEvent(eve); tmp->set_line(*this); return tmp; } @@ -964,6 +970,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const /* * $Log: elab_expr.cc,v $ + * Revision 1.81 2003/09/19 03:30:05 steve + * Fix name search in elab_lval. + * * Revision 1.80 2003/06/24 01:38:02 steve * Various warnings fixed. * diff --git a/elab_lval.cc b/elab_lval.cc index fe2709cd5..845b34513 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -17,13 +17,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_lval.cc,v 1.26 2003/01/27 05:09:17 steve Exp $" +#ident "$Id: elab_lval.cc,v 1.27 2003/09/19 03:30:05 steve Exp $" #endif # include "config.h" # include "PExpr.h" # include "netlist.h" +# include "netmisc.h" # include @@ -138,25 +139,27 @@ NetAssign_* PEConcat::elaborate_lval(Design*des, NetScope*scope) const /* * Handle the ident as an l-value. This includes bit and part selects * of that ident. - * - * XXXX FIXME: The search order looks for signals all the way up the - * scope tree, then looks for memories then variables. It should be - * looking for signals, memories and variables in parallel. */ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const { - NetNet*reg = des->find_signal(scope, path_); + NetNet* reg = 0; + NetMemory* mem = 0; + NetVariable* var = 0; + const NetExpr*par = 0; + NetEvent* eve = 0; + + symbol_search(des, scope, path_, reg, mem, var, par, eve); + + if (mem) { + return elaborate_mem_lval_(des, scope, mem); + } + + if (var) { + NetAssign_*cur = new NetAssign_(var); + return cur; + } if (reg == 0) { - if (NetMemory*mem = des->find_memory(scope, path_)) { - return elaborate_mem_lval_(des, scope, mem); - } - - if (NetVariable*var = des->find_variable(scope, path_)) { - NetAssign_*cur = new NetAssign_(var); - return cur; - } - cerr << get_line() << ": error: Could not find variable ``" << path_ << "'' in ``" << scope->name() << "''" << endl; @@ -347,6 +350,9 @@ NetAssign_* PENumber::elaborate_lval(Design*des, NetScope*) const /* * $Log: elab_lval.cc,v $ + * Revision 1.27 2003/09/19 03:30:05 steve + * Fix name search in elab_lval. + * * Revision 1.26 2003/01/27 05:09:17 steve * Spelling fixes. * diff --git a/net_design.cc b/net_design.cc index d2bb72e94..c44663c83 100644 --- a/net_design.cc +++ b/net_design.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: net_design.cc,v 1.38 2003/08/28 04:11:19 steve Exp $" +#ident "$Id: net_design.cc,v 1.39 2003/09/19 03:30:05 steve Exp $" #endif # include "config.h" @@ -586,29 +586,6 @@ NetEvent* Design::find_event(NetScope*scope, const hname_t&p) return 0; } -NetVariable* Design::find_variable(NetScope*scope, const hname_t&p) -{ - hname_t path = p; - assert(scope); - - char*key = path.remove_tail_name(); - if (path.peek_name(0)) - scope = find_scope(scope, path); - - while (scope) { - if (NetVariable*ev = scope->find_variable(key)) { - delete key; - return ev; - } - - if (scope->type() == NetScope::MODULE) - break; - scope = scope->parent(); - } - - delete key; - return 0; -} void Design::add_node(NetNode*net) { @@ -685,6 +662,9 @@ void Design::delete_process(NetProcTop*top) /* * $Log: net_design.cc,v $ + * Revision 1.39 2003/09/19 03:30:05 steve + * Fix name search in elab_lval. + * * Revision 1.38 2003/08/28 04:11:19 steve * Spelling patch. * diff --git a/netlist.h b/netlist.h index 3fc1bbde0..cf8e168f5 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.h,v 1.299 2003/09/13 01:01:52 steve Exp $" +#ident "$Id: netlist.h,v 1.300 2003/09/19 03:30:05 steve Exp $" #endif /* @@ -3233,9 +3233,6 @@ class Design { // Events NetEvent* find_event(NetScope*scope, const hname_t&path); - // Variables - NetVariable* find_variable(NetScope*scope, const hname_t&path); - // NODES void add_node(NetNode*); void del_node(NetNode*); @@ -3322,6 +3319,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.300 2003/09/19 03:30:05 steve + * Fix name search in elab_lval. + * * Revision 1.299 2003/09/13 01:01:52 steve * Spelling fixes. * diff --git a/netmisc.h b/netmisc.h index 678c400a2..36fcf60a7 100644 --- a/netmisc.h +++ b/netmisc.h @@ -19,11 +19,28 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netmisc.h,v 1.17 2003/01/30 16:23:08 steve Exp $" +#ident "$Id: netmisc.h,v 1.18 2003/09/19 03:30:05 steve Exp $" #endif # include "netlist.h" +/* + * Search for a symbol using the "start" scope as the starting + * point. If the path includes a scope part, then locate the + * scope first. + * + * The return value is the scope where the symbol was found. + * If the symbol was not found, return 0. The output arguments + * get 0 except for the pointer to the object that represents + * the located symbol. + */ +extern NetScope* symbol_search(Design*des, NetScope*start, hname_t path, + NetNet*&net, /* net/reg */ + NetMemory*&mem, /* memory */ + NetVariable*&var, /* real/realtime */ + const NetExpr*&par,/* parameter */ + NetEvent*&eve /* named event */); + /* * This function transforms an expression by padding the high bits * with V0 until the expression has the desired width. This may mean @@ -57,6 +74,9 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe); /* * $Log: netmisc.h,v $ + * Revision 1.18 2003/09/19 03:30:05 steve + * Fix name search in elab_lval. + * * Revision 1.17 2003/01/30 16:23:08 steve * Spelling fixes. * diff --git a/symbol_search.cc b/symbol_search.cc new file mode 100644 index 000000000..368c9d19a --- /dev/null +++ b/symbol_search.cc @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2003 Stephen Williams (steve@icarus.com) + * + * This source code is free software; you can redistribute it + * and/or modify it in source code form under the terms of the GNU + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#ifdef HAVE_CVS_IDENT +#ident "$Id: symbol_search.cc,v 1.1 2003/09/19 03:30:05 steve Exp $" +#endif + +# include "netlist.h" +# include + + +/* + * Search for the hierarchical name. + */ +NetScope*symbol_search(Design*des, NetScope*scope, hname_t path, + NetNet*&net, + NetMemory*&mem, + NetVariable*&var, + const NetExpr*&par, + NetEvent*&eve) +{ + assert(scope); + + /* Get the tail name of the object we are looking for. */ + char*key = path.remove_tail_name(); + + /* Initialize output argument to cleared. */ + net = 0; + mem = 0; + var = 0; + par = 0; + eve = 0; + + /* If the path has a scope part, then search for the specified + scope that we are supposed to search. */ + if (path.peek_name(0)) + scope = des->find_scope(scope, path); + + while (scope) { + if ( (net = scope->find_signal(key)) ) { + delete key; + return scope; + } + + if ( (mem = scope->find_memory(key)) ) { + delete key; + return scope; + } + + if ( (var = scope->find_variable(key)) ) { + delete key; + return scope; + } + + if ( (eve = scope->find_event(key)) ) { + delete key; + return scope; + } + + if ( (par = scope->get_parameter(key)) ) { + delete key; + return scope; + } + + if (scope->type() == NetScope::MODULE) + scope = 0; + else + scope = scope->parent(); + } + + delete key; + return 0; +} + +/* + * $Log: symbol_search.cc,v $ + * Revision 1.1 2003/09/19 03:30:05 steve + * Fix name search in elab_lval. + * + */ +