Skip to content

Commit 8cdea9c

Browse files
committed
finishing: refactor shell script
1 parent 5959777 commit 8cdea9c

File tree

2 files changed

+77
-42
lines changed

2 files changed

+77
-42
lines changed

ihp13/init.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 77 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,53 @@
66
#
77
# - Thomas Benz <tbenz@iis.ee.ethz.ch>
88

9-
# klayout batch mode to create the sealring and fill
9+
# KLayout batch mode to create the sealring and metal fill
10+
11+
set -e # Exit on error
12+
set -u # Error on undefined vars
13+
14+
15+
################
16+
### Setup
17+
################
1018

1119
export KLAYOUT=${KLAYOUT:-klayout}
1220

13-
root_dir=$(realpath $(dirname "${BASH_SOURCE[0]}")/../..)
21+
root_dir=$(realpath $(dirname "${BASH_SOURCE[0]}")/..)
1422
klayout_dir=${root_dir}/ihp13/pdk/ihp-sg13g2/libs.tech/klayout
1523
export KLAYOUT_PATH=$klayout_dir
1624
export PDK=ihp-sg13g2
1725
export PDK_ROOT=${root_dir}/ihp13/pdk
1826

19-
echo "Root: ${root_dir}"
20-
echo "KLayout: ${klayout_dir}"
21-
27+
echo "[INFO] Root: ${root_dir}"
28+
echo "[INFO] KLayout: ${klayout_dir}"
2229

23-
###############
24-
### Filler ###
25-
###############
26-
FILLER=false
30+
# Apply PDK patches required for filling
31+
if [ ! -f ${root_dir}/ihp13/pdk.patched ]; then
32+
git -C ${PDK_ROOT} apply ../patches/0001-Filling-improvements.patch
33+
touch ${root_dir}/ihp13/pdk.patched
34+
echo "[INFO] Applied all PDK patches"
35+
else
36+
echo "[INFO] PDK patches already applied"
37+
fi
2738

2839

2940
#############
3041
### Help ###
3142
#############
43+
3244
show_help() {
3345
cat <<EOF
3446
Usage: $(basename "$0") [OPTIONS]
3547
3648
Options:
37-
-f, --filler Enable filler mode
49+
--no-stream Skip producing stream from LEF/DEF
50+
--no-seal Skip seal ring
51+
--filling Enable activ and metal filling
3852
-h, --help Show this help message and exit
3953
4054
Examples:
41-
$(basename "$0") --filler
55+
$(basename "$0") --filling
4256
$(basename "$0") -f
4357
EOF
4458
}
@@ -47,9 +61,22 @@ EOF
4761
########################
4862
### Parse Arguments ###
4963
########################
64+
65+
STREAM=true
66+
SEAL=true
67+
FILLER=false
68+
5069
while [[ $# -gt 0 ]]; do
5170
case "$1" in
52-
-f|--filler)
71+
--no-stream)
72+
STREAM=false
73+
shift
74+
;;
75+
--no-seal)
76+
SEAL=false
77+
shift
78+
;;
79+
--filling)
5380
FILLER=true
5481
shift
5582
;;
@@ -70,6 +97,7 @@ done
7097
################
7198
### Project ###
7299
################
100+
73101
top_design=${TOP_DESIGN:-"croc_chip"}
74102
def_file=${DEF_FILE:-"$root_dir/openroad/out/croc.def"}
75103
out_file=${OUT_FILE:-"$root_dir/klayout/out/$top_design.gds.gz"}
@@ -87,13 +115,14 @@ die_um=($(grep DIEAREA ${def_file} | grep -oE '[0-9]+' | tail -n 2 | xargs))
87115
die_width=$(( ${die_um[-2]} / 1000 ))
88116
die_height=$(( ${die_um[-1]} / 1000 ))
89117

90-
echo "Read ${def_file} - die area is ${die_width} um x ${die_height} um"
118+
echo "[INFO] Read ${def_file} - die area is ${die_width} um x ${die_height} um"
91119

92120

