Skip to content
This repository
Browse code

Merge similar probes within a module.

  • Loading branch information...
commit fd09bc3e3ee5550e660f59b3f2409453354afaa7 1 parent e0dcdf6
authored May 27, 2000
18  elaborate.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: elaborate.cc,v 1.173 2000/05/16 04:05:16 steve Exp $"
  20
+#ident "$Id: elaborate.cc,v 1.174 2000/05/27 19:33:23 steve Exp $"
21 21
 #endif
22 22
 
23 23
 /*
@@ -1832,8 +1832,17 @@ NetProc* PEventStatement::elaborate_st(Design*des, const string&path,
1832 1832
 	   expression (and not a named event) then add this
1833 1833
 	   event. Otherwise, we didn't use it so delete it. */
1834 1834
       if (expr_count > 0) {
1835  
-	    scope->add_event(ev);
1836  
-	    wa->add_event(ev);
  1835
+	    if (NetEvent*match = ev->find_similar_event()) {
  1836
+		  cerr << "XXXX Found similar event for " <<
  1837
+			ev->name() << endl;
  1838
+		  delete ev;
  1839
+		  wa->add_event(match);
  1840
+
  1841
+	    } else {
  1842
+
  1843
+		  scope->add_event(ev);
  1844
+		  wa->add_event(ev);
  1845
+	    }
1837 1846
       } else {
1838 1847
 	    delete ev;
1839 1848
       }
@@ -2429,6 +2438,9 @@ Design* elaborate(const map<string,Module*>&modules,
2429 2438
 
2430 2439
 /*
2431 2440
  * $Log: elaborate.cc,v $
  2441
+ * Revision 1.174  2000/05/27 19:33:23  steve
  2442
+ *  Merge similar probes within a module.
  2443
+ *
2432 2444
  * Revision 1.173  2000/05/16 04:05:16  steve
2433 2445
  *  Module ports are really special PEIdent
2434 2446
  *  expressions, because a name can be used
77  net_event.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: net_event.cc,v 1.6 2000/04/18 04:50:20 steve Exp $"
  20
+#ident "$Id: net_event.cc,v 1.7 2000/05/27 19:33:23 steve Exp $"
21 21
 #endif
22 22
 
23 23
 # include  "netlist.h"
@@ -93,6 +93,73 @@ unsigned NetEvent::nwait() const
93 93
       return waitref_;
94 94
 }
95 95
 
  96
+NetEvent* NetEvent::find_similar_event()
  97
+{
  98
+      if (probes_ == 0)
  99
+	    return 0;
  100
+#define NCAND 256
  101
+      NetEvent*cand[NCAND];
  102
+      bool cflg[NCAND];
  103
+      unsigned ncand = 0;
  104
+
  105
+      NetEvProbe*cur = probes_;
  106
+
  107
+	/* First locate all the canditate events from the probe
  108
+	   objects that are connected to them. */
  109
+
  110
+      for (NetNode*idx = cur->next_node()
  111
+		 ; idx && (idx != cur) ;  idx = idx->next_node()) {
  112
+	    NetEvProbe*tmp = dynamic_cast<NetEvProbe*>(idx);
  113
+	    if (tmp == 0)
  114
+		  continue;
  115
+	    if (tmp->edge() != cur->edge())
  116
+		  continue;
  117
+
  118
+	    cand[ncand++] = tmp->event();
  119
+	    assert(ncand <= NCAND);
  120
+      }
  121
+
  122
+      for (cur = cur->enext_ ;  cur && ncand ;  cur = cur->enext_) {
  123
+	    for (unsigned idx = 0 ;  idx < ncand ;  idx += 1)
  124
+		  cflg[idx] = false;
  125
+
  126
+	    for (NetNode*idx = cur->next_node()
  127
+		       ; idx && (idx != cur) ;  idx = idx->next_node()) {
  128
+		  NetEvProbe*tmp = dynamic_cast<NetEvProbe*>(idx);
  129
+		  if (tmp == 0)
  130
+			continue;
  131
+		  if (tmp->edge() != cur->edge())
  132
+			continue;
  133
+
  134
+		  for (unsigned srch = 0 ;  srch < ncand ;  srch += 1)
  135
+			if (cand[srch] == tmp->event()) {
  136
+			      cflg[srch] = true;
  137
+			      break;
  138
+			}
  139
+	    }
  140
+
  141
+	    for (unsigned idx = 0 ;  idx < ncand ;  ) {
  142
+		  if (cflg[idx]) {
  143
+			idx += 1;
  144
+			continue;
  145
+		  }
  146
+
  147
+		  for (unsigned tmp = idx ;  idx+1 < ncand ;  idx += 1) {
  148
+			cflg[tmp] = cflg[tmp+1];
  149
+			cand[tmp] = cand[tmp+1];
  150
+		  }
  151
+		  ncand -= 1;
  152
+	    }
  153
+      }
  154
+
  155
+      for (unsigned idx = 0 ;  idx < ncand ;  idx += 1) {
  156
+	    if (cand[idx]->nprobe() == nprobe())
  157
+		  return cand[idx];
  158
+      }
  159
+
  160
+      return 0;
  161
+}
  162
