From bd1cbefcd5a8aeed69c6332e02f6c47fecdfb469 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Fri, 1 May 2026 10:32:20 -0700 Subject: [PATCH] write_sdc -mode Signed-off-by: James Cherry --- doc/ChangeLog.txt | 7 +++++++ include/sta/Sta.hh | 7 +++++++ sdc/Sdc.i | 14 +++++++------- sdc/Sdc.tcl | 11 ++++++++--- sdf/Sdf.tcl | 2 +- search/Search.i | 12 ++++++++++++ search/Sta.cc | 16 ++++++++++++++++ 7 files changed, 58 insertions(+), 11 deletions(-) diff --git a/doc/ChangeLog.txt b/doc/ChangeLog.txt index b6238246..496aab91 100644 --- a/doc/ChangeLog.txt +++ b/doc/ChangeLog.txt @@ -4,6 +4,13 @@ OpenSTA Timing Analyzer Release Notes This file summarizes user visible changes for each release. See ApiChangeLog.txt for changes to the STA api. +2026/05/01 +---------- + +The write_sdc command supports a -mode argument. + + read_sdc [-mode mode] + 2026/03/23 ---------- diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index 5f9c1362..5237ec9a 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -1041,6 +1041,13 @@ public: const Scene *scene, const MinMax *min_max, int digits); + void writeSdc(std::string_view filename, + std::string_view mode_name, + bool leaf, + bool native, + int digits, + bool gzip, + bool no_timestamp); void writeSdc(const Sdc *sdc, std::string_view filename, // Map hierarchical pins and instances to leaf pins and instances. diff --git a/sdc/Sdc.i b/sdc/Sdc.i index 0a02cb07..4b3050b0 100644 --- a/sdc/Sdc.i +++ b/sdc/Sdc.i @@ -94,15 +94,15 @@ private: void write_sdc_cmd(std::string filename, - bool leaf, - bool compatible, - int digits, - bool gzip, - bool no_timestamp) + std::string mode_name, + bool leaf, + bool compatible, + int digits, + bool gzip, + bool no_timestamp) { Sta *sta = Sta::sta(); - const Sdc *sdc = sta->cmdSdc(); - sta->writeSdc(sdc, filename, leaf, compatible, digits, gzip, no_timestamp); + sta->writeSdc(filename, mode_name, leaf, compatible, digits, gzip, no_timestamp); } void diff --git a/sdc/Sdc.tcl b/sdc/Sdc.tcl index 4c11522b..ead9a778 100644 --- a/sdc/Sdc.tcl +++ b/sdc/Sdc.tcl @@ -62,13 +62,18 @@ proc_redirect read_sdc { ################################################################ define_cmd_args "write_sdc" \ - {[-map_hpins] [-digits digits] [-gzip] [-no_timestamp] filename} + {[-mode mode] [-map_hpins] [-digits digits] [-gzip] [-no_timestamp] filename} proc write_sdc { args } { - parse_key_args "write_sdc" args keys {-digits -significant_digits} \ + parse_key_args "write_sdc" args keys {-mode -digits} \ flags {-map_hpins -compatible -gzip -no_timestamp} check_argc_eq1 "write_sdc" $args + set mode [cmd_mode] + if { [info exists keys(-mode)] } { + set mode $keys(-mode) + } + set digits 4 if { [info exists keys(-digits)] } { set digits $keys(-digits) @@ -80,7 +85,7 @@ proc write_sdc { args } { set no_timestamp [info exists flags(-no_timestamp)] set map_hpins [info exists flags(-map_hpins)] set native [expr ![info exists flags(-compatible)]] - write_sdc_cmd $filename $map_hpins $native $digits $gzip $no_timestamp + write_sdc_cmd $filename $mode $map_hpins $native $digits $gzip $no_timestamp } ################################################################ diff --git a/sdf/Sdf.tcl b/sdf/Sdf.tcl index df0a775c..bdbb1de8 100644 --- a/sdf/Sdf.tcl +++ b/sdf/Sdf.tcl @@ -180,7 +180,7 @@ define_cmd_args "write_sdf" \ proc_redirect write_sdf { parse_key_args "write_sdf" args \ - keys {-corner -scene -divider -digits -significant_digits} \ + keys {-corner -scene -divider -digits} \ flags {-include_typ -gzip -no_timestamp -no_version} check_argc_eq1 "write_sdf" $args set scene [parse_scene keys] diff --git a/search/Search.i b/search/Search.i index 85de21d5..d3eb7455 100644 --- a/search/Search.i +++ b/search/Search.i @@ -816,6 +816,12 @@ cmd_mode_name() return Sta::sta()->cmdMode()->name(); } +Mode * +cmd_mode() +{ + return Sta::sta()->cmdMode(); +} + void set_cmd_mode(std::string mode_name) { @@ -828,6 +834,12 @@ find_modes(std::string mode_name) return Sta::sta()->findModes(mode_name); } +Mode * +find_mode(std::string mode_name) +{ + return Sta::sta()->findMode(mode_name); +} + //////////////////////////////////////////////////////////////// CheckErrorSeq & diff --git a/search/Sta.cc b/search/Sta.cc index 6593b16d..357256d0 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -2206,6 +2206,22 @@ Sta::checkExceptionToPins(ExceptionTo *to, } } +void +Sta::writeSdc(std::string_view filename, + std::string_view mode_name, + bool leaf, + bool native, + int digits, + bool gzip, + bool no_timestamp) +{ + Mode *mode = findMode(mode_name); + if (mode) + writeSdc(mode->sdc(), filename, leaf, native, digits, gzip, no_timestamp); + else + report_->warn(1561, "mode {} not found.", mode_name); +} + void Sta::writeSdc(const Sdc *sdc, std::string_view filename,