Skip to content

Commit

Permalink
Merge pull request #5991 from gadfort/bpin-desc
Browse files Browse the repository at this point in the history
gui: add bpin descriptor
  • Loading branch information
maliberty authored Oct 21, 2024
2 parents 9ca8405 + 611e241 commit 01ca374
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
111 changes: 111 additions & 0 deletions src/gui/src/dbDescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,14 @@ Descriptor::Properties DbBTermDescriptor::getProperties(std::any object) const
props.push_back({"Constraint Region", constraint.value()});
}

SelectionSet pins;
for (auto* pin : bterm->getBPins()) {
pins.insert(gui->makeSelected(pin));
}
if (!pins.empty()) {
props.push_back({"Pins", pins});
}

populateODBProperties(props, bterm);

return props;
Expand Down Expand Up @@ -1890,6 +1898,109 @@ bool DbBTermDescriptor::getAllObjects(SelectionSet& objects) const

//////////////////////////////////////////////////

DbBPinDescriptor::DbBPinDescriptor(odb::dbDatabase* db) : db_(db)
{
}

std::string DbBPinDescriptor::getName(std::any object) const
{
odb::dbBPin* pin = std::any_cast<odb::dbBPin*>(object);
return pin->getBTerm()->getName();
}

std::string DbBPinDescriptor::getTypeName() const
{
return "BPin";
}

bool DbBPinDescriptor::getBBox(std::any object, odb::Rect& bbox) const
{
auto* bpin = std::any_cast<odb::dbBPin*>(object);
bbox = bpin->getBBox();
return !bbox.isInverted();
}

void DbBPinDescriptor::highlight(std::any object, Painter& painter) const
{
auto* bpin = std::any_cast<odb::dbBPin*>(object);
for (auto box : bpin->getBoxes()) {
odb::Rect rect = box->getBox();
painter.drawRect(rect);
}
}

Descriptor::Properties DbBPinDescriptor::getProperties(std::any object) const
{
auto gui = Gui::get();
auto bpin = std::any_cast<odb::dbBPin*>(object);
SelectionSet aps;
for (auto ap : bpin->getAccessPoints()) {
DbTermAccessPoint bap{ap, bpin->getBTerm()};
aps.insert(gui->makeSelected(bap));
}
Properties props{{"BTerm", gui->makeSelected(bpin->getBTerm())},
{"Placement status", bpin->getPlacementStatus().getString()},
{"Access points", aps}};

PropertyList boxes;
for (auto* box : bpin->getBoxes()) {
auto* layer = box->getTechLayer();
if (layer != nullptr) {
boxes.push_back({gui->makeSelected(box->getTechLayer()), box->getBox()});
}
}
props.push_back({"Boxes", boxes});

if (bpin->hasEffectiveWidth()) {
props.push_back(
{"Effective width", convertUnits(bpin->getEffectiveWidth())});
}

if (bpin->hasMinSpacing()) {
props.push_back({"Min spacing", convertUnits(bpin->getMinSpacing())});
}

populateODBProperties(props, bpin);

return props;
}

Selected DbBPinDescriptor::makeSelected(std::any object) const
{
if (auto bpin = std::any_cast<odb::dbBPin*>(&object)) {
return Selected(*bpin, this);
}
return Selected();
}

bool DbBPinDescriptor::lessThan(std::any l, std::any r) const
{
auto l_bpin = std::any_cast<odb::dbBPin*>(l);
auto r_bpin = std::any_cast<odb::dbBPin*>(r);
return l_bpin->getId() < r_bpin->getId();
}

bool DbBPinDescriptor::getAllObjects(SelectionSet& objects) const
{
auto* chip = db_->getChip();
if (chip == nullptr) {
return false;
}
auto* block = chip->getBlock();
if (block == nullptr) {
return false;
}

for (auto* term : block->getBTerms()) {
for (auto* pin : term->getBPins()) {
objects.insert(makeSelected(pin));
}
}
return true;
}

//////////////////////////////////////////////////

DbMTermDescriptor::DbMTermDescriptor(
odb::dbDatabase* db,
std::function<bool(void)> usingPolyDecompView)
Expand Down
21 changes: 21 additions & 0 deletions src/gui/src/dbDescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,27 @@ class DbBTermDescriptor : public Descriptor
odb::dbDatabase* db_;
};

class DbBPinDescriptor : public Descriptor
{
public:
DbBPinDescriptor(odb::dbDatabase* db);

std::string getName(std::any object) const override;
std::string getTypeName() const override;
bool getBBox(std::any object, odb::Rect& bbox) const override;

void highlight(std::any object, Painter& painter) const override;

Properties getProperties(std::any object) const override;
Selected makeSelected(std::any object) const override;
bool lessThan(std::any l, std::any r) const override;

bool getAllObjects(SelectionSet& objects) const override;

private:
odb::dbDatabase* db_;
};

class DbMTermDescriptor : public Descriptor
{
public:
Expand Down
1 change: 1 addition & 0 deletions src/gui/src/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ void MainWindow::init(sta::dbSta* sta)
gui->registerDescriptor<odb::dbMTerm*>(new DbMTermDescriptor(
db_, [this]() -> bool { return show_poly_decomp_view_->isChecked(); }));
gui->registerDescriptor<odb::dbBTerm*>(new DbBTermDescriptor(db_));
gui->registerDescriptor<odb::dbBPin*>(new DbBPinDescriptor(db_));
gui->registerDescriptor<odb::dbVia*>(new DbViaDescriptor(db_));
gui->registerDescriptor<odb::dbBlockage*>(new DbBlockageDescriptor(db_));
gui->registerDescriptor<odb::dbObstruction*>(
Expand Down

0 comments on commit 01ca374

Please sign in to comment.