litex/litesata/test/bist_tb.py

46 lines
1.3 KiB
Python
Raw Normal View History

2015-01-16 17:52:41 -05:00
from litesata.common import *
from litesata import LiteSATA
from litesata.frontend.bist import LiteSATABISTGenerator, LiteSATABISTChecker
2014-12-15 10:44:12 -05:00
2015-01-16 17:52:41 -05:00
from litesata.test.hdd import *
from litesata.test.common import *
2014-12-15 10:44:12 -05:00
class TB(Module):
def __init__(self):
self.hdd = HDD(
link_debug=False, link_random_level=0,
2014-12-15 10:44:12 -05:00
transport_debug=False, transport_loopback=False,
hdd_debug=True)
2015-01-16 17:52:41 -05:00
self.controller = LiteSATA(self.hdd.phy, with_crossbar=True)
self.generator = LiteSATABISTGenerator(self.controller.crossbar.get_port())
self.checker = LiteSATABISTChecker(self.controller.crossbar.get_port())
2014-12-15 10:44:12 -05:00
def gen_simulation(self, selfp):
hdd = self.hdd
hdd.malloc(0, 64)
2015-01-14 03:19:41 -05:00
selfp.generator.sector = 0
selfp.generator.count = 17
selfp.checker.sector = 0
selfp.checker.count = 17
2014-12-15 10:44:12 -05:00
while True:
2015-01-14 03:19:41 -05:00
selfp.generator.start = 1
2014-12-15 10:44:12 -05:00
yield
2015-01-14 03:19:41 -05:00
selfp.generator.start = 0
2014-12-15 10:44:12 -05:00
yield
2015-01-14 03:19:41 -05:00
while selfp.generator.done == 0:
2014-12-15 10:44:12 -05:00
yield
2015-01-14 03:19:41 -05:00
selfp.checker.start = 1
2015-01-07 16:15:57 -05:00
yield
2015-01-14 03:19:41 -05:00
selfp.checker.start = 0
2015-01-07 16:15:57 -05:00
yield
2015-01-14 03:19:41 -05:00
while selfp.checker.done == 0:
2015-01-07 16:15:57 -05:00
yield
2015-01-14 03:19:41 -05:00
print("errors {}".format(selfp.checker.errors))
selfp.generator.sector += 1
selfp.generator.count = max((selfp.generator.count + 1)%8, 1)
selfp.checker.sector += 1
selfp.checker.count = max((selfp.checker.count + 1)%8, 1)
2014-12-15 10:44:12 -05:00
if __name__ == "__main__":
2014-12-15 13:48:22 -05:00
run_simulation(TB(), ncycles=8192*2, vcd_name="my.vcd", keep_files=True)