`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    11:41:18 01/25/2020 
// Design Name: 
// Module Name:    FP_adder 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module FP_mul(ctrl,a,b,y
    );
input [15:0] a,b;
output [15:0] y;
input ctrl;
wire [4:0] t1,t2;
wire [3:0] E,t8,t9;
wire [10:0] M;
wire [11:0] t3,t4,t6,t7,t11,t12,t20; 
wire [23:0] t5;
wire [3:0] zcnt,zcnt1;
wire bo,bo1,bo2,bo3;

adsub5 ad1(1'b0,{1'b0,a[14:11]},{1'b0,b[14:11]},t1,bo);
adsub5 ad2(1'b1,t1,5'b00111,t2,bo);
assign t3 = {1'b1,a[10:0]};
assign t4 = {1'b1,b[10:0]};

assign t5 = t3 * t4;
mux11 mx2(t5[21:11],t5[22:12],t5[23],M);
assign s = (a[15] ^ b[15]);
mux4 mx4(4'b0000,4'b0001,t5[23],t8);
adsub4 ad4(1'b0,t2[3:0],t8,E,bo3);
assign y = {s,E,M};
endmodule

module mux11(A,B,S,Y);

input [10:0] A,B;
    
output [10:0] Y;
    
input S;
assign Y = (S)? B : A;
endmodule

module mux4(A,B,S,Y);

input [3:0] A,B;
    
output [3:0] Y;
    input S;
assign Y = (S)? B : A;
endmodule


module adsub4 (sel,c,a,p,bo);
  
input sel;
  input [3:0] a,c;
  
output [3:0] p;
output bo;

assign {bo,p} = (sel)?(c-a):(c+a);

endmodule

module adsub5 (sel,c,a,p,bo);
  
input sel;
  
input [4:0] a,c;
  
output [4:0] p;
output bo;

assign {bo,p} = (sel)?(c-a):(c+a);

endmodule



