Skip to content

Commit 2148a9a

Browse files
committed
ord: add report_fmax_metric
Taken from SiC Signed-off-by: Matt Liberty <[email protected]>
1 parent f31ae46 commit 2148a9a

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

src/Metrics.tcl

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ proc report_tns_metric { args } {
3636

3737
define_cmd_args "report_worst_slack_metric" {[-setup]|[-hold]}
3838
proc report_worst_slack_metric { args } {
39-
global sta_report_default_digits
4039
parse_key_args "report_worst_slack_metric" args keys {} flags {-setup -hold}
4140

4241
set min_max "-max"
@@ -53,7 +52,6 @@ proc report_worst_slack_metric { args } {
5352

5453
define_cmd_args "report_worst_negative_slack_metric" {[-setup]|[-hold]}
5554
proc report_worst_negative_slack_metric { args } {
56-
global sta_report_default_digits
5755
parse_key_args "report_worst_negative_slack_metric" args keys {} flags {-setup -hold}
5856

5957
set min_max "-max"
@@ -68,6 +66,51 @@ proc report_worst_negative_slack_metric { args } {
6866
utl::metric_float $metric_name [worst_negative_slack $min_max]
6967
}
7068

69+
define_cmd_args "report_fmax_metric" {}
70+
proc report_fmax_metric { args } {
71+
parse_key_args "report_fmax_metric" args keys {} flags {}
72+
73+
# Taken from: https://github.com/siliconcompiler/siliconcompiler/blob/e46c702df218c93483b951533fe00bcf01cf772d/siliconcompiler/tools/openroad/scripts/common/reports.tcl#L98
74+
# Modeled on: https://github.com/The-OpenROAD-Project/OpenSTA/blob/f913c3ddbb3e7b4364ed4437c65ac78c4da9174b/tcl/Search.tcl#L1078
75+
set fmax_metric 0
76+
foreach clk [sta::sort_by_name [all_clocks]] {
77+
set clk_name [get_name $clk]
78+
set min_period [sta::find_clk_min_period $clk 1]
79+
if { $min_period == 0.0 } {
80+
continue
81+
}
82+
set fmax [expr { 1.0 / $min_period }]
83+
utl::metric_float "timing__fmax__clock:${clk_name}" $fmax
84+
puts "$clk_name fmax = [format %.2f [expr { $fmax / 1e6 }]] MHz"
85+
set fmax_metric [expr { max($fmax_metric, $fmax) }]
86+
}
87+
if { $fmax_metric == 0 } {
88+
# attempt to compute based on combinatorial path
89+
set fmax_valid true
90+
set max_path [find_timing_paths -unconstrained -path_delay max]
91+
if { $max_path == "" } {
92+
set fmax_valid false
93+
} else {
94+
set max_path_delay [$max_path data_arrival_time]
95+
}
96+
set min_path [find_timing_paths -unconstrained -path_delay min]
97+
if { $min_path == "" } {
98+
set fmax_valid false
99+
} else {
100+
set min_path_delay [$min_path data_arrival_time]
101+
}
102+
if { $fmax_valid } {
103+
set path_delay [expr { $max_path_delay - min(0, $min_path_delay) }]
104+
if { $path_delay > 0 } {
105+
set fmax_metric [expr { 1.0 / $path_delay }]
106+
}
107+
}
108+
}
109+
if { $fmax_metric > 0 } {
110+
utl::metric_float "timing__fmax" $fmax_metric
111+
}
112+
}
113+
71114
# From https://wiki.tcl-lang.org/page/Inf
72115
proc ::tcl::mathfunc::finite { x } {
73116
expr { [string is double -strict $x] && $x == $x && $x + 1 != $x }

0 commit comments

Comments
 (0)