Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nesting Parts with a variable offset throws an AssertionError #605

Closed
jfng opened this issue Apr 6, 2021 · 0 comments · Fixed by #650
Closed

Nesting Parts with a variable offset throws an AssertionError #605

jfng opened this issue Apr 6, 2021 · 0 comments · Fixed by #650
Labels
Milestone

Comments

@jfng
Copy link
Contributor

jfng commented Apr 6, 2021

Repro:

from nmigen import *
from nmigen.back import rtlil

m = Module()

data = Signal(4)
sel  = Signal()

part_0 = data.word_select(sel, width=2)
part_1 = part_0.word_select(0, width=1)

m.d.comb += part_1.eq(1)

print(rtlil.convert(m, ports=[data, sel]))

Output:

Traceback (most recent call last):
  File "/tmp/repro.py", line 14, in <module>
    print(rtlil.convert(m, ports=[data, sel]))
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 1054, in convert
    il_text, name_map = convert_fragment(fragment, name)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 1048, in convert_fragment
    _convert_fragment(builder, fragment, name_map, hierarchy=(name,))
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 942, in _convert_fragment
    stmt_compiler(group_stmts)
  File "/home/jf/src/nmigen/nmigen/hdl/xfrm.py", line 232, in __call__
    return self.on_statement(stmt)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 783, in on_statement
    super().on_statement(stmt)
  File "/home/jf/src/nmigen/nmigen/hdl/xfrm.py", line 220, in on_statement
    new_stmt = self.on_statements(stmt)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 801, in on_statements
    self.on_statement(stmt)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 783, in on_statement
    super().on_statement(stmt)
  File "/home/jf/src/nmigen/nmigen/hdl/xfrm.py", line 209, in on_statement
    new_stmt = self.on_Assign(stmt)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 731, in on_Assign
    self._case.assign(self.lhs_compiler(stmt.lhs), rhs_sigspec)
  File "/home/jf/src/nmigen/nmigen/hdl/xfrm.py", line 127, in __call__
    return self.on_value(value)
  File "/home/jf/src/nmigen/nmigen/hdl/xfrm.py", line 104, in on_value
    new_value = self.on_Slice(value)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 398, in on_Slice
    sigspec = self._prepare_value_for_Slice(value.value)
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 661, in _prepare_value_for_Slice
    assert isinstance(value, (ast.Signal, ast.Slice, ast.Cat))
AssertionError

This error does not occur if sel is replaced by a constant offset in the above repro.

@whitequark whitequark added the bug label Dec 11, 2021
modwizcode added a commit to modwizcode/amaranth that referenced this issue Dec 11, 2021
whitequark pushed a commit that referenced this issue Dec 11, 2021
@whitequark whitequark added this to the 0.3 milestone Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants