Skip to content

Commit 77644f4

Browse files
committed
SystemVerilog: Parsing and type checking for queue types
This adds parsing and type checking for 1800-2017 7.10 queues.
1 parent 3579ca1 commit 77644f4

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
@@ -447,6 +447,13 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
447447
// package::typedef
448448
return elaborate_package_scope_typedef(to_type_with_subtypes(src));
449449
}
450+
else if(src.id() == ID_verilog_queue)
451+
{
452+
// The subtype is the element type.
453+
auto tmp = to_type_with_subtype(src);
454+
tmp.subtype() = elaborate_type(tmp.subtype());
455+
return std::move(tmp);
456+
}
450457
else
451458
{
452459
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
@@ -34,7 +34,7 @@ typet verilog_declaratort::merged_type(const typet &declaration_type) const
3434
typet *p = &result;
3535

3636
while(p->id() == ID_verilog_unpacked_array ||
37-
p->id() == ID_verilog_associative_array)
37+
p->id() == ID_verilog_associative_array || p->id() == ID_verilog_queue)
3838
{
3939
p = &to_type_with_subtype(*p).subtype();
4040
}

0 commit comments

Comments
 (0)