case 2:
{
float16_t x16 = ::f32_to_f16((float32_t)value);
+ fprintf(stderr, "f32-to-f16\n");
v = freg(x16);
break;
}
fprintf(stderr, "writefreg spec %ld bitwidth %d offs %d shift %d\n",
reg, bitwidth, offs, shift);
}
+ if (((int)reg) >= SV_NFPR) {
+ throw trap_illegal_instruction(0);
+ }
freg_shift fd;
if (xlen != bitwidth)
{
fprintf(stderr, "writereg spec %ld %lx bitwidth %d offs %d shift %d\n",
reg, wval, bitwidth, offs, shift);
}
+ if (((int)reg) >= SV_NFPR) {
+ throw trap_illegal_instruction(0);
+ }
if (xlen != bitwidth)
{
char report[2] = {};
freg_t (sv_proc_t::READ_FREG)(reg_spec_t const& spec)
{
- //int flen = sizeof(freg_t) * 8; // FLEN (not specified in spike)
+ int regflen = sizeof(freg_t) * 8; // FLEN (not specified in spike)
int flen = _insn->flen;
reg_t reg = spec.reg;
uint8_t elwidth = _insn->reg_elwidth(reg, false);
offs /= nbytes;
reg += offs;
}
+ if (((int)reg) >= SV_NFPR) {
+ throw trap_illegal_instruction(0);
+ }
freg_shift fs;
fs.f = _insn->p->get_state()->FPR[reg];
fprintf(stderr, "READ_FREG rd %ld ew %d bw %d fl %d data %lx %lx\n",
reg, elwidth, bitwidth, flen, fs.f.v[0], fs.f.v[1]);
- if (flen != bitwidth)
+ if (regflen != bitwidth)
{
// shuffle the data down by bytes (annoying but easier)
int sblen = shift*bitwidth/8;
- for (int i = 0; i < ((int)flen/8); i++) {
+ for (int i = 0; i < ((int)regflen/8); i++) {
if (i < (bitwidth/8)) {
fs.b[i] = fs.b[i+sblen];
} else {
offs /= nbytes;
reg += offs;
}
+ if (((int)reg) >= SV_NFPR) {
+ throw trap_illegal_instruction(0);
+ }
uint64_t data = _insn->p->get_state()->XPR[reg];
uint64_t ndata = data;
if (addr_mode)
sv_float32_t (sv_proc_t::f32)(sv_freg_t x)
{
+ freg_t v = (freg_t)x;
switch (x.get_elwidth())
{
// 8-bit
fprintf(stderr, "f16-to-f32 %lx\n", (uint64_t)x32);
return f16_to_f32(f_16);
}
- // 0 and 3 are 32-bit
+ case 3:
+ {
+ return sv_float32_t(::f32(x.to_uint32()));
+ }
default: break;
}
- return ::f32(x);
+ sv_float32_t value = ::f32(v);
+ fprintf(stderr, "::f32 %lx %lx %x\n", v.v[0], v.v[1], ((float32_t)value).v);
+ return value;
}
sv_float32_t (sv_proc_t::f32)(sv_reg_t const& v)
{
uint64_t x = v;
+ fprintf(stderr, "::f32 %lx\n", x);
switch (v.get_elwidth())
{
// 8-bit
sv_float32_t (sv_proc_t::f32_add)( sv_float32_t a, sv_float32_t b )
{
+ reg_t reg = _insn->rd().reg;
+ uint8_t dest_elwidth = _insn->reg_elwidth(reg, false);
//uint8_t reswidth = maxelwidth(a.get_elwidth(), b.get_elwidth());
//return sv_float32_t(::f32_add(a, b), xlen, reswidth);
- return ::f32_add(a, b);
+ sv_float32_t value = ::f32_add(a, b);
+ fprintf(stderr, "f32_add a %x b %x sv_float32_t %x\n",
+ ((float32_t)a).v, ((float32_t)b).v, ((float32_t)value).v);
+ return value;
}
sv_float32_t (sv_proc_t::f32_sub)( sv_float32_t a, sv_float32_t b )