Merge pull request 'main' (#13) from akiles/osic-stacks:main into main
Some checks failed
release / build-analog-xk (push) Has been cancelled
release / build-analog-xm (push) Has been cancelled
release / build-analog-heavy (push) Has been cancelled
release / build-digital-ator (push) Has been cancelled
release / build-digital-icarus (push) Has been cancelled
release / build-digital-heavy (push) Has been cancelled
release / build-heavy (push) Has been cancelled
release / build-base (push) Failing after 44s

Reviewed-on: #13
This commit is contained in:
Mario Romero 2023-10-02 21:24:16 +00:00
commit 4c51d34015
10 changed files with 763 additions and 1 deletions

5
.gitattributes vendored
View File

@ -3,9 +3,12 @@
.png filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.sh text eol=lf
*.py text eol=lf
*.bat text eol=crlf
desktopinit text eol=lf
klayout text eol=lf
.bashrc text eol=lf
setwallpaper text eol=lf
startserver text eol=lf
*.desktop text eol=lf
*.desktop text eol=lf
xschemrc text eol=lf

43
compile.bat Normal file
View File

@ -0,0 +1,43 @@
@echo off
setlocal
@REM SET BASE_IMG=git.1159.cl/mario1159/analog-xk-web:latest
SET BASE_IMG=git.1159.cl/mario1159/heavy-desktop:latest
SET RESULT_IMAGE=akilesalreadytaken/chipathon-tools:latest
SET CALL=call
:parse
IF /I ""%1""=="""" GOTO run
IF /I ""%1""==""--help"" GOTO documentation
IF /I ""%1""==""-h"" GOTO documentation
IF /I ""%1""==""--dry"" ( SET "CALL=echo" )
IF /I ""%1""==""-s"" ( SET "CALL=echo" )
IF /I ""%1""==""--path"" ( SET "DESIGNS=%~2" && SHIFT )
IF /I ""%1""==""-p"" ( SET "DESIGNS=%~2" && SHIFT )
SHIFT
GOTO parse
:documentation
echo Usage: run.bat %~nx0 [-h^|--help] [-s^|--dry-run]
GOTO end
:run
%CALL% docker build --build-arg BASE_IMG=%BASE_IMG% -t %RESULT_IMAGE% -f stacks/chipathon-tools/Dockerfile stacks/chipathon-tools/
GOTO end
:end
endlocal
:normalizepath
SET DESIGNS=%~f1
EXIT /B
:: Get DISPLAY from WSL
::wsl --exec bash --norc -c 'echo $DISPLAY'
:: Get current path of batsh script
::SET BATCH_PATH=%~dpnx0

166
run.bat Normal file
View File

@ -0,0 +1,166 @@
@echo off
setlocal
SET IMAGE=akilesalreadytaken/analog-xk:latest
SET IMAGE=akilesalreadytaken/chipathon-tools:latest
::SET IMAGE=git.1159.cl/mario1159/analog-xk-web:latest
SET CALL=call
:parse
IF /I ""%~1""=="""" GOTO run
IF /I ""%~1""==""--help"" GOTO documentation
IF /I ""%~1""==""-h"" GOTO documentation
IF /I ""%~1""==""--dry"" ( SET "CALL=echo" )
IF /I ""%~1""==""-s"" ( SET "CALL=echo" )
IF /I ""%~1""==""-v"" ( SET "ENABLE_VNC=" )
IF /I ""%~1""==""--vnc"" ( SET "ENABLE_VNC=" )
IF /I ""%~1""==""--path"" ( SET "DESIGNS=%~2" && SHIFT )
IF /I ""%~1""==""-p"" ( SET "DESIGNS=%~2" && SHIFT )
IF /I ""%~1""==""-k"" ( SET "PDK=%~2" && SHIFT )
IF /I ""%~1""==""--pdk"" ( SET "PDK=%~2" && SHIFT )
SHIFT
GOTO parse
:documentation
echo Usage: run.bat %~nx0 [ OPTIONS ]
echo.
echo -h --help Show usage information
echo -s --dry See the commands to be executed
echo -p --path PATH Link to a directory
echo -v --vnc Enable the vnc in port "https:\\localhost:8444"
echo If vnc is not working, execute:
echo ^$ xfce4-session --display=:1 ^&
echo -k --pdk PDK Set the PDK to be used: gf180mcuC ^| sky130A
echo By default: gf180mcuC
GOTO end
:run
:: Set fixed parameters
:::::::::::::::::::::::::::
IF NOT DEFINED DESIGNS SET DESIGNS=%CD%
CALL :NORMALIZEPATH %DESIGNS%
IF NOT DEFINED PDK SET PDK=gf180mcuC
IF NOT DEFINED DOCKER_USER SET DOCKER_USER=git.1159.cl/mario1159
IF NOT DEFINED DOCKER_IMAGE SET DOCKER_IMAGE=analog-xk
IF NOT DEFINED DOCKER_TAG SET DOCKER_TAG=latest
IF NOT DEFINED CONTAINER_USER SET CONTAINER_USER=1000
IF NOT DEFINED CONTAINER_GROUP SET CONTAINER_GROUP=1000
IF NOT DEFINED CONTAINER_NAME SET CONTAINER_NAME=chipathon-tools
IF NOT DEFINED JUPYTER_PORT SET JUPYTER_PORT=8888
IF NOT DEFINED VNC_PORT SET VNC_PORT=8444
:: Get parameters from wsl
::::::::::::::::::::::::::
SET WSL_GET_PARAMETER=wsl --exec bash --norc -c "echo $DISPLAY"
@REM SET WSL_GET_PARAMETER=wsl -d docker-desktop --exec ash -c "echo $DISPLAY"
FOR /F "USEBACKQ" %%i IN (`%WSL_GET_PARAMETER%`) DO ( SET "DISPLAY=%%i" )
SET WSL_GET_PARAMETER=wsl --exec bash --norc -c "echo $WAYLAND_DISPLAY"
@REM SET WSL_GET_PARAMETER=wsl -d docker-desktop --exec ash -c "echo $WAYLAND_DISPLAY"
FOR /F "USEBACKQ" %%i IN (`%WSL_GET_PARAMETER%`) DO ( SET "WAYLAND_DISPLAY=%%i" )
SET WSL_GET_PARAMETER=wsl --exec bash --norc -c "echo $XDG_RUNTIME_DIR"
@REM SET WSL_GET_PARAMETER=wsl -d docker-desktop --exec ash -c "echo $XDG_RUNTIME_DIR"
FOR /F "USEBACKQ" %%i IN (`%WSL_GET_PARAMETER%`) DO ( SET "XDG_RUNTIME_DIR=%%i" )
:: Validate parameters
::::::::::::::::::::::
IF %CONTAINER_USER% NEQ 0 IF %CONTAINER_USER% LSS 1000 (
echo WARNING: Selected User ID %CONTAINER_USER% is below 1000. This ID might interfere with User-IDs inside the container and cause undefined behaviour!
)
IF %CONTAINER_GROUP% NEQ 0 IF %CONTAINER_GROUP% LSS 1000 (
echo WARNING: Selected Group ID %CONTAINER_GROUP% is below 1000. This ID might interfere with Group-IDs inside the container and cause undefined behaviour!
)
:: Attach to existing container
:::::::::::::::::::::::::::::::
docker container inspect %CONTAINER_NAME% 2>&1 | find "Status" | find /i "running"
IF NOT ERRORLEVEL 1 (
ECHO Container %CONTAINER_NAME% is running!
ECHO Stop with "docker stop %CONTAINER_NAME%"
ECHO Remove with "docker rm %CONTAINER_NAME%" if required.
GOTO attach_shell
)
docker container inspect %CONTAINER_NAME% 2>&1 | find "Status" | find /i "exited"
IF NOT ERRORLEVEL 1 (
ECHO Container %CONTAINER_NAME% exists.
ECHO Restart with "docker start %CONTAINER_NAME%"
ECHO Or remove with "docker rm %CONTAINER_NAME%" if required.
GOTO restart_shell
)
:: Set environment, variables and run the container
:::::::::::::::::::::::::::::::::::::::::::::::::::
echo Check requirements
%CALL% wsl --install Ubuntu --no-launch
%CALL% wsl --update
echo Container does not exist, creating %CONTAINER_NAME% ...
SET PARAMS=-d
SET PARAMS=%PARAMS% --name %CONTAINER_NAME%
::SET PARAMS=%PARAMS% --user %CONTAINER_USER%:%CONTAINER_GROUP%
SET PARAMS=%PARAMS% --security-opt seccomp=unconfined
SET PARAMS=%PARAMS% -p %JUPYTER_PORT%:8888
SET PARAMS=%PARAMS% -p %VNC_PORT%:8444
SET PARAMS=%PARAMS% -v "%DESIGNS%":/home/designer/shared
SET PARAMS=%PARAMS% -v "\\wsl.localhost\Ubuntu\mnt\wslg":/tmp
SET PARAMS=%PARAMS% -v "\\wsl.localhost\Ubuntu\mnt\wslg\runtime-dir":%XDG_RUNTIME_DIR%
@REM SET PARAMS=%PARAMS% -v "\\wsl.localhost\docker-desktop\mnt\host\wslg":/tmp
@REM SET PARAMS=%PARAMS% -v "\\wsl.localhost\docker-desktop\mnt\host\wslg\runtime-dir":%XDG_RUNTIME_DIR%
SET PARAMS=%PARAMS% -e PDK=%PDK%
SET PARAMS=%PARAMS% -e DISPLAY=%DISPLAY%
SET PARAMS=%PARAMS% -e WAYLAND_DISPLAY=%WAYLAND_DISPLAY%
SET PARAMS=%PARAMS% -e XDG_RUNTIME_DIR=%XDG_RUNTIME_DIR%
@REM IF NOT DEFINED ENABLE_VNC (
@REM ) ELSE (
@REM )
IF NOT DEFINED IMAGE (
SET IMAGE=%DOCKER_USER%/%DOCKER_IMAGE%
IF DEFINED DOCKER_TAG SET IMAGE=%IMAGE%:%DOCKER_TAG%
)
@REM SET COMMAND=jupyter-lab --no-browser
@REM SET COMMAND=sleep infinity
%CALL% docker run %PARAMS% %IMAGE% %COMMAND%
GOTO attach_shell
:attach_shell
%CALL% docker exec -it %CONTAINER_NAME% bash
GOTO end
:restart_shell
%CALL% docker start %CONTAINER_NAME%
GOTO attach_shell
:end
endlocal
EXIT
:normalizepath
SET DESIGNS=%~f1
EXIT /B
:: Get DISPLAY from WSL
::wsl --exec bash --norc -c 'echo $DISPLAY'
:: Get current path of batsh script
::SET BATCH_PATH=%~dpnx0

155
run.sh Normal file
View File

@ -0,0 +1,155 @@
#!/bin/bash
set -e
# IMAGE=akilesalreadytaken/analog-xk:latest
IMAGE=akilesalreadytaken/chipathon-tools:latest
# IMAGE=git.1159.cl/mario1159/analog-xk-web:latest
CALL=
function parse () {
while getopts ":hsvp:k:" option; do
case $option in
h) documentation ;;
s) CALL="echo [CMD] " ;;
#v) ENABLE_VNC=1 ;; # VNC not working rigth now
p) DESIGNS=$OPTARG ;;
k) PDK=$OPTARG ;;
\?) echo "Error: Invalid option"; documentation ;;
esac
done
}
function documentation () {
echo "Usage: run.bat [ OPTIONS ]"
echo ""
echo " -h Show usage information"
echo " -s See the commands to be executed"
echo " -p PATH Link to a directory"
# echo " -v Enable the vnc in port "https:\\localhost:8444""
# echo " If vnc is not working, execute:"
# echo " $ xfce4-session --display=:1 &"
echo " -k PDK Set the PDK to be used (gf180mcuC | sky130A)"
echo " By default: gf180mcuC"
exit
}
function run () {
# Set fixed parameters
####################
[ -z "${DESIGNS+x}" ] && DESIGNS=$PWD
DESIGNS=$( realpath $DESIGNS )
[ -z "${PDK+x}" ] && PDK=gf180mcuC
[ -z "${DOCKER_USER+x}" ] && DOCKER_USER=git.1159.cl/mario1159
[ -z "${DOCKER_IMAGE+x}" ] && DOCKER_IMAGE=analog-xk
[ -z "${DOCKER_TAG+x}" ] && DOCKER_TAG=latest
[ -z "${CONTAINER_USER+x}" ] && CONTAINER_USER=$(id -u)
[ -z "${CONTAINER_GROUP+x}" ] && CONTAINER_GROUP=$(id -g)
[ -z "${CONTAINER_NAME+x}" ] && CONTAINER_NAME=chipathon-tools
[ -z "${JUPYTER_PORT+x}" ] && JUPYTER_PORT=8888
[ -z "${VNC_PORT+x}" ] && VNC_PORT=8444
# Validate parameters
#####################
if [[ ${CONTAINER_USER} -ne 0 ]] && [[ ${CONTAINER_USER} -lt 1000 ]]; then
prt_str="# [WARNING] Selected User ID ${CONTAINER_USER} is below 1000. This ID might interfere with User-IDs inside the container and cause undefined behavior! #"
printf -- '#%.0s' $(seq 1 ${#prt_str})
echo
echo "${prt_str}"
printf -- '#%.0s' $(seq 1 ${#prt_str})
echo
fi
if [[ ${CONTAINER_GROUP} -ne 0 ]] && [[ ${CONTAINER_GROUP} -lt 1000 ]]; then
prt_str="# [WARNING] Selected Group ID ${CONTAINER_GROUP} is below 1000. This ID might interfere with Group-IDs inside the container and cause undefined behavior! #"
printf -- '#%.0s' $(seq 1 ${#prt_str})
echo
echo "${prt_str}"
printf -- '#%.0s' $(seq 1 ${#prt_str})
echo
fi
# Check if the container exists and if it is running.
if [ "$(docker ps -q -f name="${CONTAINER_NAME}")" ]; then
echo "[WARNING] Container is running!"
echo "[HINT] It can also be stopped with \"docker stop ${CONTAINER_NAME}\" and removed with \"docker rm ${CONTAINER_NAME}\" if required."
echo
echo -n "Press \"s\" to stop, and \"r\" to stop & remove: "
read -r -n 1 k <&1
echo
if [[ $k = s ]] ; then
$CALL docker stop "${CONTAINER_NAME}"
elif [[ $k = r ]] ; then
$CALL docker stop "${CONTAINER_NAME}"
$CALL docker rm "${CONTAINER_NAME}"
fi
exit
fi
# If the container exists but is exited, it is restarted.
if [ "$(docker ps -aq -f name="${CONTAINER_NAME}")" ]; then
echo "[WARNING] Container ${CONTAINER_NAME} exists."
echo "[HINT] It can also be restarted with \"docker start ${CONTAINER_NAME}\" or removed with \"docker rm ${CONTAINER_NAME}\" if required."
echo
echo -n "Press \"s\" to start, and \"r\" to remove: "
read -r -n 1 k <&1
echo
if [[ $k = s ]] ; then
$CALL docker start "${CONTAINER_NAME}"
elif [[ $k = r ]] ; then
$CALL docker rm "${CONTAINER_NAME}"
fi
exit
fi
# Set environment, variables and run the container
##################################################
echo "[INFO] Container does not exist, creating ${CONTAINER_NAME} ..."
PARAMS="-d"
PARAMS="$PARAMS --name $CONTAINER_NAME"
PARAMS="$PARAMS -e PDK=$PDK"
PARAMS="$PARAMS --user ${CONTAINER_USER}:${CONTAINER_GROUP}"
PARAMS="$PARAMS --security-opt seccomp=unconfined"
PARAMS="$PARAMS -p $JUPYTER_PORT:8888"
PARAMS="$PARAMS -v $DESIGNS:/home/designer/shared"
PARAMS="$PARAMS -v /tmp/.X11-unix:/tmp/.X11-unix"
if [ -z "${ENABLE_VNC+x}" ]; then
PARAMS="$PARAMS -e DISPLAY=$DISPLAY"
PARAMS="$PARAMS -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY"
PARAMS="$PARAMS -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
else
PARAMS="$PARAMS -p $VNC_PORT:8444"
# Should use WSL_DISTRO_NAME ?
PARAMS="$PARAMS -v /mnt/wslg:/mnt/wsl"
fi
if [ -z "${IMAGE+x}" ]; then
IMAGE=$DOCKER_USER/$DOCKER_IMAGE:$DOCKER_TAG
fi
echo "[INFO] Container based on $IMAGE"
$CALL docker run $PARAMS $IMAGE $COMMAND
attach_shell
}
function attach_shell () {
$CALL docker exec -it $CONTAINER_NAME bash
}
function restart_shell () {
$CALL docker start $CONTAINER_NAME
attach_shell
}
parse $@
run

View File

@ -0,0 +1,14 @@
ARG BASE_IMG=heavy-desktop
FROM $BASE_IMG as chipathon-tools
# Add scripts
COPY --chown=designer:designer --chmod=755 scripts/install-open-pdks.sh .
RUN ./install-open-pdks.sh
COPY --chown=designer:designer --chmod=755 scripts/* .
RUN ./patch-open-pdks.sh
RUN rm *.sh
# Initialize the enviroment keeping container alive
CMD ["sleep", "infinity"]

View File

@ -0,0 +1,49 @@
[[ $- != *i* ]] && return
case "$PDK" in
gf180mcuC)
export PDKPATH=$PDK_ROOT/$PDK
export STD_CELL_LIBRARY=gf180mcu_fd_sc_mcu7t5v0
;;
sky130A)
export PDKPATH=$PDK_ROOT/$PDK
export STD_CELL_LIBRARY=sky130_fd_sc_hd
;;
*)
echo "PDK not defined, using default one (gf180mcuC)"
export PDK=gf180mcuC
export PDKPATH=$PDK_ROOT/$PDK
export STD_CELL_LIBRARY=gf180mcu_fd_sc_mcu7t5v0
;;
esac
function git_branch {
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [ "$branch" != "" ]; then
echo "[$branch]"
fi
}
c_res='\[\033[00m\]' # Reset
c_bla='\[\033[01;30m\]' # Black
c_red='\[\033[01;31m\]' # Red
c_gre='\[\033[01;32m\]' # Green
c_yel='\[\033[01;33m\]' # Yellow
c_blu='\[\033[01;34m\]' # Blue
c_pur='\[\033[01;35m\]' # Purple
c_cya='\[\033[01;36m\]' # Cyan
c_whi='\[\033[01;37m\]' # White
# export PS1="${c_pur}\w $(git_branch)\n${c_res}\$ " ## This dont work :(
PS1="${c_pur}\w \n${c_res}\$ " ## This dont work :(
export KLAYOUT_HOME=$PDK_ROOT/$PDK/libs.tech/klayout
export DESIGNS="/home/designer/shared"
alias ls="ls --color=auto -XF"
alias grep="grep --color=auto"
alias xschem='xschem -b --rcfile $PDK_ROOT/$PDK/libs.tech/xschem/xschemrc'
alias xschemtcl='xschem --rcfile $PDK_ROOT/$PDK/libs.tech/xschem/xschemrc'
git config --global --add safe.directory $DESIGNS

View File

@ -0,0 +1,26 @@
set nocompatible
filetype plugin on
filetype indent on
syntax on
set number relativenumber
set autoindent expandtab tabstop=4 shiftwidth=4
set cursorline
set mouse=a
set showcmd
set showmatch
set lazyredraw
set ttyfast
set clipboard="unnamedplus"
set showmatch
set wildmenu
set backspace=indent,eol,start
let &t_SI="\e[6 q"
let &t_EI="\e[2 q"
let &t_ut=''

View File

@ -0,0 +1,133 @@
#!/usr/bin/env python3
# ========================================================================
# SPDX-FileCopyrightText: 2021-2022 Harald Pretl
# Johannes Kepler University, Institute for Integrated Circuits
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0
#
# This script traverses SPICE model files (e.g. from SKY130) and
# extracts only the wanted model section, removes all comments and
# empty lines, and resolves all includes so that a flat model file
# results. This should speed up ngspice starts.
# ========================================================================
import sys,re,os
def process_file(file_in_name, top_file):
global is_warning
try:
f_in = open(file_in_name, 'r')
except FileNotFoundError:
print('Warning! File ' + file_in_name + ' not found.')
is_warning = True
return;
# process_file can be called recursively, so that nested include
# files can be traversed
# write_active indicates whether we are in the right model section; in
# include files, it is always true
if top_file == True:
write_active = False
else:
write_active = True
for line in f_in:
line_trim = (line.lower()).strip()
if top_file == True:
# we assume that .lib statements are only used in the main file
if '.lib' in line_trim:
if model_section in line_trim:
write_active = True
else:
write_active = False
if '.endl' == line_trim:
write_active = False
f_out.write(line)
if len(line_trim) > 0: # write no empty lines
if (line_trim[0] != '*'): # write no comments
if (write_active == True):
if '.include' in line_trim:
# need to save and restore working dir so that nested
# includes work
current_wd = os.getcwd()
newfile = re.findall(r'"(.*?)(?<!\\)"', line_trim)
print('Reading ',newfile[0])
# enter new working dir
new_wd = os.path.dirname(newfile[0])
if len(new_wd) > 0:
try:
os.chdir(new_wd)
except OSError:
print('Warning: Could not enter directory ' + new_wd)
is_warning = True
# traverse into new include file
new_file_name = os.path.basename(newfile[0])
process_file(new_file_name, False)
# restore old working dir after return
os.chdir(current_wd)
else:
f_out.write(line)
f_in.close()
return;
# main routine
if len(sys.argv) == 3:
model_section = sys.argv[2]
else:
model_section = 'tt'
if (len(sys.argv) == 2) or (len(sys.argv) == 3):
infile_name = sys.argv[1]
outfile_name = infile_name + '.' + model_section + '.red'
try:
f_out = open(outfile_name, 'w')
except OSError:
print('Error: Cannot write file ' + outfile_name + '.')
sys.exit(1)
is_warning = False
process_file(infile_name, True)
f_out.close()
print()
print('Model file ' + outfile_name + ' written.')
if is_warning == True:
print('There have been warnings! Please check output log.')
sys.exit(0)
else:
sys.exit(0)
else:
print()
print('iic-spice-model-red.py SPICE model file reducer')
print(' (c) 2021 Harald Pretl, JKU')
print()
print('Usage: iic-spice-model-red <inputfile> [corner] (default corner = tt)')
print()
print('Return codes for script automation:')
print(' 0 = all OK or warnings')
print(' 1 = errors')
print(' 2 = call of script w/o parameters (= showing this message)')
print()
sys.exit(2)

View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
export OPEN_PDKS_VERSION="dd7771c384ed36b91a25e9f8b314355fc26561be"
export SCRIPT_DIR=$PWD
######################
# INSTALL GF180MCU PDK
######################
volare enable "${OPEN_PDKS_VERSION}" --pdk gf180mcu
rm -rf $PDK_ROOT/volare/gf180mcu/versions/*/gf180mcuA
rm -rf $PDK_ROOT/volare/gf180mcu/versions/*/gf180mcuB
rm -rf $PDK_ROOT/volare/gf180mcu/versions/*/gf180mcuD
rm -rf $PDK_ROOT/gf180mcuA
rm -rf $PDK_ROOT/gf180mcuB
rm -rf $PDK_ROOT/gf180mcuD
####################
# INSTALL SKY130 PDK
####################
pip install sky130 --upgrade --break-system-packages
volare enable "${OPEN_PDKS_VERSION}" --pdk sky130
# ADD PCELL SUPPORT
# remove version sky130B to save space (efabless TO use mostly sky130A)
rm -rf "$PDK_ROOT"/volare/sky130/versions/*/sky130B
rm -rf "$PDK_ROOT"/sky130B

View File

@ -0,0 +1,140 @@
#!/bin/bash
set -e
SCRIPT_DIR=$PWD
DROPDOWN_REPO="https://github.com/mabrains/globalfoundries-pdk-libs-gf180mcu_fd_pr"
# 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
pip install docopt --upgrade --break-system-packages
######################
# PATCH GF180MCU PDK
######################
function gf180_patch_xschemrc() {
FILEPATH=$PDK_ROOT/gf180mcuC/libs.tech/xschem/xschemrc
ORIGINAL='append XSCHEM_LIBRARY_PATH :$env(PWD)'
REPLACE='append XSCHEM_LIBRARY_PATH :$env(PDK_ROOT)/$env(PDK)/libs.tech/xschem'
sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH
ORIGINAL='set 180MCU_MODELS ${PDK_ROOT}/models/ngspice'
REPLACE='set 180MCU_MODELS $env(PDK_ROOT)/$env(PDK)/libs.tech/ngspice'
sed -i "s\\$ORIGINAL\\$REPLACE\g" $FILEPATH
}
function gf180_patch_klayout_pcells() {
KLAYOUT_HOME="$PDK_ROOT/gf180mcuC/libs.tech/klayout"
mv $KLAYOUT_HOME/pymacros $KLAYOUT_HOME/cells
mkdir $KLAYOUT_HOME/pymacros
mv $KLAYOUT_HOME/cells $KLAYOUT_HOME/pymacros
mv $KLAYOUT_HOME/tech/gf180mcu.lym $KLAYOUT_HOME/pymacros
rm -rf .scripts/klayout
}
function gf180_patch_klayout_dropdown() {
# 27:00 & 36:40
KLAYOUT_HOME="$PDK_ROOT/gf180mcuC/libs.tech/klayout"
DROPDOWN_DIRECTORY="globalfoundries"
git clone $DROPDOWN_REPO $DROPDOWN_DIRECTORY
cp -r $DROPDOWN_DIRECTORY/rules/klayout/macros $KLAYOUT_HOME
# There's no directories
# cp -r $DROPDOWN_DIRECTORY/rules/klayout/drc/*.drc $KLAYOUT_HOME/drc
# cp -r $DROPDOWN_DIRECTORY/rules/klayout/lvs/*.lvs $KLAYOUT_HOME/lvs
rm -rf $DROPDOWN_DIRECTORY
}
function gf180_patch_klayout_precheck_drc() {
KLAYOUT_HOME="$PDK_ROOT/gf180mcuC/libs.tech/klayout"
#curl -o $KLAYOUT_HOME/drc/rule_decks/$PRECHECK_GF_FILE $PRECHECK_REPO/$PRECHECK_GF_FILE
wget -O $KLAYOUT_HOME/drc/rule_decks/$PRECHECK_GF_FILE $PRECHECK_REPO/$PRECHECK_GF_FILE
}
function gf180_patch() {
gf180_patch_xschemrc
gf180_patch_klayout_pcells
gf180_patch_klayout_dropdown
gf180_patch_klayout_precheck_drc
}
####################
# PATCH SKY130 PDK
####################
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
"$SCRIPT_DIR/iic-spice-model-red.py" sky130.lib.spice ss
"$SCRIPT_DIR/iic-spice-model-red.py" sky130.lib.spice ff
cd "$SCRIPT_DIR"
rm -rf "iic-spice-model-red.py"
}
function sky130_patch_klayout_lyt() {
KLAYOUT_HOME="$PDK_ROOT/sky130A/libs.tech/klayout"
FILEPATH="$KLAYOUT_HOME/tech/sky130A.lyt"
sed -i 's/>sky130</>sky130A</g' $FILEPATH
sed -i 's/sky130.lyp/sky130A.lyp/g' $FILEPATH
sed -i '/<base-path>/c\ <base-path/>' $FILEPATH
sed -i '/<original-base-path>/c\ <original-base-path>$PDK_ROOT/$PDK/libs.tech/klayout</original-base-path>' $FILEPATH
}
function sky130_patch_klayout_lym () {
KLAYOUT_HOME="$PDK_ROOT/sky130A/libs.tech/klayout"
# ERROR: Reading /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/sky130.lym: XML parser error: invalid name for processing instruction in line 17, column 6
# ERROR: Reading /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/sky130.lym: XML parser error: invalid name for processing instruction in line 17, column 6
# ERROR: Reading /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/sky130.lym: XML parser error: invalid name for processing instruction in line 17, column 6
FILENAME="$KLAYOUT_HOME/pymacros/sky130.lym"
LINE=17
( sed -n ${LINE}' {p;q}' $FILENAME ; sed "${LINE}d" $FILENAME ) > $FILENAME
}
function sky130_patch_klayout_pcells() {
KLAYOUT_HOME="$PDK_ROOT/sky130A/libs.tech/klayout"
# Fixing the above, the cells indicates the following:
# ERROR: /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/cells/via_generator.py:23: ModuleNotFoundError: No module named 'gdsfactory.types'
# /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/cells/via_generator.py:23
# /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/cells/vias.py:20
# /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/cells/__init__.py:21
# /home/designer/.volare/sky130A/libs.tech/klayout/pymacros/sky130.lym:9 (class ModuleNotFoundError)
echo hola
}
function sky130_patch_klayout_precheck_drc() {
KLAYOUT_HOME="$PDK_ROOT/sky130A/libs.tech/klayout"
wget -O $KLAYOUT_HOME/drc/$PRECHECK_SKY_FILE $PRECHECK_REPO/$PRECHECK_SKY_FILE
}
function sky130_patch() {
sky130_patch_reduced_models
sky130_patch_klayout_lyt
# sky130_patch_klayout_lym # TODO: The file disappears
# sky130_patch_klayout_pcells # TODO: Before fixing lym, this explodes
sky130_patch_klayout_precheck_drc
}
gf180_patch
sky130_patch
sudo aur-install gedit xterm gvim