diff --git a/t-vvm.cc b/t-vvm.cc index cf0a1cc43..085eb501b 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: t-vvm.cc,v 1.58 1999/10/05 06:19:46 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.59 1999/10/06 01:28:18 steve Exp $" #endif # include @@ -1498,7 +1498,7 @@ void target_vvm::proc_stask(ostream&os, const NetSTask*net) defn << " vvm_calltask(sim_, \"" << net->name() << "\", " << net->nparms() << ", " << ptmp << ");" << endl; - + defn << " if (sim_->finished()) return false;" << endl; } void target_vvm::proc_utask(ostream&os, const NetUTask*net) @@ -1678,6 +1678,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.59 1999/10/06 01:28:18 steve + * The $finish task should work immediately. + * * Revision 1.58 1999/10/05 06:19:46 steve * Add support for reduction NOR. * diff --git a/vvm/vvm.h b/vvm/vvm.h index e81ac7a40..22690695b 100644 --- a/vvm/vvm.h +++ b/vvm/vvm.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvm.h,v 1.13 1999/10/05 04:02:10 steve Exp $" +#ident "$Id: vvm.h,v 1.14 1999/10/06 01:28:18 steve Exp $" #endif # include @@ -227,7 +227,11 @@ class vvm_simulation { unsigned long get_sim_time() const { return time_; } + // The s_finish() method marks the simulation as finished and + // prevents more events being executed. The finished() method + // returns true if the s_finish() method has been called. void s_finish(); + bool finished() const; private: bool going_; @@ -300,6 +304,9 @@ template class vvm_signal_t : public vvm_monitor_t { /* * $Log: vvm.h,v $ + * Revision 1.14 1999/10/06 01:28:18 steve + * The $finish task should work immediately. + * * Revision 1.13 1999/10/05 04:02:10 steve * Relaxed width handling for <= assignment. * diff --git a/vvm/vvm_simulation.cc b/vvm/vvm_simulation.cc index 40bebd496..a018d8ddd 100644 --- a/vvm/vvm_simulation.cc +++ b/vvm/vvm_simulation.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvm_simulation.cc,v 1.5 1999/09/29 02:53:33 steve Exp $" +#ident "$Id: vvm_simulation.cc,v 1.6 1999/10/06 01:28:18 steve Exp $" #endif # include "vvm.h" @@ -132,7 +132,7 @@ void vvm_simulation::run() time_ += sim_->delay; sim_->delay = 0; - for (;;) { + while (going_) { /* Look for some events to make active. If the main event list is empty, then activate the nonblock list. */ @@ -150,7 +150,7 @@ void vvm_simulation::run() if (active == 0) break; - while (active) { + while (active && going_) { vvm_event*cur = active; active = cur->next_; cur->event_function(); @@ -158,6 +158,12 @@ void vvm_simulation::run() } } + /* If the simulation was stopped by one of the events, + then break out of the loop before doing any monitor + events, and before clearing the current time. */ + if (!going_) + break; + /* XXXX Execute monitor events here. */ if (mon_) { mon_->event_function(); @@ -193,6 +199,11 @@ void vvm_simulation::s_finish() going_ = false; } +bool vvm_simulation::finished() const +{ + return !going_; +} + void vvm_simulation::thread_delay(unsigned long delay, vvm_thread*thr) { delay_event*ev = new delay_event(thr); @@ -208,6 +219,9 @@ void vvm_simulation::thread_active(vvm_thread*thr) /* * $Log: vvm_simulation.cc,v $ + * Revision 1.6 1999/10/06 01:28:18 steve + * The $finish task should work immediately. + * * Revision 1.5 1999/09/29 02:53:33 steve * Useless assertion. *