Skip to content

upf: add supply-net commands, upf_version, and supply options (#5617) - #10720

Open
saurav-fermions wants to merge 7 commits into
The-OpenROAD-Project:masterfrom
Fermions-ASI:fix/5617
Open

saurav-fermions wants to merge 7 commits into
The-OpenROAD-Project:masterfrom
Fermions-ASI:fix/5617

Conversation

@saurav-fermions

Copy link
Copy Markdown
Contributor

Summary

Adds a coherent, tested subset of the UPF supply-net commands, upf_version, and supply options that the UPF reader was missing, mapped onto existing ODB structures. Scoped conservatively: anything requiring new ODB schema is explicitly deferred.

Type of Change

  • New feature

Impact

UPF scripts using the added commands now parse and apply instead of erroring; existing flows unaffected.

Verification

  • Local build succeeds.
  • Relevant tests pass (rebuilt from source): ctest -R '^upf\.' 5/5.
  • Code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

Fixes #5617


Developed with SAIGE, Fermions' autonomous RTL/EDA debugging agent; root-caused, tested, and signed off by the submitter (@saurav-fermions).

@saurav-fermions
saurav-fermions requested a review from a team as a code owner June 21, 2026 05:16

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for UPF supply ports, supply nets, and versioning in OpenROAD. Since the odb schema lacks dedicated objects for these constructs, they are persisted as string properties on the block, power domain, or isolation strategy. The changes include new C++ functions, SWIG/Tcl bindings, and integration tests. Feedback is provided regarding connect_supply_net, which currently overwrites the connection property with the last port specified; it should instead append ports to support connecting a supply net to multiple supply ports.

Comment thread src/upf/src/upf.cpp Outdated
}
}

setStringProperty(block, kSupplyNetConnPrefix + net, port);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Currently, connect_supply_net overwrites the connection property kSupplyNetConnPrefix + net with the last port specified. In UPF, a supply net can be connected to multiple supply ports (e.g., via -ports {VDD1 VDD2}). To support multiple port connections correctly, we should append the port to the existing space-separated list of ports instead of overwriting it.

  const std::string conn_prop = kSupplyNetConnPrefix + net;
  odb::dbStringProperty* prop = odb::dbStringProperty::find(block, conn_prop.c_str());
  if (prop != nullptr) {
    std::string existing = prop->getValue();
    if (!existing.empty() && !port.empty()) {
      existing += " " + port;
    } else if (existing.empty()) {
      existing = port;
    }
    prop->setValue(existing.c_str());
  } else {
    odb::dbStringProperty::create(block, conn_prop.c_str(), port.c_str());
  }

@maliberty
maliberty requested review from LucasYuki and removed request for maliberty June 22, 2026 20:25
@maliberty

Copy link
Copy Markdown
Member

Code should be formatted with clang-format

src/upf/src/upf.cpp:84:30: error: code should be clang-formatted [-Wclang-format-violations]
  odb::dbStringProperty* prop = odb::dbStringProperty::find(block, name.c_str());
                             ^
src/upf/src/upf.cpp:220:30: error: code should be clang-formatted [-Wclang-format-violations]
  odb::dbStringProperty* prop

@saurav-fermions
saurav-fermions force-pushed the fix/5617 branch 2 times, most recently from 2958413 to 4d18841 Compare June 23, 2026 04:35
saurav-fermions added a commit to Fermions-ASI/OpenROAD that referenced this pull request Jun 24, 2026
connect_supply_net is invoked once per port (the tcl loops over -ports),
so overwriting the connection property kept only the last port and
silently dropped earlier ones. Store the ports as a space-separated,
de-duplicated list instead, and extend supply.tcl to cover the
multi-port case.

Addresses gemini-code-assist review on The-OpenROAD-Project#10720.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
@saurav-fermions

Copy link
Copy Markdown
Contributor Author

Both addressed: clang-format is clean now, and connect_supply_net appends to a de-duplicated, space-separated list instead of overwriting — the tcl wrapper calls it once per port, so multi-port nets were losing all but the last port. I also extended supply.tcl to cover the multi-port case (it fails on the old overwrite behavior and passes now).

@maliberty

Copy link
Copy Markdown
Member

Needs a tclfmt as well. @LucasYuki I'll leave the functional review to you.

