2 Authors : Vinod.G, Renuka Venkat
3 Email : g.vinod1993@gmail.com
4 Last Update : 27th November 2017
5 See License for More Details
7 This module examines the floating point input and outputs the class of floating point number. The corresponding bit of the output register is set according to the class of instructions given by the table below,
10 1 Negative Normal Number
11 2 Negative Subnormal Number
14 5 Positive Subnormal Number
15 6 Positive Normal Number
20 The module examines and finds the class as follows
21 Sign Exponent (e) Fraction (f) Value
24 0 00⋯00 00⋯01 Positive Denormalized Real
28 0 00⋯01 XX⋯XX Positive Normalized Real
43 1 00⋯00 00⋯01 Negative Denormalized Real
47 1 00⋯01 XX⋯XX Negative Normalized Real
64 import defined_types::*;
65 `include "defined_parameters.bsv"
67 interface Ifc_fpu_fclass#(numeric type fpinp, numeric type fpman, numeric type fpexp);
68 method ActionValue#(Floating_output#(fpinp)) _start(Bit#(1) sign1,Bit#(fpman)mantissa,Bit#(fpexp)exponent, Bit#(5) flags);
71 `ifdef fpu_hierarchical
72 interface Ifc_fpu_fclass32;
73 method ActionValue#(Floating_output#(32)) _start(Bit#(1) sign1,Bit#(23)mantissa,Bit#(8)exponent, Bit#(5) flags);
76 interface Ifc_fpu_fclass64;
77 method ActionValue#(Floating_output#(64)) _start(Bit#(1) sign1,Bit#(52)mantissa,Bit#(11)exponent, Bit#(5) flags);
81 module mkfpu_fclass(Ifc_fpu_fclass#(fpinp,fpman,fpexp))
83 Add#(TAdd#(fpexp,fpman),1,fpinp), //Defining fpinp to be fpexp + fpman + 1
88 let fPINP = valueOf(fpinp);
89 let fPMAN = valueOf(fpman);
90 let fPEXP = valueOf(fpexp);
92 method ActionValue#(Floating_output#(fpinp)) _start(Bit#(1) sign1,Bit#(fpman)mantissa,Bit#(fpexp)exponent, Bit#(5) flags);
94 Bit#(10) result_fclass;
95 Bool sbit = (sign1==1);
96 Bool inf = (flags[1]==1);
97 Bool normal = (flags == '0);
98 Bool subnormal = (flags[4] == 1);
99 Bool zero = (flags[3] == 1);
100 if(sbit && inf) //negtive infinity
105 else if(sbit && normal) //negative normal
110 else if(sbit && subnormal) //negative subnormal
115 else if(sbit && zero) //-0
120 else if(!sbit && zero) // +0
122 result_fclass = 'd16;
125 else if( !sbit && subnormal) //positive subnormal
127 result_fclass = 'd32;
130 else if(!sbit && normal) //positive normal
132 result_fclass = 'd64;
135 else if(!sbit && inf) //positive infinity
137 result_fclass = 'd128;
140 else if (flags[0]==1) //Signaling NaN
142 result_fclass = 'd256;
147 result_fclass = 'd512;
152 return Floating_output {
153 final_result : zeroExtend(result_fclass),
158 `ifdef fpu_hierarchical
160 module mkfpu_fclass32(Ifc_fpu_fclass32);
161 Ifc_fpu_fclass#(32,23,8) uut <- mkfpu_fclass();
162 method ActionValue#(Floating_output#(32)) _start(Bit#(1) sign1,Bit#(23)mantissa,Bit#(8)exponent, Bit#(5) flags);
163 let x <- uut._start(sign1,mantissa,exponent,flags);
169 module mkfpu_fclass64(Ifc_fpu_fclass64);
170 Ifc_fpu_fclass#(64,52,11) uut <- mkfpu_fclass();
171 method ActionValue#(Floating_output#(64)) _start(Bit#(1) sign1,Bit#(52)mantissa,Bit#(11)exponent, Bit#(5) flags);
172 let x <- uut._start(sign1,mantissa,exponent,flags);
179 // module mkTb_fpu_fclass();
180 // Ifc_fpu_fclass#(32,23,8) inst_fpu_fclass <- mkfpu_fclass();
181 // Reg#(Bit#(32)) rg_clock <- mkReg(0);
182 // Reg#(Bit#(32)) rg_operand1<-mkReg('h7f8ff000); //positive normal set 6
184 // rule get_input(rg_clock == 0);
185 // inst_fpu_fclass._start(rg_operand1);
186 // rg_clock <= rg_clock + 1;
190 // let lv_result = inst_fpu_fclass.result_();
191 // `ifdef verbose $display("Result is: %h",lv_result.final_result); `endif