yunsup made this fix..ask him
authorYunsup Lee <yunsup@cs.berkeley.edu>
Wed, 19 Oct 2011 00:03:26 +0000 (17:03 -0700)
committerYunsup Lee <yunsup@cs.berkeley.edu>
Wed, 19 Oct 2011 00:03:26 +0000 (17:03 -0700)
riscv/htif.cc
riscv/htif.h
riscv/sim.cc

index 02809d088eefd7f8c9ad9428798e21014d0a13ea..3bb8b9914c47ad10e13bbecad09c96cd3299113c 100644 (file)
@@ -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);
index 01066957245ba7141cdfdb8bb6f6a635b6bde3b3..d7a8c898197db39e9bb39304ef130e8e7389fc6a 100644 (file)
@@ -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:
index 65125e49a475e001e375a1bab295bdd75ee38e40..9020da4554082c147fecc9f9daf3bdf12ff9ffb9 100644 (file)
@@ -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()