diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-12-07 20:04:15 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-12-07 20:04:23 -0600 |
| commit | a7adc0af074826a4c68c7395d2abfd4b931955df (patch) | |
| tree | e9db6027bf690ad17e66a97334a52e7f8790d36f | |
| parent | c39552375661e495b344e8386649ade92a4d45b2 (diff) | |
Make the cycle limit optional
| -rw-r--r-- | sim/gdbstub.py | 1 | ||||
| -rwxr-xr-x | sim/sim.py | 7 | ||||
| -rw-r--r-- | tb/top/conspiracion.cpp | 8 |
3 files changed, 11 insertions, 5 deletions
diff --git a/sim/gdbstub.py b/sim/gdbstub.py index 75c15cb..c01a4a7 100644 --- a/sim/gdbstub.py +++ b/sim/gdbstub.py @@ -1,5 +1,6 @@ import sys, socket +cycles = None start_halted = True def init(): @@ -275,13 +275,16 @@ prelude.update({k: v for k, v in all_regs}) module.__dict__.update(prelude) spec.loader.exec_module(module) -cycles = module_get('cycles', 1024) mem_dumps = module_get('mem_dumps', []) if init := module_get('init'): init() -exec_args = [verilated, '--headless', '--no-tty', '--cycles', str(cycles), '--dump-regs'] +exec_args = [verilated, '--headless', '--no-tty', '--dump-regs'] + +cycles = module_get('cycles', 1024) +if cycles is not None: + exec_args.extend(['--cycles', str(cycles)]) for rng in mem_dumps: length = rng.stop - rng.start diff --git a/tb/top/conspiracion.cpp b/tb/top/conspiracion.cpp index bd1086a..f222e54 100644 --- a/tb/top/conspiracion.cpp +++ b/tb/top/conspiracion.cpp @@ -1,3 +1,4 @@ +#include <climits> #include <cstdio> #include <cstdint> #include <cstdlib> @@ -204,7 +205,7 @@ int main(int argc, char **argv) args::ValueFlag<unsigned> cycles ( - parser, "cycles", "Number of core cycles to run", {"cycles"}, 256 + parser, "cycles", "Max number of core cycles to run", {"cycles"}, UINT_MAX ); args::ValueFlag<int> control_fd @@ -446,9 +447,10 @@ int main(int argc, char **argv) }; unsigned i = 0; - while(!failed && i < *cycles) + // Abuse unsigned overflow (cycles is UINT_MAX by default) + while(!failed && i + 1 <= *cycles) { - for(; i < *cycles; ++i) + for(; i + 1 <= *cycles; ++i) { cycle(); if(failed || top.cpu_halted) [[unlikely]] |
