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") args = parser.parse_args() sim = Simulator(OTBNModel(verbose=args.trace_file)) sim.load_program(decode_file(args.imem_file, RV32IXotbn)) with open(args.dmem_file, "rb") as f: sim.load_data(f.read()) cycles = sim.run() 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
def on_load_i(sim: OTBNSim, args: List[str]) -> None: '''Load contents of insn memory from file at path given by only argument''' if len(args) != 1: raise ValueError( 'load_i expects exactly 1 argument. Got {}.'.format(args)) path = args[0] print('LOAD_I {!r}'.format(path)) sim.load_program(decode_file(0, path))
def on_load_i(sim: OTBNSim, args: List[str]) -> Optional[OTBNSim]: '''Load contents of insn memory from file at path given by only argument''' check_arg_count('load_i', 1, args) path = args[0] print('LOAD_I {!r}'.format(path)) sim.load_program(decode_file(0, path)) return None