From a1f66113f1d0ec4898e942deb2354ccba9d71f64 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 19 Oct 2018 23:11:43 +0100 Subject: [PATCH] temporarily comment out setting of elwidth sv_reg_t seems to be being typecast somewhere, probably to a uint64_t, and accessing the elwidth corrupts memory --- riscv/sv_insn_redirect.cc | 3 ++- riscv/sv_reg.h | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/riscv/sv_insn_redirect.cc b/riscv/sv_insn_redirect.cc index 19df7b7..da1a643 100644 --- a/riscv/sv_insn_redirect.cc +++ b/riscv/sv_insn_redirect.cc @@ -104,7 +104,7 @@ sv_reg_t sv_proc_t::get_intreg(reg_t reg) { uint8_t elwidth = _insn->reg_elwidth(reg, true); uint64_t data = _insn->p->get_state()->XPR[reg]; - return sv_reg_t(data, elwidth); + return sv_reg_t(data /*, elwidth*/); } #define GET_REG(name) \ @@ -265,6 +265,7 @@ sv_reg_t::operator sv_reg_t () return y; } */ + sv_reg_t sv_proc_t::rv_add(sv_reg_t lhs, sv_reg_t rhs) { return lhs + rhs; diff --git a/riscv/sv_reg.h b/riscv/sv_reg.h index 5a38d09..8db28da 100644 --- a/riscv/sv_reg.h +++ b/riscv/sv_reg.h @@ -5,34 +5,37 @@ class sv_sreg_t; class sv_reg_t { public: - sv_reg_t(uint64_t _reg) : reg(_reg), elwidth(0) { } // default elwidth - sv_reg_t(uint64_t _reg, uint8_t _elwidth) : reg(_reg), elwidth(_elwidth) {} + sv_reg_t(uint64_t _reg) : reg(_reg) /*, elwidth(0)*/ { } // default elwidth + //sv_reg_t(uint64_t _reg, uint8_t _elwidth) : reg(_reg), elwidth(_elwidth) {} uint64_t reg; uint8_t elwidth; public: uint64_t get_data() { return reg; } - uint8_t get_width() { return elwidth; } + //uint8_t get_width() { return elwidth; } - operator uint64_t() { return reg; } - operator sv_sreg_t(); + operator uint64_t() const & { return reg; } + operator sv_sreg_t() const &; }; class sv_sreg_t { public: - sv_sreg_t(int64_t _reg) : reg(_reg), elwidth(0) {} // default elwidth - sv_sreg_t(int64_t _reg, uint8_t _elwidth) : reg(_reg), elwidth(_elwidth) {} + sv_sreg_t(int64_t _reg) : reg(_reg) /*, elwidth(0)*/ {} // default elwidth + //sv_sreg_t(int64_t _reg, uint8_t _elwidth) : reg(_reg), elwidth(_elwidth) {} int64_t reg; uint8_t elwidth; public: int64_t get_data() { return reg; } - uint8_t get_width() { return elwidth; } + //uint8_t get_width() { return elwidth; } - operator int64_t() { return reg; } - operator sv_reg_t() { return sv_reg_t((uint64_t)reg, elwidth); } + operator int64_t() const& { return reg; } + //operator sv_reg_t() { return sv_reg_t((uint64_t)reg, elwidth); } + operator sv_reg_t() const& { return sv_reg_t((uint64_t)reg); } }; -inline sv_reg_t::operator sv_sreg_t() { return sv_sreg_t((int64_t)reg, elwidth); } +//inline sv_reg_t::operator sv_sreg_t() { return sv_sreg_t((int64_t)reg, elwidth); } +inline sv_reg_t::operator sv_sreg_t() const & +{ return sv_sreg_t((int64_t)reg); } #endif -- 2.30.2