Verilog Code for 2 bit Binary Multiplier

2 bit Binary Multiplier:

We have to implement  binary multiplier, so we take 2-bit input as a and b. output is taken as a 4-bit reg p.  
Now, whenever we give value of a and b, it produces the output as the multiplication of a and b always. Whenever  the assign statements are satisfied, the output is produced.

Verilog Code for 2 bit Binary Multiplier:

module multiplier_2bit_binary(a,b,p); 
output [3:0]p; 
input [1:0]a,b; 
assign p[0]= (b[0]*a[0]); 
assign p[1]= ((a[0]*b[1])^(a[1]*b[0])); 
assign p[2]= ((a[1]*b[1])^(a[0]*b[1])^(a[1]*b[0])); 
assign p[3]= ((a[1]*b[1])&(a[0]*b[1])&(a[1]*b[0])); 
endmodule

OUTPUT:


Post a Comment

0 Comments