Skip to content

Commit 2e161cb

Browse files
authored
Merge pull request #1126 from diffblue/smv1
SMV word-level output now prints range types
2 parents 49b4542 + 07588cf commit 2e161cb

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CORE
2+
smv1.smv
3+
--smv-word-level
4+
^MODULE main$
5+
^VAR unsigned_bit_vector : unsigned word\[20\];$
6+
^VAR signed_bit_vector : signed word\[20\];$
7+
^VAR range_type : 1..10;$
8+
^VAR bool_type : boolean;$
9+
^INIT bool_type = FALSE$
10+
^INIT range_type = 1$
11+
^INIT signed_bit_vector = 0sd20_1$
12+
^INIT unsigned_bit_vector = 0ud20_1$
13+
^TRANS next\(bool_type\) = \(!\(bool_type\)\)$
14+
^TRANS next\(range_type\) = 2$
15+
^TRANS next\(signed_bit_vector\) = 0sd20_2$
16+
^TRANS next\(unsigned_bit_vector\) = 0ud20_2$
17+
^EXIT=0$
18+
^SIGNAL=0$
19+
--
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MODULE main
2+
3+
VAR bool_type : boolean;
4+
5+
ASSIGN init(bool_type) := FALSE;
6+
ASSIGN next(bool_type) := !bool_type;
7+
8+
VAR range_type : 1..10;
9+
10+
ASSIGN init(range_type) := 1;
11+
ASSIGN next(range_type) := 2;
12+
13+
VAR signed_bit_vector : signed word [20];
14+
15+
ASSIGN init(signed_bit_vector) := swconst(1, 20);
16+
ASSIGN next(signed_bit_vector) := swconst(2, 20);
17+
18+
VAR unsigned_bit_vector : unsigned word [20];
19+
20+
ASSIGN init(unsigned_bit_vector) := uwconst(1, 20);
21+
ASSIGN next(unsigned_bit_vector) := uwconst(2, 20);

src/ebmc/output_smv_word_level.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ operator<<(std::ostream &out, const smv_type_printert &type_printer)
3939
{
4040
auto &type = type_printer.type();
4141

42-
if(type.id() == ID_bool)
43-
return out << "boolean";
44-
else if(type.id() == ID_signedbv)
45-
return out << "signed word[" << to_signedbv_type(type).get_width() << "]";
46-
else if(type.id() == ID_unsignedbv)
47-
return out << "unsigned word[" << to_unsignedbv_type(type).get_width()
48-
<< "]";
42+
symbol_tablet symbol_table;
43+
namespacet ns(symbol_table);
44+
45+
if(
46+
type.id() == ID_bool || type.id() == ID_signedbv ||
47+
type.id() == ID_unsignedbv || type.id() == ID_range)
48+
{
49+
return out << type2smv(type, ns);
50+
}
4951
else
5052
throw ebmc_errort{} << "cannot convert type " << type.id() << " to SMV";
5153

@@ -146,7 +148,7 @@ static void smv_transition_relation(
146148
if(expr.id() == ID_and)
147149
{
148150
for(auto &conjunct : expr.operands())
149-
smv_initial_states(conjunct, ns, out);
151+
smv_transition_relation(conjunct, ns, out);
150152
}
151153
else if(expr.is_true())
152154
{

0 commit comments

Comments
 (0)