build/add_period_constraint: Fix trellis (thanks bjonnh and zyp) and avoid specific add_period_constraint in libero_soc.

This commit is contained in:
Florent Kermarrec 2023-05-21 09:06:20 +02:00
parent 60537fc39f
commit f5a9efd8ba
3 changed files with 8 additions and 7 deletions

View File

@ -146,6 +146,10 @@ class LatticeTrellisToolchain(YosysNextPNRToolchain):
}
def add_period_constraint(self, platform, clk, period):
if clk is None:
return
if hasattr(clk, "p"):
clk = clk.p
platform.add_platform_command("""FREQUENCY PORT "{clk}" {freq} MHz;""".format(
freq=str(float(1/period)*1000), clk="{clk}"), clk=clk)

View File

@ -236,13 +236,6 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
if subprocess.call(shell + [script]) != 0:
raise OSError("Subprocess failed")
def add_period_constraint(self, platform, clk, period):
if clk in self.clocks:
if period != self.clocks[clk]:
raise ValueError("Clock already constrained to {:.2f}ns, new constraint to {:.2f}ns"
.format(self.clocks[clk], period))
self.clocks[clk] = period
def add_false_path_constraint(self, platform, from_, to):
if (to, from_) not in self.false_paths:
self.false_paths.add((from_, to))

View File

@ -206,6 +206,10 @@ bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt}
# them through clock objects like DCM and PLL objects.
def add_period_constraint(self, platform, clk, period):
if clk is None:
return
if hasattr(clk, "p"):
clk = clk.p
clk.attr.add("keep")
platform.add_platform_command(
"""