diff --git a/pipelined/src/fma/fma16_testgen.c b/pipelined/src/fma/fma16_testgen.c index b294552e6..a9a26d803 100644 --- a/pipelined/src/fma/fma16_testgen.c +++ b/pipelined/src/fma/fma16_testgen.c @@ -11,6 +11,7 @@ typedef union sp { // lists of tests, terminated with 0x8000 uint16_t easyExponents[] = {15, 0x8000}; uint16_t medExponents[] = {1, 14, 15, 16, 20, 30, 0x8000}; +uint16_t allExponents[] = {1, 15, 16, 30, 31, 0x8000}; uint16_t easyFracts[] = {0, 0x200, 0x8000}; // 1.0 and 1.1 uint16_t medFracts[] = {0, 0x200, 0x001, 0x3FF, 0x8000}; uint16_t zeros[] = {0x0000, 0x8000}; @@ -37,7 +38,7 @@ float convFloat(float16_t f16) { void genCase(FILE *fptr, float16_t x, float16_t y, float16_t z, int mul, int add, int negp, int negz, int zeroAllowed, int infAllowed, int nanAllowed) { float16_t result; int op; - char calc[80]; + char calc[80], flags[80]; float32_t x32, y32, z32, r32; float xf, yf, zf, rf; float16_t smallest; @@ -47,8 +48,15 @@ void genCase(FILE *fptr, float16_t x, float16_t y, float16_t z, int mul, int add if (negp) x.v ^= 0x8000; // flip sign of x to negate p if (negz) z.v ^= 0x8000; // flip sign of z to negate z op = mul<<3 | add<<2 | negp<<1 | negz; + softfloat_exceptionFlags = 0; // clear exceptions result = f16_mulAdd(x, y, z); + sprintf(flags, "NV: %d OF: %d UF: %d NX: %d", + (softfloat_exceptionFlags >> 4) % 2, + (softfloat_exceptionFlags >> 2) % 2, + (softfloat_exceptionFlags >> 1) % 2, + (softfloat_exceptionFlags) % 2); + // convert to floats for printing xf = convFloat(x); yf = convFloat(y); @@ -67,7 +75,7 @@ void genCase(FILE *fptr, float16_t x, float16_t y, float16_t z, int mul, int add if (resultmag.v == 0x0000 && !zeroAllowed) fprintf(fptr, "// skip zero: "); 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); + fprintf(fptr, "%04x_%04x_%04x_%02x_%04x_%02x // %s %s\n", x.v, y.v, z.v, op, result.v, softfloat_exceptionFlags, calc, flags); } void prepTests(uint16_t *e, uint16_t *f, char *testName, char *desc, float16_t *cases, @@ -107,8 +115,8 @@ void genMulTests(uint16_t *e, uint16_t *f, int sgn, char *testName, char *desc, fclose(fptr); } -void genAddTests(uint16_t *e, uint16_t *f, int sgn, char *testName, char *desc) { - int i, j, numCases; +void genAddTests(uint16_t *e, uint16_t *f, int sgn, char *testName, char *desc, int zeroAllowed, int infAllowed, int nanAllowed) { + int i, j, k, numCases; float16_t x, y, z; float16_t cases[100000]; FILE *fptr; @@ -122,7 +130,72 @@ void genAddTests(uint16_t *e, uint16_t *f, int sgn, char *testName, char *desc) x.v = cases[i].v; for (j=0; j