core: change cba_shift parameter to more explicit address_mapping parameter

This commit is contained in:
Florent Kermarrec 2018-10-19 17:38:04 +02:00
parent 230ea24113
commit ab0d519ebb
3 changed files with 19 additions and 7 deletions

View File

@ -71,6 +71,7 @@ def data_layout(data_width):
class LiteDRAMInterface(Record): class LiteDRAMInterface(Record):
def __init__(self, address_align, settings): def __init__(self, address_align, settings):
rankbits = log2_int(settings.phy.nranks) rankbits = log2_int(settings.phy.nranks)
self.address_align = address_align
self.address_width = settings.geom.rowbits + settings.geom.colbits + rankbits - address_align self.address_width = settings.geom.rowbits + settings.geom.colbits + rankbits - address_align
self.data_width = settings.phy.dfi_databits*settings.phy.nphases self.data_width = settings.phy.dfi_databits*settings.phy.nphases
self.nbanks = settings.phy.nranks*(2**settings.geom.bankbits) self.nbanks = settings.phy.nranks*(2**settings.geom.bankbits)

View File

@ -22,6 +22,7 @@ class ControllerSettings(Settings):
class LiteDRAMController(Module): class LiteDRAMController(Module):
def __init__(self, phy_settings, geom_settings, timing_settings, def __init__(self, phy_settings, geom_settings, timing_settings,
controller_settings=ControllerSettings()): controller_settings=ControllerSettings()):
address_align = log2_int(burst_lengths[phy_settings.memtype])
self.settings = settings = controller_settings self.settings = settings = controller_settings
self.settings.phy = phy_settings self.settings.phy = phy_settings
self.settings.geom = geom_settings self.settings.geom = geom_settings
@ -34,13 +35,10 @@ class LiteDRAMController(Module):
phy_settings.dfi_databits, phy_settings.dfi_databits,
phy_settings.nphases) phy_settings.nphases)
address_align = log2_int(burst_lengths[phy_settings.memtype])
self.interface = interface = LiteDRAMInterface(address_align, settings) self.interface = interface = LiteDRAMInterface(address_align, settings)
# # # # # #
self.nrowbits = settings.geom.colbits - address_align # FIXME
# refresher # refresher
refresher = Refresher(settings) refresher = Refresher(settings)
self.submodules += refresher self.submodules += refresher

View File

@ -12,10 +12,14 @@ from litedram.common import *
from litedram.frontend.adaptation import * from litedram.frontend.adaptation import *
ROW_BANK_COL = 0b01
ROW_COL_BANK = 0b10
class LiteDRAMCrossbar(Module): class LiteDRAMCrossbar(Module):
def __init__(self, controller, cba_shift): def __init__(self, controller, address_mapping=ROW_BANK_COL):
self.controller = controller self.controller = controller
self.cba_shift = cba_shift self.address_mapping = address_mapping
self.rca_bits = controller.address_width self.rca_bits = controller.address_width
self.nbanks = controller.nbanks self.nbanks = controller.nbanks
@ -86,8 +90,17 @@ class LiteDRAMCrossbar(Module):
def do_finalize(self): def do_finalize(self):
nmasters = len(self.masters) nmasters = len(self.masters)
m_ba = [m.get_bank_address(self.bank_bits, self.cba_shift)for m in self.masters] # address mapping
m_rca = [m.get_row_column_address(self.bank_bits, self.rca_bits, self.cba_shift) for m in self.masters] cba_shift = {
ROW_BANK_COL: self.controller.settings.geom.colbits -
self.controller.address_align,
ROW_COL_BANK: self.controller.settings.geom.rowbits +
self.controller.settings.geom.colbits -
self.controller.address_align
}
m_ba = [m.get_bank_address(self.bank_bits, cba_shift[self.address_mapping])for m in self.masters]
m_rca = [m.get_row_column_address(self.bank_bits, self.rca_bits, cba_shift[self.address_mapping]) for m in self.masters]
controller = self.controller controller = self.controller
master_readys = [0]*nmasters master_readys = [0]*nmasters