Skip to content

Commit 82c9305

Browse files
authored
Merge pull request #995 from diffblue/ignore-initial
ebmc: `--ignore-initial`
2 parents aeb8c12 + 77f64a7 commit 82c9305

12 files changed

+64
-17
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
ignore-initial1.sv
3+
--top main --bound 1 --ignore-initial
4+
^\[main\.p1\] always main\.x == 20 || main\.x == 5: REFUTED$
5+
^\[main\.p2\] always main\.y == 30 || main\.y == 6: REFUTED$
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
^warning: ignoring
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module main(input clk);
2+
3+
reg [7:0] x, y = 30;
4+
5+
initial x=20;
6+
7+
always_ff @(posedge clk) x=5;
8+
always_ff @(posedge clk) y=6;
9+
10+
// fails, owing to nondeterministic initial state
11+
p1: assert property (x==20 || x==5);
12+
13+
// fails, owing to nondeterministic initial state
14+
p2: assert property (y==30 || y==6);
15+
16+
endmodule

regression/verilog/initial1/test.desc renamed to regression/verilog/initial/initial1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.v
2+
initial1.v
33
--module main --bound 2
44
^EXIT=0$
55
^SIGNAL=0$

src/ebmc/ebmc_parse_options.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,6 @@ void ebmc_parse_optionst::help()
356356
" {y--numbered-trace} \t give a trace with identifiers numbered by timeframe\n"
357357
" {y--show-properties} \t list the properties in the model\n"
358358
" {y--property} {uid} \t check the property with given ID\n"
359-
" {y-I} {upath} \t set include path\n"
360-
" {y--systemverilog} \t force SystemVerilog instead of Verilog\n"
361-
" {y--reset} {uexpr} \t set up module reset\n"
362359
" {y--liveness-to-safety} \t translate liveness properties to safety properties\n"
363360
"\n"
364361
"Methods:\n"
@@ -398,6 +395,13 @@ void ebmc_parse_optionst::help()
398395
" {y--yices} \t use Yices as solver\n"
399396
" {y--z3} \t use Z3 as solver\n"
400397
"\n"
398+
"Verilog options:\n"
399+
" {y-I} {upath} \t set include path\n"
400+
" {y-D} {uvar}[={uvalue}] \t set preprocessor define\n"
401+
" {y--systemverilog} \t force SystemVerilog instead of Verilog\n"
402+
" {y--reset} {uexpr} \t set up module reset\n"
403+
" {y--ignore-initial} \t disregard initial blocks\n"
404+
"\n"
401405
"Debugging options:\n"
402406
" {y--preprocess} \t output the preprocessed source file\n"
403407
" {y--show-parse} \t show parse trees\n"

src/ebmc/ebmc_parse_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ebmc_parse_optionst:public parse_options_baset
3535
"(outfile):(xml-ui)(verbosity):(gui)"
3636
"(json-modules):(json-properties):(json-result):"
3737
"(neural-liveness)(neural-engine):"
38-
"(reset):"
38+
"(reset):(ignore-initial)"
3939
"(version)(verilog-rtl)(verilog-netlist)"
4040
"(compute-interpolant)(interpolation)(interpolation-vmcai)"
4141
"(ic3)(property):(constr)(h)(new-mode)(aiger)"

