Learning Logic Networks That Synthesis Can Delete

Neural networks built from lookup tables (small truth tables, each mapping a handful of input bits to one output bit) can now be trained by gradient descent and compiled directly into FPGA logic. They reach inference latencies near 20 ns. The training objective, however, knows nothing about what the hardware compiler will do next. The logic-synthesis tool removes inputs a table does not really use, propagates constants, and deletes any gate whose output nobody reads. That removal is large: LogicNets found Vivado's output up to 39× smaller than analytical estimates. Yet it is uncontrolled. Two networks with the same accuracy can differ enormously in how much logic survives synthesis, and neither one was trained to be compressible.

This note proposes training the network to make synthesis effective. The proposal adds a differentiable penalty on the number of inputs each lookup table truly depends on, measured only on input patterns the data actually produces. Through a soft "liveness" calculation, the penalty lets a table be deleted once none of its consumers depend on it. Each removed input is also a removed wire, so we weight the penalty by an estimated wire length from a fast approximate placement. The pressure to shrink logic then falls first on connections that are expensive to route. The bet is that compressibility and routability are learnable properties of the truth tables. On this view they do not have to be patched in after training.

Core Claim

The claim has three parts. First, a training-time penalty on data-restricted input dependence, annealed toward a hard count of dependent inputs, should produce networks whose post-synthesis lookup-table count tracks the penalty closely. Second, at matched accuracy, these networks should need substantially fewer lookup tables than networks compressed after training by tying units to constants. Third, weighting the penalty by placement-estimated wire cost should lower routed wirelength and raise post-route clock frequency at a fixed lookup-table count.

The first two parts concern logic minimization, and they are the core of the proposal. The third part concerns the gap between post-synthesis and post-route quality. It is a secondary hypothesis, and an ablation will either confirm or remove it.

What Exists and What Is Missing

The closest prior work is Two-Stage Unit Tying. It takes a trained differentiable logic network, chooses gates to clamp to constant 0 or 1 (Gauss-Newton screening followed by group testing on calibration batches), and lets Vivado's constant propagation delete the logic downstream. It reports up to 48.3% fewer lookup tables on CIFAR-10. Three of its properties matter here:

  • It runs after training, so the training run never anticipates which gates will be tied.
  • It operates layer by layer.
  • It removes only whole gates. Clamping to a constant is the extreme case of dropping every input.

We generalize to partial input removal, perform it during training, and let the effect cascade globally through soft liveness. The same paper also constrains our design. It shows that Taylor-style saliency fails on logic networks because changing a gate is a discrete, non-local jump. This is why our penalty is defined on truth-table entries and their flip-pairs, not on weight magnitudes.

The base learner comes from the differentiable-logic literature:

  • Light Differentiable Logic Gate Networks parameterizes each gate directly by its $2^n$ truth-table entries. This "input-wise" form scales naturally to 6-input lookup tables, and it is what makes our penalty a simple function of the parameters.
  • Mind the Gap uses a Gumbel straight-through estimator so the forward pass is discrete during training, which removes most of the discretization gap.
  • BitLogic exports such networks to synthesizable Verilog.

None of these three includes any hardware term in the loss. We reuse their machinery unchanged. From HashNet we borrow continuation: a smooth function is sharpened gradually toward a hard step.

On the physical side, PigMAP places a technology-independent gate graph approximately before mapping and uses the resulting "virtual wirelength" to guide cell choice. It cuts post-routing delay by 14% on EPFL/ASAP7. It works on fixed ASIC netlists downstream of any learning. We take its idea of cheap early placement and use it upstream, to set penalty weights.

ARITH-DAS shows the value of real-tool feedback over analytical proxies for arithmetic circuits. It is limited to compressor trees and stops at post-synthesis metrics. It motivates our insistence on validating the surrogate against Vivado rather than trusting it.

Research Program

