diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-10-22 15:05:09 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-10-22 15:05:09 +0200 |
commit | b7e25c6ca7746e86ef201b9be7ecec57bf5b2d2a (patch) | |
tree | d1f9ab118643e3aa8eddb1f846d5a89120177b29 /lib | |
parent | 9f85fc2f2678c491d1ae8d42995fae0fb931f1fe (diff) |
Improve sync=la timing restoration. There's still something fishy though...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/harness.py | 23 | ||||
-rw-r--r-- | lib/lennart/DataProcessor.py | 5 | ||||
-rw-r--r-- | lib/lennart/SigrokInterface.py | 43 | ||||
-rw-r--r-- | lib/loader.py | 24 |
4 files changed, 42 insertions, 53 deletions
diff --git a/lib/harness.py b/lib/harness.py index 51013e1..04b14eb 100644 --- a/lib/harness.py +++ b/lib/harness.py @@ -355,10 +355,14 @@ class OnboardTimerHarness(TransitionHarness): the dict `offline_aggregates` with the member `duration`. It contains a list of durations (in us) of the corresponding state/transition for each benchmark iteration. I.e. `.traces[*]['trace'][*]['offline_aggregates']['duration'] = [..., ...]` + :param remove_nop_from_timings: If true, remove the nop duration from reported timings + (i.e., reported timings reflect the estimated transition/state duration with the timer call overhea dremoved). + If false, do not remove nop durations, so the timings more accurately reflect the elapsed wall-clock time during the benchmark. """ - def __init__(self, counter_limits, **kwargs): + def __init__(self, counter_limits, remove_nop_from_timings=True, **kwargs): super().__init__(**kwargs) + self.remove_nop_from_timings = remove_nop_from_timings self.trace_length = 0 ( self.one_cycle_in_us, @@ -422,7 +426,6 @@ class OnboardTimerHarness(TransitionHarness): gpio.led_toggle(1); ptalog.stopTransition(); // ======================= LED SYNC ================================ - arch.sleep_ms(250); }\n\n""" return ret @@ -431,14 +434,17 @@ class OnboardTimerHarness(TransitionHarness): if self.energytrace_sync == "led": ret += "runLASync();\n" ret += "ptalog.passNop();\n" + if self.energytrace_sync == "led": + ret += "arch.sleep_ms(250);\n" ret += super().start_benchmark(benchmark_id) return ret def stop_benchmark(self): ret = "" + ret += super().stop_benchmark() if self.energytrace_sync == "led": ret += "runLASync();\n" - ret += super().stop_benchmark() + ret += "arch.sleep_ms(250);\n" return ret def pass_transition( @@ -498,8 +504,9 @@ class OnboardTimerHarness(TransitionHarness): prev_state_duration_us = ( prev_state_cycles * self.one_cycle_in_us + prev_state_overflow * self.one_overflow_in_us - - self.nop_cycles * self.one_cycle_in_us ) + if self.remove_nop_from_timings: + prev_state_duration_us -= self.nop_cycles * self.one_cycle_in_us final_state = self.traces[self.trace_id]["trace"][-1] if "offline_aggregates" not in final_state: final_state["offline_aggregates"] = {"duration": list()} @@ -561,15 +568,15 @@ class OnboardTimerHarness(TransitionHarness): ) ) duration_us = ( - cycles * self.one_cycle_in_us - + overflow * self.one_overflow_in_us - - self.nop_cycles * self.one_cycle_in_us + cycles * self.one_cycle_in_us + overflow * self.one_overflow_in_us ) prev_state_duration_us = ( prev_state_cycles * self.one_cycle_in_us + prev_state_overflow * self.one_overflow_in_us - - self.nop_cycles * self.one_cycle_in_us ) + if self.remove_nop_from_timings: + duration_us -= self.nop_cycles * self.one_cycle_in_us + prev_state_duration_us -= self.nop_cycles * self.one_cycle_in_us if duration_us < 0: duration_us = 0 # self.traces contains transitions and states, UART output only contains transitions -> use index * 2 diff --git a/lib/lennart/DataProcessor.py b/lib/lennart/DataProcessor.py index 8d762e7..90cc54d 100644 --- a/lib/lennart/DataProcessor.py +++ b/lib/lennart/DataProcessor.py @@ -228,9 +228,10 @@ class DataProcessor: def getDataText(x): # print(x) + dl = len(annotateData) for i, xt in enumerate(self.modified_timestamps): - if xt > x: - return "Value: %s" % annotateData[i - 5] + if xt > x and i >= 4 and i - 5 < dl: + return f"SoT: {annotateData[i - 5]}" def update_annot(x, y, name): annot.xy = (x, y) diff --git a/lib/lennart/SigrokInterface.py b/lib/lennart/SigrokInterface.py index 1733b68..32e8fe2 100644 --- a/lib/lennart/SigrokInterface.py +++ b/lib/lennart/SigrokInterface.py @@ -1,4 +1,5 @@ import json +import numpy as np from dfatool.lennart.DataInterface import DataInterface import logging @@ -62,48 +63,6 @@ class SigrokResult: return SigrokResult(data["timestamps"], data["onBeforeFirstChange"]) pass - @classmethod - def fromTraces(cls, traces): - """ - Generates SigrokResult from ptalog.json traces - - :param traces: traces from dfatool ptalog.json - :return: SigrokResult object - """ - timestamps = [0] - for tr in traces: - for t in tr["trace"]: - # print(t['online_aggregates']['duration'][0]) - timestamps.append( - timestamps[-1] + (t["online_aggregates"]["duration"][0] * 10 ** -6) - ) - - # print(timestamps) - # prepend FAKE Sync point - t_neu = [0.0, 0.0000001, 1.0, 1.00000001] - for i, x in enumerate(timestamps): - t_neu.append( - round(float(x) + t_neu[3] + 0.20, 6) - ) # list(map(float, t_ist.split(",")[:i+1])) - - # append FAKE Sync point / eine überschneidung - # [30.403632, 30.403639, 31.407265, 31.407271] - # appendData = [29.144855,30.148495,30.148502,30.403632,30.403639,31.407265,31.407271,] - appendData = [0, 1.000001, 1.000002, 1.25, 1.2500001] - - # TODO future work here, why does the sync not work completely - t_neu[-1] = ( - t_neu[-2] + (t_neu[-1] - t_neu[-2]) * 0.9 - ) # Weird offset failure with UART stuff - - offset = t_neu[-1] - appendData[0] - for x in appendData: - t_neu.append(x + offset) - - # print(t_neu) - print(len(t_neu)) - return SigrokResult(t_neu, False) - class SigrokInterface(DataInterface): def __init__(self, sample_rate, driver="fx2lafw", filename="temp/sigrok.log"): diff --git a/lib/loader.py b/lib/loader.py index 3f6b5ec..2f8e603 100644 --- a/lib/loader.py +++ b/lib/loader.py @@ -1780,9 +1780,31 @@ class EnergyTraceWithTimer(EnergyTraceWithLogicAnalyzer): pass def analyze_states(self, traces, offline_index: int): + + # Start "Synchronization pulse" + timestamps = [0, 10, 1e6, 1e6 + 10] + + # 250ms zwischen Ende der LASync und Beginn der Messungen + # (wegen sleep(250) in der generierten multipass-runLASync-Funktion) + timestamps.append(timestamps[-1] + 240e3) + for tr in traces: + for t in tr["trace"]: + # print(t['online_aggregates']['duration'][0]) + timestamps.append( + timestamps[-1] + t["online_aggregates"]["duration"][offline_index] + ) + + print(timestamps) + + # Stop "Synchronization pulses". The first one has already started. + timestamps.extend(np.array([10, 1e6, 1e6 + 10]) + timestamps[-1]) + timestamps.extend(np.array([0, 10, 1e6, 1e6 + 10]) + 250e3 + timestamps[-1]) + + timestamps = list(np.array(timestamps) * 1e-6) + from dfatool.lennart.SigrokInterface import SigrokResult - self.sync_data = SigrokResult.fromTraces(traces) + self.sync_data = SigrokResult(timestamps, False) return super().analyze_states(traces, offline_index) |