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,
[...]
This commit is contained in:
Florent Kermarrec 2020-04-29 10:34:34 +02:00
parent 20a849c652
commit 9a2d3f0eb9
1 changed files with 22 additions and 0 deletions

View File

@ -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