build/gowin/common: Add AsyncResetSynchronizer implementation.

This commit is contained in:
Florent Kermarrec 2021-07-14 09:37:00 +02:00
parent fab6512928
commit cfbc06c297
1 changed files with 35 additions and 3 deletions

View File

@ -1,8 +1,40 @@
# #
# This file is part of LiteX. # This file is part of LiteX.
# #
# Copyright (c) 2020 Pepijn de Vos <pepijndevos@gmail.com> # Copyright (c) 2021 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2015-2018 Florent Kermarrec <florent@enjoy-digital.fr>
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
gowin_special_overrides = {} from migen.fhdl.module import Module
from migen.genlib.resetsync import AsyncResetSynchronizer
from litex.build.io import *
# Gowin AsyncResetSynchronizer ---------------------------------------------------------------------
class GowinAsyncResetSynchronizerImpl(Module):
def __init__(self, cd, async_reset):
rst1 = Signal()
self.specials += [
Instance("DFFP",
i_D = 0,
i_PRESET = async_reset,
i_CLK = cd.clk,
o_Q = rst1),
Instance("DFFP",
i_D = rst1,
i_PRESET = async_reset,
i_CLK = cd.clk,
o_Q = cd.rst)
]
class GowinAsyncResetSynchronizer:
@staticmethod
def lower(dr):
return GowinAsyncResetSynchronizerImpl(dr.cd, dr.async_reset)
# Gowin Special Overrides --------------------------------------------------------------------------
gowin_special_overrides = {
AsyncResetSynchronizer: GowinAsyncResetSynchronizer,
}