+
96 163
 NetEvTrig::NetEvTrig(NetEvent*ev)
97 164
 : event_(ev)
98 165
 {
@@ -155,6 +222,11 @@ NetEvProbe::edge_t NetEvProbe::edge() const
155 222
       return edge_;
156 223
 }
157 224
 
  225
+NetEvent* NetEvProbe::event()
  226
+{
  227
+      return event_;
  228
+}
  229
+
158 230
 const NetEvent* NetEvProbe::event() const
159 231
 {
160 232
       return event_;
@@ -225,6 +297,9 @@ NetProc* NetEvWait::statement()
225 297
 
226 298
 /*
227 299
  * $Log: net_event.cc,v $
  300
+ * Revision 1.7  2000/05/27 19:33:23  steve
  301
+ *  Merge similar probes within a module.
  302
+ *
228 303
  * Revision 1.6  2000/04/18 04:50:20  steve
229 304
  *  Clean up unneeded NetEvent objects.
230 305
  *
37  netlist.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: netlist.cc,v 1.126 2000/05/19 01:43:16 steve Exp $"
  20
+#ident "$Id: netlist.cc,v 1.127 2000/05/27 19:33:23 steve Exp $"
21 21
 #endif
22 22
 
23 23
 # include  <cassert>
@@ -165,6 +165,11 @@ void Link::unlink()
165 165
       next_ = prev_ = this;
166 166
 }
167 167
 
  168
+bool Link::is_equal(const Link&that) const
  169
+{
  170
+      return (node_ == that.node_) && (pin_ == that.pin_);
  171
+}
  172
+
168 173
 bool Link::is_linked() const
169 174
 {
170 175
       return next_ != this;
@@ -399,12 +404,39 @@ const Link& NetObj::pin(unsigned idx) const
399 404
       return pins_[idx];
400 405
 }
401 406
 
  407
+NetNode::NetNode(const string&n, unsigned npins)
  408
+: NetObj(n, npins), node_next_(0), node_prev_(0), design_(0)
  409
+{
  410
+}
  411
+
402 412
 NetNode::~NetNode()
403 413
 {
404 414
       if (design_)
405 415
 	    design_->del_node(this);
406 416
 }
407 417
 
  418
+NetNode* NetNode::next_node()
  419
+{
  420
+      for (Link*pin0 = pin(0).next_link()
  421
+		 ; *pin0 != pin(0) ;  pin0 = pin0->next_link()) {
  422
+	    NetNode*cur = dynamic_cast<NetNode*>(pin0->get_obj());
  423
+	    if (cur == 0)
  424
+		  continue;
  425
+	    if (cur->pin_count() != pin_count())
  426
+		  continue;
  427
+
  428
+
  429
+	    bool flag = true;
  430
+	    for (unsigned idx = 0 ;  idx < pin_count() ;  idx += 1)
  431
+		  flag = flag && pin(idx).is_linked(cur->pin(idx));
  432
+
  433
+	    if (flag == true)
  434
+		  return cur;
  435
+      }
  436
+
  437
+      return 0;
  438
+}
  439
+
408 440
 NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
409 441
 : NetObj(n, npins), sig_next_(0), sig_prev_(0), scope_(s),
410 442
     type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0),
@@ -2604,6 +2636,9 @@ bool NetUDP::sequ_glob_(string input, char output)
2604 2636
 
2605 2637
 /*
2606 2638
  * $Log: netlist.cc,v $
  2639
+ * Revision 1.127  2000/05/27 19:33:23  steve
  2640
+ *  Merge similar probes within a module.
  2641
+ *
2607 2642
  * Revision 1.126  2000/05/19 01:43:16  steve
2608 2643
  *  Accept different widths for add operands.
2609 2644
  *
20  netlist.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: netlist.h,v 1.138 2000/05/11 23:37:27 steve Exp $"
  22
+#ident "$Id: netlist.h,v 1.139 2000/05/27 19:33:23 steve Exp $"
23 23
 #endif
24 24
 
25 25
 /*
@@ -160,8 +160,9 @@ class Link {
160 160
 	// Return true if this link is connected to any pin of r.
161 161
       bool is_linked(const NetObj&r) const;
162 162
 
163  
-      bool is_equal(const Link&that) const
164  
-      { return (node_ == that.node_) && (pin_ == that.pin_); }
  163
+	// Return true if this is the same pin of the same object of
  164
+	// that link.
  165
+      bool is_equal(const Link&that) const;
165 166
 
166 167
 	// Return information about the object that this link is
167 168
 	// a part of.
@@ -205,11 +206,14 @@ class Link {
205 206
 class NetNode  : public NetObj {
206 207
 
207 208
     public:
208  
-      explicit NetNode(const string&n, unsigned npins)
209  
-      : NetObj(n, npins), node_next_(0), node_prev_(0), design_(0) { }
  209
+      explicit NetNode(const string&n, unsigned npins);
210 210
 
211 211
       virtual ~NetNode();
212 212
 
  213
+	// This method locates the next node that has all its pins
  214
+	// connected to the same of my own pins.
  215
+      NetNode*next_node();
  216
+
213 217
       virtual void emit_node(ostream&, struct target_t*) const;
214 218
       virtual void dump_node(ostream&, unsigned) const;
215 219
 
@@ -1401,6 +1405,8 @@ class NetEvent : public LineInfo {
1401 1405
       NetScope* scope();
1402 1406
       const NetScope* scope() const;
1403 1407
 
  1408
+      NetEvent* find_similar_event();
  1409
+
1404 1410
     private:
1405 1411
       string name_;
1406 1412
 
@@ -1479,6 +1485,7 @@ class NetEvProbe  : public NetNode {
1479 1485
       ~NetEvProbe();
1480 1486
 
1481 1487
       edge_t edge() const;
  1488
+      NetEvent* event();
1482 1489
       const NetEvent* event() const;
1483 1490
 
1484 1491
       virtual void emit_node(ostream&, struct target_t*) const;
@@ -2575,6 +2582,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
2575 2582
 
2576 2583
 /*
2577 2584
  * $Log: netlist.h,v $
  2585
+ * Revision 1.139  2000/05/27 19:33:23  steve
  2586
+ *  Merge similar probes within a module.
  2587
+ *
2578 2588
  * Revision 1.138  2000/05/11 23:37:27  steve
2579 2589
  *  Add support for procedural continuous assignment.
2580 2590
  *

0 notes on commit fd09bc3

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