The quantity we penalize. Take a lookup table with $n$ inputs. Let $t(x) \in [0,1]$ be its soft truth-table entry for input pattern $x \in \{0,1\}^n$, and let $x \oplus e_k$ denote $x$ with input bit $k$ flipped.

The key observation is about data-level don't-cares. If a pattern never occurs during training, its entry is free. We may assign it whatever value makes the function simplest. The synthesis tool cannot exploit this, because it never sees the data.

So we measure dependence on input $k$ only over flip-pairs that both occur. Let $p(x)$ be a running estimate of how often pattern $x$ reaches the table. The data-restricted sensitivity is

$$ s_k = \sum_{x} \min\big(p(x),\, p(x \oplus e_k)\big)\, \big| t(x) - t(x \oplus e_k) \big|. $$

When $s_k = 0$, the table can be rewritten so it ignores input $k$ without changing its behaviour on any observed input.

The training loss. The regularized loss is

$$ L = L_{\text{task}} + \lambda \sum_{j} a_j \sum_{k} c_{jk}\, \big(1 - e^{-s_{jk}/\tau}\big), $$

where the symbols are defined as follows:

  • $j$ indexes lookup tables.
  • $c_{jk}$ is the estimated wire cost of table $j$'s $k$-th input.
  • $\lambda$ trades accuracy for hardware.
  • $\tau$ is annealed toward zero, so the saturating term approaches a count of dependent inputs (the continuation step).
  • $a_j$ is the soft liveness of table $j$.

Soft liveness is defined as one minus the product, over table $j$'s consumers, of the probability that the consumer ignores $j$. It is computed in a single backward sweep from the outputs. The effect is that dropping the last dependence on a table also removes that table's own penalty, which rewards the deletion cascades synthesis performs.

Wire costs. Every few epochs we run a fast analytical placement, in the spirit of PigMAP's placer, on the network's current wiring graph. We set $c_{jk}$ proportional to the Manhattan distance of the corresponding connection. A uniform $c_{jk}=1$ gives the logic-only variant.

Export. At export we perform the don't-care completion explicitly. For every input whose $s_k$ falls below a small threshold, we fill the free entries so the exported function is literally independent of that input. We then delete dead tables and emit Verilog through a BitLogic-style exporter for Vivado.

Analysis. Beyond end results, we will measure how well the surrogate predicts reality: the rank correlation between predicted live-table count and Vivado's post-synthesis count, and between summed $c_{jk}$ over surviving connections and routed wirelength. Measuring this tests Tension 3 in the literature directly. That tension is the observation that identical-accuracy networks differ in Boolean reducibility.

Baselines

Naive reference. The do-nothing baseline is the same input-wise, Gumbel straight-through network trained without any hardware term and exported directly to Vivado. Vivado performs its usual minimization. Every reduction we report is relative to this network, with identical architecture, seeds, and training budget.

Strongest existing method. This is Two-Stage Unit Tying with post-tying fine-tuning, applied to the same trained reference networks. The cited paper reports up to 48.3% post-synthesis lookup-table reduction on CIFAR-10 and up to 42.9% on MNIST at a 50% tied ratio, with 0.35% accuracy degradation on MNIST after fine-tuning (LogicTreeNet architecture). We will reimplement it on our architecture. We will give its fine-tuning the same number of epochs our method spends in its annealing phase, and sweep its tied ratio to trace an accuracy–lookup-table curve. Beating it means a curve that lies strictly below it at matched accuracy: at least a further 20% fewer lookup tables at the accuracy where tying sits at a 50% ratio. Because published LogicTreeNet numbers may not transfer to our base network, we also report it on LogicTreeNet if reproduction allows.

Cheap rival to the key ingredient. This is post-hoc don't-care completion. It is the export step of our pipeline run on the unregularized network: compute visit statistics, fill free entries to drop exactly-irrelevant inputs, delete dead tables, fine-tune. It isolates whether the in-training penalty matters at all.

