Skip to content

Commit

Permalink
alumacc: alternative cmp unification implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianparvino committed Oct 11, 2023
1 parent 3e22791 commit de50379
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions passes/techmap/alumacc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ struct AlumaccWorker
if (GetSize(C) > 1)
goto next_macc;

if (!subtract_b && B < A && GetSize(B))
std::swap(A, B);

log(" creating $alu model for $macc %s.\n", log_id(n->cell));

alunode = new alunode_t;
Expand Down Expand Up @@ -405,11 +402,6 @@ struct AlumaccWorker
RTLIL::SigSpec B = sigmap(cell->getPort(ID::B));
RTLIL::SigSpec Y = sigmap(cell->getPort(ID::Y));

if (B < A && GetSize(B)) {
cmp_less = !cmp_less;
std::swap(A, B);
}

alunode_t *n = nullptr;

for (auto node : sig_alu[RTLIL::SigSig(A, B)])
Expand All @@ -418,6 +410,16 @@ struct AlumaccWorker
break;
}

if (n == nullptr) {
for (auto node : sig_alu[RTLIL::SigSig(B, A)])
if (node->invert_b && node->c == State::S1) {
n = node;
cmp_less = !cmp_less;
std::swap(A, B);
break;
}
}

if (n == nullptr) {
n = new alunode_t;
n->a = A;
Expand Down Expand Up @@ -445,9 +447,6 @@ struct AlumaccWorker
RTLIL::SigSpec B = sigmap(cell->getPort(ID::B));
RTLIL::SigSpec Y = sigmap(cell->getPort(ID::Y));

if (B < A && GetSize(B))
std::swap(A, B);

alunode_t *n = nullptr;

for (auto node : sig_alu[RTLIL::SigSig(A, B)])
Expand All @@ -456,6 +455,14 @@ struct AlumaccWorker
break;
}

if (n == nullptr) {
for (auto node : sig_alu[RTLIL::SigSig(B, A)])
if (node->invert_b && node->c == State::S1) {
n = node;
break;
}
}

if (n != nullptr) {
log(" creating $alu model for %s (%s): merged with %s.\n", log_id(cell), log_id(cell->type), log_id(n->cells.front()));
n->cells.push_back(cell);
Expand Down

0 comments on commit de50379

Please sign in to comment.