Conversation
Signed-off-by: Bbn08 <atrancendentbeing@gmail.com>
…efok Signed-off-by: Bbn08 <atrancendentbeing@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for secondary ground nets in voltage domains, which is a valuable addition for designs with multiple ground rails. The changes are well-implemented across the C++ code, SWIG interface, and TCL commands. The logic for ordering nets in VoltageDomain::getNets() has been correctly updated to primary power -> secondary power(s) -> secondary ground(s) -> primary ground. The introduction of PdnGen::run is a good refactoring that encapsulates the grid generation process and adds timing information. I've included a couple of suggestions to reduce code duplication, which would improve maintainability.
src/pdn/src/domain.cpp
Outdated
| if (!secondary_power_.empty()) { | ||
| std::string nets; | ||
| for (auto* net : secondary_power_) { | ||
| nets += net->getName() + " "; | ||
| } | ||
| logger_->report(" Secondary power nets: {}", nets); | ||
| } | ||
|
|
||
| if (!secondary_ground_.empty()) { | ||
| std::string nets; | ||
| for (auto* net : secondary_) { | ||
| for (auto* net : secondary_ground_) { | ||
| nets += net->getName() + " "; | ||
| } | ||
| logger_->report(" Secondary nets: {}", nets); | ||
| logger_->report(" Secondary ground nets: {}", nets); | ||
| } |
There was a problem hiding this comment.
The logic for reporting secondary power and ground nets is duplicated. This can be refactored into a helper function to avoid repetition and improve readability. According to repository guidelines, helper logic should be defined as a free function in a namespace rather than as a local lambda within a function.
References
- Helper logic should be defined as a free function in a namespace rather than as a local lambda within a function.
There was a problem hiding this comment.
Refactored into a reportSecondaryNets() free function in an anonymous namespace.
src/pdn/src/pdn.tcl
Outdated
| # Collect secondary power nets (placed between primary power and ground). | ||
| set secondary_power {} | ||
| if { [info exists keys(-secondary_power)] } { | ||
| foreach snet $keys(-secondary_power) { | ||
| set db_net [[ord::get_db_block] findNet $snet] | ||
| if { $db_net == "NULL" } { | ||
| utl::error PDN 1006 "Unable to find secondary power net: $snet" | ||
| } else { | ||
| lappend secondary $db_net | ||
| lappend secondary_power $db_net | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Collect secondary ground nets (placed between secondary power and primary | ||
| # ground). | ||
| set secondary_ground {} | ||
| if { [info exists keys(-secondary_ground)] } { | ||
| foreach snet $keys(-secondary_ground) { | ||
| set db_net [[ord::get_db_block] findNet $snet] | ||
| if { $db_net == "NULL" } { | ||
| utl::error PDN 1007 "Unable to find secondary ground net: $snet" | ||
| } else { | ||
| lappend secondary_ground $db_net | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
There was a problem hiding this comment.
Extracted into a pdn::collect_secondary_nets helper proc shared by both secondary power and ground collection
Signed-off-by: Bbn08 <atrancendentbeing@gmail.com>
| void reportSecondaryNets(utl::Logger* logger, | ||
| const char* label, | ||
| const std::vector<odb::dbNet*>& nets) | ||
| { | ||
| if (nets.empty()) { | ||
| return; | ||
| } | ||
| std::string names; | ||
| for (auto* net : nets) { | ||
| names += net->getName() + " "; | ||
| } | ||
| logger->report(" Secondary {} nets: {}", label, names); | ||
| } | ||
| } // namespace |
There was a problem hiding this comment.
I think you can just make a loop in the reporting function to avoid needing to add this function.
| foreach snet $net_names { | ||
| set db_net [[ord::get_db_block] findNet $snet] | ||
| if { $db_net == "NULL" } { | ||
| utl::error PDN $err_id "Unable to find secondary $type_label net: $snet" |
There was a problem hiding this comment.
I would avoid the use of a variable for the err_id since that will not be detectable by the id parser.
| utl::Timer timer; | ||
| buildGrids(trim); | ||
| writeToDb(add_pins, report_file); | ||
| logger_->info(utl::PDN, 500, "Runtime: {:.2f}s", timer.elapsed()); |
There was a problem hiding this comment.
I like this function, but I think we need to resolve the formatting question before adding the timer code here.
| nets.push_back(power_); | ||
| } | ||
|
|
||
| nets.insert(nets.end(), secondary_.begin(), secondary_.end()); |
There was a problem hiding this comment.
I think it will be okay, but I'm a little worried about reordering of the nets for folks who are currently expecting the current order.
| updateRenderer(); | ||
| } | ||
|
|
||
| void PdnGen::run(bool trim, bool add_pins, const std::string& report_file) |
There was a problem hiding this comment.
warning: no header providing "std::string" is directly included [misc-include-cleaner]
src/pdn/src/PdnGen.cc:12:
- #include <utility>
+ #include <string>
+ #include <utility>
As per your request i have moved the PDN to its own pr @maliberty.
Added
-secondary_groundparameter toset_voltage_domainfor designs with secondary ground rails (e.g. VSSA).Also fixes
VoltageDomain::getNets()which was placing secondary nets after ground instead of between primary power and ground. Correct order is:primary power → secondary power(s) → secondary ground(s) → primary ground
Two regression tests added;
CMakeListsregistration pending.defokgeneration.