diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2022-02-18 12:28:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-18 04:28:55 -0800 |
commit | 5892e9356e53129afa6cdcaf3fc5aad5490a7f83 (patch) | |
tree | 27b1ba8fc5eb1c2d75511184510b3fa3e67f8669 /riscv/sim.cc | |
parent | f224b15addeaacb5cff1a68cac21d3e926a0015f (diff) | |
download | riscv-isa-sim-5892e9356e53129afa6cdcaf3fc5aad5490a7f83.zip riscv-isa-sim-5892e9356e53129afa6cdcaf3fc5aad5490a7f83.tar.gz riscv-isa-sim-5892e9356e53129afa6cdcaf3fc5aad5490a7f83.tar.bz2 |
Don't instantiate a CLINT if there is none in the device config (#921)
This change makes it possible to faithfully simulate systems which
don't have a CLINT (without adding yet another command line argument
to pass through!).
Without a change like this, lowRISC has been using a local hack in its
Spike fork, where we've just commented out the internals of
clint_t::increment(). This approach is rather cleaner and is hopefully
general enough to use upstream.
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r-- | riscv/sim.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc index 2ee05d6..a0f13ae 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -98,12 +98,17 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch, make_dtb(); void *fdt = (void *)dtb.c_str(); - //handle clic - clint.reset(new clint_t(procs, CPU_HZ / INSNS_PER_RTC_TICK, real_time_clint)); + + // Only make a CLINT (Core-Local INTerrupt controller) if one is specified in + // the device tree configuration. + // + // This isn't *quite* as general as we could get (because you might have one + // that's not bus-accessible), but it should handle the normal use cases. In + // particular, the default device tree configuration that you get without + // setting the dtb_file argument has one. reg_t clint_base; - if (fdt_parse_clint(fdt, &clint_base, "riscv,clint0")) { - bus.add_device(CLINT_BASE, clint.get()); - } else { + if (fdt_parse_clint(fdt, &clint_base, "riscv,clint0") == 0) { + clint.reset(new clint_t(procs, CPU_HZ / INSNS_PER_RTC_TICK, real_time_clint)); bus.add_device(clint_base, clint.get()); } @@ -214,7 +219,7 @@ void sim_t::step(size_t n) procs[current_proc]->get_mmu()->yield_load_reservation(); if (++current_proc == procs.size()) { current_proc = 0; - clint->increment(INTERLEAVE / INSNS_PER_RTC_TICK); + if (clint) clint->increment(INTERLEAVE / INSNS_PER_RTC_TICK); } host->switch_to(); |