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

nmigen.compat Case.makedefault() broken #100

Closed
sbourdeauducq opened this issue Jun 12, 2019 · 3 comments
Closed

nmigen.compat Case.makedefault() broken #100

sbourdeauducq opened this issue Jun 12, 2019 · 3 comments
Labels
Milestone

Comments

@sbourdeauducq
Copy link
Member

Minimal repro:

from nmigen.compat import *

mux = Signal(4)
cases = {0: []}
Case(mux, cases).makedefault()

Result:

Traceback (most recent call last):
  File "foo.py", line 5, in <module>
    Case(mux, cases).makedefault()
  File "/nix/store/vqlpzfgw1k2k5pgby8g7b1kgc4b13g7w-python3-3.7.3-env/lib/python3.7/site-packages/nmigen/tools.py", line 73, in wrapper
    return f(*args, **kwargs)
  File "/nix/store/vqlpzfgw1k2k5pgby8g7b1kgc4b13g7w-python3-3.7.3-env/lib/python3.7/site-packages/nmigen/compat/fhdl/structure.py", line 107, in makedefault
    key = "{:0{}b}".format(wrap(key).value, len(self.test))
  File "/nix/store/vqlpzfgw1k2k5pgby8g7b1kgc4b13g7w-python3-3.7.3-env/lib/python3.7/site-packages/nmigen/tools.py", line 73, in wrapper
    return f(*args, **kwargs)
  File "/nix/store/vqlpzfgw1k2k5pgby8g7b1kgc4b13g7w-python3-3.7.3-env/lib/python3.7/site-packages/nmigen/compat/fhdl/structure.py", line 18, in wrap
    return Value.wrap(v)
  File "/nix/store/vqlpzfgw1k2k5pgby8g7b1kgc4b13g7w-python3-3.7.3-env/lib/python3.7/site-packages/nmigen/hdl/ast.py", line 41, in wrap
    raise TypeError("Object '{!r}' is not an nMigen value".format(obj))
TypeError: Object ''0000'' is not an nMigen value
@sbourdeauducq
Copy link
Member Author

The issue comes from Case turning case values into strings when they are added.

@whitequark whitequark added the bug label Jun 12, 2019
@whitequark
Copy link
Contributor

Hm, I think a lot of that logic is fairly broken, like non-last "default".

@whitequark
Copy link
Contributor

Okay, fixed that and everything else I could see, I think.

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

No branches or pull requests

2 participants