litex/misoc/cores/sdram/test/bankmachine_tb.py

44 lines
1.3 KiB
Python
Raw Normal View History

2015-09-22 12:36:47 -04:00
from migen import *
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.code import lasmibus
from misoc.mem.sdram.core.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
2015-04-13 10:47:22 -04:00
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
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):
def __init__(self):
self.req = Interface(32, 32, 1,
sdram_timing.req_queue_size, sdram_phy.read_latency, sdram_phy.write_latency)
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
2013-07-15 11:45:55 -04:00
def do_simulation(self, selfp):
if selfp.req.dat_ack:
self.dat_ack_cnt += 1
if selfp.req.req_ack:
try:
we, adr = next(self.generator)
except StopIteration:
selfp.req.stb = 0
if not selfp.req.lock:
print("data ack count: {0}".format(self.dat_ack_cnt))
raise StopSimulation
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")