add test_bist_mila to show how to capture data

This commit is contained in:
Florent Kermarrec 2014-12-23 20:56:03 +01:00
parent db711edd89
commit 74dd907503
3 changed files with 42 additions and 79 deletions

View File

@ -189,8 +189,6 @@ class TestDesign(UART2WB, AutoCSR):
debug = (
ctrl.ready,
ctrl.sink.data,
ctrl.sink.charisk,
self.sata_phy.source.stb,
self.sata_phy.source.data,

View File

@ -1,77 +0,0 @@
import time
import argparse
from config import *
sector_size = 512
class SATABISTDriver:
def __init__(self, regs):
self.regs = regs
self.last_sector = 0
self.last_time = time.time()
self.last_errors = 0
self.mode = "rw"
def set_mode(self, mode):
self.mode = mode
self.regs.bist_write_only.write(0)
self.regs.bist_read_only.write(0)
if mode == "wr":
self.regs.bist_write_only.write(1)
if mode == "rd":
self.regs.bist_read_only.write(1)
def start(self, sector, count, mode):
self.set_mode(mode)
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()
if self.mode in ["wr", "rd"]:
speed_mult = 1
else:
speed_mult = 2
print("%4.2f MB/sec errors=%d sector=%d" %(n*sector_size*speed_mult/(1024*1024), errors, sector))
def _get_args():
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
description="""\
SATA BIST utility.
""")
parser.add_argument("-s", "--sector", default=0, help="BIST start sector")
parser.add_argument("-c", "--count", default=4, help="BIST count (number of sectors per transaction)")
parser.add_argument("-m", "--mode", default="rw", help="BIST mode (rw, wr, rd")
return parser.parse_args()
if __name__ == "__main__":
args = _get_args()
wb.open()
###
bist = SATABISTDriver(wb.regs)
try:
bist.start(int(args.sector), int(args.count), args.mode)
while True:
bist.show_status()
time.sleep(1)
except KeyboardInterrupt:
pass
bist.stop()
###
wb.close()

42
test/test_bist_mila.py Normal file
View File

@ -0,0 +1,42 @@
import time
from config import *
from tools import *
from bist import *
from miscope.host.drivers import MiLaDriver
mila = MiLaDriver(wb.regs, "mila")
bist = SATABISTDriver(wb.regs)
wb.open()
regs = wb.regs
###
wr_cond = {
"sata_con_source_source_stb" : 1,
"sata_con_source_source_payload_write" : 1,
}
rd_cond = {
"sata_con_source_source_stb" : 1,
"sata_con_source_source_payload_read" : 1,
}
mila.prog_term(port=0, cond=rd_cond)
mila.prog_sum("term")
# Trigger / wait / receive
mila.trigger(offset=32, length=1024)
bist.start(0, 4, "rw")
mila.wait_done()
bist.stop()
mila.read()
mila.export("dump.vcd")
###
wb.close()
print_link_trace(mila,
tx_data_name="sata_phy_sink_sink_payload_data",
rx_data_name="sata_phy_source_source_payload_data"
)