Skip to content

Commit 2ffcd78

Browse files
committed
corrects memory to actually work now
this was a huge oversight causing the memory to return random data when read
1 parent bd9125a commit 2ffcd78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/iss/mem/memory_with_htif.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ template <typename PLAT> struct memory_with_htif : public memory_elem {
6969
// for(auto offs = 0U; offs < length; ++offs) {
7070
// *(data + offs) = mem[(addr + offs) % mem.size()];
7171
// }
72-
mem_type mem = memories[space];
72+
mem_type& mem = memories[space];
7373
if(mem.is_allocated(addr)) {
7474
const auto& p = mem(addr / mem.page_size);
7575
auto offs = addr & mem.page_addr_mask;
@@ -90,7 +90,7 @@ template <typename PLAT> struct memory_with_htif : public memory_elem {
9090
}
9191

9292
iss::status write_mem(iss::access_type access, uint32_t space, uint64_t addr, unsigned length, uint8_t const* data) {
93-
mem_type mem = memories[space];
93+
mem_type& mem = memories[space];
9494
auto& p = mem(addr / mem.page_size);
9595
auto offs = addr & mem.page_addr_mask;
9696
if((offs + length) > mem.page_size) {
@@ -114,7 +114,7 @@ template <typename PLAT> struct memory_with_htif : public memory_elem {
114114
// have the largest possible size. Memory footprint should still be small as it
115115
// a sparse array
116116
using mem_type = util::sparse_array<uint8_t, arch::traits<PLAT>::max_mem_size>;
117-
std::array<mem_type, arch::traits<PLAT>::mem_sizes.size()> memories;
117+
std::array<mem_type, arch::traits<PLAT>::mem_sizes.size()> memories{};
118118
arch::priv_if<reg_t> hart_if;
119119
};
120120
} // namespace mem

0 commit comments

Comments
 (0)