Skip to content

Commit 02b08f1

Browse files
authored
Merge pull request #872 from diffblue/fix-signed-on-bool
Fix `$signed` on bool
2 parents 615c98b + 2a1b333 commit 02b08f1

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

Diff for: regression/verilog/expressions/signing_cast1.desc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
KNOWNBUG
2+
signing_cast1.sv
3+
--module main --bound 0
4+
^\[main\.p0\] always signed \[0:0\]'\(1'b1\) == -1: PROVED up to bound 0$
5+
^\[main\.p1\] always signed \[0:0\]'\(4'b1110\) == -2: PROVED up to bound 0$
6+
^\[main\.p2\] always signed \[0:0\]'\(4'b0111\) == 7: PROVED up to bound 0$
7+
^\[main\.p3\] always signed \[0:0\]'\(!0\) == -1: PROVED up to bound 0$
8+
^\[main\.p4\] always \[0:0\]'\(!0\) == 1: PROVED up to bound 0$
9+
^\[main\.p5\] always \[0:0\]'\(-1\) == 32'hFFFFFFFF: PROVED up to bound 0$
10+
^EXIT=0$
11+
^SIGNAL=0$
12+
--
13+
^warning: ignoring
14+
--
15+
The width of the operand is not preserved.

Diff for: regression/verilog/expressions/signing_cast1.sv

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module main;
2+
3+
// 1800-2017 6.24.1
4+
p0: assert final (signed'(1'b1) == -1);
5+
p1: assert final (signed'(4'b1110) == -2);
6+
p2: assert final (signed'(4'b0111) == 7);
7+
p3: assert final (signed'(!0) == -1);
8+
p4: assert final (unsigned'(!0) == 1);
9+
p5: assert final (unsigned'(-1) == 32'hffff_ffff);
10+
11+
// signing casts yield constants
12+
parameter Q = signed'(1);
13+
14+
endmodule

Diff for: regression/verilog/system-functions/signed2.desc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
signed2.sv
3+
--bound 0
4+
^\[main\.p0\] always \$signed\(1\) == 1: PROVED up to bound 0$
5+
^\[main\.p1\] always \$signed\(1'b1\) == -1: PROVED up to bound 0$
6+
^\[main\.p2\] always \$signed\(-1\) == -1: PROVED up to bound 0$
7+
^\[main\.p3\] always \$signed\(!0\) == -1: PROVED up to bound 0$
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
11+
^warning: ignoring

Diff for: regression/verilog/system-functions/signed2.sv

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module main;
2+
3+
p0: assert final ($signed(1) == 1);
4+
p1: assert final ($signed(1'b1) == -1);
5+
p2: assert final ($signed(-1) == -1);
6+
p3: assert final ($signed(!0) == -1);
7+
8+
endmodule

Diff for: src/verilog/verilog_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ exprt verilog_typecheck_exprt::convert_system_function(
784784
}
785785
else if(argument.type().id()==ID_bool)
786786
{
787-
expr.type() = signedbv_typet{2};
787+
expr.type() = signedbv_typet{1};
788788
return std::move(expr);
789789
}
790790
else

0 commit comments

Comments
 (0)