Skip to content

Commit f6c4dd9

Browse files
committed
docs: Document $lut and $sop
1 parent 1a54e8d commit f6c4dd9

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

docs/source/yosys_internals/formats/cell_library.rst

+43-2
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,49 @@ 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+
This will correspond to ``\TABLE`` holding ``010000``
690+
691+
.. code-block::
692+
~A[2]-----┐
693+
A[2]----┐|
694+
~A[1]---┐||
695+
A[1]--┐|||
696+
~A[0]-┐||||
697+
A[0]┐||||| product formula
698+
010000 ~\A[0]
699+
001001 \A[1]~\A[2]
700+
701+
So the value of CONFIG will become ``010000001001``.
702+
703+
Any logic function with a single bit output can be represented with
704+
``$sop`` but may have variously minimized or ordered summands represented
705+
in the ``CONFIG`` values.
706+
664707
Specify rules
665708
~~~~~~~~~~~~~
666709

@@ -1192,6 +1235,4 @@ file via ABC using the abc pass.
11921235

11931236
.. todo:: Add information about ``$slice`` and ``$concat`` cells.
11941237

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

0 commit comments

Comments
 (0)