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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gpl/src/graphicsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void GraphicsImpl::initHeatmap()
}
});

setBlock(pbc_->db()->getChip()->getBlock());
setChip(pbc_->db()->getChip());
registerHeatMap();
}

Expand Down
11 changes: 8 additions & 3 deletions src/gui/include/gui/heatMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace odb {
class dbBlock;
class dbChip;
class Rect;
} // namespace odb

Expand Down Expand Up @@ -73,7 +74,7 @@ class HeatMapDataSource

void registerHeatMap();

virtual void setBlock(odb::dbBlock* block) { block_ = block; }
virtual void setChip(odb::dbChip* chip) { chip_ = chip; }
void setUseDBU(bool use_dbu) { use_dbu_ = use_dbu; }

HeatMapRenderer* getRenderer() { return renderer_.get(); }
Expand Down Expand Up @@ -139,7 +140,11 @@ class HeatMapDataSource
virtual double getGridSizeMaximumValue() const { return 100.0; }
// The default implementation uses the block's bounds
virtual odb::Rect getBounds() const;
odb::dbBlock* getBlock() const { return block_; }
odb::dbChip* getChip() const { return chip_; }
odb::dbBlock* getBlock() const
{
return chip_ != nullptr ? chip_->getBlock() : nullptr;
}

// map controls
void update() { destroyMap(); }
Expand Down Expand Up @@ -216,7 +221,7 @@ class HeatMapDataSource
bool colors_correct_;
bool issue_redraw_;

odb::dbBlock* block_;
odb::dbChip* chip_;
utl::Logger* logger_;
double grid_x_size_;
double grid_y_size_;
Expand Down
28 changes: 19 additions & 9 deletions src/gui/src/heatMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ HeatMapDataSource::HeatMapDataSource(utl::Logger* logger,
populated_(false),
colors_correct_(false),
issue_redraw_(true),
block_(nullptr),
chip_(nullptr),
logger_(logger),
grid_x_size_(10.0),
grid_y_size_(10.0),
Expand Down Expand Up @@ -89,12 +89,17 @@ void HeatMapDataSource::dumpToFile(const std::string& file)
logger_->error(utl::GUI, 72, "\"{}\" is not populated with data.", name_);
}

if (getChip() == nullptr) {
logger_->error(utl::GUI, 82, "No chip available for \"{}\".", name_);
return;
}

std::ofstream csv(file);
if (!csv.is_open()) {
logger_->error(utl::GUI, 73, "Unable to open {}", file);
}

const double dbu_to_micron = block_->getDbUnitsPerMicron();
const double dbu_to_micron = getChip()->getDb()->getDbuPerMicron();

csv << "x0,y0,x1,y1,value (" << getValueUnits() << ")\n";
for (const auto& map_col : map_) {
Expand Down Expand Up @@ -227,15 +232,15 @@ Painter::Color HeatMapDataSource::getColor(double value) const

void HeatMapDataSource::showSetup()
{
if (block_ == nullptr) {
if (chip_ == nullptr) {
return;
}

if (setup_ == nullptr) {
setup_ = new HeatMapSetup(*this,
QString::fromStdString(name_),
use_dbu_,
block_->getDbUnitsPerMicron());
getChip()->getDb()->getDbuPerMicron());

QObject::connect(setup_, &QDialog::finished, &QObject::deleteLater);
QObject::connect(
Expand Down Expand Up @@ -392,6 +397,9 @@ void HeatMapDataSource::addToMap(const odb::Rect& region, double value)

odb::Rect HeatMapDataSource::getBounds() const
{
if (getBlock() == nullptr) {
return getChip()->getBBox();
}
return getBlock()->getDieArea();
}

Expand All @@ -404,7 +412,7 @@ void HeatMapDataSource::clearMap()

bool HeatMapDataSource::setupMap()
{
if (getBlock() == nullptr || getBlock()->getDieArea().area() == 0) {
if (getChip() == nullptr || getBounds().area() == 0) {
return false;
}

Expand Down Expand Up @@ -447,8 +455,9 @@ bool HeatMapDataSource::setupMap()

void HeatMapDataSource::populateXYGrid()
{
const int dx = getGridXSize() * getBlock()->getDbUnitsPerMicron();
const int dy = getGridYSize() * getBlock()->getDbUnitsPerMicron();
const int dbu_per_micron = getChip()->getDb()->getDbuPerMicron();
const int dx = getGridXSize() * dbu_per_micron;
const int dy = getGridYSize() * dbu_per_micron;

const odb::Rect bounds = getBounds();

Expand Down Expand Up @@ -723,7 +732,8 @@ void HeatMapRenderer::drawObjects(Painter& painter)
// minimum box size is 2 pixels
const double min_dbu = 2.0 / painter.getPixelsPerDBU();

const double dbu_per_micron = datasource_.getBlock()->getDbUnitsPerMicron();
const double dbu_per_micron
= datasource_.getChip()->getDb()->getDbuPerMicron();
const int x_scale
= std::ceil(min_dbu / (datasource_.getGridXSize() * dbu_per_micron));
const int y_scale
Expand Down Expand Up @@ -1025,7 +1035,7 @@ std::pair<double, double> GlobalRoutingDataSource::getReportableXYGrid() const
const double y_grid = grid_mode(gcell_grid->getNumGridPatternsY(),
&odb::dbGCellGrid::getGridPatternY);

const double dbus = getBlock()->getDbUnitsPerMicron();
const double dbus = getChip()->getDb()->getDbuPerMicron();
return {x_grid / dbus, y_grid / dbus};
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ void MainWindow::setBlock(odb::dbBlock* block)
save_->setEnabled(true);
}
for (auto* heat_map : Gui::get()->getHeatMaps()) {
heat_map->setBlock(block);
heat_map->setChip(block != nullptr ? block->getChip() : nullptr);
}
hierarchy_widget_->setBlock(block);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/stub_heatMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HeatMapDataSource::HeatMapDataSource(utl::Logger* logger,
populated_(false),
colors_correct_(false),
issue_redraw_(true),
block_(nullptr),
chip_(nullptr),
logger_(logger),
grid_x_size_(10.0),
grid_y_size_(10.0),
Expand Down
14 changes: 7 additions & 7 deletions src/psm/src/heatMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ IRDropDataSource::IRDropDataSource(PDNSim* psm,
[this](const std::string& value) { setCorner(value); });
}

void IRDropDataSource::setBlock(odb::dbBlock* block)
void IRDropDataSource::setChip(odb::dbChip* chip)
{
if (block && block->getParent()) {
return; // not the top block so ignore it
}
gui::HeatMapDataSource::setBlock(block);
if (block != nullptr) {
tech_ = block->getTech();
gui::HeatMapDataSource::setChip(chip);
if (chip != nullptr) {
odb::dbBlock* block = chip->getBlock();
tech_ = block != nullptr ? block->getTech() : nullptr;
} else {
tech_ = nullptr;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/psm/src/heatMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IRDropDataSource : public gui::RealValueHeatMapDataSource
public:
IRDropDataSource(PDNSim* psm, sta::Sta* sta, utl::Logger* logger);

void setBlock(odb::dbBlock* block) override;
void setChip(odb::dbChip* chip) override;

void setNet(odb::dbNet* net) { net_ = net; }
void setCorner(sta::Scene* corner) { corner_ = corner; }
Expand Down
Loading