Optimization passes¶
clean - remove unused cells and wires¶
- yosys> help clean¶
- clean [options] [selection]¶
This is identical to 'opt_clean', but less verbose. When commands are separated using the ';;' token, this command will be executed between the commands. When commands are separated using the ';;;' token, this command will be executed in -purge mode between the commands.
Note
Help text automatically generated from
passes/opt/opt_clean.cc:729
muxpack - $mux/$pmux cascades to $pmux¶
- yosys> help muxpack¶
- muxpack [selection]¶
This pass converts cascaded chains of $pmux cells (e.g. those create from case constructs) and $mux cells (e.g. those created by if-else constructs) into $pmux cells. This optimisation is conservative --- it will only pack $mux or $pmux cells whose select lines are driven by '$eq' cells with other such cells if it can be certain that their select inputs are mutually exclusive.
Note
Help text automatically generated from
passes/opt/muxpack.cc:328
onehot - optimize $eq cells for onehot signals¶
opt - perform simple optimizations¶
- yosys> help opt¶
- opt [options] [selection]¶
This pass calls all the other opt_* passes in a useful order. This performs a series of trivial optimizations and cleanups. This pass executes the other passes in the following order: opt_expr [-mux_undef] [-mux_bool] [-undriven] [-noclkinv] [-fine] [-full] [-keepdc] opt_merge [-share_all] -nomux do opt_muxtree opt_reduce [-fine] [-full] opt_merge [-share_all] opt_share (-full only) opt_dff [-nodffe] [-nosdff] [-keepdc] [-sat] (except when called with -noff) opt_hier (-hier only) opt_clean [-purge] opt_expr [-mux_undef] [-mux_bool] [-undriven] [-noclkinv] [-fine] [-full] [-keepdc] while <changed design> When called with -fast the following script is used instead: do opt_expr [-mux_undef] [-mux_bool] [-undriven] [-noclkinv] [-fine] [-full] [-keepdc] opt_merge [-share_all] opt_dff [-nodffe] [-nosdff] [-keepdc] [-sat] (except when called with -noff) opt_hier (-hier only) opt_clean [-purge] while <changed design in opt_dff> Note: Options in square brackets (such as [-keepdc]) are passed through to the opt_* commands when given to 'opt'.Note
Help text automatically generated from
passes/opt/opt.cc:29
opt_clean - remove unused cells and wires¶
- yosys> help opt_clean¶
- opt_clean [options] [selection]¶
This pass identifies wires and cells that are unused and removes them. Other passes often remove cells but leave the wires in the design or reconnect the wires but leave the old cells in the design. This pass can be used to clean up after the passes that do the actual work. This pass only operates on completely selected modules without processes.
-purgealso remove internal nets if they have a public name
Note
Help text automatically generated from
passes/opt/opt_clean.cc:662
opt_demorgan - Optimize reductions with DeMorgan equivalents¶
opt_dff - perform DFF optimizations¶
- yosys> help opt_dff¶
- opt_dff [-nodffe] [-nosdff] [-keepdc] [-sat] [selection]¶
This pass converts flip-flops to a more suitable type by merging clock enables and synchronous reset multiplexers, removing unused control inputs, or potentially removes the flip-flop altogether, converting it to a constant driver.
-nodffedisables dff -> dffe conversion, and other transforms recognizing clock enable
-nosdffdisables dff -> sdff conversion, and other transforms recognizing sync resets
-simple-dffeonly enables clock enable recognition transform for obvious cases
-satadditionally invoke SAT solver to detect and remove flip-flops (with non-constant inputs) that can also be replaced with a constant driver
-keepdcsome optimizations change the behavior of the circuit with respect to don't-care bits. for example in 'a+0' a single x-bit in 'a' will cause all result bits to be set to x. this behavior changes when 'a+0' is replaced by 'a'. the -keepdc option disables all such optimizations.
Note
Help text automatically generated from
passes/opt/opt_dff.cc:913
opt_expr - perform const folding and simple expression rewriting¶
- yosys> help opt_expr¶
- opt_expr [options] [selection]¶
This pass performs const folding on internal cell types with constant inputs. It also performs some simple expression rewriting.
-mux_undefremove 'undef' inputs from $mux, $pmux and $_MUX_ cells
-mux_boolreplace $mux cells with inverters or buffers when possible
-undrivenreplace undriven nets with undef (x) constants
-noclkinvdo not optimize clock inverters by changing FF types
-fineperform fine-grain optimizations
-fullalias for -mux_undef -mux_bool -undriven -fine
-keepdcsome optimizations change the behavior of the circuit with respect to don't-care bits. for example in 'a+0' a single x-bit in 'a' will cause all result bits to be set to x. this behavior changes when 'a+0' is replaced by 'a'. the -keepdc option disables all such optimizations.
Note
Help text automatically generated from
passes/opt/opt_expr.cc:2277
opt_ffinv - push inverters through FFs¶
opt_hier - perform cross-boundary optimization¶
- yosys> help opt_hier¶
- opt_hier [selection]¶
This pass considers the design hierarchy and propagates unused signals, constant signals, and tied-together signals across module boundaries to facilitate optimization. Only the selected modules are affected. Note this pass changes port semantics on modules which are not the top.
Note
Help text automatically generated from
passes/opt/opt_hier.cc:407
opt_lut - optimize LUT cells¶
- yosys> help opt_lut¶
- opt_lut [options] [selection]¶
This pass combines cascaded $lut cells with unused inputs.
-tech ice40treat the design as a LUT-mapped circuit for the iCE40 architecture and preserve connections to SB_CARRY as appropriate
-limit Nonly perform the first N combines, then stop. useful for debugging.
Note
Help text automatically generated from
passes/opt/opt_lut.cc:527
opt_lut_ins - discard unused LUT inputs¶
- yosys> help opt_lut_ins¶
- opt_lut_ins [options] [selection]¶
This pass removes unused inputs from LUT cells (that is, inputs that can not influence the output signal given this LUT's value). While such LUTs cannot be directly emitted by ABC, they can be a result of various post-ABC transformations, such as mapping wide LUTs (not all sub-LUTs will use the full set of inputs) or optimizations such as xilinx_dffopt.
-tech <technology>Instead of generic $lut cells, operate on LUT cells specific to the given technology. Valid values are: xilinx, lattice, gowin.
Note
Help text automatically generated from
passes/opt/opt_lut_ins.cc:27
opt_mem - optimize memories¶
opt_mem_feedback - convert memory read-to-write port feedback paths to write enables¶
- yosys> help opt_mem_feedback¶
- opt_mem_feedback [selection]¶
This pass detects cases where an asynchronous read port is only connected via a mux tree to a write port with the same address. When such a connection is found, it is replaced with a new condition on an enable signal, allowing for removal of the read port.
Note
Help text automatically generated from
passes/opt/opt_mem_feedback.cc:326
opt_mem_priority - remove priority relations between write ports that can never collide¶
- yosys> help opt_mem_priority¶
- opt_mem_priority [selection]¶
This pass detects cases where one memory write port has priority over another even though they can never collide with each other -- ie. there can never be a situation where a given memory bit is written by both ports at the same time, for example because of always-different addresses, or mutually exclusive enable signals. In such cases, the priority relation is removed.
Note
Help text automatically generated from
passes/opt/opt_mem_priority.cc:29
opt_mem_widen - optimize memories where all ports are wide¶
opt_merge - consolidate identical cells¶
- yosys> help opt_merge¶
- opt_merge [options] [selection]¶
This pass identifies cells with identical type and input signals. Such cells are then merged to one cell.
-nomuxDo not merge MUX cells.
-share_allOperate on all cell types, not just built-in types.
-keepdcDo not merge flipflops with don't-care bits in their initial value.
Note
Help text automatically generated from
passes/opt/opt_merge.cc:328
opt_muxtree - eliminate dead trees in multiplexer trees¶
- yosys> help opt_muxtree¶
- opt_muxtree [selection]¶
This pass analyzes the control signals for the multiplexer trees in the design and identifies inputs that can never be active. It then removes this dead branches from the multiplexer trees. This pass only operates on completely selected modules without processes.
Note
Help text automatically generated from
passes/opt/opt_muxtree.cc:590
opt_reduce - simplify large MUXes and AND/OR gates¶
- yosys> help opt_reduce¶
- opt_reduce [options] [selection]¶
This pass performs two interlinked optimizations: 1. it consolidates trees of large AND gates or OR gates and eliminates duplicated inputs. 2. it identifies duplicated inputs to MUXes and replaces them with a single input with the original control signals OR'ed together.
-fineperform fine-grain optimizations
-fullalias for -fine
Note
Help text automatically generated from
passes/opt/opt_reduce.cc:612
peepopt - collection of peephole optimizers¶
- yosys> help peepopt¶
- peepopt [options] [selection]¶
This pass applies a collection of peephole optimizers to the current design. This pass employs the following rules by default: * muldiv - Replace (A*B)/B with A * muldiv_c - Replace (A*B)/C with A*(B/C) when C is a const divisible by B. * shiftmul - Replace A>>(B*C) with A'>>(B<<K) where C and K are constants and A' is derived from A by appropriately inserting padding into the signal. (right variant) Analogously, replace A<<(B*C) with appropriate selection of output bits from A<<(B<<K). (left variant) * shiftadd - Replace A>>(B+D) with (A'>>D)>>(B) where D is constant and A' is derived from A by padding or cutting inaccessible bits. Scratchpad: 'peepopt.shiftadd.max_data_multiple' (default: 2) limits the amount of padding to a multiple of the data, to avoid high resource usage from large temporary MUX trees. If -formalclk is specified it instead employs the following rules: * clockgateff - Replace latch based clock gating patterns with a flip-flop based pattern to prevent combinational paths from the output to the enable input after running clk2fflogic.Note
Help text automatically generated from
passes/opt/peepopt.cc:43
pmux2shiftx - transform $pmux cells to $shiftx cells¶
- yosys> help pmux2shiftx¶
- pmux2shiftx [options] [selection]¶
This pass transforms $pmux cells to $shiftx cells.
-v, -vvverbose output
-min_density <percentage>specifies the minimum density for the shifter default: 50
-min_choices <int>specified the minimum number of choices for a control signal default: 3
-onehot ignore|pmux|shiftxselect strategy for one-hot encoded control signals default: pmux
-norangedisable $sub inference for "range decoders"
Note
Help text automatically generated from
passes/opt/pmux2shiftx.cc:192
recover_names - Execute a lossy mapping command and recover original netnames¶
wreduce - reduce the word size of operations if possible¶
- yosys> help wreduce¶
- wreduce [options] [selection]¶
This command reduces the word size of operations. For example it will replace the 32 bit adders in the following code with adders of more appropriate widths: module test(input [3:0] a, b, c, output [7:0] y); assign y = a + b + c + 1; endmodule Options:-memxDo not change the width of memory address ports. Use this options in flows that use the 'memory_memx' pass.
-mux_undefremove 'undef' inputs from $mux, $pmux and $_MUX_ cells
-keepdcDo not optimize explicit don't-care values.
Note
Help text automatically generated from
passes/opt/wreduce.cc:522