Browse Source

Move the "default hartids" logic from sim.cc into spike.cc

This moves another part of the "configuration" out of the generic
sim.cc code.
pull/954/head
Rupert Swarbrick 4 years ago
committed by Rupert Swarbrick
parent
commit
e4aaed1b7b
  1. 13
      riscv/sim.cc
  2. 16
      spike_main/spike.cc

13
riscv/sim.cc

@ -63,6 +63,8 @@ sim_t::sim_t(const cfg_t *cfg, const char* varch, bool halted, bool real_time_cl
remote_bitbang(NULL),
debug_module(this, dm_config)
{
assert(hartids.size() == cfg->nprocs());
signal(SIGINT, &handle_signal);
sout_.rdbuf(std::cerr.rdbuf()); // debug output goes to stderr by default
@ -77,17 +79,8 @@ sim_t::sim_t(const cfg_t *cfg, const char* varch, bool halted, bool real_time_cl
debug_mmu = new mmu_t(this, NULL);
if (! (hartids.empty() || hartids.size() == nprocs())) {
std::cerr << "Number of specified hartids ("
<< hartids.size()
<< ") doesn't match number of processors ("
<< nprocs() << ").\n";
exit(1);
}
for (size_t i = 0; i < nprocs(); i++) {
int hart_id = hartids.empty() ? i : hartids[i];
procs[i] = new processor_t(&isa, varch, this, hart_id, halted,
procs[i] = new processor_t(&isa, varch, this, hartids[i], halted,
log_file.get(), sout_);
}

16
spike_main/spike.cc

@ -458,6 +458,22 @@ int main(int argc, char** argv)
}
#endif
if (!hartids.empty()) {
if (cfg.nprocs.overridden() && (cfg.nprocs() != hartids.size())) {
std::cerr << "Number of specified hartids ("
<< hartids.size()
<< ") doesn't match specified number of processors ("
<< cfg.nprocs() << ").\n";
exit(1);
}
} else {
// Set default set of hartids based on nprocs
hartids.reserve(cfg.nprocs());
for (size_t i = 0; i < cfg.nprocs(); ++i) {
hartids.push_back(i);
}
}
sim_t s(&cfg, varch, halted, real_time_clint,
mems, plugin_devices, htif_args,
std::move(hartids), dm_config, log_path, dtb_enabled, dtb_file,

Loading…
Cancel
Save