Merge pull request #1241 from YosysHQ/clifford/jsonfix
[yosys.git] / manual / CHAPTER_Optimize.tex
index c562650b8a183e76ddabc13cac7b0890e30ddcd0..eee92ef5c5a3fbcf471f14c88e0773533c666521 100644 (file)
@@ -15,23 +15,23 @@ passes that each perform a simple optimization:
 \begin{itemize}
 \item Once at the beginning of {\tt opt}:
 \begin{itemize}
-\item {\tt opt\_const}
-\item {\tt opt\_share -nomux}
+\item {\tt opt\_expr}
+\item {\tt opt\_merge -nomux}
 \end{itemize}
 \item Repeat until result is stable:
 \begin{itemize}
 \item {\tt opt\_muxtree}
 \item {\tt opt\_reduce}
-\item {\tt opt\_share}
+\item {\tt opt\_merge}
 \item {\tt opt\_rmdff}
 \item {\tt opt\_clean}
-\item {\tt opt\_const}
+\item {\tt opt\_expr}
 \end{itemize}
 \end{itemize}
 
 The following section describes each of the {\tt opt\_*} passes.
 
-\subsection{The opt\_const pass}
+\subsection{The opt\_expr pass}
 
 This pass performs const folding on the internal combinational cell types
 described in Chap.~\ref{chapter:celllib}. This means a cell with all constant
@@ -57,11 +57,11 @@ this pass can also optimize cells with some constant inputs.
                $a$ &   1 & $a$ \\
                  1 & $b$ & $b$ \\
        \end{tabular}
-       \caption{Const folding rules for {\tt\$\_AND\_} cells as used in {\tt opt\_const}.}
-       \label{tab:opt_const_and}
+       \caption{Const folding rules for {\tt\$\_AND\_} cells as used in {\tt opt\_expr}.}
+       \label{tab:opt_expr_and}
 \end{table}
 
-Table~\ref{tab:opt_const_and} shows the replacement rules used for optimizing
+Table~\ref{tab:opt_expr_and} shows the replacement rules used for optimizing
 an {\tt\$\_AND\_} gate. The first three rules implement the obvious const folding
 rules. Note that `any' might include dynamic values calculated by other parts
 of the circuit. The following three lines propagate undef (X) states.
@@ -69,17 +69,17 @@ These are the only three cases in which it is allowed to propagate an undef
 according to Sec.~5.1.10 of IEEE Std. 1364-2005 \cite{Verilog2005}.
 
 The next two lines assume the value 0 for undef states. These two rules are only
-used if no other subsitutions are possible in the current module. If other substitutions
+used if no other substitutions are possible in the current module. If other substitutions
 are possible they are performed first, in the hope that the `any' will change to
 an undef value or a 1 and therefore the output can be set to undef.
 
 The last two lines simply replace an {\tt\$\_AND\_} gate with one constant-1
 input with a buffer.
 
-Besides this basic const folding the {\tt opt\_const} pass can replace 1-bit wide
+Besides this basic const folding the {\tt opt\_expr} pass can replace 1-bit wide
 {\tt \$eq} and {\tt \$ne} cells with buffers or not-gates if one input is constant.
 
-The {\tt opt\_const} pass is very conservative regarding optimizing {\tt \$mux} cells,
+The {\tt opt\_expr} pass is very conservative regarding optimizing {\tt \$mux} cells,
 as these cells are often used to model decision-trees and breaking these trees can
 interfere with other optimizations.
 
@@ -130,13 +130,13 @@ This pass identifies unused signals and cells and removes them from the design.
 creates an \B{unused\_bits} attribute on wires with unused bits. This attribute can be
 used for debugging or by other optimization passes.
 
-\subsection{The opt\_share pass}
+\subsection{The opt\_merge pass}
 
 This pass performs trivial resource sharing. This means that this pass identifies cells
 with identical inputs and replaces them with a single instance of the cell.
 
 The option {\tt -nomux} can be used to disable resource sharing for multiplexer
-cells ({\tt \$mux}, {\tt \$pmux}, and {\tt \$safe\_pmux}). This can be useful as
+cells ({\tt \$mux} and {\tt \$pmux}. This can be useful as
 it prevents multiplexer trees to be merged, which might prevent {\tt opt\_muxtree}
 to identify possible optimizations.
 
@@ -222,6 +222,10 @@ This heuristic has proven to work very well. It is possible to overwrite it by s
 and setting \B{fsm\_encoding}{\tt = "none"} on registers that match the above criteria
 but should not be considered FSM state registers.
 
+Note however that marking state registers with \B{fsm\_encoding} that are not
+suitable for FSM recoding can cause synthesis to fail or produce invalid
+results.
+
 \subsection{FSM Extraction}
 
 The {\tt fsm\_extract} pass operates on all state signals marked with the
@@ -241,7 +245,7 @@ by identifying the driver for the state signal.
 
 From there the {\tt \$mux}-tree driving the state register inputs is
 recursively traversed. All select inputs are control signals and the leaves of the
-{\tt \$mux}-tree are the states. The algorithm fails if a non-constant leaf 
+{\tt \$mux}-tree are the states. The algorithm fails if a non-constant leaf
 that is not the state signal itself is found.
 
 The list of control outputs is initialized with the bits from the state signal.
@@ -296,7 +300,7 @@ table altered to give the same performance without the external feedback path.
 \item Entries in the transition table that yield the same output and only
 differ in the value of a single control input bit are merged and the different bit is removed
 from the sensitivity list (turned into a don't-care bit).
-\item Constant inputs are removed and the transition table is alterered to give an unchanged behaviour.
+\item Constant inputs are removed and the transition table is altered to give an unchanged behaviour.
 \item Unused inputs are removed.
 \end{itemize}