common/PHYPadsReducer: make Cat optional (disabled by default).

This commit is contained in:
Florent Kermarrec 2020-09-04 11:10:48 +02:00
parent 543a94dd33
commit 3bab6f2024
1 changed files with 9 additions and 6 deletions

View File

@ -66,17 +66,20 @@ class PHYPadsReducer:
For testing purposes, we often need to use only some of the DRAM modules. PHYPadsReducer allows 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. selecting specific modules and avoid re-definining dram pins in the Platform for this.
""" """
def __init__(self, pads, modules): def __init__(self, pads, modules, with_cat=False):
self.pads = pads self.pads = pads
self.modules = modules self.modules = modules
self.with_cat = with_cat
def __getattr__(self, name): def __getattr__(self, name):
if name in ["dq"]: if name in ["dq"]:
return Cat(Array([getattr(self.pads, name)[8*i + j] r = Array([getattr(self.pads, name)[8*i + j]
for i in self.modules for i in self.modules
for j in range(8)])) for j in range(8)])
return r if not self.with_cat else Cat(r)
if name in ["dm", "dqs", "dqs_p", "dqs_n"]: if name in ["dm", "dqs", "dqs_p", "dqs_n"]:
return Cat(Array([getattr(self.pads, name)[i] for i in self.modules])) r = Array([getattr(self.pads, name)[i] for i in self.modules])
return r if not self.with_cat else Cat(r)
else: else:
return getattr(self.pads, name) return getattr(self.pads, name)