aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunsup Lee <yunsup@cs.berkeley.edu>2011-10-18 17:03:26 -0700
committerYunsup Lee <yunsup@cs.berkeley.edu>2011-10-18 17:03:26 -0700
commited8a77d328a85affe0d5d7a5cf631f64236fe895 (patch)
treec517612a86701329794e0f853c6f29e54a01bcd0
parent4ddd7773f8fb40ea1c9b48c8f3a61a40c3f168fb (diff)
downloadspike-ed8a77d328a85affe0d5d7a5cf631f64236fe895.zip
spike-ed8a77d328a85affe0d5d7a5cf631f64236fe895.tar.gz
spike-ed8a77d328a85affe0d5d7a5cf631f64236fe895.tar.bz2
yunsup made this fix..ask him
-rw-r--r--riscv/htif.cc5
-rw-r--r--riscv/htif.h1
-rw-r--r--riscv/sim.cc1
3 files changed, 7 insertions, 0 deletions
diff --git a/riscv/htif.cc b/riscv/htif.cc
index 02809d0..3bb8b99 100644
--- a/riscv/htif.cc
+++ b/riscv/htif.cc
@@ -51,6 +51,11 @@ void htif_t::wait_for_start()
while(wait_for_packet() != APP_CMD_START);
}
+void htif_t::wait_for_tohost_write()
+{
+ while(wait_for_packet() != APP_CMD_READ_CONTROL_REG);
+}
+
void htif_t::wait_for_fromhost_write()
{
while(wait_for_packet() != APP_CMD_WRITE_CONTROL_REG);
diff --git a/riscv/htif.h b/riscv/htif.h
index 0106695..d7a8c89 100644
--- a/riscv/htif.h
+++ b/riscv/htif.h
@@ -19,6 +19,7 @@ public:
// we block on the host if the target machine reads the fromhost register,
// which provides determinism in tohost/fromhost communication.
+ void wait_for_tohost_write();
void wait_for_fromhost_write();
private:
diff --git a/riscv/sim.cc b/riscv/sim.cc
index 65125e4..9020da4 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -58,6 +58,7 @@ void sim_t::set_tohost(reg_t val)
{
fromhost = 0;
tohost = val;
+ htif->wait_for_tohost_write();
}
reg_t sim_t::get_fromhost()