Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alumacc: alternative cmp unification implementation #4000

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions passes/techmap/alumacc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,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 +413,16 @@ struct AlumaccWorker
break;
}

if (n == nullptr) {
for (auto node : sig_alu[RTLIL::SigSig(B, A)])
if (node->is_signed == is_signed && 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 +450,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 +458,14 @@ struct AlumaccWorker
break;
}

if (n == nullptr) {
for (auto node : sig_alu[RTLIL::SigSig(B, A)])
if (node->is_signed == is_signed && 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
Loading