| #!/bin/bash |
| # Copyright 2020 The Skywater PDK Authors |
| # |
| # 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 |
| # |
| # https://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. |
| |
| |
| # Example call |
| # $ ./build_skywater_pdk.sh /home/user/skywater-src-nda /home/user/output /home/user/tmpdir [optional /home/user/skywater-pdk-docs] |
| |
| set -e |
| source common.sh |
| |
| if [[ $# -ne 4 ]]; then |
| msg "You must provide 4 parameters: \n - path to skywater-src-nda\n - path to skywater-pdk-scratch\n - path to a temporary directory\n - path to skywater-pdk-docs" |
| exit 1 |
| fi |
| |
| SKYWATER_NDA_PATH=$(realpath ${1%/}) |
| OUTPUT_DIRECTORY=$(realpath ${2%/}) |
| TMP_DIRECTORY=$(realpath ${3%/}) |
| DOCS_DIRECTORY=$(realpath ${4%/}) |
| NO_OA=1 |
| |
| # Check if we should delete TMP_DIRECTORY (some oa tools fails if file exists) |
| if [ -n "$DELETE_TMP_DIRECTORY" ] |
| then |
| msg "Deleting $TMP_DIRECTORY" |
| rm -rf $TMP_DIRECTORY |
| fi |
| |
| # Check if programs installed are in required versions |
| if [ `which yosys |wc -l` -eq 0 ] || [ `yosys -p 'splitinout' 2>&1 |grep ERROR | wc -l` -eq 1 ] |
| then |
| msg "Yosys not installed or installed in version which does not have the 'splitinout' pass" |
| msg "Please install yosys from 'https://github.com/mithro/yosys/tree/split-inout'" |
| exit 1 |
| fi |
| if [ `which symbolator |wc -l` -eq 0 ] || [ `symbolator --help 2>&1 |grep 'libname' | wc -l` -lt 1 ] |
| then |
| msg "Symbolator not installed or installed in version which does not have the 'libname' argument" |
| msg "Please install symbolator from 'https://github.com/antmicro/symbolator' using 'python3 -m pip install git+https://github.com/antmicro/symbolator'" |
| exit 1 |
| fi |
| |
| if [ ! "$NO_OA" = "1" ] |
| then |
| if [ `which oa2verilog |wc -l` -eq 0 ] || [ -z "$OA_BIT" ] |
| then |
| msg "Missing oa2verilog in path or missing OA_BIT variable" |
| msg "Please install oaTools from openaccess and source env.sh from oaScript/bin" |
| exit 1 |
| fi |
| fi |
| |
| if [ `which magic|wc -l` -eq 0 ] |
| then |
| msg "magic not installed" |
| msg "Please install magic using 'git clone https://github.com/libresilicon/magic-8.2.git && cd magic-8.2 && ./configure && make && make install'" |
| msg "Dependencies (Debian) : csh, tcl, tcl-dev, libreadline-dev" |
| exit 1 |
| fi |
| |
| if [ `which lefrw |wc -l` -eq 0 ] |
| then |
| msg "lefrw not installed" |
| msg "Please install lefrw from 'https://github.com/jrrk/LEF' " |
| exit 1 |
| fi |
| |
| if [ `which netlistsvg |wc -l` -eq 0 ] |
| then |
| msg "netlistsvg not installed" |
| msg "Please install netlistsvg using 'npm install -g netlistsvg' " |
| exit 1 |
| fi |
| |
| declare -A pids |
| function save_pid { |
| pids["$2"]="$1" |
| } |
| |
| # Update paths file with path to skywater-src-nda repository |
| echo $SKYWATER_NDA_PATH > paths |
| |
| # Create json files grouping src-nda files by mods |
| msg "Start initial setup" |
| msg "files-list" |
| python3 files-list.py |
| msg "files-spice" |
| python3 files-spice.py |
| msg "lib2mods" |
| python3 lib2mods.py |
| msg "spice2mods" |
| python3 spice2mods.py |
| msg "verilog2mods" |
| python3 verilog2mods.py |
| msg "End initial setup" |
| |
| if [ ! "$ONLY_OA" = "1" ] ; then |
| |
| ( |
| msg "Start Liberty section" |
| # Clean Liberty files |
| ROOT_DIR=$(pwd) |
| cd liberty_parser |
| msg "Liberty-to-JSON" |
| python3 ../mod2files-json-to-filelist.py ../.files.mod2files.lib.json $TMP_DIRECTORY/lib.list |
| python3 quicklogic_timings_importer/test_full_pipeline.py $TMP_DIRECTORY/lib.list --log-suppress-below ERROR --output-json-root-dir $TMP_DIRECTORY/out-json --skip-json-to-lib |
| msg "JSON-to-Liberty groups" |
| python3 quicklogic_timings_importer/group_cells.py ../.files.mod2files.lib.json $OUTPUT_DIRECTORY/skywater-pdk/libraries --json-path $TMP_DIRECTORY/out-json --path-prefix-to-remove "$TMP_DIRECTORY/out-json/$SKYWATER_NDA_PATH" --log-suppress WARNING --sourcetodests $TMP_DIRECTORY/group_cells.filemapping.json |
| cd $ROOT_DIR |
| msg "End Liberty section" |
| )& |
| save_pid $! "Liberty" |
| |
| ( |
| msg "Start Verilog section" |
| VERILOG2FULL_MAP=verilog2full.filemapping.json |
| VERILOGSPLIT_MAP=verilog_split.filemapping.json |
| msg 'Generating .full.v files' |
| python3 verilog2full.py $SKYWATER_NDA_PATH $OUTPUT_DIRECTORY $TMP_DIRECTORY/$VERILOG2FULL_MAP |
| msg ' Split merged .full.v files' |
| python3 verilog_split.py $OUTPUT_DIRECTORY $TMP_DIRECTORY/$VERILOGSPLIT_MAP |
| msg "Parse specify blocks in Verilog files" |
| python3 parse_specify_from_filelist.py .files.mod2files.verilog.json $OUTPUT_DIRECTORY/skywater-pdk/libraries --path-prefix-to-remove $SKYWATER_NDA_PATH --sourcetodests $TMP_DIRECTORY/parse_specify_from_filelist.filemapping.json |
| msg 'Removing strength "twins"' |
| python3 merge-cells-with-different-strengths.py $OUTPUT_DIRECTORY |
| msg 'Generating .specify.v' |
| python3 verilog2specify.py $OUTPUT_DIRECTORY $TMP_DIRECTORY/verilog2specify.filemapping.json |
| msg 'Generating .simple.v files' |
| python3 verilog2simple.py $OUTPUT_DIRECTORY |
| msg 'Creating temporary base cells lists' |
| pushd $OUTPUT_DIRECTORY |
| for x in `find . -type d -name 'V[0-9].[0-9].[0-9]'` |
| do |
| pushd $x > /dev/null |
| >.base |
| modules=() |
| touch temp |
| mapfile -t modules < <( grep -r -E --include=*.simple.v '^[ ]*sky130\w*? ' |cut -d ':' -f 2 | sed 's/^ *//g' | cut -d ' ' -f 1| sort |uniq |grep -v 'alias' ) |
| mapfile -t -O "${#modules[@]}" modules < <( grep -r -E --include=*.simple.v '^[ ]*(pg_)?[u]_\w*? ' |cut -d ':' -f 2 | sed 's/^ *//g' | cut -d ' ' -f 1| sort |uniq |grep -v 'alias' ) |
| for mod in "${modules[@]}" |
| do |
| msg $mod |
| # Allow 'sky130_fd_io' to use 'sky130_fd_sc_ls' cells in behavioral_tmax |
| lib=`dirname dirname $x |sed 's;.*/;;g' | sed -n '2p'` |
| if [ "${lib}" == "sky130_fd_io" ] && { [ "$mod" == "sky130_fd_sc_ls__pg_u_mux_2_1" ] || [ "$mod" == "sky130_fd_sc_ls__pg_u_dl_p_r" ] ;} ; |
| then |
| realpath `grep -r -E --include "*.simple.v" -l "^module ${mod} ?[\( ]" ` ../../ | sort -r |head -n 1 >> temp |
| else |
| realpath `grep -r -E --include "*.simple.v" -l "^module ${mod} ?[\( ]" ` | sort -r | grep -v '\.\w*\.simple\.v' |head -n 1 >> temp |
| fi |
| done |
| sort temp |uniq >.base |
| rm temp |
| popd > /dev/null |
| done |
| popd > /dev/null |
| |
| msg 'Generating .blackbox.v files' |
| python3 verilog2blackbox.py $OUTPUT_DIRECTORY |
| msg 'Generating .sch.png files' |
| python3 verilog2sch.py $OUTPUT_DIRECTORY |
| msg 'Generating .module.png files' |
| python3 verilog2symbol.py $OUTPUT_DIRECTORY |
| |
| msg 'Renaming and cleaning' |
| pushd $OUTPUT_DIRECTORY > /dev/null |
| shopt -s globstar |
| # Rename module diagrams from '.png' to '.module.png' |
| for x in `ls **/*[^s][^c][^h].png` |
| do mv $x ${x%.png}.module.png |
| done |
| # Remove .base files |
| rm **/.base |
| popd > /dev/null > /dev/null |
| |
| msg 'Rewriting .lef files' |
| python3 lef_rewrite.py $SKYWATER_NDA_PATH $OUTPUT_DIRECTORY $TMP_DIRECTORY/lef_rewrite.filemapping.json |
| msg 'Splitting .lef files' |
| python3 lef_split.py $OUTPUT_DIRECTORY $TMP_DIRECTORY/lef_split.filemapping.json |
| msg "End .lef section" |
| |
| msg "Start GDS and MAG generation" |
| python3 gds_to_lef_gds_mag.py $SKYWATER_NDA_PATH $OUTPUT_DIRECTORY $SKYWATER_NDA_PATH/s8.tech $TMP_DIRECTORY |
| msg "End GDS and MAG generation" |
| |
| # Skipped for release - mag files will be added later on |
| # # Remove old naming from `.mag` `rlabel comment` |
| # pushd $OUTPUT_DIRECTORY > /dev/null |
| # for x in `find . -name *.mag`; |
| # do |
| # sed -i 's/ scs8/ sky130_fd_sc_/g' $x |
| # sed -i 's/ hkscl5hdv1_/ sky130_fd_sc_hdll_/g' $x |
| # done; |
| # popd > /dev/null |
| |
| msg "RST generation" |
| python3 generate-rst.py --mapping $TMP_DIRECTORY/reverse-$VERILOG2FULL_MAP --mapping $TMP_DIRECTORY/reverse-$VERILOGSPLIT_MAP $OUTPUT_DIRECTORY $DOCS_DIRECTORY |
| msg "End Verilog section" |
| |
| )& |
| save_pid $! "Verilog" |
| |
| # Clean up Spice files |
| ( |
| msg "Start Spice files cleanup" |
| python3 clean_spice_files.py .files.mod2files.spice.json $OUTPUT_DIRECTORY/skywater-pdk/libraries .files.mod2files.spice.unassigned --path-prefix-to-remove $SKYWATER_NDA_PATH --sourcetodests $TMP_DIRECTORY/clean_spice_files.filemapping.json --fileswithoutincludes $TMP_DIRECTORY/clean_spice_files_missing_includes.txt |
| msg "End Spice files cleanup" |
| )& |
| save_pid $! "Spice files cleanup" |
| |
| ( |
| msg "Start PM3-to-CSV conversion" |
| python3 convert_pm3_to_csv.py $OUTPUT_DIRECTORY/skywater-pdk/libraries 2>$TMP_DIRECTORY/convert_pm3_to_csv.err --sourcetodests $TMP_DIRECTORY/convert_pm3_to_csv.filemapping.json |
| msg "End PM3-to-CSV conversion" |
| )& |
| save_pid $! "PM3 to CSV" |
| |
| fi |
| |
| if [ ! "$NO_OA" = "1" ] ; then |
| ( |
| msg "Start OA Repack" |
| python3 oa_repack.py $SKYWATER_NDA_PATH $OUTPUT_DIRECTORY $TMP_DIRECTORY --sourcetodest $TMP_DIRECTORY/oa_repack.filemapping.json --cpus $(nproc) |
| msg "End OA Repack" |
| )& |
| save_pid $! "OA Repack" |
| fi |
| |
| FAILED=0 |
| for proc in "${!pids[@]}" |
| do |
| msg "Waiting for pid ${pids[$proc]} (${proc})" |
| if wait "${pids[$proc]}" |
| then |
| msg "Success running ${pids[$proc]} (${proc})!" |
| else |
| msg "Failed running ${pids[$proc]} (${proc})!" |
| FAILED=1 |
| fi |
| done |
| |
| if [[ $FAILED == 1 ]] |
| then |
| exit $FAILED |
| fi |
| |
| if [ ! "$ONLY_OA" = "1" ] ; then |
| # Generating Category files !!!! SHOULD BE LAST AS IT MAY MOVE SOME DIRECTORIES !!!! |
| msg 'Generating Cat files' |
| python3 cat_generate.py $SKYWATER_NDA_PATH $OUTPUT_DIRECTORY $TMP_DIRECTORY/cat_generator.filemapping.json |
| |
| msg "Latest version generation" |
| python3 add_latest_version.py $OUTPUT_DIRECTORY $TMP_DIRECTORY |
| |
| msg "Fixing cell names" |
| python3 fixup_cell_names.py $OUTPUT_DIRECTORY |
| |
| msg "Fixing pr_rf mod files" |
| python3 rf_mod_fixup.py $OUTPUT_DIRECTORY |
| |
| # Directory cleanup |
| find $OUTPUT_DIRECTORY/skywater-pdk/libraries -type d -empty -delete |
| fi |