from lambdasoc.periph import Peripheral
from gram.dfii import DFIInjector
+from gram.compat import CSRPrefixProxy
from gram.core.controller import ControllerSettings, gramController
from gram.core.crossbar import gramCrossbar
class gramCore(Peripheral, Elaboratable):
def __init__(self, phy, geom_settings, timing_settings, clk_freq, **kwargs):
+ super().__init__()
+
+ bank = self.csr_bank()
+
+ self._zero_ev = self.event(mode="rise")
+
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 = dfii = DFIInjector(
+ self.dfii = DFIInjector(
+ csr_bank = CSRPrefixProxy(bank, "dfii"),
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 += dfii.master.connect(self._phy.dfi)
- m.submodules.controller = controller = gramController(
+ self.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(dfii.slave)
- m.submodules.crossbar = gramCrossbar(controller.interface)
+ self.crossbar = gramCrossbar(self.controller.interface)
+
+ self._bridge = self.bridge(data_width=32, granularity=8, alignment=2)
+ self.bus = self._bridge.bus
+ self.irq = self._bridge.irq
+
+ def elaborate(self, platform):
+ m = Module()
+
+ m.submodules += self.dfii
+ m.d.comb += self.dfii.master.connect(self._phy.dfi)
+
+ m.submodules.controller = self.controller
+ m.d.comb += self.controller.dfi.connect(self.dfii.slave)
+
+ m.submodules += self.crossbar
return m
from nmigen import *
from gram.phy import dfi
+from gram.compat import CSRPrefixProxy
from lambdasoc.periph import Peripheral
# PhaseInjector ------------------------------------------------------------------------------------
-class PhaseInjector(Peripheral, Elaboratable):
- def __init__(self, phase):
- super().__init__(name = "phaseinjector")
-
- bank = self.csr_bank()
- self._command = bank.csr(6, "rw")
- self._command_issue = bank.csr(1, "rw")
- self._address = bank.csr(len(phase.address), "rw")
- self._baddress = bank.csr(len(phase.bank), "rw")
- self._wrdata = bank.csr(len(phase.wrdata), "rw")
- self._rddata = bank.csr(len(phase.rddata), "rw")
+class PhaseInjector(Elaboratable):
+ def __init__(self, csr_bank, phase):
+ self._command = csr_bank.csr(6, "rw")
+ self._command_issue = csr_bank.csr(1, "rw")
+ self._address = csr_bank.csr(len(phase.address), "rw")
+ self._baddress = csr_bank.csr(len(phase.bank), "rw")
+ self._wrdata = csr_bank.csr(len(phase.wrdata), "rw")
+ self._rddata = csr_bank.csr(len(phase.rddata), "rw")
self._phase = phase
# DFIInjector --------------------------------------------------------------------------------------
-class DFIInjector(Peripheral, Elaboratable):
- def __init__(self, addressbits, bankbits, nranks, databits, nphases=1):
- super().__init__(name = "dfii")
-
+class DFIInjector(Elaboratable):
+ def __init__(self, csr_bank, addressbits, bankbits, nranks, databits, nphases=1):
self._nranks = nranks
self._inti = dfi.Interface(addressbits, bankbits, nranks, databits, nphases)
self.slave = dfi.Interface(addressbits, bankbits, nranks, databits, nphases)
self.master = dfi.Interface(addressbits, bankbits, nranks, databits, nphases)
- bank = self.csr_bank()
- self._control = bank.csr(4, "rw") # sel, cke, odt, reset_n
+ self._control = csr_bank.csr(4, "rw") # sel, cke, odt, reset_n
+
+ self._phases = []
+ for n, phase in enumerate(self._inti.phases):
+ self._phases += [PhaseInjector(CSRPrefixProxy(csr_bank, "p{}".format(n)), phase)]
def elaborate(self, platform):
m = Module()
- for n, phase in enumerate(self._inti.phases):
- m.submodules += PhaseInjector(phase)
+ m.submodules += self._phases
with m.If(self._control.r_data[0]):
m.d.comb += self.slave.connect(self.master)