From 7560435d078327ba9e56e6469ed7bf6aeaf85a31 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Wed, 17 Nov 2021 15:01:36 +0800 Subject: [PATCH] phy/ecp5ddrphy: Bring back dm_remapping This allows swapping UDM/LDM pins. Was removed in https://github.com/enjoy-digital/litedram/commit/af9abd6ec9bef7182ec00fa9d21c32c9faba9f87 phy/ecp5ddrphy: remove dm_remapping introduce for VexRiscv-SMP on OrangeCrab... But is still useful for native port uses of litedram Add dm_swap parameter to gen.py Signed-off-by: Matt Johnston --- litedram/gen.py | 7 ++++++- litedram/phy/ecp5ddrphy.py | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/litedram/gen.py b/litedram/gen.py index 06fb4da..d1fa927 100755 --- a/litedram/gen.py +++ b/litedram/gen.py @@ -582,10 +582,15 @@ class LiteDRAMCore(SoCCore): # ECP5DDRPHY. elif core_config["sdram_phy"] in [litedram_phys.ECP5DDRPHY]: assert core_config["memtype"] in ["DDR3"] + kwargs = {} + if core_config.get("dm_swap", False): + kwargs['dm_remapping'] = {0:1, 1:0} + self.submodules.ddrphy = sdram_phy = core_config["sdram_phy"]( pads = platform.request("ddram"), sys_clk_freq = sys_clk_freq, - cmd_delay = core_config.get("cmd_delay", 0)) + cmd_delay = core_config.get("cmd_delay", 0), + **kwargs) self.ddrphy.settings.add_electrical_settings(**electrical_settings_kwargs) self.comb += crg.stop.eq(self.ddrphy.init.stop) self.comb += crg.reset.eq(self.ddrphy.init.reset) diff --git a/litedram/phy/ecp5ddrphy.py b/litedram/phy/ecp5ddrphy.py index 4f1010e..2aa49ca 100644 --- a/litedram/phy/ecp5ddrphy.py +++ b/litedram/phy/ecp5ddrphy.py @@ -117,7 +117,8 @@ class ECP5DDRPHY(Module, AutoCSR): cl = None, cwl = None, cmd_delay = 0, - clk_polarity = 0): + clk_polarity = 0, + dm_remapping = None): assert isinstance(cmd_delay, int) and cmd_delay < 128 pads = PHYPadsCombiner(pads) memtype = "DDR3" @@ -127,6 +128,8 @@ class ECP5DDRPHY(Module, AutoCSR): nranks = 1 if not hasattr(pads, "cs_n") else len(pads.cs_n) databits = len(pads.dq) nphases = 2 + if not dm_remapping: + dm_remapping = {} assert databits%8 == 0 # Init ------------------------------------------------------------------------------------- @@ -327,7 +330,7 @@ class ECP5DDRPHY(Module, AutoCSR): dm_o_data_d = Signal(8) dm_o_data_muxed = Signal(4) for n in range(8): - self.comb += dm_o_data[n].eq(dfi.phases[n//4].wrdata_mask[n%4*databits//8 + i]) + self.comb += dm_o_data[n].eq(dfi.phases[n//4].wrdata_mask[n%4*databits//8+dm_remapping.get(i, i)]) self.sync += dm_o_data_d.eq(dm_o_data) dm_bl8_cases = {} dm_bl8_cases[0] = dm_o_data_muxed.eq(dm_o_data[:4])