-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgds2rect.sh
More file actions
executable file
·87 lines (72 loc) · 1.9 KB
/
Copy pathgds2rect.sh
File metadata and controls
executable file
·87 lines (72 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
set -euo pipefail
# gds2rect.sh -T <tech> -i <input.gds> [-o <output.rect>]
# -T <tech> : REQUIRED.
# -i <input.gds> : REQUIRED.
# -o <output.rect> : Optional. If omitted, derived by replacing .gds with .rect.
usage() {
cat <<USAGE
Usage: $(basename "$0") -T <tech> -i <input.gds> [-o <output.rect>]
Example:
$(basename "$0") -T my_tech -i layout.gds -o layout.rect
USAGE
exit 2
}
TECH=""
IN_GDS=""
OUT_RECT=""
# Parse args (getopts style)
while getopts "T:i:o:h" opt; do
case "$opt" in
T) TECH="$OPTARG" ;;
i) IN_GDS="$OPTARG" ;;
o) OUT_RECT="$OPTARG" ;;
h|*) usage ;;
esac
done
if [ -z "$TECH" ]; then
echo "Error: -T <tech> is required."
usage
fi
if [ -z "$IN_GDS" ]; then
echo "Error: -i <input.gds> is required."
usage
fi
if [ ! -f "$IN_GDS" ]; then
echo "Error: input GDS file '$IN_GDS' not found."
exit 3
fi
# If OUT_RECT not provided, replace extension of IN_GDS with .rect
if [ -z "$OUT_RECT" ]; then
# Strip trailing path and extension safely:
# If IN_GDS has an extension, remove it; otherwise just append .rect
basename_noext="${IN_GDS%.*}"
OUT_RECT="${basename_noext}.rect"
fi
# Ensure magic exists
if ! command -v magic >/dev/null 2>&1; then
echo "Error: 'magic' executable not found in PATH. Install Magic or adjust PATH."
exit 4
fi
# Ensure techgen exists
if ! command -v techgen >/dev/null 2>&1; then
echo "Error: 'techgen' executable not found in PATH. Install ACT or adjust PATH."
exit 4
fi
echo "Using tech: $TECH"
echo "Input GDS: $IN_GDS"
echo "Output (rect): $OUT_RECT"
filename="${IN_GDS##*/}"
# Run Magic and issue commands.
techgen -T$TECH -dnull > ${TECH}_tmp.tech
magic -T${TECH}_tmp -noconsole <<MAGIC_CMDS
gds read "$IN_GDS"
load ${filename%.*}
flatten ${filename%.*}
save "${OUT_RECT%.*}.mag"
quit -noprompt
MAGIC_CMDS
echo "mag -> rect"
python mag2rect.py ${OUT_RECT%.*}.mag
rm ${TECH}_tmp.tech
rm ${OUT_RECT%.*}.mag