ram: Enable optional user-provided name for power rails#10572
Conversation
Signed-off-by: Thinh Nguyen <nguyenthinh19011@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for custom power and ground net names in the RAM generator by introducing the optional -power_net_name and -ground_net_name arguments (defaulting to VDD and VSS). These parameters are propagated from the TCL interface down to the C++ implementation. Feedback on the changes suggests adding defensive checks in the C++ code to handle null or empty net names and to look up existing nets before creation, preventing potential segmentation faults.
| auto power_net = dbNet::create(block_, power_net_name); | ||
| auto ground_net = dbNet::create(block_, ground_net_name); |
There was a problem hiding this comment.
To prevent potential crashes (segmentation faults) if power_net_name or ground_net_name are null/empty, or if the nets already exist in the block (in which case dbNet::create returns nullptr), we should defensively check for null/empty names, try to find the existing nets first, and verify that the nets were successfully retrieved or created before using them.
if (power_net_name == nullptr || power_net_name[0] == '\0') {
power_net_name = "VDD";
}
if (ground_net_name == nullptr || ground_net_name[0] == '\0') {
ground_net_name = "VSS";
}
auto power_net = block_->findNet(power_net_name);
if (!power_net) {
power_net = dbNet::create(block_, power_net_name);
}
auto ground_net = block_->findNet(ground_net_name);
if (!ground_net) {
ground_net = dbNet::create(block_, ground_net_name);
}
if (!power_net) {
logger_->error(RAM, 38, "Failed to find or create power net: {}", power_net_name);
}
if (!ground_net) {
logger_->error(RAM, 39, "Failed to find or create ground net: {}", ground_net_name);
}Signed-off-by: Thinh Nguyen <nguyenthinh19011@gmail.com>
…rguments Signed-off-by: Thinh Nguyen <nguyenthinh19011@gmail.com>
Signed-off-by: Thinh Nguyen <nguyenthinh19011@gmail.com>
Summary
Allow users to change the names of power rails or leave as default (
power_net=VDD,ground_net=VSS). README.md is also updated to include information on this changeType of Change
Impact
Allow user-defined name for power rails
Verification
./etc/Build.sh).Related Issues
Fixes #10563
@rovinski