diff --git a/src/kyupy/logic.py b/src/kyupy/logic.py index 146bf7c..84765bc 100644 --- a/src/kyupy/logic.py +++ b/src/kyupy/logic.py @@ -13,14 +13,14 @@ Utility functions defined here follow these conventions. In general, the bits in these constants have the following meaning: - * bit0: Final/settled binary value of a signal - * bit1: Initial binary value of a signal - * bit2: Activity or transitions are present on a signal +* bit0: Final/settled binary value of a signal +* bit1: Initial binary value of a signal +* bit2: Activity or transitions are present on a signal Except when bit0 differs from bit1, but bit2 (activity) is 0: - * bit0 = 1, bit1 = 0, bit2 = 0 means ``UNKNOWN`` in 4-valued and 8-valued logic. - * bit0 = 0, bit1 = 1, bit2 = 0 means ``UNASSIGNED`` in 4-valued and 8-valued logic. +* bit0 = 1, bit1 = 0, bit2 = 0 means ``UNKNOWN`` in 4-valued and 8-valued logic. +* bit0 = 0, bit1 = 1, bit2 = 0 means ``UNASSIGNED`` in 4-valued and 8-valued logic. 2-valued logic only considers bit0, but should store logic one as ``ONE=0b011`` for interoperability. 4-valued logic only considers bit0 and bit1. @@ -28,12 +28,14 @@ Except when bit0 differs from bit1, but bit2 (activity) is 0: Logic values are stored in numpy arrays of data type ``np.uint8``. The axis convention is as follows: + * The **last** axis goes along patterns/vectors. I.e. ``values[...,0]`` is pattern 0, ``values[...,1]`` is pattern 1, etc. * The **second-to-last** axis goes along the I/O and flip-flops of circuits. For a circuit ``c``, this axis is usually ``len(c.s_nodes)`` long. The values of all inputs, outputs and flip-flops are stored within the same array and the location along the second-to-last axis is determined by the order in ``c.s_nodes``. Two storage formats are used in KyuPy: + * ``mv...`` (for "multi-valued"): Each logic value is stored in the least significant 3 bits of ``np.uint8``. * ``bp...`` (for "bit-parallel"): Groups of 8 logic values are stored as three ``np.uint8``. This format is used for bit-parallel logic simulations. It is also more memory-efficient.