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
)
94 log_assert(parent
->children
.count(instance
) == 0);
95 parent
->children
[instance
] = this;
98 for (auto wire
: module
->wires())
100 SigSpec sig
= sigmap(wire
);
102 for (int i
= 0; i
< GetSize(sig
); i
++) {
103 if (state_nets
.count(sig
[i
]) == 0)
104 state_nets
[sig
[i
]] = State::Sx
;
105 if (wire
->port_output
) {
106 upd_outports
[sig
[i
]].insert(wire
);
107 dirty_bits
.insert(sig
[i
]);
111 if (wire
->attributes
.count(ID::init
)) {
112 Const initval
= wire
->attributes
.at(ID::init
);
113 for (int i
= 0; i
< GetSize(sig
) && i
< GetSize(initval
); i
++)
114 if (initval
[i
] == State::S0
|| initval
[i
] == State::S1
) {
115 state_nets
[sig
[i
]] = initval
[i
];
116 dirty_bits
.insert(sig
[i
]);
121 for (auto cell
: module
->cells())
123 Module
*mod
= module
->design
->module(cell
->type
);
125 if (mod
!= nullptr) {
126 dirty_children
.insert(new SimInstance(shared
, mod
, cell
, this));
129 for (auto &port
: cell
->connections()) {
130 if (cell
->input(port
.first
))
131 for (auto bit
: sigmap(port
.second
)) {
132 upd_cells
[bit
].insert(cell
);
133 // Make sure cell inputs connected to constants are updated in the first cycle
134 if (bit
.wire
== nullptr)
135 dirty_bits
.insert(bit
);
139 if (cell
->type
.in(ID($dff
))) {
141 ff
.past_clock
= State::Sx
;
142 ff
.past_d
= Const(State::Sx
, cell
->getParam(ID::WIDTH
).as_int());
143 ff_database
[cell
] = ff
;
146 if (cell
->type
== ID($mem
))
150 mem
.past_wr_clk
= Const(State::Sx
, GetSize(cell
->getPort(ID::WR_CLK
)));
151 mem
.past_wr_en
= Const(State::Sx
, GetSize(cell
->getPort(ID::WR_EN
)));
152 mem
.past_wr_addr
= Const(State::Sx
, GetSize(cell
->getPort(ID::WR_ADDR
)));
153 mem
.past_wr_data
= Const(State::Sx
, GetSize(cell
->getPort(ID::WR_DATA
)));
155 mem
.data
= cell
->getParam(ID::INIT
);
156 int sz
= cell
->getParam(ID::SIZE
).as_int() * cell
->getParam(ID::WIDTH
).as_int();
158 if (GetSize(mem
.data
) > sz
)
159 mem
.data
.bits
.resize(sz
);
161 while (GetSize(mem
.data
) < sz
)
162 mem
.data
.bits
.push_back(State::Sx
);
164 mem_database
[cell
] = mem
;
166 if (cell
->type
.in(ID($memwr
),ID($memrd
)))
168 log_error("$memrd and $memwr cells have to be merged to stand-alone $mem cells (execute memory_collect pass)\n");
170 if (cell
->type
.in(ID($
assert), ID($cover
), ID($assume
))) {
171 formal_database
.insert(cell
);
177 for (auto &it
: ff_database
)
179 Cell
*cell
= it
.first
;
180 ff_state_t
&ff
= it
.second
;
183 SigSpec qsig
= cell
->getPort(ID::Q
);
184 Const qdata
= get_state(qsig
);
186 set_state(qsig
, qdata
);
189 for (auto &it
: mem_database
) {
190 mem_state_t
&mem
= it
.second
;
191 zinit(mem
.past_wr_en
);
199 for (auto child
: children
)
203 IdString
name() const
205 if (instance
!= nullptr)
206 return instance
->name
;
210 std::string
hiername() const
212 if (instance
!= nullptr)
213 return parent
->hiername() + "." + log_id(instance
->name
);
215 return log_id(module
->name
);
218 Const
get_state(SigSpec sig
)
222 for (auto bit
: sigmap(sig
))
223 if (bit
.wire
== nullptr)
224 value
.bits
.push_back(bit
.data
);
225 else if (state_nets
.count(bit
))
226 value
.bits
.push_back(state_nets
.at(bit
));
228 value
.bits
.push_back(State::Sz
);
231 log("[%s] get %s: %s\n", hiername().c_str(), log_signal(sig
), log_signal(value
));
235 bool set_state(SigSpec sig
, Const value
)
237 bool did_something
= false;
240 log_assert(GetSize(sig
) <= GetSize(value
));
242 for (int i
= 0; i
< GetSize(sig
); i
++)
243 if (state_nets
.at(sig
[i
]) != value
[i
]) {
244 state_nets
.at(sig
[i
]) = value
[i
];
245 dirty_bits
.insert(sig
[i
]);
246 did_something
= true;
250 log("[%s] set %s: %s\n", hiername().c_str(), log_signal(sig
), log_signal(value
));
251 return did_something
;
254 void update_cell(Cell
*cell
)
256 if (ff_database
.count(cell
))
259 if (formal_database
.count(cell
))
262 if (mem_database
.count(cell
))
264 mem_state_t
&mem
= mem_database
.at(cell
);
266 int num_rd_ports
= cell
->getParam(ID::RD_PORTS
).as_int();
268 int size
= cell
->getParam(ID::SIZE
).as_int();
269 int offset
= cell
->getParam(ID::OFFSET
).as_int();
270 int abits
= cell
->getParam(ID::ABITS
).as_int();
271 int width
= cell
->getParam(ID::WIDTH
).as_int();
273 if (cell
->getParam(ID::RD_CLK_ENABLE
).as_bool())
274 log_error("Memory %s.%s has clocked read ports. Run 'memory' with -nordff.\n", log_id(module
), log_id(cell
));
276 SigSpec rd_addr_sig
= cell
->getPort(ID::RD_ADDR
);
277 SigSpec rd_data_sig
= cell
->getPort(ID::RD_DATA
);
279 for (int port_idx
= 0; port_idx
< num_rd_ports
; port_idx
++)
281 Const addr
= get_state(rd_addr_sig
.extract(port_idx
*abits
, abits
));
282 Const data
= Const(State::Sx
, width
);
284 if (addr
.is_fully_def()) {
285 int index
= addr
.as_int() - offset
;
286 if (index
>= 0 && index
< size
)
287 data
= mem
.data
.extract(index
*width
, width
);
290 set_state(rd_data_sig
.extract(port_idx
*width
, width
), data
);
296 if (children
.count(cell
))
298 auto child
= children
.at(cell
);
299 for (auto &conn
: cell
->connections())
300 if (cell
->input(conn
.first
)) {
301 Const value
= get_state(conn
.second
);
302 child
->set_state(child
->module
->wire(conn
.first
), value
);
304 dirty_children
.insert(child
);
308 if (yosys_celltypes
.cell_evaluable(cell
->type
))
310 RTLIL::SigSpec sig_a
, sig_b
, sig_c
, sig_d
, sig_s
, sig_y
;
311 bool has_a
, has_b
, has_c
, has_d
, has_s
, has_y
;
313 has_a
= cell
->hasPort(ID::A
);
314 has_b
= cell
->hasPort(ID::B
);
315 has_c
= cell
->hasPort(ID::C
);
316 has_d
= cell
->hasPort(ID::D
);
317 has_s
= cell
->hasPort(ID::S
);
318 has_y
= cell
->hasPort(ID::Y
);
320 if (has_a
) sig_a
= cell
->getPort(ID::A
);
321 if (has_b
) sig_b
= cell
->getPort(ID::B
);
322 if (has_c
) sig_c
= cell
->getPort(ID::C
);
323 if (has_d
) sig_d
= cell
->getPort(ID::D
);
324 if (has_s
) sig_s
= cell
->getPort(ID::S
);
325 if (has_y
) sig_y
= cell
->getPort(ID::Y
);
328 log("[%s] eval %s (%s)\n", hiername().c_str(), log_id(cell
), log_id(cell
->type
));
330 // Simple (A -> Y) and (A,B -> Y) cells
331 if (has_a
&& !has_c
&& !has_d
&& !has_s
&& has_y
) {
332 set_state(sig_y
, CellTypes::eval(cell
, get_state(sig_a
), get_state(sig_b
)));
336 // (A,B,C -> Y) cells
337 if (has_a
&& has_b
&& has_c
&& !has_d
&& !has_s
&& has_y
) {
338 set_state(sig_y
, CellTypes::eval(cell
, get_state(sig_a
), get_state(sig_b
), get_state(sig_c
)));
342 // (A,B,S -> Y) cells
343 if (has_a
&& has_b
&& !has_c
&& !has_d
&& has_s
&& has_y
) {
344 set_state(sig_y
, CellTypes::eval(cell
, get_state(sig_a
), get_state(sig_b
), get_state(sig_s
)));
348 log_warning("Unsupported evaluable cell type: %s (%s.%s)\n", log_id(cell
->type
), log_id(module
), log_id(cell
));
352 log_error("Unsupported cell type: %s (%s.%s)\n", log_id(cell
->type
), log_id(module
), log_id(cell
));
357 pool
<Cell
*> queue_cells
;
358 pool
<Wire
*> queue_outports
;
360 queue_cells
.swap(dirty_cells
);
364 for (auto bit
: dirty_bits
)
366 if (upd_cells
.count(bit
))
367 for (auto cell
: upd_cells
.at(bit
))
368 queue_cells
.insert(cell
);
370 if (upd_outports
.count(bit
) && parent
!= nullptr)
371 for (auto wire
: upd_outports
.at(bit
))
372 queue_outports
.insert(wire
);
377 if (!queue_cells
.empty())
379 for (auto cell
: queue_cells
)
386 for (auto wire
: queue_outports
)
387 if (instance
->hasPort(wire
->name
)) {
388 Const value
= get_state(wire
);
389 parent
->set_state(instance
->getPort(wire
->name
), value
);
392 queue_outports
.clear();
394 for (auto child
: dirty_children
)
397 dirty_children
.clear();
399 if (dirty_bits
.empty())
406 bool did_something
= false;
408 for (auto &it
: ff_database
)
410 Cell
*cell
= it
.first
;
411 ff_state_t
&ff
= it
.second
;
413 if (cell
->type
.in(ID($dff
)))
415 bool clkpol
= cell
->getParam(ID::CLK_POLARITY
).as_bool();
416 State current_clock
= get_state(cell
->getPort(ID::CLK
))[0];
418 if (clkpol
? (ff
.past_clock
== State::S1
|| current_clock
!= State::S1
) :
419 (ff
.past_clock
== State::S0
|| current_clock
!= State::S0
))
422 if (set_state(cell
->getPort(ID::Q
), ff
.past_d
))
423 did_something
= true;
427 for (auto &it
: mem_database
)
429 Cell
*cell
= it
.first
;
430 mem_state_t
&mem
= it
.second
;
432 int num_wr_ports
= cell
->getParam(ID::WR_PORTS
).as_int();
434 int size
= cell
->getParam(ID::SIZE
).as_int();
435 int offset
= cell
->getParam(ID::OFFSET
).as_int();
436 int abits
= cell
->getParam(ID::ABITS
).as_int();
437 int width
= cell
->getParam(ID::WIDTH
).as_int();
439 Const wr_clk_enable
= cell
->getParam(ID::WR_CLK_ENABLE
);
440 Const wr_clk_polarity
= cell
->getParam(ID::WR_CLK_POLARITY
);
441 Const current_wr_clk
= get_state(cell
->getPort(ID::WR_CLK
));
443 for (int port_idx
= 0; port_idx
< num_wr_ports
; port_idx
++)
445 Const addr
, data
, enable
;
447 if (wr_clk_enable
[port_idx
] == State::S0
)
449 addr
= get_state(cell
->getPort(ID::WR_ADDR
).extract(port_idx
*abits
, abits
));
450 data
= get_state(cell
->getPort(ID::WR_DATA
).extract(port_idx
*width
, width
));
451 enable
= get_state(cell
->getPort(ID::WR_EN
).extract(port_idx
*width
, width
));
455 if (wr_clk_polarity
[port_idx
] == State::S1
?
456 (mem
.past_wr_clk
[port_idx
] == State::S1
|| current_wr_clk
[port_idx
] != State::S1
) :
457 (mem
.past_wr_clk
[port_idx
] == State::S0
|| current_wr_clk
[port_idx
] != State::S0
))
460 addr
= mem
.past_wr_addr
.extract(port_idx
*abits
, abits
);
461 data
= mem
.past_wr_data
.extract(port_idx
*width
, width
);
462 enable
= mem
.past_wr_en
.extract(port_idx
*width
, width
);
465 if (addr
.is_fully_def())
467 int index
= addr
.as_int() - offset
;
468 if (index
>= 0 && index
< size
)
469 for (int i
= 0; i
< width
; i
++)
470 if (enable
[i
] == State::S1
&& mem
.data
.bits
.at(index
*width
+i
) != data
[i
]) {
471 mem
.data
.bits
.at(index
*width
+i
) = data
[i
];
472 dirty_cells
.insert(cell
);
473 did_something
= true;
479 for (auto it
: children
)
480 if (it
.second
->update_ph2()) {
481 dirty_children
.insert(it
.second
);
482 did_something
= true;
485 return did_something
;
490 for (auto &it
: ff_database
)
492 Cell
*cell
= it
.first
;
493 ff_state_t
&ff
= it
.second
;
495 if (cell
->type
.in(ID($dff
))) {
496 ff
.past_clock
= get_state(cell
->getPort(ID::CLK
))[0];
497 ff
.past_d
= get_state(cell
->getPort(ID::D
));
501 for (auto &it
: mem_database
)
503 Cell
*cell
= it
.first
;
504 mem_state_t
&mem
= it
.second
;
506 mem
.past_wr_clk
= get_state(cell
->getPort(ID::WR_CLK
));
507 mem
.past_wr_en
= get_state(cell
->getPort(ID::WR_EN
));
508 mem
.past_wr_addr
= get_state(cell
->getPort(ID::WR_ADDR
));
509 mem
.past_wr_data
= get_state(cell
->getPort(ID::WR_DATA
));
512 for (auto cell
: formal_database
)
514 string label
= log_id(cell
);
515 if (cell
->attributes
.count(ID::src
))
516 label
= cell
->attributes
.at(ID::src
).decode_string();
518 State a
= get_state(cell
->getPort(ID::A
))[0];
519 State en
= get_state(cell
->getPort(ID::EN
))[0];
521 if (cell
->type
== ID($cover
) && en
== State::S1
&& a
!= State::S1
)
522 log("Cover %s.%s (%s) reached.\n", hiername().c_str(), log_id(cell
), label
.c_str());
524 if (cell
->type
== ID($assume
) && en
== State::S1
&& a
!= State::S1
)
525 log("Assumption %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell
), label
.c_str());
527 if (cell
->type
== ID($
assert) && en
== State::S1
&& a
!= State::S1
)
528 log_warning("Assert %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell
), label
.c_str());
531 for (auto it
: children
)
532 it
.second
->update_ph3();
535 void writeback(pool
<Module
*> &wbmods
)
537 if (wbmods
.count(module
))
538 log_error("Instance %s of module %s is not unique: Writeback not possible. (Fix by running 'uniquify'.)\n", hiername().c_str(), log_id(module
));
540 wbmods
.insert(module
);
542 for (auto wire
: module
->wires())
543 wire
->attributes
.erase(ID::init
);
545 for (auto &it
: ff_database
)
547 Cell
*cell
= it
.first
;
548 SigSpec sig_q
= cell
->getPort(ID::Q
);
549 Const initval
= get_state(sig_q
);
551 for (int i
= 0; i
< GetSize(sig_q
); i
++)
553 Wire
*w
= sig_q
[i
].wire
;
555 if (w
->attributes
.count(ID::init
) == 0)
556 w
->attributes
[ID::init
] = Const(State::Sx
, GetSize(w
));
558 w
->attributes
[ID::init
][sig_q
[i
].offset
] = initval
[i
];
562 for (auto &it
: mem_database
)
564 Cell
*cell
= it
.first
;
565 mem_state_t
&mem
= it
.second
;
566 Const initval
= mem
.data
;
568 while (GetSize(initval
) >= 2) {
569 if (initval
[GetSize(initval
)-1] != State::Sx
) break;
570 if (initval
[GetSize(initval
)-2] != State::Sx
) break;
571 initval
.bits
.pop_back();
574 cell
->setParam(ID::INIT
, initval
);
577 for (auto it
: children
)
578 it
.second
->writeback(wbmods
);
581 void write_vcd_header(std::ofstream
&f
, int &id
)
583 f
<< stringf("$scope module %s $end\n", log_id(name()));
585 for (auto wire
: module
->wires())
587 if (shared
->hide_internal
&& wire
->name
[0] == '$')
590 f
<< stringf("$var wire %d n%d %s%s $end\n", GetSize(wire
), id
, wire
->name
[0] == '$' ? "\\" : "", log_id(wire
));
591 vcd_database
[wire
] = make_pair(id
++, Const());
594 for (auto child
: children
)
595 child
.second
->write_vcd_header(f
, id
);
597 f
<< stringf("$upscope $end\n");
600 void write_vcd_step(std::ofstream
&f
)
602 for (auto &it
: vcd_database
)
604 Wire
*wire
= it
.first
;
605 Const value
= get_state(wire
);
606 int id
= it
.second
.first
;
608 if (it
.second
.second
== value
)
611 it
.second
.second
= value
;
614 for (int i
= GetSize(value
)-1; i
>= 0; i
--) {
616 case State::S0
: f
<< "0"; break;
617 case State::S1
: f
<< "1"; break;
618 case State::Sx
: f
<< "x"; break;
623 f
<< stringf(" n%d\n", id
);
626 for (auto child
: children
)
627 child
.second
->write_vcd_step(f
);
631 struct SimWorker
: SimShared
633 SimInstance
*top
= nullptr;
634 std::ofstream vcdfile
;
635 pool
<IdString
> clock
, clockn
, reset
, resetn
;
642 void write_vcd_header()
644 if (!vcdfile
.is_open())
648 top
->write_vcd_header(vcdfile
, id
);
650 vcdfile
<< stringf("$enddefinitions $end\n");
653 void write_vcd_step(int t
)
655 if (!vcdfile
.is_open())
658 vcdfile
<< stringf("#%d\n", t
);
659 top
->write_vcd_step(vcdfile
);
667 log("\n-- ph1 --\n");
672 log("\n-- ph2 --\n");
674 if (!top
->update_ph2())
679 log("\n-- ph3 --\n");
684 void set_inports(pool
<IdString
> ports
, State value
)
686 for (auto portname
: ports
)
688 Wire
*w
= top
->module
->wire(portname
);
691 log_error("Can't find port %s on module %s.\n", log_id(portname
), log_id(top
->module
));
693 top
->set_state(w
, value
);
697 void run(Module
*topmod
, int numcycles
)
699 log_assert(top
== nullptr);
700 top
= new SimInstance(this, topmod
);
703 log("\n===== 0 =====\n");
705 log("Simulating cycle 0.\n");
707 set_inports(reset
, State::S1
);
708 set_inports(resetn
, State::S0
);
710 set_inports(clock
, State::Sx
);
711 set_inports(clockn
, State::Sx
);
718 for (int cycle
= 0; cycle
< numcycles
; cycle
++)
721 log("\n===== %d =====\n", 10*cycle
+ 5);
723 set_inports(clock
, State::S0
);
724 set_inports(clockn
, State::S1
);
727 write_vcd_step(10*cycle
+ 5);
730 log("\n===== %d =====\n", 10*cycle
+ 10);
732 log("Simulating cycle %d.\n", cycle
+1);
734 set_inports(clock
, State::S1
);
735 set_inports(clockn
, State::S0
);
737 if (cycle
+1 == rstlen
) {
738 set_inports(reset
, State::S0
);
739 set_inports(resetn
, State::S1
);
743 write_vcd_step(10*cycle
+ 10);
746 write_vcd_step(10*numcycles
+ 2);
749 pool
<Module
*> wbmods
;
750 top
->writeback(wbmods
);
755 struct SimPass
: public Pass
{
756 SimPass() : Pass("sim", "simulate the circuit") { }
759 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
761 log(" sim [options] [top-level]\n");
763 log("This command simulates the circuit using the given top-level module.\n");
765 log(" -vcd <filename>\n");
766 log(" write the simulation results to the given VCD file\n");
768 log(" -clock <portname>\n");
769 log(" name of top-level clock input\n");
771 log(" -clockn <portname>\n");
772 log(" name of top-level clock input (inverse polarity)\n");
774 log(" -reset <portname>\n");
775 log(" name of top-level reset input (active high)\n");
777 log(" -resetn <portname>\n");
778 log(" name of top-level inverted reset input (active low)\n");
780 log(" -rstlen <integer>\n");
781 log(" number of cycles reset should stay active (default: 1)\n");
784 log(" zero-initialize all uninitialized regs and memories\n");
786 log(" -n <integer>\n");
787 log(" number of cycles to simulate (default: 20)\n");
790 log(" include all nets in VCD output, not just those with public names\n");
793 log(" writeback mode: use final simulation state as new init state\n");
796 log(" enable debug output\n");
799 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) override
804 log_header(design
, "Executing SIM pass (simulate the circuit).\n");
807 for (argidx
= 1; argidx
< args
.size(); argidx
++) {
808 if (args
[argidx
] == "-vcd" && argidx
+1 < args
.size()) {
809 worker
.vcdfile
.open(args
[++argidx
].c_str());
812 if (args
[argidx
] == "-n" && argidx
+1 < args
.size()) {
813 numcycles
= atoi(args
[++argidx
].c_str());
816 if (args
[argidx
] == "-rstlen" && argidx
+1 < args
.size()) {
817 worker
.rstlen
= atoi(args
[++argidx
].c_str());
820 if (args
[argidx
] == "-clock" && argidx
+1 < args
.size()) {
821 worker
.clock
.insert(RTLIL::escape_id(args
[++argidx
]));
824 if (args
[argidx
] == "-clockn" && argidx
+1 < args
.size()) {
825 worker
.clockn
.insert(RTLIL::escape_id(args
[++argidx
]));
828 if (args
[argidx
] == "-reset" && argidx
+1 < args
.size()) {
829 worker
.reset
.insert(RTLIL::escape_id(args
[++argidx
]));
832 if (args
[argidx
] == "-resetn" && argidx
+1 < args
.size()) {
833 worker
.resetn
.insert(RTLIL::escape_id(args
[++argidx
]));
836 if (args
[argidx
] == "-a") {
837 worker
.hide_internal
= false;
840 if (args
[argidx
] == "-d") {
844 if (args
[argidx
] == "-w") {
845 worker
.writeback
= true;
848 if (args
[argidx
] == "-zinit") {
854 extra_args(args
, argidx
, design
);
856 Module
*top_mod
= nullptr;
858 if (design
->full_selection()) {
859 top_mod
= design
->top_module();
862 log_cmd_error("Design has no top module, use the 'hierarchy' command to specify one.\n");
864 auto mods
= design
->selected_whole_modules();
865 if (GetSize(mods
) != 1)
866 log_cmd_error("Only one top module must be selected.\n");
867 top_mod
= mods
.front();
870 worker
.run(top_mod
, numcycles
);
874 PRIVATE_NAMESPACE_END