src/ebmc/transition_system.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ static bool parse(
174174
if(cmdline.isset('D'))
175175
options.set_option("defines", cmdline.get_values('D'));
176176

177+
// do --ignore-initial
178+
if(cmdline.isset("ignore-initial"))
179+
options.set_option("ignore-initial", true);
180+
177181
language.set_language_options(options, message_handler);
178182

179183
message.status() << "Parsing " << filename << messaget::eom;

src/verilog/verilog_language.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void verilog_languaget::set_language_options(
3939
include_paths = options.get_list_option("I");
4040
initial_defines = options.get_list_option("defines");
4141
warn_implicit_nets = options.get_bool_option("warn-implicit-nets");
42+
ignore_initial = options.get_bool_option("ignore-initial");
4243
}
4344

4445
/*******************************************************************\
@@ -191,8 +192,14 @@ bool verilog_languaget::typecheck(
191192
message.debug() << "Synthesis " << module << messaget::eom;
192193

193194
if(verilog_synthesis(
194-
symbol_table, module, parse_tree.standard, message_handler, optionst{}))
195+
symbol_table,
196+
module,
197+
parse_tree.standard,
198+
ignore_initial,
199+
message_handler))
200+
{
195201
return true;
202+
}
196203

197204
return false;
198205
}

src/verilog/verilog_language.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class verilog_languaget:public languaget
9494
bool force_systemverilog = false;
9595
bool vl2smv_extensions = false;
9696
bool warn_implicit_nets = false;
97+
bool ignore_initial = false;
9798
std::list<std::string> include_paths;
9899
std::list<std::string> initial_defines;
99100
verilog_parse_treet parse_tree;

src/verilog/verilog_synthesis.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,11 @@ void verilog_synthesist::synth_module_instance(
14591459

14601460
// make sure the module is synthesized already
14611461
verilog_synthesis(
1462-
symbol_table, module_identifier, standard, get_message_handler(), options);
1462+
symbol_table,
1463+
module_identifier,
1464+
standard,
1465+
ignore_initial,
1466+
get_message_handler());
14631467

14641468
for(auto &instance : statement.instances())
14651469
expand_module_instance(module_symbol, instance, trans);
@@ -1782,6 +1786,9 @@ void verilog_synthesist::synth_initial(
17821786
<< "initial module item expected to have one operand";
17831787
}
17841788

1789+
if(ignore_initial)
1790+
return;
1791+
17851792
construct=constructt::INITIAL;
17861793
event_guard=event_guardt::NONE;
17871794

@@ -3716,12 +3723,12 @@ bool verilog_synthesis(
37163723
symbol_table_baset &symbol_table,
37173724
const irep_idt &module,
37183725
verilog_standardt standard,
3719-
message_handlert &message_handler,
3720-
const optionst &options)
3726+
bool ignore_initial,
3727+
message_handlert &message_handler)
37213728
{
37223729
const namespacet ns(symbol_table);
37233730
verilog_synthesist verilog_synthesis(
3724-
standard, ns, symbol_table, module, options, message_handler);
3731+
standard, ignore_initial, ns, symbol_table, module, message_handler);
37253732
return verilog_synthesis.typecheck_main();
37263733
}
37273734

@@ -3744,14 +3751,13 @@ bool verilog_synthesis(
37443751
message_handlert &message_handler,
37453752
const namespacet &ns)
37463753
{
3747-
optionst options;
37483754
symbol_tablet symbol_table;
37493755

37503756
const auto errors_before =
37513757
message_handler.get_message_count(messaget::M_ERROR);
37523758

37533759
verilog_synthesist verilog_synthesis(
3754-
standard, ns, symbol_table, module_identifier, options, message_handler);
3760+
standard, false, ns, symbol_table, module_identifier, message_handler);
37553761

37563762
try
37573763
{

src/verilog/verilog_synthesis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ bool verilog_synthesis(
1919
symbol_table_baset &,
2020
const irep_idt &module,
2121
verilog_standardt,
22-
message_handlert &,
23-
const optionst &);
22+
bool ignore_initial,
23+
message_handlert &);
2424

2525
bool verilog_synthesis(
2626
exprt &,

src/verilog/verilog_synthesis_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class verilog_synthesist:
4242
public:
4343
verilog_synthesist(
4444
verilog_standardt _standard,
45+
bool _ignore_initial,
4546
const namespacet &_ns,
4647
symbol_table_baset &_symbol_table,
4748
const irep_idt &_module,
48-
const optionst &_options,
4949
message_handlert &_message_handler)
5050
: verilog_typecheck_baset(_standard, _ns, _message_handler),
5151
verilog_symbol_tablet(_symbol_table),
52-
options(_options),
52+
ignore_initial(_ignore_initial),
5353
value_map(NULL),
5454
module(_module),
5555
temporary_counter(0)
@@ -69,7 +69,7 @@ class verilog_synthesist:
6969
[[nodiscard]] exprt synth_expr(exprt expr, symbol_statet symbol_state);
7070

7171
protected:
72-
const optionst &options;
72+
bool ignore_initial;
7373

7474
[[nodiscard]] exprt synth_expr_rec(exprt expr, symbol_statet symbol_state);
7575

0 commit comments

Comments
 (0)