Skip to content

Commit 7af7ff5

Browse files
committed
Verilog: constant output now includes signedness and width
The conversion of constants to Verilog source now includes the signedness and width when outputting hex or binary literals.
1 parent 2fecbb0 commit 7af7ff5

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

regression/verilog/expressions/constants1.desc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
CORE
22
constants1.v
33
--bound 1
4+
^\[.*\] always main\.w == 32'hFFFF: PROVED up to bound 1$
5+
^\[.*\] always main\.X == 16: PROVED up to bound 1$
46
^EXIT=0$
57
^SIGNAL=0$
68
--

regression/verilog/expressions/equality1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ equality1.v
1010
^\[.*\] always 1'bx != 10 === 1'bx: PROVED up to bound 0$
1111
^\[.*\] always 1'bz != 20 === 1'bx: PROVED up to bound 0$
1212
^\[.*\] always 2'b11 == 2'b11 === 0: REFUTED$
13-
^\[.*\] always 2'sb-1 == 2'sb-1 === 1: PROVED up to bound 0$
13+
^\[.*\] always 2'sb11 == 2'sb11 === 1: PROVED up to bound 0$
1414
^EXIT=10$
1515
^SIGNAL=0$
1616
--

regression/verilog/expressions/equality2.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ equality2.v
1111
^\[.*\] always 1'bx === 1 == 0: PROVED up to bound 0$
1212
^\[.*\] always 1'bz === 1 == 0: PROVED up to bound 0$
1313
^\[.*\] always 1 === 1 == 1: PROVED up to bound 0$
14-
^\[.*\] always 3'b11 === 3'b111 == 1: REFUTED$
15-
^\[.*\] always 3'sb-1 === 3'sb-1 == 1: PROVED up to bound 0$
14+
^\[.*\] always 3'b011 === 3'b111 == 1: REFUTED$
15+
^\[.*\] always 3'sb111 === 3'sb111 == 1: PROVED up to bound 0$
1616
^EXIT=10$
1717
^SIGNAL=0$
1818
--

src/verilog/expr2verilog.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,14 +1020,20 @@ std::string expr2verilogt::convert_constant(
10201020
auto i = numeric_cast_v<mp_integer>(src);
10211021

10221022
if(i>=256)
1023-
dest="'h"+integer2string(i, 16);
1023+
{
1024+
dest = std::to_string(width);
1025+
dest += "'h";
1026+
if(type.id() == ID_signedbv)
1027+
dest += 's';
1028+
dest += integer2string(i, 16);
1029+
}
10241030
else if(width<=7)
10251031
{
10261032
dest=std::to_string(width);
10271033
dest+="'";
10281034
if(type.id()==ID_signedbv) dest+='s';
10291035
dest+='b';
1030-
dest+=integer2string(i, 2);
1036+
dest += integer2binary(i, width);
10311037
}
10321038
else
10331039
dest=integer2string(i);

0 commit comments

Comments
 (0)