Algorithm Search⌘K

Problemcore

FPGA packing

Also called FPGA clustering, logic block packing.

Group LUTs and flip-flops into the logic clusters of an FPGA under limits on cluster size and inputs, so that delay and routing demand between clusters are low.

FPGA packing is the step of the FPGA CAD flow that groups the LUTs and flip-flops of a mapped netlist into the logic clusters of the chip. Each cluster has room for at most NN basic logic elements (BLEs) and at most II input nets from outside, and the clusters are then placed and routed as single blocks. The problem asks for few clusters, and for few connections between clusters on the critical paths, since a connection inside a cluster is fast and uses no general routing.

In plain words

After LUT mapping, the design is a long list of small logic pieces. The chip does not hold them one by one: it holds them in groups, and each group has a fixed number of seats and a fixed number of input wires.

Packing chooses the groups. Pieces that talk to each other a lot should sit in the same group, because a signal inside a group is fast and needs no long wire. A group must not need more input wires than it has. Fewer groups mean a smaller chip, and fewer slow signals between groups mean a faster design.

Definition

Input.

  • A netlist of nn BLEs. BLE bb has a set of at most KK input nets, one output net, and a flag for its flip-flop. A BLE is formed from a LUT and the flip-flop that only it feeds.
  • The cluster parameters: the size NN and the number of input pins II, with K≤IK \le I.
  • For the timing form, a delay model with a delay for a connection inside a cluster and a larger one for a connection between clusters.

Output. A partition of the BLEs into clusters C1,…,CmC_1, \ldots, C_m.

Constraints. Each cluster is legal. Let ext(C)\mathrm{ext}(C) be the set of nets that some member of CC reads and no member drives. With the full local crossbar of the logic cluster definition, CC is legal if and only if

∣C∣≤Nand∣ext(C)∣≤I,|C| \le N \quad\text{and}\quad |\mathrm{ext}(C)| \le I,

and its BLEs use at most the number of clocks that the cluster has. With sparse local routing, a cluster is legal when a routing of its nets exists inside it, which is a stronger condition.

Objective. The basic form minimizes mm, the number of clusters. The timing form minimizes the delay of the longest path when connections between clusters are slow, and the routability form minimizes the number of nets that leave clusters. Real packers mix the three.

Decision form. Given the netlist, NN, II and mm, decide whether a legal partition into at most mm clusters exists.

Variants

  • Cluster count only. Minimize mm with the two counting limits. This is the form whose hardness is shown below.
  • Timing-driven. Keep the connections of critical paths inside clusters. T-VPack targets this form.
  • Routability-driven. Lower the number of nets that cross between clusters, and leave some pins free so that the clusters are easier to route to.
  • Complex blocks. Blocks with hierarchy, modes, carry chains, memories and multipliers, where legality is a routing check inside the block. AAPack targets this form.
  • Depopulated clusters. Fill clusters below NN on purpose to spread congestion, at the cost of more clusters.

Examples

A hand instance. Take K=2K = 2, N=2N = 2, I=3I = 3 and four BLEs: aa reads x,yx, y and drives AA; bb reads A,zA, z and drives BB; cc reads x,wx, w and drives CC; dd reads C,yC, y and drives DD.

cluster external nets legal
{a,b}\{a, b\} x,y,zx, y, z yes
{c,d}\{c, d\} x,w,yx, w, y yes
{a,c}\{a, c\} x,y,wx, y, w yes
{b,d}\{b, d\} A,z,C,yA, z, C, y no
{a,d}\{a, d\} x,y,Cx, y, C yes
{b,c}\{b, c\} A,z,x,wA, z, x, w no

Two clusters is the least possible, since ⌈4/2⌉=2\lceil 4 / 2 \rceil = 2, and {a,b},{c,d}\{a, b\}, \{c, d\} reaches it. It also keeps the connections a→ba \to b and c→dc \to d inside clusters. The pairing {a,c},{b,d}\{a, c\}, \{b, d\} is not legal, and the pairing {a,d},{b,c}\{a, d\}, \{b, c\} is not either, so the optimum is unique.

Absorbed nets. In {a,b}\{a, b\} the net AA is driven inside, so it needs no input pin. Adding a BLE to a cluster can lower the input count, which is why the limit cannot be checked BLE by BLE.

Known algorithms

  • Greedy growth. T-VPack fills one cluster at a time from a critical seed, adding the BLE of highest attraction that fits. Every cluster that it outputs is legal and each closed cluster is full or admits no remaining BLE, but it has no guarantee on the number of clusters; its page has a 4-BLE netlist where it uses 3 clusters and 2 suffice.
  • Greedy growth with a routing check. AAPack grows clusters in the same way and checks each addition by placing the BLE in a slot of the block and routing inside the block. The result is legal for the block's real interconnect, with no guarantee on the count.
  • Partitioning. A hypergraph partitioning of the netlist into parts of size NN lowers the nets between parts, and the parts are then repaired to meet the input limit. This gives no legality by itself.
  • Exact search. For tiny netlists, a dynamic program over subsets finds the least number of clusters: best(S)=1+min⁡best(S∖C)\mathrm{best}(S) = 1 + \min \mathrm{best}(S \setminus C) over legal C⊆SC \subseteq S that hold the lowest element of SS. It takes O(3n)O(3^n) steps and is the brute force that the tests of the packer pages use.
  • Clusters of two. For N=2N = 2 the problem is a maximum matching: join two BLEs by an edge when the pair is legal. A partition into mm clusters of size at most 2 has n−mn - m pairs, and the pairs are a matching, so the least mm is nn minus the size of a maximum matching, which Edmonds' blossom algorithm finds in polynomial time.
