Skip to content

Commit

Permalink
Added logic evaluator plugin, first working version
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Jul 12, 2024
1 parent e071095 commit 013c31d
Show file tree
Hide file tree
Showing 13 changed files with 1,105 additions and 88 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
* changed API so that no instance of the plugin needs to be created anymore to apply its algorithms
* changed propagation logic for better results
* miscellaneous
* added logic evaluator plugin
* added backward compatibility for view management
* bugfixes
* fixed incompatibility between shipped zlib and QuaZip libraries
Expand Down
2 changes: 1 addition & 1 deletion include/hal_core/plugin_system/plugin_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace hal
class PluginParameter
{
public:
enum ParameterType { Absent, Boolean, Color, ComboBox, Dictionary, ExistingDir, Float, Gate, Integer, Module, NewFile, PushButton, String, TabName };
enum ParameterType { Absent, Boolean, Color, ComboBox, Dictionary, ExistingDir, Float, Gate, Integer, Label, Module, NewFile, PushButton, String, TabName };
private:
ParameterType m_type;
std::string m_tagname;
Expand Down
154 changes: 154 additions & 0 deletions plugins/gui/resources/stylesheet/dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -1511,3 +1511,157 @@ hal--Overlay
background : rgba(0, 0, 0, 150);
}

hal--LogicEvaluatorDialog
{
font-size : 14px;
color : #A9B7C6;
background : #515253;
}

hal--LogicEvaluatorPingroup
{
background : #717273;
border : 2px solid gray;
padding-top : 4px;
padding-bottom : 4px;
padding-left : 0px;
padding-right : 0px;
}


hal--LogicEvaluatorPingroup[output="true"]
{
border-color : #A0A5A8 #414243 #414243 black;
border-width : 2 2 2 0;
}

hal--LogicEvaluatorPingroup[output="false"]
{
border-color : #A0A5A8 black #414243 #A0A5A8;
border-width : 2 0 2 2;
}

hal--LogicEvaluatorValue
{
min-width : 48;
max-width : 48;
min-height : 28;
max-height : 28;
}

hal--LogicEvaluatorValue QSpinBox
{
color : #CBD2D0;
font-family : "Iosevka";
font-style : normal;
background-color : rgb(28, 28, 29);
border : none;
}

hal--LogicEvaluatorValue QSpinBox::up-button
{
color : #CBD2D0;
background-color : #505152;
border-style : solid;
border-color : #808182 #313233 #313233 #808182;
border-width : 1;
}

hal--LogicEvaluatorValue QSpinBox::down-button
{
color : #CBD2D0;
background-color : #505152;
border-style : solid;
border-color : #808182 #313233 #313233 #808182;
border-width : 1;
}

/*
hal--LogicEvaluatorValue QSpinBox::up-arrow
{
color : #CBD2D0;
background-color : rgb(128, 28, 29);
}

hal--LogicEvaluatorValue QSpinBox::down-arrow
{
color : #CBD2D0;
background-color : rgb(28, 28, 128);
}
*/

hal--LogicEvaluatorValue QLabel
{
color : #CBD2D0;
font-family : "Iosevka";
font-style : normal;
background-color : rgb(28, 28, 29);
border : none;
}

hal--LogicEvaluatorPingroup > QLabel
{
color : white;
font-family : "Iosevka";
font-style : bold;
border : none;
background-color : none;
max-height : 28;
}

QLabel > QCheckBox
{
color : white;
font-family : "Iosevka";
font-style : bold;
font-size : 10px;
border : none;
background-color : black;
max-height : 28;
}

hal--LogicEvaluatorPingroup QCheckBox
{
font : bold "Iosevka";
color : white;
background : black;
padding-top : 4px;
padding-bottom : 4px;
padding-left : 8px;
padding-right : 8px;
min-width : 250px;
}

hal--LogicEvaluatorPingroup QCheckBox::indicator:checked
{
background : rgb(255,0,0);
border : 1px solid black;
}

hal--LogicEvaluatorPingroup QCheckBox::indicator:unchecked
{
background : rgb(0,170,255);
border : 1px solid black;
}

hal--LogicEvaluatorDialog > QLabel
{
border-style : solid;
border-color : #A0A5A8 black #414243 black;
border-width : 2 0 2 0;
font-size : 14pt;
font-style : normal;
background : black;
color : white;
min-width : 160px;
}

