Skip to content

Commit b58d9be

Browse files
authored
Merge pull request #8313 from The-OpenROAD-Project-staging/gui-write-path-def
gui: add option to write a DEF for timing path
2 parents af26353 + 5621444 commit b58d9be

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/gui/src/mainWindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ void MainWindow::setLogger(utl::Logger* logger)
16451645
drc_viewer_->setLogger(logger);
16461646
clock_viewer_->setLogger(logger);
16471647
charts_widget_->setLogger(logger);
1648+
timing_widget_->setLogger(logger);
16481649
}
16491650

16501651
void MainWindow::fit()

src/gui/src/timingWidget.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "db_sta/dbSta.hh"
2121
#include "gui_utils.h"
2222
#include "odb/db.h"
23+
#include "odb/defout.h"
2324
#include "sta/Liberty.hh"
2425
#include "staGui.h"
2526

@@ -249,6 +250,11 @@ void TimingWidget::init(sta::dbSta* sta)
249250
clearPathDetails();
250251
}
251252

253+
void TimingWidget::setLogger(utl::Logger* logger)
254+
{
255+
logger_ = logger;
256+
}
257+
252258
void TimingWidget::updatePaths()
253259
{
254260
update_button_->click();
@@ -336,6 +342,10 @@ void TimingWidget::addCommandsMenuActions()
336342
[this] {
337343
writePathReportCommand(timing_paths_table_index_, kFromStartToEnd);
338344
});
345+
346+
connect(commands_menu_->addAction("Write path DEF"),
347+
&QAction::triggered,
348+
[this] { writePathDef(timing_paths_table_index_, kFromStartToEnd); });
339349
}
340350

341351
void TimingWidget::showCommandsMenu(const QPoint& pos)
@@ -349,6 +359,35 @@ void TimingWidget::showCommandsMenu(const QPoint& pos)
349359
commands_menu_->popup(focus_view_->viewport()->mapToGlobal(pos));
350360
}
351361

362+
void TimingWidget::writePathDef(const QModelIndex& selected_index,
363+
const CommandType& type)
364+
{
365+
TimingPathsModel* focus_model
366+
= static_cast<TimingPathsModel*>(focus_view_->model());
367+
TimingPath* path = focus_model->getPathAt(selected_index);
368+
369+
odb::dbBlock* block = nullptr;
370+
odb::DefOut def_out(logger_);
371+
auto add_path = [&](TimingNodeList* node_list) {
372+
for (int i = 0; i < (node_list->size() - 1); i++) {
373+
TimingPathNode* curr_node = (*node_list)[i].get();
374+
odb::dbInst* curr_node_inst = curr_node->getInstance();
375+
if (curr_node_inst) {
376+
block = curr_node_inst->getBlock();
377+
def_out.selectInst(curr_node_inst);
378+
}
379+
def_out.selectNet(curr_node->getNet());
380+
}
381+
};
382+
383+
add_path(&path->getPathNodes());
384+
add_path(&path->getCaptureNodes());
385+
386+
const std::string file_name
387+
= fmt::format("path{}.def", selected_index.row() + 1);
388+
def_out.writeBlock(block, file_name.c_str());
389+
}
390+
352391
// The nodes must be written within curly braces to
353392
// deal with characters like '$'
354393
void TimingWidget::writePathReportCommand(const QModelIndex& selected_index,

src/gui/src/timingWidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class TimingWidget : public QDockWidget
5454
~TimingWidget() override;
5555

5656
void init(sta::dbSta* sta);
57+
void setLogger(utl::Logger* logger);
5758

5859
TimingPathRenderer* getTimingRenderer() { return path_renderer_.get(); }
5960
TimingConeRenderer* getConeRenderer() { return cone_renderer_.get(); }
@@ -101,6 +102,7 @@ class TimingWidget : public QDockWidget
101102

102103
void writePathReportCommand(const QModelIndex& selected_index,
103104
const CommandType& type);
105+
void writePathDef(const QModelIndex& selected_index, const CommandType& type);
104106
void showCommandsMenu(const QPoint& pos);
105107

106108
private slots:
@@ -127,6 +129,7 @@ class TimingWidget : public QDockWidget
127129
QString generateFromStartToEndString(TimingPath* path);
128130
QString generateClosestMatchString(CommandType type, TimingPath* path);
129131

132+
utl::Logger* logger_{nullptr};
130133
QMenu* commands_menu_;
131134

132135
QModelIndex timing_paths_table_index_;

0 commit comments

Comments
 (0)