`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    18:31:02 01/28/2020 
// Design Name: 
// Module Name:    FP_comp 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module FP_comp(a,b,lt,eq,gt);

input [15:0] a,b;
output lt,eq,gt;
wire lt1,lt2,gt1,gt2,eq1,eq2;

comp4 cmp2(a[14:11],b[14:11],lt2,gt2,eq2);
comp11 cmp1(a[10:0],b[10:0],lt1,gt1,eq1);

assign eq0 = ~(a[15] ^ b[15]);
assign lt0 = a[15] & ~b[15];
assign gt0 = ~a[15] & b[15];
assign eq = eq1 & eq2 & eq0;
assign gt = gt0 | (eq0 & gt2) | (eq0 & eq2 & gt1);
assign lt = lt0 | (eq0 & lt2) | (eq0 & eq2 & lt1);
endmodule

module comp11(a,b,lt1,gt1,eq1);
input [10:0] a,b;
output reg lt1,eq1,gt1;
always @(a or b)
begin
lt1=0; eq1=0; gt1=0;
if(a==b)
eq1=1;
else if (a>b)
gt1=1;
else
lt1=1;
end
endmodule

module comp4(a,b,lt1,gt1,eq1);
input [3:0] a,b;
output reg lt1,eq1,gt1;
always @(a or b)
begin
lt1=0; eq1=0; gt1=0;
if(a==b)
eq1=1;
else if (a>b)
gt1=1;
else
lt1=1;
end

endmodule