-from migen import *
+from nmigen import *
-from litex.soc.interconnect.csr import AutoCSR
+from lambdasoc.periph import Peripheral
-from litedram.dfii import DFIInjector
-from litedram.core.controller import ControllerSettings, LiteDRAMController
-from litedram.core.crossbar import LiteDRAMCrossbar
+from gram.dfii import DFIInjector
+from gram.core.controller import ControllerSettings, gramController
+from gram.core.crossbar import gramCrossbar
# Core ---------------------------------------------------------------------------------------------
-class LiteDRAMCore(Module, AutoCSR):
+class gramCore(Peripheral, Elaboratable):
def __init__(self, phy, geom_settings, timing_settings, clk_freq, **kwargs):
- self.submodules.dfii = DFIInjector(
- addressbits = geom_settings.addressbits,
- bankbits = geom_settings.bankbits,
- nranks = phy.settings.nranks,
- databits = phy.settings.dfi_databits,
- nphases = phy.settings.nphases)
- self.comb += self.dfii.master.connect(phy.dfi)
-
- self.submodules.controller = controller = LiteDRAMController(
- phy_settings = phy.settings,
- geom_settings = geom_settings,
- timing_settings = timing_settings,
- clk_freq = clk_freq,
- **kwargs)
- self.comb += controller.dfi.connect(self.dfii.slave)
-
- self.submodules.crossbar = LiteDRAMCrossbar(controller.interface)
+ self._phy = phy
+ self._geom_settings = geom_settings
+ self._timing_settings = timing_settings
+ self._clk_freq = clk_freq
+ self._kwargs = kwargs
+
+ def elaborate(self, platform):
+ m = Module()
+
+ m.submodules.dfii = DFIInjector(
+ addressbits = self._geom_settings.addressbits,
+ bankbits = self._geom_settings.bankbits,
+ nranks = self._phy.settings.nranks,
+ databits = self._phy.settings.dfi_databits,
+ nphases = self._phy.settings.nphases)
+ m.d.comb += self.dfii.master.connect(self._phy.dfi)
+
+ m.submodules.controller = controller = gramController(
+ phy_settings = self._phy.settings,
+ geom_settings = self._geom_settings,
+ timing_settings = self._timing_settings,
+ clk_freq = self._clk_freq,
+ **self._kwargs)
+ m.d.comb += controller.dfi.connect(self.dfii.slave)
+
+ m.submodules.crossbar = LiteDRAMCrossbar(controller.interface)
+
+ return m
# Controller ---------------------------------------------------------------------------------------
-class LiteDRAMController(Module):
+class gramController(Elaboratable):
def __init__(self, phy_settings, geom_settings, timing_settings, clk_freq,
controller_settings=ControllerSettings()):
address_align = log2_int(burst_lengths[phy_settings.memtype])
databits = phy_settings.dfi_databits,
nphases = phy_settings.nphases)
- # # #
+ def elaborate(self, platform):
+ m = Module()
# Refresher --------------------------------------------------------------------------------
- self.submodules.refresher = self.settings.refresh_cls(self.settings,
+ m.submodules.refresher = self.settings.refresh_cls(self.settings,
clk_freq = clk_freq,
zqcs_freq = self.settings.refresh_zqcs_freq,
postponing = self.settings.refresh_postponing)
nranks = nranks,
settings = self.settings)
bank_machines.append(bank_machine)
- self.submodules += bank_machine
- self.comb += getattr(interface, "bank"+str(n)).connect(bank_machine.req)
+ m.submodules += bank_machine
+ m.d.comb += getattr(interface, "bank"+str(n)).connect(bank_machine.req)
# Multiplexer ------------------------------------------------------------------------------
- self.submodules.multiplexer = Multiplexer(
+ m.submodules.multiplexer = Multiplexer(
settings = self.settings,
bank_machines = bank_machines,
refresher = self.refresher,
dfi = self.dfi,
interface = interface)
+ return m
+
def get_csrs(self):
return self.multiplexer.get_csrs()