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

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Logic Synthesis Glossary
  • Logic Synthesis Cheatsheet
  • Synthesis Foundations14
  • Logic Optimisation and Mapping20
    • Boolean Optimisation
    • Technology Mapping
      • Covering a Network with Cells
      • Cuts and Matching
      • Area Against Delay
      • Inverters and Banned Cells
      • Mapping in Yosys
    • Cell Libraries and Liberty
    • 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

‹Technology Mapping
  1. Topics
  2. Logic Synthesis
  3. Logic Optimisation and Mapping
  4. Technology Mapping
  5. Mapping in Yosys

Part 2 · Logic Optimisation and Mapping · Intermediate

Mapping in Yosys

A 4-bit adder mapped with ABC to two libraries, with asserted areas.

On this page

    The setup

    A behavioural 4-bit adder, s = a + b, is synthesised and then mapped twice with ABC: once to the full teaching library and once to a NAND-only variant. Areas below are library units of the fictional teaching library, never silicon figures.

    Cell

    Area

    Cell

    Area

    INV

    1

    XNOR2

    5

    BUF

    2

    AOI21

    3

    NAND2

    2

    OAI21

    3

    NOR2

    2

    MUX2

    5

    AND2

    3

    DFF

    8

    OR2

    3

    DFFR

    10

    NAND3

    3

    NOR3

    3

    XOR2

    5

    The restricted variant, nand_only.lib, holds only INV, BUF, and NAND2 at the same areas. Every other function must be built from those three.

    Mapping to the full library

    The first block maps the adder to course.lib and proves the netlist holds no generic gates. The stat line reports the area for this exact course build: 52 area units.

    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
    read_verilog <<EOV
    module adder4(input [3:0] a, b, output [4:0] s);
    assign s = a + b;
    endmodule
    EOV
    synth -top adder4
    abc -liberty course.lib
    stat -liberty course.lib
    select -assert-none t:$and
    select -assert-none t:$or
    select -assert-none t:$xor
    select -assert-none t:$xnor
    select -assert-none t:$mux
    select -assert-none t:$not
    select -assert-none t:$_AND_
    select -assert-none t:$_OR_
    select -assert-none t:$_XOR_
    select -assert-none t:$_XNOR_
    select -assert-none t:$_MUX_
    select -assert-none t:$_NOT_
    select -assert-none t:$_NAND_
    select -assert-none t:$_NOR_
    check
    log PASS: adder4 maps to course.lib cells with no generic gates left

    Mapping to the restricted library

    The second block maps the same adder to nand_only.lib and proves only INV, BUF, and NAND2 remain. The stat line reports 68 area units on the same build.

    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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    read_verilog <<EOV
    module adder4(input [3:0] a, b, output [4:0] s);
    assign s = a + b;
    endmodule
    EOV
    synth -top adder4
    abc -liberty nand_only.lib
    stat -liberty nand_only.lib
    select -assert-none t:$and
    select -assert-none t:$or
    select -assert-none t:$xor
    select -assert-none t:$xnor
    select -assert-none t:$mux
    select -assert-none t:$not
    select -assert-none t:$_AND_
    select -assert-none t:$_OR_
    select -assert-none t:$_XOR_
    select -assert-none t:$_XNOR_
    select -assert-none t:$_MUX_
    select -assert-none t:$_NOT_
    select -assert-none t:$_NAND_
    select -assert-none t:$_NOR_
    select -assert-none t:AND2
    select -assert-none t:OR2
    select -assert-none t:XOR2
    select -assert-none t:XNOR2
    select -assert-none t:NAND3
    select -assert-none t:NOR3
    select -assert-none t:AOI21
    select -assert-none t:OAI21
    select -assert-none t:MUX2
    select -assert-none t:DFF
    select -assert-none t:DFFR
    select -assert-min 1 t:NAND2
    check
    log PASS: adder4 maps to INV BUF NAND2 only with no generic gates left

    Library

    Cells available

    Area (area units)

    course.lib

    15

    52

    nand_only.lib

    3

    68

    Diagram
    this exact course build and library (example result, not a guarantee)
    course.lib area = 52 area units
    nand_only.lib area = 68 area units
    difference = 68 - 52 = 16 area units
    ratio = 68 / 52 = 1.3077, about 1.31x

    The restricted cover costs more because sums need XOR behaviour. The full library offers it in one cell; the restricted library builds it from several NAND2 cells, and the extra gates outweigh the saving per cell.

    Common mistakes

    Common pitfall

    Quoting ABC areas as guarantees: 52 against 68 holds for this exact build and library. Assert cell structure in scripts and treat area numbers as examples that move between builds.

    Interview

    Likely probes: reading a mapping result.

    • stat area is a sum of cell areas in library units, not silicon.

    • A restricted library costs more where the missing cells fit best.

    • Absence assertions prove which gate kinds a mapping really used.

    Check yourself Why does the NAND-only mapping cost more area on the adder?

    Sums need XOR behaviour. The full library offers it in one cell, while the restricted library builds it from several NAND2 cells.

    Check yourself What does each select -assert-none line prove?

    That the named generic gate kind is gone from the mapped netlist. Together they prove the mapping reached library cells.

    Related topics

    • Inverters and Banned Cells

    • Reading Netlists and Reports

    • Equivalence Checking

    Previous

    26 / 139

    Next: Cell Libraries and Liberty

    Up next

    Up nextCell Libraries and Liberty

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Covering a Network with Cells
    • Cuts and Matching
    • Area Against Delay