Skip to content

Commit

Permalink
Merge branch 'master' of github.com:emsec/hal
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKlx committed Oct 17, 2024
2 parents 8c59634 + 47c535f commit 681327e
Show file tree
Hide file tree
Showing 22 changed files with 277 additions and 264 deletions.
4 changes: 4 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ foreach(i IN ITEMS "" "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO")
endforeach()
endforeach()

# Build netlist_preprocessing and dependend libraries
option(PL_NETLIST_PREPROCESSING "PL_NETLIST_PREPROCESSING" ON)

include_directories(${include_directories}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/hal_plugins
Expand All @@ -14,6 +17,7 @@ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib/hal_plugins/)
file(WRITE ${CMAKE_BINARY_DIR}/lib/hal_plugins/__init__.py "")
install(FILES ${CMAKE_BINARY_DIR}/lib/hal_plugins/__init__.py DESTINATION ${PLUGIN_LIBRARY_INSTALL_DIRECTORY})


include_directories(${CMAKE_CURRENT_SOURCE_DIR})

SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
4 changes: 3 additions & 1 deletion plugins/genlib_writer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
option(PL_GENLIB_WRITER "PL_GENLIB_WRITER" OFF)
if(PL_GENLIB_WRITER OR BUILD_ALL_PLUGINS)

