Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 360bc9b5b462
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 85ae99c1b479
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Apr 21, 2019

  1. back.rtlil: emit nmigen.hierarchy attribute.

    Fixes #54.
    whitequark committed Apr 21, 2019
    Copy the full SHA
    85ae99c View commit details
Showing with 10 additions and 4 deletions.
  1. +10 −4 nmigen/back/rtlil.py
14 changes: 10 additions & 4 deletions nmigen/back/rtlil.py
Original file line number Diff line number Diff line change
@@ -666,7 +666,7 @@ def on_statements(self, stmts):
self.on_statement(stmt)


def convert_fragment(builder, fragment, name, top):
def convert_fragment(builder, fragment, hierarchy):
if isinstance(fragment, ir.Instance):
port_map = OrderedDict()
for port_name, value in fragment.named_ports.items():
@@ -677,7 +677,13 @@ def convert_fragment(builder, fragment, name, top):
else:
return "\\{}".format(fragment.type), port_map

with builder.module(name or "anonymous", attrs={"top": 1} if top else {}) as module:
module_name = hierarchy[-1] or "anonymous"
module_attrs = {}
if len(hierarchy) == 1:
module_attrs["top"] = 1
module_attrs["nmigen.hierarchy"] = ".".join(name or "anonymous" for name in hierarchy)

with builder.module(module_name, attrs=module_attrs) as module:
compiler_state = _ValueCompilerState(module)
rhs_compiler = _RHSValueCompiler(compiler_state)
lhs_compiler = _LHSValueCompiler(compiler_state)
@@ -746,7 +752,7 @@ def convert_fragment(builder, fragment, name, top):
sub_params[param_name] = param_value

sub_type, sub_port_map = \
convert_fragment(builder, subfragment, top=False, name=sub_name)
convert_fragment(builder, subfragment, hierarchy=hierarchy + (sub_name,))

sub_ports = OrderedDict()
for port, value in sub_port_map.items():
@@ -851,5 +857,5 @@ def convert_fragment(builder, fragment, name, top):
def convert(fragment, name="top", **kwargs):
fragment = ir.Fragment.get(fragment, platform=None).prepare(**kwargs)
builder = _Builder()
convert_fragment(builder, fragment, name=name, top=True)
convert_fragment(builder, fragment, hierarchy=(name,))
return str(builder)