litex/milkymist/asmicon/__init__.py

64 lines
2.2 KiB
Python
Raw Normal View History

2012-03-14 13:26:05 -04:00
from migen.fhdl.structure import *
from migen.fhdl.module import Module
2012-03-14 13:26:05 -04:00
from migen.bus import dfi, asmibus
from milkymist.asmicon.refresher import *
from milkymist.asmicon.bankmachine import *
from milkymist.asmicon.multiplexer import *
class PhySettings:
2012-03-17 19:12:03 -04:00
def __init__(self, dfi_d, nphases, rdphase, wrphase):
2012-03-14 13:26:05 -04:00
self.dfi_d = dfi_d
self.nphases = nphases
self.rdphase = rdphase
self.wrphase = wrphase
class GeomSettings:
2012-03-15 15:29:26 -04:00
def __init__(self, bank_a, row_a, col_a):
self.bank_a = bank_a
2012-03-14 13:26:05 -04:00
self.row_a = row_a
self.col_a = col_a
2012-03-17 19:12:03 -04:00
self.mux_a = max(row_a, col_a)
2012-03-14 13:26:05 -04:00
class TimingSettings:
2012-07-13 13:25:38 -04:00
def __init__(self, tRP, tRCD, tWR, tREFI, tRFC, CL, rd_delay, read_time, write_time, slot_time=0):
2012-03-15 15:29:26 -04:00
self.tRP = tRP
2012-03-17 19:12:03 -04:00
self.tRCD = tRCD
2012-03-18 17:11:01 -04:00
self.tWR = tWR
2012-03-14 13:26:05 -04:00
self.tREFI = tREFI
self.tRFC = tRFC
2012-03-18 17:11:01 -04:00
self.CL = CL
self.rd_delay = rd_delay
self.read_time = read_time
self.write_time = write_time
2012-07-13 13:25:38 -04:00
self.slot_time = slot_time
2012-03-14 13:26:05 -04:00
class ASMIcon(Module):
def __init__(self, phy_settings, geom_settings, timing_settings, full_selector=False):
2012-03-14 13:26:05 -04:00
self.phy_settings = phy_settings
self.geom_settings = geom_settings
self.timing_settings = timing_settings
self.full_selector = full_selector
2012-03-14 13:26:05 -04:00
2012-03-17 19:12:03 -04:00
self.dfi = dfi.Interface(self.geom_settings.mux_a,
2012-03-15 15:29:26 -04:00
self.geom_settings.bank_a,
2012-03-14 13:26:05 -04:00
self.phy_settings.dfi_d,
self.phy_settings.nphases)
burst_length = self.phy_settings.nphases*2
self.address_align = log2_int(burst_length)
2012-03-15 15:29:26 -04:00
aw = self.geom_settings.bank_a + self.geom_settings.row_a + self.geom_settings.col_a - self.address_align
2012-03-14 13:26:05 -04:00
dw = self.phy_settings.dfi_d*self.phy_settings.nphases
self.submodules.hub = asmibus.Hub(aw, dw, self.timing_settings.slot_time)
2012-03-14 13:26:05 -04:00
def do_finalize(self):
2012-03-14 13:26:05 -04:00
slots = self.hub.get_slots()
self.submodules.refresher = Refresher(self.geom_settings.mux_a, self.geom_settings.bank_a,
2012-03-15 15:29:26 -04:00
self.timing_settings.tRP, self.timing_settings.tREFI, self.timing_settings.tRFC)
self.submodules.bank_machines = [BankMachine(self.geom_settings, self.timing_settings, self.address_align, i, slots, self.full_selector)
for i in range(2**self.geom_settings.bank_a)]
self.submodules.multiplexer = Multiplexer(self.phy_settings, self.geom_settings, self.timing_settings,
2012-03-14 13:26:05 -04:00
self.bank_machines, self.refresher,
self.dfi, self.hub)