Skip to content

This repo includes all the files related to the design of a 32-bit multiplier invigorated with the Karatsuba Algorithm on Hardware Description Language SystemVerilog.

Notifications You must be signed in to change notification settings

akarxxx1030/pes_karatsuba_multiplier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Karatsuba Algorithm for Multiplication

The Karatsuba algorithm is a fast multiplication algorithm that reduces the multiplication of two large numbers to a smaller number of single-digit multiplications, effectively improving the computational complexity of the multiplication operation. It was developed by Anatolii Alexeevitch Karatsuba in 1960 and is based on the principle of divide-and-conquer.

Algorithm Overview

The fundamental idea behind Karatsuba multiplication is to break down the multiplication of large numbers into smaller multiplications by splitting the numbers into smaller parts, using recursion to perform the necessary multiplications efficiently, and combining the results.

The algorithm follows these steps:

  1. Given two large numbers, split each into two parts of equal size.
  2. Recursively compute three multiplications of these smaller parts.
  3. Combine the results using addition and subtraction to obtain the final product.

Implementation in Pseudocode

function karatsuba_multiply(x, y):
    if x < 10 or y < 10:
        return x * y
    
    n = max(length(x), length(y))
    n_2 = n // 2
    
    # Splitting the numbers into parts
    a, b = split_number(x, n_2)
    c, d = split_number(y, n_2)
    
    # Recursive steps
    ac = karatsuba_multiply(a, c)
    bd = karatsuba_multiply(b, d)
    ad_bc = karatsuba_multiply(a + b, c + d) - ac - bd
    
    # Combining results
    return (10**(2*n_2) * ac) + (10**n_2 * ad_bc) + bd

OpenLANE Flow for Karatsuba Multiplier

This guide outlines the steps to implement a Karatsuba multiplier using the OpenLANE flow.

Step 1: RTL Design

1 2
%%writefile spm.v
module spm #(
parameter wI = 64,
parameter wO = 2 * wI
)
(
input   logic   [wI-1:0]    iX,
input   logic   [wI-1:0]    iY,
output  logic   [wO-1:0]    oO
);

localparam wI_pt = wI / 2;

logic   [wI_pt-1:0] X_hi, X_lo;
logic   [wI_pt-1:0] Y_hi, Y_lo;

assign  {X_hi, X_lo} = iX;
assign  {Y_hi, Y_lo} = iY;

logic   [wI_pt*2-1:0]   p;
logic   [wI_pt*2-1:0]   q;
logic   [wI_pt:0]       r;
logic   [wI_pt:0]       s;
assign  p = X_hi * Y_hi;
assign  q = X_lo * Y_lo;
assign  r = X_hi + X_lo;
assign  s = Y_hi + Y_lo;

logic   [wI_pt*2:0]     u;
assign  u = p + q;

logic   [wI+1:0]        t;
logic   r_hi, s_hi;
logic   [wI_pt-1:0]     r_lo, s_lo;

assign  {r_hi, r_lo} = r;
assign  {s_hi, s_lo} = s;

logic   [wI-1:0]        t_s;

assign t_s = r_lo * s_lo;
assign t = ((r_hi & s_hi) << wI) + ((r_hi * s_lo + s_hi * r_lo) << wI_pt) + t_s;

assign oO = (p << wI) + ((t - u) << wI_pt) + q;

endmodule

Description:

  • Start with the Register Transfer Level (RTL) design of the Karatsuba multiplier.
  • Implement the multiplication logic using the Karatsuba algorithm.
Config

Step 2: Synthesis

Description:

  • Synthesize the RTL design to generate a gate-level netlist.
  • Optimize the design for area, power, and timing.
yos 1 yos 2 yos 3 yos 4 yos 5 yos 6

Step 3: Floorplanning

Description:

  • Define the floorplan for the chip and place mac ros.
  • Allocate space for the Karatsuba multiplier and other necessary components.

Screenshots:

floorplan GlobalPlacement

Step 4: Placement and Routing

Description:

  • Place the synthesized netlist components onto the chip floorplan.
  • Route interconnections between the components.

Screenshots:

detailedplacement

Step 5: Physical Verification

Description:

  • Perform Design Rule Checking (DRC) and Layout versus Schematic (LVS) checks.

  • Ensure the design meets physical constraints and is electrically correct.

    DetailedRouting
DetailedRouting2 floorplan dpl cts1 ## Step 6: GDSII Generation

Description:

  • Generate the GDSII file, the final layout representation in a standard format.

Screenshots:

gds

About

This repo includes all the files related to the design of a 32-bit multiplier invigorated with the Karatsuba Algorithm on Hardware Description Language SystemVerilog.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published