2015-09-22 12:36:47 -04:00
|
|
|
from migen import *
|
2013-06-11 08:18:16 -04:00
|
|
|
|
2015-09-25 06:43:20 -04:00
|
|
|
from misoc.interconnect import dfi, lasmi_bus
|
|
|
|
from misoc.cores.lasmicon.refresher import *
|
|
|
|
from misoc.cores.lasmicon.bankmachine import *
|
|
|
|
from misoc.cores.lasmicon.multiplexer import *
|
2013-06-11 08:18:16 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2015-10-01 23:17:47 -04:00
|
|
|
class ControllerSettings:
|
|
|
|
def __init__(self, req_queue_size=8, read_time=32, write_time=16, with_bandwidth=False):
|
2015-04-13 10:19:55 -04:00
|
|
|
self.req_queue_size = req_queue_size
|
|
|
|
self.read_time = read_time
|
|
|
|
self.write_time = write_time
|
2015-10-01 23:17:47 -04:00
|
|
|
self.with_bandwidth = with_bandwidth
|
2015-03-21 17:51:24 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-06-11 08:18:16 -04:00
|
|
|
class LASMIcon(Module):
|
2015-10-01 23:17:47 -04:00
|
|
|
def __init__(self, phy_settings, geom_settings, timing_settings,
|
|
|
|
controller_settings=None):
|
|
|
|
if controller_settings is None:
|
|
|
|
controller_settings = ControllerSettings()
|
2015-04-13 10:19:55 -04:00
|
|
|
if phy_settings.memtype in ["SDR"]:
|
2015-04-13 11:16:12 -04:00
|
|
|
burst_length = phy_settings.nphases*1 # command multiplication*SDR
|
2015-04-13 10:19:55 -04:00
|
|
|
elif phy_settings.memtype in ["DDR", "LPDDR", "DDR2", "DDR3"]:
|
2015-04-13 11:16:12 -04:00
|
|
|
burst_length = phy_settings.nphases*2 # command multiplication*DDR
|
2015-04-13 10:19:55 -04:00
|
|
|
address_align = log2_int(burst_length)
|
2013-06-11 08:18:16 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
self.dfi = dfi.Interface(geom_settings.addressbits,
|
|
|
|
geom_settings.bankbits,
|
|
|
|
phy_settings.dfi_databits,
|
|
|
|
phy_settings.nphases)
|
2015-09-25 06:43:20 -04:00
|
|
|
self.lasmic = lasmi_bus.Interface(
|
2015-04-13 10:19:55 -04:00
|
|
|
aw=geom_settings.rowbits + geom_settings.colbits - address_align,
|
|
|
|
dw=phy_settings.dfi_databits*phy_settings.nphases,
|
|
|
|
nbanks=2**geom_settings.bankbits,
|
|
|
|
req_queue_size=controller_settings.req_queue_size,
|
|
|
|
read_latency=phy_settings.read_latency+1,
|
|
|
|
write_latency=phy_settings.write_latency+1)
|
|
|
|
self.nrowbits = geom_settings.colbits - address_align
|
2014-10-17 05:14:35 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
###
|
2013-06-11 08:18:16 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
self.submodules.refresher = Refresher(geom_settings.addressbits, geom_settings.bankbits,
|
2015-09-24 04:01:08 -04:00
|
|
|
timing_settings.tRP, timing_settings.tREFI, timing_settings.tRFC)
|
2015-04-13 10:19:55 -04:00
|
|
|
self.submodules.bank_machines = [BankMachine(geom_settings, timing_settings, controller_settings, address_align, i,
|
|
|
|
getattr(self.lasmic, "bank"+str(i)))
|
|
|
|
for i in range(2**geom_settings.bankbits)]
|
|
|
|
self.submodules.multiplexer = Multiplexer(phy_settings, geom_settings, timing_settings, controller_settings,
|
|
|
|
self.bank_machines, self.refresher,
|
2015-10-01 23:17:47 -04:00
|
|
|
self.dfi, self.lasmic)
|
2013-06-15 06:51:11 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
def get_csrs(self):
|
|
|
|
return self.multiplexer.get_csrs()
|