File: qflow.sh.in

package info (click to toggle)
qflow 1.3.17%2Bdfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,852 kB
  • sloc: ansic: 8,342; csh: 3,873; sh: 2,869; makefile: 426; tcl: 6
file content (828 lines) | stat: -rw-r--r-- 24,649 bytes parent folder | download | duplicates (2)
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
#!/usr/bin/tcsh -f
#
#------------------------------------------------------------------
# qflow.sh --- main program shell script
#------------------------------------------------------------------

# Environment variable overrides the tech type in all cases except
# when the technology is specified on the command line by -T.  If
# the environment variable is not set, the technology defaults to
# the technology that is issued with the qflow distribution.

set tech=`printenv QFLOW_TECH`
set has_tech=0
if ( $tech == "" ) then
   # But. . . check if there is already a "qflow_vars.sh".  If so,
   # parse it for "techname", and use that preferentially over the
   # default technology.
   if ( -f qflow_vars.sh ) then
      set tech=`cat qflow_vars.sh | grep techname | cut -d= -f2`
      set has_tech=1
   else
      set tech=osu035
      set has_tech=-1
   endif
endif

# Environment variable overrides the project root path in all cases
# except when the project root path is specified on the command line
# by -p.  If the environment variable does not exist, the project
# root directory is assumed to be the current working directory.

set project=`printenv QFLOW_PROJECT_ROOT`
if ( $project == "" ) then
   set project=`pwd`
endif

set modulename=""
set vsource=""

# Don't do anything unless told to on the command line
set actions=0
set dogui=0
set dohelp=0
set doversion=0
set dosynth=0
set doplace=0
set dosta=0
set doroute=0
set dobackanno=0
set domigrate=0
set dolvs=0
set dodrc=0
set dogdsii=0
set doclean=0
set dodisplay=0

