phy/s7ddrphy: simplify commands (avoid duplication between address/banks/controls).

This commit is contained in:
Florent Kermarrec 2020-09-30 08:04:45 +02:00
parent 7f347af1ed
commit c17bf3f5a1
1 changed files with 20 additions and 80 deletions

View File

@ -154,81 +154,22 @@ class S7DDRPHY(Module, AutoCSR):
o_OB = pads.clk_n[i] o_OB = pads.clk_n[i]
) )
# Addresses and Commands --------------------------------------------------------------- # Commands -----------------------------------------------------------------------------
for i in range(addressbits): commands = {
address = Signal() "a" : "address",
self.specials += Instance("OSERDESE2", "ba" : "bank" ,
p_SERDES_MODE = "MASTER", "ras_n": "ras_n" ,
p_DATA_WIDTH = 2*nphases, "cas_n": "cas_n" ,
p_TRISTATE_WIDTH = 1, "we_n" : "we_n" ,
p_DATA_RATE_OQ = "DDR", "cke" : "cke" ,
p_DATA_RATE_TQ = "BUF", "odt" : "odt" ,
i_RST = ResetSignal() | self._rst.storage, }
i_CLK = ClockSignal(ddr_clk), if hasattr(pads, "reset_n"): commands.update({"reset_n" : "reset_n"})
i_CLKDIV = ClockSignal(), if hasattr(pads, "cs_n") : commands.update({"cs_n" : "cs_n"})
**{f"i_D{n+1}": dfi.phases[n//2].address[i] for n in range(8)}, for pad_name, dfi_name in commands.items():
i_OCE = 1, pad = getattr(pads, pad_name)
o_OQ = address if with_odelay else pads.a[i], for i in range(len(pad)):
) oq = Signal()
if with_odelay:
self.specials += Instance("ODELAYE2",
p_SIGNAL_PATTERN = "DATA",
p_DELAY_SRC = "ODATAIN",
p_CINVCTRL_SEL = "FALSE",
p_HIGH_PERFORMANCE_MODE = "TRUE",
p_PIPE_SEL = "FALSE",
p_REFCLK_FREQUENCY = iodelay_clk_freq/1e6,
p_ODELAY_TYPE = "VARIABLE",
p_ODELAY_VALUE = 0,
i_C = ClockSignal(),
i_LD = self._cdly_rst.re | self._rst.storage,
i_LDPIPEEN = 0,
i_CE = self._cdly_inc.re,
i_INC = 1,
o_ODATAIN = address,
o_DATAOUT = pads.a[i],
)
for i in range(bankbits):
bank = Signal()
self.specials += Instance("OSERDESE2",
p_SERDES_MODE = "MASTER",
p_DATA_WIDTH = 2*nphases,
p_TRISTATE_WIDTH = 1,
p_DATA_RATE_OQ = "DDR",
p_DATA_RATE_TQ = "BUF",
i_RST = ResetSignal() | self._rst.storage,
i_CLK = ClockSignal(ddr_clk),
i_CLKDIV = ClockSignal(),
**{f"i_D{n+1}": dfi.phases[n//2].bank[i] for n in range(8)},
i_OCE = 1,
o_OQ = bank if with_odelay else pads.ba[i],
)
if with_odelay:
self.specials += Instance("ODELAYE2",
p_SIGNAL_PATTERN = "DATA",
p_DELAY_SRC = "ODATAIN",
p_CINVCTRL_SEL = "FALSE",
p_HIGH_PERFORMANCE_MODE = "TRUE",
p_PIPE_SEL = "FALSE",
p_REFCLK_FREQUENCY = iodelay_clk_freq/1e6,
p_ODELAY_TYPE = "VARIABLE",
p_ODELAY_VALUE = 0,
i_C = ClockSignal(),
i_LD = self._cdly_rst.re | self._rst.storage,
i_LDPIPEEN = 0,
i_CE = self._cdly_inc.re,
i_INC = 1,
o_ODATAIN = bank,
o_DATAOUT = pads.ba[i],
)
controls = ["ras_n", "cas_n", "we_n", "cke", "odt"]
if hasattr(pads, "reset_n"):
controls.append("reset_n")
if hasattr(pads, "cs_n"):
controls.append("cs_n")
for name in controls:
for i in range(len(getattr(pads, name))):
cmd = Signal()
self.specials += Instance("OSERDESE2", self.specials += Instance("OSERDESE2",
p_SERDES_MODE = "MASTER", p_SERDES_MODE = "MASTER",
p_DATA_WIDTH = 2*nphases, p_DATA_WIDTH = 2*nphases,
@ -238,9 +179,9 @@ class S7DDRPHY(Module, AutoCSR):
i_RST = ResetSignal() | self._rst.storage, i_RST = ResetSignal() | self._rst.storage,
i_CLK = ClockSignal(ddr_clk), i_CLK = ClockSignal(ddr_clk),
i_CLKDIV = ClockSignal(), i_CLKDIV = ClockSignal(),
**{f"i_D{n+1}": getattr(dfi.phases[n//2], name)[i] for n in range(8)}, **{f"i_D{n+1}": getattr(dfi.phases[n//2], dfi_name)[i] for n in range(8)},
i_OCE = 1, i_OCE = 1,
o_OQ = cmd if with_odelay else getattr(pads, name)[i], o_OQ = oq if with_odelay else pad[i],
) )
if with_odelay: if with_odelay:
self.specials += Instance("ODELAYE2", self.specials += Instance("ODELAYE2",
@ -257,8 +198,8 @@ class S7DDRPHY(Module, AutoCSR):
i_LDPIPEEN = 0, i_LDPIPEEN = 0,
i_CE = self._cdly_inc.re, i_CE = self._cdly_inc.re,
i_INC = 1, i_INC = 1,
o_ODATAIN = cmd, o_ODATAIN = oq,
o_DATAOUT = getattr(pads, name)[i], o_DATAOUT = pad[i],
) )
# DQS -------------------------------------------------------------------------------------- # DQS --------------------------------------------------------------------------------------
@ -316,7 +257,6 @@ class S7DDRPHY(Module, AutoCSR):
io_IOB = pads.dqs_n[i], io_IOB = pads.dqs_n[i],
) )
# DM --------------------------------------------------------------------------------------- # DM ---------------------------------------------------------------------------------------
for i in range(databits//8): for i in range(databits//8):
dm_o_nodelay = Signal() dm_o_nodelay = Signal()