diff --git a/config/shared/config-shared.vh b/config/shared/config-shared.vh index 6763f583c..481247eae 100644 --- a/config/shared/config-shared.vh +++ b/config/shared/config-shared.vh @@ -1,3 +1,6 @@ +//max function +`define max(a,b) (((a) > (b)) ? (a) : (b)) + // constants defining different privilege modes // defined in Table 1.1 of the privileged spec localparam M_MODE = (2'b11); @@ -107,12 +110,13 @@ localparam DURLEN = $clog2(FPDUR); // enough bi localparam DIVBLEN = $clog2(DIVb+1); // enough bits to count number of fractional bits + 1 integer bit // largest length in IEU/FPU -localparam CVTLEN = ((NF(DIVb + 1 +NF+1) & (CVTLEN+NF+1)>(3*NF+6)) ? (CVTLEN+NF+1) : ((DIVb + 1 +NF+1) > (3*NF+6) ? (DIVb + 1 +NF+1) : (3*NF+6))); // max(CVTLEN+NF+1, DIVb + 1 + NF + 1, 3*NF+6) +localparam NORMSHIFTSZ = `max(`max((CVTLEN+NF+1), (DIVb + 1 + NF + 1)), (3*NF+6)); localparam LOGNORMSHIFTSZ = ($clog2(NORMSHIFTSZ)); -localparam CORRSHIFTSZ = (NORMSHIFTSZ-2 > (DIVMINb + 1 + NF)) ? NORMSHIFTSZ-2 : (DIVMINb+1+NF); // max(NORMSHIFTSZ-2, DIVMINb + 1 + NF) +localparam CORRSHIFTSZ = `max((NORMSHIFTSZ-2), (DIVMINb + 1 + NF)); // Disable spurious Verilator warnings diff --git a/src/fpu/postproc/specialcase.sv b/src/fpu/postproc/specialcase.sv index e3a1466fe..e9ba573e1 100644 --- a/src/fpu/postproc/specialcase.sv +++ b/src/fpu/postproc/specialcase.sv @@ -305,7 +305,7 @@ module specialcase import cvw::*; #(parameter cvw_t P) ( // signed | 2^31-1 | 2^63-1 | // unsigned | 2^32-1 | 2^64-1 | // - // other: 32 bit unsinged res should be sign extended as if it were a signed number + // other: 32 bit unsigned res should be sign extended as if it were a signed number if(P.IEEE754) begin always_comb @@ -343,7 +343,7 @@ module specialcase import cvw::*; #(parameter cvw_t P) ( else OfIntRes2 = OfIntRes; if (Zfa) Int64Res = {{(P.XLEN-32){CvtNegRes[P.XLEN-1]}}, CvtNegRes[31:0]}; else Int64Res = CvtNegRes[P.XLEN-1:0]; - if (Zfa) SelCvtOfRes = InfIn | NaNIn | (CvtCe > 32 + 52); // fcvtmod.w.d only overflows to 0 on NaN or Infinity, or if the shift is so large that only zeros are left + if (Zfa) SelCvtOfRes = InfIn | NaNIn | (CvtCe > 32 + 52); // fcvtmod.w.d only overflows to 0 on NaN or Infinity, or if the shift is so large that only zeros are left else SelCvtOfRes = IntInvalid; // regular fcvt gives an overflow if out of range end else