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

Possibly-misleading error when forgetting the number argument to Resource __init__. #599

Closed
cr1901 opened this issue Mar 12, 2021 · 0 comments
Labels
Milestone

Comments

@cr1901
Copy link
Contributor

cr1901 commented Mar 12, 2021

Consider the following, snippet:

from nmigen import *
from nmigen_boards.tinyfpga_ax2 import *
from nmigen.build import *

plat = TinyFPGAAX2Platform()
plat.add_resources([Resource("led", Pins("1", dir="o", conn=("gpio", 0)))])

The above errors with:

$ python mk_build.py
Traceback (most recent call last):
  File "mk_build.py", line 8, in <module>
    plat.add_resources([Resource("led", Pins("gpio:13"))])
  File "C:/msys64/home/william/projects/fpga/nmigen/nmigen/nmigen/build/dsl.py", line 200, in __init__
    super().__init__(name, *args)
  File "C:/msys64/home/william/projects/fpga/nmigen/nmigen/nmigen/build/dsl.py", line 132, in __init__
    raise ValueError("Missing I/O constraints")
ValueError: Missing I/O constraints

Strictly-speaking, I don't think this is a missing I/O constraints problem. It's a "I forgot the number argument to Resource.__init__()" problem. It took me a few seconds to realize my mistake; I can see this error being frustrating to people who are trying to create resources for the first time. The correct code is: plat.add_resources([Resource("led", 0, Pins("1", dir="o", conn=("gpio", 0)))])- I didn't add any I/O constraints :).

I'd create a PR, but it's simply easier for me to open an issue right now :(.

@whitequark whitequark added the bug label Mar 12, 2021
@whitequark whitequark added this to the 0.3 milestone Dec 11, 2021
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

2 participants