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

Integer constants in nmigen.compat Instance ports fail #249

Closed
rroohhh opened this issue Oct 12, 2019 · 1 comment
Closed

Integer constants in nmigen.compat Instance ports fail #249

rroohhh opened this issue Oct 12, 2019 · 1 comment
Labels
Milestone

Comments

@rroohhh
Copy link
Contributor

rroohhh commented Oct 12, 2019

Using a integer constant in a Instance port like this

from nmigen.compat import *
from nmigen.back import verilog

# from migen import *
# import migen.fhdl.verilog as verilog

class A(Module):
    def __init__(self):
        self.specials += Instance("a", i_in = 0)

print(verilog.convert(A()))

fails when using nmigen.compat with this error message:

a.py:9: DeprecationWarning: instead of `self.specials +=`, use `m.submodules +=`
  self.specials += Instance("a", i_in = 0)
Traceback (most recent call last):
  File "a.py", line 11, in <module>
    print(verilog.convert(A()))
  File "/data/projects/nmigen/nmigen/back/verilog.py", line 74, in convert
    rtlil_text = rtlil.convert(*args, **kwargs)
  File "/data/projects/nmigen/nmigen/back/rtlil.py", line 988, in convert
    fragment = ir.Fragment.get(elaboratable, platform).prepare(**kwargs)
  File "/data/projects/nmigen/nmigen/hdl/ir.py", line 536, in prepare
    fragment = SampleLowerer()(self)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 315, in __call__
    return self.on_fragment(value)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 307, in on_fragment
    self.map_subfragments(fragment, new_fragment)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 270, in map_subfragments
    new_fragment.add_subfragment(self(subfragment), name)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 315, in __call__
    return self.on_fragment(value)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 301, in on_fragment
    self.map_named_ports(fragment, new_fragment)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 279, in map_named_ports
    new_fragment.named_ports[name] = self.on_value(value), dir
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 128, in on_value
    new_value = self.on_unknown_value(value)
  File "/data/projects/nmigen/nmigen/hdl/xfrm.py", line 86, in on_unknown_value
    raise TypeError("Cannot transform value '{!r}'".format(value)) # :nocov:
TypeError: Cannot transform value '0'

but worked in oMigen.

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

Indeed. Actually, it also fails in nMigen, and I don't think there's any especially good reason it should.

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