Jump to content

Lookup Table

From Logic World Wiki
Revision as of 12:09, 6 September 2025 by GHXX (talk | contribs)

Any arbitrary logic formula can, theoretically, always be represented in Conjunctive Normal Form. Put in simple terms, this means the output is computed using a single OR-operation, whose inputs are formed by AND gates, which directly use (possibly negated) inputs. Each AND-gate represents a single case where the output is supposed to be true.

In Logic World, this is referred to as a Lookup Table (LUT), which is generally implemented by first creating a list of all input states that should lead to a true output. From this list, the LUT can then be constructed quite easily. It consists of multiple relay chains that are simply OR-ed together at the end, where one chain corresponds to one input-assignment that should lead to a truthy output value. The aforementioned relay chains are started by a single NOT-gate whose inputs are all signals that are false in the case where a true output is expected, followed by a set of relays where the top input is expected to be true for such a true result.

Normally, however, it is also necessary to prevent back-propagation of signals by using fast-buffers, meaning each chain requires as many components as there are inputs to account for relays and fast-buffers, along with one NOT-gate if there are any inputs that are supposed to be off.

Complexity

When following the arrangement described above, we can compute the approximate required component count as chainCount(1+inputCount). If we assume that half of the possible input assignments lead to a true output, the number of chains would be equivalent to 50%2inputCount=2inputCount1. If we factor in, that each chain requires 1+inputCount components, the total can be written as 2inputCount1(1+inputCount). Approximately, this could be written as 𝒪(2inputCount1(1+inputCount))=𝒪(2inputCount(inputCount))=𝒪(2inputCount). In order words, the component count scales exponentially with input size, under the assumption that the amount of true assignment also scales exponentially.

While LUTs tend to become very expensive quite quickly, they are very fast, computing the output in a single tick, regardless of input size.


TODO: add infobox giving an overview of time and component count maybe?

TODO: add screenshot of 5 bit equality LUT