# LINKED FROM RESYNTHESIS WHICH IS LINKED FROM NETLIST_PREPROCESSING
if(PL_GENLIB_WRITER OR PL_RESYNTHESIS OR PL_NETLIST_PREPROCESSING OR BUILD_ALL_PLUGINS)
file(GLOB_RECURSE GENLIB_WRITER_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
file(GLOB_RECURSE GENLIB_WRITER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE GENLIB_WRITER_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/python/*.cpp)
Expand Down
3 changes: 0 additions & 3 deletions plugins/gui/include/gui/graph_widget/graph_graphics_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ namespace hal
private Q_SLOTS:
void conditionalUpdate();
void handleIsolationViewAction();
void handleMoveAction(u32 moduleId);
void handleMoveNewAction();
void adjustMinScale();
void handleAddCommentAction();

Expand All @@ -163,7 +161,6 @@ namespace hal
void handleHighlightPredecessor();
void handleSuccessorDistance();
void handlePredecessorDistance();
void handleModuleDialog();
void handleCancelPickMode();
void handlePluginContextContributionTriggered();
void selectedNodeToItem();
Expand Down
7 changes: 7 additions & 0 deletions plugins/gui/include/gui/netlist_relay/netlist_relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "gui/grouping/grouping_color_serializer.h"
#include "gui/module_model/module_color_manager.h"
#include "gui/module_model/module_item.h"
#include "gui/gui_def.h"
#include <QMap>
#include <QObject>

Expand Down Expand Up @@ -123,6 +124,12 @@ namespace hal
*/
void addChildModuleDialog(const u32 id);

/**
* Opens 'add to module' Dialog. Node gets added to selected module or new module.
* @param node - The node to be added. If node is empty the current selection will be added.
*/
void addToModuleDialog(const Node& node = Node());

/**
* Deletes the specified module from the netlist.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,6 @@ namespace hal
*/
void selectionToGrouping();

/**
* Checks all modules if the current selection can be added to that specific module. Thereafter it
* creates a context menu with all valid modules as options as well as a "New module..." option.
*/
void selectionToModuleMenu();

/**
* Toggles the visibiliy of the searchbar.
*/
Expand All @@ -299,12 +293,6 @@ namespace hal
*/
void singleSelectionInternal(const ModuleItem* sti);

/**
* Adds the current selection to a module selected by id (=actionCode if positive).
* Create new module an pops up new module dialog if actionCode is negative.
*/
void selectionToModuleAction(int actionCode);

void showNoSelection();

QSplitter* mSplitter;
Expand Down
110 changes: 0 additions & 110 deletions plugins/gui/src/graph_widget/graph_graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,70 +166,6 @@ namespace hal
context->setDirty(false);
}

void GraphGraphicsView::handleMoveAction(u32 moduleId)
{
ActionAddItemsToObject* act = new ActionAddItemsToObject(gSelectionRelay->selectedModules(),
gSelectionRelay->selectedGates());
act->setObject(UserActionObject(moduleId,UserActionObjectType::Module));
act->exec();
gSelectionRelay->clear();
gSelectionRelay->addModule(moduleId);
gSelectionRelay->setFocus(SelectionRelay::ItemType::Module,moduleId);
gSelectionRelay->relaySelectionChanged(this);
gContentManager->getGraphTabWidget()->ensureSelectionVisible();
}

void GraphGraphicsView::handleMoveNewAction()
{
std::unordered_set<Gate*> gate_objs;
std::unordered_set<Module*> module_objs;
for (const auto& id : gSelectionRelay->selectedGatesList())
{
gate_objs.insert(gNetlist->get_gate_by_id(id));
}
for (const auto& id : gSelectionRelay->selectedModulesList())
{
module_objs.insert(gNetlist->get_module_by_id(id));
}
Module* parent = gui_utility::firstCommonAncestor(module_objs, gate_objs);
QString parent_name = QString::fromStdString(parent->get_name());
bool ok;
QString name = QInputDialog::getText(nullptr, "", "New module will be created under \"" + parent_name + "\"\nModule Name:", QLineEdit::Normal, "", &ok);
if (!ok || name.isEmpty())
return;

ActionCreateObject* actNewModule = new ActionCreateObject(UserActionObjectType::Module, name);
actNewModule->setParentId(parent->get_id());

UserActionCompound* compound = new UserActionCompound;
compound->setUseCreatedObject();
compound->addAction(actNewModule);
compound->addAction(new ActionAddItemsToObject(gSelectionRelay->selectedModules(),
gSelectionRelay->selectedGates()));
if (mItem && (mItem->itemType()==ItemType::Gate || mItem->itemType()==ItemType::Module))
{
Node nd(mItem->id(),mItem->itemType()==ItemType::Gate ? Node::Gate : Node::Module);
const NodeBox* box = mGraphWidget->getContext()->getLayouter()->boxes().boxForNode(nd);
if (box)
{
ActionMoveNode* actMoveNode = new ActionMoveNode(mGraphWidget->getContext()->id(),
QPoint(box->x(),box->y()));
compound->addAction(actMoveNode);
}
}

GraphContext* context = mGraphWidget->getContext();
context->setSpecialUpdate(true);
context->setScheduleRemove(gSelectionRelay->selectedModules(),gSelectionRelay->selectedGates());

compound->exec();
gSelectionRelay->clear();
gSelectionRelay->addModule(compound->object().id());
gSelectionRelay->setFocus(SelectionRelay::ItemType::Module,compound->object().id());
gSelectionRelay->relaySelectionChanged(this);
gContentManager->getGraphTabWidget()->ensureSelectionVisible();
}

void GraphGraphicsView::adjustMinScale()
{
if (!scene())
Expand Down Expand Up @@ -689,14 +625,6 @@ namespace hal
data.setValue(Node(mItem->id(), isGate ? Node::NodeType::Gate : Node::NodeType::Module));
action->setData(data);
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleAddCommentAction);

// only allow move actions on anything that is not the top module
Module* m = isModule ? gNetlist->get_module_by_id(mItem->id()) : nullptr;
if (!(isModule && m == gNetlist->get_top_module()))
{
action = context_menu.addAction(" Move to module …");
connect(action, &QAction::triggered, this, &GraphGraphicsView::handleModuleDialog);
}
}
}
else
Expand Down Expand Up @@ -1310,44 +1238,6 @@ namespace hal
act->exec();
}

