From 4e37798145fa03bd90880f4ac315529190472eaf Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Mar 2019 15:15:54 +0100 Subject: generate PTA from YAML model, support several types of test harness --- lib/harness.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/harness.py (limited to 'lib/harness.py') diff --git a/lib/harness.py b/lib/harness.py new file mode 100644 index 0000000..c03406c --- /dev/null +++ b/lib/harness.py @@ -0,0 +1,70 @@ +""" +Harnesses for various types of benchmark logs. + +tbd +""" + +class OnboardTimerHarness: + def __init__(self, gpio_pin = None): + self.gpio_pin = gpio_pin + pass + + def global_code(self): + ret = '#include "driver/counter.h"\n' + ret += '#define PTALOG_TIMING\n' + if self.gpio_pin != None: + ret += '#define PTALOG_GPIO {}\n'.format(self.gpio_pin) + ret += '#include "object/ptalog.h"\n' + return ret + + def start_benchmark(self): + return 'ptalog.startBenchmark(0);\n' + + def start_run(self): + return 'ptalog.reset();\n' + + def pass_transition(self, transition_id, transition_code): + ret = 'ptalog.passTransition({:d});\n'.format(transition_id) + ret += 'ptalog.startTransition();\n' + ret += 'counter.start();\n' + ret += '{}\n'.format(transition_code) + ret += 'counter.stop();\n' + ret += 'ptalog.stopTransition(counter);\n' + return ret + + def stop_run(self): + return 'ptalog.dump();\n' + + def stop_benchmark(self): + return '' + +class TransitionHarness: + def __init__(self, gpio_pin = None): + self.gpio_pin = gpio_pin + pass + + def global_code(self): + ret = '' + if self.gpio_pin != None: + ret += '#define PTALOG_GPIO {}\n'.format(self.gpio_pin) + ret += '#include "object/ptalog.h"\n' + return ret + + def start_benchmark(self): + return 'ptalog.startBenchmark(0);\n' + + def start_run(self): + return 'ptalog.reset();\n' + + def pass_transition(self, transition_id, transition_code): + ret = 'ptalog.passTransition({:d});\n'.format(transition_id) + ret += 'ptalog.startTransition();\n' + ret += '{}\n'.format(transition_code) + ret += 'ptalog.stopTransition();\n' + return ret + + def stop_run(self): + return 'ptalog.dump();\n' + + def stop_benchmark(self): + return '' -- cgit v1.2.3