litex/test/test_bist.py

49 lines
1007 B
Python
Raw Normal View History

2014-12-22 18:41:39 -05:00
import time
from config import *
from tools import *
2014-12-22 19:39:41 -05:00
sector_size = 512
2014-12-22 18:41:39 -05:00
wb.open()
###
class SATABISTDriver:
def __init__(self, regs):
self.regs = regs
self.last_sector = 0
self.last_time = time.time()
self.last_errors = 0
def start_loopback(self, sector, count):
self.regs.bist_start_sector.write(sector)
self.regs.bist_count.write(count)
self.regs.bist_stop.write(0)
self.regs.bist_start.write(1)
def stop(self):
self.regs.bist_stop.write(1)
def show_status(self):
errors = self.regs.bist_errors.read() - self.last_errors
self.last_errors += errors
sector = self.regs.bist_sector.read()
n = sector - self.last_sector
self.last_sector = sector
t = self.last_time - time.time()
self.last_time = time.time()
print("%4.2f Mb/sec errors=%d sector=%d" %(n*512*8*2/(1024*1024), errors, sector))
bist = SATABISTDriver(wb.regs)
try:
bist.start_loopback(0, 4)
while True:
bist.show_status()
time.sleep(1)
except KeyboardInterrupt:
pass
bist.stop()
2014-12-22 18:41:39 -05:00
###
wb.close()