saurav-fermions added a commit to Fermions-ASI/OpenROAD that referenced this pull request Jun 25, 2026
Apply tclfmt (spaces-in-braces) to the test per repo Tcl style.

Addresses @maliberty review on The-OpenROAD-Project#10720.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
@saurav-fermions

Copy link
Copy Markdown
Contributor Author

Done — ran tclfmt on supply.tcl (it's clean now) and rebuilt + re-ran upf.supply, still passing. Thanks @LucasYuki, over to you for the functional review.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 21 days if no further activity occurs. Remove the Stale label or comment to keep it open.

@github-actions github-actions Bot added the Stale A stale PR or issue subject to automated closure. label Aug 24, 2026
@maliberty maliberty removed the Stale A stale PR or issue subject to automated closure. label Aug 24, 2026
@maliberty

Copy link
Copy Markdown
Member

@LucasYuki you need to review

Comment thread src/upf/src/upf.cpp

} // namespace

bool set_upf_version(utl::Logger* logger,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the IEEE 1801-2013 – UPF 2.1 standard.
Could you add a warning to inform the user if the version is different?

Comment thread src/upf/src/upf.tcl
sta::define_cmd_args "create_power_domain" { [-elements elements] name }
sta::define_cmd_args "create_power_domain" { \
[-elements elements] \
[-include_scope] \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In UPF 2.1 this flag is already deprecated.

Comment thread src/upf/src/upf.cpp Outdated
logger->warn(utl::UPF, 84, "Supply net {} already exists", name);
return false;
}
// -reuse: tolerate the redeclaration, refresh the domain association.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reuse flag is for making an existing net available in another domain, not for changing the domain of an existing supply net.
When this flag is used, the domain must be given on both the original command and the -reuse one.

Comment thread src/upf/src/upf.tcl Outdated
[-clamp_value clamp_value] \
[-isolation_signal isolation_signal] \
[-isolation_sense isolation_sense] \
[-isolation_supply isolation_supply] \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option name is isolation_supply_set in UPF 2.1.

Comment thread src/upf/src/upf.tcl Outdated
sta::check_argc_eq1 "create_supply_port" $args

set port_name [lindex $args 0]
set direction ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default direction is "in".

Comment thread src/upf/src/upf.cpp Outdated
const std::string& name,
const std::string& direction)
{
if (!direction.empty() && direction != "in" && direction != "out") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also be "inout".

Comment thread src/upf/src/upf.tcl Outdated
}

