build/microsemi/common: add async reset synchronizer (using DFN1P0)
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 19 Nov 2018 12:15:34 +0000 (13:15 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 19 Nov 2018 14:35:59 +0000 (15:35 +0100)
litex/build/microsemi/common.py

index 2b82aed3ae3738ad3323332a9968f0a4a6cd62be..9fcc58f1cad2683748f20e1ee0a02412080ae912 100644 (file)
@@ -1,2 +1,24 @@
+from migen import *
+from migen.genlib.resetsync import AsyncResetSynchronizer
+
+
+class MicrosemiPolarfireAsyncResetSynchronizerImpl(Module):
+    def __init__(self, cd, async_reset):
+        rst1 = Signal()
+        self.specials += [
+            Instance("DFN1P0", i_D=0, i_PRE=~async_reset,
+                     i_CLK=cd.clk, o_Q=rst1),
+            Instance("DFN1P0", i_D=rst1, i_PRE=~async_reset,
+                     i_CLK=cd.clk, o_Q=cd.rst)
+        ]
+
+
+class MicrosemiPolarfireAsyncResetSynchronizer:
+    @staticmethod
+    def lower(dr):
+        return MicrosemiPolarfireAsyncResetSynchronizerImpl(dr.cd, dr.async_reset)
+
+
 microsemi_polarfire_special_overrides = {
+    AsyncResetSynchronizer: MicrosemiPolarfireAsyncResetSynchronizer,
 }