mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
litex/build/altera/common: added reset synchronizer
This commit is contained in:
parent
866fa34493
commit
8558065fca
1 changed files with 25 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
|||
from migen.fhdl.module import Module
|
||||
from migen.fhdl.specials import Instance
|
||||
from migen.genlib.io import DifferentialInput, DifferentialOutput
|
||||
from migen.genlib.resetsync import AsyncResetSynchronizer
|
||||
|
||||
from migen.fhdl.structure import *
|
||||
|
||||
|
||||
class AlteraDifferentialInputImpl(Module):
|
||||
|
@ -32,8 +35,29 @@ class AlteraDifferentialOutput:
|
|||
def lower(dr):
|
||||
return AlteraDifferentialOutputImpl(dr.i, dr.o_p, dr.o_n)
|
||||
|
||||
class AlteraAsyncResetSynchronizerImpl(Module):
|
||||
def __init__(self, cd, async_reset):
|
||||
if not hasattr(async_reset, "attr"):
|
||||
i, async_reset = async_reset, Signal()
|
||||
self.comb += async_reset.eq(i)
|
||||
rst_meta = Signal()
|
||||
self.specials += [
|
||||
Instance("DFF", i_d=0, i_clk=cd.clk, i_clrn=1,
|
||||
i_prn=async_reset, o_q=rst_meta,
|
||||
attr={"async_reg", "ars_ff1"}),
|
||||
Instance("DFF", i_d=rst_meta, i_clk=cd.clk, i_clrn=1,
|
||||
i_prn=async_reset, o_q=cd.rst,
|
||||
attr={"async_reg", "ars_ff2"})
|
||||
]
|
||||
|
||||
class AlteraAsyncResetSynchronizer:
|
||||
@staticmethod
|
||||
def lower(dr):
|
||||
return AlteraAsyncResetSynchronizerImpl(dr.cd, dr.async_reset)
|
||||
|
||||
|
||||
altera_special_overrides = {
|
||||
DifferentialInput: AlteraDifferentialInput,
|
||||
DifferentialOutput: AlteraDifferentialOutput
|
||||
DifferentialOutput: AlteraDifferentialOutput,
|
||||
AsyncResetSynchronizer: AlteraAsyncResetSynchronizer
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue