2 * Copyright (c) 2000 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #if !defined(WINNT) && !defined(macintosh)
20 #ident "$Id: net_event.cc,v 1.7 2000/05/27 19:33:23 steve Exp $"
25 NetEvent::NetEvent(const string
&n
)
37 assert(waitref_
== 0);
38 if (scope_
) scope_
->rem_event(this);
40 NetEvProbe
*tmp
= probes_
->enext_
;
46 string
NetEvent::name() const
51 string
NetEvent::full_name() const
54 return scope_
->name() + "." + name_
;
57 unsigned NetEvent::nprobe() const
60 NetEvProbe
*cur
= probes_
;
69 NetEvProbe
* NetEvent::probe(unsigned idx
)
71 NetEvProbe
*cur
= probes_
;
79 unsigned NetEvent::ntrig() const
82 NetEvTrig
*cur
= trig_
;
91 unsigned NetEvent::nwait() const
96 NetEvent
* NetEvent::find_similar_event()
101 NetEvent
*cand
[NCAND
];
105 NetEvProbe
*cur
= probes_
;
107 /* First locate all the canditate events from the probe
108 objects that are connected to them. */
110 for (NetNode
*idx
= cur
->next_node()
111 ; idx
&& (idx
!= cur
) ; idx
= idx
->next_node()) {
112 NetEvProbe
*tmp
= dynamic_cast<NetEvProbe
*>(idx
);
115 if (tmp
->edge() != cur
->edge())
118 cand
[ncand
++] = tmp
->event();
119 assert(ncand
<= NCAND
);
122 for (cur
= cur
->enext_
; cur
&& ncand
; cur
= cur
->enext_
) {
123 for (unsigned idx
= 0 ; idx
< ncand
; idx
+= 1)
126 for (NetNode
*idx
= cur
->next_node()
127 ; idx
&& (idx
!= cur
) ; idx
= idx
->next_node()) {
128 NetEvProbe
*tmp
= dynamic_cast<NetEvProbe
*>(idx
);
131 if (tmp
->edge() != cur
->edge())
134 for (unsigned srch
= 0 ; srch
< ncand
; srch
+= 1)
135 if (cand
[srch
] == tmp
->event()) {
141 for (unsigned idx
= 0 ; idx
< ncand
; ) {
147 for (unsigned tmp
= idx
; idx
+1 < ncand
; idx
+= 1) {
148 cflg
[tmp
] = cflg
[tmp
+1];
149 cand
[tmp
] = cand
[tmp
+1];
155 for (unsigned idx
= 0 ; idx
< ncand
; idx
+= 1) {
156 if (cand
[idx
]->nprobe() == nprobe())
163 NetEvTrig::NetEvTrig(NetEvent
*ev
)
166 enext_
= event_
->trig_
;
167 event_
->trig_
= this;
170 NetEvTrig::~NetEvTrig()
172 if (event_
->trig_
== this) {
173 event_
->trig_
= enext_
;
176 NetEvTrig
*cur
= event_
->trig_
;
177 while (cur
->enext_
!= this) {
182 cur
->enext_
= this->enext_
;
186 const NetEvent
* NetEvTrig::event() const
191 NetEvProbe::NetEvProbe(const string
&n
, NetEvent
*tgt
,
192 edge_t t
, unsigned p
)
193 : NetNode(n
, p
), event_(tgt
), edge_(t
)
195 for (unsigned idx
= 0 ; idx
< p
; idx
+= 1) {
196 pin(idx
).set_dir(Link::INPUT
);
197 pin(idx
).set_name("P", idx
);
200 enext_
= event_
->probes_
;
201 event_
->probes_
= this;
204 NetEvProbe::~NetEvProbe()
206 if (event_
->probes_
== this) {
207 event_
->probes_
= enext_
;
210 NetEvProbe
*cur
= event_
->probes_
;
211 while (cur
->enext_
!= this) {
216 cur
->enext_
= this->enext_
;
220 NetEvProbe::edge_t
NetEvProbe::edge() const
225 NetEvent
* NetEvProbe::event()
230 const NetEvent
* NetEvProbe::event() const
235 NetEvWait::NetEvWait(NetProc
*pr
)
236 : statement_(pr
), nevents_(0), events_(0)
240 NetEvWait::~NetEvWait()
243 for (unsigned idx
= 0 ; idx
< nevents_
; idx
+= 1) {
244 NetEvent
*tgt
= events_
[idx
];
252 void NetEvWait::add_event(NetEvent
*tgt
)
256 events_
= new NetEvent
*[1];
259 NetEvent
**tmp
= new NetEvent
*[nevents_
+1];
260 for (unsigned idx
= 0 ; idx
< nevents_
; idx
+= 1) {
261 tmp
[idx
] = events_
[idx
];
262 assert(tmp
[idx
] != tgt
);
268 events_
[nevents_
] = tgt
;
271 // Remember to tell the NetEvent that there is someone
276 unsigned NetEvWait::nevents() const
281 const NetEvent
* NetEvWait::event(unsigned idx
) const
283 assert(idx
< nevents_
);
287 NetEvent
* NetEvWait::event(unsigned idx
)
289 assert(idx
< nevents_
);
293 NetProc
* NetEvWait::statement()
299 * $Log: net_event.cc,v $
300 * Revision 1.7 2000/05/27 19:33:23 steve
301 * Merge similar probes within a module.
303 * Revision 1.6 2000/04/18 04:50:20 steve
304 * Clean up unneeded NetEvent objects.
306 * Revision 1.5 2000/04/16 23:32:18 steve
307 * Synthesis of comparator in expressions.
309 * Connect the NetEvent and related classes
312 * Revision 1.4 2000/04/12 20:02:53 steve
313 * Finally remove the NetNEvent and NetPEvent classes,
314 * Get synthesis working with the NetEvWait class,
315 * and get started supporting multiple events in a
318 * Revision 1.3 2000/04/12 04:23:58 steve
319 * Named events really should be expressed with PEIdent
320 * objects in the pform,
322 * Handle named events within the mix of net events
323 * and edges. As a unified lot they get caught together.
324 * wait statements are broken into more complex statements
325 * that include a conditional.
327 * Do not generate NetPEvent or NetNEvent objects in
328 * elaboration. NetEvent, NetEvWait and NetEvProbe
329 * take over those functions in the netlist.
331 * Revision 1.2 2000/04/10 05:26:06 steve
332 * All events now use the NetEvent class.
334 * Revision 1.1 2000/04/04 03:20:15 steve
335 * Simulate named event trigger and waits.