diff --git a/stacks/chipathon-tools/Dockerfile b/stacks/chipathon-tools/Dockerfile index 12bac9b..d663776 100644 --- a/stacks/chipathon-tools/Dockerfile +++ b/stacks/chipathon-tools/Dockerfile @@ -2,6 +2,8 @@ ARG BASE_IMG=heavy-desktop FROM $BASE_IMG as chipathon-tools # Add scripts +COPY --chown=designer:designer --chmod=755 stacks/chipathon-tools/scripts/global-variables . + COPY --chown=designer:designer --chmod=755 stacks/chipathon-tools/scripts/install-open-pdks.sh . RUN ./install-open-pdks.sh diff --git a/stacks/chipathon-tools/scripts/global-variables.sh b/stacks/chipathon-tools/scripts/global-variables.sh new file mode 100644 index 0000000..64fd2f8 --- /dev/null +++ b/stacks/chipathon-tools/scripts/global-variables.sh @@ -0,0 +1,11 @@ +export PDK_ROOT=/home/designer/.volare +export OPEN_PDKS_COMMIT="cd1748bb197f9b7af62a54507de6624e30363943" + +# This files can be downloaded directly +# - sky130A_mr.drc +# - gf180mcuD_mr.drc +export PRECHECK_REPO=https://raw.githubusercontent.com/efabless/mpw_precheck/main/checks/tech-files/ +export PRECHECK_GF_FILE=gf180mcuD_mr.drc +export PRECHECK_SKY_FILE=sky130A_mr.drc + +export SCRIPT_DIR=$PWD \ No newline at end of file diff --git a/stacks/chipathon-tools/scripts/install-open-pdks.sh b/stacks/chipathon-tools/scripts/install-open-pdks.sh index aa02580..27f1dae 100644 --- a/stacks/chipathon-tools/scripts/install-open-pdks.sh +++ b/stacks/chipathon-tools/scripts/install-open-pdks.sh @@ -2,8 +2,7 @@ set -ex -export OPEN_PDKS_VERSION="e0f692f46654d6c7c99fc70a0c94a080dab53571" -export SCRIPT_DIR=$PWD +source ./global-variables.sh #pip install git+https://github.com/gdsfactory/skywater130.git git+https://github.com/gdsfactory/gf180.git --upgrade --break-system-packages # pip install gf180 --upgrade --break-system-packages diff --git a/stacks/chipathon-tools/scripts/patch-open-pdks-gf180.sh b/stacks/chipathon-tools/scripts/patch-open-pdks-gf180.sh index e5054dc..1ab4e1d 100644 --- a/stacks/chipathon-tools/scripts/patch-open-pdks-gf180.sh +++ b/stacks/chipathon-tools/scripts/patch-open-pdks-gf180.sh @@ -1,28 +1,90 @@ #!/bin/bash set -ex +function _arch_setup() { + sudo aur-install wget gedit xterm gvim + pip install docopt --upgrade --break-system-packages +} + + +function _gf180mcuD_clean_install() { + # Re-installs gf180mcuD + + rm -rf $PDK_ROOT/gf180mcu* + rm -rf $PDK_ROOT/volare/gf180mcu/versions/$OPEN_PDKS_COMMIT + + volare enable --pdk gf180mcu $OPEN_PDKS_COMMIT + + rm -rf $PDK_ROOT/gf180mcuA + rm -rf $PDK_ROOT/gf180mcuB + rm -rf $PDK_ROOT/gf180mcuC + + rm -rf $PDK_ROOT/volare/gf180mcu/versions/$OPEN_PDKS_COMMIT/gf180mcuA + rm -rf $PDK_ROOT/volare/gf180mcu/versions/$OPEN_PDKS_COMMIT/gf180mcuB + rm -rf $PDK_ROOT/volare/gf180mcu/versions/$OPEN_PDKS_COMMIT/gf180mcuC +} + + function gf180_delete_repos() { rm -rf globalfoundries-pdk-libs-gf180mcu_fd_pr rm -rf globalfoundries-pdk-libs-gf180mcu_fd_pv } + function gf180_download_repos() { gf180_delete_repos - git clone https://github.com/efabless/globalfoundries-pdk-libs-gf180mcu_fd_pr.git - git clone https://github.com/efabless/globalfoundries-pdk-libs-gf180mcu_fd_pv.git + git clone --depth 1 https://github.com/efabless/globalfoundries-pdk-libs-gf180mcu_fd_pr.git + git clone --depth 1 https://github.com/efabless/globalfoundries-pdk-libs-gf180mcu_fd_pv.git } -function gf180_patch_xschemrc() { + +function gf180_patch_ngspice_primitives() { + NGSPICE_TECH=$PDK_ROOT/gf180mcuD/libs.tech/ngspice + + rm -rf $NGSPICE_TECH + mv globalfoundries-pdk-libs-gf180mcu_fd_pr/models/ngspice $NGSPICE_TECH +} + + +function gf180_patch_xyce_primitives() { + XYCE_TECH=$PDK_ROOT/gf180mcuD/libs.tech/xyce + + rm -rf $XYCE_TECH + mv globalfoundries-pdk-libs-gf180mcu_fd_pr/models/xyce $XYCE_TECH +} + +function gf180_patch_xschem_primitives() { + # Replace volare xschem dir with efabless one + XSCHEM_TECH=$PDK_ROOT/gf180mcuD/libs.tech/xschem + + rm -rf $XSCHEM_TECH + mv globalfoundries-pdk-libs-gf180mcu_fd_pr/cells/xschem $XSCHEM_TECH +} + +function gf180_patch_xschem_xschemrc() { FILEPATH=$PDK_ROOT/gf180mcuD/libs.tech/xschem/xschemrc + # Add gf180mcuD symbols to xschem path ORIGINAL='append XSCHEM_LIBRARY_PATH :$env(PWD)' - REPLACE='append XSCHEM_LIBRARY_PATH :$env(PDK_ROOT)/$env(PDK)/libs.tech/xschem' + REPLACE='append XSCHEM_LIBRARY_PATH :$env(PDK_ROOT)/gf180mcuD/libs.tech/xschem' sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH + # Update 180MCU_MODELS ORIGINAL='set 180MCU_MODELS ${PDK_ROOT}/models/ngspice' - REPLACE='set 180MCU_MODELS $env(PDK_ROOT)/$env(PDK)/libs.tech/ngspice' + REPLACE='set 180MCU_MODELS $env(PDK_ROOT)/gf180mcuD/libs.tech/ngspice' sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH + + # Allow setting of symbol paths with XSCHEM_USER_LIBRARY_PATH env variable + echo '' >> $FILEPATH + echo '# open_pdks-specific' >> $FILEPATH + echo 'set XSCHEM_START_WINDOW ${PDK_ROOT}/gf180mcuD/libs.tech/xschem/tests/0_top.sch' >> $FILEPATH + echo 'append XSCHEM_LIBRARY_PATH :${PDK_ROOT}/gf180mcuD/libs.tech/xschem' >> $FILEPATH + echo '' >> $FILEPATH + echo '# allow a user-specific path add-on' >> $FILEPATH + echo 'if { [info exists ::env(XSCHEM_USER_LIBRARY_PATH) ] } {' >> $FILEPATH + echo ' append XSCHEM_LIBRARY_PATH :$env(XSCHEM_USER_LIBRARY_PATH)' >> $FILEPATH + echo '}' >> $FILEPATH } function gf180_patch_klayout_pcells() { @@ -45,8 +107,8 @@ function gf180_patch_klayout_drc_lvs() { rm -rf $KLAYOUT_HOME/drc rm -rf $KLAYOUT_HOME/lvs - cp globalfoundries-pdk-libs-gf180mcu_fd_pv/klayout/drc $KLAYOUT_HOME - cp globalfoundries-pdk-libs-gf180mcu_fd_pv/klayout/lvs $KLAYOUT_HOME + mv globalfoundries-pdk-libs-gf180mcu_fd_pv/klayout/drc $KLAYOUT_HOME + mv globalfoundries-pdk-libs-gf180mcu_fd_pv/klayout/lvs $KLAYOUT_HOME } function gf180_patch_klayout_dropdown() { @@ -54,8 +116,23 @@ function gf180_patch_klayout_dropdown() { # Depends on $KLAYOUT_HOME/drc $KLAYOUT_HOME/lvs mv globalfoundries-pdk-libs-gf180mcu_fd_pr/rules/klayout/macros $KLAYOUT_HOME - # Make D the default variant - sed -i "s/variant: C/variant: D/g" $KLAYOUT_HOME/macros/*_options.yml + # Make D the default variant in {drc lvs}_options.yml + FILEPATH=$KLAYOUT_HOME/macros/*_options.yml + + ORIGINAL='variant: C' + REPLACE='variant: D' + sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH + + # Make D default on .lym + FILEPATH=$KLAYOUT_HOME/macros/gf180mcu_options.lym + + ORIGINAL=';"C"' + REPLACE=';"D"' + sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH + + ORIGINAL='], 2)' + REPLACE='], 3)' + sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH } function gf180_patch_klayout_precheck_drc() { @@ -69,12 +146,17 @@ function gf180_patch_klayout_lyp() { function gf180_patch() { # volare pdk should be installed with ./volare_install.sh - export KLAYOUT_HOME="$PDK_ROOT/gf180mcuD/libs.tech/klayout" gf180_download_repos - gf180_patch_xschemrc + gf180_patch_ngspice_primitives + + gf180_patch_xyce_primitives + + gf180_patch_xschem_primitives + gf180_patch_xschem_xschemrc + gf180_patch_klayout_pcells gf180_patch_klayout_tech_clean gf180_patch_klayout_drc_lvs @@ -85,19 +167,8 @@ function gf180_patch() { gf180_delete_repos } +source ./global-variables.sh -SCRIPT_DIR=$PWD - -# This files can be downloaded directly -# - sky130A_mr.drc -# - gf180mcuD_mr.drc -PRECHECK_REPO=https://raw.githubusercontent.com/efabless/mpw_precheck/main/checks/tech-files/ -PRECHECK_GF_FILE=gf180mcuD_mr.drc -PRECHECK_SKY_FILE=sky130A_mr.drc - -sudo aur-install wget -pip install docopt --upgrade --break-system-packages - +#_gf180mcuD_clean_install +_arch_setup gf180_patch - -sudo aur-install gedit xterm gvim \ No newline at end of file diff --git a/stacks/chipathon-tools/scripts/patch-open-pdks-sky130.sh b/stacks/chipathon-tools/scripts/patch-open-pdks-sky130.sh index b816aa7..c4f99f1 100644 --- a/stacks/chipathon-tools/scripts/patch-open-pdks-sky130.sh +++ b/stacks/chipathon-tools/scripts/patch-open-pdks-sky130.sh @@ -1,23 +1,6 @@ #!/bin/bash set -ex -SCRIPT_DIR=$PWD - -# This files can be downloaded directly -# - sky130A_mr.drc -# - gf180mcuC_mr.drc -PRECHECK_REPO=https://raw.githubusercontent.com/efabless/mpw_precheck/main/checks/tech-files/ -PRECHECK_GF_FILE=gf180mcuC_mr.drc -PRECHECK_SKY_FILE=sky130A_mr.drc - -# TODO: DOWNLOAD WITH WGET, DONT HAVE IT STATIC -if [ -d $SCRIPT_DIR/iic-spice-model-red.py ]; then - echo File iic-spice-model.red.py not found - return -1 -fi - -sudo aur-install wget - function sky130_patch_reduced_models() { cd "$PDK_ROOT/sky130A/libs.tech/ngspice" || exit 1 "$SCRIPT_DIR/iic-spice-model-red.py" sky130.lib.spice tt @@ -69,6 +52,16 @@ function sky130_patch() { sky130_patch_klayout_precheck_drc } +source ./global-variables.sh + +# TODO: DOWNLOAD WITH WGET, DONT HAVE IT STATIC +if [ -d $SCRIPT_DIR/iic-spice-model-red.py ]; then + echo File iic-spice-model.red.py not found + return -1 +fi + +sudo aur-install wget + sky130_patch sudo aur-install gedit xterm gvim \ No newline at end of file