diff --git a/litex/build/efinix/common.py b/litex/build/efinix/common.py index 9c104ab69..9a4ef0c2b 100644 --- a/litex/build/efinix/common.py +++ b/litex/build/efinix/common.py @@ -5,4 +5,39 @@ # Copyright (c) 2015-2018 Florent Kermarrec # SPDX-License-Identifier: BSD-2-Clause -efinix_special_overrides = {} \ No newline at end of file +from migen.fhdl.module import Module +from migen.genlib.resetsync import AsyncResetSynchronizer + +from litex.build.io import * + +# Efinix AsyncResetSynchronizer --------------------------------------------------------------------- + +class EfinixAsyncResetSynchronizerImpl(Module): + def __init__(self, cd, async_reset): + rst1 = Signal() + self.specials += [ + Instance("EFX_FF", + i_D = 0, + i_SR = async_reset, + i_CLK = cd.clk, + i_CE = 1, + o_Q = rst1), + Instance("EFX_FF", + i_D = rst1, + i_SR = async_reset, + i_CLK = cd.clk, + i_CE = 1, + o_Q = cd.rst) + ] + + +class EfinixAsyncResetSynchronizer: + @staticmethod + def lower(dr): + return EfinixAsyncResetSynchronizerImpl(dr.cd, dr.async_reset) + +# Gowin Special Overrides -------------------------------------------------------------------------- + +efinix_special_overrides = { + AsyncResetSynchronizer: EfinixAsyncResetSynchronizer +}