8bit Multiplier Verilog Code Github Access

Best for low-area designs where speed is not critical. The multiplication takes 8 clock cycles.

module sequential_multiplier_8bit (
    input clk, rst, start,
    input [7:0] a, b,
    output reg [15:0] product,
    output reg done
);
    reg [2:0] count;
    reg [7:0] multiplicand, multiplier;
    reg [15:0] acc;
always @(posedge clk or posedge rst) begin
    if (rst) begin
        count <= 0;
        done <= 0;
        product <= 0;
        acc <= 0;
    end else if (start) begin
        count <= 0;
        multiplicand <= a;
        multiplier <= b;
        acc <= 0;
        done <= 0;
    end else if (!done && count < 8) begin
        if (multiplier[0])
            acc <= acc + 8'b0, multiplicand;
        multiplicand <= multiplicand << 1;
        multiplier <= multiplier >> 1;
        count <= count + 1;
    end else if (count == 8 && !done) begin
        product <= acc;
        done <= 1;
    end
end

endmodule

GitHub popularity: High — this is the most common "learning multiplier" on repositories. Look for tags like sequential, FSM, shift-add.


all: compile run view

compile: $(SIMULATOR) -o $(OUTPUT) $(SOURCES) 8bit multiplier verilog code github

run: vvp $(OUTPUT)

view: $(VIEWER) $(VCD_FILE)

clean: rm -f $(OUTPUT) $(VCD_FILE)

sim: compile run

.PHONY: all compile run view clean sim

module top_multiplier #(
    parameter ARCH_TYPE = "ARRAY"  // "ARRAY", "CARRY_SAVE", "WALLACE"
)(
    input  wire        clk,
    input  wire        rst_n,
    input  wire [7:0]  A,
    input  wire [7:0]  B,
    input  wire        start,
    output reg [15:0]  P,
    output reg         done
);
wire [15:0] product;
generate
    if (ARCH_TYPE == "ARRAY") begin
        multiplier_array u_mult (
            .A(A), .B(B), .P(product)
        );
    end else if (ARCH_TYPE == "CARRY_SAVE") begin
        multiplier_carry_save u_mult (
            .A(A), .B(B), .P(product)
        );
    end else begin
        multiplier_wallace u_mult (
            .A(A), .B(B), .P(product)
        );
    end
endgenerate
// Pipeline register for product output
always @(posedge clk or negedge rst_n) begin
    if (!rst_n) begin
        P <= 16'b0;
        done <= 1'b0;
    end else if (start) begin
        P <= product;
        done <= 1'b1;
    end else begin
        done <= 1'b0;
    end
end

endmodule

Scene: A cramped electronics lab, 11:47 PM. Pizza boxes double as coasters.

Maya, a 22-year-old FPGA design intern, stares at her waveform viewer. Her task: implement a high-speed 8-bit multiplier in Verilog for a real-time audio effects processor. The lead architect, Dr. Rhinehart, has given her 48 hours.

Her naive for-loop multiplier works, but it uses 64 clock cycles per multiply—too slow. Her carry-save array multiplier? Saves cycles but fails timing at 200 MHz. The synthesis log reads: Best for low-area designs where speed is not critical

Warning: 8x8 multiplier path violates timing (-2.34 ns slack)

She needs a pipelined, radix-4 Booth-encoded Wallace tree. The kind of code that takes weeks to perfect.

She opens her browser. Types: 8bit multiplier verilog code github


initial begin
    #10 rst_n = 0; #5 rst_n = 1;
    multiplicand = 8'b00001111; // 15
    multiplier  = 8'b00001010; // 10
    start = 1; #10 start = 0;
    #200;
    if (product == 150) $display("Test passed!");
    else $display("Test failed: %d", product);
end

An 8-bit multiplier takes two 8-bit inputs (A and B) and produces a 16-bit product. Why is this size special?


Uses a single adder and shifts over multiple clock cycles. Ideal for resource-constrained FPGAs.

Pros: Extremely low area (one adder plus registers).
Cons: Requires 8 clock cycles to produce a result. endmodule