From 38ad35757b92b66226cd1863c1b3e5c24a3d9268 Mon Sep 17 00:00:00 2001 From: Wanda Date: Sat, 6 Apr 2024 13:14:44 +0200 Subject: [PATCH] build.res: give a more specific error for `add_clock_constraint(ClockSignal)`. Fixes #542. --- amaranth/build/res.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/amaranth/build/res.py b/amaranth/build/res.py index 6cce534..5e525af 100644 --- a/amaranth/build/res.py +++ b/amaranth/build/res.py @@ -242,7 +242,11 @@ class ResourceManager: yield f"{port_name}[{bit}]", pin_name, attrs def add_clock_constraint(self, clock, frequency): - if not isinstance(clock, Signal): + if isinstance(clock, ClockSignal): + raise TypeError(f"A clock constraint can only be applied to a Signal, but a " + f"ClockSignal is provided; assign the ClockSignal to an " + f"intermediate signal and constrain the latter instead.") + elif not isinstance(clock, Signal): raise TypeError(f"Object {clock!r} is not a Signal") if not isinstance(frequency, (int, float)): raise TypeError(f"Frequency must be a number, not {frequency!r}")