93121
################
94122
## Technology ##
95123
################
96-
if [[ -d "$root_dir/technology" ]]; then
124+
125+
if [[ -d "[INFO] $root_dir/technology" ]]; then
97126
echo "Init tech from ETHZ DZ cockpit"
98127
pdk_dir=$(realpath "$root_dir/technology")
99128
pdk_cells_lef_dir="${pdk_dir}/lef"
@@ -103,7 +132,7 @@ if [[ -d "$root_dir/technology" ]]; then
103132
pdk_sram_gds_dir="${pdk_dir}/gds"
104133
pdk_io_gds_dir="${pdk_dir}/gds"
105134
else
106-
echo "Init tech from Github PDK"
135+
echo "[INFO] Init tech from Github PDK"
107136
pdk_dir=${pdk_dir:-$(realpath "$root_dir/ihp13/pdk/ihp-sg13g2")}
108137
pdk_cells_lef_dir="${pdk_dir}/libs.ref/sg13g2_stdcell/lef"
109138
pdk_sram_lef_dir="${pdk_dir}/libs.ref/sg13g2_sram/lef"
@@ -131,6 +160,7 @@ gds="$(find "$pdk_cells_gds_dir" -name 'sg13g2_stdcell.gds' -exec realpath {} \;
131160
################
132161
## Def2Stream ##
133162
################
163+
134164
klayout_cmd="$KLAYOUT -zz \
135165
-rd gds_allow_empty="True" \
136166
-rd design_name=\"$top_design\" \
@@ -141,9 +171,14 @@ klayout_cmd="$KLAYOUT -zz \
141171
-rd out_file=\"$out_file\" \
142172
-rm scripts/def2stream.py"
143173

144-
echo $klayout_cmd
145-
eval $klayout_cmd
146-
174+
if [[ "$STREAM" == true ]]; then
175+
echo "[INFO] Running LEF/DEF to stream"
176+
echo $klayout_cmd
177+
echo ""
178+
eval $klayout_cmd
179+
else
180+
echo "[INFO] Skipping LEF/DEF to stream"
181+
fi
147182

148183
#################
149184
### Seal Gen ###
@@ -154,8 +189,14 @@ sealring_gen_cmd="$KLAYOUT -n sg13g2 -zz \
154189
-rd height=$(( $die_width + 2 * $sealringspace )) \
155190
-rd output=$seal_file"
156191

157-
echo $sealring_gen_cmd
158-
eval $sealring_gen_cmd
192+
if [[ "$SEAL" == true ]]; then
193+
echo "[INFO] Creating seal ring"
194+
echo $sealring_gen_cmd
195+
echo ""
196+
eval $sealring_gen_cmd
197+
else
198+
echo "[INFO] Skipping seal ring creation"
199+
fi
159200

160201

161202
###################
@@ -167,12 +208,17 @@ sealring_merge_cmd="$KLAYOUT -zz \
167208
-rd seal_gds=$seal_file \
168209
-rd dx_um=$sealringspace \
169210
-rd dy_um=$sealringspace \
170-
-rd top_name=${chipname}_w_sealring \
211+
-rd top_name=${top_design}_w_sealring \
171212
-rd out_gds=$sealed_file"
172213

173-
echo $sealring_merge_cmd
174-
eval $sealring_merge_cmd
175-
214+
if [[ "$SEAL" == true ]]; then
215+
echo "[INFO] Merging seal ring"
216+
echo $sealring_merge_cmd
217+
echo ""
218+
eval $sealring_merge_cmd
219+
else
220+
echo "[INFO] Skipping seal ring merging"
221+
fi
176222

177223
#######################
178224
### Density Filling ###
@@ -183,7 +229,12 @@ fill_cmd="$KLAYOUT -n sg13g2 -zz \
183229
-rd no_topmetal_2 \
184230
$sealed_file"
185231

186-
echo $fill_cmd
232+
187233
if [[ "$FILLER" == true ]]; then
188-
eval $fill_cmd
234+
echo "[INFO] Activ and metal filling"
235+
echo $fill_cmd
236+
echo ""
237+
eval $fill_cmd
238+
else
239+
echo "[INFO] Skipping activ and metal filling"
189240
fi

0 commit comments

Comments
 (0)