From df34b3ae6a36a36e82c785fd8ab2cf47f2b06102 Mon Sep 17 00:00:00 2001 From: Franck Jullien Date: Fri, 17 Dec 2021 10:14:43 +0100 Subject: [PATCH] efinix: supports for EfinixTristateImpl with nbits > 1 --- litex/build/efinix/common.py | 48 +++++++++++++++++++++------------- litex/build/efinix/platform.py | 5 +++- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/litex/build/efinix/common.py b/litex/build/efinix/common.py index 6dbcde953..0c62ac34e 100644 --- a/litex/build/efinix/common.py +++ b/litex/build/efinix/common.py @@ -65,24 +65,36 @@ class EfinixAsyncResetSynchronizer: class EfinixTristateImpl(Module): def __init__(self, platform, io, o, oe, i=None): nbits, sign = value_bits_sign(io) - assert nbits == 1 - io_name = platform.get_pin_name(io) - io_loc = platform.get_pin_location(io) - io_o = platform.add_iface_io(io_name + "_OUT") - io_oe = platform.add_iface_io(io_name + "_OE") - io_i = platform.add_iface_io(io_name + "_IN") - self.comb += io_o.eq(o) - self.comb += io_oe.eq(oe) - if i is not None: - self.comb += i.eq(io_i) - block = { - "type" : "GPIO", - "mode" : "INOUT", - "name" : io_name, - "location" : [io_loc[0]], - } - platform.toolchain.ifacewriter.blocks.append(block) - platform.toolchain.excluded_ios.append(io_name) + + for bit in range(nbits): + io_name = platform.get_pin_name(io[bit]) + io_loc = platform.get_pin_location(io[bit]) + io_o = platform.add_iface_io(io_name + "_OUT") + io_oe = platform.add_iface_io(io_name + "_OE") + io_i = platform.add_iface_io(io_name + "_IN") + self.comb += io_o.eq(o[bit]) + self.comb += io_oe.eq(oe) + if i[bit] is not None: + self.comb += i[bit].eq(io_i) + block = { + "type" : "GPIO", + "mode" : "INOUT", + "name" : io_name, + "location" : [io_loc[0]], + } + + platform.toolchain.ifacewriter.blocks.append(block) + + # Remove the group from the io list + exclude = platform.get_pin_name(io[0], without_index=True) + + # In case of a single signal, there is still a '0' index + # to be remove at the end + if (nbits == 1) and (exclude[:-1] == '0'): + exclude = exclude[:-1] + + platform.toolchain.excluded_ios.append(exclude) + class EfinixTristate(Module): @staticmethod diff --git a/litex/build/efinix/platform.py b/litex/build/efinix/platform.py index b267f57c7..81f36d6c7 100644 --- a/litex/build/efinix/platform.py +++ b/litex/build/efinix/platform.py @@ -100,7 +100,10 @@ class EfinixPlatform(GenericPlatform): for s, pins, others, resource in sc: if s == sig: if resource[2]: - return resource[0] + "_" + resource[2] + (f"{idx}" if slc else "") + name = resource[0] + "_" + resource[2] + if without_index is False: + name = name + (f"{idx}" if slc else "") + return name else: return resource[0] + (f"{idx}" if slc else "") return None