Skip to content

Commit 25ab85f

Browse files
[STA] Added Tutorial for Post-Implementation Timing Analysis
Created a tutorial demonstrating how OpenSTA can be used after VPR to perform static timing analysis.
1 parent bb690a5 commit 25ab85f

File tree

3 files changed

+467
-0
lines changed

3 files changed

+467
-0
lines changed

doc/src/tutorials/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ Tutorials
1010
arch/index
1111
titan_benchmarks/index
1212
timing_simulation/index
13+
timing_analysis/index
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
.. _timing_analysis_tutorial:
2+
3+
Post-Implementation Timing Analysis
4+
-----------------------------------
5+
6+
This tutorial describes how to perform static timing analysis (STA) on a circuit which has
7+
been implemented by :ref:`VPR` using OpenSTA, an external timing analysis tool.
8+
9+
External timing analysis can be useful since VPR's timing analyzer (Tatum) does
10+
not support all timing constraints and does not provide a TCL interface to allow
11+
you to directly interrogate the timing graph. VPR also has limited support for
12+
multi-clock timing analysis, which tools like OpenSTA have better support for.
13+
14+
A user flow which would use this would perform the following steps:
15+
1. Run VPR with the timing commands it can support.
16+
2. Perform timing analysis on the resulting netlist using OpenSTA with
17+
more complex timing commands.
18+
3. Modify the user design to meet the complex timing constraints.
19+
4. Repeat.
20+
21+
Generating the Post-Implementation Netlist for STA
22+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23+
24+
For this tutorial, we will be using the ``clma`` :ref:`benchmark <benchmarks>`
25+
targetting the ``k6_frac_N10_frac_chain_mem32K_40nm.xml`` architecture.
26+
27+
We will first create a working directory to hold all the timing analysis files:
28+
29+
.. code-block:: console
30+
31+
$ mkdir timing_analysis_tut
32+
$ cd timing_analysis_tut
33+
34+
Next we will copy over the benchmark and FPGA architecture into the working
35+
directory for convenience:
36+
37+
.. code-block:: console
38+
39+
$ cp $VTR_ROOT/vtr_flow/benchmarks/blif/clma.blif .
40+
$ cp $VTR_ROOT/vtr_flow/arch/timing/k6_frac_N10_frac_chain_mem32K_40nm.xml .
41+
42+
.. note:: Replace :term:`$VTR_ROOT` with the root directory of the VTR source tree
43+
44+
To perform timing analysis externally to VTR, we will need to create an SDC file
45+
which will contain the timing constraints on the clocks and I/Os in the circuit.
46+
For this tutorial, we will use the following ``clma.sdc`` file:
47+
48+
.. code-block:: tcl
49+
:linenos:
50+
:caption: SDC file ``clma.sdc`` used for timing analysis.
51+
52+
# Set pclk to be a clock with a 16ns period.
53+
create_clock -period 16 pclk
54+
55+
# Set the input delays of all input ports in the clma design to be 0 relative to pclk.
56+
set_input_delay -clock pclk -max 0 [get_ports {pi*}]
57+
58+
# Set the output delays of all output ports in the clma design to be 0 relative to pclk.
59+
set_output_delay -clock pclk -max 0 [get_ports {p__*}]
60+
61+
Next, we can generate the post-implementation netlist and other necessary files
62+
for timing analysis using VPR.
63+
64+
.. code-block:: console
65+
66+
$ vpr \
67+
$ k6_frac_N10_frac_chain_mem32K_40nm.xml \
68+
$ clma.blif \
69+
$ --route_chan_width 100 \
70+
$ --sdc_file clma.sdc \
71+
$ --gen_post_synthesis_netlist on \
72+
$ --gen_post_implementation_sdc on \
73+
$ --post_synth_netlist_unconn_inputs gnd \
74+
$ --post_synth_netlist_module_parameters off
75+
76+
In this command, we provide the architecture, circuit, the channel width, and
77+
the SDC file. The other four commands are what generate the necessary netlist
78+
files for timing simulation:
79+
* ``--gen_post_synthesis_netlist on``: This will generate the post-implementation netlist as a Verilog file.
80+
* ``--gen_post_implementation_sdc on``: This will have VPR generate a new SDC file which contains extra timing information used from proper timing analysis.
81+
* ``--post_synth_netlist_unconn_inputs gnd``: For timing analysis with OpenSTA we want to be explicit about how we handle unconnected signal ports. Here we just ground them for simplicity.
82+
* ``--post_synth_netlist_module_parameters off``: OpenSTA does not allow parameters to be used in the netlist. This command tells VPR to generate a netlist without using parameters.
83+
84+
Once VPR has completed, we should see the generated Verilog netlist, SDF file, and SDC file:
85+
86+
.. code-block:: console
87+
88+
$ ls *.v *.sdf *.sdc
89+
top_post_synthesis.sdc top_post_synthesis.sdf top_post_synthesis.v
90+
91+
92+
Performing Timing Analysis using OpenSTA
93+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94+
95+
To perform static timing analysis for this tutorial, we will be using OpenSTA.
96+
Other STA tools can be used, they may use slightly different commands.
97+
98+
First, install OpenSTA onto your system. Building from source is a good option,
99+
using the following instructions:
100+
https://github.com/parallaxsw/OpenSTA?tab=readme-ov-file#build-from-source
101+
102+
After OpenSTA is installed, we can perfrom static timing analysis on the post-implementation
103+
netlist generated by VPR.
104+
105+
It is easiest to write a ``sdf_delays.tcl`` file to setup and configure the timing analysis:
106+
107+
.. code-block:: tcl
108+
:linenos:
109+
:caption: OpenSTA TCL file ``sdf_delays.tcl``. Note that :term:`$VTR_ROOT` should be replaced with the relevant path.
110+
111+
# Read a skeleton of a liberty file which contains just enough information to
112+
# allow OpenSTA to perform timing analysis on the post-synthesized netlist using
113+
# an SDF file. This contains descriptions of the timing arcs of the primitives
114+
# in the circuit.
115+
read_liberty $VTR_ROOT/vtr_flow/primitives.lib
116+
117+
# Read the post-implementation netlist generated by VPR.
118+
read_verilog top_post_synthesis.v
119+
120+
# Link the top-level design.
121+
link_design top
122+
123+
# Read the post-synthesis SDF file.
124+
read_sdf top_post_synthesis.sdf
125+
126+
# Read the SDC commands generated by VPR.
127+
read_sdc top_post_synthesis.sdc
128+
129+
# Report the setup and hold timing checks using OpenSTA and write to a file.
130+
report_checks -group_path_count 100 -path_delay max > open_sta_report_timing.setup.rpt
131+
report_checks -group_path_count 100 -path_delay min > open_sta_report_timing.hold.rpt
132+
133+
# Report the minimum period of the clock and the fmax.
134+
report_clock_min_period
135+
136+
# Exit OpenSTA's TCL terminal.
137+
# This can be removed if you want terminal access to write TCL commands after
138+
# executing the prior commands.
139+
exit
140+
141+
Now that we have a ``.tcl`` file, we can launch OpenSTA from the terminal and run it:
142+
143+
.. code-block:: console
144+
145+
$ sta sdf_delays.tcl
146+
147+
Running this command will open a TCL terminal which will execute all of the commands
148+
in ``sdf_delays.tcl``. The TCL file above will write setup and hold timing reports (similar to
149+
the reports written by VPR), report the minimum period of all clocks, and then exit the OpenSTA TCL terminal.
150+
151+
You can compare the timing reports generated by OpenSTA (``open_sta_report_timing.{setup/hold}.rpt``)
152+
to the timing reports generated by VPR (``report_timing.{setup/hold}.rpt``).
153+
You can also compare the minimum period reported by OpenSTA with the final
154+
period reported by VTR at the bottom of ``vpr_stdout.log``.
155+
156+
The TCL file above is just an example of what OpenSTA can do. For full documentation
157+
of the different commands available in OpenSTA, see:
158+
https://github.com/parallaxsw/OpenSTA/blob/master/doc/OpenSTA.pdf
159+

0 commit comments

Comments
 (0)