Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/pdn/include/pdn/PdnGen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,18 @@ class PdnGen
void setCoreDomain(odb::dbNet* power,
odb::dbNet* switched_power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary);
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground);
void makeRegionVoltageDomain(const std::string& name,
odb::dbNet* power,
odb::dbNet* switched_power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_nets,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
odb::dbRegion* region);

// Grids
void run(bool trim, bool add_pins, const std::string& report_file);
void buildGrids(bool trim);
std::vector<Grid*> findGrid(const std::string& name) const;
void makeCoreGrid(VoltageDomain* domain,
Expand Down
30 changes: 24 additions & 6 deletions src/pdn/src/PdnGen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "straps.h"
#include "techlayer.h"
#include "utl/Logger.h"
#include "utl/timer.h"
#include "via.h"
#include "via_repair.h"

Expand Down Expand Up @@ -58,6 +59,14 @@ void PdnGen::resetShapes()
updateRenderer();
}

void PdnGen::run(bool trim, bool add_pins, const std::string& report_file)
{
utl::Timer timer;
buildGrids(trim);
writeToDb(add_pins, report_file);
logger_->info(utl::PDN, 500, "Runtime: {:.2f}s", timer.elapsed());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this function, but I think we need to resolve the formatting question before adding the timer code here.

}

void PdnGen::buildGrids(bool trim)
{
debugPrint(logger_, utl::PDN, "Make", 1, "Build - begin");
Expand Down Expand Up @@ -254,7 +263,7 @@ VoltageDomain* PdnGen::getCoreDomain() const
void PdnGen::ensureCoreDomain()
{
if (core_domain_ == nullptr) {
setCoreDomain(nullptr, nullptr, nullptr, {});
setCoreDomain(nullptr, nullptr, nullptr, {}, {});
}
}

Expand Down Expand Up @@ -291,14 +300,15 @@ VoltageDomain* PdnGen::findDomain(const std::string& name)
void PdnGen::setCoreDomain(odb::dbNet* power,
odb::dbNet* switched_power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary)
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground)
{
auto* block = db_->getChip()->getBlock();
if (core_domain_ != nullptr) {
logger_->warn(utl::PDN, 183, "Replacing existing core voltage domain.");
}
core_domain_ = std::make_unique<VoltageDomain>(
this, block, power, ground, secondary, logger_);
this, block, power, ground, secondary_power, secondary_ground, logger_);

