WRITE_FREG(_insn->rvc_rs2s(), freg(value));
}
-//void (sv_proc_t::WRITE_RD)(bool value)
-//{
-// WRITE_REG( _insn->rd(), value ? 1 : 0);
-//}
-
-//
-//void (sv_proc_t::WRITE_RD)(sv_reg_t value)
-//{
-// WRITE_REG( _insn->rd(), value );
-//}
-
-
-//void (sv_proc_t::WRITE_RVC_RS1S)(sv_sreg_t value)
-//{
-// WRITE_REG(_insn->rvc_rs1s(), value );
-//}
-
void (sv_proc_t::WRITE_RVC_RS1S)(sv_reg_t const& value)
{
WRITE_REG(_insn->rvc_rs1s(), value );
WRITE_REG(_insn->rvc_rs2s(), value );
}
-//void (sv_proc_t::WRITE_RVC_RS2S)(sv_sreg_t value)
-//{
-// WRITE_REG(_insn->rvc_rs2s(), value );
-//}
-
void (sv_proc_t::WRITE_RD)(sv_reg_t const& value)
{
WRITE_REG( _insn->rd(), value ); // XXX TODO: replace properly
}
-//void (sv_proc_t::WRITE_RD)(sv_sreg_t value)
-//{
-// WRITE_REG( _insn->rd(), value ); // XXX TODO: replace properly
-//}
-
-//void (sv_proc_t::WRITE_REG)(reg_t reg, sv_sreg_t value)
-//{
-// //WRITE_REG( reg, value ); // XXX TODO: replace properly
-// STATE.XPR.write(reg, value);
-//}
-
-//#define OFFSDIV
-
void (sv_proc_t::DO_WRITE_FREG)(reg_spec_t const& spec, sv_freg_t const& value)
{
- //WRITE_REG( reg, value ); // XXX TODO: replace properly
reg_t reg = spec.reg;
if (spec.offset) {
reg += *spec.offset;
void (sv_proc_t::WRITE_REG)(reg_spec_t const& spec, sv_reg_t const& value)
{
uint64_t wval = (uint64_t)value;
- //WRITE_REG( reg, value ); // XXX TODO: replace properly
reg_t reg = spec.reg;
int bitwidth = get_bitwidth(_insn->reg_elwidth(reg, true), xlen);
unsigned int shift = 0;
return ((UINT64_C(18446744073709551615)));
}
-/*
-sv_reg_t (sv_proc_t::sext_xlen)(uint64_t x)
-{
- x = (((sreg_t)(x) << (64-xlen)) >> (64-xlen));
- return sv_uint64_t(x);
-}
-*/
sv_sreg_t (sv_proc_t::sext_xlen)(sv_sreg_t const& v)
{
int64_t x = v;
return sv_reg_t(x);
}
-/*
-sv_reg_t (sv_proc_t::sext32)(uint_fast32_t v)
-{
- return sext32((uint64_t)v); // XXX TODO do properly
-}
-*/
sv_sreg_t (sv_proc_t::sext32)(sv_reg_t const& v)
{
uint64_t x = v;
return sv_sreg_t((int64_t)x, v.get_xlen(), v.get_elwidth());
}
-//sv_sreg_t (sv_proc_t::sext32)(sv_sreg_t const& v)
-//{
-// int64_t x = v;
-// x = ((sreg_t)(int32_t)(x));
-// return sv_sreg_t(x);
-//}
-
sv_reg_t (sv_proc_t::zext32)(sv_reg_t const& v)
{
uint64_t x = v;
return sv_reg_t(x);
}
-/*
-sv_reg_t sv_reg_t::make_sv_int64_t (int64_t v) const
-{
- return sv_sreg_t(v);
-}
-
-sv_reg_t sv_reg_t::make_sv_uint64_t (uint64_t v) const
-{
- return sv_uint64_t(v);
-}
-
-
-sv_reg_t::operator sv_sreg_t ()
-{
- return sv_sreg_t ( as_uint64() );
-}
-
-sv_reg_t::operator int32_t ()
-{
- uint64_t x = get_data();
- sv_sreg_t _x = (sv_sreg_t) x;
- sv_sreg_t y = sv_sreg_t ( _x );
- return y;
-}
-
-
-sv_reg_t::operator uint16_t ()
-{
- uint64_t x = get_data();
- uint16_t _x = (uint16_t) x;
- sv_uint16_t y = sv_uint16_t ( _x );
- return y;
-}
-
-
-sv_reg_t::operator uint8_t () // XXX TODO, make_sv_char_t
-{
- uint64_t x = get_data();
- uint8_t _x = (uint8_t) x;
- sv_uint64_t y = sv_uint64_t ( _x );
- return y;
-}
-
-sv_reg_t::operator char () // XXX TODO, make_sv_char_t
-{
- uint64_t x = get_data();
- char _x = (char) x;
- sv_sreg_t y = sv_sreg_t ( _x );
- return y;
-}
-
-sv_reg_t::operator uint32_t () // TODO, make_sv_uint32_t
- { return make_sv_uint64_t( (sv_sreg_t) (as_uint64()) ); }
-sv_reg_t::operator sv_sreg_t ()
- { return make_sv_int64_t( (sv_sreg_t) (as_uint64()) ); }
-
-sv_reg_t::operator sv_reg_t ()
-{
- uint64_t x = get_data();
- sv_uint64_t y = sv_uint64_t ( x );
- return y;
-}
-*/
-
sv_reg_t sv_proc_t::rv_add(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
uint8_t bitwidth = _insn->src_bitwidth;
return lhs << rhs;
}
-//sv_sreg_t sv_proc_t::rv_sr(sv_sreg_t const & lhs, sv_reg_t const & rhs)
-//{
-// return lhs >> rhs;
-//}
-
sv_reg_t sv_proc_t::rv_sr(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
return lhs >> rhs;
return v;
}
+void sv_proc_t::mmu_store(reg_spec_t const& spec, sv_reg_t const& offs,
+ size_t width, reg_t val)
+{
+ // different "mode" applies, here: addr_mode.
+ reg_t reg = READ_REG(spec, true, width);
+ sv_reg_t addr = sv_reg_t((uint64_t)reg + (int64_t)offs);
+
+ // now that the address has been moved on by the modulo-offset,
+ // get only an elwidth-sized element (if not "default")
+ width = get_bitwidth(_insn->reg_elwidth(spec.reg, true), width);
+ fprintf(stderr, "mmu_store wid %ld addr %lx offs %lx stored %lx\n",
+ width, (uint64_t)reg, (int64_t)offs, (uint64_t)val);
+ switch (width)
+ {
+ case 8:
+ p->get_mmu()->store_uint8(addr, val);
+ break;
+ case 16:
+ p->get_mmu()->store_uint16(addr, val);
+ break;
+ case 32:
+ p->get_mmu()->store_uint32(addr, val);
+ break;
+ case 64:
+ p->get_mmu()->store_uint64(addr, val);
+ break;
+ }
+}
+
sv_load_func(int32, 32, false )
sv_load_func(int64, 64, false )
-#define sv_store_func(type) \
+#define sv_store_func(type, width) \
+void sv_mmu_t::store_##type(reg_spec_t const& spec, sv_reg_t const& offs, \
+ type##_t val) { \
+ proc->s.mmu_store(spec, offs, width, val); \
+} \
void sv_mmu_t::store_##type(sv_reg_t const& addr, type##_t val) { \
mmu_t::store_##type(addr, val); \
}
// store value to memory at aligned address
-sv_store_func(uint8)
-sv_store_func(uint16)
-sv_store_func(uint32)
-sv_store_func(uint64)
+sv_store_func(uint8, 8)
+sv_store_func(uint16, 16)
+sv_store_func(uint32, 32)
+sv_store_func(uint64, 64)
#if 0
#define sv_amo_func(type) \