Skip to content

Commit

Permalink
Merge pull request #2105 from VOGL-electronic/add_io_bus
Browse files Browse the repository at this point in the history
build: io: add multibit/bus variants of SDR and DDR
  • Loading branch information
enjoy-digital authored Jan 14, 2025
2 parents a1ea5a2 + e7a55fa commit 4933bcb
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 352 deletions.
114 changes: 61 additions & 53 deletions litex/build/altera/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ def lower(dr):

class AlteraDDROutputImpl(Module):
def __init__(self, i1, i2, o, clk):
self.specials += Instance("ALTDDIO_OUT",
p_WIDTH = 1,
i_outclock = clk,
i_datain_h = i1,
i_datain_l = i2,
o_dataout = o,
)
for j in range(len(o)):
self.specials += Instance("ALTDDIO_OUT",
p_WIDTH = 1,
i_outclock = clk,
i_datain_h = i1[j],
i_datain_l = i2[j],
o_dataout = o[j],
)

class AlteraDDROutput:
@staticmethod
Expand All @@ -108,13 +109,14 @@ def lower(dr):

class AlteraDDRInputImpl(Module):
def __init__(self, i, o1, o2, clk):
self.specials += Instance("ALTDDIO_IN",
p_WIDTH = 1,
i_inclock = clk,
i_datain = i,
o_dataout_h = o1,
o_dataout_l = o2
)
for j in range(len(i)):
self.specials += Instance("ALTDDIO_IN",
p_WIDTH = 1,
i_inclock = clk,
i_datain = i[j],
o_dataout_h = o1[j],
o_dataout_l = o2[j],
)

class AlteraDDRInput:
@staticmethod
Expand Down Expand Up @@ -169,18 +171,19 @@ def lower(dr):

class Agilex5DDROutputImpl(Module):
def __init__(self, i1, i2, o, clk):
self.specials += Instance("tennm_ph2_ddio_out",
p_mode = "MODE_DDR",
p_asclr_ena = "ASCLR_ENA_NONE",
p_sclr_ena = "SCLR_ENA_NONE",
o_dataout = o,
i_datainlo = i2,
i_datainhi = i1,
i_clk = clk,
i_ena = Constant(1, 1),
i_areset = Constant(1, 1),
i_sreset = Constant(1, 1),
)
for j in range(len(o)):
self.specials += Instance("tennm_ph2_ddio_out",
p_mode = "MODE_DDR",
p_asclr_ena = "ASCLR_ENA_NONE",
p_sclr_ena = "SCLR_ENA_NONE",
o_dataout = o[j],
i_datainlo = i2[j],
i_datainhi = i1[j],
i_clk = clk,
i_ena = Constant(1, 1),
i_areset = Constant(1, 1),
i_sreset = Constant(1, 1),
)

class Agilex5DDROutput:
@staticmethod
Expand All @@ -191,18 +194,19 @@ def lower(dr):

class Agilex5DDRInputImpl(Module):
def __init__(self, i, o1, o2, clk):
self.specials += Instance("tennm_ph2_ddio_in",
p_mode = "MODE_DDR",
p_asclr_ena = "ASCLR_ENA_NONE",
p_sclr_ena = "SCLR_ENA_NONE",
i_clk = clk,
i_datain = i,
o_regouthi = o1,
o_regoutlo = o2,
i_ena = Constant(1, 1),
i_areset = Constant(1, 1),
i_sreset = Constant(1, 1),
)
for j in range(len(i)):
self.specials += Instance("tennm_ph2_ddio_in",
p_mode = "MODE_DDR",
p_asclr_ena = "ASCLR_ENA_NONE",
p_sclr_ena = "SCLR_ENA_NONE",
i_clk = clk,
i_datain = i[j],
o_regouthi = o1[j],
o_regoutlo = o2[j],
i_ena = Constant(1, 1),
i_areset = Constant(1, 1),
i_sreset = Constant(1, 1),
)

class Agilex5DDRInput:
@staticmethod
Expand All @@ -227,25 +231,29 @@ def lower(dr):

class Agilex5SDRTristateImpl(Module):
def __init__(self, io, o, oe, i, clk):
_i = Signal()
_o = Signal()
_oe = Signal()
_i = Signal().like(i)
_o = Signal().like(o)
_oe = Signal().like(oe)
self.specials += [
SDRIO(o, _o, clk),
SDRIO(oe, _oe, clk),
SDRIO(_i, i, clk),
Instance("tennm_ph2_io_ibuf",
p_bus_hold = "BUS_HOLD_OFF",
io_i = io, # FIXME: its an input but io is needed to have correct dir at top module
o_o = _i,
),
Instance("tennm_ph2_io_obuf",
p_open_drain = "OPEN_DRAIN_OFF",
i_i = _o,
i_oe = _oe,
io_o = io, # FIXME: its an output but io is needed to have correct dir at top module
),
SDRIO(_i, i, clk)
]

for j in range(len(io)):
self.specials += [
Instance("tennm_ph2_io_ibuf",
p_bus_hold = "BUS_HOLD_OFF",
io_i = io[j], # FIXME: its an input but io is needed to have correct dir at top module
o_o = _i[j],
),
Instance("tennm_ph2_io_obuf",
p_open_drain = "OPEN_DRAIN_OFF",
i_i = _o[j],
i_oe = _oe[j],
io_o = io[j], # FIXME: its an output but io is needed to have correct dir at top module
),
]

class Agilex5SDRTristate(Module):
@staticmethod
Expand Down
41 changes: 22 additions & 19 deletions litex/build/colognechip/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,32 @@ def lower(dr):

class CologneChipDDRInputImpl(Module):
def __init__(self, i, o1, o2, clk):
self.specials += Instance("CC_IDDR",
i_CLK = clk,
i_D = i,
o_Q0 = o1,
o_Q1 = o2,
)
for j in range(len(i)):
self.specials += Instance("CC_IDDR",
i_CLK = clk,
i_D = i[j],
o_Q0 = o1[j],
o_Q1 = o2[j],
)

class CologneChipDDRInput:
@staticmethod
def lower(dr):
return CologneChipInputImpl(dr.i, dr.o1, dr.o2, dr.clk)
return CologneChipDDRInputImpl(dr.i, dr.o1, dr.o2, dr.clk)

# CologneChip DDR Output ---------------------------------------------------------------------------

class CologneChipDDROutputImpl(Module):
def __init__(self, i1, i2, o, clk):
self.specials += Instance("CC_ODDR",
p_CLK_INV = 0,
i_CLK = clk,
i_DDR = ~clk,
i_D0 = i1,
i_D1 = i2,
o_Q = o,
)
for j in range(len(o)):
self.specials += Instance("CC_ODDR",
p_CLK_INV = 0,
i_CLK = clk,
i_DDR = ~clk,
i_D0 = i1[j],
i_D1 = i2[j],
o_Q = o[j],
)

class CologneChipDDROutput:
@staticmethod
Expand Down Expand Up @@ -110,10 +112,11 @@ def lower(dr):

class CologneChipSDRInputImpl(Module):
def __init__(self, i, o):
self.specials += Instance("CC_IBUF",
i_I = i,
o_O = o,
)
for j in range(len(i)):
self.specials += Instance("CC_IBUF",
i_I = i[j],
o_O = o[j],
)

class CologneChipSDRInput:
@staticmethod
Expand Down
Loading

0 comments on commit 4933bcb

Please sign in to comment.