void GraphGraphicsView::handleModuleDialog()
{
QSet<u32> exclude_ids;
QList<u32> modules = gSelectionRelay->selectedModulesList();
QList<u32> gates = gSelectionRelay->selectedGatesList();

for (u32 gid : gates)
{
Gate* g = gNetlist->get_gate_by_id(gid);
if (!g)
continue;
exclude_ids.insert(g->get_module()->get_id());
}

for (u32 mid : modules)
{
exclude_ids.insert(mid);
Module* m = gNetlist->get_module_by_id(mid);
if (!m)
continue;
Module* pm = m->get_parent_module();
if (pm)
exclude_ids.insert(pm->get_id());
for (Module* sm : m->get_submodules(nullptr, true))
exclude_ids.insert(sm->get_id());
}

AddToModuleReceiver* receiver = new AddToModuleReceiver(this);
ModuleDialog md(exclude_ids, "Move to module", false, receiver, this);
if (md.exec() != QDialog::Accepted) return;
if (md.isNewModule())
{
handleMoveNewAction();
return;
}
handleMoveAction(md.selectedId());
}

void GraphGraphicsView::handleSelectOutputs()
{
auto context = mGraphWidget->getContext();
Expand Down
8 changes: 2 additions & 6 deletions plugins/gui/src/gui_api/gui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,9 @@ namespace hal

GridPlacement* GuiApiClasses::View::getGridPlacement(int viewId)
{
GraphContext* context = gGraphContextManager->getContextById(viewId);
const GraphContext* context = gGraphContextManager->getContextById(viewId);
if (context == nullptr) return new GridPlacement();
GridPlacement* retval = new GridPlacement();
QMap<Node, QPoint> contextNodeMap = context->getLayouter()->nodeToPositionMap();
for (auto it = contextNodeMap.begin(); it != contextNodeMap.end(); it++)
retval->insert(it.key(), it.value());
return retval;
return context->getLayouter()->gridPlacementFactory();
}

bool GuiApiClasses::View::setGridPlacement(int viewId, GridPlacement *gp)
Expand Down
21 changes: 20 additions & 1 deletion plugins/gui/src/module_context_menu/module_context_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ namespace hal {
if(gSelectionRelay->selectedModules().contains(id))
act->setEnabled(false);

if (gSelectionRelay->numberSelectedNodes() == 1)
contextMenu->addAction(" Move to module …",
[id](){
gNetlistRelay->addToModuleDialog(Node(id,Node::Module));
}
);
sm = contextMenu->addMenu(" To grouping …");
QString actionText = " Assign module to grouping";
if(module->get_grouping() != nullptr)
Expand Down Expand Up @@ -151,6 +157,12 @@ namespace hal {
if(gSelectionRelay->selectedGates().contains(id))
act->setEnabled(false);

if (gSelectionRelay->numberSelectedNodes() == 1)
contextMenu->addAction(" Move to module …",
[id](){
gNetlistRelay->addToModuleDialog(Node(id,Node::Gate));
}
);
sm = contextMenu->addMenu(" To grouping …");
QString actionText = " Assign gate to grouping";
if(gate->get_grouping() != nullptr)
Expand Down Expand Up @@ -251,6 +263,13 @@ namespace hal {
{
contextMenu->addSeparator();
contextMenu->addAction("Entire selection:")->setDisabled(true);
if (gSelectionRelay->numberSelectedNodes() > 1)
contextMenu->addAction(" Move to module …",
[](){
gNetlistRelay->addToModuleDialog();
}
);

contextMenu->addAction(" Assign all to grouping",
[modules, gates, nets]()
{gContentManager->getGroupingManagerWidget()->assignElementsToGroupingDialog(modules, gates, nets);}
Expand All @@ -260,4 +279,4 @@ namespace hal {
{gContentManager->getGroupingManagerWidget()->removeElementsFromGrouping(modules, gates, nets);}
);
}
}
}
Loading

0 comments on commit 681327e

Please sign in to comment.