diff --git a/pipelined/src/fma/Makefile b/fma/Makefile similarity index 100% rename from pipelined/src/fma/Makefile rename to fma/Makefile diff --git a/fma/div b/fma/div new file mode 100755 index 000000000..faeb00d97 Binary files /dev/null and b/fma/div differ diff --git a/pipelined/src/fma/div.c b/fma/div.c similarity index 100% rename from pipelined/src/fma/div.c rename to fma/div.c diff --git a/pipelined/src/fma/fma.do b/fma/fma.do similarity index 100% rename from pipelined/src/fma/fma.do rename to fma/fma.do diff --git a/pipelined/src/fma/fma16.sv b/fma/fma16.sv similarity index 99% rename from pipelined/src/fma/fma16.sv rename to fma/fma16.sv index 9732d6c93..5fe63b1d3 100644 --- a/pipelined/src/fma/fma16.sv +++ b/fma/fma16.sv @@ -99,7 +99,7 @@ module postproc( always_comb begin ueb = ue-7'd15; if (ue >= 7'd46) begin // overflow - uebiased = 5'd30; + uebiased = 7'd30; uff = 10'h3ff; end else begin uebiased = ue-7'd15; diff --git a/fma/fma16_testgen b/fma/fma16_testgen new file mode 100755 index 000000000..625c72189 Binary files /dev/null and b/fma/fma16_testgen differ diff --git a/pipelined/src/fma/fma16_testgen.c b/fma/fma16_testgen.c similarity index 97% rename from pipelined/src/fma/fma16_testgen.c rename to fma/fma16_testgen.c index 69bade22f..b294552e6 100644 --- a/pipelined/src/fma/fma16_testgen.c +++ b/fma/fma16_testgen.c @@ -65,7 +65,7 @@ void genCase(FILE *fptr, float16_t x, float16_t y, float16_t z, int mul, int add resultmag.v &= 0x7FFF; // take absolute value if (f16_lt(resultmag, smallest) && (resultmag.v != 0x0000)) fprintf (fptr, "// skip denorm: "); if (resultmag.v == 0x0000 && !zeroAllowed) fprintf(fptr, "// skip zero: "); - if (resultmag.v == 0x7C00 && !infAllowed) fprintf(fptr, "// Skip inf: "); + if ((resultmag.v == 0x7C00 || resultmag.v == 0x7BFF) && !infAllowed) fprintf(fptr, "// Skip inf: "); if (resultmag.v > 0x7C00 && !nanAllowed) fprintf(fptr, "// Skip NaN: "); fprintf(fptr, "%04x_%04x_%04x_%02x_%04x // %s\n", x.v, y.v, z.v, op, result.v, calc); } diff --git a/fma/fma32 b/fma/fma32 new file mode 100755 index 000000000..44be8588f Binary files /dev/null and b/fma/fma32 differ diff --git a/fma/fma32.c b/fma/fma32.c new file mode 100644 index 000000000..4b7bda1fd --- /dev/null +++ b/fma/fma32.c @@ -0,0 +1,47 @@ +#include +#include +#include "softfloat.h" +#include "softfloat_types.h" + +int float_rounding_mode = 0; + +union sp { + unsigned short x[2]; + float y; +} X; + + +int main() +{ + uint8_t rounding_mode; + uint8_t exceptions; + + uint32_t multiplier, multiplicand, addend, result; + float32_t f_multiplier, f_multiplicand, f_addend, f_result; + + multiplier = 0xbf800000; + multiplicand = 0xbf800000; + addend = 0xffaaaaaa; + + f_multiplier.v = multiplier; + f_multiplicand.v = multiplicand; + f_addend.v = addend; + + softfloat_roundingMode = rounding_mode; + softfloat_exceptionFlags = 0; + softfloat_detectTininess = softfloat_tininess_beforeRounding; + + f_result = f32_mulAdd(f_multiplier, f_multiplicand, f_addend); + + result = f_result.v; + exceptions = softfloat_exceptionFlags & 0x1f; + + printf("%x\n", f_result.v); + + // Print out SP number + X.x[1] = (f_result.v & 0xffff0000) >> 16; + X.x[0] = (f_result.v & 0x0000ffff); + printf("Number = %f\n", X.y); + + return 0; +} diff --git a/pipelined/src/fma/lint-fma b/fma/lint-fma similarity index 100% rename from pipelined/src/fma/lint-fma rename to fma/lint-fma diff --git a/pipelined/src/fma/sim-fma b/fma/sim-fma similarity index 100% rename from pipelined/src/fma/sim-fma rename to fma/sim-fma diff --git a/pipelined/src/fma/testbench.sv b/fma/testbench.sv similarity index 100% rename from pipelined/src/fma/testbench.sv rename to fma/testbench.sv