Skip to content

Commit e7fcf46

Browse files
committed
Verilog: create $root module instance
Create a $root module instance that contains an instance of the top-level module, per IEEE 1800-2017. The $root module is synthesized via verilog_synthesis, which expands the top-level module into $root's namespace. The main_symbol now points to $root. The $root module's type is copied from the top-level module (including ports), and its module field is set to the instance identifier for expression resolution (used by -p, --reset, etc.). Pretty names and expression output strip the $root prefix since it is implicit in SystemVerilog.
1 parent fa2c2c0 commit e7fcf46

12 files changed

Lines changed: 155 additions & 43 deletions

File tree

regression/ebmc/netlist/netlist-output1.desc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ netlist-output1.v
33
--show-netlist
44
activate-multi-line-match
55
^Variable map:
6-
Verilog::main\.clk=0->false \(input\)
7-
Verilog::main\.data=1->false \(input\)
8-
Verilog::main\.some_register=2->!3 \(latch\)
9-
Verilog::main\.some_register_aux0=!3->false \(wire\)
6+
Verilog::\$root.main\.clk=0->false \(input\)
7+
Verilog::\$root.main\.data=1->false \(input\)
8+
Verilog::\$root.main\.some_register=2->!3 \(latch\)
9+
Verilog::\$root.main\.some_register_aux0=!3->false \(wire\)
1010

1111
Total no. of variable bits: 3
1212
Total no. of latch bits: 1
@@ -15,10 +15,10 @@ Total no. of input bits: 2
1515
Total no. of output bits: 0
1616

1717
Next state functions:
18-
NEXT\(Verilog::main\.some_register\)=!\(!\(Verilog::main\.data\) & !\(Verilog::main\.some_register\)\)
18+
NEXT\(Verilog::\$root.main\.some_register\)=!\(!\(Verilog::\$root.main\.data\) & !\(Verilog::\$root.main\.some_register\)\)
1919

2020
Initial state:
21-
!\(Verilog::main\.some_register\)
21+
!\(Verilog::\$root.main\.some_register\)
2222

2323
State invariant constraints:
2424

regression/ebmc/smv-netlist/array_assignment.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
array_assignment.sv
33
--reset rst --smv-netlist --simple-netlist
4-
^ASSIGN next\(Verilog\.main\.data\[0\]\):=nondet\[1\];$
5-
^ASSIGN next\(Verilog\.main\.data\[1\]\):=nondet\[2\];$
4+
^ASSIGN next\(Verilog\.\$36\$root\.main\.data\[0\]\):=nondet\[1\];$
5+
^ASSIGN next\(Verilog\.\$36\$root\.main\.data\[1\]\):=nondet\[2\];$
66
^EXIT=0$
77
^SIGNAL=0$
88
--

regression/ebmc/smv-netlist/verilog1.desc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ CORE
22
verilog1.sv
33
--smv-netlist
44
^MODULE main$
5-
^VAR Verilog\.main\.x: boolean;$
6-
^ASSIGN next\(Verilog\.main\.x\):=\!Verilog\.main\.x;$
7-
^INIT !Verilog\.main\.x$
8-
^-- Verilog::main.assert.1$
9-
^LTLSPEC G F Verilog\.main\.x$
10-
^-- Verilog::main.assert.2$
5+
^VAR Verilog\.\$36\$root\.main\.x: boolean;$
6+
^ASSIGN next\(Verilog\.\$36\$root\.main\.x\):=\!Verilog\.\$36\$root\.main\.x;$
7+
^INIT !Verilog\.\$36\$root\.main\.x$
8+
^-- Verilog::\$root\.main\.assert\.1$
9+
^LTLSPEC G F Verilog\.\$36\$root\.main\.x$
10+
^-- Verilog::\$root\.main\.assert\.2$
1111
^-- not translated$
1212
^EXIT=0$
1313
^SIGNAL=0$

