Skip to content

Commit

Permalink
Allow to reference output pins as input when compiling boolean functions
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Jul 31, 2024
1 parent 2610215 commit d650001
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions plugins/logic_evaluator/src/logic_evaluator_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@ namespace hal {
// propagate by gates
for (const Gate* g : mEvaluationOrder)
{
QMap<QString,QString> referableOutputPins;

for (const GatePin* gp : g->get_type()->get_output_pins())
{
QString pinName = QString::fromStdString(gp->get_name());
QString pinNameOut = QString::fromStdString(gp->get_name());
const Net* nOut = g->get_fan_out_net(gp);
if (!mExternalArrayIndex.contains(nOut))
{
Expand All @@ -300,16 +302,23 @@ namespace hal {
QString theFunction = QString::fromStdString(g->get_boolean_function(gp).to_string());
for (const GatePin* gp : g->get_type()->get_input_pins())
{
QString pinName = QString::fromStdString(gp->get_name());
QString pinNameIn = QString::fromStdString(gp->get_name());
const Net* nIn = g->get_fan_in_net(gp);
int inxIn = mExternalArrayIndex.value(nIn,-1);
if (inxIn < 0) return false;
QString ccVar = QString("logic_evaluator_signals[%1]").arg(inxIn);
theFunction.replace(pinName, ccVar);
theFunction.replace(pinNameIn, ccVar);
}
for (auto it = referableOutputPins.constBegin(); it != referableOutputPins.constEnd(); ++it)
{
theFunction.replace(it.key(),it.value());
}

int inxOut = mExternalArrayIndex.value(nOut,-1);
if (inxOut < 0) return false;
codeEvalFunction += QString(" logic_evaluator_signals[%1] = %2;\n").arg(inxOut).arg(theFunction);

referableOutputPins[pinNameOut] = QString("logic_evaluator_signals[%1]").arg(inxOut);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ namespace hal {
{
for (GatePin* gp : gate_pin_group->get_pins())
{
Net* n = gate->get_fan_in_net(gp);
Net* n = nullptr;
if (gp->get_direction() == PinDirection::input || gp->get_direction() == PinDirection::inout)
n = gate->get_fan_in_net(gp);
else
n = gate->get_fan_out_net(gp);
if (n) retval.push_back(n);
}
}
Expand Down

0 comments on commit d650001

Please sign in to comment.