Skip to content

Commit 2dbe9a4

Browse files
authored
Merge pull request #420 from diffblue/verilog-final
Verilog: parse the `final` construct
2 parents 31aeef7 + 06f7109 commit 2dbe9a4

File tree

8 files changed

+35
-0
lines changed

8 files changed

+35
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
final1.sv
3+
4+
^no properties$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module main;
2+
3+
// no synthesis semantics at all
4+
final $display("Final time: %d", $time);
5+
6+
endmodule

src/hw_cbmc_irep_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ IREP_ID_ONE(continuous_assign)
6868
IREP_ID_ONE(wait)
6969
IREP_ID_ONE(always)
7070
IREP_ID_ONE(named_port_connection)
71+
IREP_ID_ONE(verilog_final)
7172
IREP_ID_ONE(initial)
7273
IREP_ID_ONE(verilog_label_statement)
7374
IREP_ID_ONE(disable)

src/verilog/parser.y

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ module_common_item:
861861
| bind_directive
862862
| continuous_assign
863863
| initial_construct
864+
| final_construct
864865
| always_construct
865866
| loop_generate_construct
866867
| conditional_generate_construct
@@ -2511,6 +2512,10 @@ always_keyword:
25112512
| TOK_ALWAYS_FF { init($$, ID_always); }
25122513
;
25132514

2515+
final_construct: TOK_FINAL function_statement
2516+
{ init($$, ID_verilog_final); mto($$, $2); }
2517+
;
2518+
25142519
blocking_assignment:
25152520
variable_lvalue '=' delay_or_event_control expression
25162521
{ init($$, ID_blocking_assign); mto($$, $1); mto($$, $4); }
@@ -2696,6 +2701,9 @@ statement_item:
26962701
| procedural_assertion_statement
26972702
;
26982703

2704+
function_statement: statement
2705+
;
2706+
26992707
system_task_name: TOK_SYSIDENT
27002708
{ new_symbol($$, $1); }
27012709
;

src/verilog/verilog_elaborate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ void verilog_typecheckt::collect_symbols(
764764
{
765765
collect_symbols(to_verilog_set_genvars(module_item).module_item());
766766
}
767+
else if(module_item.id() == ID_verilog_final)
768+
{
769+
}
767770
else if(module_item.id() == ID_verilog_let)
768771
{
769772
collect_symbols(to_verilog_let(module_item));

src/verilog/verilog_interfaces.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ void verilog_typecheckt::interface_module_item(
270270
{
271271
// does not yield symbol
272272
}
273+
else if(module_item.id() == ID_verilog_final)
274+
{
275+
}
273276
else if(module_item.id() == ID_verilog_let)
274277
{
275278
// already done during constant elaboration

src/verilog/verilog_synthesis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,10 @@ void verilog_synthesist::synth_module_item(
26252625
{
26262626
// ignore for now
26272627
}
2628+
else if(module_item.id() == ID_verilog_final)
2629+
{
2630+
// no synthesis semantics
2631+
}
26282632
else if(module_item.id() == ID_verilog_let)
26292633
{
26302634
// done already

src/verilog/verilog_typecheck.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,9 @@ void verilog_typecheckt::convert_module_item(
16251625
module_item.swap(tmp);
16261626
convert_module_item(module_item);
16271627
}
1628+
else if(module_item.id() == ID_verilog_final)
1629+
{
1630+
}
16281631
else if(module_item.id() == ID_verilog_let)
16291632
{
16301633
// done already

0 commit comments

Comments
 (0)