Skip to content

Commit 72a76c3

Browse files
committed
build.res: give a more specific error for add_clock_constraint(ClockSignal).
Fixes #542.
1 parent 6857daf commit 72a76c3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

amaranth/build/res.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ def iter_port_constraints_bits(self):
242242
yield f"{port_name}[{bit}]", pin_name, attrs
243243

244244
def add_clock_constraint(self, clock, frequency):
245-
if not isinstance(clock, Signal):
245+
if isinstance(clock, ClockSignal):
246+
raise TypeError(f"Object {clock!r} is not a Signal, it is a ClockSignal. "
247+
f"You may be able to assign the value of {clock!r} to "
248+
f"a Signal, which can then be used to add a clock constraint.")
249+
elif not isinstance(clock, Signal):
246250
raise TypeError(f"Object {clock!r} is not a Signal")
247251
if not isinstance(frequency, (int, float)):
248252
raise TypeError(f"Frequency must be a number, not {frequency!r}")

0 commit comments

Comments
 (0)