Permalink
Browse files

Simulate named event trigger and waits.

  • Loading branch information...
steve
steve committed Apr 4, 2000
1 parent b62a7ac commit 30e828923970546025480eb08ec73cf8973f4131
Showing with 544 additions and 126 deletions.
  1. +3 −2 Makefile.in
  2. +8 −1 PEvent.h
  3. +26 −1 design_dump.cc
  4. +61 −5 elaborate.cc
  5. +23 −1 emit.cc
  6. +82 −0 net_event.cc
  7. +160 −0 net_scope.cc
  8. +5 −112 netlist.cc
  9. +92 −1 netlist.h
  10. +51 −1 t-vvm.cc
  11. +24 −1 target.cc
  12. +9 −1 target.h
View
@@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.42 2000/04/01 19:31:57 steve Exp $"
+#ident "$Id: Makefile.in,v 1.43 2000/04/04 03:20:15 steve Exp $"
#
#
SHELL = /bin/sh
@@ -72,7 +72,8 @@ FF = nobufz.o nodangle.o propinit.o synth.o xnfio.o xnfsyn.o
O = main.o cprop.o design_dump.o dup_expr.o elaborate.o elab_expr.o \
elab_net.o elab_pexpr.o elab_scope.o emit.o eval.o eval_tree.o \
expr_synth.o functor.o lexor.o lexor_keyword.o mangle.o netlist.o \
-net_design.o net_udp.o nexus_from_link.o pad_to_width.o \
+net_design.o net_event.o net_scope.o net_udp.o nexus_from_link.o \
+pad_to_width.o \
parse.o parse_misc.o pform.o pform_dump.o \
set_width.o \
verinum.o verireal.o target.o targets.o Module.o PDelays.o PEvent.o \
View
@@ -19,12 +19,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: PEvent.h,v 1.1 2000/04/01 19:31:57 steve Exp $"
+#ident "$Id: PEvent.h,v 1.2 2000/04/04 03:20:15 steve Exp $"
#endif
# include "LineInfo.h"
# include <string>
class ostream;
+class Design;
+class NetScope;
/*
* The PEvent class represents event objects. These are things that
@@ -38,6 +40,8 @@ class PEvent : public LineInfo {
string name() const;
+ void elaborate(Design*des, NetScope*scope) const;
+
private:
string name_;
@@ -48,6 +52,9 @@ class PEvent : public LineInfo {
/*
* $Log: PEvent.h,v $
+ * Revision 1.2 2000/04/04 03:20:15 steve
+ * Simulate named event trigger and waits.
+ *
* Revision 1.1 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: design_dump.cc,v 1.72 2000/04/02 04:26:06 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.73 2000/04/04 03:20:15 steve Exp $"
#endif
/*
@@ -527,6 +527,22 @@ void NetCondit::dump(ostream&o, unsigned ind) const
}
}
+void NetEvTrig::dump(ostream&o, unsigned ind) const
+{
+ o << setw(ind) << "" << "-> " << event_->name() << "; "
+ << "// " << get_line() << endl;
+}
+
+void NetEvWait::dump(ostream&o, unsigned ind) const
+{
+ o << setw(ind) << "" << "@" << event_->name()
+ << " // " << get_line() << endl;
+ if (statement_)
+ statement_->dump(o, ind+2);
+ else
+ o << setw(ind+2) << "" << "/* noop */ ;" << endl;
+}
+
void NetForever::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "forever" << endl;
@@ -648,6 +664,12 @@ void NetScope::dump(ostream&o) const
}
}
+ /* Dump the events in this scope. */
+ for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) {
+ o << " event " << cur->name() << "; "
+ << "// " << cur->get_line() << endl;
+ }
+
/* Dump any sub-scopes. */
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_)
cur->dump(o);
@@ -906,6 +928,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.73 2000/04/04 03:20:15 steve
+ * Simulate named event trigger and waits.
+ *
* Revision 1.72 2000/04/02 04:26:06 steve
* Remove the useless sref template.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: elaborate.cc,v 1.153 2000/04/01 22:14:19 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.154 2000/04/04 03:20:15 steve Exp $"
#endif
/*
@@ -30,6 +30,7 @@
# include <typeinfo>
# include <strstream>
# include "pform.h"
+# include "PEvent.h"
# include "netlist.h"
# include "netmisc.h"
@@ -47,6 +48,13 @@ string Design::local_symbol(const string&path)
static const map<string,Module*>* modlist = 0;
static const map<string,PUdp*>* udplist = 0;
+void PEvent::elaborate(Design*des, NetScope*scope) const
+{
+ NetEvent*ev = new NetEvent(name_);
+ ev->set_line(*this);
+ scope->add_event(ev);
+}
+
/*
* Elaborate a source wire. The "wire" is the declaration of wires,
* registers, ports and memories. The parser has already merged the
@@ -1540,6 +1548,30 @@ NetProc* PDelayStatement::elaborate(Design*des, const string&path) const
NetProc* PEventStatement::elaborate_st(Design*des, const string&path,
NetProc*enet) const
{
+ NetScope*scope = des->find_scope(path);
+ assert(scope);
+
+ /* Handle as a special case the block on an event. In this
+ case I generate a NetEvWait object to represent me.
+
+ XXXX Do I want to move all event handling to NetEvent style
+ event support? I think I do. */
+
+ if ((expr_.count() == 1) && (expr_[0]->expr() == 0)) {
+ string ename = expr_[0]->name();
+ NetEvent*ev = scope->find_event(ename);
+ if (ev == 0) {
+ cerr << get_line() << ": error: no such named event "
+ << "``" << ename << "''." << endl;
+ des->errors += 1;
+ return 0;
+ }
+
+ NetEvWait*pr = new NetEvWait(ev, enet);
+ pr->set_line(*this);
+ return pr;
+ }
+
/* Create a single NetPEvent, and a unique NetNEvent for each
conjuctive event. An NetNEvent can have many pins only if
@@ -1837,10 +1869,20 @@ void PTask::elaborate_2(Design*des, const string&path) const
NetProc* PTrigger::elaborate(Design*des, const string&path) const
{
- cerr << get_line() << ": sorry: named event trigger not supported."
- << endl;
- des->errors += 1;
- return 0;
+ NetScope*scope = des->find_scope(path);
+ assert(scope);
+
+ NetEvent*ev = scope->find_event(event_);
+ if (ev == 0) {
+ cerr << get_line() << ": error: event <" << event_ << ">"
+ << " not found." << endl;
+ des->errors += 1;
+ return 0;
+ }
+
+ NetEvTrig*trig = new NetEvTrig(ev);
+ trig->set_line(*this);
+ return trig;
}
/*
@@ -1856,11 +1898,22 @@ NetProc* PWhile::elaborate(Design*des, const string&path) const
return loop;
}
+/*
+ * When a module is instantiated, it creates the scope then uses this
+ * method to elaborate the contents of the module.
+ */
bool Module::elaborate(Design*des, NetScope*scope) const
{
const string path = scope->name();
bool result_flag = true;
+ // Scan through the named events and elaborate them.
+ for (map<string,PEvent*>::const_iterator et = events.begin()
+ ; et != events.end() ; et ++ ) {
+
+ (*et).second->elaborate(des, scope);
+
+ }
// Get all the explicitly declared wires of the module and
// start the signals list with them.
@@ -2018,6 +2071,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
+ * Revision 1.154 2000/04/04 03:20:15 steve
+ * Simulate named event trigger and waits.
+ *
* Revision 1.153 2000/04/01 22:14:19 steve
* detect unsupported block on named events.
*
View
24 emit.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: emit.cc,v 1.36 2000/04/01 21:40:22 steve Exp $"
+#ident "$Id: emit.cc,v 1.37 2000/04/04 03:20:15 steve Exp $"
#endif
/*
@@ -248,6 +248,21 @@ void NetCondit::emit_recurse_else(ostream&o, struct target_t*tgt) const
else_->emit_proc(o, tgt);
}
+bool NetEvTrig::emit_proc(ostream&o, struct target_t*tgt) const
+{
+ return tgt->proc_trigger(o, this);
+}
+
+bool NetEvWait::emit_proc(ostream&o, struct target_t*tgt) const
+{
+ return tgt->proc_wait(o, this);
+}
+
+bool NetEvWait::emit_recurse(ostream&o, struct target_t*tgt) const
+{
+ return statement_->emit_proc(o, tgt);
+}
+
void NetForever::emit_recurse(ostream&o, struct target_t*tgt) const
{
if (statement_)
@@ -263,6 +278,10 @@ void NetRepeat::emit_recurse(ostream&o, struct target_t*tgt) const
void NetScope::emit_scope(ostream&o, struct target_t*tgt) const
{
tgt->scope(o, this);
+
+ for (NetEvent*cur = events_ ; cur ; cur = cur->snext_)
+ tgt->event(o, cur);
+
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_)
cur->emit_scope(o, tgt);
}
@@ -407,6 +426,9 @@ bool emit(ostream&o, const Design*des, const char*type)
/*
* $Log: emit.cc,v $
+ * Revision 1.37 2000/04/04 03:20:15 steve
+ * Simulate named event trigger and waits.
+ *
* Revision 1.36 2000/04/01 21:40:22 steve
* Add support for integer division.
*
View
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2000 Stephen Williams (steve@icarus.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#if !defined(WINNT) && !defined(macintosh)
+#ident "$Id: net_event.cc,v 1.1 2000/04/04 03:20:15 steve Exp $"
+#endif
+
+# include "netlist.h"
+
+NetEvent::NetEvent(const string&n)
+: name_(n)
+{
+ scope_ = 0;
+ snext_ = 0;
+}
+
+NetEvent::~NetEvent()
+{
+}
+
+string NetEvent::name() const
+{
+ return name_;
+}
+
+string NetEvent::full_name() const
+{
+ assert(scope_);
+ return scope_->name() + "." + name_;
+}
+
+NetEvTrig::NetEvTrig(NetEvent*ev)
+: event_(ev)
+{
+}
+
+NetEvTrig::~NetEvTrig()
+{
+}
+
+const NetEvent* NetEvTrig::event() const
+{
+ return event_;
+}
+
+NetEvWait::NetEvWait(NetEvent*ev, NetProc*pr)
+: event_(ev), statement_(pr)
+{
+}
+
+NetEvWait::~NetEvWait()
+{
+ delete statement_;
+}
+
+const NetEvent* NetEvWait::event() const
+{
+ return event_;
+}
+
+/*
+ * $Log: net_event.cc,v $
+ * Revision 1.1 2000/04/04 03:20:15 steve
+ * Simulate named event trigger and waits.
+ *
+ */
+
Oops, something went wrong.

0 comments on commit 30e8289

Please sign in to comment.