Exemplo n.º 1
0
def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("imem_words", type=int)
    parser.add_argument("imem_file")
    parser.add_argument("dmem_words", type=int)
    parser.add_argument("dmem_file")
    parser.add_argument("cycles_file")
    parser.add_argument("trace_file")
    parser.add_argument("start_addr", type=int)

    args = parser.parse_args()
    sim = OTBNSim(OTBNModel(verbose=args.trace_file))

    sim.load_program(decode_file(args.imem_file))
    with open(args.dmem_file, "rb") as f:
        sim.load_data(f.read())

    cycles = sim.run(start_addr=args.start_addr)

    with open(args.dmem_file, "wb") as f:
        f.write(sim.dump_data())

    with open(args.cycles_file, "wb") as f:
        f.write(struct.pack("<L", cycles))

    return 0
Exemplo n.º 2
0
def on_load_d(sim: OTBNSim, args: List[str]) -> None:
    '''Load contents of data memory from file at path given by only argument'''
    if len(args) != 1:
        raise ValueError(
            'load_d expects exactly 1 argument. Got {}.'.format(args))
    path = args[0]

    print('LOAD_D {!r}'.format(path))
    with open(path, 'rb') as handle:
        sim.load_data(handle.read())
Exemplo n.º 3
0
def on_load_d(sim: OTBNSim, args: List[str]) -> Optional[OTBNSim]:
    '''Load contents of data memory from file at path given by only argument'''
    check_arg_count('load_d', 1, args)

    path = args[0]

    print('LOAD_D {!r}'.format(path))
    with open(path, 'rb') as handle:
        sim.load_data(handle.read(), has_validity=True)

    return None