From 913a7096269f68ba47ecaf2b2dfb11c25fa059b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Thu, 23 Jan 2025 13:34:28 +0100 Subject: [PATCH] build: common: TristateImpl: support longer oe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit support setting a different oe for every line in the Tristates. this is also needed for the multibit io, where oe has the same lenght as the io., because some platforms use the generic implementation of the SDR/DDRTristate, that uses a Tristate internally. Signed-off-by: Fin Maaß --- litex/build/efinix/common.py | 2 +- litex/build/gowin/common.py | 2 +- litex/build/lattice/common.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/litex/build/efinix/common.py b/litex/build/efinix/common.py index 77ae00bd36..081334ade1 100644 --- a/litex/build/efinix/common.py +++ b/litex/build/efinix/common.py @@ -163,7 +163,7 @@ def __init__(self, io, o, oe, i=None): io_data_i = platform.add_iface_io(io_name + "_OUT", len(io)) self.comb += io_data_i.eq(o) io_data_e = platform.add_iface_io(io_name + "_OE", len(io)) - self.comb += io_data_e.eq(oe) + self.comb += io_data_e.eq(oe if len(oe) == len(io) else Replicate(oe, len(io))) if i is not None: io_data_o = platform.add_iface_io(io_name + "_IN", len(io)) self.comb += i.eq(io_data_o) diff --git a/litex/build/gowin/common.py b/litex/build/gowin/common.py index 20697b9cce..b0a92005d7 100644 --- a/litex/build/gowin/common.py +++ b/litex/build/gowin/common.py @@ -120,7 +120,7 @@ def __init__(self, io, o, oe, i): io_IO = io[bit] if nbits > 1 else io, o_O = i[bit] if nbits > 1 else i, i_I = o[bit] if nbits > 1 else o, - i_OEN = ~oe, + i_OEN = ~oe[bit] if len(oe) == nbits > 1 else ~oe, ) class Gw5ATristate: diff --git a/litex/build/lattice/common.py b/litex/build/lattice/common.py index 4e98b80e2b..fa3be42b3e 100644 --- a/litex/build/lattice/common.py +++ b/litex/build/lattice/common.py @@ -151,7 +151,7 @@ def __init__(self, io, o, oe, i): io_B = io[bit] if nbits > 1 else io, i_I = o[bit] if nbits > 1 else o, o_O = i[bit] if nbits > 1 else i, - i_T = ~oe + i_T = ~oe[bit] if len(oe) == nbits > 1 else ~oe ) class LatticeECP5Tristate(Module): @@ -183,7 +183,7 @@ def __init__(self, io, o, oe, i): i_B = io[bit] if nbits > 1 else io, i_I = o[bit] if nbits > 1 else o, o_O = i[bit] if nbits > 1 else i, - i_T = ~oe + i_T = ~oe[bit] if len(oe) == nbits > 1 else ~oe ) class LatticeECP5TrellisTristate(Module): @@ -400,7 +400,7 @@ def __init__(self, io, o, oe, i): self.specials += Instance("SB_IO", p_PIN_TYPE = C(0b101001, 6), # PIN_OUTPUT_TRISTATE + PIN_INPUT io_PACKAGE_PIN = io[bit] if nbits > 1 else io, - i_OUTPUT_ENABLE = oe, + i_OUTPUT_ENABLE = oe[bit] if len(oe) == nbits > 1 else oe, i_D_OUT_0 = o[bit] if nbits > 1 else o, o_D_IN_0 = i[bit] if nbits > 1 else i, )