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

bufnorm: preserve constant bits when mapping back to connections #4727

Merged
merged 1 commit into from
Nov 13, 2024
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
21 changes: 14 additions & 7 deletions passes/techmap/bufnorm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ struct BufnormPass : public Pass {

pool<Cell*> added_buffers;

const auto lookup_mapping = [&mapped_bits](const SigBit bit, bool default_sx = false)
{
if (!bit.is_wire())
return bit;

if (default_sx)
return mapped_bits.at(bit, State::Sx);

return mapped_bits.at(bit);
};

auto make_buffer_f = [&](const IdString &type, const SigSpec &src, const SigSpec &dst)
{
auto it = old_buffers.find(pair<IdString, SigSpec>(type, dst));
Expand Down Expand Up @@ -438,12 +449,8 @@ struct BufnormPass : public Pass {
bool chain_this_wire = chain_this_wire_f(wire);

SigSpec keysig = sigmap(wire), insig = wire, outsig = wire;
for (int i = 0; i < GetSize(insig); i++) {
if (keysig[i].is_wire())
insig[i] = mapped_bits.at(keysig[i], State::Sx);
else
insig[i] = keysig[i];
}
for (int i = 0; i < GetSize(insig); i++)
insig[i] = lookup_mapping(keysig[i], true);

if (chain_this_wire) {
for (int i = 0; i < GetSize(outsig); i++)
Expand Down Expand Up @@ -491,7 +498,7 @@ struct BufnormPass : public Pass {

SigSpec newsig = conn.second;
for (auto &bit : newsig)
bit = mapped_bits[sigmap(bit)];
bit = lookup_mapping(sigmap(bit));

if (conn.second != newsig) {
log(" fixing input signal on cell %s port %s: %s\n",
Expand Down
Loading