/* testgen.c */ /* Written 2/19/2022 by David Harris This program creates test vectors for mantissa and exponent components of an IEEE floating point divider. Builds upon program that creates test vectors for mantissa component only. */ /* #includes */ #include #include #include /* Constants */ #define ENTRIES 17 #define RANDOM_VECS 500 // #define BIAS 1023 // Bias is for double precision /* Prototypes */ void output(FILE *fptr, int aSign, int aExp, double aFrac, int bSign, int bExp, double bFrac, int rSign, int rExp, double rFrac); void printhex(FILE *fptr, double x); double random_input(void); double random_input_e(void); /* Main */ void main(void) { FILE *fptr; // aExp & bExp are exponents // aFrac & bFrac are mantissas // rFrac is result of fractional divsion // rExp is result of exponent division double aFrac, bFrac, rFrac; int aExp, bExp, rExp; int aSign, bSign, rSign; double mantissa[ENTRIES] = {1, 1.5, 1.25, 1.125, 1.0625, 1.75, 1.875, 1.99999, 1.1, 1.2, 1.01, 1.001, 1.0001, 1/1.1, 1/1.5, 1/1.25, 1/1.125}; int exponent[ENTRIES] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; int i, j; int bias = 1023; if ((fptr = fopen("testvectors","w")) == NULL) { fprintf(stderr, "Couldn't write testvectors file\n"); exit(1); } for (i=0; i2) m /= 2; for (i=0; i