2003-09-19 05:30:04 +02:00
|
|
|
/*
|
|
|
|
|
* 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
|
2007-06-02 05:42:12 +02:00
|
|
|
#ident "$Id: symbol_search.cc,v 1.7 2007/06/02 03:42:13 steve Exp $"
|
2003-09-19 05:30:04 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "netlist.h"
|
2007-06-02 05:42:12 +02:00
|
|
|
# include "netmisc.h"
|
2003-09-19 05:30:04 +02:00
|
|
|
# include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Search for the hierarchical name.
|
|
|
|
|
*/
|
2007-06-02 05:42:12 +02:00
|
|
|
NetScope*symbol_search(Design*des, NetScope*scope, pform_name_t path,
|
2003-09-19 05:30:04 +02:00
|
|
|
NetNet*&net,
|
|
|
|
|
const NetExpr*&par,
|
2005-11-27 06:56:20 +01:00
|
|
|
NetEvent*&eve,
|
|
|
|
|
const NetExpr*&ex1, const NetExpr*&ex2)
|
2003-09-19 05:30:04 +02:00
|
|
|
{
|
|
|
|
|
assert(scope);
|
|
|
|
|
|
|
|
|
|
/* Get the tail name of the object we are looking for. */
|
2007-05-24 06:07:11 +02:00
|
|
|
perm_string key = peek_tail_name(path);
|
|
|
|
|
path.pop_back();
|
2003-09-19 05:30:04 +02:00
|
|
|
|
|
|
|
|
/* Initialize output argument to cleared. */
|
|
|
|
|
net = 0;
|
|
|
|
|
par = 0;
|
|
|
|
|
eve = 0;
|
|
|
|
|
|
|
|
|
|
/* If the path has a scope part, then search for the specified
|
|
|
|
|
scope that we are supposed to search. */
|
2007-06-02 05:42:12 +02:00
|
|
|
if (! path.empty()) {
|
|
|
|
|
list<hname_t> path_list = eval_scope_path(des, scope, path);
|
2007-07-23 06:55:35 +02:00
|
|
|
assert(path_list.size() <= path.size());
|
|
|
|
|
|
|
|
|
|
// If eval_scope_path returns a short list, then some
|
|
|
|
|
// part of the scope was not found. Abort.
|
|
|
|
|
if (path_list.size() < path.size())
|
|
|
|
|
return 0;
|
|
|
|
|
|
2007-06-02 05:42:12 +02:00
|
|
|
scope = des->find_scope(scope, path_list);
|
|
|
|
|
}
|
2003-09-19 05:30:04 +02:00
|
|
|
|
|
|
|
|
while (scope) {
|
2007-04-26 05:06:21 +02:00
|
|
|
if ( (net = scope->find_signal(key)) )
|
2003-09-19 05:30:04 +02:00
|
|
|
return scope;
|
|
|
|
|
|
2007-04-26 05:06:21 +02:00
|
|
|
if ( (eve = scope->find_event(key)) )
|
2003-09-19 05:30:04 +02:00
|
|
|
return scope;
|
|
|
|
|
|
2007-04-26 05:06:21 +02:00
|
|
|
if ( (par = scope->get_parameter(key, ex1, ex2)) )
|
2003-09-19 05:30:04 +02:00
|
|
|
return scope;
|
|
|
|
|
|
|
|
|
|
if (scope->type() == NetScope::MODULE)
|
|
|
|
|
scope = 0;
|
|
|
|
|
else
|
|
|
|
|
scope = scope->parent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|