Skip to content

Commit 14cad99

Browse files
authored
Merge pull request #1993 from arrv-sc/arrv-sc/init-blocksz
feat: move cache block size initialization to constructor
2 parents f6b16b1 + b346571 commit 14cad99

File tree

7 files changed

+8
-11
lines changed

7 files changed

+8
-11
lines changed

riscv/cfg.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ cfg_t::cfg_t()
4747
explicit_hartids = false;
4848
real_time_clint = false;
4949
trigger_count = 4;
50+
cache_blocksz = 64;
5051
}

riscv/cfg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class cfg_t
7878
bool explicit_hartids;
7979
bool real_time_clint;
8080
reg_t trigger_count;
81+
reg_t cache_blocksz;
8182
std::optional<abstract_sim_if_t*> external_simulator;
8283

8384
size_t nprocs() const { return hartids.size(); }

riscv/mmu.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "processor.h"
88
#include "decode_macros.h"
99

10-
mmu_t::mmu_t(simif_t* sim, endianness_t endianness, processor_t* proc)
11-
: sim(sim), proc(proc),
10+
mmu_t::mmu_t(simif_t* sim, endianness_t endianness, processor_t* proc, reg_t cache_blocksz)
11+
: sim(sim), proc(proc), blocksz(cache_blocksz),
1212
#ifdef RISCV_ENABLE_DUAL_ENDIAN
1313
target_big_endian(endianness == endianness_big),
1414
#endif

riscv/mmu.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class mmu_t
8989
mem_access_info_t generate_access_info(reg_t addr, access_type type, xlate_flags_t xlate_flags);
9090

9191
public:
92-
mmu_t(simif_t* sim, endianness_t endianness, processor_t* proc);
92+
mmu_t(simif_t* sim, endianness_t endianness, processor_t* proc, reg_t cache_blocksz);
9393
~mmu_t();
9494

9595
template<typename T>
@@ -397,11 +397,6 @@ class mmu_t
397397
return target_big_endian? target_endian<T>::to_be(n) : target_endian<T>::to_le(n);
398398
}
399399

400-
void set_cache_blocksz(reg_t size)
401-
{
402-
blocksz = size;
403-
}
404-
405400
private:
406401
simif_t* sim;
407402
processor_t* proc;

riscv/processor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ processor_t::processor_t(const char* isa_str, const char* priv_str,
6363
VU.vstart_alu = 0;
6464

6565
register_base_instructions();
66-
mmu = new mmu_t(sim, cfg->endianness, this);
66+
mmu = new mmu_t(sim, cfg->endianness, this, cfg->cache_blocksz);
6767

6868
disassembler = new disassembler_t(&isa);
6969
for (auto e : isa.get_extensions())

riscv/sim.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
9696
}
9797
#endif
9898

99-
debug_mmu = new mmu_t(this, cfg->endianness, NULL);
99+
debug_mmu = new mmu_t(this, cfg->endianness, NULL, cfg->cache_blocksz);
100100

101101
// When running without using a dtb, skip the fdt-based configuration steps
102102
if (!dtb_enabled) {

spike_main/spike.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ int main(int argc, char** argv)
451451
min_blocksz, max_blocksz);
452452
exit(-1);
453453
}
454+
cfg.cache_blocksz = blocksz;
454455
});
455456
parser.option(0, "instructions", 1, [&](const char* s){
456457
instructions = strtoull(s, 0, 0);
@@ -541,7 +542,6 @@ int main(int argc, char** argv)
541542
if (dc) s.get_core(i)->get_mmu()->register_memtracer(&*dc);
542543
for (auto e : extensions)
543544
s.get_core(i)->register_extension(e());
544-
s.get_core(i)->get_mmu()->set_cache_blocksz(blocksz);
545545
}
546546

547547
s.set_debug(debug);

0 commit comments

Comments
 (0)