diff --git a/litex/build/lattice/diamond.py b/litex/build/lattice/diamond.py index 3e192d930..c2c05218f 100644 --- a/litex/build/lattice/diamond.py +++ b/litex/build/lattice/diamond.py @@ -152,6 +152,9 @@ class LatticeDiamondToolchain: special_overrides = common.lattice_ecpx_special_overrides + def __init__(self): + self.false_paths = set() # FIXME: use it + def build(self, platform, fragment, build_dir = "build", build_name = "top", @@ -200,3 +203,9 @@ class LatticeDiamondToolchain: # TODO: handle differential clk platform.add_platform_command("""FREQUENCY PORT "{clk}" {freq} MHz;""".format( freq=str(float(1/period)*1000), clk="{clk}"), clk=clk) + + def add_false_path_constraint(self, platform, from_, to): + from_.attr.add("keep") + to.attr.add("keep") + if (to, from_) not in self.false_paths: + self.false_paths.add((from_, to)) \ No newline at end of file diff --git a/litex/build/lattice/platform.py b/litex/build/lattice/platform.py index 389f49172..b4f8593e2 100644 --- a/litex/build/lattice/platform.py +++ b/litex/build/lattice/platform.py @@ -37,3 +37,10 @@ class LatticePlatform(GenericPlatform): if hasattr(clk, "p"): clk = clk.p self.toolchain.add_period_constraint(self, clk, period) + + def add_false_path_constraint(self, from_, to): + if hasattr(from_, "p"): + from_ = from_.p + if hasattr(to, "p"): + to = to.p + self.toolchain.add_false_path_constraint(self, from_, to) diff --git a/litex/build/lattice/trellis.py b/litex/build/lattice/trellis.py index 478035176..7244f2835 100644 --- a/litex/build/lattice/trellis.py +++ b/litex/build/lattice/trellis.py @@ -173,6 +173,7 @@ class LatticeTrellisToolchain: def __init__(self): self.yosys_template = _yosys_template self.build_template = _build_template + self.false_paths = set() # FIXME: use it def build(self, platform, fragment, build_dir = "build", @@ -231,6 +232,12 @@ class LatticeTrellisToolchain: platform.add_platform_command("""FREQUENCY PORT "{clk}" {freq} MHz;""".format( freq=str(float(1/period)*1000), clk="{clk}"), clk=clk) + def add_false_path_constraint(self, platform, from_, to): + from_.attr.add("keep") + to.attr.add("keep") + if (to, from_) not in self.false_paths: + self.false_paths.add((from_, to)) + def trellis_args(parser): parser.add_argument("--yosys-nowidelut", action="store_true", help="pass '-nowidelut' to yosys synth_ecp5")