Skip to content

Commit

Permalink
Fix elaboration so alias registers inherit primary instance's interna…
Browse files Browse the repository at this point in the history
…l/external type. #123
  • Loading branch information
amykyta3 committed Mar 4, 2022
1 parent ec825a6 commit ee42ee7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions systemrdl/core/ComponentVisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,14 @@ def resolve_inst_external(self, ctx: SystemRDLParser.Component_instsContext, com
src_ref_from_antlr(inst_type)
)
elif isinstance(comp_inst, comp.Reg):
comp_inst.external = False
if (inst_type is not None) and (inst_type.type == SystemRDLParser.EXTERNAL_kw):
comp_inst.external = True
if inst_type is not None:
if inst_type.type == SystemRDLParser.EXTERNAL_kw:
comp_inst.external = True
elif inst_type.type == SystemRDLParser.INTERNAL_kw:
comp_inst.external = False
else:
# Leave as None. Elaborate step will resolve later.
comp_inst.external = None

elif isinstance(comp_inst, comp.Regfile):
if inst_type is not None:
Expand Down
6 changes: 6 additions & 0 deletions systemrdl/core/elaborate.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,12 @@ def enter_Reg(self, node: RegNode) -> None:
if self.coerce_external_to is not None:
# Is nested inside regfile that is coercing to a particular inst type
node.inst.external = self.coerce_external_to
elif node.inst.external is None:
assert isinstance(node.inst, comp.Reg)
if node.inst.is_alias:
node.inst.external = node.inst.alias_primary_inst.external
else:
node.inst.external = False


def exit_Regfile(self, node: RegfileNode) -> None:
Expand Down

0 comments on commit ee42ee7

Please sign in to comment.