build/lattice/icestorm/add_period_constraint: improve
- store period in ns. - pass clocks to_build_pre_pack and do the convertion to MHz there. - improve error message.
This commit is contained in:
parent
6b91e8827c
commit
fe4eaf5860
|
@ -29,10 +29,10 @@ def _build_pcf(named_sc, named_pc):
|
||||||
|
|
||||||
# Timing Constraints (in pre_pack file) ------------------------------------------------------------
|
# Timing Constraints (in pre_pack file) ------------------------------------------------------------
|
||||||
|
|
||||||
def _build_pre_pack(vns, freq_cstrs):
|
def _build_pre_pack(vns, clocks):
|
||||||
r = ""
|
r = ""
|
||||||
for sig in freq_cstrs:
|
for clk, period in clocks.items():
|
||||||
r += """ctx.addClock("{}", {})\n""".format(vns.get_name(sig), freq_cstrs[sig])
|
r += """ctx.addClock("{}", {})\n""".format(vns.get_name(clk), 1e3/period)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
# Yosys/Nextpnr Helpers/Templates ------------------------------------------------------------------
|
# Yosys/Nextpnr Helpers/Templates ------------------------------------------------------------------
|
||||||
|
@ -193,12 +193,9 @@ 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:
|
||||||
if clk_ns != self.clocks[clk]:
|
if period != self.clocks[clk]:
|
||||||
raise ValueError(
|
raise ValueError("Clock already constrained to {:.2f}ns, new constraint to {:.2f}ns"
|
||||||
"A period constraint already exists"
|
.format(self.clocks[clk], period))
|
||||||
"(wanted: {:.2f}ns, got {:.2f}ns)".format(
|
self.clocks[clk] = period
|
||||||
clk_ns, self.clocks[clk]))
|
|
||||||
self.clocks[clk] = clk_ns
|
|
||||||
|
|
Loading…
Reference in New Issue