Module 7: Advanced RTL Design Techniques · 7.2 Arithmetic Circuits in RTL

Pipelining a Multiplier

Hardware multipliers contain long combinational critical paths. Module 2 showed that an $N \times N$ array multiplier has an $O(N)$ propagation delay. Even Wallace tree reduction networks require $O(\log N)$ carry-save adder stages followed by a carry-propagate adder. At 32-bit and 64-bit operand widths, multiplier propagation delays frequently violate single-cycle clock timing requirements. Pipelining is necessary to achieve high clock frequencies.

Identifying Optimal Pipeline Cut Boundaries

Placing registers only at the primary inputs and outputs does not shorten the internal critical path. The multiplier array remains a monolithic combinational block between register boundaries. The pipeline cut must segment the internal logic structure.

For a tree multiplier, the natural partition boundary occurs between the carry-save reduction tree and the final vector adder. The tree reduces all partial products into two multi-bit vectors: a sum row and a carry row. Registering these two rows forms the pipeline stage boundary:

Cut after the reduction tree, before the final adder
Figure 1: Cutting a multiplier between the reduction tree and the final adder

In behavioral RTL models, designers can partition operand b into lower and upper halves. The product $a \times b$ equals $(a \times b_{\text{lower}}) + ((a \times b_{\text{upper}}) \ll (N/2))$. Stage 1 computes the partial products, and Stage 2 sums the shifted terms.

Implementing a Two-Stage Pipelined Multiplier

The following module implements a 2-stage pipelined multiplier with a synchronized valid control flag:

`timescale 1ns / 1ps
`default_nettype none

module pipelined_mult #(parameter WIDTH = 16) (
    input  wire                      clk,
    input  wire [WIDTH-1:0]          a, b,
    input  wire                      valid_in,
    output reg  [2*WIDTH-1:0]        product,
    output reg                       valid_out
);
    localparam H = WIDTH / 2;

    // Stage 1 registers: capture partial products and valid control signal
    reg [2*WIDTH-1:0] pp_lo, pp_hi;
    reg               valid_s1;

    always @(posedge clk) begin
        pp_lo    <= a * b[H-1:0];                 // Multiply lower half of b
        pp_hi    <= (a * b[WIDTH-1:H]) << H;      // Multiply and shift upper half of b
        valid_s1 <= valid_in;
    end

    // Stage 2 registers: execute final carry-propagate addition
    always @(posedge clk) begin
        product   <= pp_lo + pp_hi;
        valid_out <= valid_s1;
    end
endmodule

Propagating Transaction Valid Flags

Digital datapaths rarely process valid data on every clock cycle. Control pipelines introduce stalls, bubbles, and idle cycles. The valid_in signal must propagate through pipeline registers alongside arithmetic data. Downstream circuits inspect valid_out to distinguish valid calculation outputs from uninitialized register states.

Testbench Verification

module tb_pipelined_mult;
    parameter WIDTH = 8;
    reg clk = 0, valid_in;
    reg [WIDTH-1:0] a, b;
    wire [2*WIDTH-1:0] product;
    wire valid_out;

    pipelined_mult #(.WIDTH(WIDTH)) dut (
        .clk(clk), .a(a), .b(b), .valid_in(valid_in),
        .product(product), .valid_out(valid_out)
    );

    always #5 clk = ~clk;

    initial begin
        $dumpfile("tb.vcd");
        $dumpvars(0, tb_pipelined_mult);

        valid_in = 0; a = 0; b = 0;
        @(negedge clk);

        // Apply stimulus: 13 * 11 = 143
        a = 8'd13; b = 8'd11; valid_in = 1;
        @(negedge clk);   // Clock cycle 1: partial products captured
        valid_in = 0;
        @(negedge clk);   // Clock cycle 2: final product available

        if (product == 16'd143 && valid_out == 1'b1)
            $display("PASS: product=%0d arrived on cycle 2 with valid_out asserted", product);
        else
            $display("FAIL: product=%0d valid_out=%b (expected 143, 1)", product, valid_out);

        $finish;
    end
endmodule

The testbench confirms both mathematical correctness and cycle latency. The output data must arrive exactly two clock cycles after input assertions, accompanied by valid_out = 1'b1.

FPGA architectures contain dedicated DSP slices (such as Xilinx DSP48 or Intel DSP blocks). These hardware blocks include integrated pipeline registers at reduction and adder stages. Synthesis tools infer these hard DSP primitives automatically from registered RTL multiplication code.

Verification Exercise

Extend the multiplier architecture to a 3-stage pipeline. Apply the split-adder technique from the previous article to the final addition stage. Ensure the valid control flag propagates across all three pipeline stages.

View Solution
module pipelined_mult_3stage #(parameter WIDTH = 16) (
    input  wire               clk,
    input  wire [WIDTH-1:0]   a, b,
    input  wire               valid_in,
    output reg  [2*WIDTH-1:0] product,
    output reg                valid_out
);
    localparam H = WIDTH / 2;
    reg [2*WIDTH-1:0] pp_lo, pp_hi;
    reg               valid_s1;

    // Stage 1: partial product calculation
    always @(posedge clk) begin
        pp_lo    <= a * b[H-1:0];
        pp_hi    <= (a * b[WIDTH-1:H]) << H;
        valid_s1 <= valid_in;
    end

    // Stage 2: lower half of final adder with carry capture
    reg [WIDTH-1:0]       sum_lo;
    reg                   carry_mid;
    reg [2*WIDTH-1:WIDTH] pp_lo_hi, pp_hi_hi;
    reg                   valid_s2;

    always @(posedge clk) begin
        {carry_mid, sum_lo} <= pp_lo[WIDTH-1:0] + pp_hi[WIDTH-1:0];
        pp_lo_hi <= pp_lo[2*WIDTH-1:WIDTH];
        pp_hi_hi <= pp_hi[2*WIDTH-1:WIDTH];
        valid_s2 <= valid_s1;
    end

    // Stage 3: upper half of final adder using registered carry
    always @(posedge clk) begin
        product[WIDTH-1:0]       <= sum_lo;
        product[2*WIDTH-1:WIDTH] <= pp_lo_hi + pp_hi_hi + carry_mid;
        valid_out <= valid_s2;
    end
endmodule

The valid signal traverses three sequential registers: valid_s1, valid_s2, and valid_out. The final product becomes valid exactly three clock cycles after input assertion.

Pipelining multipliers cuts critical paths and enables high-frequency processing. This completes Section 7.2. Section 7.3 formalizes pipeline flow control, throughput versus latency trade-offs, and stall handling.

← Pipelining a Wide Adder Balancing an N-Stage Pipeline →