very bad hack on xlen=32 to sign-extend out into top bits of 64-bit register
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 8 Nov 2018 18:12:08 +0000 (18:12 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 8 Nov 2018 18:12:08 +0000 (18:12 +0000)
riscv/sv_insn_redirect.cc

index dc3037c0a80783c29c2566473253725dc2fbbadb..b6312adead82d6cb65c305ea40773e4613db318c 100644 (file)
@@ -236,6 +236,14 @@ void (sv_proc_t::WRITE_REG)(reg_spec_t const& spec, sv_reg_t const& value)
                 report[0] = 'z';
             }
         }
+        // XXX BAD HACK, keep an eye on this
+        // when xlen = 32, spike appears to expect all 32-bit
+        // results to be sign-extended in the 64-bit register.
+        // this MAY not be properly spec-compliant when xlen
+        // is changed at runtime.
+        if (xlen == 32 && bitwidth != 32) {
+            wval = sext_bwid(wval, 32);
+        }
         fprintf(stderr, "writereg %s %ld bitwidth %d offs %d shift %d %lx " \
                         " %lx %lx %lx\n",
                         report, spec.reg, bitwidth, offs, shift, data,