build/lattice: work around lack of SDR I/O primitives in nextpnr

Fixes #907.
This commit is contained in:
Dan Callaghan 2021-08-09 19:26:40 +10:00
parent 79ac09316a
commit cd8666d0b3
2 changed files with 32 additions and 1 deletions

View File

@ -241,6 +241,31 @@ class LatticeNXSDROutput:
def lower(dr):
return LatticeNXSDROutputImpl(dr.i, dr.o, dr.clk)
# NX SDR Input and Output via regular flip-flops ---------------------------------------------------
# This is a workaround for IO-specific primitives IFD1P3BX / OFD1P3BX being unsupported in nextpnr:
# https://github.com/YosysHQ/nextpnr/issues/698
class LatticeNXSDRFFImpl(Module):
def __init__(self, i, o, clk):
self.specials += Instance("FD1P3BX",
i_CK = clk,
i_PD = 0,
i_SP = 1,
i_D = i,
o_Q = o,
)
class LatticeNXSDRInputViaFlipFlop:
@staticmethod
def lower(dr):
return LatticeNXSDRFFImpl(dr.i, dr.o, dr.clk)
class LatticeNXSDROutputViaFlipFlop:
@staticmethod
def lower(dr):
return LatticeNXSDRFFImpl(dr.i, dr.o, dr.clk)
# NX DDR Input -------------------------------------------------------------------------------------
class LatticeNXDDRInputImpl(Module):
@ -283,6 +308,12 @@ lattice_NX_special_overrides = {
DDROutput: LatticeNXDDROutput,
}
lattice_NX_special_overrides_for_oxide = dict(lattice_NX_special_overrides)
lattice_NX_special_overrides_for_oxide.update({
SDRInput: LatticeNXSDRInputViaFlipFlop,
SDROutput: LatticeNXSDROutputViaFlipFlop,
})
# iCE40 AsyncResetSynchronizer ---------------------------------------------------------------------
class LatticeiCE40AsyncResetSynchronizerImpl(Module):

View File

@ -110,7 +110,7 @@ class LatticeOxideToolchain:
"keep": ("keep", "true"),
}
special_overrides = common.lattice_NX_special_overrides
special_overrides = common.lattice_NX_special_overrides_for_oxide
def __init__(self):
self.yosys_template = _yosys_template