Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / docxml2 / text / doc / hitas_tutorial / ssta.xml
1 <?xml version="1.0" encoding="ISO-8859-1" ?>
2 <chapter>
3 <section niv='1'><title>SSTA</title>
4
5 <section niv='2'><title>Principles</title>
6 <p>&tool; SSTA is a Monte-Carlo like analysis: it is based on a collection of STA samples.
7 Each STA sample is based upon the creation of a timing database sample, constructed by picking up random values for the statistical parameters
8 embedded in either the SPICE netlist or the technology files.
9 An SSTA sample consists therefore of a timing database and a STA run.
10 In the end, there are as many different timing databases and STA runs as SSTA samples. STA runs are of course highly configurable, in order to extract
11 any relevant information. </p>
12 </section>
13
14 <section niv='2'><title>Analysis on the ADDACCU</title>
15 <p>This example features 2 analysis: A SSTA analysis and the PATH analysis. In the SSTA analysis, slacks are computed, sorted and displayed in an efficient way. In the PATH analysis, particular paths are retrieved and their variations are displayed.
16 For each of those analyses, 50 runs are performed on the ADDACCU design. </p>
17
18 <section niv='3'><title>Generating the data for the SSTA analysis</title>
19 <p>The script to generate the SSTA data is no different from a standard STA script except for 2 TCL instructions inserted at the
20 beginning and at the end of the script. The script used to generate those data is named <f>ssta.tcl</f>.
21 </p>
22 <p>The first instruction is responsible for the handling of the 50 runs:</p>
23 <code>
24 <cl>runStatHiTas 50 -incremental -result slacks.ssta -storedir store</cl>
25 </code>
26 <p>In case the configuration variable <f>avtLibraryDirs</f> is used, this instruction must be placed after the configuration because modifications are applied to this configuration variable to get proper search paths.</p>
27 <p>
28 Calling <f>runStatHiTas</f> will launch 50 separate runs of the <f>ssta.tcl</f> script one by one (multiprocessing is not used in the tutorial). Each run will have its data written into the file <f>slacks.ssta</f>
29 and the required information to display the slack details will be stored in the directory <f>store</f>.</p>
30 <p>Using the option <f>-storedir</f> is not mandatory but if it is not used, only the slack summaries will be available.</p>
31 <p>The <f>-incremental</f> flag is set to enrich any previous execution of the SSTA database so 50 more runs will be added to any existing set of runs.
32 </p>
33 <p>The second instruction is responsible for the handling of STA data:</p>
34 <code>
35 <cl>ssta_SlackReport -senddata $stbfig simple</cl>
36 </code>
37 <p>
38 <f>ssta_SlackReport</f> is called after the <f>stb</f> API execution. The stability figure and a slack data output mode is given to the function. The only mode available at the moment is <f>simple</f>.
39 Called in this form, it retrieves at most the 10000 worst negative slacks from the stability figure. If no negative slacks are found, the worst positive one is searched.
40 The slack descriptions are then written to the file <f>slacks.ssta</f> for a future use.
41 </p>
42 </section>
43 <section niv='3'><title>Reporting the results for SSTA analysis</title>
44 <p>
45 The script <f>slack_analysis.tcl</f> reads the <f>slacks.ssta</f> file and uses the data in the directory <f>store</f> to display some results.
46 </p>
47 <section niv='4'><title>Slack occurrence</title>
48 <p>The first kind of result output is generated using the command:</p>
49 <code>
50 ssta_SlackReport -display "slacks.ssta" $ofile -storedir store
51 </code>
52 <p>
53 The report is driven to the file <f>slack_report.log</f>.
54 </p>
55 <p>At the beginning of the report, yield information is printed: the total number of runs, the number of runs with negative holds, the number of runs with negative setups, the number of runs with PVT errors and the global yield.
56 </p>
57 <p>
58 In a second part, each negative slack is printed with the number of occurrence the of slack, the run number where the slack is the worst, some statistical information and the slack description.
59 As the <f>store</f> directory is given as an argument to the function, the detail of each negative slack is displayed after this summary.
60 </p>
61 <p>
62 Finally, at the end, a list with the different seeds used to generate each run database is displayed.
63 </p>
64 </section>
65 <section niv='4'><title>Worst slack distributions</title>
66 <p>The second kind of result is output in a set of file through a gnuplot graphical file representation by using the command:</p>
67 <code>
68 ssta_SlackReport -plot "slacks.ssta" "distrib"
69 </code>
70 <p>
71 <f>distrib</f> is a prefix that will be used to generate the gnuplot files. There are 2 plots: 1 for the setups slacks and 1 for the holds slacks.
72 </p>
73 <p>The gnuplot command file will be named <f>distrib.holds.plt</f> and <f>distrib.setups.plt</f>.
74 The corresponding data files are <f>distrib.holds.plt.dat</f> and <f>distrib.holds.plt.dat</f>.
75 </p>
76
77 <p>The distributions can be viewed using the UNIX command:</p>
78 <code>
79 <cl>gnuplot &lt;command file&gt;</cl>
80 </code>
81 </section>
82 </section>
83
84
85
86 <section niv='3'><title>Generating the data for the PATH analysis</title>
87 <p>The script to generate the PATH data is very easy. In this case there is no need for stability to be performed. The only operation to be done is to retrieve the list of desired paths to analyse. In this example all paths and accesses will be taken. As for the SSTA data generation, 2 TCL instructions are inserted at the
88 beginning and at the end of the script. In between, the UTD is built and the path search is performed. The script used to generate those data is named <f>paths.tcl</f>.
89 </p>
90 <p>The first instruction is responsible for the handling of the 50 runs:</p>
91 <code>
92 <cl>runStatHiTas 50 -incremental -result paths.ssta -storedir store_paths</cl>
93 </code>
94 <p>The instruction is placed after the configuration variable <f>avtLibraryDirs</f></p>
95 <p>
96 After the UTD generation, the list of accesses and paths are extracted from the UTD and merged together:</p>
97 <code>
98 <cl>set paths [concat [ttv_GetPaths $fig -access] [ttv_GetPaths $fig]] </cl>
99 </code>
100
101
102 <p>The last instruction is responsible for the handling of PATH data:</p>
103 <code>
104 <cl>ssta_PathReport -senddata $paths simple</cl>
105 </code>
106 <p>
107 <f>ssta_PathReport</f> is called with the path list and a path data output mode. The only mode available at the moment is <f>simple</f>.
108 The path descriptions are written into the file <f>paths.ssta</f> for a future use.
109 </p>
110 </section>
111
112 <section niv='3'><title>Reporting the results for SSTA analysis</title>
113 <p>
114 The script <f>path_analysis.tcl</f> reads the <f>paths.ssta</f> file and uses the data in the directory <f>store_paths</f> to display some results.
115 </p>
116 <p>The path result report is generated using the command:</p>
117 <code>
118 ssta_PathReport -display "paths.ssta" $ofile -storedir store_paths
119 </code>
120 <p>
121 The report is driven to the file <f>path_report.log</f>.
122 </p>
123 <p>A summary of all paths/accesses is printed at the beginning of the report.
124 Each path has an entry in the summary with some statistical information, the minimum delay of the path and the corresponding run number, the maximum delay and the corresponding run number and finally the path description.
125 </p>
126 <p>
127 As the <f>store_paths</f> directory is given as an argument to the function, the detail of each path is displayed after this summary. There are 2 details for each path: the detail for the minimum path value and the detail for the maximum path value.
128 </p>
129 <p>
130 Finally, at the end, a list with the different seeds used to generate each run database is displayed.
131 </p>
132 </section>
133
134 </section>
135
136
137 <!--
138 <section niv='4'><title>The db.tcl script </title>
139
140 <p>The database generation and STA is performed in the <f>db.tcl</f> script.
141 The result of the STA run is printed in a file given as first argument to the script:</p>
142 <code>
143 <cl>set filename [ lindex $argv 0 ]</cl>
144 </code>
145
146 <p>You will find in this script the procedure <f>build_slack_string</f>. After the STA, it retrieves the worst setup slack and the worst hold slack
147 of the STA. The worst slack is retrieved by limiting the number of slacks to 1 and the margin to 1s.</p>
148 <code>
149 <cl>set sl [ stb_GetSlacks $stbfig -nbslacks 1 $type -margin 1 ]</cl>
150 </code>
151
152 <p>The procedure <f>build_slack_string</f> is subsequently called as follows:</p>
153
154 <code>
155 <cl>set setupstring [build_slack_string $stbfig -setuponly]</cl>
156 <cl>set holdstring [build_slack_string $stbfig -holdonly]</cl>
157 </code>
158
159 <p>The procedure <f>build_slack_string</f> returns a string with the slack type, the start, thru and end event of the slack DATA VALID
160 and finally the corresponding slack value. The start, thru and end event strings are obtained
161 by the function "ssta_GetEventName" which returns the NET_NAME of the signal followed by the transition
162 direction of the event. The thru event is set to "- -" in case the DATAVALID is not an access.</p>
163 <p>The returned string of the procedure <f>build_slack_string</f> looks like:</p>
164 <code>
165 <cl>"-setuponly sel u - - l3.sff_m d 5.5e-10"</cl>
166 </code>
167
168 <p>The <f>db.tcl</f> script then creates the result file and a line is written with the setup string and the hold string side by side:</p>
169
170 <code>
171 <cl>puts $channel "$setupstring $holdstring"</cl>
172 </code>
173
174 <p>So the result file for one SSTA run contains one line with 16 fields which will be further analyzed.</p>
175 <p>You can write here any procedure you want, and analyze statistically any characteristics of your design.</p>
176 </section>
177 </section>
178
179 <section niv='3'><title>Performing 50 STA samples</title>
180
181 <p>The script <f>ssta_top.tcl</f> runs 50 STA scripts, creating 50 SSTA samples.
182 It creates a directory named <f>ssta_results/</f> which stores intermediate results:</p>
183 <code>
184 <cl>set resdir ssta_results</cl>
185 <cl>catch {file mkdir $resdir}</cl>
186 </code>
187
188 <p>The script iterates from 1 to 50, generating 50 different result files:</p>
189 <code>
190 <cl>set filename "$resdir/ssta_run$i"</cl>
191 </code>
192
193 <p><f>ssta_sample.tcl</f> is invoked with this filename as argument:</p>
194 <code>
195 <cl>catch [list exec ./ssta_sample.tcl $filename] msg</cl>
196 </code>
197
198 <p>The filename is stored in a list of files to merge.</p>
199 <code>
200 <cl>lappend reslist $filename</cl>
201 </code>
202
203 <p>Finally, all files are packed together in <f>result.ssta</f>:</p>
204 <code>
205 <cl>eval "exec cat $reslist >> result.ssta"</cl>
206 </code>
207 </section>
208
209 <section niv='3'><title>Example of SSTA Results Usage</title>
210
211 <p><f>data_analysis.tcl</f> reads in <f>results.ssta</f> and computes the circuit timing yield, and setup and hold slacks distribution.</p>
212 <p>The API ssta_ToolBox provides some functions to handle SSTA results. The setup and hold value list is extracted from the result file using:</p>
213 <code>
214 <cl>set lsetup [ ssta_ToolBox -filename $file -getfield 8 ]</cl>
215 <cl>set lhold [ ssta_ToolBox -filename $file -getfield 16 ]</cl>
216 </code>
217
218 <p>The setup and hold values are the 8th and 16th field of each line.</p>
219 <p>The yield is computed using the function <f>get_yield</f> and <f>get_nb_neg</f>.</p>
220
221 <p>The same API is used in another mode to build graphical distribution display by generating gnuplot
222 data and command files from the setup and hold value lists:</p>
223 <code>
224 <cl>ssta_ToolBox -plot -values $lhold -filename result_hold.plt -title "Hold Slacks"</cl>
225 <cl>ssta_ToolBox -plot -values $lsetup -filename result_setup.plt -title "Setup Slacks"</cl>
226 </code>
227
228 <p>The gnuplot command file will be named <f>result_hold.plt</f> and <f>result_setup.plt</f> respectively.
229 The corresponding data files are <f>result_hold.plt.dat</f> and <f>result_setup.plt.dat</f>.</p>
230
231 <p>The distributions can be viewed using the UNIX command:</p>
232 <code>
233 <cl>gnuplot &lt;command file&gt;</cl>
234 </code>
235 </section>
236
237 </section>
238 -->
239
240 <!-- <section niv='2'><title>SSTA on the cpu</title>
241 <p>This example runs the STA 30 times on the cpu. Each result is sent to a master script packing results together in a file.
242 The master script runs an API dealing with the parallel SSTA runs through a user defined script.
243 The advantage of using this script is that the number of parallel runs is handled transparently and the user given
244 script to launch a SSTA run has all the freedom necessary to launch remote execution for example.</p>
245
246 <section niv='3'><title>One sample of STA analysis</title>
247
248 <p>The STA is done by 2 scripts.
249 The script (slave.tcl) enables the statistical functions and then calls the STA script (db.tcl).
250 The slave.tcl script is supposed to have been launched by the master.tcl script which handles the parallelism.
251 Once db.tcl finished, slave.tcl finishes by building a result string and sending it to the master.tcl script.</p>
252 <p>The activation of statistical functions is done by using the command:</p>
253 <code>
254 <cl>avt_config spiActivateStatisticalFunctions yes</cl>
255 </code>
256
257 <p>The slave.tcl script is supposed to be called with an argument representing the absolute path where
258 to find the source files. As the script can be run remotely, the file search path is enriched with this path:</p>
259 <code>
260 <cl>set srcdir [ lindex $argv 0 ]</cl>
261 <cl>avt_config avtLibraryDirs .:$srcdir</cl>
262 </code>
263
264 <p>The UTD generation and STA is performed in the db.tcl script.</p>
265
266 <p>After the stability figure generation, the slave.tcl creates a result string using the function "build_slack_list".
267 The function "build_slack_list" is called to retrieve at most the 1000 worst negative setup or hold slacks.
268 The function is also called with the stability figure and a flag to use with the API "stb_GetSlacks". This flag set
269 the choice between setup (-setuponly) and hold (-holdonly):</p>
270 <p>In the case there are negative slacks, the function will retrieve the first worst positive slack.</p>
271
272 <p>At the end, the function returns a TCL list which contains the description of each slack:</p>
273 <p>(the start, thru and end event of the DATA VALID and the corresponding slack value)</p>
274 <p>The start, thru and end event strings are obtained by the function "ssta_GetEventName" which returns
275 the NETNAME of the signal followed by the transition direction of the event.
276 The thru event is set to "- -" in case the DATAVALID is not an access.</p>
277
278 <p>The result list is a list with the word "setup" followed by the list of setup slacks,
279 the word "hold" followed by the list of hold slacks:</p>
280 <code>
281 <cl>set reslist [list setup [build_slack_list $stbfig -setuponly] hold [build_slack_list $stbfig -holdonly]]</cl>
282 </code>
283
284 <p>The result looks like the following:</p>
285
286 <code>
287 <cl>setup {{{ck d} {ram_m_1_0_dff_s d} {accu_m2_dff_m u} -1.35e-10} {{ck d} {ram_m_1_0_dff_s d} {accu_m3_dff_m u} -9.36e-11}}} hold {{{scin d} {- -} {accu_m0_dff_m u} 1.19e-12}}</cl>
288 </code>
289
290 <p>Finally, the result list is sent to the master script using the API "avt_McPostData" which should be the last command of the script:</p>
291 <code>
292 <cl>avt_McPostData $reslist</cl>
293 </code>
294
295 </section>
296
297 <section niv='3'><title>Performing the 30 SSTA runs</title>
298
299 <p>The script (master.tcl) exists for the purpose of launching several runs of single SSTA runs in a parallel oriented way.</p>
300 <p>The API runStatHiTas is used for this:</p>
301 <code>
302 <cl>runStatHiTas 30:2 ./exec_stat.sh slave.tcl data.log</cl>
303 </code>
304
305 <p>This means that a total of 30 runs must be done but only 2 are authorized simultaneously.
306 The script (exec_stat.sh) is responsible for the launching of the script (slave.tcl).
307 All the results sent back to the master will be written in the result file "data.log".
308 If this file already exists, it will not be overwritten but a number will be added to the filename "data_xxx.log".</p>
309
310 <p>For this example, the (exec_stat.sh) will not run remote (slave.tcl) but will execute the runs on the same machine.
311 The script is written in "sh" format and is always called with 4 arguments:</p>
312 <code>
313 <cl>- the name of the slave script to run</cl>
314 <cl>- the sample number ranging from 1 to 30 in our example</cl>
315 <cl>- the parallel job number ranging from 1 to 2 in our example</cl>
316 <cl>- communication data between master and slave which must be the last argument given to the slave script to run</cl>
317 </code>
318
319 <p>The script gets the current working directory where the data file resides into the variable "curw".</p>
320 <p>It creates a temporary directory using the sample number given and moves into it.</p>
321 <p>Then, the slave script is executed with the "curw" as first argument and the communication data as the last one.</p>
322 <p>Finally in case of success of the slave script run, the temporary directory will be erased.</p>
323
324 </section>
325
326 <section niv='3'><title>An example of the SSTA result utilization</title>
327
328 <p>The script (data_analysis.tcl) reads the result file "data.log", computes the yield of the circuit,
329 the distribution of the setup and hold slacks and the number of negative slacks.</p>
330
331 <p>The script must be called with one argument which is the data file name.
332 The content of the file can be read with the API "ssta_ToolBox" which returns a list with one entry for each SSTA run.
333 The script loops thru all the entries doing the following operations:</p>
334 <code>
335 <cl>- get the worst setup and add it to the lsetup list</cl>
336 <cl>- get the worst hold and add it to the lhold list</cl>
337 <cl>- for each setup slack, append the slack value to a list of slacks associated to the slack description in the tcl dictionary setupdict</cl>
338 <cl>- for each hold slack, append the slack value to a list of slacks associated to the slack description in the tcl dictionary holddict</cl>
339 </code>
340
341 <p>A list of occurrences is built and sorted from the most present slack description to the less one.</p>
342 <p>The list is displayed for each slack description with the number of occurrence,
343 the mean slack value and the slack description. This is done for the setup and hold dictionary built.</p>
344
345 <p>The API "ssta_ToolBox" is used in the plot mode to build graphical distribution display by generating gnuplot data
346 and command files from the setup and hold value lists:</p>
347 <code>
348 <cl>ssta_ToolBox -plot -values $lhold -filename result_hold.plt -title "Hold Slacks" -nbrange 10</cl>
349 <cl>ssta_ToolBox -plot -values $lsetup -filename result_setup.plt -title "Setup Slacks" -nbrange 10</cl>
350 </code>
351
352 <p>The gnuplot command file will be named "result_hold.plt" and "result_setup.plt" respectively.
353 The corresponding data files are "result_hold.plt.dat" and "result_setup.plt.dat".</p>
354
355 <p>The distributions can be viewed using the unix command:</p>
356 <code>
357 <cl>gnuplot &lt;command file&gt;</cl>
358 </code>
359 </section>
360
361
362 </section>-->
363
364 </section>
365
366 </chapter>
367
368
369
370