if { [llength $ports] == 0 } {
upf::connect_supply_net_cmd $net_name ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no ports, you should raise an error.

Comment thread src/upf/src/upf.cpp Outdated

if (!port.empty()) {
const std::string port_prop = kSupplyPortPrefix + port;
if (odb::dbStringProperty::find(block, port_prop.c_str()) == nullptr) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-ports accepts rooted port names, including design ports and hierarchical names, not just ports declared with create_supply_port.

Comment thread src/upf/src/upf.tcl
proc create_power_domain { args } {
upf::check_block_exists

sta::parse_key_args "create_power_domain" args \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -supply can be used multiple times in the same command and sta::parse_key_args does not support this.
To parse this option, you can do the following modifications:

  ord::parse_list_args "create_power_domain" args list {-supply}
  sta::parse_key_args "create_power_domain" args \
    keys {-elements} flags {-include_scope}
  ...
  foreach supply_arg $list(-supply) {
    if { [llength $supply_arg] < 1 || [llength $supply_arg] > 2 } {
      utl::error UPF 89 \
        "-supply expects {supply_set_handle \[supply_set_ref\]}, got {$supply_arg}"
    }
    lassign [upf::process_list_arg $supply_arg 2] handle ref
    upf::set_power_domain_supply_cmd $domain_name $handle $ref
  }

…enROAD-Project#5617)

Implements a conservative, tested subset of the missing UPF surface from
issue The-OpenROAD-Project#5617 that maps onto existing odb structures without a schema bump:

New commands:
  - upf_version        (validate known versions, store as block property)
  - create_supply_port (store as block string-property)
  - create_supply_net  (store as block property, supports -domain/-reuse)
  - connect_supply_net (validate net/port refs, store connection)

New options on existing commands:
  - create_power_domain -include_scope (maps to '.' element) and -supply
    (stored as a property on the domain)
  - set_isolation -isolation_supply / -source / -sink (stored as
    properties on the dbIsolation object)

Supply-net/port constructs have no dedicated odb object, so they are
persisted via the generic dbStringProperty mechanism, keeping them
queryable and round-trippable through DB save/load without new schema.

PST, create_supply_set, set_port_attributes, and add_port_state are
deferred (they require new odb schema). See AGENT_REPORT.md.

Adds src/upf/test/supply.tcl exercising all new commands/options and
asserting the resulting odb state, registered in both CMake and Bazel.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
connect_supply_net is invoked once per port (the tcl loops over -ports),
so overwriting the connection property kept only the last port and
silently dropped earlier ones. Store the ports as a space-separated,
de-duplicated list instead, and extend supply.tcl to cover the
multi-port case.

Addresses gemini-code-assist review on The-OpenROAD-Project#10720.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
Apply tclfmt (spaces-in-braces) to the test per repo Tcl style.

Addresses @maliberty review on The-OpenROAD-Project#10720.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
Address review feedback on the supply-net support:

- upf_version: warn (UPF-0080) when the version is not 2.1, the
  IEEE 1801-2013 revision OpenROAD implements.
- create_power_domain: -supply may be given multiple times (parsed with
  ord::parse_list_args); each {handle [ref]} is validated (UPF-0089)
  and stored per handle. -include_scope is deprecated in UPF 2.1 and
  now warns (UPF-0090) while still mapping to the '.' element.
- create_supply_port: default -direction is in; inout is accepted.
- create_supply_net -reuse: makes an existing net available in another
  domain instead of changing its domain. -domain is required with
  -reuse (UPF-0092), the net must exist (UPF-0093) and must have been
  created with -domain (UPF-0094).
- connect_supply_net: -ports is required (UPF-0091) and accepts rooted
  names: supply ports, design ports, leaf instance pins and
  hierarchical module-instance ports.
- set_isolation: rename -isolation_supply to the UPF 2.1 option
  -isolation_supply_set.
- Include Exception.i in upf.i so errors raised from C++ become Tcl
  errors.

Extend upf.supply and add upf.supply_hier to cover these behaviors.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
Add README entries for upf_version, create_supply_port,
create_supply_net and connect_supply_net, and for the new
create_power_domain and set_isolation options, so the man/Tcl
command-count doc check matches. Update the readme message check
golden accordingly.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
@saurav-fermions

Copy link
Copy Markdown
Contributor Author

@LucasYuki sorry for the churn. A force-push landed on this branch before I was ready, and it rewrote the history you reviewed, so "changes since last review" won't line up.

I'm still checking the changes against your comments. I'll follow up here with a point-by-point reply once that's done, so it's probably not worth re-reviewing until then.

The supported version is IEEE 1801-2013 (UPF 2.1); the inline comment
still cited 2.0 as the example.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
@saurav-fermions

Copy link
Copy Markdown
Contributor Author

@LucasYuki following up. All nine points are addressed in d7d9c7f and e88a882 (plus a one-line comment fix in 8b6ff60).

  1. upf_version: anything other than 2.1 warns (UPF-0080).
  2. -include_scope: still accepted with a deprecation warning, treated as -elements {.}. Happy to remove it instead.
  3. -supply: repeatable, parsed with ord::parse_list_args.
  4. inout is accepted.
  5. Default direction is in.
  6. -reuse now adds the net to another domain and keeps the original. -domain is required on both commands.
  7. -ports accepts supply ports, design ports, leaf pins and hierarchical module ports.
  8. No ports is an error.
  9. Renamed to -isolation_supply_set.

UPF-related tests pass (14/14) and formatting is clean. I haven't run Bazel.

Resolve the two conflicts:
- src/upf/test/CMakeLists.txt: master removed the CMake build; the supply and
  supply_hier tests stay registered in src/upf/test/BUILD.
- src/upf/src/upf.i: master now includes Exception.i itself, the same include
  this branch added.

Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
@saurav-fermions

Copy link
Copy Markdown
Contributor Author

Merged current master (which removed the CMake build) into this branch. Two trivial conflicts, no change to the code you reviewed. CI is green again, including Mac-Build.

@LucasYuki, could you take another look when you have a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing UPF commands and options

3 participants