litex/tb/lasmicon/lasmicon.py

47 lines
1.1 KiB
Python
Raw Normal View History

2013-07-15 11:45:55 -04:00
from migen.fhdl.std import *
from migen.bus.lasmibus import *
from migen.sim.generic import Simulator, TopLevel
2013-11-09 09:27:32 -05:00
from misoclib.lasmicon import *
2013-07-15 11:45:55 -04:00
from common import sdram_phy, sdram_geom, sdram_timing, DFILogger
def my_generator_r(n):
for x in range(10):
t = TRead(128*n + 48*n*x)
yield t
print("{0:3}: reads done".format(n))
def my_generator_w(n):
for x in range(10):
t = TWrite(128*n + 48*n*x, x)
yield t
print("{0:3}: writes done".format(n))
def my_generator(n):
if n % 2:
return my_generator_w(n // 2)
else:
return my_generator_r(n // 2)
class TB(Module):
def __init__(self):
self.submodules.dut = LASMIcon(sdram_phy, sdram_geom, sdram_timing)
2013-11-23 11:51:41 -05:00
self.submodules.xbar = lasmibus.Crossbar([self.dut.lasmic], self.dut.nrowbits)
2013-07-15 11:45:55 -04:00
self.submodules.logger = DFILogger(self.dut.dfi)
2013-11-23 11:51:41 -05:00
masters = [self.xbar.get_master() for i in range(6)]
2013-07-15 11:45:55 -04:00
self.initiators = [Initiator(my_generator(n), master)
2013-11-23 11:51:41 -05:00
for n, master in enumerate(masters)]
2013-07-15 11:45:55 -04:00
self.submodules += self.initiators
def do_simulation(self, s):
s.interrupt = all(initiator.done for initiator in self.initiators)
def main():
sim = Simulator(TB(), TopLevel("my.vcd"))
sim.run()
main()