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