Skip to content

Commit eba5fa8

Browse files
authored
Merge pull request #4387 from YosysHQ/emil/document-lut-sop
docs: Document $lut and $sop
2 parents 40c7162 + fd84a33 commit eba5fa8

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

docs/source/yosys_internals/formats/cell_library.rst

+42-2
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,48 @@ The CONFIG parameter carries the following information:
661661
662662
B is an array of concatenated 1-bit-wide unsigned integers to also be summed up.
663663

664+
Arbitrary logic functions
665+
~~~~~~~~~~~~~~~~~~~~~~~~~
666+
667+
The ``$lut`` cell type implements a single-output LUT (lookup table).
668+
It implements an arbitrary logic function with its ``\LUT`` parameter to map
669+
input port ``\A`` to values of ``\Y`` output port values.
670+
In psuedocode: ``Y = \LUT[A]``.
671+
``\A`` has width set by parameter ``\WIDTH`` and ``\Y`` has a width of 1.
672+
Every logic function with a single bit output has a unique ``$lut``
673+
representation.
674+
675+
The ``$sop`` cell type implements a sum-of-products expression, also known
676+
as disjunctive normal form (DNF). It implements an arbitrary logic function.
677+
Its structure mimics a programmable logic array (PLA).
678+
Output port ``\Y`` is the sum of products of the bits of the input port ``\A``
679+
as defined by parameter ``\TABLE``. ``\A`` is ``\WIDTH`` bits wide.
680+
The number of products in the sum is set by parameter ``\DEPTH``, and each
681+
product has two bits for each input bit - for the presence of the
682+
unnegated and negated version of said input bit in the product.
683+
Therefore the ``\TABLE`` parameter holds ``2 * \WIDTH * \DEPTH`` bits.
684+
685+
For example:
686+
687+
Let ``\WIDTH`` be 3. We would like to represent ``\Y =~\A[0] + \A[1]~\A[2]``.
688+
There are 2 products to be summed, so ``\DEPTH`` shall be 2.
689+
690+
.. code-block::
691+
~A[2]-----┐
692+
A[2]----┐|
693+
~A[1]---┐||
694+
A[1]--┐|||
695+
~A[0]-┐||||
696+
A[0]┐||||| product formula
697+
010000 ~\A[0]
698+
001001 \A[1]~\A[2]
699+
700+
So the value of ``\TABLE`` will become ``010000001001``.
701+
702+
Any logic function with a single bit output can be represented with
703+
``$sop`` but may have variously minimized or ordered summands represented
704+
in the ``\TABLE`` values.
705+
664706
Specify rules
665707
~~~~~~~~~~~~~
666708

@@ -1192,6 +1234,4 @@ file via ABC using the abc pass.
11921234

11931235
.. todo:: Add information about ``$slice`` and ``$concat`` cells.
11941236

1195-
.. todo:: Add information about ``$lut`` and ``$sop`` cells.
1196-
11971237
.. todo:: Add information about ``$alu``, ``$fa``, and ``$lcu`` cells.

0 commit comments

Comments
 (0)