2015-09-22 12:36:47 -04:00
|
|
|
from migen import *
|
2014-01-28 07:50:01 -05:00
|
|
|
from migen.sim.generic import run_simulation
|
2013-07-15 15:34:53 -04:00
|
|
|
|
2015-09-22 12:35:02 -04:00
|
|
|
from misoc.mem.sdram.core import lasmibus
|
|
|
|
from misoc.mem.sdram.core.lasmicon import *
|
|
|
|
from misoc.mem.sdram.frontend import dma_lasmi
|
2013-07-15 15:34:53 -04:00
|
|
|
|
|
|
|
from common import sdram_phy, sdram_geom, sdram_timing, DFILogger
|
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-07-15 15:34:53 -04:00
|
|
|
class TB(Module):
|
2015-04-13 10:19:55 -04:00
|
|
|
def __init__(self):
|
|
|
|
self.submodules.ctler = LASMIcon(sdram_phy, sdram_geom, sdram_timing)
|
|
|
|
self.submodules.xbar = lasmibus.Crossbar([self.ctler.lasmic], self.ctler.nrowbits)
|
|
|
|
self.submodules.logger = DFILogger(self.ctler.dfi)
|
|
|
|
self.submodules.writer = dma_lasmi.Writer(self.xbar.get_master())
|
2013-07-15 15:34:53 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
self.comb += self.writer.address_data.stb.eq(1)
|
|
|
|
pl = self.writer.address_data.payload
|
|
|
|
pl.a.reset = 255
|
|
|
|
pl.d.reset = pl.a.reset*2
|
|
|
|
self.sync += If(self.writer.address_data.ack,
|
|
|
|
pl.a.eq(pl.a + 1),
|
|
|
|
pl.d.eq(pl.d + 2)
|
|
|
|
)
|
|
|
|
self.open_row = None
|
2013-07-15 15:34:53 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
def do_simulation(self, selfp):
|
|
|
|
dfip = selfp.ctler.dfi
|
|
|
|
for p in dfip.phases:
|
2015-04-13 11:16:12 -04:00
|
|
|
if p.ras_n and not p.cas_n and not p.we_n: # write
|
2015-04-13 10:19:55 -04:00
|
|
|
d = dfip.phases[0].wrdata | (dfip.phases[1].wrdata << 64)
|
|
|
|
print(d)
|
|
|
|
if d != p.address//2 + p.bank*512 + self.open_row*2048:
|
|
|
|
print("**** ERROR ****")
|
2015-04-13 11:16:12 -04:00
|
|
|
elif not p.ras_n and p.cas_n and p.we_n: # activate
|
2015-04-13 10:19:55 -04:00
|
|
|
self.open_row = p.address
|
2013-07-15 15:34:53 -04:00
|
|
|
|
2014-01-28 07:50:01 -05:00
|
|
|
if __name__ == "__main__":
|
2015-04-13 10:19:55 -04:00
|
|
|
run_simulation(TB(), ncycles=3500, vcd_name="my.vcd")
|