Skip to content

Commit f1203c9

Browse files
committed
Throw error right after encountering negative slack
1 parent 5a50af6 commit f1203c9

File tree

4 files changed

+22
-42
lines changed

4 files changed

+22
-42
lines changed

vpr/src/timing/timing_fail_error.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,10 @@
99
#include "timing_util.h"
1010
#include "timing_fail_error.h"
1111

12-
/* True if negative final slack. */
13-
static bool failed_timing = false;
14-
12+
/* Sets terminate_if_timing_fails in the timing context if the user has indicated
13+
* terminate_if_timing_fails option should be on.
14+
*/
1515
void set_terminate_if_timing_fails(bool cmd_opt_terminate_if_timing_fails) {
1616
auto& timing_ctx = g_vpr_ctx.mutable_timing();
1717
timing_ctx.terminate_if_timing_fails = cmd_opt_terminate_if_timing_fails;
1818
}
19-
20-
/* Checks if slack is negative, if routing is finished, and if user wants VPR flow to fail if their
21-
* design doesn't meet timingconstraints. If both conditions are true, failed_timing is set to True.
22-
*/
23-
void check_if_failed_timing_constraints(double& slack, std::string prefix) {
24-
// The error should only be thrown after routing. Checking that prefix == "Final" ensures that
25-
// only negative slacks found after routing are considered.
26-
auto& timing_ctx = g_vpr_ctx.timing();
27-
28-
if (timing_ctx.terminate_if_timing_fails && slack < 0 && prefix == "Final ") {
29-
failed_timing = true;
30-
}
31-
return;
32-
}
33-
34-
/* Throws an error if slack is negative and if user wants VPR flow to fail if their design doesn't meet timing
35-
* constraints. Called by print_timing_stats in main.cpp.
36-
*/
37-
void error_if_timing_failed() {
38-
if (failed_timing) {
39-
std::string msg = "\nDesign did not meet timing constraints.\nTiming failed and terminate_if_timing_fails set -- exiting";
40-
VPR_FATAL_ERROR(VPR_ERROR_TIMING, msg.c_str());
41-
}
42-
return;
43-
}

vpr/src/timing/timing_fail_error.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
#include "tatum/timing_paths.hpp"
88
#include "timing_util.h"
99

10-
/* Checks if slack is negative and if user wants VPR flow to fail if their desisn doesn't meet timing
11-
* constraints. If both conditions are true, the function adds details about the negative slack to a string
12-
* that will be printed when VPR throws an error.
13-
*/
14-
void check_if_failed_timing_constraints(double& slack, std::string prefix);
15-
16-
void error_if_timing_failed();
17-
1810
/* Represents whether or not VPR should fail if timing constraints aren't met. */
1911
void set_terminate_if_timing_fails(bool cmd_opt_terminate_if_timing_fails);
2012

vpr/src/timing/timing_util.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,14 @@ void print_setup_timing_summary(const tatum::TimingConstraints& constraints,
417417

418418
VTR_LOG("\n");
419419

420-
check_if_failed_timing_constraints(setup_worst_neg_slack, prefix);
421-
check_if_failed_timing_constraints(setup_total_neg_slack, prefix);
420+
/* If the terminate_if_timing fails option is on, this checks if slack is negative and if user wants VPR
421+
* flow to fail if their design doesn't meet timing constraints. If both conditions are true, the function
422+
* adds details about the negative slack to a string that will be printed when VPR throws an error.
423+
*/
424+
if (timing_ctx.terminate_if_timing_fails && (setup_worst_neg_slack < 0 || setup_total_neg_slack < 0) && prefix == "Final ") {
425+
std::string msg = "\nDesign did not meet timing constraints.\nTiming failed and terminate_if_timing_fails set -- exiting";
426+
VPR_FATAL_ERROR(VPR_ERROR_TIMING, msg.c_str());
427+
}
422428
}
423429

424430
/*
@@ -597,7 +603,9 @@ std::vector<HistogramBucket> create_hold_slack_histogram(const tatum::HoldTiming
597603
}
598604

599605
void print_hold_timing_summary(const tatum::TimingConstraints& constraints, const tatum::HoldTimingAnalyzer& hold_analyzer, std::string prefix) {
600-
auto hold_worst_neg_slack = sec_to_nanosec(find_hold_worst_negative_slack(hold_analyzer));
606+
auto& timing_ctx = g_vpr_ctx.timing();
607+
608+
auto hold_worst_neg_slack = sec_to_nanosec(find_hold_worst_negative_slack(hold_analyzer));
601609
auto hold_total_neg_slack = sec_to_nanosec(find_hold_total_negative_slack(hold_analyzer));
602610

603611
VTR_LOG("%shold Worst Negative Slack (hWNS): %g ns\n", prefix.c_str(), hold_worst_neg_slack);
@@ -646,8 +654,14 @@ void print_hold_timing_summary(const tatum::TimingConstraints& constraints, cons
646654
}
647655
VTR_LOG("\n");
648656

649-
check_if_failed_timing_constraints(hold_worst_neg_slack, prefix);
650-
check_if_failed_timing_constraints(hold_total_neg_slack, prefix);
657+
/* If the terminate_if_timing fails option is on, this checks if slack is negative and if user wants VPR
658+
* flow to fail if their design doesn't meet timing constraints. If both conditions are true, the function
659+
* adds details about the negative slack to a string that will be printed when VPR throws an error.
660+
*/
661+
if (timing_ctx.terminate_if_timing_fails && (hold_worst_neg_slack < 0 || hold_total_neg_slack < 0) && prefix == "Final ") {
662+
std::string msg = "\nDesign did not meet timing constraints.\nTiming failed and terminate_if_timing_fails set -- exiting";
663+
VPR_FATAL_ERROR(VPR_ERROR_TIMING, msg.c_str());
664+
}
651665
}
652666

653667
/*

vpr/src/util/vpr_utils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,5 +2022,4 @@ void print_timing_stats(std::string name,
20222022
current.num_full_hold_updates - past.num_full_hold_updates,
20232023
current.num_full_setup_hold_updates - past.num_full_setup_hold_updates);
20242024

2025-
error_if_timing_failed();
20262025
}

0 commit comments

Comments
 (0)