`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 02/13/2016 08:25:37 PM
// Design Name: 
// Module Name: Multiplier
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module Multiplier(
  input [3:0] A,
  input [3:0] B,
  output [7:0] R
  );

  wire P00, P01, P02, P03, P10, P11, P12, P13, P20, P21, P22, P23, P30, P31, P32, P33;
  assign P00 = A[0] & B[0];
  assign P01 = A[1] & B[0];
  assign P02 = A[2] & B[0];
  assign P03 = A[3] & B[0];

  assign P10 = A[0] & B[1];
  assign P11 = A[1] & B[1];
  assign P12 = A[2] & B[1];
  assign P13 = A[3] & B[1];

  assign P20 = A[0] & B[2];
  assign P21 = A[1] & B[2];
  assign P22 = A[2] & B[2];
  assign P23 = A[3] & B[2];

  assign P30 = A[0] & B[3];
  assign P31 = A[1] & B[3];
  assign P32 = A[2] & B[3];
  assign P33 = A[3] & B[3];

  wire [3:0] Part1_2;
  wire [3:0] Part2_3;
  wire Cout1_2, Cout2_3;

FullAdder Part1 (
  .A({1'b0, P03, P02, P01}),
  .B({P13, P12, P11, P10}),
  .Operation(1'b0),
  .S(Part1_2),
  .Cout(Cout1_2)
  );

FullAdder Part2 (
  .A({P23, P22, P21, P20}),
  .B({Cout1_2, Part1_2[3:1]}),
  .Operation(1'b0),
  .S(Part2_3),
  .Cout(Cout2_3)
  );
wire [3:0] temp;

FullAdder Part3 (
  .A({P33, P32, P31, P30}),
  .B({Cout2_3, Part2_3[3:1]}),
  .Operation(1'b0),
  .S(temp ),
  .Cout(R[7])
  );
    assign R[6:3] = temp;
    assign R[0] = P00;
    assign R[1] = Part1_2[0];
    assign R[2] = Part2_3[0];


endmodule
