Associate signals with scopes rather than entities

This commit is contained in:
Nick Gasson 2008-06-25 18:12:57 +01:00
parent 43c671cb5c
commit 44aa8a6b91
4 changed files with 16 additions and 13 deletions

View File

@ -41,12 +41,12 @@ static vhdl_var_ref *translate_signal(ivl_expr_t e)
{ {
ivl_signal_t sig = ivl_expr_signal(e); ivl_signal_t sig = ivl_expr_signal(e);
const vhdl_entity *ent = find_entity_for_signal(sig); const vhdl_scope *scope = find_scope_for_signal(sig);
assert(ent); assert(scope);
const char *renamed = get_renamed_signal(sig).c_str(); const char *renamed = get_renamed_signal(sig).c_str();
const vhdl_decl *decl = ent->get_arch()->get_scope()->get_decl(strip_var(renamed)); const vhdl_decl *decl = scope->get_decl(strip_var(renamed));
assert(decl); assert(decl);
vhdl_type *type = new vhdl_type(*decl->get_type()); vhdl_type *type = new vhdl_type(*decl->get_type());

View File

@ -141,7 +141,7 @@ static void declare_signals(vhdl_entity *ent, ivl_scope_t scope)
else else
sig_type = vhdl_type::nunsigned(width); sig_type = vhdl_type::nunsigned(width);
remember_signal(sig, ent); remember_signal(sig, ent->get_arch()->get_scope());
// Make sure the signal name conforms to VHDL naming rules // Make sure the signal name conforms to VHDL naming rules
std::string name(ivl_signal_basename(sig)); std::string name(ivl_signal_basename(sig));
@ -381,8 +381,11 @@ int draw_function(ivl_scope_t scope, ivl_scope_t parent)
vhdl_function *func = new vhdl_function(funcname, vhdl_type::std_logic()); vhdl_function *func = new vhdl_function(funcname, vhdl_type::std_logic());
ent->get_arch()->get_scope()->add_decl(func); int nports = ivl_scope_ports(scope);
std::cout << "function has " << nports << " ports" << std::endl;
ent->get_arch()->get_scope()->add_decl(func);
return 0; return 0;
} }

View File

@ -38,8 +38,8 @@
* defined. * defined.
*/ */
struct signal_defn_t { struct signal_defn_t {
std::string renamed; // The name of the VHDL signal std::string renamed; // The name of the VHDL signal
const vhdl_entity *ent; // The entity where it is defined const vhdl_scope *scope; // The scope where it is defined
}; };
typedef std::map<ivl_signal_t, signal_defn_t> signal_defn_map_t; typedef std::map<ivl_signal_t, signal_defn_t> signal_defn_map_t;
@ -93,11 +93,11 @@ void remember_entity(vhdl_entity* ent)
/* /*
* Remeber the association of signal to entity. * Remeber the association of signal to entity.
*/ */
void remember_signal(ivl_signal_t sig, const vhdl_entity *ent) void remember_signal(ivl_signal_t sig, const vhdl_scope *scope)
{ {
assert(g_known_signals.find(sig) == g_known_signals.end()); assert(g_known_signals.find(sig) == g_known_signals.end());
signal_defn_t defn = { ivl_signal_basename(sig), ent }; signal_defn_t defn = { ivl_signal_basename(sig), scope };
g_known_signals[sig] = defn; g_known_signals[sig] = defn;
} }
@ -111,11 +111,11 @@ void rename_signal(ivl_signal_t sig, const std::string &renamed)
g_known_signals[sig].renamed = renamed; g_known_signals[sig].renamed = renamed;
} }
const vhdl_entity *find_entity_for_signal(ivl_signal_t sig) const vhdl_scope *find_scope_for_signal(ivl_signal_t sig)
{ {
assert(g_known_signals.find(sig) != g_known_signals.end()); assert(g_known_signals.find(sig) != g_known_signals.end());
return g_known_signals[sig].ent; return g_known_signals[sig].scope;
} }
const std::string &get_renamed_signal(ivl_signal_t sig) const std::string &get_renamed_signal(ivl_signal_t sig)

View File

@ -27,9 +27,9 @@ vhdl_entity *get_active_entity();
vhdl_var_ref *nexus_to_var_ref(vhdl_scope *arch_scope, ivl_nexus_t nexus); vhdl_var_ref *nexus_to_var_ref(vhdl_scope *arch_scope, ivl_nexus_t nexus);
void remember_signal(ivl_signal_t sig, const vhdl_entity *ent); void remember_signal(ivl_signal_t sig, const vhdl_scope *scope);
void rename_signal(ivl_signal_t sig, const std::string &renamed); void rename_signal(ivl_signal_t sig, const std::string &renamed);
const vhdl_entity *find_entity_for_signal(ivl_signal_t sig); const vhdl_scope *find_scope_for_signal(ivl_signal_t sig);
const std::string &get_renamed_signal(ivl_signal_t sig); const std::string &get_renamed_signal(ivl_signal_t sig);
void blocking_assign_to(vhdl_procedural *proc, ivl_signal_t sig); void blocking_assign_to(vhdl_procedural *proc, ivl_signal_t sig);