Physical ablation. This compares uniform against placement-weighted $c_{jk}$ at matched lookup-table count. It isolates the wire-cost weighting.

Architecture baseline. This uniformly shrinks width or lookup-table arity (6 down to 4 inputs) to match lookup-table counts. It tests whether learned, per-table input removal beats simply building a smaller network.

Application-domain anchors. For the tabular benchmarks, the anchors are LogicNets' reported JSC-L result of 71.8% accuracy at 384 MHz with 13 ns latency, and NID-M at 91.30% accuracy at 471 MHz. For CIFAR-10, the anchor is BitLogic's reported 72.3% using fewer than 0.3 million gates.

Why not just…?

Why not just tie units to constants after training, as Two-Stage Unit Tying does? This is the most direct competitor, and it works. Its limits are structural. It can only delete a gate entirely, never prune one of a gate's six inputs. It decides layer by layer on a network that was never shaped to be prunable. Its own analysis shows that discrete gate changes defeat local saliency estimates, which suggests that letting the network adapt during training is worthwhile. Whether that adaptation is worth the cost is an empirical question. The accuracy–lookup-table curves at matched fine-tuning budget settle it. If tying matches us, we will report that the in-training penalty adds nothing beyond its partial-input generalization.

Why not just fill unseen truth-table entries after training and let Vivado do the rest? This alternative is a real threat. It is cheap, exact on the observed data, and may capture much of the benefit. Its weakness is that it removes only inputs that are exactly irrelevant on observed patterns. It cannot trade a tiny accuracy loss for removing an input that is almost irrelevant, and it cannot let the next layer reorganize so whole chains die. The post-hoc completion baseline above measures this directly. If it lands within a few percent of the full method, the honest conclusion is that the contribution is a post-processing tool. That result would still be useful and would be reported as such.

Why not just put a real synthesis tool in the loop, as ARITH-DAS does? Real-tool feedback avoids the proxy gap ARITH-DAS documents. However, a Vivado run on a network with hundreds of thousands of tables takes far longer than a training step, so it cannot provide per-step gradients. We use the tool differently. We call it on checkpoints to measure surrogate fidelity, and if the correlation is poor we recalibrate the per-table cost model from those runs. If fidelity is high, the expensive loop is unnecessary.

Why not just train a smaller or lower-arity network? Uniform shrinking spends the budget evenly. Learned removal can keep wide tables where the data needs them and strip them elsewhere. The matched-count architecture baseline tests this. If uniform shrinking ties our curve, the penalty is acting only as an expensive width knob.

Proposed Experiments

We train on JSC and UNSW-NB15 network intrusion detection, which are latency-critical tabular tasks where LogicNets set the reference points, and on MNIST, Fashion-MNIST, and CIFAR-10, where the tying and BitLogic numbers exist. All designs are synthesized and fully placed and routed in Vivado, targeting the Kintex-7 410T. That device is the budget part the tying paper aimed to fit, so whether a design fits it is a meaningful binary outcome. We report test accuracy, post-synthesis lookup-table count, routed wirelength, post-route clock frequency and latency, and routing congestion. All are plotted as accuracy–cost curves over sweeps of $\lambda$, averaged over three seeds.

Three checks decide the outcome:

  1. The predicted live-table count must rank-correlate with Vivado's count across checkpoints at Spearman rho of at least 0.9. Below that, the surrogate is not doing what we claim.
  2. The full method must dominate both post-hoc tying and post-hoc completion on the accuracy–lookup-table curve.
  3. At matched lookup-table count, placement weighting must measurably reduce routed wirelength and raise post-route clock frequency relative to uniform weighting. If it does not, the physical arm is dropped and the contribution is stated as logic minimization alone.

A final stress test applies the method to wide, shallow networks. BitLogic finds these more accurate, but they are expected to be the hardest to route. This tests whether learned input removal relieves the congestion that width creates.