Skip to content
This repository
Browse code

Support chained events.

  • Loading branch information...
commit d03350935977af14b3064a70e4b2681a1e3d4748 1 parent 62c6422
steve authored

Showing 3 changed files with 79 additions and 11 deletions. Show diff stats Hide diff stats

  1. +35 8 t-vvm.cc
  2. +18 1 vvm/vvm_gates.h
  3. +26 2 vvm/vvm_pevent.cc
43 t-vvm.cc
@@ -17,7 +17,7 @@
17 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 18 */
19 19 #if !defined(WINNT) && !defined(macintosh)
20   -#ident "$Id: t-vvm.cc,v 1.135 2000/04/14 23:31:53 steve Exp $"
  20 +#ident "$Id: t-vvm.cc,v 1.136 2000/04/15 02:25:32 steve Exp $"
21 21 #endif
22 22
23 23 # include <iostream>
@@ -150,6 +150,8 @@ class target_vvm : public target_t {
150 150
151 151 map<verinum,unsigned,less_verinum>number_constants;
152 152 unsigned number_counter;
  153 +
  154 + unsigned selector_counter;
153 155 };
154 156
155 157
@@ -745,6 +747,7 @@ void target_vvm::start_design(ostream&os, const Design*mod)
745 747 string_counter = 1;
746 748 number_counter = 1;
747 749 nexus_wire_counter = 1;
  750 + selector_counter = 0;
