From ac5b7c073a4edda9a55d1a4298c139975807b5b1 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 23 Feb 2015 18:55:19 +0100 Subject: [PATCH] test: add make.py to replace static config.py file --- test/config.py | 9 --------- test/make.py | 33 +++++++++++++++++++++++++++++++++ test/test_io.py | 19 +++++++++---------- test/test_la.py | 42 +++++++++++++++++++++--------------------- test/test_regs.py | 19 +++++++++---------- 5 files changed, 72 insertions(+), 50 deletions(-) delete mode 100644 test/config.py create mode 100644 test/make.py diff --git a/test/config.py b/test/config.py deleted file mode 100644 index fb98ad1d..00000000 --- a/test/config.py +++ /dev/null @@ -1,9 +0,0 @@ -from litescope.host.driver.uart import LiteScopeUARTDriver - -csr_csv_file = "./csr.csv" -busword = 32 -debug_wb = False - -com = 3 -baud = 115200 -wb = LiteScopeUARTDriver(com, baud, csr_csv_file, busword, debug_wb) \ No newline at end of file diff --git a/test/make.py b/test/make.py new file mode 100644 index 00000000..92fe667b --- /dev/null +++ b/test/make.py @@ -0,0 +1,33 @@ +#!/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=3, help="UART port") + parser.add_argument("--baudrate", default=115200, 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 litescope.host.driver.uart import LiteScopeUARTDriver + wb = LiteScopeUARTDriver(args.port, args.baudrate, "./csr.csv", int(args.busword), debug=False) + elif args.bridge == "etherbone": + from 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_"+test) + t.main(wb) diff --git a/test/test_io.py b/test/test_io.py index 431c6cb6..15440820 100644 --- a/test/test_io.py +++ b/test/test_io.py @@ -1,6 +1,4 @@ import time - -from config import * from litescope.host.driver.io import LiteScopeIODriver def led_anim0(io): @@ -25,11 +23,12 @@ def led_anim1(io): time.sleep(i*i*0.0020) led_data = (led_data>>1) -io = LiteScopeIODriver(wb.regs, "io") -wb.open() -### -led_anim0(io) -led_anim1(io) -print("%02X" %io.read()) -### -wb.close() +def main(wb): + io = LiteScopeIODriver(wb.regs, "io") + wb.open() + ### + led_anim0(io) + led_anim1(io) + print("%02X" %io.read()) + ### + wb.close() diff --git a/test/test_la.py b/test/test_la.py index 641b693b..9ae14dd6 100644 --- a/test/test_la.py +++ b/test/test_la.py @@ -1,26 +1,26 @@ -from config import * from litescope.host.driver.la import LiteScopeLADriver -wb.open() -### -la = LiteScopeLADriver(wb.regs, "la", debug=True) +def main(wb): + wb.open() + ### + la = LiteScopeLADriver(wb.regs, "la", debug=True) -#cond = {"cnt0" : 128} # trigger on cnt0 = 128 -cond = {} # trigger on cnt0 = 128 -la.configure_term(port=0, cond=cond) -la.configure_sum("term") -la.configure_subsampler(1) -#la.configure_qualifier(1) -la.configure_rle(1) -la.run(offset=128, length=256) + #cond = {"cnt0" : 128} # trigger on cnt0 = 128 + cond = {} # trigger on cnt0 = 128 + la.configure_term(port=0, cond=cond) + la.configure_sum("term") + la.configure_subsampler(1) + #la.configure_qualifier(1) + la.configure_rle(1) + la.run(offset=128, length=256) -while not la.done(): - pass -la.upload() + while not la.done(): + pass + la.upload() -la.save("dump.vcd") -la.save("dump.csv") -la.save("dump.py") -la.save("dump.sr") -### -wb.close() + la.save("dump.vcd") + la.save("dump.csv") + la.save("dump.py") + la.save("dump.sr") + ### + wb.close() diff --git a/test/test_regs.py b/test/test_regs.py index 982f849c..c0ef387f 100644 --- a/test/test_regs.py +++ b/test/test_regs.py @@ -1,10 +1,9 @@ -from config import * - -wb.open() -regs = wb.regs -### -print("sysid : 0x%04x" %regs.identifier_sysid.read()) -print("revision : 0x%04x" %regs.identifier_revision.read()) -print("frequency : %d MHz" %(regs.identifier_frequency.read()/1000000)) -### -wb.close() +def main(wb): + wb.open() + regs = wb.regs + ### + print("sysid : 0x%04x" %regs.identifier_sysid.read()) + print("revision : 0x%04x" %regs.identifier_revision.read()) + print("frequency : %d MHz" %(regs.identifier_frequency.read()/1000000)) + ### + wb.close() -- 2.30.2