A Multiplier is a electronic circuit used in computers for multiplication of two numbers.
let us see how multiplication actually works.
as we can see in the above example that we are performing logical AND operation and addition of the partial products..... for which in digital electronics we have adder circuits such as Half adder and Full adder.
let us see how multiplication actually works.
Write the multiplication down and you'll know what to do. For example A1A2A3*B1B2B3
A1 A2 A3
x B1 B2 B3
-------------------------
B3A1 B3A2 B3A3
+ B2A1 B2A2 B2A3
B1A1 B1A2 B1A3
---------------------------------as we can see in the above example that we are performing logical AND operation and addition of the partial products..... for which in digital electronics we have adder circuits such as Half adder and Full adder.
Verilog Code for the 3-Bit Multiplier is as follow:
module halfadder(sum,carry,a,b);
input a,b;
output sum,carry;
xor(sum,a,b);
and(carry,a,b);
endmodule
module halfadder(sum,carry,a,b);
input a,b;
output sum,carry;
xor(sum,a,b);
and(carry,a,b);
endmodule
module multiply3bits(product,a,b);
input [2:0]a, b;
output [5:0] product;
wire s1,c1,s2,c2,s3,c3;
assign product[0]= (a[0] & b[0]);
halfadder ha1 (s1,c1,(a[1] & b[0]),(a[0] & b[1]));
fulladder fa1 ((a[2] & b[0]),(a[1] & b[1]),c1,s2,c2);
halfadder ha2 (s3,c3,(a[2] & b[1]),c2);
assign product[1]=s1;
halfadder ha3 (s4,c4,s2,(a[0] & b[2]));
fulladder fa2 (s3,(a[1] & b[2]),c4,s5,c5);
halfadder ha4 (s6,c6,c5,(a[2] & b[2]));
assign product[2]=s4;
assign product[3]=s5;
assign product[4]=s6;
assign product[5]=c4;
endmodule