Allow specifying the same clock constraint multiple times.

(As long as the clock values actually match.)
This commit is contained in:
Tim 'mithro' Ansell 2019-12-30 19:25:14 +01:00
parent 8b955e6f69
commit f0b5c67216
1 changed files with 7 additions and 2 deletions

View File

@ -193,7 +193,12 @@ class LatticeIceStormToolchain:
return v_output.ns return v_output.ns
def add_period_constraint(self, platform, clk, period): def add_period_constraint(self, platform, clk, period):
clk_ns = 1e3/period
clk.attr.add("keep") clk.attr.add("keep")
if clk in self.clocks: if clk in self.clocks:
raise ValueError("A period constraint already exists") if clk_ns != self.clocks[clk]:
self.clocks[clk] = 1e3/period raise ValueError(
"A period constraint already exists"
"(wanted: {:.2f}ns, got {:.2f}ns)".format(
clk_ns, self.clocks[clk]))
self.clocks[clk] = clk_ns