diff --git a/openfasoc/MLoptimization/quickstart.bash b/openfasoc/MLoptimization/quickstart.bash index 8845be6a3..ffd6bb647 100644 --- a/openfasoc/MLoptimization/quickstart.bash +++ b/openfasoc/MLoptimization/quickstart.bash @@ -25,13 +25,11 @@ fi # check that ngspice>40 is installed ngspice --version > test_ngspice_version.txt version_line=$(sed -n '2p' test_ngspice_version.txt) -version_number=$(echo "$version_line" | grep -oP '(?<=ngspice-)\d+') -required_version=40 - -if [[ "$version_number" -ge "$required_version" ]]; then - echo "Correct ngspice version ($version_line) is installed." +expected_version="ngspice-40" +if [[ $version_line == *"$expected_version"* ]]; then + echo "Correct ngspice version ($expected_version) is installed." else - echo "Error: Incorrect ngspice version. Expected version >= $required_version but found:" + echo "Error: Incorrect ngspice version. Expected $expected_version but found:" echo "$version_line" exit 1 fi @@ -47,30 +45,30 @@ is_installed() { } # Read the dependencies from requirements.txt and process each line -# while IFS= read -r package || [ -n "$package" ]; do -# # Remove leading/trailing whitespace -# package=$(echo "$package" | xargs) -# # Skip empty lines and comments -# if [[ -z "$package" || "$package" == \#* ]]; then -# continue -# fi -# # Extract the package name without extras and version specifiers for checking -# package_name=$(echo "$package" | sed 's/\[.*\]//;s/[<>=].*//') -# echo "Checking if $package is installed..." -# if is_installed "$package_name"; then -# echo "$package is already installed." -# else -# echo "$package is not installed. Installing..." -# $PY_RUN -m pip install "$package" -# # Check if the installation was successful -# if is_installed "$package_name"; then -# echo "$package installed successfully." -# else -# echo "Failed to install $package." -# fi -# fi -# echo -# done < "$requirements_file" +while IFS= read -r package || [ -n "$package" ]; do + # Remove leading/trailing whitespace + package=$(echo "$package" | xargs) + # Skip empty lines and comments + if [[ -z "$package" || "$package" == \#* ]]; then + continue + fi + # Extract the package name without extras and version specifiers for checking + package_name=$(echo "$package" | sed 's/\[.*\]//;s/[<>=].*//') + echo "Checking if $package is installed..." + if is_installed "$package_name"; then + echo "$package is already installed." + else + echo "$package is not installed. Installing..." + $PY_RUN -m pip install "$package" + # Check if the installation was successful + if is_installed "$package_name"; then + echo "$package installed successfully." + else + echo "Failed to install $package." + fi + fi + echo +done < "$requirements_file" echo "Dependency check and package installations complete." diff --git a/openfasoc/MLoptimization/test.py b/openfasoc/MLoptimization/test.py index 350d85279..2826fc7b6 100644 --- a/openfasoc/MLoptimization/test.py +++ b/openfasoc/MLoptimization/test.py @@ -3,13 +3,32 @@ import sys from sky130_nist_tapeout import safe_single_build_and_simulation -from sky130_nist_tapeout import opamp_parameters_serializer +from sky130_nist_tapeout import opamp_parameters_serializer, opamp_parameters_de_serializer import yaml from pathlib import Path import numpy as np from typing import Union +params = { + "diffpair_params0" : [1, 8, 1], + "diffpair_params1" : [0.5, 2.1, 0.1], + "diffpair_params2" : [1, 13, 1], + "Diffpair_bias0" : [1, 8, 1], + "Diffpair_bias1" : [1, 4.5, 0.5], + "Diffpair_bias2" : [3, 13, 1], + "pamp_hparams0" : [1, 9, 1], + "pamp_hparams1" : [0.5, 2.1, 0.1], + "pamp_hparams2" : [2, 14, 1], + "bias0" : [1, 8, 1], + "bias1" : [0.5, 2.1, 0.1], + "bias2" : [3, 18, 1], + "bias3" : [2, 4, 1], + "half_pload1": [3, 10, 1], + "half_pload3": [4, 9, 1], + "mim_cap_rows" : [1, 4, 1], + } + def get_indices_from_ranges(opamp_parameters: Union[dict, np.array]) -> np.array: """The RL framework works by doing design searches within a user defined range for each parameter For example, the RL framework may be told to search diffpair widths between 1um and 8um in steps of 1um @@ -79,25 +98,6 @@ def closest_index(range_params, number): # this relies on the fact that the params dict should be in order return np.array(opamp_parameter_arr) -params = { - "diffpair_params0" : [1, 8, 1], - "diffpair_params1" : [0.5, 2.1, 0.1], - "diffpair_params2" : [1, 13, 1], - "Diffpair_bias0" : [1, 8, 1], - "Diffpair_bias1" : [1, 4.5, 0.5], - "Diffpair_bias2" : [3, 13, 1], - "pamp_hparams0" : [1, 9, 1], - "pamp_hparams1" : [0.5, 2.1, 0.1], - "pamp_hparams2" : [2, 14, 1], - "bias0" : [1, 8, 1], - "bias1" : [0.5, 2.1, 0.1], - "bias2" : [3, 18, 1], - "bias3" : [2, 4, 1], - "half_pload1": [3, 10, 1], - "half_pload3": [4, 9, 1], - "mim_cap_rows" : [1, 4, 1], - } - paramss = [] params_id = list(params.keys()) @@ -118,7 +118,6 @@ def closest_index(range_params, number): inputparam[22] = paramsss[14] inputparam[25] = paramsss[15] - result = safe_single_build_and_simulation(inputparam, hardfail=True) print(result)