Skip to content

Commit

Permalink
Changes to logic evaluator layout
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Jul 16, 2024
1 parent 573e5a1 commit 4db3365
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <dlfcn.h>
#include <QTemporaryFile>
#include <QCheckBox>
#include <QMenuBar>
#include <QAction>
#include "hal_core/netlist/boolean_function.h"

namespace hal {
Expand Down Expand Up @@ -65,8 +67,9 @@ namespace hal {
SharedLibHandle mSharedLib;
QHash<const Net*, int> mExternalArrayIndex;
QHash<const Net*, BooleanFunction::Value> mSignals;
QCheckBox* mCheckCompiled;
QCheckBox* mCheckIndicate;
QMenuBar* mMenuBar;
QAction* mActionCompile;
QAction* mActionIndicate;

void calculateEvaluationOrder();
void recalcCompiled();
Expand All @@ -76,8 +79,8 @@ namespace hal {
public Q_SLOTS:
void recalc();
private Q_SLOTS:
void handleCompiledStateChanged(int state);
void handleIndicateStateChanged(int state);
void handleCompiledToggled(bool checked);
void handleIndicateToggled(bool checked);
public:
LogicEvaluatorDialog(std::vector<Gate*>& gates, bool skipCompile, QWidget* parent = nullptr);
~LogicEvaluatorDialog();
Expand Down
40 changes: 19 additions & 21 deletions plugins/logic_evaluator/src/logic_evaluator_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace hal {
const char* COMPILER = "gcc";

LogicEvaluatorDialog::LogicEvaluatorDialog(std::vector<Gate *> &gates, bool skipCompile, QWidget *parent)
: QDialog(parent), mSimulationInput(new SimulationInput), mCheckCompiled(nullptr), mCheckIndicate(nullptr)
: QDialog(parent), mSimulationInput(new SimulationInput), mActionCompile(nullptr), mActionIndicate(nullptr)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle("Logic Evaluator");
Expand Down Expand Up @@ -112,30 +112,28 @@ namespace hal {
outLayout->addWidget(lep);
}

QLabel* bbox = new QLabel(this);
QLabel* bbox = new QLabel(QString("%1 Gate%2").arg(gates.size()).arg(gates.size()==1?"":"s"),this);
bbox->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

mMenuBar = new QMenuBar(this);
QMenu* options = mMenuBar->addMenu("Options");
mActionCompile = options->addAction("Run compiled logic");
connect(mActionCompile, &QAction::toggled, this, &LogicEvaluatorDialog::handleCompiledToggled);
mActionCompile->setCheckable(true);
mActionIndicate = options->addAction("Show in graphic view");
connect(mActionIndicate, &QAction::toggled, this, &LogicEvaluatorDialog::handleIndicateToggled);
mActionIndicate->setCheckable(true);

inpLayout->addStretch();
outLayout->addStretch();
topLayout->addLayout(inpLayout);
topLayout->addWidget(bbox);
topLayout->addLayout(outLayout);
topLayout->setMenuBar(mMenuBar);

if (!skipCompile)
compile();

QGridLayout* labLayout = new QGridLayout(bbox);
QLabel* ngates = new QLabel(QString("%1 Gate%2").arg(gates.size()).arg(gates.size()==1?"":"s"),bbox);
ngates->setAlignment(Qt::AlignHCenter);
labLayout->addWidget(ngates,0,0);
mCheckCompiled = new QCheckBox("Run compiled logic", bbox);
mCheckCompiled->setChecked(mSharedLib.handle!=nullptr);
mCheckIndicate = new QCheckBox("Show in graphic view", bbox);
labLayout->addWidget(mCheckCompiled,2,0);
labLayout->addWidget(mCheckIndicate,3,0);
connect(mCheckCompiled, &QCheckBox::stateChanged, this, &LogicEvaluatorDialog::handleCompiledStateChanged);
connect(mCheckIndicate, &QCheckBox::stateChanged, this, &LogicEvaluatorDialog::handleIndicateStateChanged);

QStyle* s = style();

s->unpolish(this);
Expand All @@ -149,19 +147,19 @@ namespace hal {
delete mSimulationInput;
}

void LogicEvaluatorDialog::handleCompiledStateChanged(int state)
void LogicEvaluatorDialog::handleCompiledToggled(bool checked)
{
if (state==Qt::Checked && !mSharedLib.handle)
if (checked && !mSharedLib.handle)
{
compile();
if (!mSharedLib.handle)
mCheckCompiled->setChecked(false);
mActionCompile->setChecked(false);
}
}

void LogicEvaluatorDialog::handleIndicateStateChanged(int state)
void LogicEvaluatorDialog::handleIndicateToggled(bool checked)
{
if (state==Qt::Checked)
if (checked)
recalc();
else
omitNetlistVisualization();
Expand Down Expand Up @@ -326,7 +324,7 @@ namespace hal {
void LogicEvaluatorDialog::recalc()
{
mSignals.clear();
if (mCheckCompiled->isChecked() && mSharedLib.handle)
if (mActionCompile->isChecked() && mSharedLib.handle)
recalcCompiled();
else
recalcInterpreted();
Expand All @@ -341,7 +339,7 @@ namespace hal {
}
}

if (mCheckIndicate->isChecked())
if (mActionIndicate->isChecked())
visualizeResultsInNetlist();
}

Expand Down
7 changes: 6 additions & 1 deletion plugins/logic_evaluator/src/logic_evaluator_pingroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ namespace hal {
{
LogicEvaluatorCheckBox* lecb = new LogicEvaluatorCheckBox(net, this);
connect(lecb, &QCheckBox::stateChanged, this, &LogicEvaluatorPingroup::handleCheckStateChanged);
if (mOutput) lecb->setDisabled(true);
if (mOutput)
lecb->setDisabled(true);
else
{
lecb->setLayoutDirection(Qt::RightToLeft);
}
mPinList.prepend(lecb);
pinLayout->addWidget(lecb);
}
Expand Down

0 comments on commit 4db3365

Please sign in to comment.