Skip to content

Commit 2d97822

Browse files
authored
Merge pull request #7571 from AcKoucher/gui-dft-descriptors
gui: add descriptor for dbScanInst
2 parents 1c5d5df + 76d83a8 commit 2d97822

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
@@ -4218,4 +4218,94 @@ void DbMarkerDescriptor::paintMarker(odb::dbMarker* marker,
42184218
}
42194219
}
42204220

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

84258425
void setClockEdge(ClockEdge clock_edge);
84268426
ClockEdge getClockEdge() const;
8427+
std::string getClockEdgeString() const;
84278428

84288429
// The number of bits that are in this scan inst from the scan in to the scan
84298430
// 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)