Careful not to lose bits parameter add expression
[iverilog.git] / symbol_search.cc
blob399b2c65ad32f989766f967ca26815c831453947
1 /*
2 * Copyright (c) 2003 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: symbol_search.cc,v 1.7 2007/06/02 03:42:13 steve Exp $"
21 #endif
23 # include "netlist.h"
24 # include "netmisc.h"
25 # include <assert.h>
29 * Search for the hierarchical name.
31 NetScope*symbol_search(Design*des, NetScope*scope, pform_name_t path,
32 NetNet*&net,
33 const NetExpr*&par,
34 NetEvent*&eve,
35 const NetExpr*&ex1, const NetExpr*&ex2)
37 assert(scope);
39 /* Get the tail name of the object we are looking for. */
40 perm_string key = peek_tail_name(path);
41 path.pop_back();
43 /* Initialize output argument to cleared. */
44 net = 0;
45 par = 0;
46 eve = 0;
48 /* If the path has a scope part, then search for the specified
49 scope that we are supposed to search. */
50 if (! path.empty()) {
51 list<hname_t> path_list = eval_scope_path(des, scope, path);
52 assert(path_list.size() == path.size());
53 scope = des->find_scope(scope, path_list);
56 while (scope) {
57 if ( (net = scope->find_signal(key)) )
58 return scope;
60 if ( (eve = scope->find_event(key)) )
61 return scope;
63 if ( (par = scope->get_parameter(key, ex1, ex2)) )
64 return scope;
66 if (scope->type() == NetScope::MODULE)
67 scope = 0;
68 else
69 scope = scope->parent();
72 return 0;
77 * $Log: symbol_search.cc,v $
78 * Revision 1.7 2007/06/02 03:42:13 steve
79 * Properly evaluate scope path expressions.
81 * Revision 1.6 2007/05/24 04:07:12 steve
82 * Rework the heirarchical identifier parse syntax and pform
83 * to handle more general combinations of heirarch and bit selects.
85 * Revision 1.5 2007/04/26 03:06:22 steve
86 * Rework hname_t to use perm_strings.
88 * Revision 1.4 2007/01/16 05:44:15 steve
89 * Major rework of array handling. Memories are replaced with the
90 * more general concept of arrays. The NetMemory and NetEMemory
91 * classes are removed from the ivl core program, and the IVL_LPM_RAM
92 * lpm type is removed from the ivl_target API.
94 * Revision 1.3 2005/11/27 05:56:20 steve
95 * Handle bit select of parameter with ranges.
97 * Revision 1.2 2005/07/11 16:56:51 steve
98 * Remove NetVariable and ivl_variable_t structures.
100 * Revision 1.1 2003/09/19 03:30:05 steve
101 * Fix name search in elab_lval.