|
@@ -1,189 +0,0 @@
|
|
|
-import tempfile
|
|
|
|
|
-import time
|
|
|
|
|
-import pickle
|
|
|
|
|
-import pandas as pd
|
|
|
|
|
-import threading
|
|
|
|
|
-import datetime
|
|
|
|
|
-
|
|
|
|
|
-from imc_utils.pps_e36311a import PPS_E36311A
|
|
|
|
|
-from imc_utils.smu_b2902a import SMU_B2902A
|
|
|
|
|
-from imc_utils.build_config.cortex_m33 import BuildConfigM33
|
|
|
|
|
-from imc_utils.build_config.test_env import TestEnv
|
|
|
|
|
-from imc_utils.serial_watch import SerialWatcher
|
|
|
|
|
-from imc_utils.oscilloscope_dsox1204a import DSOX1204A
|
|
|
|
|
-
|
|
|
|
|
-import imc_utils.serial_device
|
|
|
|
|
-
|
|
|
|
|
-WORKSPACE_ROOT = "/home/ybkim/workspace/imc/imc_freertos_app_m33"
|
|
|
|
|
-NVM_RESET_BIN = f"{WORKSPACE_ROOT}/imc/utils/nvm_reset.elf"
|
|
|
|
|
-OPENOCD_SCRIPT = f"{WORKSPACE_ROOT}/imc_freertos_app_m33.cfg"
|
|
|
|
|
-
|
|
|
|
|
-def set_current_limit_thread(current_limits, interval_sec, smu: SMU_B2902A):
|
|
|
|
|
- for limit in current_limits:
|
|
|
|
|
- # smu_busy = smu.smu.ask("*OPC?")
|
|
|
|
|
- # print(smu_busy)
|
|
|
|
|
- smu.smu.write("*WAI")
|
|
|
|
|
- print(f"set current limit to: {limit*1000:.3f}mA")
|
|
|
|
|
- smu.set_current_limit(limit)
|
|
|
|
|
- time.sleep(interval_sec)
|
|
|
|
|
-
|
|
|
|
|
-def get_sampling_duration(curr_limit):
|
|
|
|
|
- ratio = 0.020 / curr_limit
|
|
|
|
|
- return 10 * ratio
|
|
|
|
|
-
|
|
|
|
|
-def get_scope_timebase(cap_size_uF):
|
|
|
|
|
- d = {
|
|
|
|
|
- 1000: 3,
|
|
|
|
|
- 470: 2,
|
|
|
|
|
- 220: 1,
|
|
|
|
|
- 100: 0.8,
|
|
|
|
|
- 50: 0.5,
|
|
|
|
|
- }
|
|
|
|
|
- return d[cap_size_uF]
|
|
|
|
|
-
|
|
|
|
|
-def get_smu_sample_freq(cap_size_uF):
|
|
|
|
|
- d = {
|
|
|
|
|
- 1000: 1000,
|
|
|
|
|
- 470: 1000,
|
|
|
|
|
- 220: 1000,
|
|
|
|
|
- 100: 2000,
|
|
|
|
|
- 50: 2000,
|
|
|
|
|
- }
|
|
|
|
|
- return d[cap_size_uF]
|
|
|
|
|
-
|
|
|
|
|
-def main():
|
|
|
|
|
- volt = 1.5
|
|
|
|
|
- cap_size_uF = 1000
|
|
|
|
|
- smu_sample_freq = get_smu_sample_freq(cap_size_uF)
|
|
|
|
|
- smu = SMU_B2902A(voltage=volt, sample_freq=smu_sample_freq)
|
|
|
|
|
- smu.setup_sense()
|
|
|
|
|
-
|
|
|
|
|
- config = get_default_build_config()
|
|
|
|
|
-
|
|
|
|
|
- scope = DSOX1204A()
|
|
|
|
|
-
|
|
|
|
|
- timebase = get_scope_timebase(cap_size_uF)
|
|
|
|
|
- scope.set_volt_scale(3, 1)
|
|
|
|
|
- scope.set_timebase(timebase)
|
|
|
|
|
- scope.set_timebase_reference_left()
|
|
|
|
|
- scope.set_trigger_falling_edge(3, 2)
|
|
|
|
|
- scope.set_acquisition_type("hresolution")
|
|
|
|
|
-
|
|
|
|
|
- benchmark = "vFFT"
|
|
|
|
|
-
|
|
|
|
|
- current_limits = [ 0.001*i for i in range(20,0,-1)]
|
|
|
|
|
- # current_limits = []
|
|
|
|
|
- current_limits += [0.0005]
|
|
|
|
|
- # current_limits = [0.01, 0.005, 0.001]
|
|
|
|
|
-
|
|
|
|
|
- config.bench_name = benchmark
|
|
|
|
|
-
|
|
|
|
|
- smu.set_current_limit(0.1)
|
|
|
|
|
- smu.power_on()
|
|
|
|
|
-
|
|
|
|
|
- env = TestEnv(WORKSPACE_ROOT, NVM_RESET_BIN, OPENOCD_SCRIPT)
|
|
|
|
|
-
|
|
|
|
|
- with tempfile.TemporaryDirectory() as build_dir:
|
|
|
|
|
- binary = env.build_binary(config, build_dir)
|
|
|
|
|
- env.clear_nvm_and_load_binary(binary, resume=False)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- smu.power_on()
|
|
|
|
|
- smu.set_current_limit(current_limits[0])
|
|
|
|
|
- startup_time = 10
|
|
|
|
|
- print(f"wait for startup ({startup_time}s)")
|
|
|
|
|
- time.sleep(startup_time)
|
|
|
|
|
-
|
|
|
|
|
- interval = get_sampling_duration(current_limits[0])
|
|
|
|
|
- # t = threading.Thread(target=set_current_limit_thread, args=(current_limits, interval, smu))
|
|
|
|
|
- # t.start()
|
|
|
|
|
-
|
|
|
|
|
- results = []
|
|
|
|
|
- i = 0
|
|
|
|
|
- current_limit_index = 0
|
|
|
|
|
- start = datetime.datetime.now()
|
|
|
|
|
-
|
|
|
|
|
- while True:
|
|
|
|
|
- print(f"({i}) Start waiting for trigger")
|
|
|
|
|
- scope.aquire_single()
|
|
|
|
|
- smu.start_measure()
|
|
|
|
|
-
|
|
|
|
|
- scope.wait_aquire_finish()
|
|
|
|
|
- smu.stop_measure_only()
|
|
|
|
|
- print(f"({i}) Finish measurement")
|
|
|
|
|
-
|
|
|
|
|
- in_execution = scope.get_waveform(2)
|
|
|
|
|
- eps_on = scope.get_waveform(3)
|
|
|
|
|
- x_increment = scope.get_xincrement()
|
|
|
|
|
-
|
|
|
|
|
- d = {
|
|
|
|
|
- "in_execution": in_execution,
|
|
|
|
|
- "eps_on": eps_on,
|
|
|
|
|
- "timestamp": [i * x_increment for i in range(len(in_execution))],
|
|
|
|
|
- }
|
|
|
|
|
- scope_results = pd.DataFrame(d)
|
|
|
|
|
-
|
|
|
|
|
- print(f"Sampled {len(scope_results)} points from the scope")
|
|
|
|
|
-
|
|
|
|
|
- currs = smu.fetch_curr()
|
|
|
|
|
- volts = smu.fetch_volt()
|
|
|
|
|
- timestamps = smu.fetch_time()
|
|
|
|
|
-
|
|
|
|
|
- d = {
|
|
|
|
|
- "curr": currs,
|
|
|
|
|
- "volt": volts,
|
|
|
|
|
- "timestamp": timestamps
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- smu_results = pd.DataFrame(d)
|
|
|
|
|
- print(f"Sampled {len(smu_results)} point from the smu")
|
|
|
|
|
-
|
|
|
|
|
- results.append({
|
|
|
|
|
- "scope_result": scope_results,
|
|
|
|
|
- "smu_result": smu_results,
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- i += 1
|
|
|
|
|
- now = datetime.datetime.now()
|
|
|
|
|
- time_elapsed = now - start
|
|
|
|
|
- print(time_elapsed)
|
|
|
|
|
- if time_elapsed > datetime.timedelta(seconds=interval):
|
|
|
|
|
- if current_limit_index == len(current_limits)-1:
|
|
|
|
|
- break
|
|
|
|
|
- current_limit_index += 1
|
|
|
|
|
- current_limit = current_limits[current_limit_index]
|
|
|
|
|
- print(f"set current limit to {current_limit*1000:.3f}mA")
|
|
|
|
|
- interval = get_sampling_duration(current_limit)
|
|
|
|
|
- print(f"set sampling duration: {interval:.3f}s")
|
|
|
|
|
- smu.set_current_limit(current_limit)
|
|
|
|
|
- start = now
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- save_records(f"result_{cap_size_uF}_uF", results)
|
|
|
|
|
- smu.power_off()
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-def get_default_build_config():
|
|
|
|
|
- config = BuildConfigM33()
|
|
|
|
|
- config.insert_compiler_checkpoints = False
|
|
|
|
|
- config.enable_extension = True
|
|
|
|
|
- config.use_checkpoint_pass_counter = False
|
|
|
|
|
- config.use_checkpoint_voltage_check = False
|
|
|
|
|
- config.bench_infinite_loop = True
|
|
|
|
|
- config.print_recovery_message = False
|
|
|
|
|
- config.split_loop = False
|
|
|
|
|
- config.enable_static_loop_pass_count = False
|
|
|
|
|
- config.enable_adaptive_loop_pass_count = False
|
|
|
|
|
- config.print_stats = False
|
|
|
|
|
- config.custom_unroll = False
|
|
|
|
|
- config.loop_opt_debug = False
|
|
|
|
|
- return config
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-def save_records(bench_name, df):
|
|
|
|
|
- with open(f"output/{bench_name}.pickle", "wb") as f:
|
|
|
|
|
- pickle.dump(df, f)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-if __name__ == "__main__":
|
|
|
|
|
- main()
|
|
|