diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-03-05 08:44:46 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-03-05 08:44:46 +0100 |
commit | 57b27d7d96f832fbedf65a5111ad9dd4f0aaa53c (patch) | |
tree | 166f29711547e9865776b03c196c3a266c51d605 | |
parent | 965b35d6ae356a0aed8b7a044af62e868f1fab4e (diff) |
DFA benchmarks: Add missing boilerplate code
-rwxr-xr-x | bin/generate-dfa-benchmark.py | 13 | ||||
-rwxr-xr-x | lib/automata.py | 7 | ||||
-rw-r--r-- | lib/harness.py | 8 |
3 files changed, 27 insertions, 1 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py index 4789ad7..ce67313 100755 --- a/bin/generate-dfa-benchmark.py +++ b/bin/generate-dfa-benchmark.py @@ -47,8 +47,13 @@ if __name__ == '__main__': harness = TransitionHarness('GPIO::p1_0') print('#include "arch.h"') + if pta.header: + print('#include "{}"'.format(pta.header)) print(harness.global_code()) + print('void loop(void)') + print('{') + print(harness.start_benchmark()) class_prefix = '' @@ -75,4 +80,12 @@ if __name__ == '__main__': print() print(harness.stop_benchmark()) + print('}\n') + print('int main(void)') + print('{') + for driver in ('arch', 'gpio', 'kout'): + print('{}.setup();'.format(driver)) + print('arch.idle_loop();') + print('return 0;') + print('}') sys.exit(0) diff --git a/lib/automata.py b/lib/automata.py index 2d5c27c..df8363f 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -259,7 +259,7 @@ class PTA: def __init__(self, state_names: list = [], accepting_states: list = None, parameters: list = [], initial_param_values: list = None, - instance: str = None): + instance: str = None, header: str = None): """ Return a new PTA object. @@ -270,11 +270,13 @@ class PTA: parameters -- names of PTA parameters initial_param_values -- initial value for each parameter instance -- class used for generated C++ code + header -- header include path for C++ class definition """ self.state = dict([[state_name, State(state_name)] for state_name in state_names]) self.accepting_states = accepting_states.copy() if accepting_states else None self.parameters = parameters.copy() self.instance = instance + self.header = header if initial_param_values: self.initial_param_values = initial_param_values.copy() else: @@ -386,6 +388,9 @@ class PTA: if 'instance' in yaml_input: kwargs['instance'] = yaml_input['instance'] + if 'header' in yaml_input: + kwargs['header'] = yaml_input['header'] + pta = cls(**kwargs) for trans_name in sorted(yaml_input['transition'].keys()): diff --git a/lib/harness.py b/lib/harness.py index c03406c..3f8d93c 100644 --- a/lib/harness.py +++ b/lib/harness.py @@ -15,6 +15,10 @@ class OnboardTimerHarness: if self.gpio_pin != None: ret += '#define PTALOG_GPIO {}\n'.format(self.gpio_pin) ret += '#include "object/ptalog.h"\n' + if self.gpio_pin != None: + ret += 'PTALog ptalog({});\n'.format(self.gpio_pin) + else: + ret += 'PTALog ptalog;\n' return ret def start_benchmark(self): @@ -48,6 +52,10 @@ class TransitionHarness: if self.gpio_pin != None: ret += '#define PTALOG_GPIO {}\n'.format(self.gpio_pin) ret += '#include "object/ptalog.h"\n' + if self.gpio_pin != None: + ret += 'PTALog ptalog({});\n'.format(self.gpio_pin) + else: + ret += 'PTALog ptalog;\n' return ret def start_benchmark(self): |