15 #include <QInputDialog>
19 const QString ModuleInfoTable::nameRowKey =
"Name";
20 const QString ModuleInfoTable::idRowKey =
"ID";
21 const QString ModuleInfoTable::typeRowKey =
"Type";
22 const QString ModuleInfoTable::moduleRowKey =
"Parent";
23 const QString ModuleInfoTable::noOfAllGatesRowKey =
"Total number of gates";
24 const QString ModuleInfoTable::noOfDirectGatesRowKey =
"Number of direct member gates";
25 const QString ModuleInfoTable::noOfGatesInSubmodulesRowKey =
"Number of gates in submodules";
26 const QString ModuleInfoTable::noOfModulesRowKey =
"Number of submodules";
27 const QString ModuleInfoTable::noOfNetsRowKey =
"Number of nets";
28 const QString ModuleInfoTable::noOfPinsKey =
"Number of pins";
29 const QString ModuleInfoTable::noOfPinGroupsKey =
"Number of pin groups";
30 const QString ModuleInfoTable::noOfInputNetsKey =
"Number of inputs";
31 const QString ModuleInfoTable::noOfOutputNetsKey =
"Number of outputs";
32 const QString ModuleInfoTable::noOfInternalNetsKey =
"Number of internal nets";
33 const QString ModuleInfoTable::isTopModuleKey =
"Is top module?";
37 mNameEntryContextMenu =
new QMenu();
38 mNameEntryContextMenu->
addAction(
"Name to clipboard", std::bind(&ModuleInfoTable::copyName,
this));
40 mNameEntryContextMenu->
addAction(
"Change name", std::bind(&ModuleInfoTable::changeName,
this));
42 mNameEntryContextMenu->
addAction(mPyIcon,
"Get name", std::bind(&ModuleInfoTable::pyCopyName,
this));
44 mIdEntryContextMenu =
new QMenu();
45 mIdEntryContextMenu->
addAction(
"ID to clipboard", std::bind(&ModuleInfoTable::copyId,
this));
47 mIdEntryContextMenu->
addAction(mPyIcon,
"Get ID", std::bind(&ModuleInfoTable::pyCopyId,
this));
49 mTypeEntryContextMenu =
new QMenu();
50 mTypeEntryContextMenu->
addAction(
"Type to clipboard", std::bind(&ModuleInfoTable::copyType,
this));
52 mTypeEntryContextMenu->
addAction(
"Change type", std::bind(&ModuleInfoTable::changeType,
this));
54 mTypeEntryContextMenu->
addAction(mPyIcon,
"Get type", std::bind(&ModuleInfoTable::pyCopyType,
this));
56 mModuleEntryContextMenu =
new QMenu();
57 mModuleEntryContextMenu->
addAction(
"Parent name to clipboard", std::bind(&ModuleInfoTable::copyModule,
this));
58 mModuleEntryContextMenu->
addAction(
"Parent ID to clipboard", std::bind(&ModuleInfoTable::copyParentID,
this));
59 mModuleEntryContextMenu->
addAction(
"Set as current Selection", std::bind(&ModuleInfoTable::setParentAsSelection,
this));
60 mModuleEntryContextMenu->
addAction(
"Add to current Selection", std::bind(&ModuleInfoTable::addParentToSelection,
this));
61 mChangeParentAction = mModuleEntryContextMenu->
addAction(
"Change parent", std::bind(&ModuleInfoTable::changeParentAction,
this));
63 mModuleEntryContextMenu->
addAction(mPyIcon,
"Get parent", std::bind(&ModuleInfoTable::pyCopyModule,
this));
65 mNumOfAllGatesContextMenu =
new QMenu();
66 mNumOfAllGatesContextMenu->
addAction(
"Number of gates to clipboard", std::bind(&ModuleInfoTable::copyNumberOfAllGates,
this));
67 mNumOfAllGatesContextMenu->
addAction(mPyIcon,
"Get all gates recursively", std::bind(&ModuleInfoTable::pyCopyAllGates,
this));
69 mNumOfDirectGatesContextMenu =
new QMenu();
70 mNumOfDirectGatesContextMenu->
addAction(
"Number of gates to clipboard", std::bind(&ModuleInfoTable::copyNumberOfDirectGates,
this));
71 mNumOfDirectGatesContextMenu->
addAction(mPyIcon,
"Get direct member gates", std::bind(&ModuleInfoTable::pyCopyDirectMemberGates,
this));
73 mNumOfGatesInSubmodulesContextMenu =
new QMenu();
74 mNumOfGatesInSubmodulesContextMenu->
addAction(
"Number of gates in submodules", std::bind(&ModuleInfoTable::copyNumberOfGatesInSubmodules,
this));
76 mNumOfSubmodulesContextMenu =
new QMenu();
77 mNumOfSubmodulesContextMenu->
addAction(
"Number of submodules to clipboard", std::bind(&ModuleInfoTable::copyNumberOfSubmodules,
this));
78 mNumOfSubmodulesContextMenu->
addAction(mPyIcon,
"Get submodules", std::bind(&ModuleInfoTable::pyCopyGetSubmodules,
this));
80 mNumOfNetsContextMenu =
new QMenu();
81 mNumOfNetsContextMenu->
addAction(
"Number of nets to clipboard", std::bind(&ModuleInfoTable::copyNumberOfNets,
this));
82 mNumOfNetsContextMenu->
addAction(mPyIcon,
"Get nets", std::bind(&ModuleInfoTable::pyCopyGetNets,
this));
84 mNumOfPinsContextMenu =
new QMenu;
85 mNumOfPinsContextMenu->
addAction(
"Number of pins to clipboard", std::bind(&ModuleInfoTable::copyNumberOfPins,
this));
86 mNumOfPinsContextMenu->
addAction(mPyIcon,
"Get pins", std::bind(&ModuleInfoTable::pyCopyGetPins,
this));
88 mNumOfPinGroupsContextMenu =
new QMenu;
89 mNumOfPinGroupsContextMenu->
addAction(
"Number of pin groups to clipboard", std::bind(&ModuleInfoTable::copyNumberOfPinGroups,
this));
90 mNumOfPinGroupsContextMenu->
addAction(mPyIcon,
"Get pin groups", std::bind(&ModuleInfoTable::pyCopyGetPinGroups,
this));
92 mNumOfInputNetsContextMenu =
new QMenu;
93 mNumOfInputNetsContextMenu->
addAction(
"Number of input nets to clipboard", std::bind(&ModuleInfoTable::copyNumberOfInputs,
this));
94 mNumOfInputNetsContextMenu->
addAction(mPyIcon,
"Get input nets", std::bind(&ModuleInfoTable::pyCopyGetInputNets,
this));
95 mNumOfInputNetsContextMenu->
addAction(mPyIcon,
"Get input pins", std::bind(&ModuleInfoTable::pyCopyInputPins,
this));
97 mNumOfOutputNetsContextMenu =
new QMenu;
98 mNumOfOutputNetsContextMenu->
addAction(
"Number of output nets to clipboard", std::bind(&ModuleInfoTable::copyNumberOfOutputs,
this));
99 mNumOfOutputNetsContextMenu->
addAction(mPyIcon,
"Get output nets", std::bind(&ModuleInfoTable::pyCopyGetOutputNets,
this));
100 mNumOfOutputNetsContextMenu->
addAction(mPyIcon,
"Get output pins", std::bind(&ModuleInfoTable::pyCopyOutputPins,
this));
102 mNumOfInternalNetsContextMenu =
new QMenu;
103 mNumOfInternalNetsContextMenu->
addAction(
"Number of internal nets to clipboard", std::bind(&ModuleInfoTable::copyNumberOfInternalNets,
this));
104 mNumOfInternalNetsContextMenu->
addAction(mPyIcon,
"Get internal nets", std::bind(&ModuleInfoTable::pyCopyGetInternalNets,
this));
106 mIsTopModuleContextMenu =
new QMenu;
107 mIsTopModuleContextMenu->
addAction(mPyIcon,
"Check if module is top module", std::bind(&ModuleInfoTable::pyCopyIsTopModule,
this));
109 mModuleDoubleClickedAction = std::bind(&ModuleInfoTable::navModule,
this);
132 setRow(nameRowKey, name(), mNameEntryContextMenu);
133 setRow(idRowKey,
id(), mIdEntryContextMenu);
134 setRow(typeRowKey, type(), mTypeEntryContextMenu);
135 setRow(moduleRowKey, parentModule(), mModuleEntryContextMenu, mModuleDoubleClickedAction);
136 setRow(noOfAllGatesRowKey, numberOfAllGates(), mNumOfAllGatesContextMenu);
137 setRow(noOfDirectGatesRowKey, numberOfDirectGateMembers(), mNumOfDirectGatesContextMenu);
138 setRow(noOfGatesInSubmodulesRowKey, numberOfGatesInSubmodules(), mNumOfGatesInSubmodulesContextMenu);
139 setRow(noOfModulesRowKey, numberOfSubModules(), mNumOfSubmodulesContextMenu);
140 setRow(noOfNetsRowKey, numberOfNets(), mNumOfNetsContextMenu);
141 setRow(noOfPinsKey, numberOfPins(), mNumOfPinsContextMenu);
142 setRow(noOfPinGroupsKey, numberOfPinGroups(), mNumOfPinGroupsContextMenu);
143 setRow(noOfInputNetsKey, numberOfInputNets(), mNumOfInputNetsContextMenu);
144 setRow(noOfOutputNetsKey, numberOfOutputNets(), mNumOfOutputNetsContextMenu);
145 setRow(noOfInternalNetsKey, numberOfInternalNets(), mNumOfInternalNetsContextMenu);
146 setRow(isTopModuleKey, isTopModule(), mIsTopModuleContextMenu);
152 QString ModuleInfoTable::name()
const
157 QString ModuleInfoTable::id()
const
162 QString ModuleInfoTable::type()
const
172 QString ModuleInfoTable::parentModule()
const
184 QString ModuleInfoTable::numberOfAllGates()
const
201 QString ModuleInfoTable::numberOfDirectGateMembers()
const
206 QString ModuleInfoTable::numberOfGatesInSubmodules()
const
211 QString ModuleInfoTable::numberOfSubModules()
const
216 QString ModuleInfoTable::numberOfNets()
const
221 QString ModuleInfoTable::numberOfPins()
const
226 QString ModuleInfoTable::numberOfPinGroups()
const
231 QString ModuleInfoTable::numberOfInputNets()
const
236 QString ModuleInfoTable::numberOfOutputNets()
const
241 QString ModuleInfoTable::numberOfInternalNets()
const
246 QString ModuleInfoTable::isTopModule()
const
251 void ModuleInfoTable::changeName()
254 QString prompt =
"Change module name";
261 ActionRenameObject* act =
new ActionRenameObject(newName);
262 act->setObject(UserActionObject(mModule->
get_id(), UserActionObjectType::ObjectType::Module));
267 void ModuleInfoTable::copyName()
const
272 void ModuleInfoTable::pyCopyName()
const
277 void ModuleInfoTable::copyId()
const
282 void ModuleInfoTable::pyCopyId()
const
287 void ModuleInfoTable::changeType()
296 ActionSetObjectType* act =
new ActionSetObjectType(newType);
302 void ModuleInfoTable::copyType()
const
307 void ModuleInfoTable::pyCopyType()
const
312 void ModuleInfoTable::copyModule()
const
315 if(!parentMod)
return;
320 void ModuleInfoTable::pyCopyModule()
const
325 void ModuleInfoTable::pyCopyAllGates()
const
330 void ModuleInfoTable::copyNumberOfAllGates()
const
335 void ModuleInfoTable::copyNumberOfDirectGates()
const
340 void ModuleInfoTable::pyCopyDirectMemberGates()
const
345 void ModuleInfoTable::copyNumberOfGatesInSubmodules()
const
350 void ModuleInfoTable::pyCopyGatesInSubmodules()
const
355 void ModuleInfoTable::copyNumberOfSubmodules()
const
360 void ModuleInfoTable::pyCopyGetSubmodules()
const
365 void ModuleInfoTable::copyNumberOfNets()
const
370 void ModuleInfoTable::pyCopyGetNets()
const
375 void ModuleInfoTable::copyNumberOfPins()
const
380 void ModuleInfoTable::copyNumberOfPinGroups()
const
385 void ModuleInfoTable::pyCopyGetPinGroups()
const
390 void ModuleInfoTable::copyNumberOfInputs()
const
395 void ModuleInfoTable::pyCopyGetInputNets()
const
400 void ModuleInfoTable::copyNumberOfOutputs()
const
405 void ModuleInfoTable::pyCopyGetOutputNets()
const
410 void ModuleInfoTable::copyNumberOfInternalNets()
const
415 void ModuleInfoTable::pyCopyGetInternalNets()
const
420 void ModuleInfoTable::pyCopyIsTopModule()
const
425 void ModuleInfoTable::copyParentID()
const
428 if(!parentMod)
return;
433 void ModuleInfoTable::pyCopyInputPins()
const
438 void ModuleInfoTable::pyCopyOutputPins()
const
443 void ModuleInfoTable::setParentAsSelection()
446 if(!parentMod)
return;
453 void ModuleInfoTable::addParentToSelection()
456 if(!parentMod)
return;
462 void ModuleInfoTable::pyCopyGetPins()
const
467 void ModuleInfoTable::navModule()
471 if(parentModule !=
nullptr)
473 u32 parentModuleId = parentModule->
get_id();
481 void ModuleInfoTable::changeParentAction()
487 if (parentMod) excludeMods.
insert(parentMod->get_id());
489 ModuleDialog md(excludeMods,
"Move to module",
false,
nullptr,
this);
491 if (md.isNewModule())
496 if (!ok ||
name.isEmpty())
return;
500 UserActionCompound* compound =
new UserActionCompound;
501 compound->setUseCreatedObject();
502 compound->addAction(actNewModule);
503 compound->addAction(
new ActionAddItemsToObject(
QSet<u32>() << mModule->
get_id()));
507 ActionAddItemsToObject* addAct =
new ActionAddItemsToObject(
QSet<u32>() << mModule->
get_id());
513 void ModuleInfoTable::refresh()
518 void ModuleInfoTable::handleModuleRemoved(Module*
module)
524 const QString notification(
"Displayed module has been removed.");
526 setRow(nameRowKey, notification,
nullptr);
527 setRow(idRowKey, notification,
nullptr);
528 setRow(typeRowKey, notification,
nullptr);
529 setRow(moduleRowKey, notification,
nullptr,
nullptr);
530 setRow(noOfAllGatesRowKey, notification,
nullptr);
531 setRow(noOfModulesRowKey, notification,
nullptr);
532 setRow(noOfNetsRowKey, notification,
nullptr);
538 void ModuleInfoTable::handleModuleChanged(Module*
module)
544 void ModuleInfoTable::handleSubmoduleChanged(Module* parentModule,
u32 affectedModuleId)
546 Q_UNUSED(affectedModuleId);
555 void ModuleInfoTable::handleGateChanged(Module* parentModule,
u32 affectedGateId)
557 Q_UNUSED(affectedGateId);
566 void ModuleInfoTable::handleNetChaned(Net*
net,
u32 affectedGateId)
574 std::vector<Gate*> allChildGates = mModule->
get_gates(
nullptr,
true);
576 if(std::find(std::begin(allChildGates), std::end(allChildGates), affectedGate) != std::end(allChildGates))
Module * get_parent_module() const
std::vector< ModulePin * > get_pins(const std::function< bool(ModulePin *)> &filter=nullptr) const
const std::unordered_set< Net * > & get_internal_nets() const
bool is_top_module() const
const std::vector< Gate * > & get_gates() const
std::string get_name() const
const std::unordered_set< Net * > & get_input_nets() const
bool contains_module(const Module *other, bool recursive=false) const
std::vector< PinGroup< ModulePin > * > get_pin_groups(const std::function< bool(PinGroup< ModulePin > *)> &filter=nullptr) const
std::vector< Module * > get_submodules(const std::function< bool(Module *)> &filter=nullptr, bool recursive=false) const
std::string get_type() const
const std::unordered_set< Net * > & get_output_nets() const
ModuleInfoTable(QWidget *parent=nullptr)
void setModule(hal::Module *module)
Module * get_top_module() const
Gate * get_gate_by_id(const u32 gate_id) const
bool is_module_in_netlist(const Module *module) const
void netDestinationRemoved(Net *n, const u32 dst_gate_id) const
void moduleTypeChanged(Module *m) const
void netSourceAdded(Net *n, const u32 src_gate_id) const
void moduleGateRemoved(Module *m, const u32 removed_gate) const
void moduleGateAssigned(Module *m, const u32 assigned_gate) const
void netSourceRemoved(Net *n, const u32 src_gate_id) const
void netDestinationAdded(Net *n, const u32 dst_gate_id) const
void moduleSubmoduleRemoved(Module *m, const u32 removed_module) const
void moduleNameChanged(Module *m) const
void moduleRemoved(Module *m) const
void moduleParentChanged(Module *m) const
void moduleSubmoduleAdded(Module *m, const u32 added_module) const
static QString pyCodeModuleIsTopModule(u32 moduleId)
static QString pyCodeModuleType(u32 moduleId)
static QString pyCodeModuleOutputNets(u32 moduleId)
static QString pyCodeModuleInternalNets(u32 moduleId)
static QString pyCodeModuleInputNets(u32 moduleId)
static QString pyCodeModuleNets(u32 moduleId)
static QString pyCodeModulePins(u32 moduleId)
static QString pyCodeModuleInputPins(u32 moduleId)
static QString pyCodeModuleModule(u32 moduleId)
static QString pyCodeModuleOutputPins(u32 moduleId)
static QString pyCodeModuleId(u32 moduleId)
static QString pyCodeModuleSubmodules(u32 moduleId)
static QString pyCodeModuleGates(u32 moduleId, bool recursively=false)
static QString pyCodeModulePinGroups(u32 moduleId)
static QString pyCodeModuleName(u32 moduleId)
void relaySelectionChanged(void *sender)
const Module * module(const Gate *g, const NodeBoxes &boxes)
SelectionRelay * gSelectionRelay
NetlistRelay * gNetlistRelay
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QSet::iterator insert(const T &value)
QString fromStdString(const std::string &str)
QString number(int n, int base)