import argparse
import random as rand
from collections import OrderedDict
-from config import *
+from misoclib.tools.litescope.host.driver.uart import LiteScopeUARTDriver
KB = 1024
MB = 1024*KB
description="""\
SATA BIST utility.
""")
+ parser.add_argument("--port", default=2, help="UART port")
+ parser.add_argument("--baudrate", default=921600, help="UART baudrate")
+ parser.add_argument("--busword", default=32, help="CSR busword")
parser.add_argument("-s", "--transfer_size", default=1024, help="transfer sizes (in KB, up to 16MB)")
parser.add_argument("-l", "--total_length", default=256, help="total transfer length (in MB, up to HDD capacity)")
parser.add_argument("-n", "--loops", default=1, help="number of loop per transfer (allow more precision on speed calculation for small transfers)")
if __name__ == "__main__":
args = _get_args()
+ wb = LiteScopeUARTDriver(args.port, args.baudrate, "./csr.csv", int(args.busword), debug=False)
wb.open()
###
identify = LiteSATABISTIdentifyDriver(wb.regs, "sata_bist")
--- /dev/null
+#!/usr/bin/env python3
+import argparse, importlib
+
+def _get_args():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-b", "--bridge", default="uart", help="Bridge to use")
+ parser.add_argument("--port", default=2, help="UART port")
+ parser.add_argument("--baudrate", default=921600, help="UART baudrate")
+ parser.add_argument("--ip_address", default="192.168.1.40", help="Etherbone IP address")
+ parser.add_argument("--udp_port", default=20000, help="Etherbone UDP port")
+ parser.add_argument("--busword", default=32, help="CSR busword")
+
+ parser.add_argument("test", nargs="+", help="specify a test")
+
+ return parser.parse_args()
+
+if __name__ == "__main__":
+ args = _get_args()
+ if args.bridge == "uart":
+ from misoclib.tools.litescope.host.driver.uart import LiteScopeUARTDriver
+ wb = LiteScopeUARTDriver(args.port, args.baudrate, "./csr.csv", int(args.busword), debug=False)
+ elif args.bridge == "etherbone":
+ from misoclib.tools.litescope.host.driver.etherbone import LiteScopeEtherboneDriver
+ wb = LiteScopeEtherboneDriver(args.ip_address, int(args.udp_port), "./csr.csv", int(args.busword), debug=False)
+ else:
+ ValueError("Invalid bridge {}".format(args.bridge))
+
+ def _import(name):
+ return importlib.import_module(name)
+
+ for test in args.test:
+ t = _import(test)
+ t.main(wb)
import sys
-from config import *
from tools import *
-from bist import *
+from test_bist import *
from litescope.host.driver.la import LiteScopeLADriver
-la = LiteScopeLADriver(wb.regs, "la")
-identify = LiteSATABISTIdentifyDriver(wb.regs, "sata_bist")
-generator = LiteSATABISTGeneratorDriver(wb.regs, "sata_bist")
-checker = LiteSATABISTCheckerDriver(wb.regs, "sata_bist")
-wb.open()
-regs = wb.regs
-###
+def main(wb):
+ la = LiteScopeLADriver(wb.regs, "la")
+ identify = LiteSATABISTIdentifyDriver(wb.regs, "sata_bist")
+ generator = LiteSATABISTGeneratorDriver(wb.regs, "sata_bist")
+ checker = LiteSATABISTCheckerDriver(wb.regs, "sata_bist")
+ wb.open()
+ regs = wb.regs
+ ###
-trig = "now"
-if len(sys.argv) < 2:
- print("No trigger condition, triggering immediately!")
-else:
- trig = sys.argv[1]
+ trig = "now"
+ if len(sys.argv) < 2:
+ print("No trigger condition, triggering immediately!")
+ else:
+ trig = sys.argv[1]
-conditions = {}
-conditions["now"] = {}
-conditions["id_cmd"] = {
- "sata_command_tx_sink_stb" : 1,
- "sata_command_tx_sink_payload_identify" : 1,
-}
-conditions["id_resp"] = {
- "source_source_payload_data" : primitives["X_RDY"],
-}
-conditions["wr_cmd"] = {
- "sata_command_tx_sink_stb" : 1,
- "sata_command_tx_sink_payload_write" : 1,
-}
-conditions["wr_resp"] = {
- "sata_command_rx_source_stb" : 1,
- "sata_command_rx_source_payload_write" : 1,
-}
-conditions["rd_cmd"] = {
- "sata_command_tx_sink_stb" : 1,
- "sata_command_tx_sink_payload_read" : 1,
-}
-conditions["rd_resp"] = {
- "sata_command_rx_source_stb" : 1,
- "sata_command_rx_source_payload_read" : 1,
-}
+ conditions = {}
+ conditions["now"] = {}
+ conditions["id_cmd"] = {
+ "sata_command_tx_sink_stb" : 1,
+ "sata_command_tx_sink_payload_identify" : 1,
+ }
+ conditions["id_resp"] = {
+ "source_source_payload_data" : primitives["X_RDY"],
+ }
+ conditions["wr_cmd"] = {
+ "sata_command_tx_sink_stb" : 1,
+ "sata_command_tx_sink_payload_write" : 1,
+ }
+ conditions["wr_resp"] = {
+ "sata_command_rx_source_stb" : 1,
+ "sata_command_rx_source_payload_write" : 1,
+ }
+ conditions["rd_cmd"] = {
+ "sata_command_tx_sink_stb" : 1,
+ "sata_command_tx_sink_payload_read" : 1,
+ }
+ conditions["rd_resp"] = {
+ "sata_command_rx_source_stb" : 1,
+ "sata_command_rx_source_payload_read" : 1,
+ }
-la.configure_term(port=0, cond=conditions[trig])
-la.configure_sum("term")
+ la.configure_term(port=0, cond=conditions[trig])
+ la.configure_sum("term")
-# Run Logic Analyzer
-la.run(offset=64, length=1024)
+ # Run Logic Analyzer
+ la.run(offset=64, length=1024)
-#identify.run(blocking=False)
-generator.run(0, 2, 1, 0, blocking=False)
-#checker.run(0, 2, 1, 0, blocking=False)
+ #identify.run(blocking=False)
+ generator.run(0, 2, 1, 0, blocking=False)
+ #checker.run(0, 2, 1, 0, blocking=False)
-while not la.done():
- pass
+ while not la.done():
+ pass
-la.upload()
-la.save("dump.vcd")
-###
-wb.close()
+ la.upload()
+ la.save("dump.vcd")
+ ###
+ wb.close()
-f = open("dump_link.txt", "w")
-data = link_trace(la,
- tx_data_name="sink_sink_payload_data",
- rx_data_name="source_source_payload_data"
-)
-f.write(data)
-f.close()
+ f = open("dump_link.txt", "w")
+ data = link_trace(la,
+ tx_data_name="sink_sink_payload_data",
+ rx_data_name="source_source_payload_data"
+ )
+ f.write(data)
+ f.close()