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 11:45:55 -04:00
|
|
|
|
2015-09-22 12:35:02 -04:00
|
|
|
from misoc.mem.sdram.core import lasmibus
|
|
|
|
from misoc.mem.sdram.core.lasmicon import *
|
2013-07-15 11:45:55 -04:00
|
|
|
|
|
|
|
from common import sdram_phy, sdram_geom, sdram_timing, DFILogger
|
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-07-15 11:45:55 -04:00
|
|
|
def my_generator_r(n):
|
2015-04-13 10:19:55 -04:00
|
|
|
for x in range(10):
|
|
|
|
t = TRead(128*n + 48*n*x)
|
|
|
|
yield t
|
|
|
|
print("{0:3}: reads done".format(n))
|
2013-07-15 11:45:55 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-07-15 11:45:55 -04:00
|
|
|
def my_generator_w(n):
|
2015-04-13 10:19:55 -04:00
|
|
|
for x in range(10):
|
|
|
|
t = TWrite(128*n + 48*n*x, x)
|
|
|
|
yield t
|
|
|
|
print("{0:3}: writes done".format(n))
|
2013-07-15 11:45:55 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-07-15 11:45:55 -04:00
|
|
|
def my_generator(n):
|
2015-04-13 10:19:55 -04:00
|
|
|
if n % 2:
|
|
|
|
return my_generator_w(n // 2)
|
|
|
|
else:
|
|
|
|
return my_generator_r(n // 2)
|
2013-07-15 11:45:55 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-07-15 11:45:55 -04:00
|
|
|
class TB(Module):
|
2015-04-13 10:19:55 -04:00
|
|
|
def __init__(self):
|
|
|
|
self.submodules.dut = LASMIcon(sdram_phy, sdram_geom, sdram_timing)
|
|
|
|
self.submodules.xbar = lasmibus.Crossbar([self.dut.lasmic], self.dut.nrowbits)
|
|
|
|
self.submodules.logger = DFILogger(self.dut.dfi)
|
2013-07-15 11:45:55 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
masters = [self.xbar.get_master() for i in range(6)]
|
|
|
|
self.initiators = [Initiator(my_generator(n), master)
|
|
|
|
for n, master in enumerate(masters)]
|
|
|
|
self.submodules += self.initiators
|
2013-07-15 11:45:55 -04:00
|
|
|
|
2014-01-28 07:50:01 -05:00
|
|
|
if __name__ == "__main__":
|
2015-04-13 10:19:55 -04:00
|
|
|
run_simulation(TB(), vcd_name="my.vcd")
|