litex/misoclib/mem/sdram/test/bankmachine_tb.py

42 lines
1.1 KiB
Python
Raw Normal View History

2013-07-15 11:45:55 -04:00
from migen.fhdl.std import *
from migen.sim.generic import run_simulation
2013-07-15 11:45:55 -04:00
from misoclib.mem.sdram.bus import lasmibus
from misoclib.mem.sdram.lasmicon.bankmachine import *
2013-07-15 11:45:55 -04:00
from common import sdram_phy, sdram_geom, sdram_timing, CommandLogger
2013-07-15 11:45:55 -04:00
def my_generator():
for x in range(10):
yield True, x
for x in range(10):
yield False, 128*x
class TB(Module):
def __init__(self):
self.req = Interface(32, 32, 1,
sdram_timing.req_queue_size, sdram_phy.read_latency, sdram_phy.write_latency)
2013-07-15 11:45:55 -04:00
self.submodules.dut = BankMachine(sdram_geom, sdram_timing, 2, 0, self.req)
self.submodules.logger = CommandLogger(self.dut.cmd, True)
self.generator = my_generator()
self.dat_ack_cnt = 0
def do_simulation(self, selfp):
if selfp.req.dat_ack:
2013-07-15 11:45:55 -04:00
self.dat_ack_cnt += 1
if selfp.req.req_ack:
2013-07-15 11:45:55 -04:00
try:
we, adr = next(self.generator)
except StopIteration:
selfp.req.stb = 0
if not selfp.req.lock:
2013-07-15 11:45:55 -04:00
print("data ack count: {0}".format(self.dat_ack_cnt))
raise StopSimulation
2013-07-15 11:45:55 -04:00
return
selfp.req.adr = adr
selfp.req.we = we
selfp.req.stb = 1
2013-07-15 11:45:55 -04:00
if __name__ == "__main__":
run_simulation(TB(), vcd_name="my.vcd")