1
+ #! /bin/bash
2
+ set -e
3
+ main_path=$PWD
4
+ start=` date +%s`
5
+
6
+
7
+ design=" manchesterencoderdecoder"
8
+ ip_name=" " # design_level
9
+ # select tool (verilator, vcs, ghdl, iverilog)
10
+ tool_name=" iverilog"
11
+
12
+ # simulation stages
13
+ post_synth_sim=false
14
+ post_route_sim=false
15
+ bitstream_sim=false
16
+
17
+ # raptor options
18
+ device=" GEMINI_COMPACT_104x68"
19
+
20
+ strategy=" delay" # (area, delay, mixed, none)
21
+
22
+ add_constraint_file=" ./pin_mapping.pin" # Sets SDC + location constraints Constraints: set_pin_loc, set_mode, all SDC Standard commands
23
+
24
+ verific_parser=" " # (on/off)
25
+
26
+ synthesis_type=" " # (Yosys/QL/RS)
27
+
28
+ custom_synth_script=" " # (Uses a custom Yosys templatized script)
29
+
30
+ synth_options=" "
31
+ # synth_options <option list>: RS-Yosys Plugin Options. The following defaults exist:
32
+ # : -effort high
33
+ # : -fsm_encoding binary if optimization == area else onehot
34
+ # : -carry auto
35
+ # : -clke_strategy early
36
+ # -effort <level> : Optimization effort level (high, medium, low)
37
+ # -fsm_encoding <encoding> : FSM encoding:
38
+ # binary : Compact encoding - using minimum of registers to cover the N states
39
+ # onehot : One hot encoding - using N registers for N states
40
+ # -carry <mode> : Carry logic inference mode:
41
+ # all : Infer as much as possible
42
+ # auto : Infer carries based on internal heuristics
43
+ # none : Do not infer carries
44
+ # -no_dsp : Do not use DSP blocks to implement multipliers and associated logic
45
+ # -no_bram : Do not use Block RAM to implement memory components
46
+ # -fast : Perform the fastest synthesis. Don't expect good QoR.
47
+ # -no_simplify : Do not run special simplification algorithms in synthesis.
48
+ # -clke_strategy <strategy>: Clock enable extraction strategy for FFs:
49
+ # early : Perform early extraction
50
+ # late : Perform late extraction
51
+ # -cec : Dump verilog after key phases and use internal equivalence checking (ABC based)
52
+
53
+ pin_loc_assign_method=" " # pin_loc_assign_method <Method>: Method choices:
54
+ # in_define_order(Default), port order pin assignment
55
+ # random , random pin assignment
56
+ # free , no automatic pin assignment
57
+
58
+ pnr_options=" " # VPR options
59
+ pnr_netlist_lang=" " # blif, edif, verilog
60
+ set_channel_width=" " # int
61
+ architecture=" " # <vpr_file.xml> ?<openfpga_file.xml>? : Uses the architecture file and optional openfpga arch file (For bitstream generation)
62
+ set_device_size=" " # XxY Device fabric size selection
63
+ bitstream=$( [ " $bitstream_sim " = " true" ] && echo " enable_simulation" || echo " " )
64
+
65
+ # ###############################################################
66
+
67
+ function end_time(){
68
+ end=` date +%s`
69
+ runtime=$(( end- start))
70
+ echo -e " \nTotal RunTime to run raptor_run.sh: $runtime " >> results.log
71
+ echo " Peak Memory Usage: 117360" >> results.log
72
+ echo " ExecEndTime: $end " >> results.log
73
+ raptor --version>> results.log
74
+ }
75
+
76
+ function parse_cga(){
77
+ cd $main_path
78
+ tail -n100 ./results_dir/raptor.log > ./results_dir/raptor_tail.log
79
+ timeout 15m python3 ../../../parser.py ./results_dir/results.log ./results_dir/raptor_perf.log
80
+ mv CGA_Result.json ./results_dir
81
+ }
82
+
83
+ command -v raptor > /dev/null 2>&1 && raptor_path=$( which raptor) || { echo >&2 echo " First you need to source Raptor" ; end_time
84
+ parse_cga exit ; }
85
+ lib_fix_path=" ${raptor_path: (-11)} "
86
+ library=${raptor_path/ $lib_fix_path // share/ raptor/ sim_models}
87
+
88
+ # removing and creating raptor_testcase_files
89
+ # rm -fR $PWD/results_dir
90
+ [ ! -d $PWD /results_dir ] && mkdir $PWD /results_dir
91
+ [ -d $PWD /results_dir ] && touch $PWD /results_dir/CGA_Result.json
92
+ cd $main_path
93
+ [ -f ../../../scripts/CGA_Result_default.json ] && cp ../../../scripts/CGA_Result_default.json ./results_dir/CGA_Result.json
94
+ [ -d $PWD /results_dir ] && cd $PWD /results_dir
95
+
96
+ echo " ExecStartTime: $start " > results.log
97
+ echo " Domain of the design: Unit Level Test" >> results.log
98
+ # Check if parameters were passed as command line arguments
99
+ reg_id=" 23"
100
+ timeout=" 90"
101
+ synth_stage=" "
102
+ mute_flag=" "
103
+ if [[ $# -eq 6 ]]; then
104
+ reg_id=$1
105
+ timeout=$2
106
+ post_synth_sim=$3
107
+ device=$4
108
+ synth_stage=$5
109
+ mute_flag=$6
110
+ else
111
+ if [[ $1 == " load_toolconf" ]]; then
112
+ # Load parameters from tool.conf file
113
+ source $main_path /../../tool.conf
114
+ elif [[ $1 == " clean" ]]; then
115
+ cd $main_path
116
+ PIDS=$( lsof +D " results_dir" | awk ' NR>1 {print $2}' | uniq)
117
+ for PID in $PIDS ; do
118
+ if kill -0 $PID 2> /dev/null; then
119
+ echo " Attempting to terminate process $PID ..."
120
+ kill $PID
121
+ sleep 1
122
+ if kill -0 $PID 2> /dev/null; then
123
+ echo " Process $PID did not terminate gracefully. Forcing termination."
124
+ kill -9 $PID 2> /dev/null || echo " Could not force terminate process $PID . It may have already exited."
125
+ fi
126
+ else
127
+ echo " Process $PID already terminated."
128
+ fi
129
+ done
130
+ rm -rf cksums.md5 newsum.md5 raptor_tcl.tcl results_dir/
131
+ echo " Files cleaned"
132
+ exit 0
133
+ else
134
+ echo " Using paramters defined in raptor_run.sh"
135
+ fi
136
+ fi
137
+
138
+ if [ -z $1 ]; then
139
+ echo " RegID: $reg_id " >> results.log
140
+ else
141
+ echo " RegID: $1 " >> results.log
142
+ fi
143
+
144
+ if [ -z $2 ]; then
145
+ echo " timeout: $timeout " >> results.log
146
+ else
147
+ timeout=$2
148
+ echo " timeout: $2 " >> results.log
149
+ fi
150
+
151
+ function compile () {
152
+ [ -z " $ip_name " ] && temp=$( cd .. && pwd) || echo " "
153
+ [ -z " $ip_name " ] && echo $temp || echo " "
154
+ # finding the design
155
+ [ -z " $ip_name " ] && echo " Current Design is $design " || echo " "
156
+ [ -z " $ip_name " ] && design_path=` find $temp -type f -iname " $design .v" ` || echo " "
157
+ if [ -z " $design_path " ]
158
+ then
159
+ [ -z " $ip_name " ] && echo " No such design $design " || echo " "
160
+ # exit 1
161
+ else
162
+ [ -z " $ip_name " ] && echo -e " $design Found!" || echo " "
163
+ fi
164
+ command -v raptor > /dev/null 2>&1 || { echo >&2 " Compilation requires Raptor but Raptor not installed." ; end_time
165
+ parse_cga exit 1; }
166
+ # directory path where all the rtl design files are placed
167
+ [ -z " $ip_name " ] && directory_path=$( dirname $design_path ) || echo " "
168
+
169
+ # creating a tcl file to run raptor flow
170
+ cd ..
171
+
172
+ echo " create_design $design " > raptor_tcl.tcl
173
+ echo " target_device 1VG28" >> raptor_tcl.tcl
174
+
175
+ # #vary design to design
176
+ [ -z " $ip_name " ] && echo " " || echo " configure_ip $ip_name " _v1_0" -mod_name=$design -Pdata_width=32 -Paddr_width=16 -Pid_width=32 -Pa_pip_out=0 -Pb_pip_out=0 -Pa_interleave=0 -Pb_interleave=0 -out_file ./$design .v" >> raptor_tcl.tcl
177
+ [ -z " $ip_name " ] && echo " " || echo " ipgenerate" >> raptor_tcl.tcl
178
+
179
+ [ -z " $ip_name " ] && echo " " || echo " add_include_path ./rapidsilicon/ip/$ip_name /v1_0/$design /src/" >> raptor_tcl.tcl
180
+ [ -z " $ip_name " ] && echo " " || echo " add_library_ext .v .sv" >> raptor_tcl.tcl
181
+ [ -z " $ip_name " ] && echo " " || echo " add_library_path rapidsilicon/ip/$ip_name /v1_0/$design /src/" >> raptor_tcl.tcl
182
+ [ -z " $ip_name " ] && echo " " || echo " add_design_file ./rapidsilicon/ip/$ip_name /v1_0/$design /src/$design .v" >> raptor_tcl.tcl
183
+
184
+ [ -z " $ip_name " ] && echo " add_include_path ./rtl" >> raptor_tcl.tcl || echo " "
185
+ [ -z " $ip_name " ] && echo " add_library_path ./rtl" >> raptor_tcl.tcl || echo " "
186
+ [ -z " $ip_name " ] && echo " add_library_ext .v .sv" >> raptor_tcl.tcl || echo " "
187
+ [ -z " $ip_name " ] && echo " add_design_file ./rtl/$design .v" >> raptor_tcl.tcl || echo " "
188
+ # #vary design to design
189
+
190
+ echo " set_top_module $design " >> raptor_tcl.tcl
191
+
192
+ # #vary design to design
193
+ [ -z " $add_constraint_file " ] && echo " " || echo " add_constraint_file $add_constraint_file " >> raptor_tcl.tcl
194
+
195
+ if [ " $post_synth_sim " == true ] || [ " $post_route_sim " == true ] || [ " $bitstream_sim " == true ]; then
196
+ echo " add_simulation_file ./sim/co_sim_tb/co_sim_$design .v ./rtl/$design .v" >> raptor_tcl.tcl
197
+ echo " set_top_testbench co_sim_$design " >> raptor_tcl.tcl
198
+ else
199
+ echo " "
200
+ fi
201
+
202
+ echo " analyze" >> raptor_tcl.tcl
203
+ [ -z " $verific_parser " ] && echo " " || echo " verific_parser $verific_parser " >> raptor_tcl.tcl
204
+ [ -z " $synthesis_type " ] && echo " " || echo " synthesis_type $synthesis_type " >> raptor_tcl.tcl
205
+ [ -z " $custom_synth_script " ] && echo " " || echo " custom_synth_script $custom_synth_script " >> raptor_tcl.tcl
206
+ [ -z " $synth_options " ] && echo " " || echo " synth_options $synth_options " >> raptor_tcl.tcl
207
+ [ -z " $strategy " ] && echo " " || echo " synthesize $strategy " >> raptor_tcl.tcl
208
+ if [ " $post_synth_sim " == true ]; then
209
+ echo " # Open the input file in read mode" >> raptor_tcl.tcl
210
+ echo " set input_file [open \" $design /run_1/synth_1_1/synthesis/$design \_post_synth.v\" r]" >> raptor_tcl.tcl
211
+ echo " # Read the file content" >> raptor_tcl.tcl
212
+ echo " set file_content [read \$ input_file]" >> raptor_tcl.tcl
213
+ echo " # Close the input file after reading" >> raptor_tcl.tcl
214
+ echo " close \$ input_file" >> raptor_tcl.tcl
215
+ echo " set modified_content [string map {\" $design (\" \" ${design} _post_synth(\" } \$ file_content]" >> raptor_tcl.tcl
216
+ echo " # Open the file again, this time in write mode to overwrite the old content" >> raptor_tcl.tcl
217
+ echo " set output_file [open \" $design /run_1/synth_1_1/synthesis/$design \_post_synth.v\" w]" >> raptor_tcl.tcl
218
+ echo " # Write the modified content back to the file" >> raptor_tcl.tcl
219
+ echo " puts \$ output_file \$ modified_content" >> raptor_tcl.tcl
220
+ echo " # Close the file" >> raptor_tcl.tcl
221
+ echo " close \$ output_file" >> raptor_tcl.tcl
222
+ echo " puts \" Modification completed.\" " >> raptor_tcl.tcl
223
+ [ " $tool_name " = " iverilog" ] && echo " simulation_options compilation icarus gate" >> raptor_tcl.tcl || echo " simulation_options compilation verilator gate" >> raptor_tcl.tcl
224
+ [ " $tool_name " = " iverilog" ] && echo " simulate gate icarus" >> raptor_tcl.tcl || echo " simulate gate verilator" >> raptor_tcl.tcl
225
+ else
226
+ echo " "
227
+ fi
228
+ if [ " $synth_stage " == " 1" ]; then
229
+ echo " "
230
+ else
231
+ [ -z " $pin_loc_assign_method " ] && echo " " || echo " pin_loc_assign_method $pin_loc_assign_method " >> raptor_tcl.tcl
232
+ [ -z " $pnr_options " ] && echo " " || echo " pnr_options $pnr_options " >> raptor_tcl.tcl
233
+ [ -z " $pnr_netlist_lang " ] && echo " " || echo " pnr_netlist_lang $pnr_netlist_lang " >> raptor_tcl.tcl
234
+ [ -z " $set_channel_width " ] && echo " " || echo " set_channel_width $set_channel_width " >> raptor_tcl.tcl
235
+ [ -z " $architecture " ] && echo " " || echo " architecture $architecture " >> raptor_tcl.tcl
236
+ [ -z " $set_device_size " ] && echo " " || echo " set_device_size $set_device_size " >> raptor_tcl.tcl
237
+ echo " packing" >> raptor_tcl.tcl
238
+ echo " place" >> raptor_tcl.tcl
239
+ echo " route" >> raptor_tcl.tcl
240
+ if [ " $post_route_sim " == true ]; then
241
+ echo " # Open the input file in read mode" >> raptor_tcl.tcl
242
+ echo " set input_file [open \" $design /run_1/synth_1_1/synthesis/post_pnr_wrapper_$design \_post_synth.v\" r]" >> raptor_tcl.tcl
243
+ echo " # Read the file content" >> raptor_tcl.tcl
244
+ echo " set file_content [read \$ input_file]" >> raptor_tcl.tcl
245
+ echo " # Close the input file after reading" >> raptor_tcl.tcl
246
+ echo " close \$ input_file" >> raptor_tcl.tcl
247
+ echo " set modified_content [string map {\" module $design (\" \" module ${design} _post_route (\" } \$ file_content]" >> raptor_tcl.tcl
248
+ echo " # Open the file again, this time in write mode to overwrite the old content" >> raptor_tcl.tcl
249
+ echo " set output_file [open \" $design /run_1/synth_1_1/synthesis/post_pnr_wrapper_$design \_post_synth.v\" w]" >> raptor_tcl.tcl
250
+ echo " # Write the modified content back to the file" >> raptor_tcl.tcl
251
+ echo " puts \$ output_file \$ modified_content" >> raptor_tcl.tcl
252
+ echo " # Close the file" >> raptor_tcl.tcl
253
+ echo " close \$ output_file" >> raptor_tcl.tcl
254
+ echo " puts \" Modification completed.\" " >> raptor_tcl.tcl
255
+ # echo "exec python3 $main_path/../../../scripts/post_route_script.py $design">>raptor_tcl.tcl
256
+ [ " $tool_name " = " iverilog" ] && echo " simulation_options compilation icarus -DPNR=1 pnr" >> raptor_tcl.tcl || echo " simulation_options compilation verilator -DPNR=1 pnr" >> raptor_tcl.tcl
257
+ [ " $tool_name " = " iverilog" ] && echo " simulate pnr icarus" >> raptor_tcl.tcl || echo " simulate pnr verilator" >> raptor_tcl.tcl
258
+ else
259
+ echo " "
260
+ fi
261
+ echo " setup_lec_sim" >> raptor_tcl.tcl
262
+ echo " simulate gate icarus" >> raptor_tcl.tcl || echo " simulate gate verilator" >> raptor_tcl.tcl
263
+ echo " simulate pnr icarus" >> raptor_tcl.tcl || echo " simulate pnr verilator" >> raptor_tcl.tcl
264
+ echo " power" >> raptor_tcl.tcl
265
+ echo " bitstream $bitstream " >> raptor_tcl.tcl
266
+ if [ " $bitstream_sim " == true ]; then
267
+ echo " clear_simulation_files" >> raptor_tcl.tcl
268
+ echo " add_simulation_file testbench.sv" >> raptor_tcl.tcl
269
+ echo " add_library_path ../../../../openfpga-pd-castor-rs/k6n8_TSMC16nm_7.5T/CommonFiles/task/CustomModules/" >> raptor_tcl.tcl
270
+ echo " simulate " bitstream_bd" " icarus" " >> raptor_tcl.tcl
271
+ else
272
+ echo " "
273
+ fi
274
+ fi
275
+
276
+ cd results_dir
277
+ echo " Device: $device " >> results.log
278
+ echo " Strategy: $strategy " >> results.log
279
+
280
+ timeout+=' m'
281
+ if [ -d ../rtl ]; then
282
+ rm -fr ../rtl/obj_dir ../rtl/* .vcd ../rtl/* .cpp ../rtl/simv.daidir ../rtl/csrc
283
+ [ ! -f ../cksums.md5 ] && find ../rtl -type f -exec md5sum {} + > ../cksums.md5
284
+ find ../rtl -type f -exec md5sum {} + > ../newsum.md5
285
+ else
286
+ echo " "
287
+ fi
288
+ # running raptor flow script
289
+ if cmp --silent -- " ../cksums.md5" " ../newsum.md5" && [ -d $design ]; then
290
+ echo " Raptor was already compiled"
291
+ else
292
+ timeout $timeout raptor --batch $mute_flag --script ../raptor_tcl.tcl 2>&1 | tee -a results.log
293
+ if [ ${PIPESTATUS[0]} -eq 124 ]; then
294
+ echo -e " \nERROR: TIM: Design Compilation took $timeout . Exiting due to timeout" >> raptor.log
295
+ cat raptor.log >> results.log
296
+ end_time
297
+ parse_cga
298
+ exit
299
+ fi
300
+ fi
301
+ [ -f ../newsum.md5 ] && cp ../newsum.md5 ../cksums.md5
302
+
303
+ }
304
+
305
+ compile
306
+ cat raptor.log >> results.log
307
+ echo -e " \n\n#########Raptor Performance Data#########" >> results.log
308
+ cat raptor_perf.log >> results.log
309
+ echo -e " #############################################\n" >> results.log
310
+
311
+ [ -f $main_path /sim/co_sim_tb/co_sim_$design \_ temp.v ] && mv $main_path /sim/co_sim_tb/co_sim_$design \_ temp.v $main_path /sim/co_sim_tb/co_sim_$design .v || echo " "
312
+ end_time
313
+ parse_cga
0 commit comments