Skip to content

Commit 8e508f2

Browse files
committed
Fix setting bits of parameters in setundef pass
This commit also adds test that verifies correctness of this change.
1 parent cef87cc commit 8e508f2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

passes/cmds/setundef.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct SetundefPass : public Pass {
243243
{
244244
for (auto *cell : module->selected_cells()) {
245245
for (auto &parameter : cell->parameters) {
246-
for (auto bit : parameter.second) {
246+
for (auto &bit : parameter.second.bits()) {
247247
if (bit > RTLIL::State::S1)
248248
bit = worker.next_bit();
249249
}

tests/various/setundef.sv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module foo #(parameter [1:0] a) (output [1:0] o);
2+
assign o = a;
3+
endmodule
4+
5+
module top(output [1:0] o);
6+
foo #(2'b0x) foo(o);
7+
always_comb begin
8+
assert(o == 2'b00);
9+
end
10+
endmodule

tests/various/setundef.ys

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
read_verilog -sv setundef.sv
2+
setundef -zero -params
3+
hierarchy -top top
4+
flatten
5+
proc
6+
async2sync
7+
write_json
8+
sat -seq 5 -prove-asserts

0 commit comments

Comments
 (0)