Module 2: Logic Synthesis · 2.2 Yosys in OpenLane

The Synthesis Script OpenLane Runs

Section 2.1 explained the theoretical foundations of logic synthesis. Section 2.2 examines practical execution inside OpenLane.

The run_synthesis command executes an automated Yosys Tcl script. OpenLane generates this script based on project configuration files. Understanding this script allows designers to diagnose synthesis issues and customize flow parameters.

The Reference Design: An 8-Bit Arithmetic Logic Unit

This module uses an 8-bit Arithmetic Logic Unit (alu8) with registered outputs for hands-on examples:

module alu8 (
    input  wire        clk,
    input  wire        rst_n,
    input  wire [7:0]  a,
    input  wire [7:0]  b,
    input  wire [2:0]  op,
    output reg  [7:0]  result,
    output reg         zero,
    output reg         carry_out
);
    // op: 0=ADD 1=SUB 2=AND 3=OR 4=XOR 5=SLT 6=SLL 7=SRL
    reg [8:0] alu_ext;
    always @(*) begin
        case (op)
            3'd0: alu_ext = a + b;
            3'd1: alu_ext = a - b;
            3'd2: alu_ext = {1'b0, a & b};
            3'd3: alu_ext = {1'b0, a | b};
            3'd4: alu_ext = {1'b0, a ^ b};
            3'd5: alu_ext = {8'b0, (a < b)};
            3'd6: alu_ext = {1'b0, a} << 1;
            default: alu_ext = {1'b0, a} >> 1;
        endcase
    end

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            result    <= 8'b0;
            zero      <= 1'b0;
            carry_out <= 1'b0;
        end else begin
            result    <= alu_ext[7:0];
            zero      <= (alu_ext[7:0] == 8'b0);
            carry_out <= alu_ext[8];
        end
    end
endmodule

The module implements eight arithmetic and logical operations selected by a 3-bit opcode. The output registers capture the 8-bit result, zero flag, and carry flag on rising clock edges.

Structure of the Generated Yosys Script

When you execute synthesis in OpenLane:

openlane --flow Classic --run-tag alu8_run designs/alu8/config.json

OpenLane generates and executes a Yosys script located at runs/alu8_run/tmp/synthesis/.

Here are the primary commands in that synthesis script:

# 1. Read the standard cell library models
read_liberty -lib -ignore_miss_dir -setattr blackbox \
    $::env(LIB_SYNTH)

# 2. Read the RTL source code
read_verilog -sv $::env(VERILOG_FILES)

# 3. Elaborate and check top-level hierarchy
hierarchy -check -top alu8

# 4. Perform generic technology-independent synthesis
synth -top alu8

# 5. Map generic flip-flops to physical library flip-flops
dfflibmap -liberty $::env(LIB_SYNTH)

# 6. Map combinational logic using ABC
abc -liberty $::env(LIB_SYNTH) -script $::env(ABC_SCRIPT)

# 7. Clean netlist and export structural Verilog
splitnets -ports
opt_clean -purge
write_verilog -noattr -noexpr -nohex -nodec $::env(SAVE_NETLIST)

The table below correlates each script command to its synthesis function:

Script Command Operation Synthesis Phase
read_liberty Loads the PDK Liberty (.lib) timing model Target library specification
read_verilog Parses Verilog source code into an internal AST HDL parsing
hierarchy -check -top Validates module ports and parameters Elaboration
synth -top Performs technology-independent logic optimization Generic logic optimization
dfflibmap Maps sequential registers to target PDK flip-flops Sequential mapping
abc -liberty ... -script ... Maps combinational networks to PDK logic gates Combinational technology mapping
write_verilog Exports the mapped structural gate netlist Netlist generation

OpenLane maps sequential registers and combinational gates separately. Flip-flops require setup and hold timing verification relative to clock pins. Combinational gates require input-to-output propagation delay modeling.

Controlling Mapping with ABC Scripts

The abc command specifies -script $::env(ABC_SCRIPT). This parameter points to an ABC command file that guides technology mapping. The script determines whether the mapper optimizes for minimum silicon area or minimum critical path delay. Section 2.2 examines this trade-off through SYNTH_STRATEGY.

OpenLane preserves all scripts, log files, and intermediate netlists in runs/<tag>/tmp/synthesis/. When synthesis yields unexpected results, inspect these files to determine the root cause.

Practice Exercise

An engineer reviews runs/<tag>/tmp/synthesis/ and discovers the following warning:

ABC: WARNING: (unmapped) ... hardcode

Which command produced this warning, and what does the message indicate?

Solution

Command 6 (abc -liberty ... -script ...) produced the warning during combinational technology mapping.

The message indicates that ABC could not match a generic logic pattern to any valid standard cell in the Liberty file. ABC left the node unmapped or marked as a blackbox. Engineers must inspect the source RTL to verify whether unsupported operators or missing library definitions caused the failure.

The next article examines the SYNTH_STRATEGY configuration setting and analyzes the trade-off between silicon area and propagation delay.

← Generic Cells Versus Standard Cells SYNTH_STRATEGY: Area Versus Delay →