while ($#argv > 0)
   switch($argv[1]:q)
      case -t:
      case -T:
      case --tech:
	 shift
	 set tech=$argv[1]
	 set has_tech=0
	 shift
	 breaksw
      case -p:
      case -P:
      case --project:
	 shift
	 set project=$argv[1]
	 shift
	 breaksw
      case -h:
      case -H:
      case --help:
	 set dohelp=1
	 shift
	 breaksw
      case -v:
      case -V:
      case --version:
	 set doversion=1
	 shift
	 breaksw
      case gui:
         set dogui=1
         shift
         breaksw
      case synth:
      case synthesize:
	 set dosynth=1
	 set actions=1
	 shift
	 breaksw
      case place:
      case placement:
	 set doplace=1
	 set actions=1
	 shift
	 breaksw
      case sta:
      case vesta:
      case opentimer:
      case opensta:
	 set dosta=1
	 set actions=1
	 shift
	 breaksw
      case route:
      case routing:
	 set doroute=1
	 set actions=1
	 shift
	 breaksw
      case backanno:
      case backannotate:
	 set dobackanno=1
	 set actions=1
	 shift
	 breaksw
      case migrate:
      case migration:
	 set domigrate=1
	 set actions=1
	 shift
	 breaksw
      case lvs:
	 set dolvs=1
	 set actions=1
	 shift
	 breaksw
      case drc:
	 set dodrc=1
	 set actions=1
	 shift
	 breaksw
      case gdsii:
      case gds:
	 set dogdsii=1
	 set actions=1
	 shift
	 breaksw
      case build:
	 set dosynth=1
	 set doplace=1
	 set doroute=1
	 set dobackanno=1
	 set actions=1
	 shift
	 breaksw
      case nocheck:
      case nochecks:
	 set dosynth=1
	 set doplace=1
	 set dosta=1
	 set doroute=1
	 set dobackanno=1
	 set doclean=1
	 set dodisplay=1
	 set actions=1
	 shift
	 breaksw
      case all:
	 set dosynth=1
	 set doplace=1
	 set dosta=1
	 set doroute=1
	 set dobackanno=1
	 set domigrate=1
	 set dolvs=1
	 set dodrc=1
	 set dogdsii=1
	 set doclean=1
	 set dodisplay=1
	 set actions=1
	 shift
	 breaksw
      case clean:
      case cleanup:
	 set doclean=1
	 set actions=1
	 shift
	 breaksw
      case display:
	 set dodisplay=1
	 set actions=1
	 shift
	 breaksw
      case buffer:
	 echo "Note:  option buffer is deprecated."
	 shift
	 breaksw
      default:
	 if (`echo $argv[1] | cut -c1` == "-") then
	    echo "Unknown option $argv[1]"
	    set dohelp=1
	    break
	 else if ($modulename == "") then
	    set modulename=$argv[1]
	    shift
	 else
	    echo "Argument $argv[1] after module name $modulename"
	    set dohelp=1
	    break
	 endif
	 breaksw
   endsw
end

if ($dogui == 1) then
    # Run interactive GUI interface instead of this script.
    if ( -f QFLOW_SCRIPT_DIR/qflow_manager.py ) then
        if ( $has_tech == 0 ) then
	    exec QFLOW_SCRIPT_DIR/qflow_manager.py $tech $modulename
	else
	    exec QFLOW_SCRIPT_DIR/qflow_manager.py None $modulename
        endif
	# exec should not return. . .
	exit 0
    else
	echo "GUI manager not installed.  Requires python3"
	set dohelp = 1
    endif
endif

if ($modulename == "") then
   set dohelp=1
endif

if ($doversion == 1 || $dohelp == 1) then
   echo "Qflow version QFLOW_VERSION revision QFLOW_REVISION"
   echo ""

   if ($doversion == 1) then
      exit 0
   endif
endif

if ($dohelp == 1 || $#argv != 0) then
   echo "Usage: qflow [processes] [options] <module_name>"
   echo "Processes:  synthesize		Synthesize verilog source"
   echo "            place		Run initial placement"
   echo "            sta			Static timing analysis"
   echo "            route		Run placement and route"
   echo "            backanno		Post-route timing analysis"
   echo "            migrate		Generate database and netlists for DRC and LVS"
   echo "            drc			Run DRC check"
   echo "            lvs			Run LVS comparison"
   echo "            gdsii		Generate GDSII output"
   echo "            clean		Remove temporary working files"
   echo ""
   echo "            display		Display routed result"
   echo ""
   echo "            build		Run scripts synthesize to backanno"
   echo "            nochecks		Run scripts synthesize to backanno and display"
   echo "            all			Run scripts synthesize to gdsii and display"
   echo ""
   echo "            gui			Run the qflow interactive GUI"
   echo ""
   echo "Options:    -T, --tech <name>		Use technology <name>"
   echo "            -p, --project <name>	Project root directory is <name>"
   if ($dohelp == 1) then
      exit 0
   else
      exit 1
   endif
endif

echo ""
echo "--------------------------------"
echo "Qflow project setup"
echo "--------------------------------"
echo ""

if ($has_tech == 1) then
   echo "Technology set to $tech from existing qflow_vars.sh file"
else if ($has_tech == -1) then
   echo "No technology specified or found;  using default technology $tech"
else
   echo "Technology set to $tech"
endif

source QFLOW_SCRIPT_DIR/checkdirs.sh ${tech} ${project}
if ($status == 1) then
   echo "Failure to verify working directories."
   echo "Check QFLOW_PROJECT_ROOT environment variable."
   exit 1
endif

# Use find, not ls, to avoid error output when no match is found.
set nvsrc = `find ${sourcedir} -name \*.v -print | grep -v match | wc -l`
set nsvsrc = `find ${sourcedir} -name \*.sv -print | wc -l`

# Verilog file root name is the same as the module name, at least until
# discovered otherwise.  If the module name is not given on the command
# line, then there must be one source file and the filename root and
# module name must match.

if ($modulename == "") then
   if ($nvsrc == 1) then
      set vsource=`ls ${sourcedir}/*.v`
      set modulename=${vsource:r}
   else if ($nsvsrc == 1) then
      set vsource=`ls ${sourcedir}/*.sv`
      set modulename=${vsource:r}
   else if ($nvsrc == 0 && $nsvsrc == 0) then
      echo "Error:  No verilog source files found in directory ${sourcedir}."
      exit 1
   else
      echo "Error:  No verilog source file or module name has been specified"
      echo "and directory ${sourcedir} contains multiple verilog files."
      echo "Please specify the source file or module name on the command line."
      exit 1
   endif
endif

if ($vsource == "") then
   # First look for a file list (extension ".fl") that specifies exactly
   # which modules to use;  this overrides the automatic search for
   # modules.
   if ( -f "${sourcedir}/${modulename}.fl" ) then
      set source_file_list = "${sourcedir}/${modulename}.fl"
   endif

   # If there is no file list, then search for modules with this name.
   if ( ! ($?source_file_list) ) then
      # Check all .v and .sv files for one with the specified module.
      foreach file ( `ls ${sourcedir}/*.v ${sourcedir}/*.sv` )
         set mline = `cat $file | grep module | grep ${modulename} | wc -l`
         if ( $mline > 0 ) then
	    set vsource = ${file}
	    break
         endif
      end

      if ( ${vsource} == "" ) then
         echo "Error:  No verilog file in ${sourcedir} contains module ${modulename}."
         exit 1
      endif
   endif
endif

#------------------------------------------------------------------
# Source the technology initialization script
#------------------------------------------------------------------

if ( -f ${techdir}/${tech}.sh ) then
   source $techdir/${tech}.sh
else
   echo "Error:  Cannot find tech init script ${techdir}/${tech}.sh to source"
   exit 1
endif

#------------------------------------------------------------------
# Prepare the script file to run in the project directory.  We
# specify all steps of the process and comment out those that
# have not been selected.  Finally, source the script.
#------------------------------------------------------------------

set varfile=${projectpath}/qflow_vars.sh
set execfile=${projectpath}/qflow_exec.sh
set userfile=${projectpath}/project_vars.sh

#------------------------------------------------------------------
# Check if a variables file exists.  If so, note that we are
# regenerating the flow, source the file, check if the technology
# is being changed, and report if so.
#------------------------------------------------------------------

set newtech = 0
if ( -f $varfile ) then
   set techorig=`cat $varfile | grep techname= | cut -d= -f2`
   if ( "${tech}" != "${techorig}" ) then
      echo "Warning:  Project technology changed from ${techorig} to ${tech}"
      set newtech = 1
   else
      echo "Regenerating files for existing project ${modulename}"
   endif
endif

echo "#\!/usr/bin/tcsh -f" > ${varfile}
echo "#-------------------------------------------" >> ${varfile}
echo "# qflow variables for project ${project}" >> ${varfile}
echo "#-------------------------------------------" >> ${varfile}
echo "" >> ${varfile}

echo "set projectpath=${projectpath}" >> ${varfile}
echo "set techdir=${techdir}" >> ${varfile}
echo "set sourcedir=${sourcedir}" >> ${varfile}
echo "set synthdir=${synthdir}" >> ${varfile}
echo "set layoutdir=${layoutdir}" >> ${varfile}
echo "set techname=${techname}" >> ${varfile}
echo "set scriptdir=${scriptdir}" >> ${varfile}
echo "set bindir=${bindir}" >> ${varfile}
echo "set logdir=${projectpath}/log" >> ${varfile}
echo "#-------------------------------------------" >> ${varfile}
echo "" >> ${varfile}

echo "#\!/usr/bin/tcsh -f" > ${execfile}
echo "#-------------------------------------------" >> ${execfile}
echo "# qflow exec script for project ${project}" >> ${execfile}
echo "#-------------------------------------------" >> ${execfile}
echo "" >> ${execfile}

#-----------------------------------------------------
# The file "project_vars.sh" will ONLY be written if
# one does not already exist, and then it will be an
# empty file with a few pointers to values that can
# be set by the user.
#-----------------------------------------------------

if ( ! -f ${userfile} ) then
   echo "#\!/usr/bin/tcsh -f" > ${userfile}
   echo "#------------------------------------------------------------" >> ${userfile}
   echo "# project variables for project ${project}" >> ${userfile}
   echo "#------------------------------------------------------------" >> ${userfile}
   echo "" >> ${userfile}
   echo "# Synthesis command options:" >> ${userfile}
   echo "# -------------------------------------------" >> ${userfile}

   #------------------------------------------------------------------
   # Check for any option defaults set by the .sh file for each entry
   # in the project_vars.sh file.  If they are not defined, then set
   # them to an empty string or a global default, if there is one.
   # Note that this does not change the behavior that options set
   # in the tech .sh file become the defaults and are overridden by
   # the same variables set in the project variables file.  The
   # purpose is to show the user what the default is, so that they
   # are aware what they may be changing.
   #------------------------------------------------------------------

   if ( ${?hard_macros} ) then
      echo \# set hard_macros = \"${hard_macros}\" >> ${userfile}
   else
      echo \# set hard_macros = >> ${userfile}
   endif

   if ( ${?yosys_options} ) then
      echo \# set yosys_options = \"${yosys_options}\" >> ${userfile}
   else
      echo \# set yosys_options = >> ${userfile}
   endif

   if ( ${?yosys_script} ) then
      echo \# set yosys_script = \"${yosys_script}\" >> ${userfile}
   else
      echo \# set yosys_script = >> ${userfile}
   endif

   if ( ${?yosys_debug} ) then
      echo \# set yosys_debug = \"${yosys_debug}\" >> ${userfile}
   else
      echo \# set yosys_debug = >> ${userfile}
   endif

   if ( ${?abc_script} ) then
      echo \# set abc_script = \"${abc_script}\" >> ${userfile}
   else
      echo \# set abc_script = >> ${userfile}
   endif

   if ( ${?nobuffers} ) then
      echo \# set nobuffers = \"${nobuffers}\" >> ${userfile}
   else
      echo \# set nobuffers = >> ${userfile}
   endif

   if ( ${?inbuffers} ) then
      echo \# set inbuffers = \"${inbuffers}\" >> ${userfile}
   else
      echo \# set inbuffers = >> ${userfile}
   endif

   if ( ${?postproc_options} ) then
      echo \# set postproc_options = \"${postproc_options}\" >> ${userfile}
   else
      echo \# set postproc_options = >> ${userfile}
   endif

   if ( ${?xspice_options} ) then
      echo \# set xspice_options = \"${xspice_options}\" >> ${userfile}
   else
      echo \# set xspice_options = >> ${userfile}
   endif

   if ( ${?fill_ratios} ) then
      echo \# set fill_ratios = \"${fill_ratios}\" >> ${userfile}
   else
      echo \# set fill_ratios = >> ${userfile}
   endif

   if ( ${?nofanout} ) then
      echo \# set nofanout = \"${nofanout}\" >> ${userfile}
   else
      echo \# set nofanout = >> ${userfile}
   endif

   if ( ${?fanout_options} ) then
      echo \# set fanout_options = \"${fanout_options}\" >> ${userfile}
   else
      echo \# set fanout_options = >> ${userfile}
   endif

   if ( ${?source_file_list} ) then
      echo \# set source_file_list = \"${source_file_list}\" >> ${userfile}
   else
      echo \# set source_file_list = >> ${userfile}
   endif

   if ( ${?is_system_verilog} ) then
      echo \# set is_system_verilog = \"${is_system_verilog}\" >> ${userfile}
   else
      echo \# set is_system_verilog = >> ${userfile}
   endif

   echo "" >> ${userfile}
   echo "# Placement command options:" >> ${userfile}
   echo "# -------------------------------------------" >> ${userfile}

   if ( ${?initial_density} ) then
      echo \# set initial_density = \"${initial_density}\" >> ${userfile}
   else
      echo \# set initial_density = >> ${userfile}
   endif

   if ( ${?graywolf_options} ) then
      echo \# set graywolf = \"${graywolf_options}\" >> ${userfile}
   else
      echo \# set graywolf_options = >> ${userfile}
   endif

   if ( ${?addspacers_options} ) then
      echo \# set addspacers_options = \"${addspacers_options}\" >> ${userfile}
   else
      echo \# set addspacers_options = >> ${userfile}
   endif

   echo "" >> ${userfile}
   echo "# Router command options:" >> ${userfile}
   echo "# -------------------------------------------" >> ${userfile}

   if ( ${?route_show} ) then
      echo \# set route_show = \"${route_show}\" >> ${userfile}
   else
      echo \# set route_show = >> ${userfile}
   endif

   if ( ${?route_layers} ) then
      echo \# set route_layers = \"${route_layers}\" >> ${userfile}
   else
      echo \# set route_layers = >> ${userfile}
   endif

   if ( ${?via_use} ) then
      echo \# set via_use = \"${via_use}\" >> ${userfile}
   else
      echo \# set via_use = >> ${userfile}
   endif

   if ( ${?via_stacks} ) then
      echo \# set via_stacks = \"${via_stacks}\" >> ${userfile}
   else
      echo \# set via_stacks = >> ${userfile}
   endif

   if ( ${?qrouter_options} ) then
      echo \# set qrouter_options = \"${qrouter_options}\" >> ${userfile}
   else
      echo \# set qrouter_options = >> ${userfile}
   endif

   echo "" >> ${userfile}
   echo "# STA command options:" >> ${userfile}
   echo "# -------------------------------------------" >> ${userfile}

   echo ""
   echo "" >> ${userfile}
   echo \# Minimum period of the clock use \"--period value\" \(value in ps\) \
	>> ${userfile}

   if ( HAVE_OPENSTA ) then
      if ( ${?opensta_options} ) then
         echo \# set opensta_options = \"${opensta_options}\" >> ${userfile}
      else
         echo \# set opensta_options = >> ${userfile}
      endif
      if ( ${?run_opensta} ) then
	 echo \# set run_opensta = \"${run_opensta}\" >> ${userfile}
      else
	 echo \# set run_opensta = 1 >> ${userfile}
      endif
   endif
   if ( HAVE_OPENTIMER ) then
      if ( ${?opentimer_options} ) then
         echo \# set opentimer_options = \"${opentimer_options}\" >> ${userfile}
      else
         echo \# set opentimer_options = >> ${userfile}
      endif
      if ( ${?run_opentimer} ) then
	 echo \# set run_opentimer = \"${run_opentimer}\" >> ${userfile}
      else
         echo \# set run_opentimer = 1 >> ${userfile}
      endif
   endif
   if ( ${?vesta_options} ) then
      echo \# set vesta_options = \"${vesta_options}\" >> ${userfile}
   else
      echo \# set vesta_options = >> ${userfile}
   endif
   if ( ${?run_vesta} ) then
      echo \# set run_vesta = \"${run_vesta}\" >> ${userfile}
   else
      echo \# set run_vesta = 0 >> ${userfile}
   endif

   echo "" >> ${userfile}
   echo "# Other options:" >> ${userfile}
   echo "# -------------------------------------------" >> ${userfile}

   if ( ${?migrate_options} ) then
      echo \# set migrate_options = \"${migrate_options}\" >> ${userfile}
   else
      echo \# set migrate_options = >> ${userfile}
   endif
   if ( ${?lef_options} ) then
      echo \# set lef_options = \"${lef_options}\" >> ${userfile}
   else
      echo \# set lef_options = >> ${userfile}
   endif

   if ( ${?drc_gdsview} ) then
      echo \# set drc_gdsview = \"${drc_gdsview}\" >> ${userfile}
   else
      echo \# set drc_gdsview = >> ${userfile}
   endif

   if ( ${?drc_options} ) then
      echo \# set drc_options = \"${drc_options}\" >> ${userfile}
   else
      echo \# set drc_options = >> ${userfile}
   endif

   if ( ${?gds_options} ) then
      echo \# set gds_options = \"${gds_options}\" >> ${userfile}
   else
      echo \# set gds_options = >> ${userfile}
   endif

   echo "" >> ${userfile}
   echo "#------------------------------------------------------------" >> ${userfile}
   echo "" >> ${userfile}
else
   # project_vars.sh may contain settings that affect how qflow.sh runs, so
   # source it here.
   source ${userfile}
endif

if ($dosynth == 0) then
   echo -n "# " >> ${execfile}
endif
if ( ${vsource} == "" ) then
   echo "${scriptdir}/synthesize.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}
else
   echo "${scriptdir}/synthesize.sh ${projectpath} ${modulename} ${vsource} || exit 1" >> ${execfile}
endif

if ($doplace == 0) then
   echo -n "# " >> ${execfile}
endif
# Use -d because the user may decide not to run fanout buffering,
# and the files generated by place2def.tcl are required for routing.
echo "${scriptdir}/placement.sh -d ${projectpath} ${modulename} || exit 1" >> ${execfile}

set first=""
if (HAVE_OPENSTA) then
    if ($dosta == 0) then
	echo -n "# " >> ${execfile}
    else if ( ! (${?run_opensta} ) ) then
	echo -n "# " >> ${execfile}
    endif
    echo "${scriptdir}/opensta.sh ${first} ${projectpath} ${modulename} || exit 1" >> ${execfile}
    set first="-a"
endif
if (HAVE_OPENTIMER) then
    if ($dosta == 0) then
	echo -n "# " >> ${execfile}
    else if ( ! (${?run_opentimer} ) ) then
	echo -n "# " >> ${execfile}
    endif
    echo "${scriptdir}/opentimer.sh ${first} ${projectpath} ${modulename} || exit 1" >> ${execfile}
    set first="-a"
endif
if ($dosta == 0) then
    echo -n "# " >> ${execfile}
else
    if ( ${?run_opensta} || ${?run_opentimer} ) then
	if ( ! (${?run_vesta} ) ) then
	    echo -n "# " >> ${execfile}
	endif
    endif
endif
echo "${scriptdir}/vesta.sh ${first} ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($doroute == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/router.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

set first=""
if (HAVE_OPENSTA) then
    if ($dobackanno == 0) then
	echo -n "# " >> ${execfile}
    else if ( ! (${?run_opensta} ) ) then
	echo -n "# " >> ${execfile}
    endif
    echo "${scriptdir}/opensta.sh ${first} -d ${projectpath} ${modulename} || exit 1" >> ${execfile}
    set first="-a"
endif
if (HAVE_OPENTIMER) then
    if ($dobackanno == 0) then
	echo -n "# " >> ${execfile}
    else if ( ! (${?run_opentimer} ) ) then
	echo -n "# " >> ${execfile}
    endif
    echo "${scriptdir}/opentimer.sh ${first} -d ${projectpath} ${modulename} || exit 1" >> ${execfile}
    set first="-a"
endif
if ($dobackanno == 0) then
    echo -n "# " >> ${execfile}
else
    if ( ${?run_opensta} || ${?run_opentimer} ) then
	if ( ! (${?run_vesta} ) ) then
	    echo -n "# " >> ${execfile}
	endif
    endif
endif
echo "${scriptdir}/vesta.sh ${first} -d ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($domigrate == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/migrate.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($dodrc == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/drc.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($dolvs == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/lvs.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($dogdsii == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/gdsii.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($doclean == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/cleanup.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ($dodisplay == 0) then
   echo -n "# " >> ${execfile}
endif
echo "${scriptdir}/display.sh ${projectpath} ${modulename} || exit 1" >> ${execfile}

if ( $actions == 0 ) then
   echo "No actions specified on command line;"
   echo "creating qflow script file ${execfile} only."
   echo "Uncomment lines in this file and source the file to run the flow."
endif

chmod u+x ${execfile}

# Note: Support legacy behavior;  ${magicrc} may be a full path or may be
# relative to ${techdir}

if ( -f ${techdir}/${magicrc} ) then
    set magicrc=${techdir}/${magicrc}
else if (!( -f ${magicrc} )) then
    echo "Error:  Technology file not in ${techdir}/${magicrc} or ${magicrc}!"
endif

# Drop the magic startup file into the layout directory if it does not exist
# If it exists but the technology directory has a newer file, or if we are
# changing technologies, then copy the old file to a backup and create a new
# one.

if (-d ${layoutdir}) then
   if (!(-f ${layoutdir}/.magicrc)) then
      cp ${magicrc} ${layoutdir}/.magicrc
   else if ( $newtech == 1 ) then
      echo "Technology changed:  Old .magicrc file moved to .magicrc.orig"
      cp ${layoutdir}/.magicrc ${layoutdir}/.magicrc.orig
      cp ${magicrc} ${layoutdir}/.magicrc
   else if ( -M ${magicrc} > -M ${layoutdir}/.magicrc ) then
      echo -n "Technology .magicrc file has been updated.  "
      echo "Old .magicrc file moved to .magicrc.orig"
      cp ${layoutdir}/.magicrc ${layoutdir}/.magicrc.orig
      cp ${magicrc} ${layoutdir}/.magicrc
   endif
endif

# Drop the GrayWolf parameter file into the layout directory if it does not
# exist.  Like the above, check if the techdir has a newer version, or if we
# are changing technologies.

if (-d ${layoutdir}) then
   if (!(-f ${layoutdir}/${modulename}.par)) then
      cp ${techdir}/${techname}.par ${layoutdir}/${modulename}.par
   else if ( $newtech == 1 ) then
      echo "Technology changed:  Old .par file moved to .par.orig"
      cp ${layoutdir}/${modulename}.par ${layoutdir}/${modulename}.par.orig
      cp ${techdir}/${techname}.par ${layoutdir}/${modulename}.par
   else if ( -M ${techdir}/${techname}.par > -M ${layoutdir}/${modulename}.par ) then
      echo "Technology .par file has been updated.  Old .par file moved to .par.orig"
      cp ${layoutdir}/${modulename}.par ${layoutdir}/${modulename}.par.orig
      cp ${techdir}/${techname}.par ${layoutdir}/${modulename}.par
   endif
endif

# Execute the script file to run any command that has not been commented out
exec ${execfile}

exit 0