Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • Logic Synthesis Glossary
  • Logic Synthesis Cheatsheet
  • Synthesis Foundations14
  • Logic Optimisation and Mapping20
    • Boolean Optimisation
    • Technology Mapping
    • Cell Libraries and Liberty
      • What a Library Contains
      • Reading the Teaching Library
      • Delay Tables and Interpolation
      • Flops, Power, and Variants
      • Mapping Against the Library
    • Structuring and Buffering
  • Constraints and Timing15
  • Sequential, FSM and Memory19
  • Datapath Synthesis14
  • Area, Power and Test14
  • Verification, ECO and Handoff15
  • Flows and Debugging15
  • Interview and Judgment11
Loading lesson

←Cell Libraries and Liberty
  1. Topics
  2. Logic Synthesis
  3. Logic Optimisation and Mapping
  4. Cell Libraries and Liberty
  5. What a Library Contains
On this page

    Part 2 of 9, lesson 11 of 20Part 2 of 9/Logic Optimisation and Mapping/Lesson 11 of 20Intermediate

    What a Library Contains

    What a cell library holds: function, area, capacitance, arcs, tables, and power.

    The mapper only trades cells the library lists. One banned entry can move a whole cover, and teams that never saw it coming quote the wrong area.

    After this lesson you can: read one Liberty entry field by field, reconcile its pF and ns units, and price what banning a cell costs.

    The question

    Every mapping result is a shopping trip through a library: the mapper matches generic gates against listed cells and keeps the cheapest cover. This lesson reads one real entry, the NAND2 cell of course.lib, field by field, then maps one NAND function twice: with the whole library, and with NAND2 banned.

    One entry, annotated

    Below is the NAND2 entry as it stands in course.lib, with line breaks added for reading. Area first, then the input pins, then the output pin with its function, then one timing group per input arc carrying rise and fall delay plus output slew tables.

    Diagram
    cell(NAND2) {                                      <= the entry the mapper trades
      area : 2;                                          <= cost of one use: 2 library units
      pin(A) { direction : input; capacitance : 0.01; }   <= input pin A loads its driver
      pin(B) { direction : input; capacitance : 0.01; }   <= input pin B loads its driver
      pin(Y) {
        direction : output;
        max_capacitance : 1.0;                           <= driver limit: 1.0 pF past this pin
        function : "!(A*B)";                             <= what the cell computes
        timing() {                                       <= arc from input A to output Y
          related_pin : "A";
          timing_sense : negative_unate;                 <= rising input falls the output
          cell_rise(dt) {
            index_1("0.01,0.1");                         <= rows: input slew
            index_2("0.01,0.1");                         <= columns: output load
            values("0.08,0.1","0.11,0.14");              <= delay table, exact from the file
          }
          cell_fall(dt) { ... same shape ... }
          rise_transition(dt) { ... output slew table ... }
          fall_transition(dt) { ... output slew table ... }
        }
        timing() { ... same tables for input B ... }
      }
    }

    Area and pin capacitance

    Each use of a cell costs its listed area: the mapper adds cell areas to score covers, so a cover that uses more cells usually costs more even when each cell is cheap. The exact prices live in the table below.

    Capacitance 0.01 is the load each input pin adds to its driver, in the file units settled below. Fanout load is a sum: one net driving three NAND2 input pins presents three times 0.01 before any wire load, and larger loads index slower table points.

    Fragment (exact from course.lib)

    What the mapper does with it

    area:2;

    Adds 2 library units per use when scoring covers.

    capacitance:0.01;

    Adds 0.01 pF of load to the driver for each driven pin.

    function:"!(A*B)";

    Matches cones computing NOT (A AND B) to this cell.

    timing_sense:negative_unate;

    Knows a rising input falls the output on this arc.

    values("0.08,0.1","0.11,0.14");

    Looks up rise delay by input slew row and output load column.

    max_capacitance:1.0;

    Flags any net past 1.0 pF on this pin as a violation to repair.

    Units, reconciled

    The file header declares its own units: capacitive_load_unit(1,pf) and time_unit 1ns. The 0.01 on each input pin is 0.01 pF, and the 0.08 table corner is 0.08 ns, which is 80 ps.

    Later lessons quote loads in femtofarads: 0.01 pF is 10 fF, exactly one teaching-library input pin. Convert before comparing: 0.11 ns here is 110 ps wherever ABC reports it. Typical.constr writes the output load as 50, which ABC reads as 50 fF, or 0.05 pF: the same load as five 10 fF input pins.

    Diagram
    course.lib units (from the file header, not a guess)
    capacitance 0.01 = 0.01 pF = 0.01 x 1000 fF = 10 fF
    delay 0.08 = 0.08 ns = 0.08 x 1000 ps = 80 ps
    typical.constr load 50 = 50 fF = 0.05 pF = 5 input-pin loads of 10 fF

    The run

    The script reads course.lib, writes the loaded cells out with write_json, then maps y = NOT (a AND b) three times from one generic netlist. All three mappings run under typical.constr (BUF driver, 50 fF on the output, so ABC reports area and delay) with a loose 1000 ps target that changes nothing in a one-size library. The bans use abc -dont_use, the command-line stand-in for marking a cell dont_use : true in Liberty.

    yosys
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    read_liberty -lib course.lib
    write_json lib.json
    read_verilog <<EOV
    module top(input a, b, output y);
    assign y = ~(a & b);
    endmodule
    EOV
    hierarchy -check -top top
    proc
    opt
    techmap
    design -save generic
    tee -o abc_full.txt abc -liberty course.lib -constr typical.constr -D 1000
    tee -o stat_full.txt stat -liberty course.lib
    write_json net_full.json
    select -assert-min 1 t:NAND2
    design -load generic
    tee -o abc_banned.txt abc -liberty course.lib -constr typical.constr -D 1000 -dont_use NAND2
    tee -o stat_banned.txt stat -liberty course.lib
    select -assert-none t:NAND2
    select -assert-min 1 t:INV
    design -load generic
    tee -o abc_banned2.txt abc -liberty course.lib -constr typical.constr -D 1000 -dont_use NAND2 -dont_use AND2
    tee -o stat_banned2.txt stat -liberty course.lib
    select -assert-none t:NAND2 t:AND2
    check
    log PASS: each ban removes its cells and every rebuild maps cleanly
    Predict first You ban NAND2 before mapping y = NOT (a AND b). Which cell disappears from the report, and can the function still map?

    NAND2 disappears entirely. The function still maps from an AND2 plus one INV: more cells and more area for identical logic in this ABC script. A ban can never make the cover cheaper: it costs more here, while the recorded XOR2 ban in mapping-in-yosys holds area 59 across 20 cells against 18 free.

    Cover

    Cells

    Area

    Delay

    Full library

    1

    2

    93.96 ps

    NAND2 banned

    2

    4

    188.07 ps

    NAND2 and AND2 banned

    3

    5

    198.07 ps

    Read the three rows as the price of one entry: the same function from one NAND2, from an AND2 plus one INV once NAND2 is banned, or from an OR2 plus 2 INV once both are banned. Same RTL, same tool, different menu. One apparent mismatch to settle now: the full-cover path delay of 93.96 ps sits above the 80 ps table corner, because the two answer different questions. The corner is one bare cell at the smallest slew and load; the ABC number covers the whole path under typical.constr, driver stage and 50 fF output load included.

    Full cover cells (recorded stat)

    Count

    Area

    NAND2

    1

    2

    Banned cover cells (recorded stat)

    Count

    Area

    AND2

    1

    3

    INV

    1

    1

    The full-library cover of one NAND function: 1 cell at area 2, with the NAND2 cell highlighted.

    Break it: ban the fallback too

    The script writes the loaded library out before any RTL is read: lib.json holds every cell as a module, all 15 of them below. When a mapping surprises you, this list is the first place to look, because the mapper cannot use what is not on it.

    Library cells (recorded lib.json)

    AND2

    AOI21

    BUF

    DFF

    DFFR

    INV

    MUX2

    NAND2

    NAND3

    NOR2

    NOR3

    OAI21

    OR2

    XNOR2

    XOR2

    The third run is the break-it: NAND2 and AND2 banned together, so both covers in the table above are illegal. The recorded fallback is one OR2 plus 2 INV: y = NOT (a AND b) becomes (NOT a) OR (NOT b), an OR of two inversions, for 3 cells at area 5 against area 4 with one ban. Real libraries ban cells the same way: legacy cells, cells uncharacterised at a corner, unroutable footprints. Every ban shrinks the choice set, so recheck area and delay after each one.

    Stacked-ban cover (recorded stat)

    Count

    Area

    INV

    2

    2

    OR2

    1

    3

    Common mistakes

    Quoting an area without naming the library. Cell areas here are library units of course.lib, a fictional teaching library. They compare against other cells in the same file and against nothing anywhere else.

    Reading a Liberty number without its unit header. The 0.01 pin capacitance is pF only because the header says capacitive_load_unit(1,pf); the 0.08 table corner is ns only because of time_unit 1ns. Paste the units next to every number you copy.

    What does the mapper read first in a library, and why can it not use a cell that is not there?

    Weak answer: it reads the gates and picks the fastest ones.

    Strong answer: function first, to see which cones each cell covers, then area and tables to price the covers. Here the same function maps to area 2 with NAND2 and area 4 without: the ban removes the cheapest cover, so the mapper pays an AND2 plus one INV for identical logic.

    Follow-up: when would you ban a cell on purpose? Name two causes and what you recheck after each.

    Check yourself The banned cover costs more area than the full cover in the table above. What does the difference pay for?

    It pays for rebuilding NOT (A AND B) without NAND2: an AND2 plus one INV instead of one NAND2 cell. The function is unchanged; only the cover moved, because the menu shrank by one entry.

    Check yourself One net drives three NAND2 input pins. What load does the driver see from those pins, in pF and in fF?

    Three times 0.01 pF, which is 0.03 pF, before any wire load. At a thousand fF per pF that is 30 fF, or three input pins of 10 fF each.

    • Area prices the use; pin capacitance loads the driver; function and sense decide which cones match.

    • course.lib units are pF and ns by its header: 0.01 pF is 10 fF, 0.08 ns is 80 ps.

    • A ban never breaks logic while an equivalent cover exists; it never makes the cover cheaper.

    Rule of thumb: paste the unit header next to every number you copy from a library.

    How this was checked

    Every number and picture on this page comes from one Yosys 0.69 run of the script shown, recorded by the course checker (scripts/tools/run-rtl-testbenches.mjs with COURSE=synth): y = NOT (a AND b) maps against course.lib free, with abc -dont_use NAND2, and with NAND2 plus AND2 banned, with stat -liberty areas and a write_json cell listing (lib.json). The annotated NAND2 entry is copied exactly from scripts/tools/synth-libs/course.lib.

    • Interview: run a mock interview on this topic

    Related topics

    • Reading the teaching library

    • Technology Mapping

    Previous

    27 / 139

    Next: Reading the Teaching Library

    Up next

    Up nextReading the Teaching Library

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Delay Tables and Interpolation
    • Flops, Power, and Variants
    • Mapping Against the Library