76 lines
2.0 KiB
Python
Executable File
76 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
from natsort import natsorted
|
|
|
|
from extract_meas import extract_parameterized_meas, indented
|
|
|
|
from stacked_cores_52xx_db import DB
|
|
|
|
## CONSTANTS/CONFIGURATION
|
|
|
|
# list of sims to extract details for
|
|
PREFIXES = { "52", "53", "54", "55", "56", "57" }
|
|
|
|
def times_of_interest(sim_name: str) -> list:
|
|
# could be more intelligent, extracting e.g. the clock duration from the name
|
|
if sim_name.startswith("52-"):
|
|
return [2e-9, 4e-9, 8e-9]
|
|
if sim_name.startswith("53-"):
|
|
return [2e-9, 4e-9]
|
|
if sim_name.startswith("54-"):
|
|
return [2e-9, 4e-9, 8e-9]
|
|
if sim_name.startswith("55-"):
|
|
return [4e-9, 6e-9, 10e-9]
|
|
if sim_name.startswith("56-"):
|
|
return [4e-9, 6e-9]
|
|
if sim_name.startswith("57-"):
|
|
return [4e-9, 6e-9]
|
|
|
|
|
|
## USER-FACING FUNCTIONS
|
|
|
|
def read_db(name_filter=lambda name: True) -> dict:
|
|
return { name: meas for (name, meas) in DB.items() if name_filter(name) }
|
|
|
|
def update_db():
|
|
db = compute_db()
|
|
dump("stacked_cores_52xx_db.py", db)
|
|
|
|
|
|
## IMPLEMENTATION DETAILS
|
|
|
|
def compute_db():
|
|
here, _ = os.path.split(__file__)
|
|
toplevel_out = f"{here}/../../../../out/applications/stacked_cores"
|
|
stems = extract_stems(os.listdir(toplevel_out))
|
|
return {
|
|
s: extract_parameterized_meas(os.path.join(toplevel_out, s), times_of_interest(s))
|
|
for s in stems
|
|
}
|
|
|
|
def extract_stems(dirlist: list) -> list:
|
|
stems = set()
|
|
TERM = "-drive-"
|
|
for d in dirlist:
|
|
print(d)
|
|
header = d.split('-')[0]
|
|
if header not in PREFIXES: continue
|
|
if TERM not in d: continue
|
|
stem = d[:d.find(TERM) + len(TERM)]
|
|
stems.add(stem)
|
|
|
|
return stems
|
|
|
|
|
|
def dump(path: str, db: dict):
|
|
with open(path, "w") as f:
|
|
f.write("from extract_meas import MeasRow, ParameterizedMeas\n\n")
|
|
f.write("DB = {")
|
|
for k, v in natsorted(db.items()):
|
|
f.write(indented(f"\n{k!r}: {v},"))
|
|
f.write("\n}")
|
|
|
|
if __name__ == '__main__': update_db()
|