lattice/common: cleanup instances, simplify tritates.
This commit is contained in:
parent
2d25bcb09c
commit
2031f28057
|
@ -99,27 +99,14 @@ lattice_ecp5_special_overrides = {
|
||||||
class LatticeECP5TrellisTristateImpl(Module):
|
class LatticeECP5TrellisTristateImpl(Module):
|
||||||
def __init__(self, io, o, oe, i):
|
def __init__(self, io, o, oe, i):
|
||||||
nbits, sign = value_bits_sign(io)
|
nbits, sign = value_bits_sign(io)
|
||||||
if nbits == 1:
|
|
||||||
self.specials += [
|
|
||||||
Instance("TRELLIS_IO",
|
|
||||||
p_DIR = "BIDIR",
|
|
||||||
i_B = io,
|
|
||||||
i_I = o,
|
|
||||||
o_O = i,
|
|
||||||
i_T = ~oe
|
|
||||||
)
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
for bit in range(nbits):
|
for bit in range(nbits):
|
||||||
self.specials += [
|
self.specials += Instance("TRELLIS_IO",
|
||||||
Instance("TRELLIS_IO",
|
p_DIR = "BIDIR",
|
||||||
p_DIR="BIDIR",
|
i_B = io[bit] if nbits > 1 else io,
|
||||||
i_B = io[bit],
|
i_I = o[bit] if nbits > 1 else o,
|
||||||
i_I = o[bit],
|
o_O = i[bit] if nbits > 1 else i,
|
||||||
o_O = i[bit],
|
|
||||||
i_T = ~oe
|
i_T = ~oe
|
||||||
)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
class LatticeECP5TrellisTristate(Module):
|
class LatticeECP5TrellisTristate(Module):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -143,10 +130,10 @@ class LatticeiCE40AsyncResetSynchronizerImpl(Module):
|
||||||
rst1 = Signal()
|
rst1 = Signal()
|
||||||
self.specials += [
|
self.specials += [
|
||||||
Instance("SB_DFFS",
|
Instance("SB_DFFS",
|
||||||
i_D= 0,
|
i_D = 0,
|
||||||
i_S= async_reset,
|
i_S = async_reset,
|
||||||
i_C= cd.clk,
|
i_C = cd.clk,
|
||||||
o_Q= rst1),
|
o_Q = rst1),
|
||||||
Instance("SB_DFFS",
|
Instance("SB_DFFS",
|
||||||
i_D = rst1,
|
i_D = rst1,
|
||||||
i_S = async_reset,
|
i_S = async_reset,
|
||||||
|
@ -165,28 +152,14 @@ class LatticeiCE40AsyncResetSynchronizer:
|
||||||
class LatticeiCE40TristateImpl(Module):
|
class LatticeiCE40TristateImpl(Module):
|
||||||
def __init__(self, io, o, oe, i):
|
def __init__(self, io, o, oe, i):
|
||||||
nbits, sign = value_bits_sign(io)
|
nbits, sign = value_bits_sign(io)
|
||||||
if nbits == 1:
|
|
||||||
self.specials += [
|
|
||||||
Instance("SB_IO",
|
|
||||||
p_PIN_TYPE = C(0b101001, 6), # PIN_OUTPUT_TRISTATE + PIN_INPUT
|
|
||||||
io_PACKAGE_PIN = io,
|
|
||||||
i_OUTPUT_ENABLE = oe,
|
|
||||||
i_D_OUT_0 = o,
|
|
||||||
o_D_IN_0 = i
|
|
||||||
)
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
for bit in range(nbits):
|
for bit in range(nbits):
|
||||||
self.specials += [
|
self.specials += Instance("SB_IO",
|
||||||
Instance("SB_IO",
|
|
||||||
p_PIN_TYPE = C(0b101001, 6), # PIN_OUTPUT_TRISTATE + PIN_INPUT
|
p_PIN_TYPE = C(0b101001, 6), # PIN_OUTPUT_TRISTATE + PIN_INPUT
|
||||||
io_PACKAGE_PIN = io[bit],
|
io_PACKAGE_PIN = io[bit] if nbits > 1 else io,
|
||||||
i_OUTPUT_ENABLE = oe,
|
i_OUTPUT_ENABLE = oe,
|
||||||
i_D_OUT_0 = o[bit],
|
i_D_OUT_0 = o[bit] if nbits > 1 else o,
|
||||||
o_D_IN_0 = i[bit]
|
o_D_IN_0 = i[bit] if nbits > 1 else i,
|
||||||
)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class LatticeiCE40Tristate(Module):
|
class LatticeiCE40Tristate(Module):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -203,9 +176,7 @@ class LatticeiCE40DifferentialOutputImpl(Module):
|
||||||
p_IO_STANDARD = "SB_LVCMOS",
|
p_IO_STANDARD = "SB_LVCMOS",
|
||||||
io_PACKAGE_PIN = o_p,
|
io_PACKAGE_PIN = o_p,
|
||||||
i_D_OUT_0 = i
|
i_D_OUT_0 = i
|
||||||
)
|
),
|
||||||
]
|
|
||||||
self.specials += [
|
|
||||||
Instance("SB_IO",
|
Instance("SB_IO",
|
||||||
p_PIN_TYPE = C(0b011000, 6), # PIN_OUTPUT
|
p_PIN_TYPE = C(0b011000, 6), # PIN_OUTPUT
|
||||||
p_IO_STANDARD = "SB_LVCMOS",
|
p_IO_STANDARD = "SB_LVCMOS",
|
||||||
|
@ -214,7 +185,6 @@ class LatticeiCE40DifferentialOutputImpl(Module):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class LatticeiCE40DifferentialOutput:
|
class LatticeiCE40DifferentialOutput:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lower(dr):
|
def lower(dr):
|
||||||
|
@ -224,8 +194,7 @@ class LatticeiCE40DifferentialOutput:
|
||||||
|
|
||||||
class LatticeiCE40DDROutputImpl(Module):
|
class LatticeiCE40DDROutputImpl(Module):
|
||||||
def __init__(self, i1, i2, o, clk):
|
def __init__(self, i1, i2, o, clk):
|
||||||
self.specials += [
|
self.specials += Instance("SB_IO",
|
||||||
Instance("SB_IO",
|
|
||||||
p_PIN_TYPE = C(0b010000, 6), # PIN_OUTPUT_DDR
|
p_PIN_TYPE = C(0b010000, 6), # PIN_OUTPUT_DDR
|
||||||
p_IO_STANDARD = "SB_LVCMOS",
|
p_IO_STANDARD = "SB_LVCMOS",
|
||||||
io_PACKAGE_PIN = o,
|
io_PACKAGE_PIN = o,
|
||||||
|
@ -235,7 +204,6 @@ class LatticeiCE40DDROutputImpl(Module):
|
||||||
i_D_OUT_0 = i1,
|
i_D_OUT_0 = i1,
|
||||||
i_D_OUT_1 = i2
|
i_D_OUT_1 = i2
|
||||||
)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class LatticeiCE40DDROutput:
|
class LatticeiCE40DDROutput:
|
||||||
|
@ -247,8 +215,7 @@ class LatticeiCE40DDROutput:
|
||||||
|
|
||||||
class LatticeiCE40DDRInputImpl(Module):
|
class LatticeiCE40DDRInputImpl(Module):
|
||||||
def __init__(self, i, o1, o2, clk):
|
def __init__(self, i, o1, o2, clk):
|
||||||
self.specials += [
|
self.specials += Instance("SB_IO",
|
||||||
Instance("SB_IO",
|
|
||||||
p_PIN_TYPE = C(0b000000, 6), # PIN_INPUT_DDR
|
p_PIN_TYPE = C(0b000000, 6), # PIN_INPUT_DDR
|
||||||
p_IO_STANDARD = "SB_LVCMOS",
|
p_IO_STANDARD = "SB_LVCMOS",
|
||||||
io_PACKAGE_PIN = i,
|
io_PACKAGE_PIN = i,
|
||||||
|
@ -257,7 +224,6 @@ class LatticeiCE40DDRInputImpl(Module):
|
||||||
o_D_IN_0 = o1,
|
o_D_IN_0 = o1,
|
||||||
o_D_IN_1 = o2
|
o_D_IN_1 = o2
|
||||||
)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class LatticeiCE40DDRInput:
|
class LatticeiCE40DDRInput:
|
||||||
|
|
Loading…
Reference in New Issue