build: automatically add keep attribute to signals with timing constraints.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 6 Dec 2019 14:41:15 +0000 (15:41 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 6 Dec 2019 14:41:15 +0000 (15:41 +0100)
Avoid having to specify it manually or eventually forget to do it and have a constraints that is not applied correctly.

litex/build/altera/quartus.py
litex/build/lattice/diamond.py
litex/build/lattice/icestorm.py
litex/build/microsemi/platform.py
litex/build/xilinx/ise.py
litex/build/xilinx/vivado.py

index ae049a8d1ffe78f665becc6109617c4170d5241c..e8d01c909d477407ac6ee05e74fcc3bebfb86588 100644 (file)
@@ -225,11 +225,14 @@ class AlteraQuartusToolchain:
         return v_output.ns
 
     def add_period_constraint(self, platform, clk, period):
+        clk.attr.add("keep")
         if clk in self.clocks:
             raise ValueError("A period constraint already exists")
         period = math.floor(period*1e3)/1e3 # Round to lowest picosecond
         self.clocks[clk] = period
 
     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))
index b8aefc80eafa205b4b639f0bfc1248deaaa2233a..dc3c5146c8eab0afc1023cb3392cc465c63a8153 100644 (file)
@@ -194,6 +194,7 @@ class LatticeDiamondToolchain:
         return v_output.ns
 
     def add_period_constraint(self, platform, clk, period):
+        clk.attr.add("keep")
         # TODO: handle differential clk
         platform.add_platform_command("""FREQUENCY PORT "{clk}" {freq} MHz;""".format(
             freq=str(float(1/period)*1000), clk="{clk}"), clk=clk)
index 0be9278fa8e33db2aa0969e708b5c372343a2486..e590785089d98caa70fb5ee22a53f7047e062766 100644 (file)
@@ -231,8 +231,8 @@ class LatticeIceStormToolchain:
         return "\n".join(read_files)
 
     def add_period_constraint(self, platform, clk, period):
+        clk.attr.add("keep")
         new_freq = 1000.0/period
-
         if clk not in self.freq_constraints.keys():
             self.freq_constraints[clk] = new_freq
         else:
index 3f7a1396b65abfaee1dae22e002eb1b93d246828..65d2c996d55ccc0b9f4c771f2d4d43f459aad9ad 100644 (file)
@@ -28,6 +28,7 @@ class MicrosemiPlatform(GenericPlatform):
         return self.toolchain.build(self, *args, **kwargs)
 
     def add_period_constraint(self, clk, period):
+        clk.attr.add("keep")
         if hasattr(clk, "p"):
             clk = clk.p
         self.toolchain.add_period_constraint(self, clk, period)
@@ -37,4 +38,6 @@ class MicrosemiPlatform(GenericPlatform):
             from_ = from_.p
         if hasattr(to, "p"):
             to = to.p
+        from_.attr.add("keep")
+        to.attr.add("keep")
         self.toolchain.add_false_path_constraint(self, from_, to)
index b441469c6df41f63ff8b111f34c51e2ad184ae6f..3a03107ec907226ca4dbaa7446606dd562167058 100644 (file)
@@ -249,6 +249,7 @@ class XilinxISEToolchain:
     # them through clock objects like DCM and PLL objects.
 
     def add_period_constraint(self, platform, clk, period):
+        clk.attr.add("keep")
         platform.add_platform_command(
             """
 NET "{clk}" TNM_NET = "PRD{clk}";
@@ -258,6 +259,8 @@ TIMESPEC "TS{clk}" = PERIOD "PRD{clk}" """ + str(period) + """ ns HIGH 50%;
             )
 
     def add_false_path_constraint(self, platform, from_, to):
+        from_.attr.add("keep")
+        to.attr.add("keep")
         platform.add_platform_command(
             """
 NET "{from_}" TNM_NET = "TIG{from_}";
index aa3dca20ba729718d60e8419bc2bb4b50a072441..fb87bccbe58fb7d1e7a719dcf29014ab69e3fe70 100644 (file)
@@ -269,12 +269,15 @@ class XilinxVivadoToolchain:
         return v_output.ns
 
     def add_period_constraint(self, platform, clk, period):
+        clk.attr.add("keep")
         if clk in self.clocks:
             raise ValueError("A period constraint already exists")
         period = math.floor(period*1e3)/1e3 # round to lowest picosecond
         self.clocks[clk] = period
 
     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))