Esempio n. 1
0
def main():
    if len(sys.argv) > 1 and sys.argv[1] == "+diag":
        del sys.argv[1]
        diag = True
    else:
        diag = False

    if len(sys.argv) > 1 and sys.argv[1] == "+compile":
        del sys.argv[1]
        compile_only = True
    else:
        compile_only = False

    ddb_path = os.path.join(os.path.dirname(sys.argv[1]), "device_db.pyon")
    dmgr = DeviceManager(DeviceDB(ddb_path))

    with open(sys.argv[1]) as f:
        testcase_code = compile(f.read(), f.name, "exec")
        testcase_vars = {'__name__': 'testbench', 'dmgr': dmgr}
        exec(testcase_code, testcase_vars)

    try:
        core = dmgr.get("core")
        if compile_only:
            core.compile(testcase_vars["entrypoint"], (), {})
        else:
            core.run(testcase_vars["entrypoint"], (), {})
            print(core.comm.get_log())
            core.comm.clear_log()
    except CompileError as error:
        if not diag:
            exit(1)
Esempio n. 2
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    if not args.print_decoded and args.write_vcd is None and args.write_dump is None:
        print("No action selected, use -p, -w and/or -d. See -h for help.")
        sys.exit(1)

    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        if args.read_dump:
            with open(args.read_dump, "rb") as f:
                dump = f.read()
        else:
            comm = device_mgr.get("comm")
            dump = comm.get_analyzer_dump()
        decoded_dump = decode_dump(dump)
        if args.print_decoded:
            print("Log channel:", decoded_dump.log_channel)
            print("DDS one-hot:", decoded_dump.dds_onehot_sel)
            for message in decoded_dump.messages:
                print(message)
        if args.write_vcd:
            with open(args.write_vcd, "w") as f:
                decoded_dump_to_vcd(f, device_mgr.get_device_db(), decoded_dump)
        if args.write_dump:
            with open(args.write_dump, "wb") as f:
                f.write(dump)
    finally:
        device_mgr.close_devices()
Esempio n. 3
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)
    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        comm = device_mgr.get("comm")
        comm.check_ident()

        if args.action == "read":
            value = comm.flash_storage_read(args.key)
            if not value:
                print("Key {} does not exist".format(args.key))
            else:
                print(value)
        elif args.action == "write":
            for key, value in args.string:
                comm.flash_storage_write(key, value.encode("utf-8"))
            for key, filename in args.file:
                with open(filename, "rb") as fi:
                    comm.flash_storage_write(key, fi.read())
        elif args.action == "delete":
            for key in args.key:
                comm.flash_storage_remove(key)
        elif args.action == "erase":
            comm.flash_storage_erase()
    finally:
        device_mgr.close_devices()
Esempio n. 4
0
def main():
    args = get_argparser().parse_args()
    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        comm = device_mgr.get("comm")

        if args.action == "log":
            print(comm.get_log())
        elif args.action == "cfg-read":
            value = comm.flash_storage_read(args.key)
            if not value:
                print("Key {} does not exist".format(args.key))
            else:
                print(value)
        elif args.action == "cfg-write":
            for key, value in args.string:
                comm.flash_storage_write(key, value)
            for key, filename in args.file:
                with open(filename, "rb") as fi:
                    comm.flash_storage_write(key, fi.read())
        elif args.action == "cfg-delete":
            for key in args.key:
                comm.flash_storage_remove(key)
        elif args.action == "cfg-erase":
            comm.flash_storage_erase()
    finally:
        device_mgr.close_devices()
Esempio n. 5
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)
    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        comm = device_mgr.get("core").comm
        comm.check_system_info()

        if args.action == "read":
            value = comm.flash_storage_read(args.key)
            if not value:
                print("Key {} does not exist".format(args.key))
            else:
                print(value)
        elif args.action == "write":
            for key, value in args.string:
                comm.flash_storage_write(key, value.encode("utf-8"))
            for key, filename in args.file:
                with open(filename, "rb") as fi:
                    comm.flash_storage_write(key, fi.read())
        elif args.action == "delete":
            for key in args.key:
                comm.flash_storage_remove(key)
        elif args.action == "erase":
            comm.flash_storage_erase()
    finally:
        device_mgr.close_devices()
Esempio n. 6
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    if (not args.print_decoded and args.write_vcd is None
            and args.write_dump is None):
        print("No action selected, use -p, -w and/or -d. See -h for help.")
        sys.exit(1)

    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        if args.read_dump:
            with open(args.read_dump, "rb") as f:
                dump = f.read()
        else:
            comm = device_mgr.get("comm")
            dump = comm.get_analyzer_dump()
        decoded_dump = decode_dump(dump)
        if args.print_decoded:
            print("Log channel:", decoded_dump.log_channel)
            print("DDS one-hot:", decoded_dump.dds_onehot_sel)
            for message in decoded_dump.messages:
                print(message)
        if args.write_vcd:
            with open(args.write_vcd, "w") as f:
                decoded_dump_to_vcd(f, device_mgr.get_device_db(),
                                    decoded_dump)
        if args.write_dump:
            with open(args.write_dump, "wb") as f:
                f.write(dump)
    finally:
        device_mgr.close_devices()
Esempio n. 7
0
def main():
    args = get_argparser().parse_args()
    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        comm = device_mgr.get("comm")

        if args.action == "log":
            print(comm.get_log())
        elif args.action == "cfg-read":
            value = comm.flash_storage_read(args.key)
            if not value:
                print("Key {} does not exist".format(args.key))
            else:
                print(value)
        elif args.action == "cfg-write":
            for key, value in args.string:
                comm.flash_storage_write(key, value)
            for key, filename in args.file:
                with open(filename, "rb") as fi:
                    comm.flash_storage_write(key, fi.read())
        elif args.action == "cfg-delete":
            for key in args.key:
                comm.flash_storage_remove(key)
        elif args.action == "cfg-erase":
            comm.flash_storage_erase()
    finally:
        device_mgr.close_devices()
Esempio n. 8
0
def main():
    if len(sys.argv) > 1 and sys.argv[1] == "+diag":
        del sys.argv[1]
        diag = True
    else:
        diag = False

    if len(sys.argv) > 1 and sys.argv[1] == "+compile":
        del sys.argv[1]
        compile_only = True
    else:
        compile_only = False

    ddb_path = os.path.join(os.path.dirname(sys.argv[1]), "device_db.py")
    dmgr = DeviceManager(DeviceDB(ddb_path))

    with open(sys.argv[1]) as f:
        testcase_code = compile(f.read(), f.name, "exec")
        testcase_vars = {'__name__': 'testbench', 'dmgr': dmgr}
        exec(testcase_code, testcase_vars)

    try:
        core = dmgr.get("core")
        if compile_only:
            core.compile(testcase_vars["entrypoint"], (), {})
        else:
            core.run(testcase_vars["entrypoint"], (), {})
            print(core.comm.get_log())
            core.comm.clear_log()
    except CompileError as error:
        if not diag:
            exit(1)
Esempio n. 9
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)
    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        comm = device_mgr.get("comm")
        comm.check_system_info()
        print(comm.get_log(), end="")
    finally:
        device_mgr.close_devices()
Esempio n. 10
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)
    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        comm = device_mgr.get("comm")
        comm.check_ident()
        print(comm.get_log(), end="")
    finally:
        device_mgr.close_devices()