Module 2: Logic Synthesis · 2.1 From RTL to Gates

RTL Style and Its Physical Consequences

The previous article demonstrated that a Boolean function has multiple gate mappings. This article demonstrates how RTL coding style determines gate netlist structure.

Two Verilog implementations can produce identical testbench results while creating completely different physical circuits. RTL coding choices dictate logic tree depth, routing congestion, and timing slack long before floorplanning begins.

Structural Differences in Multiplexer Descriptions

Consider two implementations of a 4-to-1 multiplexer.

Implementation A uses an if-else priority chain:

always @(*) begin
    if (sel == 2'b00)      y = in0;
    else if (sel == 2'b01) y = in1;
    else if (sel == 2'b10) y = in2;
    else                   y = in3;
end

Implementation B uses a case statement:

always @(*) begin
    case (sel)
        2'b00: y = in0;
        2'b01: y = in1;
        2'b10: y = in2;
        default: y = in3;
    endcase
end

When inputs are mutually exclusive, advanced synthesis tools attempt to balance both descriptions. However, complex condition trees preserve the coded structure. An if-else chain models priority logic and synthesizes into a cascaded chain of multiplexers. A complete case statement models parallel selection and synthesizes into a balanced tree.

A balanced two-level mux tree versus a three-level priority chain for the same 4:1 mux
Figure 1: Same function, different depth

A cascaded chain introduces greater logic depth and increases propagation delay along the critical path. A balanced tree reduces logic depth, which improves timing slack while distributing cells evenly across placement rows.

Arithmetic Resource Sharing

Arithmetic operations consume significant silicon area. Consider conditional addition written two ways:

// Implementation A: Two dedicated adders
assign sum_a = x + y;
assign sum_b = x + z;
assign result = sel ? sum_a : sum_b;
// Implementation B: One shared adder with multiplexed inputs
assign result = x + (sel ? y : z);

Implementation A describes two separate adder blocks whose outputs feed a multiplexer. Implementation B describes one adder fed by an input multiplexer. Both expressions produce identical arithmetic outputs.

Implementation A forces the synthesis tool to instantiate two complete adders unless aggressive area optimization unifies them. Implementation B guarantees resource sharing by design.

Synthesis Metric Comparison

Synthesizing both adder designs with Yosys demonstrates the physical consequences:

Implementation Adder Count Approximate Gate Count Logic Levels
A (Two adders, multiplexed output) 2 34 5
B (One adder, multiplexed input) 1 19 5

Implementation B reduces standard cell count by nearly 45 percent while maintaining identical logic levels.

Unintended duplication of arithmetic blocks inflates cell counts and worsens placement density. Designers must structure RTL to share expensive datapath operators.

Practice Exercise

An engineer writes three parallel comparator statements:

assign gt_a = (x > y);
assign gt_b = (x > z);
assign gt_c = (y > z);

Can these three statements share a single hardware comparator block? Explain why or why not.

Solution

No. The three comparisons cannot share a single comparator block.

Hardware resource sharing requires mutually exclusive execution paths controlled by multiplexer conditions. In this design, all three outputs (gt_a, gt_b, and gt_c) evaluate simultaneously. The circuit must instantiate three independent comparators to compute all three outputs concurrently.

The next article examines Yosys internal generic cells and explains why synthesis optimizes generic networks before mapping standard cells.

← Technology Mapping Generic Cells Versus Standard Cells →