3-bit Multiplier Verilog Code -

// Half adder for LSB assign product[0] = pp0[0];

// Instantiate behavioral multiplier (change as needed) multiplier_3bit_behavioral uut ( .a(a), .b(b), .product(product) );

full_adder fa3 ( .a(s2), .b(pp2[1]), .cin(c3), .sum(s3), .cout(c5) ); 3-bit multiplier verilog code

// Generate partial products (AND gates) assign pp0 = a[2] & b[0], a[1] & b[0], a[0] & b[0]; assign pp1 = a[2] & b[1], a[1] & b[1], a[0] & b[1]; assign pp2 = a[2] & b[2], a[1] & b[2], a[0] & b[2];

// Helper modules module half_adder ( input a, b, output sum, carry ); assign sum = a ^ b; assign carry = a & b; endmodule // Half adder for LSB assign product[0] =

// Stage 3 full_adder fa2 ( .a(s1), .b(pp1[2]), .cin(c2), .sum(product[2]), .cout(c4) );

module multiplier_3bit_behavioral ( input [2:0] a, // 3-bit multiplicand input [2:0] b, // 3-bit multiplier output [5:0] product // 6-bit product ); assign product = a * b; endmodule 2. Structural Style (using full adders and half adders) This implements the array multiplier architecture. full_adder fa3 ( .a(s2)

module multiplier_3bit_structural ( input [2:0] a, input [2:0] b, output [5:0] product ); wire [2:0] pp0, pp1, pp2; // partial products wire c1, c2, c3, c4, c5, c6; wire s1, s2, s3, s4;