@@ -191,27 +191,77 @@ std::vector<HistogramBucket> create_criticality_histogram(const SetupTimingInfo&
191
191
return histogram;
192
192
}
193
193
194
- void print_setup_timing_summary (const tatum::TimingConstraints& constraints, const tatum::SetupTimingAnalyzer& setup_analyzer, std::string prefix) {
194
+ void write_setup_timing_summary (std::string timing_summary_filename,
195
+ double least_slack_cpd,
196
+ double fmax,
197
+ double setup_worst_neg_slack,
198
+ double setup_total_neg_slack) {
199
+ if (vtr::check_file_name_extension (timing_summary_filename.c_str (), " .json" )) {
200
+ // write report in JSON format
201
+ std::fstream fp;
202
+ fp.open (timing_summary_filename, std::fstream::out | std::fstream::trunc );
203
+ fp << " {\n " ;
204
+
205
+ fp << " \" cpd\" : " << least_slack_cpd << " ,\n " ;
206
+ fp << " \" fmax\" : " << fmax << " ,\n " ;
207
+
208
+ fp << " \" swns\" : " << setup_worst_neg_slack << " ,\n " ;
209
+ fp << " \" stns\" : " << setup_total_neg_slack << " \n " ;
210
+ fp << " }\n " ;
211
+ } else if (vtr::check_file_name_extension (timing_summary_filename.c_str (), " .xml" )) {
212
+ // write report in XML format
213
+ std::fstream fp;
214
+ fp.open (timing_summary_filename, std::fstream::out | std::fstream::trunc );
215
+ fp << " <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ;
216
+ fp << " <timing_summary_report>\n " ;
217
+
218
+ fp << " <cpd value=\" " << least_slack_cpd << " \" unit=\" ns\" description=\" Final critical path delay\" ></nets>\n " ;
219
+ fp << " <fmax value=\" " << fmax << " \" unit=\" MHz\" description=\" Max circuit frequency\" ></fmax>\n " ;
220
+ fp << " <swns value=\" " << setup_worst_neg_slack << " \" unit=\" ns\" description=\" setup Worst Negative Slack (sWNS)\" ></swns>\n " ;
221
+ fp << " <stns value=\" " << setup_total_neg_slack << " \" unit=\" ns\" description=\" setup Total Negative Slack (sTNS)\" ></stns>\n " ;
222
+
223
+ fp << " </block_usage_report>\n " ;
224
+ } else {
225
+ VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
226
+ " Unknown extension on output %s" ,
227
+ timing_summary_filename.c_str ());
228
+ }
229
+ }
230
+
231
+ void print_setup_timing_summary (const tatum::TimingConstraints& constraints,
232
+ const tatum::SetupTimingAnalyzer& setup_analyzer,
233
+ std::string prefix,
234
+ std::string timing_summary_filename) {
195
235
auto & timing_ctx = g_vpr_ctx.timing ();
196
236
197
237
auto crit_paths = tatum::find_critical_paths (*timing_ctx.graph , constraints, setup_analyzer);
198
238
199
239
auto least_slack_cpd = find_least_slack_critical_path_delay (constraints, setup_analyzer);
200
- VTR_LOG (" %scritical path delay (least slack): %g ns" , prefix.c_str (), sec_to_nanosec (least_slack_cpd.delay ()));
240
+
241
+ double least_slack_cpd_delay = sec_to_nanosec (least_slack_cpd.delay ());
242
+ double fmax = sec_to_mhz (least_slack_cpd.delay ());
243
+ double setup_worst_neg_slack = sec_to_nanosec (find_setup_worst_negative_slack (setup_analyzer));
244
+ double setup_total_neg_slack = sec_to_nanosec (find_setup_total_negative_slack (setup_analyzer));
245
+
246
+ VTR_LOG (" %scritical path delay (least slack): %g ns" , prefix.c_str (), least_slack_cpd_delay);
201
247
202
248
if (crit_paths.size () == 1 ) {
203
249
// Fmax is only meaningful for a single-clock circuit
204
- VTR_LOG (" , Fmax: %g MHz" , sec_to_mhz (least_slack_cpd. delay ()) );
250
+ VTR_LOG (" , Fmax: %g MHz" , fmax );
205
251
}
206
252
VTR_LOG (" \n " );
207
253
208
- VTR_LOG (" %ssetup Worst Negative Slack (sWNS): %g ns\n " , prefix.c_str (), sec_to_nanosec ( find_setup_worst_negative_slack (setup_analyzer)) );
209
- VTR_LOG (" %ssetup Total Negative Slack (sTNS): %g ns\n " , prefix.c_str (), sec_to_nanosec ( find_setup_total_negative_slack (setup_analyzer)) );
254
+ VTR_LOG (" %ssetup Worst Negative Slack (sWNS): %g ns\n " , prefix.c_str (), setup_worst_neg_slack );
255
+ VTR_LOG (" %ssetup Total Negative Slack (sTNS): %g ns\n " , prefix.c_str (), setup_total_neg_slack );
210
256
VTR_LOG (" \n " );
211
257
212
258
VTR_LOG (" %ssetup slack histogram:\n " , prefix.c_str ());
213
259
print_histogram (create_setup_slack_histogram (setup_analyzer));
214
260
261
+ if (!timing_summary_filename.empty ())
262
+ write_setup_timing_summary (timing_summary_filename, least_slack_cpd_delay,
263
+ fmax , setup_worst_neg_slack, setup_total_neg_slack);
264
+
215
265
if (crit_paths.size () > 1 ) {
216
266
// Multi-clock
217
267
VTR_LOG (" \n " );
0 commit comments