build/lattice/common: add specific LatticeiCE40SDROutputImpl/LatticeiCE40SDRTristateImpl (thanks @tnt).

This commit is contained in:
Florent Kermarrec 2020-04-22 11:50:55 +02:00
parent 1457c32052
commit fc434af949
1 changed files with 33 additions and 1 deletions

View File

@ -251,10 +251,22 @@ class LatticeiCE40DDRInput:
# iCE40 SDR Output --------------------------------------------------------------------------------- # iCE40 SDR Output ---------------------------------------------------------------------------------
class LatticeiCE40SDROutputImpl(Module):
def __init__(self, i, o, clk):
self.specials += Instance("SB_IO",
p_PIN_TYPE = C(0b010100, 6), # PIN_OUTPUT_REGISTERED
p_IO_STANDARD = "SB_LVCMOS",
io_PACKAGE_PIN = o,
i_CLOCK_ENABLE = 1,
i_OUTPUT_CLK = clk,
i_OUTPUT_ENABLE = 1,
i_D_OUT_0 = i
)
class LatticeiCE40SDROutput: class LatticeiCE40SDROutput:
@staticmethod @staticmethod
def lower(dr): def lower(dr):
return LatticeiCE40DDROutputImpl(dr.i, dr.i, dr.o, dr.clk) return LatticeiCE40SDROutputImpl(dr.i, dr.o, dr.clk)
# iCE40 SDR Input ---------------------------------------------------------------------------------- # iCE40 SDR Input ----------------------------------------------------------------------------------
@ -263,6 +275,25 @@ class LatticeiCE40SDRInput:
def lower(dr): def lower(dr):
return LatticeiCE40DDRInputImpl(dr.i, dr.o, Signal(), dr.clk) return LatticeiCE40DDRInputImpl(dr.i, dr.o, Signal(), dr.clk)
# iCE40 SDR Tristate -------------------------------------------------------------------------------
class LatticeiCE40SDRTristateImpl(Module):
def __init__(self, io, o, oe, i, clk):
self.specials += Instance("SB_IO",
p_PIN_TYPE = C(0b110100, 6), # PIN_OUTPUT_REGISTERED_ENABLE_REGISTERED + PIN_INPUT_REGISTERED
io_PACKAGE_PIN = io,
i_INPUT_CLK = clk,
i_OUTPUT_CLK = clk,
i_OUTPUT_ENABLE = oe,
i_D_OUT_0 = o,
o_D_IN_0 = i,
)
class LatticeiCE40SDRTristate(Module):
@staticmethod
def lower(dr):
return LatticeiCE40SDRTristateImpl(dr.io, dr.o, dr.oe, dr.i, dr.clk)
# iCE40 Trellis Special Overrides ------------------------------------------------------------------ # iCE40 Trellis Special Overrides ------------------------------------------------------------------
lattice_ice40_special_overrides = { lattice_ice40_special_overrides = {
@ -273,4 +304,5 @@ lattice_ice40_special_overrides = {
DDRInput: LatticeiCE40DDRInput, DDRInput: LatticeiCE40DDRInput,
SDROutput: LatticeiCE40SDROutput, SDROutput: LatticeiCE40SDROutput,
SDRInput: LatticeiCE40SDRInput, SDRInput: LatticeiCE40SDRInput,
SDRTristate: LatticeiCE40SDRTristate,
} }