if (importUPF(core_domain_.get())) {
if (switched_power) {
Expand All @@ -315,7 +325,8 @@ void PdnGen::makeRegionVoltageDomain(
odb::dbNet* power,
odb::dbNet* switched_power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_nets,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
odb::dbRegion* region)
{
if (region == nullptr) {
Expand All @@ -331,8 +342,15 @@ void PdnGen::makeRegionVoltageDomain(
}
}
auto* block = db_->getChip()->getBlock();
auto domain = std::make_unique<VoltageDomain>(
this, name, block, power, ground, secondary_nets, region, logger_);
auto domain = std::make_unique<VoltageDomain>(this,
name,
block,
power,
ground,
secondary_power,
secondary_ground,
region,
logger_);

if (importUPF(domain.get())) {
if (switched_power) {
Expand Down
27 changes: 23 additions & 4 deletions src/pdn/src/PdnGen.i
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,29 @@ using utl::PDN;

namespace pdn {

void set_core_domain(odb::dbNet* power, odb::dbNet* switched_power, odb::dbNet* ground, const std::vector<odb::dbNet*>& secondary_nets)
void set_core_domain(odb::dbNet* power,
odb::dbNet* switched_power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground)
{
PdnGen* pdngen = ord::getPdnGen();
pdngen->setCoreDomain(power, switched_power, ground, secondary_nets);
pdngen->setCoreDomain(
power, switched_power, ground, secondary_power, secondary_ground);
}

void make_region_domain(const char* name, odb::dbNet* power, odb::dbNet* switched_power, odb::dbNet* ground, const std::vector<odb::dbNet*>& secondary_nets, odb::dbRegion* region)
void make_region_domain(const char* name,
odb::dbNet* power,
odb::dbNet* switched_power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
odb::dbRegion* region)
{
PdnGen* pdngen = ord::getPdnGen();
pdngen->makeRegionVoltageDomain(name, power, switched_power, ground, secondary_nets, region);
pdngen->makeRegionVoltageDomain(
name, power, switched_power, ground, secondary_power, secondary_ground,
region);
}

void reset()
Expand All @@ -68,6 +81,12 @@ void reset_shapes()
pdngen->resetShapes();
}

void run_pdngen(bool trim, bool add_pins, const char* report_file)
{
PdnGen* pdngen = ord::getPdnGen();
pdngen->run(trim, add_pins, report_file);
}

void build_grids(bool trim = true)
{
PdnGen* pdngen = ord::getPdnGen();
Expand Down
53 changes: 39 additions & 14 deletions src/pdn/src/domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,37 @@

namespace pdn {

namespace {
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
Comment on lines +22 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can just make a loop in the reporting function to avoid needing to add this function.


VoltageDomain::VoltageDomain(PdnGen* pdngen,
odb::dbBlock* block,
odb::dbNet* power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_nets,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
utl::Logger* logger)
: name_("Core"),
pdngen_(pdngen),
block_(block),
power_(power),
switched_power_(nullptr),
ground_(ground),
secondary_(secondary_nets),
secondary_power_(secondary_power),
secondary_ground_(secondary_ground),
region_(nullptr),
logger_(logger)
{
Expand All @@ -42,7 +60,8 @@ VoltageDomain::VoltageDomain(PdnGen* pdngen,
odb::dbBlock* block,
odb::dbNet* power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_nets,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
odb::dbRegion* region,
utl::Logger* logger)
: name_(name),
Expand All @@ -51,7 +70,8 @@ VoltageDomain::VoltageDomain(PdnGen* pdngen,
power_(power),
switched_power_(nullptr),
ground_(ground),
secondary_(secondary_nets),
secondary_power_(secondary_power),
secondary_ground_(secondary_ground),
region_(region),
logger_(logger)
{
Expand All @@ -75,21 +95,31 @@ std::vector<odb::dbNet*> VoltageDomain::getNets(bool start_with_power) const
std::vector<odb::dbNet*> nets;

if (start_with_power) {
// Order: primary power, switched power, secondary power nets,
// secondary ground nets, primary ground.
// This groups all supply rails together before the ground rails,
// fixing the ordering issue for multi-rail designs (e.g., VDDA, VDD, VSS).
nets.push_back(power_);
if (switched_power_ != nullptr) {
nets.push_back(switched_power_);
}
nets.insert(nets.end(), secondary_power_.begin(), secondary_power_.end());
nets.insert(
nets.end(), secondary_ground_.begin(), secondary_ground_.end());
nets.push_back(ground_);
} else {
// Reverse order: primary ground, secondary ground nets,
// secondary power nets, switched power, primary power.
nets.push_back(ground_);
nets.push_back(power_);
nets.insert(
nets.end(), secondary_ground_.begin(), secondary_ground_.end());
nets.insert(nets.end(), secondary_power_.begin(), secondary_power_.end());
if (switched_power_ != nullptr) {
nets.push_back(switched_power_);
}
nets.push_back(power_);
}

nets.insert(nets.end(), secondary_.begin(), secondary_.end());
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.


return nets;
}

Expand Down Expand Up @@ -210,13 +240,8 @@ void VoltageDomain::report() const
logger_->report(" Switched power net: {}", switched_power_->getName());
}

if (!secondary_.empty()) {
std::string nets;
for (auto* net : secondary_) {
nets += net->getName() + " ";
}
logger_->report(" Secondary nets: {}", nets);
}
reportSecondaryNets(logger_, "power", secondary_power_);
reportSecondaryNets(logger_, "ground", secondary_ground_);

for (const auto& grid : grids_) {
grid->report();
Expand Down
20 changes: 17 additions & 3 deletions src/pdn/src/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ class VoltageDomain
odb::dbBlock* block,
odb::dbNet* power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_nets,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
odb::dbRegion* region,
utl::Logger* logger);

VoltageDomain(PdnGen* pdngen,
odb::dbBlock* block,
odb::dbNet* power,
odb::dbNet* ground,
const std::vector<odb::dbNet*>& secondary_nets,
const std::vector<odb::dbNet*>& secondary_power,
const std::vector<odb::dbNet*>& secondary_ground,
utl::Logger* logger); // Core

const std::string& getName() const { return name_; }
Expand All @@ -54,6 +56,14 @@ class VoltageDomain
odb::dbNet* getGround() const { return ground_; }
odb::dbNet* getAlwaysOnPower() const { return power_; }
odb::dbNet* getSwitchedPower() const { return switched_power_; }
const std::vector<odb::dbNet*>& getSecondaryPower() const
{
return secondary_power_;
}
const std::vector<odb::dbNet*>& getSecondaryGround() const
{
return secondary_ground_;
}

void setSwitchedPower(odb::dbNet* switched_power)
{
Expand All @@ -62,6 +72,9 @@ class VoltageDomain
bool hasSwitchedPower() const { return switched_power_ != nullptr; }

// returns the order in which the nets should be arranged in the grid shapes
// ordering: [power, switched_power?, ...secondary_power,
// ...secondary_ground, ground] when start_with_power is true,
// and the reverse when false.
std::vector<odb::dbNet*> getNets(bool start_with_power = true) const;

bool hasRegion() const { return region_ != nullptr; }
Expand Down Expand Up @@ -90,7 +103,8 @@ class VoltageDomain
odb::dbNet* power_;
odb::dbNet* switched_power_;
odb::dbNet* ground_;
std::vector<odb::dbNet*> secondary_;
std::vector<odb::dbNet*> secondary_power_;
std::vector<odb::dbNet*> secondary_ground_;

odb::dbRegion* region_;

Expand Down
Loading