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

Misleading error when trying to use self.comb when inheriting from Module #286

Closed
asumagic opened this issue Dec 26, 2019 · 2 comments
Closed
Milestone

Comments

@asumagic
Copy link

Consider the following migen code:

class ORGate(Module):
	def __init__(self):
		self.a = Signal()
		self.b = Signal()
		self.x = Signal()

		self.comb += self.x.eq(self.a | self.b)

While this is not the valid way to implement this in nmigen, if you try to use this code as-is in nmigen, the error is misleading:

  File "/usr/lib/python3.8/site-packages/nmigen/hdl/dsl.py", line 75, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'; did you mean 'd.{}'?"
AttributeError: 'ORGate' object has no attribute 'comb'; did you mean 'd.comb'?

If my understanding is right, the direct alternative to the above code in nmigen is to inherit from Elaboratable and use the elaborate() mechanism.
In that case, the error check should hint at this accordingly, instead of incorrectly hinting to use d.comb.

@whitequark
Copy link
Contributor

whitequark commented Feb 1, 2020

Fixed in my fork.

@sbourdeauducq
Copy link
Member

Merged upstream.

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

No branches or pull requests

3 participants