Skip to content

Commit 76d83a8

Browse files
committed
gui: add descriptor for dbScanInst
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
1 parent 488aa83 commit 76d83a8

5 files changed

Lines changed: 126 additions & 0 deletions

File tree

src/gui/src/dbDescriptors.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,4 +4216,94 @@ void DbMarkerDescriptor::paintMarker(odb::dbMarker* marker,
42164216
}
42174217
}
42184218

4219+
//////////////////////////////////////////////////
4220+
4221+
DbScanInstDescriptor::DbScanInstDescriptor(odb::dbDatabase* db)
4222+
: BaseDbDescriptor<odb::dbScanInst>(db)
4223+
{
4224+
}
4225+
4226+
std::string DbScanInstDescriptor::getName(std::any object) const
4227+
{
4228+
auto* scan_inst = std::any_cast<odb::dbScanInst*>(object);
4229+
auto* inst = scan_inst->getInst();
4230+
return "(Scan) " + inst->getName();
4231+
}
4232+
4233+
std::string DbScanInstDescriptor::getTypeName() const
4234+
{
4235+
return "Scan Inst";
4236+
}
4237+
4238+
bool DbScanInstDescriptor::getBBox(std::any object, odb::Rect& bbox) const
4239+
{
4240+
auto* scan_inst = std::any_cast<odb::dbScanInst*>(object);
4241+
auto* inst = scan_inst->getInst();
4242+
bbox = inst->getBBox()->getBox();
4243+
return true;
4244+
}
4245+
4246+
void DbScanInstDescriptor::highlight(std::any object, Painter& painter) const
4247+
{
4248+
auto* scan_inst = std::any_cast<odb::dbScanInst*>(object);
4249+
auto* inst_descriptor = Gui::get()->getDescriptor<odb::dbInst*>();
4250+
inst_descriptor->highlight(scan_inst->getInst(), painter);
4251+
}
4252+
4253+
bool DbScanInstDescriptor::getAllObjects(SelectionSet& objects) const
4254+
{
4255+
auto* block = db_->getChip()->getBlock();
4256+
auto* db_dft = block->getDft();
4257+
4258+
for (auto* scan_chain : db_dft->getScanChains()) {
4259+
for (auto* scan_partition : scan_chain->getScanPartitions()) {
4260+
for (auto* scan_list : scan_partition->getScanLists()) {
4261+
for (auto* scan_inst : scan_list->getScanInsts()) {
4262+
objects.insert(makeSelected(scan_inst));
4263+
}
4264+
}
4265+
}
4266+
}
4267+
4268+
return true;
4269+
}
4270+
4271+
Descriptor::Properties DbScanInstDescriptor::getDBProperties(
4272+
odb::dbScanInst* scan_inst) const
4273+
{
4274+
Properties props;
4275+
4276+
props.push_back({"Scan Clock", scan_inst->getScanClock()});
4277+
props.push_back({"Clock Edge", scan_inst->getClockEdgeString()});
4278+
props.push_back(getScanPinProperty("Enable", scan_inst->getScanEnable()));
4279+
4280+
PropertyList access_pins_props;
4281+
odb::dbScanInst::AccessPins access_pins = scan_inst->getAccessPins();
4282+
Property scan_in_prop = getScanPinProperty("In", access_pins.scan_in);
4283+
access_pins_props.push_back({scan_in_prop.name, scan_in_prop.value});
4284+
Property scan_out_prop = getScanPinProperty("Out", access_pins.scan_out);
4285+
access_pins_props.push_back({scan_out_prop.name, scan_out_prop.value});
4286+
props.push_back({"Access Pins", access_pins_props});
4287+
4288+
auto gui = Gui::get();
4289+
props.push_back({"Inst", gui->makeSelected(scan_inst->getInst())});
4290+
4291+
return props;
4292+
}
4293+
4294+
/* static */
4295+
Descriptor::Property DbScanInstDescriptor::getScanPinProperty(
4296+
const std::string& name,
4297+
const std::variant<odb::dbBTerm*, odb::dbITerm*>& pin)
4298+
{
4299+
Descriptor::Property property;
4300+
property.name = name;
4301+
4302+
auto gui = Gui::get();
4303+
std::visit([&](auto* term) { property.value = gui->makeSelected(term); },
4304+
pin);
4305+
4306+
return property;
4307+
}
4308+
42194309
} // namespace gui

src/gui/src/dbDescriptors.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,4 +699,26 @@ class DbMarkerDescriptor : public BaseDbDescriptor<odb::dbMarker>
699699
Properties getDBProperties(odb::dbMarker* marker) const override;
700700
};
701701

702+
class DbScanInstDescriptor : public BaseDbDescriptor<odb::dbScanInst>
703+
{
704+
public:
705+
DbScanInstDescriptor(odb::dbDatabase* db);
706+
707+
std::string getName(std::any object) const override;
708+
std::string getTypeName() const override;
709+
710+
bool getBBox(std::any object, odb::Rect& bbox) const override;
711+
712+
void highlight(std::any object, Painter& painter) const override;
713+
714+
bool getAllObjects(SelectionSet& objects) const override;
715+
716+
static Descriptor::Property getScanPinProperty(
717+
const std::string& name,
718+
const std::variant<odb::dbBTerm*, odb::dbITerm*>& pin);
719+
720+
protected:
721+
Properties getDBProperties(odb::dbScanInst* scan_inst) const override;
722+
};
723+
702724
}; // namespace gui

src/gui/src/mainWindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ void MainWindow::init(sta::dbSta* sta, const std::string& help_path)
543543
gui->registerDescriptor<odb::dbMarkerCategory*>(
544544
new DbMarkerCategoryDescriptor(db_));
545545
gui->registerDescriptor<odb::dbMarker*>(new DbMarkerDescriptor(db_));
546+
gui->registerDescriptor<odb::dbScanInst*>(new DbScanInstDescriptor(db_));
546547

547548
gui->registerDescriptor<sta::Corner*>(new CornerDescriptor(sta));
548549
gui->registerDescriptor<sta::LibertyLibrary*>(

src/odb/include/odb/db.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8419,6 +8419,7 @@ class dbScanInst : public dbObject
84198419

84208420
void setClockEdge(ClockEdge clock_edge);
84218421
ClockEdge getClockEdge() const;
8422+
std::string getClockEdgeString() const;
84228423

84238424
// The number of bits that are in this scan inst from the scan in to the scan
84248425
// out. For simple flops this is just 1.

src/odb/src/db/dbScanInst.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ dbScanInst::ClockEdge dbScanInst::getClockEdge() const
110110
return static_cast<ClockEdge>(scan_inst->clock_edge_);
111111
}
112112

113+
std::string dbScanInst::getClockEdgeString() const
114+
{
115+
switch (getClockEdge()) {
116+
case ClockEdge::Rising:
117+
return "Rising";
118+
case ClockEdge::Falling:
119+
return "Falling";
120+
}
121+
122+
return "Unknown";
123+
}
124+
113125
void dbScanInst::setBits(uint bits)
114126
{
115127
_dbScanInst* scan_inst = (_dbScanInst*) this;

0 commit comments

Comments
 (0)