Partial fix for br956 (various enumeration bugs)
This patch fixes the following enumeration bugs: When looking for an enumeration look in the current scope and then recursively in any parent scope. Add enumeration definitions to a package scope.
This commit is contained in:
parent
931039761a
commit
8c3f7d78b9
|
|
@ -687,6 +687,7 @@ bool PPackage::elaborate_scope(Design*des, NetScope*scope)
|
||||||
|
|
||||||
collect_scope_parameters_(des, scope, parameters);
|
collect_scope_parameters_(des, scope, parameters);
|
||||||
collect_scope_localparams_(des, scope, localparams);
|
collect_scope_localparams_(des, scope, localparams);
|
||||||
|
elaborate_scope_enumerations(des, scope, enum_sets);
|
||||||
elaborate_scope_funcs(des, scope, funcs);
|
elaborate_scope_funcs(des, scope, funcs);
|
||||||
elaborate_scope_tasks(des, scope, tasks);
|
elaborate_scope_tasks(des, scope, tasks);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
|
||||||
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
|
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
|
|
@ -1249,7 +1249,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
||||||
|
|
||||||
} else if (enum_type_t*enum_type = dynamic_cast<enum_type_t*>(set_data_type_)) {
|
} else if (enum_type_t*enum_type = dynamic_cast<enum_type_t*>(set_data_type_)) {
|
||||||
list<named_pexpr_t>::const_iterator sample_name = enum_type->names->begin();
|
list<named_pexpr_t>::const_iterator sample_name = enum_type->names->begin();
|
||||||
const netenum_t*use_enum = scope->enumeration_for_name(sample_name->name);
|
const netenum_t*use_enum = scope->find_enumeration_for_name(sample_name->name);
|
||||||
|
|
||||||
if (debug_elaborate) {
|
if (debug_elaborate) {
|
||||||
cerr << get_fileline() << ": debug: Create signal " << wtype
|
cerr << get_fileline() << ": debug: Create signal " << wtype
|
||||||
|
|
|
||||||
18
net_scope.cc
18
net_scope.cc
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -189,6 +189,22 @@ void NetScope::set_line(perm_string file, perm_string def_file,
|
||||||
def_lineno_ = def_lineno;
|
def_lineno_ = def_lineno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look for the enumeration in the current scope and any parent scopes.
|
||||||
|
*/
|
||||||
|
const netenum_t*NetScope::find_enumeration_for_name(perm_string name)
|
||||||
|
{
|
||||||
|
NetScope *cur_scope = this;
|
||||||
|
while (cur_scope) {
|
||||||
|
NetEConstEnum*tmp = cur_scope->enum_names_[name];
|
||||||
|
if (tmp) break;
|
||||||
|
cur_scope = cur_scope->parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(cur_scope);
|
||||||
|
return cur_scope->enum_names_[name]->enumeration();
|
||||||
|
}
|
||||||
|
|
||||||
void NetScope::set_parameter(perm_string key, bool is_annotatable,
|
void NetScope::set_parameter(perm_string key, bool is_annotatable,
|
||||||
PExpr*val, ivl_variable_type_t type__,
|
PExpr*val, ivl_variable_type_t type__,
|
||||||
PExpr*msb, PExpr*lsb, bool signed_flag,
|
PExpr*msb, PExpr*lsb, bool signed_flag,
|
||||||
|
|
|
||||||
|
|
@ -919,6 +919,10 @@ class NetScope : public Definitions, public Attrib {
|
||||||
if a unique name couldn't be generated. */
|
if a unique name couldn't be generated. */
|
||||||
bool auto_name(const char* prefix, char pad, const char* suffix);
|
bool auto_name(const char* prefix, char pad, const char* suffix);
|
||||||
|
|
||||||
|
/* Routine to search for the enumeration given a name. It basically
|
||||||
|
* does what enumeration_for_name() does but searched the hierarchy. */
|
||||||
|
const netenum_t*find_enumeration_for_name(perm_string name);
|
||||||
|
|
||||||
/* Parameters exist within a scope, and these methods allow
|
/* Parameters exist within a scope, and these methods allow
|
||||||
one to manipulate the set. In these cases, the name is the
|
one to manipulate the set. In these cases, the name is the
|
||||||
*simple* name of the parameter, the hierarchy is implicit in
|
*simple* name of the parameter, the hierarchy is implicit in
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue