2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include "kernel/yosys.h"
21 #include "kernel/sigtools.h"
22 #include "kernel/celltypes.h"
25 PRIVATE_NAMESPACE_BEGIN
30 bool hide_internal
= true;
31 bool writeback
= false;
44 for (auto &bit
: v
.bits
)
56 dict
<Cell
*, SimInstance
*> children
;
59 dict
<SigBit
, State
> state_nets
;
60 dict
<SigBit
, pool
<Cell
*>> upd_cells
;
61 dict
<SigBit
, pool
<Wire
*>> upd_outports
;
63 pool
<SigBit
> dirty_bits
;
64 pool
<Cell
*> dirty_cells
;
65 pool
<SimInstance
*, hash_ptr_ops
> dirty_children
;
82 dict
<Cell
*, ff_state_t
> ff_database
;
83 dict
<Cell
*, mem_state_t
> mem_database
;
84 pool
<Cell
*> formal_database
;
86 dict
<Wire
*, pair
<int, Const
>> vcd_database
;
88 SimInstance(SimShared
*shared
, Module
*module
, Cell
*instance
= nullptr, SimInstance
*parent
= nullptr) :
89 shared(shared
), module(module
), instance(instance
), parent(parent
), sigmap(module
)
92 log_assert(parent
->children
.count(instance
) == 0);
93 parent
->children
[instance
] = this;
96 for (auto wire
: module
->wires())
98 SigSpec sig
= sigmap(wire
);
100 for (int i
= 0; i
< GetSize(sig
); i
++) {
101 if (state_nets
.count(sig
[i
]) == 0)
102 state_nets
[sig
[i
]] = State::Sx
;
103 if (wire
->port_output
) {
104 upd_outports
[sig
[i
]].insert(wire
);
105 dirty_bits
.insert(sig
[i
]);
109 if (wire
->attributes
.count("\\init")) {
110 Const initval
= wire
->attributes
.at("\\init");
111 for (int i
= 0; i
< GetSize(sig
) && i
< GetSize(initval
); i
++)
112 if (initval
[i
] == State::S0
|| initval
[i
] == State::S1
) {
113 state_nets
[sig
[i
]] = initval
[i
];
114 dirty_bits
.insert(sig
[i
]);
119 for (auto cell
: module
->cells())
121 Module
*mod
= module
->design
->module(cell
->type
);
123 if (mod
!= nullptr) {
124 dirty_children
.insert(new SimInstance(shared
, mod
, cell
, this));
127 for (auto &port
: cell
->connections()) {
128 if (cell
->input(port
.first
))
129 for (auto bit
: sigmap(port
.second
))
130 upd_cells
[bit
].insert(cell
);
133 if (cell
->type
.in("$dff")) {
135 ff
.past_clock
= State::Sx
;
136 ff
.past_d
= Const(State::Sx
, cell
->getParam("\\WIDTH").as_int());
137 ff_database
[cell
] = ff
;
140 if (cell
->type
== "$mem")
144 mem
.past_wr_clk
= Const(State::Sx
, GetSize(cell
->getPort("\\WR_CLK")));
145 mem
.past_wr_en
= Const(State::Sx
, GetSize(cell
->getPort("\\WR_EN")));
146 mem
.past_wr_addr
= Const(State::Sx
, GetSize(cell
->getPort("\\WR_ADDR")));
147 mem
.past_wr_data
= Const(State::Sx
, GetSize(cell
->getPort("\\WR_DATA")));
149 mem
.data
= cell
->getParam("\\INIT");
150 int sz
= cell
->getParam("\\SIZE").as_int() * cell
->getParam("\\WIDTH").as_int();
152 if (GetSize(mem
.data
) > sz
)
153 mem
.data
.bits
.resize(sz
);
155 while (GetSize(mem
.data
) < sz
)
156 mem
.data
.bits
.push_back(State::Sx
);
158 mem_database
[cell
] = mem
;
161 if (cell
->type
.in("$assert", "$cover", "$assume")) {
162 formal_database
.insert(cell
);
168 for (auto &it
: ff_database
)
170 Cell
*cell
= it
.first
;
171 ff_state_t
&ff
= it
.second
;
174 SigSpec qsig
= cell
->getPort("\\Q");
175 Const qdata
= get_state(qsig
);
177 set_state(qsig
, qdata
);
180 for (auto &it
: mem_database
) {
181 mem_state_t
&mem
= it
.second
;
182 zinit(mem
.past_wr_en
);
190 for (auto child
: children
)
194 IdString
name() const
196 if (instance
!= nullptr)
197 return instance
->name
;
201 std::string
hiername() const
203 if (instance
!= nullptr)
204 return parent
->hiername() + "." + log_id(instance
->name
);
206 return log_id(module
->name
);
209 Const
get_state(SigSpec sig
)
213 for (auto bit
: sigmap(sig
))
214 if (bit
.wire
== nullptr)
215 value
.bits
.push_back(bit
.data
);
216 else if (state_nets
.count(bit
))
217 value
.bits
.push_back(state_nets
.at(bit
));
219 value
.bits
.push_back(State::Sz
);
222 log("[%s] get %s: %s\n", hiername().c_str(), log_signal(sig
), log_signal(value
));
226 bool set_state(SigSpec sig
, Const value
)
228 bool did_something
= false;
231 log_assert(GetSize(sig
) == GetSize(value
));
233 for (int i
= 0; i
< GetSize(sig
); i
++)
234 if (state_nets
.at(sig
[i
]) != value
[i
]) {
235 state_nets
.at(sig
[i
]) = value
[i
];
236 dirty_bits
.insert(sig
[i
]);
237 did_something
= true;
241 log("[%s] set %s: %s\n", hiername().c_str(), log_signal(sig
), log_signal(value
));
242 return did_something
;
245 void update_cell(Cell
*cell
)
247 if (ff_database
.count(cell
))
250 if (formal_database
.count(cell
))
253 if (mem_database
.count(cell
))
255 mem_state_t
&mem
= mem_database
.at(cell
);
257 int num_rd_ports
= cell
->getParam("\\RD_PORTS").as_int();
259 int size
= cell
->getParam("\\SIZE").as_int();
260 int offset
= cell
->getParam("\\OFFSET").as_int();
261 int abits
= cell
->getParam("\\ABITS").as_int();
262 int width
= cell
->getParam("\\WIDTH").as_int();
264 if (cell
->getParam("\\RD_CLK_ENABLE").as_bool())
265 log_error("Memory %s.%s has clocked read ports. Run 'memory' with -nordff.\n", log_id(module
), log_id(cell
));
267 SigSpec rd_addr_sig
= cell
->getPort("\\RD_ADDR");
268 SigSpec rd_data_sig
= cell
->getPort("\\RD_DATA");
270 for (int port_idx
= 0; port_idx
< num_rd_ports
; port_idx
++)
272 Const addr
= get_state(rd_addr_sig
.extract(port_idx
*abits
, abits
));
273 Const data
= Const(State::Sx
, width
);
275 if (addr
.is_fully_def()) {
276 int index
= addr
.as_int() - offset
;
277 if (index
>= 0 && index
< size
)
278 data
= mem
.data
.extract(index
*width
, width
);
281 set_state(rd_data_sig
.extract(port_idx
*width
, width
), data
);
287 if (children
.count(cell
))
289 auto child
= children
.at(cell
);
290 for (auto &conn
: cell
->connections())
291 if (cell
->input(conn
.first
)) {
292 Const value
= get_state(conn
.second
);
293 child
->set_state(child
->module
->wire(conn
.first
), value
);
295 dirty_children
.insert(child
);
299 if (yosys_celltypes
.cell_evaluable(cell
->type
))
301 RTLIL::SigSpec sig_a
, sig_b
, sig_c
, sig_d
, sig_s
, sig_y
;
302 bool has_a
, has_b
, has_c
, has_d
, has_s
, has_y
;
304 has_a
= cell
->hasPort("\\A");
305 has_b
= cell
->hasPort("\\B");
306 has_c
= cell
->hasPort("\\C");
307 has_d
= cell
->hasPort("\\D");
308 has_s
= cell
->hasPort("\\S");
309 has_y
= cell
->hasPort("\\Y");
311 if (has_a
) sig_a
= cell
->getPort("\\A");
312 if (has_b
) sig_b
= cell
->getPort("\\B");
313 if (has_c
) sig_c
= cell
->getPort("\\C");
314 if (has_d
) sig_d
= cell
->getPort("\\D");
315 if (has_s
) sig_s
= cell
->getPort("\\S");
316 if (has_y
) sig_y
= cell
->getPort("\\Y");
319 log("[%s] eval %s (%s)\n", hiername().c_str(), log_id(cell
), log_id(cell
->type
));
321 // Simple (A -> Y) and (A,B -> Y) cells
322 if (has_a
&& !has_c
&& !has_d
&& !has_s
&& has_y
) {
323 set_state(sig_y
, CellTypes::eval(cell
, get_state(sig_a
), get_state(sig_b
)));
327 // (A,B,C -> Y) cells
328 if (has_a
&& has_b
&& has_c
&& !has_d
&& !has_s
&& has_y
) {
329 set_state(sig_y
, CellTypes::eval(cell
, get_state(sig_a
), get_state(sig_b
), get_state(sig_c
)));
333 // (A,B,S -> Y) cells
334 if (has_a
&& has_b
&& !has_c
&& !has_d
&& has_s
&& has_y
) {
335 set_state(sig_y
, CellTypes::eval(cell
, get_state(sig_a
), get_state(sig_b
), get_state(sig_s
)));
339 log_warning("Unsupported evaluable cell type: %s (%s.%s)\n", log_id(cell
->type
), log_id(module
), log_id(cell
));
343 log_error("Unsupported cell type: %s (%s.%s)\n", log_id(cell
->type
), log_id(module
), log_id(cell
));
348 pool
<Cell
*> queue_cells
;
349 pool
<Wire
*> queue_outports
;
351 queue_cells
.swap(dirty_cells
);
355 for (auto bit
: dirty_bits
)
357 if (upd_cells
.count(bit
))
358 for (auto cell
: upd_cells
.at(bit
))
359 queue_cells
.insert(cell
);
361 if (upd_outports
.count(bit
) && parent
!= nullptr)
362 for (auto wire
: upd_outports
.at(bit
))
363 queue_outports
.insert(wire
);
368 if (!queue_cells
.empty())
370 for (auto cell
: queue_cells
)
377 for (auto wire
: queue_outports
)
378 if (instance
->hasPort(wire
->name
)) {
379 Const value
= get_state(wire
);
380 parent
->set_state(instance
->getPort(wire
->name
), value
);
383 queue_outports
.clear();
385 for (auto child
: dirty_children
)
388 dirty_children
.clear();
390 if (dirty_bits
.empty())
397 bool did_something
= false;
399 for (auto &it
: ff_database
)
401 Cell
*cell
= it
.first
;
402 ff_state_t
&ff
= it
.second
;
404 if (cell
->type
.in("$dff"))
406 bool clkpol
= cell
->getParam("\\CLK_POLARITY").as_bool();
407 State current_clock
= get_state(cell
->getPort("\\CLK"))[0];
409 if (clkpol
? (ff
.past_clock
== State::S1
|| current_clock
!= State::S1
) :
410 (ff
.past_clock
== State::S0
|| current_clock
!= State::S0
))
413 if (set_state(cell
->getPort("\\Q"), ff
.past_d
))
414 did_something
= true;
418 for (auto &it
: mem_database
)
420 Cell
*cell
= it
.first
;
421 mem_state_t
&mem
= it
.second
;
423 int num_wr_ports
= cell
->getParam("\\WR_PORTS").as_int();
425 int size
= cell
->getParam("\\SIZE").as_int();
426 int offset
= cell
->getParam("\\OFFSET").as_int();
427 int abits
= cell
->getParam("\\ABITS").as_int();
428 int width
= cell
->getParam("\\WIDTH").as_int();
430 Const wr_clk_enable
= cell
->getParam("\\WR_CLK_ENABLE");
431 Const wr_clk_polarity
= cell
->getParam("\\WR_CLK_POLARITY");
432 Const current_wr_clk
= get_state(cell
->getPort("\\WR_CLK"));
434 for (int port_idx
= 0; port_idx
< num_wr_ports
; port_idx
++)
436 Const addr
, data
, enable
;
438 if (wr_clk_enable
[port_idx
] == State::S0
)
440 addr
= get_state(cell
->getPort("\\WR_ADDR").extract(port_idx
*abits
, abits
));
441 data
= get_state(cell
->getPort("\\WR_DATA").extract(port_idx
*width
, width
));
442 enable
= get_state(cell
->getPort("\\WR_EN").extract(port_idx
*width
, width
));
446 if (wr_clk_polarity
[port_idx
] == State::S1
?
447 (mem
.past_wr_clk
[port_idx
] == State::S1
|| current_wr_clk
[port_idx
] != State::S1
) :
448 (mem
.past_wr_clk
[port_idx
] == State::S0
|| current_wr_clk
[port_idx
] != State::S0
))
451 addr
= mem
.past_wr_addr
.extract(port_idx
*abits
, abits
);
452 data
= mem
.past_wr_data
.extract(port_idx
*width
, width
);
453 enable
= mem
.past_wr_en
.extract(port_idx
*width
, width
);
456 if (addr
.is_fully_def())
458 int index
= addr
.as_int() - offset
;
459 if (index
>= 0 && index
< size
)
460 for (int i
= 0; i
< width
; i
++)
461 if (enable
[i
] == State::S1
&& mem
.data
.bits
.at(index
*width
+i
) != data
[i
]) {
462 mem
.data
.bits
.at(index
*width
+i
) = data
[i
];
463 dirty_cells
.insert(cell
);
464 did_something
= true;
470 for (auto it
: children
)
471 if (it
.second
->update_ph2()) {
472 dirty_children
.insert(it
.second
);
473 did_something
= true;
476 return did_something
;
481 for (auto &it
: ff_database
)
483 Cell
*cell
= it
.first
;
484 ff_state_t
&ff
= it
.second
;
486 if (cell
->type
.in("$dff")) {
487 ff
.past_clock
= get_state(cell
->getPort("\\CLK"))[0];
488 ff
.past_d
= get_state(cell
->getPort("\\D"));
492 for (auto &it
: mem_database
)
494 Cell
*cell
= it
.first
;
495 mem_state_t
&mem
= it
.second
;
497 mem
.past_wr_clk
= get_state(cell
->getPort("\\WR_CLK"));
498 mem
.past_wr_en
= get_state(cell
->getPort("\\WR_EN"));
499 mem
.past_wr_addr
= get_state(cell
->getPort("\\WR_ADDR"));
500 mem
.past_wr_data
= get_state(cell
->getPort("\\WR_DATA"));
503 for (auto cell
: formal_database
)
505 string label
= log_id(cell
);
506 if (cell
->attributes
.count("\\src"))
507 label
= cell
->attributes
.at("\\src").decode_string();
509 State a
= get_state(cell
->getPort("\\A"))[0];
510 State en
= get_state(cell
->getPort("\\EN"))[0];
512 if (cell
->type
== "$cover" && en
== State::S1
&& a
!= State::S1
)
513 log("Cover %s.%s (%s) reached.\n", hiername().c_str(), log_id(cell
), label
.c_str());
515 if (cell
->type
== "$assume" && en
== State::S1
&& a
!= State::S1
)
516 log("Assumption %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell
), label
.c_str());
518 if (cell
->type
== "$assert" && en
== State::S1
&& a
!= State::S1
)
519 log_warning("Assert %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell
), label
.c_str());
522 for (auto it
: children
)
523 it
.second
->update_ph3();
526 void writeback(pool
<Module
*> &wbmods
)
528 if (wbmods
.count(module
))
529 log_error("Instance %s of module %s is not unique: Writeback not possible. (Fix by running 'uniquify'.)\n", hiername().c_str(), log_id(module
));
531 wbmods
.insert(module
);
533 for (auto wire
: module
->wires())
534 wire
->attributes
.erase("\\init");
536 for (auto &it
: ff_database
)
538 Cell
*cell
= it
.first
;
539 SigSpec sig_q
= cell
->getPort("\\Q");
540 Const initval
= get_state(sig_q
);
542 for (int i
= 0; i
< GetSize(sig_q
); i
++)
544 Wire
*w
= sig_q
[i
].wire
;
546 if (w
->attributes
.count("\\init") == 0)
547 w
->attributes
["\\init"] = Const(State::Sx
, GetSize(w
));
549 w
->attributes
["\\init"][sig_q
[i
].offset
] = initval
[i
];
553 for (auto &it
: mem_database
)
555 Cell
*cell
= it
.first
;
556 mem_state_t
&mem
= it
.second
;
557 Const initval
= mem
.data
;
559 while (GetSize(initval
) >= 2) {
560 if (initval
[GetSize(initval
)-1] != State::Sx
) break;
561 if (initval
[GetSize(initval
)-2] != State::Sx
) break;
562 initval
.bits
.pop_back();
565 cell
->setParam("\\INIT", initval
);
568 for (auto it
: children
)
569 it
.second
->writeback(wbmods
);
572 void write_vcd_header(std::ofstream
&f
, int &id
)
574 f
<< stringf("$scope module %s $end\n", log_id(name()));
576 for (auto wire
: module
->wires())
578 if (shared
->hide_internal
&& wire
->name
[0] == '$')
581 f
<< stringf("$var wire %d n%d %s%s $end\n", GetSize(wire
), id
, wire
->name
[0] == '$' ? "\\" : "", log_id(wire
));
582 vcd_database
[wire
] = make_pair(id
++, Const());
585 for (auto child
: children
)
586 child
.second
->write_vcd_header(f
, id
);
588 f
<< stringf("$upscope $end\n");
591 void write_vcd_step(std::ofstream
&f
)
593 for (auto &it
: vcd_database
)
595 Wire
*wire
= it
.first
;
596 Const value
= get_state(wire
);
597 int id
= it
.second
.first
;
599 if (it
.second
.second
== value
)
602 it
.second
.second
= value
;
605 for (int i
= GetSize(value
)-1; i
>= 0; i
--) {
607 case State::S0
: f
<< "0"; break;
608 case State::S1
: f
<< "1"; break;
609 case State::Sx
: f
<< "x"; break;
614 f
<< stringf(" n%d\n", id
);
617 for (auto child
: children
)
618 child
.second
->write_vcd_step(f
);
622 struct SimWorker
: SimShared
624 SimInstance
*top
= nullptr;
625 std::ofstream vcdfile
;
626 pool
<IdString
> clock
, clockn
, reset
, resetn
;
633 void write_vcd_header()
635 if (!vcdfile
.is_open())
639 top
->write_vcd_header(vcdfile
, id
);
641 vcdfile
<< stringf("$enddefinitions $end\n");
644 void write_vcd_step(int t
)
646 if (!vcdfile
.is_open())
649 vcdfile
<< stringf("#%d\n", t
);
650 top
->write_vcd_step(vcdfile
);
658 log("\n-- ph1 --\n");
663 log("\n-- ph2 --\n");
665 if (!top
->update_ph2())
670 log("\n-- ph3 --\n");
675 void set_inports(pool
<IdString
> ports
, State value
)
677 for (auto portname
: ports
)
679 Wire
*w
= top
->module
->wire(portname
);
682 log_error("Can't find port %s on module %s.\n", log_id(portname
), log_id(top
->module
));
684 top
->set_state(w
, value
);
688 void run(Module
*topmod
, int numcycles
)
690 log_assert(top
== nullptr);
691 top
= new SimInstance(this, topmod
);
694 log("\n===== 0 =====\n");
696 log("Simulating cycle 0.\n");
698 set_inports(reset
, State::S1
);
699 set_inports(resetn
, State::S0
);
701 set_inports(clock
, State::Sx
);
702 set_inports(clockn
, State::Sx
);
709 for (int cycle
= 0; cycle
< numcycles
; cycle
++)
712 log("\n===== %d =====\n", 10*cycle
+ 5);
714 set_inports(clock
, State::S0
);
715 set_inports(clockn
, State::S1
);
718 write_vcd_step(10*cycle
+ 5);
721 log("\n===== %d =====\n", 10*cycle
+ 10);
723 log("Simulating cycle %d.\n", cycle
+1);
725 set_inports(clock
, State::S1
);
726 set_inports(clockn
, State::S0
);
728 if (cycle
+1 == rstlen
) {
729 set_inports(reset
, State::S0
);
730 set_inports(resetn
, State::S1
);
734 write_vcd_step(10*cycle
+ 10);
737 write_vcd_step(10*numcycles
+ 2);
740 pool
<Module
*> wbmods
;
741 top
->writeback(wbmods
);
746 struct SimPass
: public Pass
{
747 SimPass() : Pass("sim", "simulate the circuit") { }
748 void help() YS_OVERRIDE
750 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
752 log(" sim [options] [top-level]\n");
754 log("This command simulates the circuit using the given top-level module.\n");
756 log(" -vcd <filename>\n");
757 log(" write the simulation results to the given VCD file\n");
759 log(" -clock <portname>\n");
760 log(" name of top-level clock input\n");
762 log(" -clockn <portname>\n");
763 log(" name of top-level clock input (inverse polarity)\n");
765 log(" -reset <portname>\n");
766 log(" name of top-level reset input (active high)\n");
768 log(" -resetn <portname>\n");
769 log(" name of top-level inverted reset input (active low)\n");
771 log(" -rstlen <integer>\n");
772 log(" number of cycles reset should stay active (default: 1)\n");
775 log(" zero-initialize all uninitialized regs and memories\n");
777 log(" -n <integer>\n");
778 log(" number of cycles to simulate (default: 20)\n");
781 log(" include all nets in VCD output, not just those with public names\n");
784 log(" writeback mode: use final simulation state as new init state\n");
787 log(" enable debug output\n");
790 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE
795 log_header(design
, "Executing SIM pass (simulate the circuit).\n");
798 for (argidx
= 1; argidx
< args
.size(); argidx
++) {
799 if (args
[argidx
] == "-vcd" && argidx
+1 < args
.size()) {
800 worker
.vcdfile
.open(args
[++argidx
].c_str());
803 if (args
[argidx
] == "-n" && argidx
+1 < args
.size()) {
804 numcycles
= atoi(args
[++argidx
].c_str());
807 if (args
[argidx
] == "-rstlen" && argidx
+1 < args
.size()) {
808 worker
.rstlen
= atoi(args
[++argidx
].c_str());
811 if (args
[argidx
] == "-clock" && argidx
+1 < args
.size()) {
812 worker
.clock
.insert(RTLIL::escape_id(args
[++argidx
]));
815 if (args
[argidx
] == "-clockn" && argidx
+1 < args
.size()) {
816 worker
.clockn
.insert(RTLIL::escape_id(args
[++argidx
]));
819 if (args
[argidx
] == "-reset" && argidx
+1 < args
.size()) {
820 worker
.reset
.insert(RTLIL::escape_id(args
[++argidx
]));
823 if (args
[argidx
] == "-resetn" && argidx
+1 < args
.size()) {
824 worker
.resetn
.insert(RTLIL::escape_id(args
[++argidx
]));
827 if (args
[argidx
] == "-a") {
828 worker
.hide_internal
= false;
831 if (args
[argidx
] == "-d") {
835 if (args
[argidx
] == "-w") {
836 worker
.writeback
= true;
839 if (args
[argidx
] == "-zinit") {
845 extra_args(args
, argidx
, design
);
847 Module
*top_mod
= nullptr;
849 if (design
->full_selection()) {
850 top_mod
= design
->top_module();
852 auto mods
= design
->selected_whole_modules();
853 if (GetSize(mods
) != 1)
854 log_cmd_error("Only one top module must be selected.\n");
855 top_mod
= mods
.front();
858 worker
.run(top_mod
, numcycles
);
862 PRIVATE_NAMESPACE_END