AlgorithmTimeSpacePropertiesCode
AAPackO(n^2 N R) packingO(n K + N K (I + N)) totaldeterministicnot exactiterative1 language
T-VPackO(n K) criticalityO(n K) totaldeterministicnot exactiterative1 language

Bounds

  • Size. m≥⌈n/N⌉m \ge \lceil n / N \rceil.
  • Inputs. If the BLEs read pp nets that no BLE drives, each such net uses a pin in every cluster that reads it, so m≥⌈p/I⌉m \ge \lceil p / I \rceil.
  • Trivial upper bound. m≤nm \le n, with one BLE per cluster, which is legal since K≤IK \le I.

Reductions

Theorem 1 (strong NP-hardness). The decision form of the cluster count problem is NP-complete in the strong sense when KK, NN and II are part of the input.

Proof. It is in NP: a partition is checked in polynomial time. For hardness, reduce from bin packing in its decision form: item sizes a1,…,ana_1, \ldots, a_n, a capacity BB with each aj≤Ba_j \le B, and a number mm of bins. Bin packing is NP-complete in the strong sense (Garey and Johnson, [SR1]; see also the hardness proof of bin packing), so we may assume that the sizes are written in unary. Build BLE jj with aja_j input nets of its own, used by no other BLE, and an output net that no BLE reads. Set K=max⁡jajK = \max_j a_j, N=nN = n and I=BI = B. No net is shared and no BLE drives a net that another reads, so ∣ext(C)∣=∑j∈Caj|\mathrm{ext}(C)| = \sum_{j \in C} a_j, and CC is legal if and only if its items fit in one bin. So a legal partition into mm clusters exists if and only if the items fit into mm bins. The netlist has ∑jaj+n\sum_j a_j + n nets, which is polynomial in the unary size. □\square

Theorem 2 (hard already for clusters of three). The decision form is NP-complete when N=3N = 3, with KK and II part of the input.

Proof. Reduce from partition into triangles (Garey and Johnson, [GT11]): given a graph HH with 3q3q vertices, decide whether its vertices split into qq triangles. Let Δ=max⁡(3,the largest degree of H)\Delta = \max(3, \text{the largest degree of } H). Make one BLE per vertex vv. It reads one net per edge at vv, shared with the other end of that edge, plus Δ−deg⁡(v)\Delta - \deg(v) nets of its own, so it reads exactly Δ\Delta nets; its output is read by no BLE. Set K=ΔK = \Delta, N=3N = 3 and I=3Δ−3I = 3\Delta - 3. A set of three BLEs with ee edges of HH among them reads 3Δ−e3\Delta - e distinct nets, so it is legal if and only if e=3e = 3, that is, it is a triangle. A set of at most two BLEs reads at most 2Δ≤3Δ−32\Delta \le 3\Delta - 3 nets and is always legal. A partition into qq clusters of size at most 3 covers 3q3q BLEs, so every cluster has exactly three BLEs and is a triangle. Conversely, a partition into triangles gives qq legal clusters. □\square

A brute force over 200 random graphs on 6 vertices (seed 2) agrees with Theorem 2 on every instance, 28 of them with a partition into triangles; this checks the construction, not the theorem. With Theorem 2 and the matching algorithm, the cluster count problem is polynomial for N≤2N \le 2 and NP-complete for N=3N = 3. This page gives no result for fixed KK, NN and II together.

Applications

  • The FPGA CAD flow. Packing runs between LUT mapping and placement, such as timing-driven annealing placement. Its result fixes how many blocks the placer and the router must handle.
  • Architecture studies. Betz, Rose and Marquardt chose the number of cluster inputs by packing benchmarks at different II and measuring how full the clusters became.
  • Heterogeneous blocks. Packing also fills memory and multiplier blocks and the carry chains of logic blocks, each with its own legality rules.

References

  1. Michael R. Garey and David S. Johnson, Computers and Intractability, A Guide to the Theory of NP-Completeness, W. H. Freeman, 1979, Appendix A, problem [SR1] Bin Packing (NP-complete in the strong sense) and problem [GT11] Partition into Triangles
  2. Vaughn Betz, Jonathan Rose and Alexander Marquardt, Architecture and CAD for Deep-Submicron FPGAs, Kluwer, 1999 (doi 10.1007/978-1-4615-5145-4), Chapter 3, Section 3.1 Logic Block Packing (the packing step of the CAD flow and its legality rules)
  3. Alexander Marquardt, Vaughn Betz and Jonathan Rose, Using cluster-based logic blocks and timing-driven packing to improve FPGA speed and density, Proceedings of the ACM/SIGDA International Symposium on Field Programmable Gate Arrays (FPGA '99), 37 to 46, 1999, the packing problem with the limits N and I and the timing-driven objective
  4. Jason Luu, Jason H. Anderson and Jonathan Rose, Architecture description and packing for logic blocks with hierarchy, modes and complex interconnect, Proceedings of the ACM/SIGDA International Symposium on Field Programmable Gate Arrays (FPGA '11), 227 to 236, 2011, packing for logic blocks whose legality depends on the local interconnect, not only on counts

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml