mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-22 16:45:32 +00:00
docs: Document $macc
This commit is contained in:
parent
040605b047
commit
a580a7c82c
2 changed files with 94 additions and 5 deletions
|
@ -619,6 +619,52 @@ Finite state machines
|
|||
|
||||
Add a brief description of the ``$fsm`` cell type.
|
||||
|
||||
Coarse arithmetics
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``$macc`` cell type represents a multiply and accumulate block, for summing any number of negated and unnegated signals and arithmetic products of pairs of signals. Cell port A concatenates pairs of signals to be multiplied together. When the second signal in a pair is zero length, a constant 1 is used instead as the second factor. Cell port B concatenates 1-bit-wide signals to also be summed, such as "carry in" in adders.
|
||||
|
||||
The cell's ``CONFIG`` parameter determines the layout of cell port ``A``.
|
||||
In the terms used for this cell, there's mixed meanings for the term "port". To disambiguate:
|
||||
A cell port is for example the A input (it is constructed in C++ as ``cell->setPort(ID::A, ...))``
|
||||
Multiplier ports are pairs of multiplier inputs ("factors").
|
||||
If the second signal in such a pair is zero length, no multiplication is necessary, and the first signal is just added to the sum.
|
||||
|
||||
In this pseudocode, ``u(foo)`` means an unsigned int that's foo bits long.
|
||||
The CONFIG parameter carries the following information:
|
||||
.. code-block::
|
||||
:force:
|
||||
struct CONFIG {
|
||||
u4 num_bits;
|
||||
struct port_field {
|
||||
bool is_signed;
|
||||
bool is_subtract;
|
||||
u(num_bits) factor1_len;
|
||||
u(num_bits) factor2_len;
|
||||
}[num_ports];
|
||||
};
|
||||
|
||||
The A cell port carries the following information:
|
||||
.. code-block::
|
||||
:force:
|
||||
struct A {
|
||||
u(CONFIG.port_field[0].factor1_len) port0factor1;
|
||||
u(CONFIG.port_field[0].factor2_len) port0factor2;
|
||||
u(CONFIG.port_field[1].factor1_len) port1factor1;
|
||||
u(CONFIG.port_field[1].factor2_len) port1factor2;
|
||||
...
|
||||
};
|
||||
|
||||
No factor1 may have a zero length.
|
||||
A factor2 having a zero length implies factor2 is replaced with a constant 1.
|
||||
|
||||
Additionally, B is an array of 1-bit-wide unsigned integers to also be summed up.
|
||||
Finally, we have:
|
||||
.. code-block::
|
||||
:force:
|
||||
Y = port0factor1 * port0factor2 + port1factor1 * port1factor2 + ...
|
||||
* B[0] + B[1] + ...
|
||||
|
||||
Specify rules
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
@ -1152,4 +1198,4 @@ file via ABC using the abc pass.
|
|||
|
||||
.. todo:: Add information about ``$lut`` and ``$sop`` cells.
|
||||
|
||||
.. todo:: Add information about ``$alu``, ``$macc``, ``$fa``, and ``$lcu`` cells.
|
||||
.. todo:: Add information about ``$alu``, ``$fa``, and ``$lcu`` cells.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue