Skip to content

Commit 154f137

Browse files
committed
SMV: bool, count, toint, word1
This adds the NuSMV operators bool, count, toint, word to the SMV frontend.
1 parent 2c6ea1e commit 154f137

File tree

14 files changed

+265
-4
lines changed

14 files changed

+265
-4
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* SystemVerilog: fix for #-# and #=# for empty matches
77
* SystemVerilog: fix for |-> and |=> for empty matches
88
* LTL/SVA to Buechi with --buechi
9+
* SMV: bool, count, toint, word1
910

1011
# EBMC 5.6
1112

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
smv_bool1.smv
3+
4+
^\[.*\] !bool\(0\): PROVED .*$
5+
^\[.*\] bool\(1\): PROVED .*$
6+
^\[.*\] bool\(2\): PROVED .*$
7+
^\[.*\] !bool\(0ud1_0\): PROVED .*$
8+
^\[.*\] bool\(0ud1_1\): PROVED .*$
9+
^EXIT=0$
10+
^SIGNAL=0$
11+
--
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MODULE main
2+
3+
CTLSPEC !bool(0)
4+
CTLSPEC bool(1)
5+
CTLSPEC bool(2)
6+
CTLSPEC !bool(uwconst(0, 1))
7+
CTLSPEC bool(uwconst(1, 1))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
KNOWNBUG
2+
smv_count1.smv
3+
4+
^\[.*\] count\(FALSE\) = 0: PROVED .*$
5+
^\[.*\] count\(TRUE\) = 1: PROVED .*$
6+
^\[.*\] count\(FALSE, TRUE\) = 1: PROVED .*$
7+
^\[.*\] count\(TRUE, FALSE\) = 1: PROVED .*$
8+
^\[.*\] count\(TRUE, TRUE, TRUE\) = 3: PROVED .*$
9+
^EXIT=0$
10+
^SIGNAL=0$
11+
--
12+
--
13+
Missing typecasts.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
KNOWNBUG
2+
smv_toint1.smv
3+
4+
^\[.*\] toint\(0\) = 0: PROVED .*$
5+
^\[.*\] toint\(1\) = 1: PROVED .*$
6+
^\[.*\] toint\(FALSE\) = 0: PROVED .*$
7+
^\[.*\] toint\(TRUE\) = 1: PROVED .*$
8+
^\[.*\] toint\(0ud8_1\) = 1: PROVED .*$
9+
^\[.*\] toint\(-0sd8_1\) = -1: PROVED .*$
10+
^EXIT=0$
11+
^SIGNAL=0$
12+
--
13+
--
14+
Missing typecasts.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MODULE main
2+
3+
CTLSPEC toint(0) = 0
4+
CTLSPEC toint(1) = 1
5+
CTLSPEC toint(FALSE) = 0
6+
CTLSPEC toint(TRUE) = 1
7+
CTLSPEC toint(uwconst(1, 8)) = 1
8+
CTLSPEC toint(swconst(-1, 8)) = -1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
smv_word1.smv
3+
4+
^\[.*\] word1\(FALSE\) = 0ud1_0: PROVED .*$
5+
^\[.*\] word1\(TRUE\) = 0ud1_1: PROVED .*$
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
9+
--
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MODULE main
2+
3+
CTLSPEC word1(FALSE) = uwconst(0, 1)
4+
CTLSPEC word1(TRUE) = uwconst(1, 1)

src/hw_cbmc_irep_ids.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ IREP_ID_ONE(E)
1818
IREP_ID_ONE(G)
1919
IREP_ID_ONE(X)
2020
IREP_ID_ONE(smv_bitimplies)
21+
IREP_ID_ONE(smv_bool)
22+
IREP_ID_ONE(smv_count)
2123
IREP_ID_ONE(smv_extend)
2224
IREP_ID_ONE(smv_next)
2325
IREP_ID_ONE(smv_iff)
2426
IREP_ID_TWO(C_smv_iff, "#smv_iff")
2527
IREP_ID_ONE(smv_resize)
28+
IREP_ID_ONE(smv_toint)
2629
IREP_ID_ONE(smv_set)
2730
IREP_ID_ONE(smv_setin)
2831
IREP_ID_ONE(smv_setnotin)
@@ -32,6 +35,7 @@ IREP_ID_ONE(smv_swconst)
3235
IREP_ID_ONE(smv_union)
3336
IREP_ID_ONE(smv_unsigned_cast)
3437
IREP_ID_ONE(smv_uwconst)
38+
IREP_ID_ONE(smv_word1)
3539
IREP_ID_ONE(smv_H)
3640
IREP_ID_ONE(smv_bounded_H)
3741
IREP_ID_ONE(smv_O)

src/smvlang/expr2smv.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,18 @@ expr2smvt::resultt expr2smvt::convert_rec(const exprt &src)
831831
else if(src.id() == ID_smv_unsigned_cast)
832832
return convert_function_application("unsigned", src);
833833

834+
else if(src.id() == ID_smv_bool)
835+
return convert_function_application("bool", src);
836+
837+
else if(src.id() == ID_smv_count)
838+
return convert_function_application("count", src);
839+
840+
else if(src.id() == ID_smv_toint)
841+
return convert_function_application("toint", src);
842+
843+
else if(src.id() == ID_smv_word1)
844+
return convert_function_application("word1", src);
845+
834846
else if(src.id() == ID_typecast)
835847
{
836848
return convert_typecast(to_typecast_expr(src));

0 commit comments

Comments
 (0)