748 751
749 752 init_code << "static void design_init()" << endl;
750 753 init_code << "{" << endl;
@@ -2418,13 +2421,34 @@ bool target_vvm::proc_wait(ostream&os, const NetEvWait*wait)
2418 2421 defn << " thr->step_ = &" << thread_class_ << "_step_"
2419 2422 << out_step << "_;" << endl;
2420 2423
2421   - for (unsigned idx = 0 ; idx < wait->nevents() ; idx+= 1) {
2422   - const NetEvent*ev = wait->event(idx);
2423   - assert(ev);
2424   - string ename = mangle(ev->full_name());
2425   - defn << " " << ename << ".wait(thr); // "
2426   - << wait->get_line() << ": @" << ev->full_name()
2427   - << "..." << endl;
  2424 + if (wait->nevents() == 1) {
  2425 + const NetEvent*ev = wait->event(0);
  2426 + assert(ev);
  2427 + string ename = mangle(ev->full_name());
  2428 + defn << " " << ename << ".wait(thr); // "
  2429 + << wait->get_line() << ": @" << ev->full_name()
  2430 + << "..." << endl;
  2431 +
  2432 + } else {
  2433 + /* If there are many events to wait for, generate a
  2434 + selector that is a vvm_sync that I chain to the
  2435 + source vvm_sync objects. Then, wait on the selector
  2436 + object instead. */
  2437 + unsigned id = selector_counter++;
  2438 + os << "static vvm_sync selector_" << id << ";" << endl;
  2439 +
  2440 + for (unsigned idx = 0 ; idx < wait->nevents() ; idx+= 1) {
  2441 + const NetEvent*ev = wait->event(idx);
  2442 + assert(ev);
  2443 + string ename = mangle(ev->full_name());
  2444 + init_code << " selector_" << id
  2445 + << ".chain_sync(&" << ename << "); // "
  2446 + << wait->get_line() << ": @" << ev->full_name()
  2447 + << "..." << endl;
  2448 + }
  2449 +
  2450 + defn << " selector_" << id << ".wait(thr);"
  2451 + << endl;
2428 2452 }
2429 2453
2430 2454 defn << " return false;" << endl;
@@ -2541,6 +2565,9 @@ extern const struct target tgt_vvm = {
2541 2565 };
2542 2566 /*
2543 2567 * $Log: t-vvm.cc,v $
  2568 + * Revision 1.136 2000/04/15 02:25:32 steve
  2569 + * Support chained events.
  2570 + *
2544 2571 * Revision 1.135 2000/04/14 23:31:53 steve
2545 2572 * No more class derivation from vvm_thread.
2546 2573 *
19 vvm/vvm_gates.h
@@ -19,7 +19,7 @@
19 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 20 */
21 21 #if !defined(WINNT) && !defined(macintosh)
22   -#ident "$Id: vvm_gates.h,v 1.56 2000/04/10 05:26:07 steve Exp $"
  22 +#ident "$Id: vvm_gates.h,v 1.57 2000/04/15 02:25:32 steve Exp $"
23 23 #endif
24 24
25 25 # include "vvm.h"
@@ -795,7 +795,15 @@ class vvm_bufz : public vvm_nexus::recvr_t, public vvm_nexus::drive_t {
795 795 * Threads use the vvm_sync to wait for something to happen. This
796 796 * class cooperates with the various event source classes that receive
797 797 * events and trigger the associated vvm_sync object.
  798 + *
  799 + * CHAINING
  800 + * A thread can only wait on one vvm_sync object. To get the effect of
  801 + * waiting on many vvm_sync objects, vvm_sync objects can be
  802 + * chained. That is, a vvm_sync object can be configured to receive
  803 + * triggers from other vvm_sync objects. That is the job of the
  804 + * chain_sync() method.
798 805 */
  806 +
799 807 class vvm_sync {
800 808
801 809 public:
@@ -804,9 +812,15 @@ class vvm_sync {
804 812 void wait(vvm_thread*);
805 813 void wakeup();
806 814
  815 + // Receive triggers from the specified source.
  816 + void chain_sync(vvm_sync*src);
  817 +
807 818 private:
808 819 vvm_thread*hold_;
809 820
  821 + vvm_sync**tgt_;
  822 + unsigned ntgt_;
  823 +
810 824 private: // not implemented
811 825 vvm_sync(const vvm_sync&);
812 826 vvm_sync& operator= (const vvm_sync&);
@@ -873,6 +887,9 @@ class vvm_posedge : public vvm_nexus::recvr_t {
873 887
874 888 /*
875 889 * $Log: vvm_gates.h,v $
  890 + * Revision 1.57 2000/04/15 02:25:32 steve
  891 + * Support chained events.
  892 + *
876 893 * Revision 1.56 2000/04/10 05:26:07 steve
877 894 * All events now use the NetEvent class.
878 895 *
28 vvm/vvm_pevent.cc
@@ -17,7 +17,7 @@
17 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 18 */
19 19 #if !defined(WINNT) && !defined(macintosh)
20   -#ident "$Id: vvm_pevent.cc,v 1.8 2000/04/12 16:08:46 steve Exp $"
  20 +#ident "$Id: vvm_pevent.cc,v 1.9 2000/04/15 02:25:32 steve Exp $"
21 21 #endif
22 22
23 23 # include "vvm.h"
@@ -25,7 +25,7 @@
25 25 # include "vvm_thread.h"
26 26
27 27 vvm_sync::vvm_sync()
28   -: hold_(0)
  28 +: hold_(0), tgt_(0), ntgt_(0)
29 29 {
30 30 }
31 31
@@ -45,9 +45,30 @@ void vvm_sync::wakeup()
45 45 assert(tmp->sync_back_ == this);
46 46 tmp->sync_back_ = 0;
47 47 tmp->thread_yield();
  48 +
  49 + for (unsigned idx = 0 ; idx < ntgt_ ; idx += 1)
  50 + tgt_[idx]->wakeup();
48 51 }
49 52 }
50 53
  54 +void vvm_sync::chain_sync(vvm_sync*src)
  55 +{
  56 + if (src->ntgt_ == 0) {
  57 + src->tgt_ = new vvm_sync*[1];
  58 + src->tgt_[0] = this;
  59 + src->ntgt_ = 1;
  60 +
  61 + } else {
  62 + vvm_sync**tmp = new vvm_sync*[src->ntgt_+1];
  63 + for (unsigned idx = 0 ; idx < src->ntgt_ ; idx += 1)
  64 + tmp[idx] = src->tgt_[idx];
  65 +
  66 + tmp[src->ntgt_] = this;
  67 + src->ntgt_ += 1;
  68 + delete [] src->tgt_;
  69 + src->tgt_ = tmp;
  70 + }
  71 +}
51 72
52 73 vvm_posedge::vvm_posedge(vvm_sync*tgt)
53 74 : sync_(tgt)
@@ -136,6 +157,9 @@ void vvm_anyedge::take_value(unsigned key, vpip_bit_t val)
136 157
137 158 /*
138 159 * $Log: vvm_pevent.cc,v $
  160 + * Revision 1.9 2000/04/15 02:25:32 steve
  161 + * Support chained events.
  162 + *
139 163 * Revision 1.8 2000/04/12 16:08:46 steve
140 164 * Backwards sense of assert test.
141 165 *

0 comments on commit d033509

Please sign in to comment.
Something went wrong with that request. Please try again.