Fix a bug where the same instantiation appeared multiple times
This commit is contained in:
parent
041925c123
commit
17ae0a6a09
|
|
@ -80,22 +80,33 @@ static int draw_module(ivl_scope_t scope, ivl_scope_t parent)
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
vhdl_entity *parent_ent = find_entity(ivl_scope_tname(parent));
|
vhdl_entity *parent_ent = find_entity(ivl_scope_tname(parent));
|
||||||
assert(parent_ent != NULL);
|
assert(parent_ent != NULL);
|
||||||
vhdl_arch *parent_arch = parent_ent->get_arch();
|
|
||||||
assert(parent_arch != NULL);
|
|
||||||
|
|
||||||
// Create a forward declaration for it
|
|
||||||
if (!parent_arch->have_declared_component(ent->get_name())) {
|
// Make sure we only collect instantiations from *one*
|
||||||
vhdl_decl *comp_decl = vhdl_component_decl::component_decl_for(ent);
|
// example of this module in the hieararchy
|
||||||
parent_arch->add_decl(comp_decl);
|
if (parent_ent->get_derived_from() == ivl_scope_name(parent)) {
|
||||||
|
|
||||||
|
vhdl_arch *parent_arch = parent_ent->get_arch();
|
||||||
|
assert(parent_arch != NULL);
|
||||||
|
|
||||||
|
// Create a forward declaration for it
|
||||||
|
if (!parent_arch->have_declared_component(ent->get_name())) {
|
||||||
|
vhdl_decl *comp_decl = vhdl_component_decl::component_decl_for(ent);
|
||||||
|
parent_arch->add_decl(comp_decl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// And an instantiation statement
|
||||||
|
const char *inst_name = ivl_scope_basename(scope);
|
||||||
|
vhdl_comp_inst *inst = new vhdl_comp_inst(inst_name, ent->get_name().c_str());
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << "Generated from " << ivl_scope_name(scope);
|
||||||
|
inst->set_comment(ss.str());
|
||||||
|
parent_arch->add_stmt(inst);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Ignoring instantiation " << ivl_scope_name(scope);
|
||||||
|
std::cout << " (already accounted for)" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And an instantiation statement
|
|
||||||
const char *inst_name = ivl_scope_basename(scope);
|
|
||||||
vhdl_comp_inst *inst = new vhdl_comp_inst(inst_name, ent->get_name().c_str());
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "Scope name " << ivl_scope_name(scope);
|
|
||||||
inst->set_comment(ss.str());
|
|
||||||
parent_arch->add_stmt(inst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue