phys: improve handling of required/optional command pads and make cke/odt optional on all phys.

This commit is contained in:
Florent Kermarrec 2021-01-29 09:21:48 +01:00
parent 5a114be7e5
commit 2f5784432d
4 changed files with 64 additions and 43 deletions

View File

@ -200,18 +200,23 @@ class ECP5DDRPHY(Module, AutoCSR):
# Commands -----------------------------------------------------------------------------
commands = {
"a" : "address",
"ba" : "bank" ,
"ras_n": "ras_n" ,
"cas_n": "cas_n" ,
"we_n" : "we_n" ,
"cke" : "cke" ,
"odt" : "odt" ,
# Pad name: (DFI name, Pad type (required or optional))
"reset_n" : ("reset_n", "optional"),
"cs_n" : ("cs_n", "optional"),
"a" : ("address", "required"),
"ba" : ("bank" , "required"),
"ras_n" : ("ras_n" , "required"),
"cas_n" : ("cas_n" , "required"),
"we_n" : ("we_n" , "required"),
"cke" : ("cke" , "optional"),
"odt" : ("odt" , "optional"),
}
if hasattr(pads, "reset_n"): commands.update({"reset_n" : "reset_n"})
if hasattr(pads, "cs_n") : commands.update({"cs_n" : "cs_n"})
for pad_name, dfi_name in commands.items():
pad = getattr(pads, pad_name)
for pad_name, (dfi_name, pad_type) in commands.items():
pad = getattr(pads, pad_name, None)
if (pad is None):
if (pad_type == "required"):
raise ValueError(f"DRAM pad {pad_name} required but not found in pads.")
continue
for i in range(len(pad)):
pad_oddrx2f = Signal()
self.specials += Instance("ODDRX2F",

View File

@ -52,18 +52,24 @@ class GENSDRPHY(Module):
for pads_group in range(len(pads.groups)):
pads.sel_group(pads_group)
# Commands -----------------------------------------------------------------------------
commands = {
"a" : "address",
"ba" : "bank" ,
"ras_n": "ras_n" ,
"cas_n": "cas_n" ,
"we_n" : "we_n" ,
# Pad name: (DFI name, Pad type (required or optional))
"cs_n" : ("cs_n", "optional"),
"a" : ("address", "required"),
"ba" : ("bank" , "required"),
"ras_n" : ("ras_n" , "required"),
"cas_n" : ("cas_n" , "required"),
"we_n" : ("we_n" , "required"),
"cke" : ("cke" , "optional"),
}
if hasattr(pads, "cke") : commands.update({"cke" : "cke"})
if hasattr(pads, "cs_n"): commands.update({"cs_n" : "cs_n"})
for pad_name, dfi_name in commands.items():
pad = getattr(pads, pad_name)
for pad_name, (dfi_name, pad_type) in commands.items():
pad = getattr(pads, pad_name, None)
if (pad is None):
if (pad_type == "required"):
raise ValueError(f"DRAM pad {pad_name} required but not found in pads.")
continue
for i in range(len(pad)):
self.specials += SDROutput(i=getattr(dfi.p0, dfi_name)[i], o=pad[i])

View File

@ -162,18 +162,23 @@ class S7DDRPHY(Module, AutoCSR):
# Commands -----------------------------------------------------------------------------
commands = {
"a" : "address",
"ba" : "bank" ,
"ras_n": "ras_n" ,
"cas_n": "cas_n" ,
"we_n" : "we_n" ,
"cke" : "cke" ,
"odt" : "odt" ,
# Pad name: (DFI name, Pad type (required or optional))
"reset_n" : ("reset_n", "optional"),
"cs_n" : ("cs_n", "optional"),
"a" : ("address", "required"),
"ba" : ("bank" , "required"),
"ras_n" : ("ras_n" , "required"),
"cas_n" : ("cas_n" , "required"),
"we_n" : ("we_n" , "required"),
"cke" : ("cke" , "optional"),
"odt" : ("odt" , "optional"),
}
if hasattr(pads, "reset_n"): commands.update({"reset_n" : "reset_n"})
if hasattr(pads, "cs_n") : commands.update({"cs_n" : "cs_n"})
for pad_name, dfi_name in commands.items():
pad = getattr(pads, pad_name)
for pad_name, (dfi_name, pad_type) in commands.items():
pad = getattr(pads, pad_name, None)
if (pad is None):
if (pad_type == "required"):
raise ValueError(f"DRAM pad {pad_name} required but not found in pads.")
continue
for i in range(len(pad)):
oq = Signal()
self.specials += Instance("OSERDESE2",

View File

@ -186,19 +186,24 @@ class USDDRPHY(Module, AutoCSR):
# Commands -----------------------------------------------------------------------------
pads_ba = Signal(bankbits)
commands = {
"a" : "address",
pads_ba : "bank",
"ras_n" : "ras_n" ,
"cas_n" : "cas_n" ,
"we_n" : "we_n" ,
"cke" : "cke" ,
"odt" : "odt" ,
# Pad name: (DFI name, Pad type (required or optional))
"reset_n" : ("reset_n", "optional"),
"cs_n" : ("cs_n", "optional"),
"a" : ("address", "required"),
pads_ba : ("bank" , "required"),
"ras_n" : ("ras_n" , "required"),
"cas_n" : ("cas_n" , "required"),
"we_n" : ("we_n" , "required"),
"cke" : ("cke" , "optional"),
"odt" : ("odt" , "optional"),
"act_n" : ("act_n", "optional"),
}
if hasattr(pads, "reset_n"): commands.update({"reset_n" : "reset_n"})
if hasattr(pads, "cs_n") : commands.update({"cs_n" : "cs_n"})
if hasattr(pads, "act_n") : commands.update({"act_n" : "act_n"})
for pad_name, dfi_name in commands.items():
pad = pad_name if isinstance(pad_name, Signal) else getattr(pads, pad_name)
for pad_name, (dfi_name, pad_type) in commands.items():
pad = pad_name if isinstance(pad_name, Signal) else getattr(pads, pad_name, None)
if (pad is None):
if (pad_type == "required"):
raise ValueError(f"DRAM pad {pad_name} required but not found in pads.")
continue
for i in range(len(pad)):
o_nodelay = Signal()
self.specials += [