45using namespace MipsISA;
57 double sdouble_val = fp_val;
58 void *sdouble_ptr = &sdouble_val;
59 uint64_t sdp_bits = *(uint64_t *) sdouble_ptr;
65 int32_t sword_val = (int32_t) fp_val;
66 void *sword_ptr = &sword_val;
67 uint64_t sword_bits= *(uint32_t *) sword_ptr;
73 float wfloat_val = fp_val;
74 void *wfloat_ptr = &wfloat_val;
75 uint64_t wfloat_bits = *(uint32_t *) wfloat_ptr;
81 double wdouble_val = fp_val;
82 void *wdouble_ptr = &wdouble_val;
83 uint64_t wdp_bits = *(uint64_t *) wdouble_ptr;
88 panic(
"Invalid Floating Point Conversion Type (%d). See \"types.hh\" for List of Conversions\n",cvt_type);
96 double digit_offset = pow(10.0,digits);
107 int trunc_val = (int)
val;
108 return (
double) trunc_val;
114 int shift = (cc_idx == 0) ? 23 : cc_idx + 24;
115 bool cc_val = (fcsr >>
shift) & 0x00000001;
122 int cc_idx = (cc_num == 0) ? 23 : cc_num + 24;
124 fcsr =
bits(fcsr, 31, cc_idx + 1) << (cc_idx + 1) |
126 bits(fcsr, cc_idx - 1, 0);
136 fcsr_bits = fcsr_bits | (1 << invalid_offset);
140 fcsr_bits = fcsr_bits | (1 << cause_offset);
152 uint32_t val_bits = *(uint32_t *) val_ptr;
153 return (
bits(val_bits, 30, 23) == 0xFF);
158 uint64_t val_bits = *(uint64_t *) val_ptr;
159 return (
bits(val_bits, 62, 52) == 0x7FF);
163 panic(
"Type unsupported. Size mismatch\n");
175 uint32_t val_bits = *(uint32_t *) val_ptr;
176 return (
bits(val_bits, 30, 22) == 0x1FE);
181 uint64_t val_bits = *(uint64_t *) val_ptr;
182 return (
bits(val_bits, 62, 51) == 0xFFE);
186 panic(
"Type unsupported. Size mismatch\n");
197 uint32_t val_bits = *(uint32_t *) val_ptr;
198 return (
bits(val_bits, 30, 22) == 0x1FF);
203 uint64_t val_bits = *(uint64_t *) val_ptr;
204 return (
bits(val_bits, 62, 51) == 0xFFF);
208 panic(
"Type unsupported. Size mismatch\n");
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define panic(...)
This implements a cprintf based panic() function.
bool getCondCode(uint32_t fcsr, int cc_idx)
uint64_t fpConvert(ConvertType cvt_type, double fp_val)
uint32_t genInvalidVector(uint32_t fcsr_bits)
double roundFP(double val, int digits)
uint32_t genCCVector(uint32_t fcsr, int cc_num, uint32_t cc_val)
bool isNan(void *val_ptr, int size)
double truncFP(double val)
bool isQnan(void *val_ptr, int size)
bool isSnan(void *val_ptr, int size)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.