test: add make.py to replace static config.py file
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 23 Feb 2015 17:55:19 +0000 (18:55 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 23 Feb 2015 17:55:19 +0000 (18:55 +0100)
test/config.py [deleted file]
test/make.py [new file with mode: 0644]
test/test_io.py
test/test_la.py
test/test_regs.py

diff --git a/test/config.py b/test/config.py
deleted file mode 100644 (file)
index fb98ad1..0000000
+++ /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 (file)
index 0000000..92fe667
--- /dev/null
@@ -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)
index 431c6cb6a02be77e781ef737e25ae2b073fbf079..154408204caacedbe2765b4341d66c3b041445d6 100644 (file)
@@ -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()
index 641b693b3119969b341cf82468b304c2ac053a7a..9ae14dd612aaafbb42b64a3b8714144393dbb106 100644 (file)
@@ -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()
index 982f849c55d6dec445559248114f463d5a8488e9..c0ef387fea4cb528dd64ef2121e2e2e914db64bc 100644 (file)
@@ -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()