Ejemplo n.º 1
0
uint64_t helper_fdiv_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t rm)
{
    softfloat_roundingMode = RISCV_RM;
    frs1 = f32_div(frs1, frs2);
    set_fp_exceptions;
    return frs1;
}
Ejemplo n.º 2
0
int f32_test(void)
{
    f32 a,b,c;

    a = f32_from_double(A);
    b = f32_from_double(B);
    c = f32_from_double(C);

    printf("************ F32\n\n");

    printf("*** ADD\n\n");
    printf("Result is        ");
    f32_print(f32_add(a,b));
    printf("\nResult should be %f\n\n", A+B);
    printf("Result is        ");
    f32_print(f32_add(b,c));
    printf("\nResult should be %f\n\n", B+C);
    printf("Result is        ");
    f32_print(f32_add(c,a));
    printf("\nResult should be %f\n\n", C+A);

    printf("*** SUB\n\n");
    printf("Result is        ");
    f32_print(f32_sub(a,b));
    printf("\nResult should be %f\n\n", A-B);
    printf("Result is        ");
    f32_print(f32_sub(b,c));
    printf("\nResult should be %f\n\n", B-C);
    printf("Result is        ");
    f32_print(f32_sub(c,a));
    printf("\nResult should be %f\n\n", C-A);

    printf("*** INV\n\n");
    printf("Result is        ");
    f32_print(f32_inv(a));
    printf("\nResult should be %f\n\n", 1.0/A);
    printf("Result is        ");
    f32_print(f32_inv(b));
    printf("\nResult should be %f\n\n", 1.0/B);
    printf("Result is        ");
    f32_print(f32_inv(c));
    printf("\nResult should be %f\n\n", 1.0/C);

    printf("*** MUL\n\n");
    printf("Result is        ");
    f32_print(f32_mul(a,b));
    printf("\nResult should be %f\n\n", A*B);
    printf("Result is        ");
    f32_print(f32_mul(b,c));
    printf("\nResult should be %f\n\n", B*C);
    printf("Result is        ");
    f32_print(f32_mul(c,a));
    printf("\nResult should be %f\n\n", C*A);

    printf("*** DIV\n\n");
    printf("Result is        ");
    f32_print(f32_div(a,b));
    printf("\nResult should be %f\n\n", A/B);
    printf("Result is        ");
    f32_print(f32_div(b,c));
    printf("\nResult should be %f\n\n", B/C);
    printf("Result is        ");
    f32_print(f32_div(c,a));
    printf("\nResult should be %f\n\n", C/A);

    printf("*** SQRT\n\n");
    printf("Result is        ");
    f32_print(f32_sqrt(a));
    printf("\nResult should be %f\n\n", sqrt(A));
    printf("Result is        ");
    f32_print(f32_sqrt(b));
    printf("\nResult should be %f\n\n", sqrt(B));
    printf("Result is        ");
    f32_print(f32_sqrt(c));
    printf("\nResult should be %f\n\n", sqrt(C));


    return 0;
}
Ejemplo n.º 3
0
inline fxx fxx_div(fxx a,fxx b)
{
  return f32_div(a,b);
}