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

Using ClockSignal in platform.add_clock_constraint #542

Open
rroohhh opened this issue Nov 11, 2020 · 3 comments
Open

Using ClockSignal in platform.add_clock_constraint #542

rroohhh opened this issue Nov 11, 2020 · 3 comments

Comments

@rroohhh
Copy link
Contributor

rroohhh commented Nov 11, 2020

Currently one cannot use a ClockSignal in platform.add_clock_constraint:

from nmigen import *
from nmigen_boards.microzed_z010 import *

plat = MicroZedZ010Platform()
plat.add_clock_constraint(ClockSignal(), 25e6)

fails with

Traceback (most recent call last):
  File "a.py", line 5, in <module>
    plat.add_clock_constraint(ClockSignal(), 25e6)
  File "/home/robin/.guix-profile/lib/python3.8/site-packages/nmigen/vendor/xilinx_7series.py", line 184, in add_clock_constraint
    super().add_clock_constraint(clock, frequency)
  File "/home/robin/.guix-profile/lib/python3.8/site-packages/nmigen/build/res.py", line 223, in add_clock_constraint
    raise TypeError("Object {!r} is not a Signal".format(clock))
TypeError: Object (clk sync) is not a Signal

It be nice to be able to use a ClockSignal directly in platform.add_clock_constraint.

@whitequark
Copy link
Member

That's not possible--the Platform does not know the context of any particular ClockSignal, and without the context, it is ambiguous.

@awygle
Copy link
Contributor

awygle commented Nov 12, 2020

I'd like to recommend enhancing the error message for this case, or else explaining in more detail here for future reference. Even with your comment above, it's not immediately obvious to me why plat.add_clock_constraint(ClockSignal(), 25e6) doesn't work but

cs = ClockSignal()
s = Signal()
m.d.comb += s.eq(cs)
plat.add_clock_constraint(s, 25e6)

does.

@awygle awygle reopened this Nov 12, 2020
@awygle
Copy link
Contributor

awygle commented Feb 10, 2021

Throwing some spaghetti at the wall for the error message:

TypeError: Object (clk sync) is not a Signal, it is a ClockSignal. You may be able to assign the value of (clk sync) to a Signal, which can then be used to add a clock constraint.

Thoughts?

@whitequark whitequark added this to the 0.5 milestone Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants