mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-10 16:13:26 +00:00
Docs: Update internal cells to autoref
This commit is contained in:
parent
c0f9828b3c
commit
e4ec3717bc
12 changed files with 183 additions and 179 deletions
|
@ -98,8 +98,8 @@ our internal cell library will be mapped to:
|
|||
:name: mycells-lib
|
||||
:caption: :file:`mycells.lib`
|
||||
|
||||
Recall that the Yosys built-in logic gate types are ``$_NOT_``, ``$_AND_``,
|
||||
``$_OR_``, ``$_XOR_``, and ``$_MUX_`` with an assortment of dff memory types.
|
||||
Recall that the Yosys built-in logic gate types are `$_NOT_`, `$_AND_`,
|
||||
`$_OR_`, `$_XOR_`, and `$_MUX_` with an assortment of dff memory types.
|
||||
:ref:`mycells-lib` defines our target cells as ``BUF``, ``NOT``, ``NAND``,
|
||||
``NOR``, and ``DFF``. Mapping between these is performed with the commands
|
||||
:cmd:ref:`dfflibmap` and :cmd:ref:`abc` as follows:
|
||||
|
|
|
@ -24,12 +24,12 @@ following description:
|
|||
|
||||
- Does not already have the ``\fsm_encoding`` attribute.
|
||||
- Is not an output of the containing module.
|
||||
- Is driven by single ``$dff`` or ``$adff`` cell.
|
||||
- The ``\D``-Input of this ``$dff`` or ``$adff`` cell is driven by a
|
||||
- Is driven by single `$dff` or `$adff` cell.
|
||||
- The ``\D``-Input of this `$dff` or `$adff` cell is driven by a
|
||||
multiplexer tree that only has constants or the old state value on its
|
||||
leaves.
|
||||
- The state value is only used in the said multiplexer tree or by simple
|
||||
relational cells that compare the state value to a constant (usually ``$eq``
|
||||
relational cells that compare the state value to a constant (usually `$eq`
|
||||
cells).
|
||||
|
||||
This heuristic has proven to work very well. It is possible to overwrite it by
|
||||
|
@ -64,9 +64,11 @@ information is determined:
|
|||
The state registers (and asynchronous reset state, if applicable) is simply
|
||||
determined by identifying the driver for the state signal.
|
||||
|
||||
From there the ``$mux-tree`` driving the state register inputs is recursively
|
||||
.. todo:: Figure out what `$mux-tree` should actually be.
|
||||
|
||||
From there the `$mux-tree` driving the state register inputs is recursively
|
||||
traversed. All select inputs are control signals and the leaves of the
|
||||
``$mux-tree`` are the states. The algorithm fails if a non-constant leaf that is
|
||||
`$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.
|
||||
|
@ -99,18 +101,18 @@ create a transition table. For each state:
|
|||
|
||||
6. If step 4 was successful: Emit transition
|
||||
|
||||
Finally a ``$fsm`` cell is created with the generated transition table and added
|
||||
Finally a `$fsm` cell is created with the generated transition table and added
|
||||
to the module. This new cell is connected to the control signals and the old
|
||||
drivers for the control outputs are disconnected.
|
||||
|
||||
FSM optimization
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The :cmd:ref:`fsm_opt` pass performs basic optimizations on ``$fsm`` cells (not
|
||||
The :cmd:ref:`fsm_opt` pass performs basic optimizations on `$fsm` cells (not
|
||||
including state recoding). The following optimizations are performed (in this
|
||||
order):
|
||||
|
||||
- Unused control outputs are removed from the ``$fsm`` cell. The attribute
|
||||
- Unused control outputs are removed from the `$fsm` cell. The attribute
|
||||
``\unused_bits`` (that is usually set by the :cmd:ref:`opt_clean` pass) is
|
||||
used to determine which control outputs are unused.
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ For example:
|
|||
techmap -map my_memory_map.v
|
||||
memory_map
|
||||
|
||||
:cmd:ref:`memory_libmap` attempts to convert memory cells (``$mem_v2`` etc) into
|
||||
:cmd:ref:`memory_libmap` attempts to convert memory cells (`$mem_v2` etc) into
|
||||
hardware supported memory using a provided library (:file:`my_memory_map.txt` in the
|
||||
example above). Where necessary, emulation logic is added to ensure functional
|
||||
equivalence before and after this conversion. :yoscrypt:`techmap -map
|
||||
|
@ -171,10 +171,10 @@ In general, you can expect the automatic selection process to work roughly like
|
|||
|
||||
This process can be overridden by attaching a ram_style attribute to the memory:
|
||||
|
||||
- `(* ram_style = "logic" *)` selects FF RAM
|
||||
- `(* ram_style = "distributed" *)` selects LUT RAM
|
||||
- `(* ram_style = "block" *)` selects block RAM
|
||||
- `(* ram_style = "huge" *)` selects huge RAM
|
||||
- ``(* ram_style = "logic" *)`` selects FF RAM
|
||||
- ``(* ram_style = "distributed" *)`` selects LUT RAM
|
||||
- ``(* ram_style = "block" *)`` selects block RAM
|
||||
- ``(* ram_style = "huge" *)`` selects huge RAM
|
||||
|
||||
It is an error if this override cannot be realized for the given target.
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ described in :doc:`/yosys_internals/formats/cell_library`. This means a cell
|
|||
with all constant inputs is replaced with the constant value this cell drives.
|
||||
In some cases this pass can also optimize cells with some constant inputs.
|
||||
|
||||
.. table:: Const folding rules for ``$_AND_`` cells as used in :cmd:ref:`opt_expr`.
|
||||
.. table:: Const folding rules for `$_AND_` cells as used in :cmd:ref:`opt_expr`.
|
||||
:name: tab:opt_expr_and
|
||||
:align: center
|
||||
|
||||
|
@ -54,7 +54,7 @@ In some cases this pass can also optimize cells with some constant inputs.
|
|||
========= ========= ===========
|
||||
|
||||
:numref:`Table %s <tab:opt_expr_and>` shows the replacement rules used for
|
||||
optimizing an ``$_AND_`` gate. The first three rules implement the obvious const
|
||||
optimizing an `$_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.
|
||||
These are the only three cases in which it is allowed to propagate an undef
|
||||
|
@ -66,18 +66,18 @@ 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 ``$_AND_`` gate with one constant-1 input
|
||||
The last two lines simply replace an `$_AND_` gate with one constant-1 input
|
||||
with a buffer.
|
||||
|
||||
Besides this basic const folding the :cmd:ref:`opt_expr` pass can replace 1-bit
|
||||
wide ``$eq`` and ``$ne`` cells with buffers or not-gates if one input is
|
||||
wide `$eq` and `$ne` cells with buffers or not-gates if one input is
|
||||
constant. Equality checks may also be reduced in size if there are redundant
|
||||
bits in the arguments (i.e. bits which are constant on both inputs). This can,
|
||||
for example, result in a 32-bit wide constant like ``255`` being reduced to the
|
||||
8-bit value of ``8'11111111`` if the signal being compared is only 8-bit as in
|
||||
:ref:`addr_gen_clean` of :doc:`/getting_started/example_synth`.
|
||||
|
||||
The :cmd:ref:`opt_expr` pass is very conservative regarding optimizing ``$mux``
|
||||
The :cmd:ref:`opt_expr` pass is very conservative regarding optimizing `$mux`
|
||||
cells, as these cells are often used to model decision-trees and breaking these
|
||||
trees can interfere with other optimizations.
|
||||
|
||||
|
@ -100,7 +100,7 @@ identifies cells with identical inputs and replaces them with a single instance
|
|||
of the cell.
|
||||
|
||||
The option ``-nomux`` can be used to disable resource sharing for multiplexer
|
||||
cells (``$mux`` and ``$pmux``.) This can be useful as it prevents multiplexer
|
||||
cells (`$mux` and `$pmux`.) This can be useful as it prevents multiplexer
|
||||
trees to be merged, which might prevent :cmd:ref:`opt_muxtree` to identify
|
||||
possible optimizations.
|
||||
|
||||
|
@ -141,16 +141,16 @@ Simplifying large MUXes and AND/OR gates - :cmd:ref:`opt_reduce`
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This is a simple optimization pass that identifies and consolidates identical
|
||||
input bits to ``$reduce_and`` and ``$reduce_or`` cells. It also sorts the input
|
||||
bits to ease identification of shareable ``$reduce_and`` and ``$reduce_or``
|
||||
input bits to `$reduce_and` and `$reduce_or` cells. It also sorts the input
|
||||
bits to ease identification of shareable `$reduce_and` and `$reduce_or`
|
||||
cells in other passes.
|
||||
|
||||
This pass also identifies and consolidates identical inputs to multiplexer
|
||||
cells. In this case the new shared select bit is driven using a ``$reduce_or``
|
||||
cells. In this case the new shared select bit is driven using a `$reduce_or`
|
||||
cell that combines the original select bits.
|
||||
|
||||
Lastly this pass consolidates trees of ``$reduce_and`` cells and trees of
|
||||
``$reduce_or`` cells to single large ``$reduce_and`` or ``$reduce_or`` cells.
|
||||
Lastly this pass consolidates trees of `$reduce_and` cells and trees of
|
||||
`$reduce_or` cells to single large `$reduce_and` or `$reduce_or` cells.
|
||||
|
||||
These three simple optimizations are performed in a loop until a stable result
|
||||
is produced.
|
||||
|
@ -160,7 +160,7 @@ Merging mutually exclusive cells with shared inputs - :cmd:ref:`opt_share`
|
|||
|
||||
This pass identifies mutually exclusive cells of the same type that:
|
||||
a. share an input signal, and
|
||||
b. drive the same ``$mux``, ``$_MUX_``, or ``$pmux`` multiplexing cell,
|
||||
b. drive the same `$mux`, `$_MUX_`, or `$pmux` multiplexing cell,
|
||||
|
||||
allowing the cell to be merged and the multiplexer to be moved from
|
||||
multiplexing its output to multiplexing the non-shared input signals.
|
||||
|
@ -176,14 +176,14 @@ multiplexing its output to multiplexing the non-shared input signals.
|
|||
|
||||
Before and after :cmd:ref:`opt_share`
|
||||
|
||||
When running :cmd:ref:`opt` in full, the original ``$mux`` (labeled ``$3``) is
|
||||
When running :cmd:ref:`opt` in full, the original `$mux` (labeled ``$3``) is
|
||||
optimized away by :cmd:ref:`opt_expr`.
|
||||
|
||||
Performing DFF optimizations - :cmd:ref:`opt_dff`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This pass identifies single-bit d-type flip-flops (``$_DFF_``, ``$dff``, and
|
||||
``$adff`` cells) with a constant data input and replaces them with a constant
|
||||
This pass identifies single-bit d-type flip-flops (`$_DFF_`, `$dff`, and
|
||||
`$adff` cells) with a constant data input and replaces them with a constant
|
||||
driver. It can also merge clock enables and synchronous reset multiplexers,
|
||||
removing unused control inputs.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue