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

rroohhh opened this issue Nov 11, 2020 · 3 comments · Fixed by #1288

Using ClockSignal in platform.add_clock_constraint #542

rroohhh opened this issue Nov 11, 2020 · 3 comments · Fixed by #1288


Copy link

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 "", line 5, in <module>
    plat.add_clock_constraint(ClockSignal(), 25e6)
  File "/home/robin/.guix-profile/lib/python3.8/site-packages/nmigen/vendor/", line 184, in add_clock_constraint
    super().add_clock_constraint(clock, frequency)
  File "/home/robin/.guix-profile/lib/python3.8/site-packages/nmigen/build/", 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.

Copy link

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

Copy link

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)


@awygle awygle reopened this Nov 12, 2020
Copy link

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.


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

Successfully merging a pull request may close this issue.

3 participants