build/efinix/common: Add initial Tristate/SDRTristate support.
This commit is contained in:
parent
89b66be323
commit
68b67af1bd
|
@ -10,6 +10,8 @@ from migen.genlib.resetsync import AsyncResetSynchronizer
|
|||
|
||||
from litex.build.io import *
|
||||
|
||||
from litex.build.efinix.efinity import EfinityToolchain
|
||||
|
||||
# Efinix AsyncResetSynchronizer --------------------------------------------------------------------
|
||||
|
||||
class EfinixAsyncResetSynchronizerImpl(Module):
|
||||
|
@ -38,8 +40,57 @@ class EfinixAsyncResetSynchronizer:
|
|||
def lower(dr):
|
||||
return EfinixAsyncResetSynchronizerImpl(dr.cd, dr.async_reset)
|
||||
|
||||
# Efinix Tristate ----------------------------------------------------------------------------------
|
||||
|
||||
class EfinixTristateImpl(Module):
|
||||
def __init__(self, platform, io, o, oe, i):
|
||||
nbits, sign = value_bits_sign(io)
|
||||
assert nbits == 1
|
||||
io_name = platform.get_pin_name(io)
|
||||
print(io_name)
|
||||
io_loc = platform.get_pin_location(io)
|
||||
self.comb += [
|
||||
platform.add_iface_io(io_name + "_OUT").eq(o),
|
||||
platform.add_iface_io(io_name + "_OE").eq(oe),
|
||||
i.eq(platform.add_iface_io(io_name + "_IN"))
|
||||
]
|
||||
block = {
|
||||
"type" : "GPIO",
|
||||
"mode" : "INOUT",
|
||||
"name" : io_name,
|
||||
"location": [io_loc[0]],
|
||||
}
|
||||
platform.toolchain.ifacewriter.blocks.append(block)
|
||||
#platform.delete(io) # FIXME!
|
||||
|
||||
class EfinixTristate(Module):
|
||||
@staticmethod
|
||||
def lower(dr):
|
||||
return EfinixTristateImpl(dr.platform, dr.target, dr.o, dr.oe, dr.i)
|
||||
|
||||
# Efinix SDRTristate -------------------------------------------------------------------------------
|
||||
|
||||
class EfinixSDRTristateImpl(Module):
|
||||
def __init__(self, platform, io, o, oe, i, clk):
|
||||
_o = Signal()
|
||||
_oe = Signal()
|
||||
_i = Signal()
|
||||
self.specials += SDROutput(o, _o, clk)
|
||||
self.specials += SDRInput(_i, i, clk)
|
||||
self.submodules += InferedSDRIO(oe, _oe, clk)
|
||||
tristate = Tristate(io, _o, _oe, _i)
|
||||
tristate.platform = platform
|
||||
self.specials += tristate
|
||||
|
||||
class EfinixSDRTristate(Module):
|
||||
@staticmethod
|
||||
def lower(dr):
|
||||
return EfinixSDRTristateImpl(dr.platform, dr.io, dr.o, dr.oe, dr.i, dr.clk)
|
||||
|
||||
# Efinix Special Overrides -------------------------------------------------------------------------
|
||||
|
||||
efinix_special_overrides = {
|
||||
AsyncResetSynchronizer: EfinixAsyncResetSynchronizer
|
||||
AsyncResetSynchronizer : EfinixAsyncResetSynchronizer,
|
||||
Tristate : EfinixTristate,
|
||||
SDRTristate : EfinixSDRTristate,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue