mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Merge branch 'main' of github.com:davidharrishmc/riscv-wally into main
This commit is contained in:
commit
17dff315f4
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
|
||||||
void output(FILE *fptr, int signa, int e1, double a, int signb, int e2, double b, int r_sign, int r_exp, double r_mantissa);
|
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);
|
void printhex(FILE *fptr, double x);
|
||||||
double random_input(void);
|
double random_input(void);
|
||||||
double random_input_e(void);
|
double random_input_e(void);
|
||||||
@ -31,12 +31,13 @@ double random_input_e(void);
|
|||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
FILE *fptr;
|
FILE *fptr;
|
||||||
// e1 & e2 are exponents
|
// aExp & bExp are exponents
|
||||||
// a & b are mantissas
|
// aFrac & bFrac are mantissas
|
||||||
// r_mantissa is result of mantissa divsion
|
// rFrac is result of fractional divsion
|
||||||
// r_exp is result of exponent division
|
// rExp is result of exponent division
|
||||||
double a, b, r_mantissa, r_exp, r_sign;
|
double aFrac, bFrac, rFrac;
|
||||||
int e1, e2, signa, signb;
|
int aExp, bExp, rExp;
|
||||||
|
int aSign, bSign, rSign;
|
||||||
double mantissa[ENTRIES] = {1, 1.5, 1.25, 1.125, 1.0625,
|
double mantissa[ENTRIES] = {1, 1.5, 1.25, 1.125, 1.0625,
|
||||||
1.75, 1.875, 1.99999,
|
1.75, 1.875, 1.99999,
|
||||||
1.1, 1.2, 1.01, 1.001, 1.0001,
|
1.1, 1.2, 1.01, 1.001, 1.0001,
|
||||||
@ -51,28 +52,28 @@ void main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<ENTRIES; i++) {
|
for (i=0; i<ENTRIES; i++) {
|
||||||
b = mantissa[i];
|
bFrac = mantissa[i];
|
||||||
e2 = exponent[i] + bias;
|
bExp = exponent[i] + bias;
|
||||||
signb = i%2;
|
bSign = i%2;
|
||||||
for (j=0; j<ENTRIES; j++) {
|
for (j=0; j<ENTRIES; j++) {
|
||||||
a = mantissa[j];
|
aFrac = mantissa[j];
|
||||||
e1 = exponent[j] + bias;
|
aExp = exponent[j] + bias;
|
||||||
signa = j%2;
|
aSign = j%2;
|
||||||
r_mantissa = a/b;
|
rFrac = aFrac/bFrac;
|
||||||
r_exp = e1 - e2 + bias;
|
rExp = aExp - bExp + bias;
|
||||||
r_sign = (i+j)%2;
|
rSign = (i+j)%2;
|
||||||
output(fptr, signa, e1, a, signb, e2, b, r_sign, r_exp, r_mantissa);
|
output(fptr, aSign, aExp, aFrac, bSign, bExp, bFrac, rSign, rExp, rFrac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (i = 0; i< RANDOM_VECS; i++) {
|
// for (i = 0; i< RANDOM_VECS; i++) {
|
||||||
// a = random_input();
|
// aFrac = random_input();
|
||||||
// b = random_input();
|
// bFrac = random_input();
|
||||||
// e1 = random_input_e() + BIAS; // make new random input function for exponents
|
// aExp = random_input_e() + BIAS; // make new random input function for exponents
|
||||||
// e2 = random_input_e() + BIAS;
|
// bExp = random_input_e() + BIAS;
|
||||||
// r_mantissa = a/b;
|
// rFrac = a/b;
|
||||||
// r_exp = e1 - e2 + BIAS;
|
// rEx[] = e1 - e2 + BIAS;
|
||||||
// output(fptr, e1, a, e2, b, r_exp, r_mantissa);
|
// output(fptr, aExp, aFrac, bExp, bFrac, rExp, rFrac);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
@ -80,19 +81,21 @@ void main(void)
|
|||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
void output(FILE *fptr, int signa, int e1, double a, int signb, int e2, double b, int r_sign, int r_exp, double r_mantissa)
|
void output(FILE *fptr, int aSign, int aExp, double aFrac, int bSign, int bExp, double bFrac, int rSign, int rExp, double rFrac)
|
||||||
{
|
{
|
||||||
fprintf(fptr, "%03x", e1|(signa<<11));
|
// Print a in standard double format
|
||||||
//printhex(fptr, e1, exp);
|
fprintf(fptr, "%03x", aExp|(aSign<<11));
|
||||||
printhex(fptr, a);
|
printhex(fptr, aFrac);
|
||||||
fprintf(fptr, "_");
|
fprintf(fptr, "_");
|
||||||
fprintf(fptr, "%03x", e2|(signb<<11));
|
|
||||||
//printhex(fptr, e2, exp);
|
// Print b in standard double format
|
||||||
printhex(fptr, b);
|
fprintf(fptr, "%03x", bExp|(bSign<<11));
|
||||||
|
printhex(fptr, bFrac);
|
||||||
fprintf(fptr, "_");
|
fprintf(fptr, "_");
|
||||||
fprintf(fptr, "%03x", r_exp|(r_sign<<11));
|
|
||||||
//printhex(fptr, r_exp, exp);
|
// Print r in standard double format
|
||||||
printhex(fptr, r_mantissa);
|
fprintf(fptr, "%03x", rExp|(rSign<<11));
|
||||||
|
printhex(fptr, rFrac);
|
||||||
fprintf(fptr, "\n");
|
fprintf(fptr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,4 +286,4 @@ c0b004189374bc6a_410c71c71c71c71c_bfa2049ba5e353f8
|
|||||||
c0dd1745d1745d17_410c71c71c71c71c_bfc05d1745d1745d
|
c0dd1745d1745d17_410c71c71c71c71c_bfc05d1745d1745d
|
||||||
40e5555555555555_410c71c71c71c71c_3fd8000000000000
|
40e5555555555555_410c71c71c71c71c_3fd8000000000000
|
||||||
c0f999999999999a_410c71c71c71c71c_bfecccccccccccce
|
c0f999999999999a_410c71c71c71c71c_bfecccccccccccce
|
||||||
410c71c71c71c71c_410c71c71c71c71c_3ff0000000000000
|
410c71c71c71c71c_410c71c71c71c71c_3ff0000000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user