Skip to content

Commit 198a99d

Browse files
committed
array types for word-level SMV output
This adds conversion for array types to the word-level SMV output. SMV only allows range types as index type, not arbitrary types.
1 parent 4fe66e8 commit 198a99d

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
verilog3.sv
3+
--smv-word-level
4+
^MODULE main$
5+
^VAR some_array : array 0\.\.31 of unsigned word\[8\];$
6+
^TRANS next\(main\.some_array\) = main\.some_array$
7+
^LTLSPEC G main\.some_array\[resize\(unsigned\(0sd32_0\), 5\)\] = 0ud8_123$
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module main(input clk);
2+
3+
// an array of bytes
4+
reg [7:0] some_array [32];
5+
6+
assert property (@(posedge clk) some_array[0] == 8'd123);
7+
8+
endmodule

src/ebmc/output_smv_word_level.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ operator<<(std::ostream &out, const smv_type_printert &type_printer)
4545

4646
if(
4747
type.id() == ID_bool || type.id() == ID_signedbv ||
48-
type.id() == ID_unsignedbv || type.id() == ID_range)
48+
type.id() == ID_unsignedbv || type.id() == ID_range ||
49+
type.id() == ID_array)
4950
{
5051
return out << type2smv(type, ns);
5152
}

src/smvlang/expr2smv.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,15 @@ std::string type2smv(const typet &type, const namespacet &ns)
903903
return "boolean";
904904
else if(type.id()==ID_array)
905905
{
906+
auto &array_type = to_array_type(type);
907+
auto size_const = to_constant_expr(array_type.size());
908+
auto size_int = numeric_cast_v<mp_integer>(size_const);
906909
std::string code = "array ";
907-
code+="..";
910+
// The index type cannot be any type, but must be a range low..high
911+
code += "0..";
912+
code += integer2string(size_int - 1);
908913
code+=" of ";
909-
code += type2smv(to_array_type(type).element_type(), ns);
914+
code += type2smv(array_type.element_type(), ns);
910915
return code;
911916
}
912917
else if(type.id() == ID_smv_enumeration)

0 commit comments

Comments
 (0)