Automate OpenROAD testing
Purpose:
We use OpenROAD to generate timing analysis reports for each design. However, manually modifying parameters, running commands, and intercepting important information will be too arduous work. It is mainly due to the following points.
- First of all, the report generated by OpenROAD for each design is too long, and the report file may be as large as hundreds of megabytes. It is almost impossible to open and find tns, wns data using a text editor.
- Secondly, the locations of the configuration files running OpenROAD are very scattered. Moreover, the configuration file directory for timing modification is stored in the
tcl
script. Manual search and modification are too anti-human and prone to misoperation. - Furthermore, the amount of data we need is very large. For each design, we hope to test its performance under 7 different clock cycles and 5 different core area sizes. In other words, for each design, it is necessary to manually modify parameters, run commands, and intercept important information 35 times, which is unbearable, not to mention that we have 7 designs.
Due to these drawbacks, I decided to use shell script to automate the process of OpenROAD testing. I have the following requirements for the script. - The script can modify the
core_area
,die_area
parameter in thetcl
script given the path to thetcl
script and the desired scale of area. - The script can modify the
create_clock
‘s-period
parameter in thesdc
configuration file referred by thetcl
script, given the path to thetcl
script and the desired clock period. - The script can set all the parameters and run OpenROAD analysis one by one, given the choice set of clock period and area scale.
- After the OpenROAD generated the report file, the script can read the report and extract the information of tns & wns for each stop point and export these data to a csv table.
Main Test Framework
The entry script is named as runit.gxy
, which can receive the name of design as an argument.
For each design, the corresponding tcl
script is fixed, so I decided to map the name of design to the tcl
script.
1 | design="$1" |
The reason I use _bak
post-fix is that, I want to reserve the original core_area
and die_area
configuration in the origin tcl
file, since the original configuration is needed in the following steps.
Then I use nested loop to change the configuration one by one. The choice set can be modified in the condition statement of each for loop.
1 | for period in 2 4 6 8 10 12 14 |
The set clk period
, set area scale
, export to csv
function will be covered in the following steps.
Set the Period of Clock
I create a new shell script called set_clk.sh
to manage the automation of changing clock period.
It takes two arguments, the path to the tcl
script (string) and the desired clock period (integer).
I first preprocess the period parameter, namely, divide it by 10.
1 | time="$2" |
The clock configuration can be modified in the sdc
file, while the path to the sdc
file can be extracted from the tcl
file, with the format of set sdc_file "PATH_TO_SDC"
I decided to use grep
to locate the line of set sdc_file
and extract the path to sdc
file using regex substitution.
1 | tcl_path="$1" |
In the sdc
file, the configuration has a format of create_clock ... -period 0.x
.
Still, use regex substitution to replace the original period with the input period and everything is done.
1 | sed -i "s/^\(create_clock.*-period \)[0-9]*\.*[0-9]\(.*\)$/\1$period\2/" "$sdc_path" |
Set the core_area
and die_area
The area of the design is expressed in the form of {x1 y1 x2 y2}
, where x1 y1
stands for the coordinate of bottom-left corner and x2 y2
stands for the coordinate of upper-right corner.
Since the area of different design varies a lot, I need to change the area proportionately. As a result I need to reserve the original area stored in tcl
script as mentioned before.
First, I read the origianl core_area
and die_area
from the original script.
1 | file_path="$1" |
Then I calculate the desired core/die area size based on the scale and original area.
1 | core_x_size=$(echo "$core3" - "$core1" | bc) |
Finally, use regex substitution to modify the area configuration in _bak.tcl
script.
1 | sed -i "s/die_area {[^}]*}/die_area {$die1 $die2 $die3 $die4}/g" "$file_path" |
Collect data and export to .csv
The key information I need from the report generated by OpenROAD is tns
& wns
.
By observation, the block containing the data has the following pattern.
1 | *** |
Therefore, I use the grep
and awk
command to get the last word in each data block. In this case, it’s stoppoint*
, [number1]
, [number2]
.
1 | input_file="$1" |
Each report contains totally 6 valid stop points, so I use a loop to get the desired data.
1 | csv_file="${design}.csv" |
After getting the desired tns
and tws
, I want to export these data to a csv table.
I decided to let the table has the following columns, period
, scale
, stop point number
, tns
and wns
, one such table for each design.
This function can be achieved with the following script
1 | design="$2" |
Replace the comment in the loop and everything is done.
Result
I assemble runit_gxy.sh
in a single script named runit_cyl.sh
to run the analysis of all designs at once.
1 | ./runit_gxy.sh APU |
Then redirect the output to runit_cyl.log
.
Here is the content of APU.csv
and runit_cyl.log
1 | Period,Scale,Stoppoint,tns,wns |
1 | use design: APU |
Automate OpenROAD testing
http://chen-yulin.github.io/2024/04/19/[OBS]Shell-Automate OpenROAD testing/