From Generic Logic to Real Gates
You've converted your RTL into optimized generic logic—a design expressed in terms of abstract gates and flip-flops. But silicon foundries don't fabricate abstract gates; they fabricate the specific standard cells characterized in Liberty files. Technology mapping bridges this gap, transforming your generic netlist into a gate-level implementation using actual cells from your target library.
This is where synthesis becomes tangible. Generic gates like $_AND_ and $_DFFE_PP0P_ become real cells such as sky130_fd_sc_hd__and4_1 and sky130_fd_sc_hd__dfrtp_1. The Liberty files you studied in Module 6 now drive critical decisions: which gates to use, what drive strengths to select, and how to balance area, timing, and power. This module explores technology mapping in Yosys, focusing on the powerful ABC tool that performs this transformation.
Understanding Technology Mapping
What Technology Mapping Accomplishes
Take the 8-bit counter with an active-high asynchronous reset and an enable that is synthesized at the end of this article. After synth, Yosys holds it as generic internal cells:
=== counter ===
+----------Local Count, excluding submodules.
|
15 wires
43 wire bits
5 public wires
19 public wire bits
4 ports
11 port bits
24 cells
2 $_ANDNOT_
5 $_AND_
8 $_DFFE_PP0P_
1 $_NAND_
1 $_NOT_
1 $_XNOR_
6 $_XOR_
$_DFFE_PP0P_ is Yosys's generic flip-flop with an enable and an active-high reset to 0; $_XOR_, $_AND_ and the rest are generic gates. None of them exists in silicon. After mapping to the SkyWater 130 library, every cell is a real library cell:
=== counter ===
+----------Local Count, excluding submodules.
| +-Local Area, excluding submodules.
| |
27 - wires
34 - wire bits
4 - public wires
11 - public wire bits
4 - ports
11 - port bits
31 334.07 cells
2 12.512 sky130_fd_sc_hd__a31oi_1
1 8.758 sky130_fd_sc_hd__and4_1
8 30.029 sky130_fd_sc_hd__clkinv_1
8 200.192 sky130_fd_sc_hd__dfrtp_1
2 12.512 sky130_fd_sc_hd__lpflow_isobufsrc_1
2 7.507 sky130_fd_sc_hd__nand2_1
1 6.256 sky130_fd_sc_hd__nand4_1
1 3.754 sky130_fd_sc_hd__nor2_1
3 26.275 sky130_fd_sc_hd__xnor2_1
3 26.275 sky130_fd_sc_hd__xor2_1
Chip area for module '\counter': 334.070400
of which used for sequential elements: 200.192000 (59.93%)
The generic flip-flops became dfrtp_1 cells, and the gates became XOR, XNOR, NAND and AND-OR-INVERT cells. The library has no flip-flop with an active-high asynchronous reset, so the mapper used the active-low dfrtp_1 and added a clkinv_1 inverter on the reset of each one: 8 extra cells. It also has no flip-flop with an enable, so the enable became part of the logic in front of each D input.
The Mapping Problem
Given:
- A generic logic network
- A technology library with characterized cells
- Optimization objectives (area, delay, power)
Find:
- The best covering of the logic network with library cells
- Appropriate drive strengths for each cell
- The optimal structure satisfying constraints
This is computationally complex—millions of possible implementations exist for even modest designs. Technology mappers use sophisticated algorithms to navigate this solution space.
Why ABC?
Yosys delegates technology mapping to ABC (A System for Sequential Synthesis and Verification), developed at UC Berkeley. ABC is:
- Highly optimized for combinational and sequential synthesis
- Based on decades of research in logic synthesis
- Used in both academic and commercial tools
- Integrated seamlessly with Yosys
When you run Yosys's abc command, it:
- Exports the generic netlist to ABC format
- Runs ABC with specified optimization strategies
- Imports the technology-mapped result back to Yosys
Loading Liberty Files: read_liberty
Basic Liberty File Reading
Before technology mapping, Yosys needs to understand your target library:
Simple Read
yosys> read_liberty mycells.lib
This loads the Liberty file, parsing:
- Cell definitions and their functions
- Timing characteristics (delays, transitions)
- Power information
- Area values
- Pin capacitances
Reading Multiple Liberty Files
yosys> read_liberty -lib stdcells.lib
yosys> read_liberty -lib memory.lib
yosys> read_liberty -lib io.lib
The -lib flag treats cells as library cells (not part of your design).
Liberty File Options
Ignore Specific Attributes
yosys> read_liberty -ignore_miss_func mycells.lib
Continues even if some functions are undefined (useful for incomplete libraries).
Specify Operating Conditions
yosys> read_liberty -lib -setattr operating_conditions typical_case mycells.lib
Although Yosys primarily uses typical values, you can annotate which conditions the file represents.
Verify Liberty Parsing
yosys> stat -liberty
Shows which library cells are available for mapping.
What Yosys Extracts from Liberty
Critical Information for Mapping:
- Cell functions: Boolean equations (for pattern matching)
- Area: Used in area optimization
- Delay: Used in timing optimization
- Drive strengths: Multiple variants of same function
- Pin capacitances: Affects load-dependent delays
Example: Inverter Variants
The typical-corner SkyWater 130 Liberty file lists these inverters (area in µm², capacitance converted to fF):
sky130_fd_sc_hd__inv_1: area=3.75, input_cap=2.30fF, max_capacitance=181fF
sky130_fd_sc_hd__inv_2: area=3.75, input_cap=4.46fF, max_capacitance=331fF
sky130_fd_sc_hd__inv_4: area=6.26, input_cap=9.00fF, max_capacitance=563fF
sky130_fd_sc_hd__inv_8: area=11.26, input_cap=17.65fF, max_capacitance=1035fF
From this, the mapper knows that all four implement the same function, that inv_8 is three times the area of inv_1 and loads its driver with about 7.7 times the input capacitance, and how much load each may drive. The delay tables, indexed by input slew and output load, say how fast each one is for a given load.
Mapping to Technology Library: The abc Command
Basic Technology Mapping
Simplest Mapping
yosys> abc -liberty mycells.lib
This performs basic technology mapping with default settings.
Complete Flow Example
# Read RTL
read_verilog counter.v
# Generic synthesis
hierarchy -check -top counter
proc
fsm
memory
opt
# Technology mapping
read_liberty -lib mycells.lib
abc -liberty mycells.lib
# View result
stat
show
# Write output
write_verilog -noattr counter_mapped.v
The ABC Black Box
When you run abc, here's what happens internally:
1. Netlist Export Yosys converts internal representation to ABC format (BLIF):
Generic cells ($and, $or, $mux) → Boolean functions
2. ABC Processing ABC runs its synthesis engine:
- Reads the technology library (Liberty)
- Performs logic optimization
- Maps logic to library cells
- Optimizes drive strengths
3. Netlist Import Yosys imports ABC's result:
ABC cell names → Yosys library cells
4. Integration The mapped netlist replaces the generic netlist in Yosys's design database.
Verifying Technology Mapping
Check Cell Types
Run stat (with -liberty for area) and check that every cell name comes from your library, as in the mapped counter above.
Check for Unmapped Cells
Generic cells have names that start with $. select -assert-none t:$* stops the script if any are left. Here is what it reports when dfflibmap was forgotten, so the flip-flops were never mapped (abc maps only the logic between them):
yosys> select -assert-none t:$*
ERROR: Assertion failed: selection is not empty: t:$*
Selection contains:
counter/$auto$ff.cc:337:slice$97
counter/$auto$ff.cc:337:slice$96
...
ABC Synthesis Options and Strategies
Yosys passes the logic between flip-flops to ABC, and the options of the abc command, or a custom -script, decide how ABC optimizes and maps it. The effect of a script is easy to guess wrongly from its name, so measure it. These are real runs on an 8-by-8 multiplier with registered inputs and output, mapped to sky130_fd_sc_hd at the typical corner, with every netlist timed afterwards in OpenSTA at a 5 ns clock:
| ABC command or script | Cells | Area (µm²) | Setup slack at 5 ns |
|---|---|---|---|
abc -liberty lib (default) | 288 | 2606.25 | 1.04 ns |
abc -D 1500 -liberty lib | 288 | 2606.25 | 1.04 ns |
abc -fast -liberty lib | 549 | 3508.36 | 1.55 ns |
-script +strash;scorr;ifraig;retime,{D};strash;dch,-f;map,-M,1,{D} | 559 | 3330.69 | 1.83 ns |
-script +strash;ifraig;retime,{D};strash;dch,-f;map,-a,{D} | 425 | 2658.80 | 1.06 ns |
-script +strash;ifraig;map,-M,2,{D} | 554 | 3548.40 | 1.45 ns |
-script +strash;retime;map | 549 | 3508.36 | 1.55 ns |
-script +strash;dch;&get,-n;&nf,-a;&put | 302 | 2745.13 | 1.53 ns |
abc -D 3000 -constr abc.constr -liberty lib | 292 | 2752.64 | 1.38 ns |
What these runs show:
- The default is the smallest. Without
-script, Yosys uses ABC's modern mapper (&nf), which gave the fewest cells and the least area. -Dalone changed nothing. Targets from 300 ps to 20,000 ps all gave the same netlist. ABC's mapper already aims for its own minimum delay, and its delay estimate does not include most of the load on each net, so the target never forced a different choice.- The older
map-based scripts are larger and often faster. Themap,-M,1script, sometimes described as area-focused, produced one of the largest netlists and the most slack.map,-ais ABC's area-oriented mapping, and here it came close to the default. retimedid nothing here. The+strash;retime;maprun gave exactly the same netlist asabc -fast, because without the-dffoption ABC never sees the flip-flops, so there is nothing to retime.- Load information matters. Giving ABC a driving cell and an output load through
-constrchanged the result where-Dalone did not.
The general lesson: area and speed trade against each other, but which script wins depends on the design and the library. Run the candidates, then compare area from stat -liberty and slack from a timing tool.
Sequential Optimization
Retiming moves flip-flops through combinational logic to balance the delay on either side. It does not change the function seen at the outputs or the latency. In Yosys, ABC only sees flip-flops when abc -dff is used; otherwise retiming commands in a script have no registers to move, as the table shows. Check any retimed netlist with a timing tool and with equivalence checking.
Custom ABC Scripts
Define Your Own Strategy
yosys> abc -liberty mycells.lib -script +strash;dch;map
A script given inline starts with +, and commas stand for spaces inside a command, as in map,-a. The form with braces, {strash;dch;map}, makes ABC stop with a command error.
You can create custom synthesis recipes:
strash: Structure sharingbalance: Balance logic treerewrite: Algebraic rewritingrefactor: Functional refactoringmap: Final technology mapping
Common Script Building Blocks:
strash- Always good to start with (merges duplicates)balance- Balances tree depth (improves timing)rewrite- Finds better logic structuresdch- Don't-care optimization (aggressive)map- Technology mapping (must come last)
Understanding ABC Script Syntax
Basic Format
+strash;command1;command2;...;map
Iteration
+strash;rewrite,-z;rewrite,-z;rewrite,-z;map
Running rewrite multiple times can find additional optimizations.
Conditional Execution
+strash;if;map
The if command performs "if-then-else" structure mapping.
Synthesis Recipes from Research
Yosys includes several predefined strategies:
Default Strategy
yosys> abc -liberty mycells.lib
Fast Strategy (quick compile)
yosys> abc -liberty mycells.lib -fast
Resyn2 Strategy (classic optimization)
+balance;rewrite;refactor;balance;rewrite;rewrite,-z;balance;refactor,-z;rewrite,-z;balance
This is a well-known recipe from the ABC literature.
Drive Strength Optimization
The Drive Strength Problem
Most functions come in several sizes: inv_1, inv_2, inv_4 and inv_8 all invert, with more drive, more area and more input capacitance as the number grows. A larger cell switches a heavy load faster but loads the cell in front of it more, so bigger is not always faster.
What ABC Does With Drive Strengths
ABC picks cells with its own delay model during mapping, which treats each cell input as a fixed load and does not know the real wiring. In the runs above, the default mapping used only the two smallest sizes (_0 and _1); abc -fast also used some _2 and _4 cells. There is no rule such as "use size 4 above a given load" inside ABC: the choice falls out of its delay and area estimates.
In an open-source flow the real sizing happens later. After placement, OpenROAD estimates wire loads, upsizes cells, inserts buffers on long or heavily loaded nets, and fixes timing violations. The clock network is built by clock tree synthesis in place and route, not by synthesis.
Influencing Mapping
Driving cell and load
# abc.constr
set_driving_cell sky130_fd_sc_hd__inv_2
set_load 0.01
yosys> abc -D 3000 -constr abc.constr -liberty sky130_fd_sc_hd__tt_025C_1v80.lib
The -constr file holds just these two lines: the cell assumed to drive the inputs and the load, in the library's capacitance unit, on the outputs. It is not an SDC file. It is used together with -D, the delay target in picoseconds.
Excluding cells
yosys> abc -liberty sky130_fd_sc_hd__tt_025C_1v80.lib -dont_use sky130_fd_sc_hd__lpflow_*
-dont_use keeps the mapper away from cells you must not use. In these runs ABC used lpflow_isobufsrc_1, an isolation buffer meant for power-gated designs, as ordinary logic; production flows exclude such cells.
Yosys has no option to set an area limit or a mapping effort level for abc.
Complete Technology Mapping Example
Let's walk through a realistic synthesis with technology mapping:
Synthesis Script
# 1. Read RTL
read_verilog counter.v
# 2. Generic synthesis
synth -top counter
# 3. Map flip-flops, then logic, to the library
dfflibmap -liberty sky130_fd_sc_hd__tt_025C_1v80.lib
abc -liberty sky130_fd_sc_hd__tt_025C_1v80.lib
# 4. Clean up and report
opt_clean -purge
tee -o stat.txt stat -liberty sky130_fd_sc_hd__tt_025C_1v80.lib
select -assert-none t:$*
# 5. Output
write_verilog -noattr counter_mapped.v
dfflibmap maps the flip-flops and abc the logic between them; leave out dfflibmap and the flip-flops stay generic. select -assert-none t:$* stops the run if anything is still unmapped.
Running the Synthesis
$ yosys -s synthesis.ys
Analyzing Results
=== counter ===
+----------Local Count, excluding submodules.
| +-Local Area, excluding submodules.
| |
27 - wires
34 - wire bits
4 - public wires
11 - public wire bits
4 - ports
11 - port bits
31 334.07 cells
2 12.512 sky130_fd_sc_hd__a31oi_1
1 8.758 sky130_fd_sc_hd__and4_1
8 30.029 sky130_fd_sc_hd__clkinv_1
8 200.192 sky130_fd_sc_hd__dfrtp_1
2 12.512 sky130_fd_sc_hd__lpflow_isobufsrc_1
2 7.507 sky130_fd_sc_hd__nand2_1
1 6.256 sky130_fd_sc_hd__nand4_1
1 3.754 sky130_fd_sc_hd__nor2_1
3 26.275 sky130_fd_sc_hd__xnor2_1
3 26.275 sky130_fd_sc_hd__xor2_1
Chip area for module '\counter': 334.070400
of which used for sequential elements: 200.192000 (59.93%)
What Happened:
- The 8 registers became 8
dfrtp_1flip-flops, 200.19 µm² of the 334.07 µm² total - The active-high reset needed 8
clkinv_1inverters, because the library's flip-flops have an active-low reset; with an active-low reset in the RTL the same counter maps to 304.04 µm² - The increment became XOR and XNOR cells for the sum bits and a few NAND, NOR and AND-OR-INVERT cells for the carries
- The enable was folded into that logic, since there is no flip-flop with an enable in the library
Advanced Technology Mapping Topics
Multi-Corner Mapping
Mapping uses one Liberty file. Mapping the multiplier above with the slow, typical and fast SkyWater 130 libraries gave the same netlist each time, because the cells and their areas are the same at every corner; only the delays differ. Map with the corner you design for, then check timing at every corner with a timing tool: the same netlist had -3.25 ns of setup slack at 5 ns in the slow corner and 2.66 ns in the fast one.
Mapping with Constraints
Clock periods and I/O delays in SDC form are for the timing tool. What abc accepts is the delay target -D and the two-line -constr file shown above.
Technology-Specific Cells
Libraries also contain cells that synthesis of ordinary logic does not create on its own: tie cells such as sky130_fd_sc_hd__conb_1, which provide a constant 0 and 1, and clock gating cells such as sky130_fd_sc_hd__dlclkp_1. Tie cells are inserted by the flow where a constant drives a gate input, and clock gating cells appear when the RTL or a dedicated pass adds clock gating; ABC does not insert them.
Debugging Technology Mapping Issues
Common Problems
Problem: Cells Left Unmapped
select -assert-none t:$* fails and lists cells whose names start with $. The usual causes are a missing dfflibmap step (generic flip-flops left behind), a library without a suitable cell, or a step that ran in the wrong order. Run the mapping steps again and check the Liberty file has the cell types the design needs.
Problem: Area Larger Than Expected
Compare stat -liberty across mapping options, as in the table above: the scripts there ranged from 2,606 to 3,548 µm² for the same multiplier. Also check the RTL for logic that should not be there, such as an active-high reset that adds an inverter per flip-flop, or a wider datapath than intended.
Problem: Timing Not Met
Time the netlist in a timing tool first: ABC's own estimate is not enough. If a path fails, try a faster mapping, give ABC realistic load information with -constr, restructure or pipeline the RTL, and leave sizing and buffering to place and route, where the wires are known.
Verification Strategy
Always Verify Mapping:
- Check all cells are from library (no generic cells remain)
- Verify timing with constraints
- Compare area to expectations
- Ensure no unmapped or unsupported cells
Sanity Checks:
yosys> stat -liberty
yosys> select t:$*
# Should return nothing if fully mapped
yosys> check
# Should pass without errors
Summary
Technology mapping transforms generic logic into real standard cells:
read_libertyloads technology library information into Yosysabcperforms the actual technology mapping using advanced algorithms- ABC options and scripts trade area against speed, but their effect must be measured: compare
stat -libertyand timing-tool slack - Drive strengths are chosen from ABC's own estimates during mapping and refined after placement, where real loads are known
dfflibmapmaps the flip-flops;select -assert-none t:$*proves nothing generic is left
Key skills you've developed:
- Loading and using Liberty files in Yosys
- Running ABC with different optimization strategies
- Understanding drive strength selection
- Debugging technology mapping issues
- Creating complete synthesis scripts from RTL to gates
With technology mapping complete, your design is now a true gate-level netlist ready for place-and-route. The abstract gates have become real silicon cells, characterized and ready to be physically implemented. In the next modules, we'll explore how to analyze and optimize this technology-mapped design for final tape-out.