Skip to content

Commit f4d2c1e

Browse files
authored
Merge pull request #1303 from diffblue/word-level-smv-array
array types for word-level SMV output
2 parents bcd9cca + 198a99d commit f4d2c1e

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
@@ -952,10 +952,15 @@ std::string type2smv(const typet &type, const namespacet &ns)
952952
return "boolean";
953953
else if(type.id()==ID_array)
954954
{
955+
auto &array_type = to_array_type(type);
956+
auto size_const = to_constant_expr(array_type.size());
957+
auto size_int = numeric_cast_v<mp_integer>(size_const);
955958
std::string code = "array ";
956-
code+="..";
959+
// The index type cannot be any type, but must be a range low..high
960+
code += "0..";
961+
code += integer2string(size_int - 1);
957962
code+=" of ";
958-
code += type2smv(to_array_type(type).element_type(), ns);
963+
code += type2smv(array_type.element_type(), ns);
959964
return code;
960965
}
961966
else if(type.id() == ID_smv_enumeration)

0 commit comments

Comments
 (0)