efinix: supports for EfinixTristateImpl with nbits > 1

This commit is contained in:
Franck Jullien 2021-12-17 10:14:43 +01:00
parent a6ed4c5c09
commit df34b3ae6a
2 changed files with 34 additions and 19 deletions

View File

@ -65,24 +65,36 @@ class EfinixAsyncResetSynchronizer:
class EfinixTristateImpl(Module): class EfinixTristateImpl(Module):
def __init__(self, platform, io, o, oe, i=None): def __init__(self, platform, io, o, oe, i=None):
nbits, sign = value_bits_sign(io) nbits, sign = value_bits_sign(io)
assert nbits == 1
io_name = platform.get_pin_name(io) for bit in range(nbits):
io_loc = platform.get_pin_location(io) 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_o = platform.add_iface_io(io_name + "_OUT")
io_oe = platform.add_iface_io(io_name + "_OE") io_oe = platform.add_iface_io(io_name + "_OE")
io_i = platform.add_iface_io(io_name + "_IN") io_i = platform.add_iface_io(io_name + "_IN")
self.comb += io_o.eq(o) self.comb += io_o.eq(o[bit])
self.comb += io_oe.eq(oe) self.comb += io_oe.eq(oe)
if i is not None: if i[bit] is not None:
self.comb += i.eq(io_i) self.comb += i[bit].eq(io_i)
block = { block = {
"type" : "GPIO", "type" : "GPIO",
"mode" : "INOUT", "mode" : "INOUT",
"name" : io_name, "name" : io_name,
"location" : [io_loc[0]], "location" : [io_loc[0]],
} }
platform.toolchain.ifacewriter.blocks.append(block) platform.toolchain.ifacewriter.blocks.append(block)
platform.toolchain.excluded_ios.append(io_name)
# 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): class EfinixTristate(Module):
@staticmethod @staticmethod

View File

@ -100,7 +100,10 @@ class EfinixPlatform(GenericPlatform):
for s, pins, others, resource in sc: for s, pins, others, resource in sc:
if s == sig: if s == sig:
if resource[2]: 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: else:
return resource[0] + (f"{idx}" if slc else "") return resource[0] + (f"{idx}" if slc else "")
return None return None