from misoclib.mem import sdram
class SDRAMModule:
- def __init__(self, clk_freq, geom_settings, timing_settings):
+ def __init__(self, clk_freq, memtype, geom_settings, timing_settings):
self.clk_freq = clk_freq
+ self.memtype = memtype
self.geom_settings = sdram.GeomSettings(
databits=geom_settings["nbits"],
bankbits=log2_int(geom_settings["nbanks"]),
"tRFC": 70
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "SDR", self.geom_settings,
self.timing_settings)
class MT48LC4M16(SDRAMModule):
"tRFC": 66
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "SDR", self.geom_settings,
self.timing_settings)
class AS4C16M16(SDRAMModule):
"tRFC": 60
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "SDR", self.geom_settings,
self.timing_settings)
# DDR
"tRFC": 70
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "DDR", self.geom_settings,
self.timing_settings)
# LPDDR
"tRFC": 72
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "LPDDR", self.geom_settings,
self.timing_settings)
# DDR2
"tRFC": 127.5
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "DDR2", self.geom_settings,
self.timing_settings)
# DDR3
"tRFC": 70
}
def __init__(self, clk_freq):
- SDRAMModule.__init__(self, clk_freq, self.geom_settings,
+ SDRAMModule.__init__(self, clk_freq, "DDR3", self.geom_settings,
self.timing_settings)
from misoclib.mem import sdram
class GENSDRPHY(Module):
- def __init__(self, pads):
+ def __init__(self, pads, module):
addressbits = flen(pads.a)
bankbits = flen(pads.ba)
databits = flen(pads.dq)
self.settings = sdram.PhySettings(
- memtype="SDR",
+ memtype=module.memtype,
dfi_databits=databits,
nphases=1,
rdphase=0,
read_latency=4,
write_latency=0
)
+ self.module = module
self.dfi = Interface(addressbits, bankbits, databits)
from misoclib.mem import sdram
class K7DDRPHY(Module, AutoCSR):
- def __init__(self, pads, memtype):
+ def __init__(self, pads, module):
addressbits = flen(pads.a)
bankbits = flen(pads.ba)
databits = flen(pads.dq)
self._wdly_dqs_inc = CSR()
self.settings = sdram.PhySettings(
- memtype=memtype,
+ memtype=module.memtype,
dfi_databits=2*databits,
nphases=nphases,
rdphase=0,
read_latency=6,
write_latency=2
)
+ self.module = module
self.dfi = Interface(addressbits, bankbits, 2*databits, nphases)
from misoclib.mem import sdram
class S6DDRPHY(Module):
- def __init__(self, pads, memtype, rd_bitslip, wr_bitslip, dqs_ddr_alignment):
- if memtype not in ["DDR", "LPDDR", "DDR2"]:
+ def __init__(self, pads, module, rd_bitslip, wr_bitslip, dqs_ddr_alignment):
+ if module.memtype not in ["DDR", "LPDDR", "DDR2"]:
raise NotImplementedError("S6DDRPHY only supports DDR, LPDDR and DDR2")
addressbits = flen(pads.a)
bankbits = flen(pads.ba)
nphases = 2
self.settings = sdram.PhySettings(
- memtype=memtype,
+ memtype=module.memtype,
dfi_databits=2*databits,
nphases=nphases,
rdphase=0,
read_latency=5,
write_latency=0
)
+ self.module = module
self.dfi = Interface(addressbits, bankbits, 2*databits, nphases)
self.clk4x_wr_strb = Signal()
self.sdram_controller_settings = sdram_controller_settings
self._sdram_phy_registered = False
- def register_sdram_phy(self, phy, geom_settings, timing_settings):
+ def register_sdram_phy(self, phy):
if self._sdram_phy_registered:
raise FinalizeError
self._sdram_phy_registered = True
raise NotImplementedError("Minicon only supports SDR memtype for now (" + phy.settings.memtype + ")")
# Core
- self.submodules.sdram = SDRAMCore(phy, geom_settings, timing_settings, self.sdram_controller_settings)
+ self.submodules.sdram = SDRAMCore(phy, phy.module.geom_settings, phy.module.timing_settings, self.sdram_controller_settings)
# LASMICON frontend
if isinstance(self.sdram_controller_settings, LASMIconSettings):
# MINICON frontend
elif isinstance(self.sdram_controller_settings, MiniconSettings):
sdram_width = flen(self.sdram.controller.bus.dat_r)
- main_ram_size = 2**(geom_settings.bankbits+geom_settings.rowbits+geom_settings.colbits)*sdram_width//8
+ main_ram_size = 2**(phy.module.geom_settings.bankbits+
+ phy.module.geom_settings.rowbits+
+ phy.module.geom_settings.colbits)*sdram_width//8
if sdram_width == 32:
self.register_mem("main_ram", self.mem_map["main_ram"], self.sdram.controller.bus, main_ram_size)
self.submodules.crg = _CRG(platform)
if not self.with_integrated_main_ram:
- sdram_module = IS42S16160(self.clk_freq)
- self.submodules.sdrphy = gensdrphy.GENSDRPHY(platform.request("sdram"))
- self.register_sdram_phy(self.sdrphy, sdram_module.geom_settings, sdram_module.timing_settings)
+ self.submodules.sdrphy = gensdrphy.GENSDRPHY(platform.request("sdram"), IS42S16160(self.clk_freq))
+ self.register_sdram_phy(self.sdrphy)
default_subtarget = BaseSoC
self.submodules.crg = _CRG(platform)
if not self.with_integrated_main_ram:
- sdram_modules = MT8JTF12864(self.clk_freq)
- self.submodules.ddrphy = k7ddrphy.K7DDRPHY(platform.request("ddram"), memtype="DDR3")
- self.register_sdram_phy(self.ddrphy, sdram_modules.geom_settings, sdram_modules.timing_settings)
+ self.submodules.ddrphy = k7ddrphy.K7DDRPHY(platform.request("ddram"), MT8JTF12864(self.clk_freq))
+ self.register_sdram_phy(self.ddrphy)
spiflash_pads = platform.request("spiflash")
spiflash_pads.clk = Signal()
self.submodules.crg = _CRG(platform, clk_freq)
if not self.with_integrated_main_ram:
- sdram_module = AS4C16M16(clk_freq)
- self.submodules.sdrphy = gensdrphy.GENSDRPHY(platform.request("sdram"))
- self.register_sdram_phy(self.sdrphy, sdram_module.geom_settings, sdram_module.timing_settings)
+ self.submodules.sdrphy = gensdrphy.GENSDRPHY(platform.request("sdram"), AS4C16M16(clk_freq))
+ self.register_sdram_phy(self.sdrphy)
default_subtarget = BaseSoC
self.submodules.crg = mxcrg.MXCRG(_MXClockPads(platform), self.clk_freq)
if not self.with_integrated_main_ram:
- sdram_modules = MT46V32M16(self.clk_freq)
- self.submodules.ddrphy = s6ddrphy.S6DDRPHY(platform.request("ddram"), memtype="DDR",
+ self.submodules.ddrphy = s6ddrphy.S6DDRPHY(platform.request("ddram"), MT46V32M16(self.clk_freq),
rd_bitslip=0, wr_bitslip=3, dqs_ddr_alignment="C1")
- self.register_sdram_phy(self.ddrphy, sdram_modules.geom_settings, sdram_modules.timing_settings)
+ self.register_sdram_phy(self.ddrphy)
self.comb += [
self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
self.submodules.crg = _CRG(platform, clk_freq)
if not self.with_integrated_main_ram:
- sdram_module = MT46H32M16(self.clk_freq)
- self.submodules.ddrphy = s6ddrphy.S6DDRPHY(platform.request("ddram"),
- "LPDDR", rd_bitslip=1, wr_bitslip=3, dqs_ddr_alignment="C1")
+ self.submodules.ddrphy = s6ddrphy.S6DDRPHY(platform.request("ddram"), MT46H32M16(self.clk_freq),
+ rd_bitslip=1, wr_bitslip=3, dqs_ddr_alignment="C1")
self.comb += [
self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb),
platform.add_platform_command("""
PIN "BUFG.O" CLOCK_DEDICATED_ROUTE = FALSE;
""")
- self.register_sdram_phy(self.ddrphy, sdram_module.geom_settings, sdram_module.timing_settings)
+ self.register_sdram_phy(self.ddrphy)
self.submodules.spiflash = spiflash.SpiFlash(platform.request("spiflash4x"), dummy=10, div=4)
# If not in ROM, BIOS is in SPI flash
self.submodules.crg = _CRG(platform, clk_freq)
if not self.with_integrated_main_ram:
- sdram_module = MT48LC4M16(clk_freq)
- self.submodules.sdrphy = gensdrphy.GENSDRPHY(platform.request("sdram"))
- self.register_sdram_phy(self.sdrphy, sdram_module.geom_settings, sdram_module.timing_settings)
+ self.submodules.sdrphy = gensdrphy.GENSDRPHY(platform.request("sdram"), MT48LC4M16(clk_freq))
+ self.register_sdram_phy(self.sdrphy)
self.submodules.spiflash = spiflash.SpiFlash(platform.request("spiflash2x"), dummy=4, div=6)
self.flash_boot_address = 0x70000