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

SyntaxError when wishbone.Decoder data width is equal to granularity #4

Closed
nmigen-issue-migration opened this issue Jan 23, 2020 · 0 comments · Fixed by #14
Closed
Labels

Comments

@nmigen-issue-migration
Copy link

Issue by jfng
Thursday Jan 23, 2020 at 11:44 GMT
Originally opened as m-labs/nmigen-soc#4


Repro:

from nmigen import *
from nmigen.back import rtlil
from nmigen_soc import wishbone


class Top(Elaboratable):
    def elaborate(self, platform):
        m = Module()

        m.submodules.dec = dec = wishbone.Decoder(addr_width=5, data_width=8, granularity=8)
        bus = wishbone.Interface(addr_width=4, data_width=8, granularity=8)
        dec.add(bus)

        return m


if __name__ == "__main__":
    print(rtlil.convert(Top()))

Output:

Traceback (most recent call last):
  File "repro.py", line 18, in <module>
    print(rtlil.convert(Top()))
  File "/home/jf/src/nmigen/nmigen/back/rtlil.py", line 1007, in convert
    fragment = ir.Fragment.get(elaboratable, platform).prepare(**kwargs)
  File "/home/jf/src/nmigen/nmigen/hdl/ir.py", line 67, in get
    obj = obj.elaborate(platform)
  File "/home/jf/src/nmigen/nmigen/hdl/dsl.py", line 484, in elaborate
    fragment.add_subfragment(Fragment.get(self._named_submodules[name], platform), name)
  File "/home/jf/src/nmigen/nmigen/hdl/ir.py", line 67, in get
    obj = obj.elaborate(platform)
  File "/home/jf/src/nmigen-soc/nmigen_soc/wishbone/bus.py", line 247, in elaborate
    with m.Case(sub_pat[:-log2_int(self.bus.data_width // self.bus.granularity)]):
  File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/home/jf/src/nmigen/nmigen/hdl/dsl.py", line 283, in Case
    .format(pattern, len(switch_data["test"])))
nmigen.hdl.dsl.SyntaxError: Case pattern '' must have the same width as switch value (which is 5)
jfng pushed a commit to jfng/amaranth-soc that referenced this issue Mar 24, 2020
whitequark pushed a commit that referenced this issue Mar 24, 2020
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.

1 participant