Algorithmresearch
DAOmap
Also called depth-optimal area-optimized mapping.
Chen and Cong's depth-optimal LUT mapper that cuts area by cost functions for logic duplication and reconvergence and by iterative cut selection.
- Solves
- LUT mapping
- Time
- O(n c^d K + n c d n) cut enumeration and costsO(T n c K) cut selection
- Space
- O(n c K) total
- Where
- K = the number of LUT inputs; T = the number of cut selection passes; c = the largest number of K-feasible cuts of a gate; d = the largest fanin of a gate; n = the number of gates
- Model
- Word RAM
- Properties
- deterministicnot exactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Deming Chen, Jason Cong, 2004
DAOmap is an algorithm for LUT mapping, a step of FPGA CAD: it maps a network of gates into -input lookup tables (LUTs) with the least possible depth and as few LUTs as it can. It lists all -feasible cuts of each node by cut enumeration, and while it does so it computes for each node the least arrival time and an area estimate that shares the area of a signal among its readers and adds a cost for logic that a cut would duplicate. Then it maps from the outputs back with required times. A node on the critical path takes its cheapest cut of least height. A node with slack takes the cut that is cheapest after a bonus for inputs that are already LUT outputs and for slack that it leaves to the nodes below. The selection runs three times, and each pass learns from the last. Chen and Cong gave it at ICCAD 2004 and reported 16.02% fewer LUTs than CutMap at the same depth with 5-input LUTs.
In plain words
Every signal that leaves a LUT costs a LUT, so a good mapping makes as few signals into LUT outputs as it can without making any path longer than the best possible depth. DAOmap first gives each node an estimate of how many LUTs its logic needs. A signal that feeds three gates splits its cost three ways, and a cut that copies logic which other gates also use pays extra. Then it walks back from the outputs. Where a node has no time to spare, it picks the cheapest fastest cut. Where it has time, it prefers cuts that read signals that are already LUT outputs, and cuts that leave time for the logic below. It repeats the walk a few times, and each walk knows which signals the last walk made into LUT outputs.
The problem
Input. A -bounded Boolean network (a directed acyclic graph of gates with at most fanins each; the paper uses 2-input networks), a set of output gates, and an integer (the paper uses 4, 5 and 6).
Output. A LUT mapping: a set of LUT roots that includes every output gate, and for each root a -feasible cut of . Every gate in a cut is a root too.
Goal. The fewest LUTs among mappings whose depth, under the unit delay model, is the least possible depth . The paper notes that area mapping is NP-hard, so DAOmap is a heuristic for the count. The depth part is exact.
The algorithm
For a cut of a gate , the arrival time is , and is the least arrival time over the cuts of , with at a primary input. These are the FlowMap labels. The area of a cut is
where is the number of readers of signal and is the area of node ( at an input). The last sum runs over the fanins of that are gates with more than one reader and are not in : for each one, the cut covers the cone of and so copies it, and it pays , where is the number of gates of that cone. The area of a node is over the cuts of that reach . With required time , the slack of a cut is , and the cut keeps the depth only if .
DAOMAP(N, outputs, K, T)- 1
enumerate the K-feasible cuts of every gate, and compute arr and the areas A_C and A_v in topological order - 2
D ← max arr(o) over the outputs; tentative ← the gates with more than 3 readers - 3
repeat T times: - 4
r(o) ← D for each output o; roots ← outputs - 5
for each gate v in reverse topological order, skipping v if it is not in roots: - 6
if r(v) = arr(v) then C* ← the cut with s(C) = 0 of least A_C - 7
else C* ← the cut with s(C) ≥ 0 of least A_C / share(C) − 0.3 s(C) - 8
the LUT of v is C*; for each gate u in C*: add u to roots and set r(u) ← min(r(u), r(v) − 1) - 9
keep this mapping if it has the fewest LUTs so far; tentative ← its roots with more than one reader - 10
return the kept mapping
At line L7, let be the number of nodes of that are roots of this pass or tentative roots from the last pass. Then is 1 when , 1.15 when , and otherwise; these values and the weight 0.3 are from the paper. Dividing by the share makes a cut cheaper when it reads signals that are already LUT outputs, so the LUTs share inputs and fewer nodes are copied. The term favors cuts that use little of the slack, so the nodes below have room to pick cheap cuts too.
The implementation leaves out two parts of the paper, and changes one. First, the paper computes from the cut size , the number of covered nodes , the fanout of the root and the number of reconvergent paths that the cut covers, with constants and ; the implementation uses , one LUT per cut. Second, the paper adjusts the cost by cut probing, which rewards a cut that lowers the fanout of a covered gate or that makes nodes into roots that the last pass had copied; the implementation does not. Third, the paper outputs the mapping of the last pass and keeps all earlier roots of strong fanout as tentative roots; the implementation keeps the best pass, and uses only the roots of the last pass. None of these changes affects the depth.
Example
Take and the network , , , , , with outputs and . Gate has two readers; the others have one.
Line L1 gives for ( and have cuts of inputs only, and ) and , so . Some of the areas:
| cut | arrival | |
|---|---|---|
| over | 1 | (it copies ) |
| over | 2 | |
| over | 2 | |
| over | 2 | |
| over | 2 | |
| over | 1 |
The selection, in reverse topological order:
| root | choice | ||
|---|---|---|---|
| 2 | 2 | critical (line L6): both cuts have slack 0, and has less area; | |
| 2 | 1 | slack (line L7): costs , costs ; take | |
| 1 | 1 | critical: only has slack 0 |
The result has 3 LUTs and depth 2: over , over and over . Gate is copied into two LUTs, but it never becomes a LUT of its own. The two later passes give the same mapping. A brute force over all cut choices shows that 3 is the least count at depth 2. The FlowMap mapping phase takes the cut of that covers the most gates, , so both and need their own LUTs and the result has 4. The test file checks every number in the two tables.
Correctness
The full proof shows that the result is a valid mapping with the same outputs and depth exactly . The argument is the same as for CutMap. The invariant is for every root. At a critical root the cut that gives has slack 0, and at a root with slack that same cut has slack at least 0, so lines L6 and L7 always have a cut to choose. Every chosen cut has , so each node of it has , and the invariant holds after line L8. Then by induction the LUT depth of each root is at most . That no mapping has depth below is FlowMap's label theorem, cited from FlowMap. Nothing in the costs, the shares or the passes can break the depth, because all of them only rank cuts that already meet the bound.
Proof: DAOmap returns a valid LUT mapping with the same outputs and the least possible depth, for any costsfull
We use the notation of the page. is a -bounded network, a directed acyclic graph whose sources are the primary inputs (PIs). A cut of a gate is a set of nodes with that meets every path from a PI to , and it is -feasible if . is computed at line L1, , and the slack of a cut of a root is .
Lemma 1 (cut lists and arrival times). Every listed set of a gate is a -feasible cut of , every minimal -feasible cut of is listed, and over all -feasible cuts of .
Proof. The enumeration is the same as on the CutMap proof, Lemmas 1 and 2: a listed set is a union over the fanins of or a cut of , so it meets every path into ; and a minimal cut of splits into for the fanins in and, for every other fanin , a minimal cut of inside , which is listed by induction, and their union is by minimality. A least-height cut contains a minimal cut of no greater height, so the minimum over the list equals the minimum over all cuts.
By Lemma 1, is the FlowMap label .
Lemma 2 (order). Every root is visited once in a pass, after all roots that read it, so is final when is visited.
Proof. A gate joins the roots at line L8 only when it is in the cut of a root . Then has a path to , so comes before in topological order and after at line L5. The value changes only at line L8 while such a is visited.
Lemma 3 (invariant, and a cut always exists). In each pass, for every root once is set, and the set of cuts at line L6 or line L7 is not empty.
Proof. At line L4, . Let be visited with . By Lemma 1 there is a listed cut with , so . If , then and line L6 has a candidate. Otherwise and line L7 has a candidate. In both cases the chosen cut has , so every has . All values of are at most , so line L8 sets to the first time, and later to a minimum of two values that are both at least .
The proof uses nothing about , the share, the weight 0.3 or the tentative roots. They only decide which cut of nonnegative slack is taken.
Theorem 4 (valid mapping, same function). In each pass, every LUT has at most inputs, every gate input of a LUT has its own LUT, and the LUT network computes the value of at every root for every input vector.
Proof. Each chosen cut is listed, so it has at most nodes. Every gate of becomes a root at line L8 and is visited later (Lemma 2), where it gets a LUT (Lemma 3). The LUT of evaluates the gates between and from the values of ; no PI outside is reached, since is a cut. By induction in topological order over the roots, each node of carries its value in , so does too.
Theorem 5 (depth). In each pass, the LUT depth of every root is at most , so every output has depth at most .
Proof. By induction in topological order. A PI has depth 0. For a root with LUT , each gate has final and depth at most by induction, and a PI in has depth because . So the depth of is at most .
Theorem 6 (optimal depth, cited). No -LUT mapping of has depth below . So every pass, and the mapping returned at line L10, has depth exactly .
Proof. Cong and Ding proved that the FlowMap label is the least depth of in any -LUT mapping of a -bounded network; the proof is on the FlowMap page. By Lemma 1, , so some output needs depth in every mapping. Theorem 5 gives the upper bound. Line L10 returns one of the pass mappings.
What is not proved. Nothing here bounds the number of LUTs. The area flow is an estimate and, as Chen and Cong note, it is not a lower bound on the area under the depth constraint. The LUT savings against CutMap are measured results of Chen and Cong (2004), not theorems.
Complexity
Let be the largest number of cuts of a gate. Cut enumeration costs per gate. The duplication cost walks the cone of each multi-reader fanin for each cut, which is per cut in the worst case and much less on real circuits, where the cones of -feasible cuts are small. Each selection pass visits each root once and scores its cuts in , so passes cost . The space is for the cut lists and their areas. Chen and Cong show (Figure 2, the 20 largest MCNC benchmarks) that the average number of cuts per node is a small constant for small , so enumeration is close to linear in , and that it grows fast for , where cut pruning is needed. They give CutMap's worst case as for comparison.
Properties
What is proved. The mapping is valid, computes the same outputs, and has the least possible depth (the last step by FlowMap's label theorem, cited by link). This holds for any costs, shares, slack weight or number of passes.
What is cited. On the 20 largest MCNC benchmarks, Chen and Cong (2004, Table 1 and Section 5.1) report that DAOmap uses 16.02% fewer LUTs than CutMap and runs 24.2 times faster with 5-input LUTs, at the same depth for every benchmark. With 4-input LUTs the numbers are 13.98% and 13.2 times, and with 6-input LUTs 12.44% and 4.7 times. Against CutMap with its depth relaxation switch, DAOmap uses 11.62%, 14.76% and 11.13% fewer LUTs for . On six industrial benchmarks, CutMap did not finish two of them in 10 hours. In the study of the passes, 3 passes gave the best average and more passes made it slightly worse. The paper also notes that the area estimate is not a lower bound on the mapped area once the depth is constrained.
What is measured. The tests compare the LUT count with an exhaustive search over every cut choice at depth , on 200 random networks of 3 to 7 two-input gates with (seed 5). DAOmap reaches the least count on all 200, and uses fewer LUTs than the FlowMap mapping phase on 1. On 400 other networks (seed 0) it reaches the least count on 395, uses fewer LUTs than FlowMap on 1 and more on 3, and the second and third passes never improve on the first. Such small networks have little room for the passes to help; the measurements show that the implementation is sound, not that it matches the results of the paper.
Variants and improvements
- CutMap (CutMap, 1995) is the flow-based mapper that DAOmap replaced. It also maps from required times, with a cut cost that favors existing roots, but it computes one cut at a time by max-flow.
- Area flow and exact area. The area flow of DAOmap, where a signal's area is divided by its fanout, became standard. Later mappers add a second pass of exact area, which counts the LUTs that a cut would really add or free given the current mapping.
- Priority cuts (Mishchenko, Cho, Chatterjee and Brayton, 2007) keep only a few best cuts per node, so that the same depth and area recovery scales to large networks and to and above.
- And-inverter graphs. Mapping from an and-inverter graph with choices, as in ABC, gives the mapper several structures of the same logic to choose from, which DAOmap cannot do on a fixed network.
When to use it
Use DAOmap when the LUT depth must be the least possible and the count matters, and is at most 6 so that all cuts can be listed. It is a good model of a depth-optimal mapper with area recovery, and its parts (area flow, duplication cost, slack, shared inputs, repeated passes) are the parts of most later mappers. For large designs or above 6, use a mapper with priority cuts.
Pitfalls
- Picking the cheapest cut everywhere. If every node takes its least at line L1, the result keeps the depth only on paths where it happens to; required times are needed to know which cuts are allowed.
- Area flow as a bound. is an estimate. It can be below the real area, because it assumes that a node with several readers is not copied, and under the depth bound it is not a lower bound either.
- Tuned constants. The share 1.15 for one shared input, the slack weight 0.3 and the constants of come from experiments on MCNC benchmarks. They are not derived, and other benchmark sets can need other values.
- Too many passes. The paper found that more than 3 passes made the result slightly worse, because the tentative roots from old passes no longer fit the current one.
- Large K. The number of cuts grows fast with . Without pruning, and above is slow.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/daomap/. The authors are listed in prov/HAXQH6.jsonl.
"""DAOmap: depth-optimal LUT mapping with area flow, slack and iterative cut selection.
A network is a dict that maps a gate name to (op, fanins). op is one of
"AND", "OR", "XOR", "NAND", "NOR", "XNOR", "NOT", "BUF". A signal that is not
a gate is a primary input.
This is a simplified DAOmap. It keeps the parts of the paper that decide the
depth and most of the area:
- cut enumeration with the minimum arrival time of each node;
- area flow A_C = sum A_i / f(i) + U_C + duplication cost, with U_C = 1;
- the duplication cost N_f / |C| for each multi-fanout fanin f whose cone
the cut covers;
- required times from the optimal depth, and the slack of a cut;
- for a non-critical node, the cost A_C / share - 0.3 * slack_C, where
share counts the inputs of C that are LUT roots (1.15 for one input);
- a few iterations of cut selection, where each iteration uses the
multi-fanout roots of the last one as tentative roots.
It leaves out the U_C formula of the paper (cut size, covered nodes, root
fanout and reconvergent paths) and the cut probing step.
"""
from itertools import product
GATE_OPS = {"AND", "OR", "XOR", "NAND", "NOR", "XNOR", "NOT", "BUF"}
SLACK_WEIGHT = 0.3
ONE_SHARE = 1.15
def gate_value(op: str, vals: list) -> int:
if op in ("AND", "NAND"):
r = int(all(vals))
elif op in ("OR", "NOR"):
r = int(any(vals))
elif op in ("XOR", "XNOR"):
r = sum(vals) % 2
elif op in ("BUF", "NOT"):
r = vals[0]
else:
raise ValueError(op)
return 1 - r if op in ("NAND", "NOR", "XNOR", "NOT") else r
def topo_order(net: dict) -> list:
order, state = [], {}
def visit(s):
if s not in net or state.get(s) == 2:
return
if state.get(s) == 1:
raise ValueError("the network has a cycle")
state[s] = 1
for f in net[s][1]:
visit(f)
state[s] = 2
order.append(s)
for g in sorted(net):
visit(g)
return order
def primary_inputs(net: dict) -> list:
return sorted({f for _, (_, fanins) in net.items() for f in fanins if f not in net})
def fanouts(net: dict, outputs: list) -> dict:
count = {}
for _, (_, fanins) in net.items():
for f in set(fanins):
count[f] = count.get(f, 0) + 1
for o in outputs:
count[o] = count.get(o, 0) + 1
return count
def enumerate_cuts(net: dict, k: int) -> dict:
"""The K-feasible cuts of each gate without the trivial cut, with
dominated cuts removed."""
cuts = {p: [frozenset([p])] for p in primary_inputs(net)}
for g in topo_order(net):
choices = []
for f in net[g][1]:
opts = [frozenset([f])]
if f in net:
opts = opts + cuts[f]
choices.append(opts)
found = set()
for combo in product(*choices):
c = frozenset().union(*combo)
if len(c) <= k:
found.add(c)
minimal = [c for c in found if not any(o < c for o in found)]
cuts[g] = sorted(minimal, key=lambda c: (len(c), sorted(c)))
return cuts
def cone(net: dict, v: str, cut) -> set:
"""The gates computed inside the LUT of v over cut, v included."""
seen, stack = set(), [v]
while stack:
s = stack.pop()
if s in cut or s in seen or s not in net:
continue
seen.add(s)
stack.extend(net[s][1])
return seen
def arrival_and_area(net: dict, outputs: list, cuts: dict):
"""Minimum arrival time arr(v), and area flow A(v) taken over the cuts
that give arr(v). Returns (arr, area, cut_area)."""
fo = fanouts(net, outputs)
arr = {p: 0 for p in primary_inputs(net)}
area = {p: 0.0 for p in primary_inputs(net)}
cut_area = {}
for v in topo_order(net):
arr[v] = min(1 + max(arr[u] for u in c) for c in cuts[v])
for c in cuts[v]:
a = sum(area[u] / max(1, fo.get(u, 1)) for u in c) + 1.0
for f in set(net[v][1]):
if f in net and f not in c and fo.get(f, 0) > 1:
a += len(cone(net, f, c)) / len(c)
cut_area[(v, c)] = a
area[v] = min(cut_area[(v, c)] for c in cuts[v] if 1 + max(arr[u] for u in c) == arr[v])
return arr, area, cut_area
def select_cuts(net, outputs, cuts, arr, cut_area, d, tentative):
"""One pass of cut selection from the outputs. Returns the LUTs."""
gate_outs = [o for o in outputs if o in net]
required = {o: d for o in gate_outs} # @line L4
roots = set(gate_outs)
luts = {}
for v in reversed(topo_order(net)): # @line L5
if v not in roots:
continue
def slack(c):
return required[v] - 1 - max(arr[u] for u in c)
if required[v] == arr[v]: # @line L6
crit = [c for c in cuts[v] if slack(c) == 0]
best = min(crit, key=lambda c: (cut_area[(v, c)], sorted(c)))
else:
def cost(c): # @line L7
shared = sum(1 for u in c if u in roots or u in tentative)
share = 1.0 if shared == 0 else ONE_SHARE if shared == 1 else float(shared)
return (cut_area[(v, c)] / share - SLACK_WEIGHT * slack(c), sorted(c))
best = min((c for c in cuts[v] if slack(c) >= 0), key=cost)
luts[v] = best # @line L8
for u in best:
if u in net:
roots.add(u)
required[u] = min(required.get(u, d), required[v] - 1)
return luts
def daomap(net: dict, outputs: list, k: int, iterations: int = 3):
"""Returns (luts, depth). luts maps each LUT root to its cut."""
for g, (op, fanins) in net.items():
if op not in GATE_OPS or not fanins or len(fanins) > k:
raise ValueError(f"gate {g} is not K-bounded or has a bad op")
cuts = enumerate_cuts(net, k) # @line L1
arr, _, cut_area = arrival_and_area(net, outputs, cuts)
fo = fanouts(net, outputs)
d = max((arr[o] for o in outputs if o in net), default=0) # @line L2
tentative = {g for g in net if fo.get(g, 0) > 3}
best = None
for _ in range(iterations): # @line L3
luts = select_cuts(net, outputs, cuts, arr, cut_area, d, tentative)
if best is None or len(luts) < len(best): # @line L9
best = luts
tentative = {g for g in luts if fo.get(g, 0) > 1}
return best, d # @line L10
def lut_value(net: dict, root: str, cut, values: dict) -> int:
memo = {}
def ev(s):
if s in cut or s not in net:
return values[s]
if s not in memo:
op, fanins = net[s]
memo[s] = gate_value(op, [ev(f) for f in fanins])
return memo[s]
return ev(root)
def eval_network(net: dict, outputs: list, values: dict) -> dict:
memo = dict(values)
def ev(s):
if s not in memo:
op, fanins = net[s]
memo[s] = gate_value(op, [ev(f) for f in fanins])
return memo[s]
return {o: ev(o) for o in outputs}
def eval_luts(net: dict, luts: dict, outputs: list, values: dict) -> dict:
memo = dict(values)
def ev(s):
if s not in memo:
cut = luts[s]
memo[s] = lut_value(net, s, cut, {u: ev(u) for u in cut})
return memo[s]
return {o: ev(o) for o in outputs}
def lut_depth(net: dict, luts: dict, outputs: list) -> int:
memo = {}
def dep(s):
if s not in net:
return 0
if s not in memo:
memo[s] = 1 + max(dep(u) for u in luts[s])
return memo[s]
return max((dep(o) for o in outputs), default=0)
def equivalent(net: dict, luts: dict, outputs: list) -> bool:
pis = primary_inputs(net)
for bits in product((0, 1), repeat=len(pis)):
values = dict(zip(pis, bits))
if eval_network(net, outputs, values) != eval_luts(net, luts, outputs, values):
return False
return True
if __name__ == "__main__":
example = {
"g0": ("OR", ["c", "d"]),
"g1": ("AND", ["b", "d"]),
"g2": ("AND", ["g1", "g0"]),
"g3": ("OR", ["g1", "a"]),
"g4": ("XOR", ["a", "g2"]),
}
luts, d = daomap(example, ["g3", "g4"], 3)
print(d, {v: sorted(c) for v, c in sorted(luts.items())})
test_daomap.py 200 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/daomap/. The authors are listed in prov/HAXQH6.jsonl.
import random
from itertools import combinations
from daomap import (
arrival_and_area,
daomap,
enumerate_cuts,
equivalent,
lut_depth,
primary_inputs,
topo_order,
)
PAGE_NET = {
"g0": ("OR", ["c", "d"]),
"g1": ("AND", ["b", "d"]),
"g2": ("AND", ["g1", "g0"]),
"g3": ("OR", ["g1", "a"]),
"g4": ("XOR", ["a", "g2"]),
}
PAGE_OUTS = ["g3", "g4"]
def random_net(rng: random.Random, n_in: int, n_gates: int, fanin: int) -> tuple[dict, list]:
net = {}
signals = [f"x{i}" for i in range(n_in)]
for i in range(n_gates):
g = f"g{i}"
d = rng.randint(2, min(fanin, len(signals)))
net[g] = (rng.choice(["AND", "OR", "XOR", "NAND"]), rng.sample(signals, d))
signals.append(g)
read = {f for _, fs in net.values() for f in fs}
outs = [g for g in net if g not in read]
return net, outs
def brute_cuts(net: dict, v: str, k: int) -> list:
"""Minimal K-feasible cuts of v, by testing every small set of nodes."""
cone, stack = set(), [v]
while stack:
s = stack.pop()
if s in net:
for f in net[s][1]:
if f not in cone:
cone.add(f)
stack.append(f)
def is_cut(c):
seen, stack = set(), [v]
while stack:
s = stack.pop()
if s in c:
continue
if s not in net:
return False
for f in net[s][1]:
if f not in seen:
seen.add(f)
stack.append(f)
return True
found = [frozenset(c) for r in range(1, k + 1) for c in combinations(sorted(cone), r) if is_cut(set(c))]
return [c for c in found if not any(o < c for o in found)]
def brute_depth(net: dict, k: int) -> dict:
"""The least LUT depth of each node, by a recursion over all cuts."""
depth = {p: 0 for p in primary_inputs(net)}
for g in topo_order(net):
depth[g] = min(1 + max(depth[u] for u in c) for c in brute_cuts(net, g, k))
return depth
def brute_min_luts(net: dict, outputs: list, k: int, d: int) -> int:
"""The fewest LUTs of any mapping of depth at most d, by trying every
minimal cut at every LUT root under the required time rule."""
least = brute_depth(net, k)
cuts = {g: brute_cuts(net, g, k) for g in net}
order = list(reversed(topo_order(net)))
best = [10**9]
def search(i, roots, required):
if len(roots) >= best[0]:
return
while i < len(order) and order[i] not in roots:
i += 1
if i == len(order):
best[0] = len(roots)
return
v = order[i]
for c in cuts[v]:
if max(least[u] for u in c) > required[v] - 1:
continue
new_roots, new_req = set(roots), dict(required)
for u in c:
if u in net:
new_roots.add(u)
new_req[u] = min(new_req.get(u, d), required[v] - 1)
search(i + 1, new_roots, new_req)
outs = [o for o in outputs if o in net]
search(0, set(outs), {o: d for o in outs})
return best[0]
def flowmap_count(net: dict, outputs: list, k: int) -> int:
"""FlowMap's mapping phase: each root takes a cut of least height, and
among those the one that covers the most gates."""
cuts = enumerate_cuts(net, k)
arr, _, _ = arrival_and_area(net, outputs, cuts)
def volume(v, c):
seen, stack = set(), [v]
while stack:
s = stack.pop()
if s in c or s in seen or s not in net:
continue
seen.add(s)
stack.extend(net[s][1])
return len(seen)
roots, stack = set(), [o for o in outputs if o in net]
while stack:
v = stack.pop()
if v in roots:
continue
roots.add(v)
c = max((c for c in cuts[v] if max(arr[u] for u in c) == arr[v] - 1), key=lambda c: (volume(v, c), sorted(c)))
stack.extend(u for u in c if u in net)
return len(roots)
def test_page_example():
cuts = enumerate_cuts(PAGE_NET, 3)
arr, area, cut_area = arrival_and_area(PAGE_NET, PAGE_OUTS, cuts)
assert [arr[g] for g in ("g0", "g1", "g2", "g3", "g4")] == [1, 1, 1, 1, 2]
rounded = {(v, tuple(sorted(c))): round(a, 3) for (v, c), a in cut_area.items()}
assert rounded[("g2", ("b", "c", "d"))] == 1.333
assert rounded[("g2", ("c", "d", "g1"))] == 1.5
assert rounded[("g4", ("a", "g2"))] == 2.333
assert rounded[("g4", ("a", "g0", "g1"))] == 2.5
assert rounded[("g3", ("a", "g1"))] == 1.5
assert rounded[("g3", ("a", "b", "d"))] == 1.333
luts, d = daomap(PAGE_NET, PAGE_OUTS, 3)
assert d == 2
assert {v: sorted(c) for v, c in luts.items()} == {
"g4": ["a", "g2"],
"g3": ["a", "b", "d"],
"g2": ["b", "c", "d"],
}
assert equivalent(PAGE_NET, luts, PAGE_OUTS)
assert brute_min_luts(PAGE_NET, PAGE_OUTS, 3, 2) == 3
assert flowmap_count(PAGE_NET, PAGE_OUTS, 3) == 4
def test_arrival_is_least_depth():
rng = random.Random(7)
for _ in range(40):
net, outs = random_net(rng, rng.randint(2, 5), rng.randint(2, 7), 3)
for k in (3, 4):
arr, _, _ = arrival_and_area(net, outs, enumerate_cuts(net, k))
assert arr == brute_depth(net, k)
def test_depth_optimal_and_equivalent():
rng = random.Random(2004)
for _ in range(200):
net, outs = random_net(rng, rng.randint(2, 5), rng.randint(2, 8), 3)
for k in (3, 4):
luts, d = daomap(net, outs, k)
least = brute_depth(net, k)
assert d == max(least[o] for o in outs)
assert lut_depth(net, luts, outs) == d
assert equivalent(net, luts, outs)
assert all(len(c) <= k for c in luts.values())
def test_area_against_exhaustive():
rng = random.Random(5)
total = equal = 0
for _ in range(200):
net, outs = random_net(rng, rng.randint(3, 5), rng.randint(3, 7), 2)
luts, d = daomap(net, outs, 3)
opt = brute_min_luts(net, outs, 3, d)
assert len(luts) >= opt
total += 1
equal += len(luts) == opt
assert equal >= total // 2
def test_one_iteration_is_valid():
rng = random.Random(1)
for _ in range(30):
net, outs = random_net(rng, 4, 6, 2)
luts, d = daomap(net, outs, 3, iterations=1)
assert lut_depth(net, luts, outs) == d
assert equivalent(net, luts, outs)
History
Cong and Ding gave FlowMap in 1992 for least depth, and CutMap (Cong and Hwang, 1995) added area by computing cuts of least cost with max-flow. Cut enumeration, which lists all cuts of a node by combining the cuts of its fanins, and the area estimate that divides the area of a signal by its fanout, came from the cut ranking and pruning work of Cong, Wu and Ding (FPGA 1999), which was area-oriented and did not keep the depth optimal. In 2004 Chen and Cong showed in DAOmap that enumeration with good costs beats the flow-based cuts on both area and run time, and it was part of the RASP system of UCLA. The ideas moved into the priority cut mappers of ABC (2007) and the mappers that followed.
References
- Deming Chen and Jason Cong, DAOmap, a depth-optimal area optimization mapping algorithm for FPGA designs, Proceedings of the IEEE/ACM International Conference on Computer-Aided Design (ICCAD 2004), San Jose, pages 752 to 759, Section 3 (cut enumeration with arrival time and area, Formulas 1 to 4), Section 4.1 to 4.3 (area flow, the cost U_C of a cut with alpha 0.8 and beta 0.4, the duplication cost of Formulas 6 and 7), Section 4.4 (Figure 4 ICS, Figure 5 pick_cut, share 1.15, slack weight 0.3, cut probing), Section 5 (Tables 1 to 3, three ICS passes)
- Jason Cong and Yean-Yow Hwang, Simultaneous depth and area minimization in LUT-based FPGA mapping, Proceedings of the 3rd ACM International Symposium on Field-Programmable Gate Arrays (FPGA 1995), pages 68 to 74, CutMap, the mapper that DAOmap is compared against (general locator)
- Cut ranking and pruning, enabling a general and efficient FPGA mapping solution, cut enumeration with the area estimate that divides the area of a signal by its fanout, and cut pruning for large K; cited by DAOmap as reference 6 (general locator)
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag HAXQH6 Edit this page History Report an error Markdown