From 611e241ff12b4e5fafbf5a2444f723f4229c6f63 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 21 Oct 2024 15:39:20 -0400 Subject: [PATCH] gui: add bpin descriptor Signed-off-by: Peter Gadfort --- src/gui/src/dbDescriptors.cpp | 111 ++++++++++++++++++++++++++++++++++ src/gui/src/dbDescriptors.h | 21 +++++++ src/gui/src/mainWindow.cpp | 1 + 3 files changed, 133 insertions(+) diff --git a/src/gui/src/dbDescriptors.cpp b/src/gui/src/dbDescriptors.cpp index f4c2d54f363..c6f1644c02f 100644 --- a/src/gui/src/dbDescriptors.cpp +++ b/src/gui/src/dbDescriptors.cpp @@ -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; @@ -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(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(object); + bbox = bpin->getBBox(); + return !bbox.isInverted(); +} + +void DbBPinDescriptor::highlight(std::any object, Painter& painter) const +{ + auto* bpin = std::any_cast(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(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(&object)) { + return Selected(*bpin, this); + } + return Selected(); +} + +bool DbBPinDescriptor::lessThan(std::any l, std::any r) const +{ + auto l_bpin = std::any_cast(l); + auto r_bpin = std::any_cast(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 usingPolyDecompView) diff --git a/src/gui/src/dbDescriptors.h b/src/gui/src/dbDescriptors.h index 3443049b3ac..34c3eb1dd12 100644 --- a/src/gui/src/dbDescriptors.h +++ b/src/gui/src/dbDescriptors.h @@ -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: diff --git a/src/gui/src/mainWindow.cpp b/src/gui/src/mainWindow.cpp index 8d62b784695..51e957182bf 100644 --- a/src/gui/src/mainWindow.cpp +++ b/src/gui/src/mainWindow.cpp @@ -494,6 +494,7 @@ void MainWindow::init(sta::dbSta* sta) gui->registerDescriptor(new DbMTermDescriptor( db_, [this]() -> bool { return show_poly_decomp_view_->isChecked(); })); gui->registerDescriptor(new DbBTermDescriptor(db_)); + gui->registerDescriptor(new DbBPinDescriptor(db_)); gui->registerDescriptor(new DbViaDescriptor(db_)); gui->registerDescriptor(new DbBlockageDescriptor(db_)); gui->registerDescriptor(