Browse Source

make HTIF interactions deterministic; fix race

confprec
Andrew Waterman 14 years ago
parent
commit
d58ee30d17
  1. 16
      riscv/htif.cc
  2. 2
      riscv/htif.h
  3. 5
      riscv/sim.cc

16
riscv/htif.cc

@ -1,5 +1,4 @@
#include "htif.h"
#include "common.h"
#include "sim.h"
#include <unistd.h>
#include <stdexcept>
@ -84,8 +83,9 @@ void htif_isasim_t::tick_once()
memcpy(&val, p.get_payload(), sizeof(val));
if (regno == PCR_RESET)
{
reset = val & 1;
sim->procs[coreid]->reset(reset);
if (reset && !(val & 1))
reset = false;
sim->procs[coreid]->reset(val & 1);
}
else
{
@ -100,8 +100,12 @@ void htif_isasim_t::tick_once()
seqno++;
}
void htif_isasim_t::stop()
bool htif_isasim_t::done()
{
htif_t::stop();
exit(exit_code());
if (reset)
return false;
for (size_t i = 0; i < sim->num_cores(); i++)
if (sim->procs[i]->running())
return false;
return true;
}

2
riscv/htif.h

@ -16,7 +16,7 @@ class htif_isasim_t : public htif_pthread_t
public:
htif_isasim_t(sim_t* _sim, const std::vector<std::string>& args);
void tick();
void stop();
bool done();
private:
sim_t* sim;

5
riscv/sim.cc

@ -49,7 +49,6 @@ sim_t::~sim_t()
delete procs[i];
delete pmmu;
}
delete htif;
delete mmu;
munmap(mem, memsz);
}
@ -72,10 +71,10 @@ reg_t sim_t::get_scr(int which)
void sim_t::run(bool debug)
{
while (1)
while (!htif->done())
{
if(!debug)
step_all(1000, 1000, false);
step_all(10000, 1000, false);
else
interactive();
}

Loading…
Cancel
Save