Skip to content

Commit

Permalink
opt_share: Fix X and CO signal width for shifted $alu in opt_share.
Browse files Browse the repository at this point in the history
These need to be the same length as actual Y, not visible part of Y.

Fixes #2538.
  • Loading branch information
mwkmwkmwk committed Jan 14, 2021
1 parent 7cd044b commit 01626e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions passes/opt/opt_share.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ void merge_operators(RTLIL::Module *module, RTLIL::Cell *mux, const std::vector<
}

if (shared_op->type.in(ID($alu))) {
shared_op->setPort(ID::X, module->addWire(NEW_ID, GetSize(new_sig_out)));
shared_op->setPort(ID::CO, module->addWire(NEW_ID, GetSize(new_sig_out)));
shared_op->setPort(ID::X, module->addWire(NEW_ID, GetSize(new_out)));
shared_op->setPort(ID::CO, module->addWire(NEW_ID, GetSize(new_out)));
}

bool is_fine = shared_op->type.in(FINE_BITWISE_OPS);
Expand Down
20 changes: 20 additions & 0 deletions tests/opt/opt_share_bug2538.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
read_verilog <<EOT

module top(...);

input [3:0] A;
input S;
output [1:0] Y;

wire [3:0] A1 = A + 1;
wire [3:0] A2 = A + 2;
assign Y = S ? A1[3:2] : A2[3:2];

endmodule

EOT

proc
alumacc
equiv_opt -assert opt_share

0 comments on commit 01626e6

Please sign in to comment.