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+
252258void 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
341351void 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 '$'
354393void TimingWidget::writePathReportCommand (const QModelIndex& selected_index,
0 commit comments