Skip to content

Commit 883173b

Browse files
authored
Merge pull request #238 from diffblue/concurrent-assertion-statement
Concurrent assertion statements
2 parents 6caf6e3 + 04c32a6 commit 883173b

File tree

3 files changed

+98
-46
lines changed

3 files changed

+98
-46
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
KNOWNBUG
2+
initial1.sv
3+
--module main --bound 1
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
--
9+
Syntax is missing for initial label: assert property (...);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module main(input clk);
2+
3+
// count up from 0 to 10
4+
reg [7:0] counter;
5+
6+
initial counter = 0;
7+
8+
always @(posedge clk)
9+
if(counter == 10)
10+
counter = 0;
11+
else
12+
counter = counter + 1;
13+
14+
// expected to pass
15+
initial p0: assert property (counter == 0);
16+
17+
// expected to pass if there are timeframes 0 and 1
18+
initial p1: assert property (s_nexttime counter == 1);
19+
20+
endmodule

src/verilog/parser.y

Lines changed: 69 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,8 @@ module_or_generate_item:
803803
| attribute_instance_brace gate_instantiation { $$=$2; }
804804
// | attribute_instance_brace udp_instantiation { $$=$2; }
805805
| attribute_instance_brace module_instantiation { $$=$2; }
806-
| attribute_instance_brace concurrent_assert_statement { $$=$2; }
807-
| attribute_instance_brace concurrent_assume_statement { $$=$2; }
808-
| attribute_instance_brace concurrent_cover_statement { $$=$2; }
809-
| attribute_instance_brace concurrent_assertion_item_declaration { $$=$2; }
806+
| attribute_instance_brace concurrent_assertion_item { $$=$2; }
807+
| attribute_instance_brace assertion_item_declaration { $$=$2; }
810808
| attribute_instance_brace module_common_item { $$=$2; }
811809
;
812810

@@ -1535,8 +1533,19 @@ block_item_declaration:
15351533
// System Verilog standard 1800-2017
15361534
// A.2.10 Assertion declarations
15371535

1538-
concurrent_assertion_item_declaration:
1539-
property_declaration
1536+
concurrent_assertion_item:
1537+
concurrent_assertion_statement
1538+
| block_identifier TOK_COLON concurrent_assertion_statement
1539+
{
1540+
$$=$3;
1541+
stack_expr($$).set(ID_identifier, stack_expr($1).id());
1542+
}
1543+
;
1544+
1545+
concurrent_assertion_statement:
1546+
assert_property_statement
1547+
| assume_property_statement
1548+
| cover_property_statement
15401549
;
15411550

15421551
assert_property_statement:
@@ -1567,6 +1576,10 @@ cover_property_statement: TOK_COVER TOK_PROPERTY '(' expression ')' action_block
15671576
{ init($$, ID_cover); mto($$, $4); mto($$, $6); }
15681577
;
15691578

1579+
assertion_item_declaration:
1580+
property_declaration
1581+
;
1582+
15701583
property_declaration:
15711584
TOK_PROPERTY property_identifier TOK_ENDPROPERTY
15721585
;
@@ -2074,6 +2087,40 @@ always_construct: TOK_ALWAYS statement
20742087
{ init($$, ID_always); mto($$, $2); }
20752088
;
20762089

2090+
blocking_assignment:
2091+
variable_lvalue '=' delay_or_event_control expression
2092+
{ init($$, ID_blocking_assign); mto($$, $1); mto($$, $4); }
2093+
| operator_assignment
2094+
;
2095+
2096+
operator_assignment:
2097+
variable_lvalue assignment_operator expression
2098+
{ init($$, ID_blocking_assign); mto($$, $1); mto($$, $3); }
2099+
;
2100+
2101+
assignment_operator:
2102+
'='
2103+
| TOK_PLUSEQUAL
2104+
| TOK_MINUSEQUAL
2105+
| TOK_ASTERICEQUAL
2106+
| TOK_SLASHEQUAL
2107+
| TOK_PERCENTEQUAL
2108+
| TOK_AMPEREQUAL
2109+
| TOK_VERTBAREQUAL
2110+
| TOK_CARETEQUAL
2111+
| TOK_LESSLESSEQUAL
2112+
| TOK_GREATERGREATEREQUAL
2113+
| TOK_LESSLESSLESSEQUAL
2114+
| TOK_GREATERGREATERGREATEREQUAL
2115+
;
2116+
2117+
nonblocking_assignment:
2118+
variable_lvalue TOK_LESSEQUAL expression
2119+
{ init($$, ID_non_blocking_assign); mto($$, $1); mto($$, $3); }
2120+
| variable_lvalue TOK_LESSEQUAL delay_or_event_control expression
2121+
{ init($$, ID_non_blocking_assign); mto($$, $1); mto($$, $4); }
2122+
;
2123+
20772124
// The extra rule to allow block_item_declaration is to avoid an ambiguity
20782125
// caused by the attribute_instance_brace.
20792126
statement:
@@ -2086,12 +2133,10 @@ statement:
20862133
;
20872134

