diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-09-19 08:25:30 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-09-19 08:25:30 +0200 |
commit | ae6c2f67c0537debc6a5446e301b210a95a38806 (patch) | |
tree | 08cfa25a9dda195b6938ed7dfa5039291be96a6b /test/test_codegen.py | |
parent | d30c76189654b9b4ffb7e84decba8ab0e38345b8 (diff) |
codegen / simulated accounting: respect granularity
Diffstat (limited to 'test/test_codegen.py')
-rwxr-xr-x | test/test_codegen.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_codegen.py b/test/test_codegen.py index 2d54158..e1bb942 100755 --- a/test/test_codegen.py +++ b/test/test_codegen.py @@ -110,6 +110,26 @@ class TestCG(unittest.TestCase): cg.sleep(90) self.assertEqual(cg.get_energy(), 900 % 256) + cg = get_simulated_accountingmethod('static_statetransition_immediate')(pta, 100000, 'uint8_t', 'uint8_t', 'uint8_t', 'uint16_t') + cg.current_state = pta.state['IDLE'] + cg.sleep(7) + self.assertEqual(cg.get_energy(), 0) + cg.sleep(15) + self.assertEqual(cg.get_energy(), 90) + cg.sleep(90) + self.assertEqual(cg.get_energy(), 900) + + pta.state['IDLE'].power = 9 # -> 90 uW + pta.transitions[1].energy = 1 # -> 100 pJ + cg = get_simulated_accountingmethod('static_statetransition_immediate')(pta, 1000000, 'uint8_t', 'uint8_t', 'uint8_t', 'uint8_t', 1e-5, 1e-5, 1e-10) + cg.current_state = pta.state['IDLE'] + cg.sleep(10) # 10 us + self.assertEqual(cg.get_energy(), 90 * 10) + cg.pass_transition(pta.transitions[1]) + self.assertAlmostEqual(cg.get_energy(), 90 * 10 + 100, places=0) + cg.pass_transition(pta.transitions[1]) + self.assertAlmostEqual(cg.get_energy(), 90 * 10 + 100 + 100, places=0) + def test_statetransition(self): pta = PTA.from_json(example_json_1) pta.set_random_energy_model() |