regression/ebmc/traces/json1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
json1.v
33
--bound 10 --json-result -
4-
^ "identifier": "Verilog::main\.property\.p1",$
4+
^ "identifier": "Verilog::\$root\.main\.property\.p1",$
55
^ "status": "REFUTED",$
66
^ "trace": \{$
77
^ "states": \[ \[$

regression/smv/smv-netlist/smv_netlist1.desc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
CORE
22
smv_netlist1.v
33
--smv-netlist
4-
^VAR Verilog\.main\.my-bit: boolean;$
5-
^VAR Verilog\.main\.clk: boolean;$
6-
^ASSIGN next\(Verilog\.main\.my-bit\):=!Verilog\.main\.my-bit;$
7-
^INIT !Verilog\.main\.my-bit$
4+
^VAR Verilog\.\$36\$root\.main\.my-bit: boolean;$
5+
^VAR Verilog\.\$36\$root\.main\.clk: boolean;$
6+
^ASSIGN next\(Verilog\.\$36\$root\.main\.my-bit\):=!Verilog\.\$36\$root\.main\.my-bit;$
7+
^INIT !Verilog\.\$36\$root\.main\.my-bit$
88
^EXIT=0$
99
^SIGNAL=0$
1010
--
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
CORE
22
show-module-hierarchy1.v
33
--show-module-hierarchy
4-
^main:$
5-
^ inner main\.inner_instance1$
6-
^ leaf1 main\.inner_instance1\.leaf1_instance$
7-
^ leaf2 main\.inner_instance1\.leaf2_instance$
8-
^ inner main\.inner_instance2$
9-
^ leaf1 main\.inner_instance2\.leaf1_instance$
10-
^ leaf2 main\.inner_instance2\.leaf2_instance$
4+
^\$root:$
5+
^ main main$
6+
^ inner main\.inner_instance1$
7+
^ leaf1 main\.inner_instance1\.leaf1_instance$
8+
^ leaf2 main\.inner_instance1\.leaf2_instance$
9+
^ inner main\.inner_instance2$
10+
^ leaf1 main\.inner_instance2\.leaf1_instance$
11+
^ leaf2 main\.inner_instance2\.leaf2_instance$
1112
^EXIT=0$
1213
^SIGNAL=0$
1314
--

src/ebmc/instrument_past.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ model_past(const past_sett &past_set, transition_systemt &transition_system)
9797
symbolt symbol{
9898
identifier, past_expr.type(), transition_system.main_symbol->mode};
9999
symbol.is_state_var = true;
100-
symbol.module = transition_system.main_symbol->module;
100+
symbol.module = transition_system.main_symbol->name;
101101
transition_system.symbol_table.add(std::move(symbol));
102102
}
103103

src/ebmc/live_signal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void set_live_signal(transition_systemt &transition_system, exprt property)
2323
symbolt live_symbol{
2424
identifier, bool_typet(), transition_system.main_symbol->mode};
2525

26-
live_symbol.module = transition_system.main_symbol->module;
26+
live_symbol.module = transition_system.main_symbol->name;
2727
live_symbol.base_name = "live";
2828

2929
const auto symbol_expr = live_symbol.symbol_expr();

src/ebmc/liveness_to_safety.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void liveness_to_safetyt::operator()()
170170
transition_system.main_symbol->mode};
171171

172172
save_symbol.is_input = true;
173-
save_symbol.module = transition_system.main_symbol->module;
173+
save_symbol.module = transition_system.main_symbol->name;
174174
save_symbol.base_name = "save";
175175

176176
auto result = transition_system.symbol_table.insert(std::move(save_symbol));
@@ -185,7 +185,7 @@ void liveness_to_safetyt::operator()()
185185
transition_system.main_symbol->mode};
186186

187187
saved_symbol.is_state_var = true;
188-
saved_symbol.module = transition_system.main_symbol->module;
188+
saved_symbol.module = transition_system.main_symbol->name;
189189
saved_symbol.base_name = "saved";
190190

191191
auto result =
@@ -223,7 +223,7 @@ void liveness_to_safetyt::operator()()
223223
transition_system.main_symbol->mode};
224224

225225
looped_symbol.is_state_var = false;
226-
looped_symbol.module = transition_system.main_symbol->module;
226+
looped_symbol.module = transition_system.main_symbol->name;
227227

228228
auto result =
229229
transition_system.symbol_table.insert(std::move(looped_symbol));
@@ -278,7 +278,7 @@ void liveness_to_safetyt::translate_GFp(propertyt &property)
278278
transition_system.main_symbol->mode};
279279

280280
live_symbol.is_state_var = true;
281-
live_symbol.module = transition_system.main_symbol->module;
281+
live_symbol.module = transition_system.main_symbol->name;
282282

283283
auto result = transition_system.symbol_table.insert(std::move(live_symbol));
284284
CHECK_RETURN(result.second);

src/trans-netlist/trans_trace.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -817,14 +817,17 @@ void show_trans_trace_vcd(
817817

818818
auto &module_symbol = ns.lookup(symbol1.module);
819819

820-
// print those in the top module
821-
822-
out << "$scope module " << module_symbol.display_name() << " $end\n";
823-
824-
// split up into hierarchy
825-
vcd_hierarchy_rec(ns, ids, id2string(module_symbol.name) + ".", out, 1);
826-
827-
out << "$upscope $end\n";
820+
// print those in the top module -- skip $root scope in VCD output
821+
if(module_symbol.base_name == "$root")
822+
{
823+
vcd_hierarchy_rec(ns, ids, id2string(module_symbol.name) + ".", out, 0);
824+
}
825+
else
826+
{
827+
out << "$scope module " << module_symbol.display_name() << " $end\n";
828+
vcd_hierarchy_rec(ns, ids, id2string(module_symbol.name) + ".", out, 1);
829+
out << "$upscope $end\n";
830+
}
828831

829832
out << "$enddefinitions $end\n";
830833

0 commit comments

Comments
 (0)