The idea: cover the logic with the cells the library really has
After synthesis and logic optimization, a circuit is still made of generic gates. A chip can only use the cells of its standard-cell library: INV, NAND2, NAND3, NOR2, AOI22 and a few hundred more, each with a known area and delay. Technology mapping picks which cells to use. It writes the logic as a graph of tiny nodes, writes every cell as a small pattern of the same nodes, and then covers the graph with patterns at the lowest total cost.
The canvas runs the classic method, tree covering by dynamic programming. The subject graph is on the left, the library and the cost table on the right. Press Next Node to handle one node, or Map All.
This page starts where other pages stop. From Verilog to Hardware shows the generic gates synthesis builds from code. Multilevel Logic shows why NAND and NOR are the natural CMOS gates and how bubble pushing turns AND-OR into NAND-NAND. Karnaugh maps minimize two-level logic by hand. None of them choose real cells.
The subject graph: NAND2 and INV only
First the logic is decomposed into a subject graph that has just two kinds of node: N, a 2-input NAND, and I, an inverter. Any function can be written this way. For f = (ab + cd)':
- n1 = N(a, b) and n2 = N(c, d) are (ab)' and (cd)'.
- n3 = N(n1, n2) = ab + cd, by De Morgan.
- n4 = I(n3) = f.
With one cell per node this is 3 NAND2 + 1 INV, area 3 · 2 + 1 = 7. That is the baseline the mapper has to beat.
Library cells as pattern trees
Each cell is written in the same N and I nodes. The letters are the cell's inputs. A pattern matches at a node when its shape fits the subject graph there, with N on N and I on I. A 2-input N may match with its inputs in either order.
| Cell | Function | Pattern | Area | Delay |
|---|---|---|---|---|
| INV | x' | I(x) | 1 | 1 + 1·load |
| NAND2 | (xy)' | N(x, y) | 2 | 2 + 2·load |
| NAND3 | (xyz)' | N(x, I(N(y, z))) | 3 | 3 + 3·load |
| NOR2 | (x + y)' | I(N(I(x), I(y))) | 2 | 2 + 2·load |
| AOI22 | (wx + yz)' | I(N(N(w, x), N(y, z))) | 4 | 4 + 2·load |
INV and NAND2 match every node, so a cover always exists. The other three cells are there to do better.
Tree covering by dynamic programming
The mapper visits the nodes from the inputs to the output. At each node it lists every match. The cost of a match is the cell's own cost plus the best costs already stored for the nodes that feed it. The node keeps only its cheapest match. A node higher up never looks below its inputs again: it just reads their stored numbers. That is dynamic programming, and on a tree it finds the cheapest cover in time linear in the number of nodes (times the number of patterns).
| Node | Matches (area) | Kept |
|---|---|---|
| n1 | NAND2: 2 + 0 = 2 | NAND2, 2 |
| n2 | NAND2: 2 + 0 = 2 | NAND2, 2 |
| n3 | NAND2: 2 + 2 + 2 = 6 | NAND2, 6 |
| n4 | INV: 1 + 6 = 7; AOI22: 4 + 0 = 4 | AOI22, 4 |
AOI22 matches at n4 and swallows n1, n2 and n3; its inputs are the primary inputs a, b, c, d, which cost nothing. Then the cover is read back from the output: take n4's best match, then the best match of each node that match uses as an input. Here there is none: the netlist is a single AOI22, area 4 instead of 7. The panel checks the netlist against the subject graph on all 16 input rows. Demo: area, one AOI22 beats four gates.
Delay as the cost
The same DP works for delay. A node's number is now its arrival time: the latest arrival at the match's inputs, plus the cell's delay. On the page a cell's delay is p + k · load. Here p is the delay with no load, k is how weak its output is, and the load counts the gate inputs the net drives, plus the output pin's load. A complex gate has transistors in series, so a small AOI22 is a weak driver (k = 2), while an INV is strong (k = 1).
| Output load | INV over three NAND2 | AOI22 | Chosen |
|---|---|---|---|
| 1 | 8 + 1 + 1 = 10 | 0 + 4 + 2 = 6 | AOI22, delay 6, area 4 |
| 8 | 8 + 1 + 8 = 17 | 0 + 4 + 16 = 20 | NAND2 ×3 + INV, delay 17, area 7 |
With a light load the AOI22 is both smaller and faster. With a heavy load it pays 2 per unit of load, and the strong INV at the end wins, for more area. Same graph, same library, different cost, different netlist. Demo: delay, light load and Demo: delay, heavy load.
A deeper tree: NAND3 and NOR2
h = (c · d · (a + b)')' decomposes into 7 nodes; one cell each would cost area 10. At n4 the NOR2 pattern I(N(I(a), I(b))) swallows four nodes for area 2 instead of 5. At n7, the root, NAND3 matches as N(c, I(N(d, n4))): 3 + 2 = 5, against NAND2 over the rest at 2 + 5 = 7. The cover is NAND3(c, d, NOR2(a, b)): two cells, area 5. Demo: NAND3 and NOR2 cover h.
With output load 8 the NAND3, the weakest driver in the library (k = 3), loses at the root: 4 + 3 + 24 = 31 against 10 + 2 + 16 = 28 for a NAND2. The result is NAND2(c, INV(NAND2(d, NOR2(a, b)))), area 7, delay 28. Demo: h with a heavy load.
Fan-out cuts the DAG into trees
Real logic shares signals, so the subject graph is a DAG, not a tree. If f = (ab + cd)' and g = (abe)' both use n1 = N(a, b), n1 has a fan-out of 2. A pattern cannot swallow n1 inside f's cover, because g needs n1's output too. Tree covering therefore cuts the graph at every fan-out point. n1 becomes the root of its own tree, and a plain input for the trees that use it. Each tree is mapped alone.
On the page the three trees cost 2 + 5 + 3 = 10. AOI22 no longer matches at f, and NAND3 no longer matches at g, because both would have to reach inside n1's tree. Copying NAND(a, b) into both cones would allow area 4 + 3 = 7. So tree covering is optimal for each tree, but not for the whole circuit. Real mappers add tricks for this: they let patterns cross fan-out points and copy the logic, or match on the DAG directly. Demo: fan-out cuts the DAG into trees.
Where mapping sits in the flow
RTL is first turned into generic logic, as in From Verilog to Hardware. It is then optimized without any library in mind, for example by algebraic factoring, with binary decision diagrams used to check that nothing changed. Technology mapping comes next. After it, the netlist is sized (logical effort sizing), placed and routed, and checked with static timing analysis. The whole chain is on the ASIC design flow page.
The decomposition matters. A different NAND2/INV graph for the same function can allow different matches, so the mapper's result depends on the shape it is handed.
See also Binary Decision Diagrams for checking that a mapped netlist still computes the same function as the original.
See also Stuck-at Faults and Test Generation, which generates manufacturing tests for a mapped gate netlist.
See also Standard-Cell Place and Route, which places the mapped library cells in rows and routes the nets between them.
What the page leaves out
- Real delay comes from tables indexed by input slew and output load, and the load of a net depends on the cells chosen above it. Mappers handle this with load bins or by mapping again after sizing; the page fixes the load of every inside net at 1.
- Real libraries have hundreds of cells in several drive strengths (INV_X1, INV_X4, …), and also XOR, mux, OAI and flip-flop cells.
- Duplication across fan-out points, DAG covering, and cut-based mapping as in ABC or FPGA LUT mappers are only mentioned.
- The decomposition step is fixed here; tools try several decompositions and choose between them.
- Placement, wire delay and power as a cost are not modelled.
On the mind map
References
Kurt Keutzer, "DAGON: Technology Binding and Local Optimization by DAG Matching", Design Automation Conference, 1987: the tree-covering method
Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, chapter 10 (cell-library binding)