summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/generate-dfa-benchmark.py17
-rw-r--r--lib/runner.py17
2 files changed, 24 insertions, 10 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py
index 1410c28..2c53d9f 100755
--- a/bin/generate-dfa-benchmark.py
+++ b/bin/generate-dfa-benchmark.py
@@ -223,17 +223,11 @@ def benchmark_from_runs(
)
elif opt["sleep"]:
if "energytrace" in opt:
- outbuf.write(
- "arch.sleep_ms({:d}); // {}\n".format(
- opt["sleep"], transition.destination.name
- )
- )
+ outbuf.write(f"// -> {transition.destination.name}\n")
+ outbuf.write(runner.sleep_ms(opt["sleep"], opt["arch"]))
else:
- outbuf.write(
- "arch.delay_ms({:d}); // {}\n".format(
- opt["sleep"], transition.destination.name
- )
- )
+ outbuf.write(f"// -> {transition.destination.name}\n")
+ outbuf.write("arch.delay_ms({:d});\n".format(opt["sleep"]))
outbuf.write(harness.stop_run(num_traces))
if dummy:
@@ -597,6 +591,9 @@ if __name__ == "__main__":
if run_flags is None:
run_flags = opt["run"].split()
+ if "msp430fr" in opt["arch"]:
+ run_flags.append("cpu_freq=8000000")
+
runs = list(
pta.dfs(
opt["depth"],
diff --git a/lib/runner.py b/lib/runner.py
index aeb8600..77b7c68 100644
--- a/lib/runner.py
+++ b/lib/runner.py
@@ -405,6 +405,23 @@ def get_counter_limits(arch: str) -> tuple:
raise RuntimeError("Did not find Counter Overflow limits")
+def sleep_ms(duration: int, arch: str, cpu_freq: int = None) -> str:
+ max_sleep = None
+ if "msp430fr" in arch:
+ if cpu_freq is not None and cpu_freq > 8000000:
+ max_sleep = 250
+ else:
+ max_sleep = 500
+ if max_sleep is not None and duration > max_sleep:
+ sub_sleep_count = duration // max_sleep
+ tail_sleep = duration % max_sleep
+ ret = f"for (unsigned char i = 0; i < {sub_sleep_count}; i++) {{ arch.sleep_ms({max_sleep}); }}\n"
+ if tail_sleep > 0:
+ ret += f"arch.sleep_ms({tail_sleep});\n"
+ return ret
+ return "arch.sleep_ms({duration});\n"
+
+
def get_counter_limits_us(arch: str) -> tuple:
"""Return duration of one counter step and one counter overflow in us."""
cpu_freq = 0