Module 8: RTL Coding for Quality & Synthesis · 8.2 Synthesis-Aware Coding

Resource Sharing

In behavioral Verilog, counting arithmetic operators does not predict physical silicon gate counts. Consider two additions within conditional branches:

always @(*) begin
    if (mode)
        result = a + b;
    else
        result = c + d;
end

The conditions are mutually exclusive. The circuit never computes both additions simultaneously. Synthesis tools can infer two separate adders followed by an output multiplexer. Alternatively, the compiler can infer a single adder preceded by input multiplexers. This automated compiler optimization is resource sharing.

Mechanics of Resource Sharing

Arithmetic circuits (such as multipliers and wide adders) consume significant silicon area. Instantiating parallel arithmetic blocks when only one operates per clock cycle wastes hardware area.

Resource sharing repositions multiplexers from the output of the arithmetic blocks to their inputs:

Two adders with an output mux versus one shared adder with input muxes
Figure 1: Resource sharing moves the mux from after the adder to before it

Input multiplexers select operand pairs (a, b) or (c, d) before entering the single shared adder. This transformation eliminates one adder, reducing silicon area.

The Area-Versus-Timing Trade-Off

Resource sharing introduces a direct trade-off between silicon area and propagation delay:

Hardware Architecture Silicon Area Metric Critical Path Timing Characteristics
Unshared (Two parallel adders) Higher: Requires two full adder circuits. Lower Delay: Path delay equals adder computation time alone.
Shared (One adder with input multiplexers) Lower: Consumes one adder plus input multiplexers. Higher Delay: Input multiplexer delay adds directly to adder path delay.

In the shared configuration, addition cannot start until input multiplexers resolve their inputs. If the addition path belongs to a critical timing path, the additional multiplexer delay causes setup timing violations.

Controlling and Preventing Resource Sharing

Synthesis compilers evaluate timing constraints before applying resource sharing. When aggressive clock constraints require minimum propagation delay, compilers disable sharing automatically.

If a shared unit causes timing violations, engineers can enforce unshared hardware by instantiating explicit submodules:

// Explicit submodule instantiation prevents automated resource sharing
adder u_adder_mode1 (.a(a), .b(b), .sum(sum1));
adder u_adder_mode0 (.a(c), .b(d), .sum(sum2));
assign result = mode ? sum1 : sum2;

Instantiating separate modules eliminates optimization ambiguity. The synthesis compiler preserves two independent adders, eliminating input multiplexer delay from the critical path.

Verification Exercise

An arithmetic block contains two 32-bit multipliers in mutually exclusive branches of a case statement. One branch belongs to the design’s critical path. Evaluate the engineering trade-offs of allowing automated resource sharing versus instantiating separate multipliers.

View Solution

Sharing one 32-bit multiplier saves substantial silicon area because multipliers require extensive gate networks. However, resource sharing inserts input multiplexers ahead of the multiplier inputs. Multipliers already exhibit long combinational propagation delays. Adding multiplexer delay to an existing critical path worsens negative timing slack. To achieve timing closure, engineers must prevent sharing by instantiating two distinct multiplier modules. Paying the silicon area penalty preserves timing margin.

Resource sharing saves area by inserting input multiplexers ahead of shared arithmetic units. The next article explains how to write RTL that guides synthesis compilers effectively.

← What Synthesis Does With Your RTL Guiding Synthesis Without Fighting It →