Skip to content

Commit

Permalink
Merge pull request #4720 from georgerennie/george/bufnorm_constants
Browse files Browse the repository at this point in the history
bufnorm: preserve constant bits driving wires
  • Loading branch information
povik authored Nov 7, 2024
2 parents 2de9f00 + a31c968 commit 5c18896
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions passes/techmap/bufnorm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,13 @@ 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++)
insig[i] = mapped_bits.at(keysig[i], State::Sx);
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];
}

if (chain_this_wire) {
for (int i = 0; i < GetSize(outsig); i++)
mapped_bits[keysig[i]] = outsig[i];
Expand Down
11 changes: 11 additions & 0 deletions tests/techmap/bufnorm.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Check wires driven by constants are kept
read_verilog <<EOT
module top(output wire [7:0] y);
assign y = 27;
endmodule
EOT

equiv_opt -assert bufnorm
design -load postopt
select -assert-count 1 t:$buf
select -assert-count 1 w:y %ci t:$buf %i

0 comments on commit 5c18896

Please sign in to comment.