Browse Source

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.
pull/923/head
Rupert Swarbrick 5 years ago
committed by GitHub
parent
commit
5892e9356e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      riscv/sim.cc

17
riscv/sim.cc

@ -98,12 +98,17 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch,
make_dtb(); make_dtb();
void *fdt = (void *)dtb.c_str(); 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; reg_t clint_base;
if (fdt_parse_clint(fdt, &clint_base, "riscv,clint0")) { if (fdt_parse_clint(fdt, &clint_base, "riscv,clint0") == 0) {
bus.add_device(CLINT_BASE, clint.get()); clint.reset(new clint_t(procs, CPU_HZ / INSNS_PER_RTC_TICK, real_time_clint));
} else {
bus.add_device(clint_base, clint.get()); 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(); procs[current_proc]->get_mmu()->yield_load_reservation();
if (++current_proc == procs.size()) { if (++current_proc == procs.size()) {
current_proc = 0; current_proc = 0;
clint->increment(INTERLEAVE / INSNS_PER_RTC_TICK); if (clint) clint->increment(INTERLEAVE / INSNS_PER_RTC_TICK);
} }
host->switch_to(); host->switch_to();

Loading…
Cancel
Save