20882135
statement_item:
2089-
assert_property_statement
2090-
| assume_property_statement
2091-
| blocking_assignment ';' { $$ = $1; }
2136+
blocking_assignment ';' { $$ = $1; }
20922137
| nonblocking_assignment ';' { $$ = $1; }
20932138
| case_statement
2094-
| cover_property_statement
2139+
| concurrent_assertion_statement
20952140
| conditional_statement
20962141
| inc_or_dec_expression ';'
20972142
| subroutine_call_statement
@@ -2103,7 +2148,7 @@ statement_item:
21032148
| procedural_continuous_assignments ';'
21042149
| seq_block
21052150
| wait_statement
2106-
| immediate_assert_statement
2151+
| procedural_assertion_statement
21072152
;
21082153

21092154
subroutine_call_statement:
@@ -2333,7 +2378,19 @@ statement_brace:
23332378
// System Verilog standard 1800-2017
23342379
// A.6.10 Assertion statements
23352380

2336-
immediate_assert_statement: TOK_ASSERT '(' expression ')' action_block
2381+
procedural_assertion_statement:
2382+
immediate_assertion_statement
2383+
;
2384+
2385+
immediate_assertion_statement:
2386+
simple_immediate_assertion_statement
2387+
;
2388+
2389+
simple_immediate_assertion_statement:
2390+
simple_immediate_assert_statement
2391+
;
2392+
2393+
simple_immediate_assert_statement: TOK_ASSERT '(' expression ')' action_block
23372394
{ init($$, ID_assert); mto($$, $3); mto($$, $5); }
23382395
;
23392396

@@ -2354,40 +2411,6 @@ procedural_continuous_assignments:
23542411
/* | TOK_RELEASE net_lvalue */
23552412
;
23562413

2357-
blocking_assignment:
2358-
variable_lvalue '=' delay_or_event_control expression
2359-
{ init($$, ID_blocking_assign); mto($$, $1); mto($$, $4); }
2360-
| operator_assignment
2361-
;
2362-
2363-
operator_assignment:
2364-
variable_lvalue assignment_operator expression
2365-
{ init($$, ID_blocking_assign); mto($$, $1); mto($$, $3); }
2366-
;
2367-
2368-
assignment_operator:
2369-
'='
2370-
| TOK_PLUSEQUAL
2371-
| TOK_MINUSEQUAL
2372-
| TOK_ASTERICEQUAL
2373-
| TOK_SLASHEQUAL
2374-
| TOK_PERCENTEQUAL
2375-
| TOK_AMPEREQUAL
2376-
| TOK_VERTBAREQUAL
2377-
| TOK_CARETEQUAL
2378-
| TOK_LESSLESSEQUAL
2379-
| TOK_GREATERGREATEREQUAL
2380-
| TOK_LESSLESSLESSEQUAL
2381-
| TOK_GREATERGREATERGREATEREQUAL
2382-
;
2383-
2384-
nonblocking_assignment:
2385-
variable_lvalue TOK_LESSEQUAL expression
2386-
{ init($$, ID_non_blocking_assign); mto($$, $1); mto($$, $3); }
2387-
| variable_lvalue TOK_LESSEQUAL delay_or_event_control expression
2388-
{ init($$, ID_non_blocking_assign); mto($$, $1); mto($$, $4); }
2389-
;
2390-
23912414
procedural_timing_control_statement:
23922415
procedural_timing_control statement_or_null
23932416
{ $$=$1; mto($$, $2); }

0 commit comments

Comments
 (0)