QLabel > QLabel
{
border : none;
font-size : 14pt;
font-style : normal;
background : black;
color : white;
min-width : 160px;
}
12 changes: 12 additions & 0 deletions plugins/gui/src/main_window/plugin_parameter_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ namespace hal {
mWidgetMap[parTagname] = floatBox;
break;
}
case PluginParameter::Label:
{
QLabel* label = new QLabel(this);
label->setText(parDefault);
mWidgetMap[parTagname] = label;
break;
}
case PluginParameter::String:
{
QLineEdit* ledit = new QLineEdit(this);
Expand Down Expand Up @@ -246,6 +253,11 @@ namespace hal {
par.set_value(QString::number(floatBox->value()).toStdString());
break;
}
case PluginParameter::Label:
{
par.set_value(std::string());
break;
}
case PluginParameter::String:
{
const QLineEdit* ledit = static_cast<const QLineEdit*>(w);
Expand Down
1 change: 1 addition & 0 deletions plugins/gui_extension_demo/python/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace hal
.value("Module", PluginParameter::Gate, R"(Module ID.)")
.value("NewFile", PluginParameter::NewFile, R"(New file name.)")
.value("PushButton", PluginParameter::PushButton, R"(Push Button.)")
.value("Label", PluginParameter::Label, R"(Text Label.)")
.value("String", PluginParameter::String, R"(String value.)")
.value("TabName", PluginParameter::TabName, R"(Tab name for structuring other elements.)")
.export_values();
Expand Down
2 changes: 1 addition & 1 deletion plugins/logic_evaluator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ if(PL_LOGIC_EVALUATOR OR BUILD_ALL_PLUGINS)
SHARED
HEADER ${LOGIC_EVALUATOR_INC}
SOURCES ${LOGIC_EVALUATOR_SRC} ${LOGIC_EVALUATOR_PYTHON_SRC} ${MOC_HDR}
LINK_LIBRARIES PUBLIC gui Qt5::Core Qt5::Gui Qt5::Widgets)
LINK_LIBRARIES PUBLIC gui netlist_simulator_controller Qt5::Core Qt5::Gui Qt5::Widgets)

endif()
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// MIT License
//
//
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -25,50 +25,62 @@

#pragma once

#include "hal_core/defines.h"
#include "hal_core/netlist/gate.h"
#include "hal_core/netlist/net.h"
#include "hal_core/netlist/netlist_writer/netlist_writer.h"
#include "gui/content_widget/content_widget.h"
#include "gui/content_manager/content_manager.h"
#include <functional>
#include <map>
#include <sstream>
#include <QString>
#include <QMap>
#include <QCheckBox>
#include <QTabWidget>
#include <QDialog>
#include <QList>
#include <vector>
#include <memory>
#include <unordered_set>
#include <dlfcn.h>
#include <QTemporaryFile>
#include <QCheckBox>
#include "hal_core/netlist/boolean_function.h"

class QStatusBar;
class QProgressBar;
class QCloseEvent;
namespace hal {
class SimulationInput;

namespace hal
{
/* forward declaration */
class Netlist;
class Gate;

/**
* @ingroup netlist_writer
*/
class NETLIST_API LogicEvaluator : public QObject
{
Q_OBJECT
class Net;

public:
class LogicEvaluatorPingroup;

LogicEvaluator(QWidget* parent = nullptr);
~LogicEvaluator();
class LogicEvaluatorDialog : public QDialog
{
Q_OBJECT

void setGates(std::vector<Gate*> gates);
struct SharedLibHandle
{
QString fnSharedLib;
void* handle;
int (*get)(int);
void (*set)(int,int);
void (*calc)(void);
void close();
SharedLibHandle() : handle(nullptr), get(nullptr), set(nullptr), calc(nullptr) {;}
~SharedLibHandle() { close(); };
};

private Q_SLOTS:
SimulationInput* mSimulationInput;
QList<const Gate*> mEvaluationOrder;
QList<LogicEvaluatorPingroup*> mInputs;
QList<LogicEvaluatorPingroup*> mOutputs;
SharedLibHandle mSharedLib;
QHash<const Net*, int> mExternalArrayIndex;
QHash<const Net*, BooleanFunction::Value> mSignals;
QCheckBox* mCheckCompiled;
QCheckBox* mCheckIndicate;

void calculateEvaluationOrder();
void recalcCompiled();
void recalcInterpreted();
void visualizeResultsInNetlist();
void omitNetlistVisualization();
public Q_SLOTS:

private:
void recalc();
private Q_SLOTS:
void handleCompiledStateChanged(int state);
void handleIndicateStateChanged(int state);
public:
LogicEvaluatorDialog(std::vector<Gate*>& gates, bool skipCompile, QWidget* parent = nullptr);
~LogicEvaluatorDialog();
bool compile();
};
} // namespace hal
}
Loading

0 comments on commit 013c31d

Please sign in to comment.