Compiling Neural Networks into Hardware Logic

28 concepts22 papers2 proposals

Traditional deep learning hardware relies on the Multiply-Accumulate (MAC) paradigm. Whether running on a CPU, GPU, or a specialized systolic array, executing a neural network layer involves fetching weights from memory, multiplying them by activations, and accumulating the results. This loop introduces fundamental overheads in latency, power, and chip area.

An emerging alternative re-envisions the neural network entirely: what if we stop treating a neuron as a mathematical equation to be computed, and instead treat it as a static piece of digital combinational logic?

If a network is heavily quantized (e.g., 1-bit or 2-bit precision), each neuron simply maps a discrete set of inputs to a discrete output. In digital design, any such mapping can be represented as a truth table and synthesized directly into hardware using Look-Up Tables (LUTs)—the native building blocks of Field Programmable Gate Arrays (FPGAs). By compiling neurons directly into logic gates or LUTs, arithmetic operations drop to zero. Inference becomes a matter of signals propagating through a shallow sea of gates, unlocking sub-15-nanosecond latencies and massive throughputs ideal for line-rate network security or high-energy physics triggers.

The State Explosion Bottleneck

The primary obstacle to this paradigm is exponential resource scaling.

Consider a single neuron. If it receives $N$ inputs, and each input is quantized to $B$ bits, the total number of unique input combinations is $2^{N \times B}$. To represent this neuron as a direct truth table, the table must contain an entry for every single combination.

Standard Neuron:  Inputs (N) ───► [ MAC Units ] ───► Linear Scaling O(N)
Logic-Based:      Inputs (N) ───► [ Truth Table] ───► Exponential Scaling O(2^(N*B))

If $N=4$ and $B=2$, the truth table requires $2^8 = 256$ rows, which easily fits into standard hardware logic. However, if the neuron has $N=16$ and $B=4$, the table explodes to $2^{64}$ rows—an impossible requirement for any physical chip.

As identified by Umuroglu et al. and Nazemi et al., this "fan-in explosion" creates a severe trade-off between input dimensionality and hardware area. Standard, densely connected neural network layers cannot be mapped directly to truth tables because their high fan-in quickly exhausts the physical memory capacity of the target device. Furthermore, when researchers attempt to optimize these networks using differentiable logic gates, the search space scales double-exponentially ($2^{2^N}$) relative to the gate arity, as noted by Rüttgers et al., making standard training techniques intractable without strict constraints.

Maximizing Expressivity Within the Scaling Wall

To bypass this scaling wall, researchers must restrict each logic block to a very small number of inputs. However, reducing fan-in typically cripples a network's capacity to learn complex relationships. The core insight that makes logic-based inference viable is that a hardware look-up table does not care how complex its underlying function is.

Whether a 6-input LUT implements a simple linear threshold or a highly intricate, non-linear mathematical relationship, it consumes the exact same physical hardware resources on an FPGA. It is always just a 64-bit string of configuration memory.

Wang et al. exploited this property by moving away from standard XNOR-based binarized networks and instead allowing FPGAs to learn arbitrary Boolean functions directly within $K$-input LUTs.

Taking this concept further, Marta Andronic introduced PolyLUT, a framework that trains neural networks using piecewise multivariate polynomials instead of linear functions. Because the polynomial math is precomputed and "hidden" entirely inside the LUT truth tables, the hardware evaluates high-degree non-linear relationships instantly at runtime. This allows shallow networks with strict fan-in limits to match the accuracy of much deeper linear networks while maintaining ultra-low latencies.

Architectural Strategies for Scaling Fan-In

To scale these systems to practical tasks, researchers rely on hardware-software co-design to manage connectivity without triggering an exponential explosion.

LUT Trees and Assembly

Instead of mapping a high-fan-in neuron to a single massive truth table, networks can be broken down into hierarchies of smaller tables. Andronic et al. developed a method to assemble large logical neurons out of trees of smaller, hardware-native LUTs. By embedding skip-connections directly into these Boolean structures, they expand the effective receptive field of the network without causing resource overflow.

Fan-In Constrained Pruning

To ensure the trained network can actually be synthesized, the training process must actively enforce hardware constraints. Nazemi et al. and Andronic et al. utilize hardware-aware structured pruning during training. This forces the network to discard less informative input pathways dynamically, ensuring that no single logical node exceeds the target hardware's maximum input threshold.

Alternative Hardware Mapping

When the resulting logic graphs still exceed traditional LUT capacity, alternative routing strategies can be deployed. For instance, Shahsavani et al. introduced a framework to compile fixed-function combinational logic onto FPGA Digital Signal Processor (DSP) blocks rather than standard LUTs, taking advantage of the DSPs' internal parallelism and dynamic reconfigurability to absorb massive logic blocks.

Training Discrete Logic via Continuous Surrogates

Because discrete truth tables and logic gates are fundamentally non-differentiable, they cannot be trained directly using standard gradient descent. The field relies on continuous relaxations during training that gradually harden into discrete logic gates for deployment.

For binary logic networks, Rüttgers et al. introduced Input-Wise Parametrization (IWP). Instead of placing weights on entire logic functions, IWP places weights on individual input combinations, allowing smooth gradient updates to navigate the discrete function space efficiently.

When extending this paradigm to many-valued or ternary logic—where nodes can choose to "abstain" from a decision—the state space scales even more aggressively. To counter this, Damera et al. developed Polynomial Surrogate Training (PST).

Discrete Space (Intractable Search) ──► [ Continuous Polynomial Surrogate ] ──► Gradient Descent
                                                                                    │
Hardware-Ready Logic Circuit        ◄── [ Hardening / Quantization ] ◄──────────────┘

PST replaces an otherwise intractable discrete search over thousands of possible ternary gate configurations with a smooth, low-coefficient polynomial surrogate. This allows backpropagation to operate seamlessly in a continuous space before the model is hardened into an ultra-fast, hardware-ready logic circuit.

Key Foundational Work

Frequent items counter based on binary decoders (2018) — contributed 2 concept elements to this direction.
A Real Time Clustering CMOS Neural Engine (1994) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_state_explosion_in_direct_computation_1fb2afc9,
  title = {state explosion in direct computation},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/state-explosion-in-direct-computation/rdr_1fb2afc9ae8f4925bb9a82f36035101a},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-19},
}

This exact version (version 1, frozen text):

@misc{lacuna_state_explosion_in_direct_computation_1fb2afc9_v1,
  title = {state explosion in direct computation},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/state-explosion-in-direct-computation/rdr_1fb2afc9ae8f4925bb9a82f36035101a/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-19},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake