Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions benchmark/runner/devices_ad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
voltage: 1.8 # <-- Voltage for DUT
usb:
0x0483: 0x5740 # Ensures detection by VID/PID (1155 / 22336)
- name: stlinkv3pwr
type: power
baud: 3686400
preference: 3
echo: false
voltage: 1.8
raw_sampling_rate: 100000
usb:
0x0483: 0x3757 # Ensures detection by VID/PID (1155 / 22336)
- name: l4r5zi
type: dut
baud:
Expand Down
9 changes: 9 additions & 0 deletions benchmark/runner/devices_kws_ic_vww.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
voltage: 1.8 # <-- Voltage for DUT
usb:
0x0483: 0x5740 # Ensures detection by VID/PID (1155 / 22336)
- name: stlinkv3pwr
type: power
baud: 3686400
preference: 3
echo: False
voltage: 1.8
raw_sampling_rate: 100000
usb:
0x0483: 0x3757 # Ensures detection by VID/PID (1155 / 22336)
- name: l4r5zi
type: dut
baud:
Expand Down
9 changes: 9 additions & 0 deletions benchmark/runner/devices_sww.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
voltage: 3.3 # <-- Voltage for DUT
usb:
0x0483: 0x5740 # Ensures detection by VID/PID (1155 / 22336)
- name: stlinkv3pwr
type: power
baud: 3686400
preference: 3
echo: false
voltage: 1.8
raw_sampling_rate: 100000
usb:
0x0483: 0x3757 # Ensures detection by VID/PID (1155 / 22336)
- name: l4r5zi
type: dut
baud:
Expand Down
10 changes: 7 additions & 3 deletions benchmark/runner/power_manager/power_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def __init__(self, device_type, port_device=None, baud_rate=None, voltage=3.3, e
from .power_manager_lpm import LPMCommands # only import this file if we're using this device
self._port = SerialDevice(port_device, baud_rate, "ack|error", "\r\n", echo=echo)
self._commands = LPMCommands(self, self._port)
elif device_type == "stlinkv3pwr":
from .power_manager_stlinkv3pwr import STLinkV3PWRCommands
self._port = SerialDevice(port_device, baud_rate, "", "\r\n", echo=echo)
self._commands = STLinkV3PWRCommands(self, self._port)
elif device_type == "js220":
from .power_manager_js220 import JoulescopeCommands
if js_device is None:
Expand All @@ -40,8 +44,8 @@ def __init__(self, device_type, port_device=None, baud_rate=None, voltage=3.3, e

def __enter__(self):
self._port.__enter__()
self._start_read_thread() # move this up
self._commands.setup() # now it's safe like the old code
self._start_read_thread() # ? move this up
self._commands.setup() # ? now it's safe like the old code
return self

def __exit__(self, *args):
Expand All @@ -61,7 +65,7 @@ def _stop_read_thread(self):
def get_results(self):
while not self._data_queue.empty():
yield self._data_queue.get()

def should_stop(self):
return not self._running

Expand Down
2 changes: 1 addition & 1 deletion benchmark/runner/power_manager/power_manager_lpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def read_loop(self):
values = self._extract_current_values(line)
for v in values:
self.m._data_queue.put(v)
elif re.match(r"event \d+ ris", line):
elif re.match(r"event \d+ (ris|fal)", line):
self.m._data_queue.put(line)
else:
self.m._message_queue.put(line)
Expand Down
138 changes: 138 additions & 0 deletions benchmark/runner/power_manager/power_manager_stlinkv3pwr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# power_manager_stlinkv3pwr.py

import re
import sys
from .power_manager_lpm import LPMCommands


class STLinkV3PWRCommands(LPMCommands):
PROMPT = "stlp > "

def __init__(self, manager, port):
super().__init__(manager, port)

def setup(self):
self._send_command("htc")
self.power_off()
self.configure_trigger("inf", 0, "sw")
self.configure_output("energy", "ascii_dec", "1k")
self.configure_voltage(self.m._voltage)


def read_loop(self):
in_summary = False

while self.m._running:
line = self._port.read_line(timeout=0.25)
if line is None:
continue
if not line:
continue

temp = self._strip_prompt(line)
if not temp:
continue

if temp == "summary beg":
in_summary = True
self.m._message_queue.put(temp)
continue

if in_summary:
self.m._message_queue.put(temp)
if temp == "summary end":
in_summary = False
continue

if re.fullmatch(r"\d{4}[+-]\d{2}", temp):
value = self._decode_ascii_dec_value(temp)
self.m._data_queue.put(value)
elif re.fullmatch(r"event \d+ (ris|fal)", temp):
self.m._data_queue.put(temp)
elif temp == "end":
self.m._message_queue.put("Acquisition completed")
else:
self.m._message_queue.put(temp)


def power_on(self):
return self._send_command("pwr on nostatus")

def get_board_id(self):
if not self.m._board_id:
result, output = self._send_command("whoami")
self.m._board_id = output if result else None
return self.m._board_id


def stop(self):
self._port.write_line("stop")
while True:
line = self.m._message_queue.get()
temp = self._strip_prompt(line)
if temp == "Acquisition completed" or temp == "end":
break
return True

def _strip_prompt(self, line):
line = line.strip()
if line.startswith(self.PROMPT):
line = line[len(self.PROMPT):].strip()
return line


def _read_response(self, command):
out_lines = []

while True:
line = self.m._message_queue.get()
temp = self._strip_prompt(line)

if not temp:
continue

if temp.startswith("ack"):
remainder = temp[3:].strip()
out_lines.append("ack")
if remainder:
if remainder.startswith(command):
tail = remainder[len(command):].strip()
if tail.startswith(":"):
tail = tail[1:].strip()
if tail:
out_lines.append(tail)
else:
out_lines.append(remainder)
break

elif temp.startswith("err"):
remainder = temp[3:].strip()
out_lines.append("err")
if remainder:
out_lines.append(remainder)
break

else:
out_lines.append(temp)

return out_lines

def _read_output(self):
while True:
line = self.m._message_queue.get()
temp = self._strip_prompt(line)
if temp == "":
return
yield temp

def _read_error_output(self):
errors = []
while not self.m._message_queue.empty():
line = self.m._message_queue.get()
temp = self._strip_prompt(line)
if temp:
errors.append(temp)
return errors if errors else ["Unknown STLINK-V3PWR error"]

def _decode_ascii_dec_value(self, s):
return float(s.replace("+", "e+").replace("-", "e-"))
4 changes: 2 additions & 2 deletions benchmark/runner/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def run(self, io, dut, dataset, mode): # mode passed to run
timestamps=timestamps,
extracted_power=power_values # <-- NEW: Power values from the file
)
)
)
else:
self._print_AP_results(infer_results,mode)

Expand All @@ -224,7 +224,7 @@ def _gather_power_results(power):
expected_samples = clock_ticks[-2][1] + 1000
print(f"At time {ts}: expected {expected_samples}, but we have {clock_ticks[-1][1]}.")
elif x.startswith("event"):
match = re.match(r"event (\d+) ris", x)
match = re.match(r"event (\d+) (ris|fal)", x)
event_num = match.group(1)
timeStamps.append((event_num, len(samples)))
else:
Expand Down
Loading