From 9a2d3f0eb9ae059077db6972f362f02b5d4a6a4e Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 29 Apr 2020 10:34:34 +0200 Subject: [PATCH] common: add PHYPadsReducer to only use specific DRAM modules. For example on KC705, to only use the 4 first modules (bytes): from litedram.common import PHYPadsReducer ddram_pads = platform.request("ddram") ddram_pads = PHYPadsReducer(ddram_pads, modules=[0, 1, 2, 3]) self.submodules.ddrphy = s7ddrphy.K7DDRPHY(ddram_pads, [...] On Arty, to only use the second module (byte): from litedram.common import PHYPadsReducer ddram_pads = platform.request("ddram") ddram_pads = PHYPadsReducer(ddram_pads, modules=[1]) self.submodules.ddrphy = s7ddrphy.A7DDRPHY(ddram_pads, [...] --- litedram/common.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/litedram/common.py b/litedram/common.py index b5d7eab..b15ac63 100644 --- a/litedram/common.py +++ b/litedram/common.py @@ -55,6 +55,28 @@ def get_sys_phases(nphases, sys_latency, cas_latency): # PHY Pads Transformers ---------------------------------------------------------------------------- +class PHYPadsReducer: + """PHY Pads Reducer + + Reduce DRAM pads to only use specific modules. + + For testing purposes, we often need to use only some of the DRAM modules. PHYPadsReducer allows + selecting specific modules and avoid re-definining dram pins in the Platform for this. + """ + def __init__(self, pads, modules): + self.pads = pads + self.modules = modules + + def __getattr__(self, name): + if name in ["dq"]: + return Array([getattr(self.pads, name)[8*i + j] + for i in self.modules + for j in range(8)]) + if name in ["dm", "dqs", "dqs_p", "dqs_n"]: + return Array([getattr(self.pads, name)[i] for i in self.modules]) + else: + return getattr(self.pads, name) + class PHYPadsCombiner: """PHY Pads Combiner