Skip to content

Commit c2c8b0d

Browse files
authored
Merge pull request #967 from diffblue/verilog-queue
SystemVerilog: Parsing and type checking for queue types
2 parents cc81eba + 77644f4 commit c2c8b0d

File tree

7 files changed

+27
-5
lines changed

7 files changed

+27
-5
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
queue1.sv
33

4-
^EXIT=0$
4+
^no properties$
5+
^EXIT=10$
56
^SIGNAL=0$
67
--
78
--
8-
Parsing fails.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module main;
22

33
byte queue_of_bytes[$];
4-
string queue_of_strings[$:10] = { "foobar" };
4+
string queue_of_strings[$:10];
55

66
endmodule

src/hw_cbmc_irep_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ IREP_ID_ONE(verilog_inside)
9494
IREP_ID_ONE(verilog_unique)
9595
IREP_ID_ONE(verilog_unique0)
9696
IREP_ID_ONE(verilog_priority)
97+
IREP_ID_ONE(verilog_queue)
9798
IREP_ID_ONE(verilog_new)
9899
IREP_ID_ONE(verilog_non_indexed_part_select)
99100
IREP_ID_ONE(verilog_indexed_part_select_plus)

src/verilog/expr2verilog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,12 @@ std::string expr2verilogt::convert(const typet &type)
20742074
{
20752075
return "enum";
20762076
}
2077+
else if(type.id() == ID_verilog_queue)
2078+
{
2079+
std::string dest = "queue of ";
2080+
dest += convert(to_type_with_subtype(type).subtype());
2081+
return dest;
2082+
}
20772083
else if(type.id() == ID_struct)
20782084
{
20792085
return "struct";

src/verilog/parser.y

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,7 @@ variable_dimension:
21142114
unsized_dimension
21152115
| unpacked_dimension
21162116
| associative_dimension
2117+
| queue_dimension
21172118
;
21182119

21192120
variable_dimension_brace:
@@ -2126,6 +2127,13 @@ variable_dimension_brace:
21262127
}
21272128
;
21282129

2130+
queue_dimension:
2131+
'[' '$' ']'
2132+
{ init($$, ID_verilog_queue); stack_type($$).add_subtype().make_nil(); }
2133+
| '[' '$' TOK_COLON constant_expression ']'
2134+
{ init($$, ID_verilog_queue); stack_type($$).add_subtype().make_nil(); }
2135+
;
2136+
21292137
unsized_dimension: '[' ']'
21302138
{ init($$, "unsized"); }
21312139
;

src/verilog/verilog_elaborate_type.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,13 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
461461
// package::typedef
462462
return elaborate_package_scope_typedef(to_verilog_package_scope_type(src));
463463
}
464+
else if(src.id() == ID_verilog_queue)
465+
{
466+
// The subtype is the element type.
467+
auto tmp = to_type_with_subtype(src);
468+
tmp.subtype() = elaborate_type(tmp.subtype());
469+
return std::move(tmp);
470+
}
464471
else
465472
{
466473
throw errort().with_location(source_location)

src/verilog/verilog_expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typet verilog_declaratort::merged_type(const typet &declaration_type) const
3535
typet *p = &result;
3636

3737
while(p->id() == ID_verilog_unpacked_array ||
38-
p->id() == ID_verilog_associative_array)
38+
p->id() == ID_verilog_associative_array || p->id() == ID_verilog_queue)
3939
{
4040
p = &to_type_with_subtype(*p).subtype();
4141
}

0 commit comments

Comments
 (0)