Skip to content

Commit b52e09d

Browse files
committed
SMV word-level output now prints range types
This adds output for SMV range types to the SMV word-level output.
1 parent 2728d52 commit b52e09d

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
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+
^INIT next\(bool_type\) = \(!\(bool_type\)\)$
14+
^INIT next\(range_type\) = 2$
15+
^INIT next\(signed_bit_vector\) = 0sd20_2$
16+
^INIT 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: 9 additions & 7 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

0 commit comments

Comments
 (0)