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

AssertionError with strange Switch #305

Closed
nmigen-issue-migration opened this issue Jan 13, 2020 · 0 comments
Closed

AssertionError with strange Switch #305

nmigen-issue-migration opened this issue Jan 13, 2020 · 0 comments
Labels
Milestone

Comments

@nmigen-issue-migration
Copy link

Issue by ZirconiumX
Monday Jan 13, 2020 at 20:31 GMT
Originally opened as m-labs/nmigen#305


from enum import Enum

from nmigen import *
from nmigen.back import verilog


class Piece(Enum):
    BISHOP = 2 # Has to be specifically > 1 to crash


class Square(Elaboratable):
    def __init__(self):
        self.i_piece = Signal(1)

    def elaborate(self, platform):
        m = Module()

        with m.Switch(self.i_piece):
            with m.Case(Piece.BISHOP): # Has to be this enum; inlining the value of 2 works fine
                pass

        return m


sq = Square()

print(verilog.convert(sq, ports=[sq.i_piece]))

This produces:

Traceback (most recent call last):
  File "testcase.py", line 27, in <module>
    print(verilog.convert(sq, ports=[sq.i_piece]))
  File "/usr/local/lib/python3.7/dist-packages/nmigen-0.2.dev17+ge18385b-py3.7.egg/nmigen/back/verilog.py", line 76, in convert
    rtlil_text = rtlil.convert(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/nmigen-0.2.dev17+ge18385b-py3.7.egg/nmigen/back/rtlil.py", line 1010, in convert
    fragment = ir.Fragment.get(elaboratable, platform).prepare(**kwargs)
  File "/usr/local/lib/python3.7/dist-packages/nmigen-0.2.dev17+ge18385b-py3.7.egg/nmigen/hdl/ir.py", line 67, in get       obj = obj.elaborate(platform)
  File "testcase.py", line 20, in elaborate
    pass
  File "/usr/lib/python3.7/contextlib.py", line 119, in __exit__
    next(self.gen)
  File "/usr/local/lib/python3.7/dist-packages/nmigen-0.2.dev17+ge18385b-py3.7.egg/nmigen/hdl/dsl.py", line 264, in Switch
    self._pop_ctrl()
  File "/usr/local/lib/python3.7/dist-packages/nmigen-0.2.dev17+ge18385b-py3.7.egg/nmigen/hdl/dsl.py", line 405, in _pop_ctrl
    src_loc=src_loc, case_src_locs=switch_case_src_locs))
  File "/usr/local/lib/python3.7/dist-packages/nmigen-0.2.dev17+ge18385b-py3.7.egg/nmigen/hdl/ast.py", line 1296, in __init__
    assert len(key) == len(self.test)
AssertionError

It minimised very oddly, but this is the smallest I could get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant