blob: 57899afe43bbc3cff9f347334c754184fdcd5f5f (
plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
#!/bin/tcsh -f
#----------------------------------------------------------
# GDSII output generating script using magic
#----------------------------------------------------------
# Tim Edwards, 4/23/18, for Open Circuit Design
#----------------------------------------------------------
if ($#argv < 2) then
echo Usage: gdsii.sh [options] <project_path> <source_name>
exit 1
endif
# Split out options from the main arguments
set argline=(`getopt "" $argv[1-]`)
set options=`echo "$argline" | awk 'BEGIN {FS = "-- "} END {print $1}'`
set cmdargs=`echo "$argline" | awk 'BEGIN {FS = "-- "} END {print $2}'`
set argc=`echo $cmdargs | wc -w`
if ($argc >= 2) then
set argv1=`echo $cmdargs | cut -d' ' -f1`
set argv2=`echo $cmdargs | cut -d' ' -f2`
else
echo Usage: gdsii.sh [options] <project_path> <source_name>
echo where
echo <project_path> is the name of the project directory containing
echo a file called qflow_vars.sh.
echo <source_name> is the root name of the verilog file
exit 1
endif
set projectpath=$argv1
set sourcename=$argv2
set rootname=${sourcename:h}
# This script is called with the first argument <project_path>, which should
# have file "qflow_vars.sh". Get all of our standard variable definitions
# from the qflow_vars.sh file.
if (! -f ${projectpath}/qflow_vars.sh ) then
echo "Error: Cannot find file qflow_vars.sh in path ${projectpath}"
exit 1
endif
source ${projectpath}/qflow_vars.sh
source ${techdir}/${techname}.sh
cd ${projectpath}
if (-f project_vars.sh) then
source project_vars.sh
endif
if (! ${?gdsii_options} ) then
set gdsii_options = ${options}
endif
set gengdsfile="${layoutdir}/generate_gds_${rootname}.tcl"
if (!($?logdir)) then
set logdir=${projectpath}/log
endif
mkdir -p ${logdir}
set lastlog=${logdir}/drc.log
set synthlog=${logdir}/gdsii.log
rm -f ${synthlog} >& /dev/null
touch ${synthlog}
set date=`date`
echo "Qflow gdsii logfile created on $date" > ${synthlog}
# Check if last line of drc log file says "error condition"
if ( ! -f ${lastlog} ) then
set lastlog=${logdir}/lvs.log
endif
if ( ! -f ${lastlog} ) then
echo "Warning: No DRC or LVS logfiles found."
else
set errcond = `tail -1 ${lastlog} | grep "error condition" | wc -l`
if ( ${errcond} == 1 ) then
echo "Synthesis flow stopped on error condition. GDSII generation"
echo "will not proceed until error condition is cleared."
exit 1
endif
endif
# Does variable "gdsfile" exist?
if (! ${?gdsfile} || ( ${?gdsfile} && ( ${gdsfile} == "" ) ) ) then
echo "GDS generation failure: No gdsfile variable set in technology setup script." \
|& tee -a ${synthlog}
echo "Premature exit." |& tee -a ${synthlog}
echo "Synthesis flow stopped due to error condition." >> ${synthlog}
exit 1
endif
# Prepend techdir to each gdsfile unless gdsfile begins with "/"
set gdspath=""
foreach f (${gdsfile})
set abspath=`echo ${f} | cut -c1`
if ( "${abspath}" == "/" ) then
set p=${gdsfile}
else
set p=${techdir}/${gdsfile}
endif
set gdspath="${gdspath} $p"
end
#----------------------------------------------------------
# Done with initialization
#----------------------------------------------------------
cd ${layoutdir}
#------------------------------------------------------------------
# Determine the version number and availability of scripting
#------------------------------------------------------------------
set version=`${bindir}/magic --version`
set major=`echo $version | cut -d. -f1`
set minor=`echo $version | cut -d. -f2`
set subv=`echo $version | cut -d. -f3`
#------------------------------------------------------------------
# Generate script for input to magic.
#------------------------------------------------------------------
cat > ${gengdsfile} << EOF
drc off
box 0 0 0 0
gds readonly true
gds rescale false
EOF
# Usually "gdsfile" is set to one GDS file for the standard cell set
# but it can be a space-separated list of GDS files to read. This
# is set by reading the .sh file.
foreach gfile ( ${gdspath} )
cat >> ${gengdsfile} << EOF
gds read $gfile
EOF
end
cat >> ${gengdsfile} << EOF
load $rootname
select top cell
expand
gds write $rootname
quit -noprompt
EOF
#------------------------------------------------------------------
# Run magic in batch mode.
#------------------------------------------------------------------
echo "Running magic $version"
echo "magic -dnull -noconsole ${gdsii_options} ${gengdsfile}" |& tee -a ${synthlog}
${bindir}/magic -dnull -noconsole ${gdsii_options} ${gengdsfile} |& tee -a ${synthlog}
#---------------------------------------------------------------------
# Spot check: Did magic produce file ${rootname}.gds?
#---------------------------------------------------------------------
if ( !( -f ${rootname}.gds || ( -f ${rootname}.gds && -M ${rootname}.def \
< -M ${rootname}.gds ))) then
echo "magic failure: No file ${rootname}.gds." |& tee -a ${synthlog}
echo "Premature exit." |& tee -a ${synthlog}
echo "Synthesis flow stopped due to error condition." >> ${synthlog}
exit 1
endif
#------------------------------------------------------------
# Done!
#------------------------------------------------------------
set endtime = `date`
echo "GDS generating script ended on $endtime" >> $synthlog
exit 0
|