diff --git a/expr_synth.cc b/expr_synth.cc index 530c34afa..cd702fa76 100644 --- a/expr_synth.cc +++ b/expr_synth.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: expr_synth.cc,v 1.10 2000/02/23 02:56:54 steve Exp $" +#ident "$Id: expr_synth.cc,v 1.11 2000/04/16 23:32:18 steve Exp $" #endif # include "netlist.h" @@ -120,6 +120,61 @@ NetNet* NetEBBits::synthesize(Design*des) return osig; } +NetNet* NetEBComp::synthesize(Design*des) +{ + string path = des->local_symbol("SYNTH"); + NetNet*lsig = left_->synthesize(des); + NetNet*rsig = right_->synthesize(des); + + unsigned width = lsig->pin_count(); + if (rsig->pin_count() > lsig->pin_count()) + width = rsig->pin_count(); + + NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, 1); + osig->local_flag(true); + + NetCompare*dev = new NetCompare(des->local_symbol(path), width); + des->add_node(dev); + + for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) + connect(dev->pin_DataA(idx), lsig->pin(idx)); + + for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1) + connect(dev->pin_DataB(idx), rsig->pin(idx)); + + + switch (op_) { + case '<': + connect(dev->pin_ALB(), osig->pin(0)); + break; + case '>': + connect(dev->pin_AGB(), osig->pin(0)); + break; + case 'e': // == + case 'E': // === ? + connect(dev->pin_AEB(), osig->pin(0)); + break; + case 'G': // >= + connect(dev->pin_AGEB(), osig->pin(0)); + break; + case 'L': // <= + connect(dev->pin_ALEB(), osig->pin(0)); + break; + case 'n': // != + case 'N': // !== + connect(dev->pin_ANEB(), osig->pin(0)); + break; + + default: + cerr << get_line() << ": internal error: cannot synthesize " + "comparison: " << *this << endl; + des->errors += 1; + return 0; + } + + return osig; +} + NetNet* NetEConcat::synthesize(Design*des) { assert(repeat_ == 1); @@ -228,6 +283,12 @@ NetNet* NetESignal::synthesize(Design*des) /* * $Log: expr_synth.cc,v $ + * Revision 1.11 2000/04/16 23:32:18 steve + * Synthesis of comparator in expressions. + * + * Connect the NetEvent and related classes + * together better. + * * Revision 1.10 2000/02/23 02:56:54 steve * Macintosh compilers do not support ident. * diff --git a/functor.cc b/functor.cc index 283b51a45..69599723a 100644 --- a/functor.cc +++ b/functor.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: functor.cc,v 1.14 2000/04/12 20:02:53 steve Exp $" +#ident "$Id: functor.cc,v 1.15 2000/04/16 23:32:18 steve Exp $" #endif # include "functor.h" @@ -173,7 +173,6 @@ int proc_match_t::condit(NetCondit*) int NetCondit::match_proc(proc_match_t*that) { - cerr << "NetCondit::match_proc" << endl; return that->condit(this); } @@ -189,6 +188,12 @@ int proc_match_t::event_wait(NetEvWait*) /* * $Log: functor.cc,v $ + * Revision 1.15 2000/04/16 23:32:18 steve + * Synthesis of comparator in expressions. + * + * Connect the NetEvent and related classes + * together better. + * * Revision 1.14 2000/04/12 20:02:53 steve * Finally remove the NetNEvent and NetPEvent classes, * Get synthesis working with the NetEvWait class, diff --git a/net_event.cc b/net_event.cc index 174105787..a4bf351a2 100644 --- a/net_event.cc +++ b/net_event.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_event.cc,v 1.4 2000/04/12 20:02:53 steve Exp $" +#ident "$Id: net_event.cc,v 1.5 2000/04/16 23:32:18 steve Exp $" #endif # include "netlist.h" @@ -28,10 +28,13 @@ NetEvent::NetEvent(const string&n) scope_ = 0; snext_ = 0; probes_ = 0; + trig_ = 0; + waitref_ = 0; } NetEvent::~NetEvent() { + assert(waitref_ == 0); } string NetEvent::name() const @@ -67,13 +70,32 @@ NetEvProbe* NetEvent::probe(unsigned idx) return cur; } +unsigned NetEvent::nwait() const +{ + return waitref_; +} + NetEvTrig::NetEvTrig(NetEvent*ev) : event_(ev) { + enext_ = event_->trig_; + event_->trig_ = this; } NetEvTrig::~NetEvTrig() { + if (event_->trig_ == this) { + event_->trig_ = enext_; + + } else { + NetEvTrig*cur = event_->trig_; + while (cur->enext_ != this) { + assert(cur->enext_); + cur = cur->enext_; + } + + cur->enext_ = this->enext_; + } } const NetEvent* NetEvTrig::event() const @@ -96,6 +118,18 @@ NetEvProbe::NetEvProbe(const string&n, NetEvent*tgt, NetEvProbe::~NetEvProbe() { + if (event_->probes_ == this) { + event_->probes_ = enext_; + + } else { + NetEvProbe*cur = event_->probes_; + while (cur->enext_ != this) { + assert(cur->enext_); + cur = cur->enext_; + } + + cur->enext_ = this->enext_; + } } NetEvProbe::edge_t NetEvProbe::edge() const @@ -115,7 +149,13 @@ NetEvWait::NetEvWait(NetProc*pr) NetEvWait::~NetEvWait() { - if (events_) delete[]events_; + if (events_) { + for (unsigned idx = 0 ; idx < nevents_ ; idx += 1) { + NetEvent*tgt = events_[idx]; + tgt->waitref_ -= 1; + } + delete[]events_; + } delete statement_; } @@ -137,6 +177,10 @@ void NetEvWait::add_event(NetEvent*tgt) events_[nevents_] = tgt; nevents_ += 1; + + // Remember to tell the NetEvent that there is someone + // pointing to it. + tgt->waitref_ += 1; } unsigned NetEvWait::nevents() const @@ -163,6 +207,12 @@ NetProc* NetEvWait::statement() /* * $Log: net_event.cc,v $ + * Revision 1.5 2000/04/16 23:32:18 steve + * Synthesis of comparator in expressions. + * + * Connect the NetEvent and related classes + * together better. + * * Revision 1.4 2000/04/12 20:02:53 steve * Finally remove the NetNEvent and NetPEvent classes, * Get synthesis working with the NetEvWait class, diff --git a/netlist.cc b/netlist.cc index 82f51b8a1..78ced48d8 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.cc,v 1.114 2000/04/15 19:51:30 steve Exp $" +#ident "$Id: netlist.cc,v 1.115 2000/04/16 23:32:19 steve Exp $" #endif # include @@ -1688,6 +1688,12 @@ NetExpr* NetCondit::expr() return expr_; } +void NetCondit::set_expr(NetExpr*ex) +{ + delete expr_; + expr_ = ex; +} + NetProc* NetCondit::if_clause() { return if_; @@ -2462,6 +2468,12 @@ bool NetUDP::sequ_glob_(string input, char output) /* * $Log: netlist.cc,v $ + * Revision 1.115 2000/04/16 23:32:19 steve + * Synthesis of comparator in expressions. + * + * Connect the NetEvent and related classes + * together better. + * * Revision 1.114 2000/04/15 19:51:30 steve * fork-join support in vvm. * diff --git a/netlist.h b/netlist.h index 790a699df..1cfa59c28 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.h,v 1.122 2000/04/15 19:51:30 steve Exp $" +#ident "$Id: netlist.h,v 1.123 2000/04/16 23:32:19 steve Exp $" #endif /* @@ -1240,6 +1240,9 @@ class NetCondit : public NetProc { NetProc* if_clause(); NetProc* else_clause(); + // Replace the condition expression. + void set_expr(NetExpr*ex); + void emit_recurse_if(ostream&, struct target_t*) const; void emit_recurse_else(ostream&, struct target_t*) const; @@ -1271,17 +1274,22 @@ class NetCondit : public NetProc { * * The NetEvTrig class represents trigger statements. Executing this * statement causes the referenced event to be triggered, which it - * turn awakens the waiting threads. + * turn awakens the waiting threads. Each NetEvTrig object references + * exactly one event object. * * The NetEvProbe class is the structural equivilent of the NetEvTrig, * in that it is a node and watches bit values that it receives. It * checks for edges then if appropriate triggers the associated - * NetEvent. + * NetEvent. Each NetEvProbe references exactly one event object, and + * the NetEvent objects have a list of NetEvProbe objects that + * reference it. */ class NetEvent : public LineInfo { friend class NetScope; friend class NetEvProbe; + friend class NetEvTrig; + friend class NetEvWait; public: explicit NetEvent (const string&n); @@ -1294,6 +1302,9 @@ class NetEvent : public LineInfo { unsigned nprobe() const; NetEvProbe* probe(unsigned); + // Return the number of NetEvWait nodes that reference me. + unsigned nwait() const; + NetScope* scope(); const NetScope* scope() const; @@ -1307,6 +1318,12 @@ class NetEvent : public LineInfo { // Use these methods to list the probes attached to me. NetEvProbe*probes_; + // Use these methods to list the triggers attached to me. + NetEvTrig* trig_; + + // Use This member to count references by NetEvWait objects. + unsigned waitref_; + private: // not implemented NetEvent(const NetEvent&); NetEvent& operator= (const NetEvent&); @@ -1325,6 +1342,8 @@ class NetEvTrig : public NetProc { private: NetEvent*event_; + // This is used to place me in the NetEvents lists of triggers. + NetEvTrig*enext_; }; class NetEvWait : public NetProc { @@ -1754,6 +1773,8 @@ class NetEBComp : public NetEBinary { virtual NetEBComp* dup_expr() const; virtual NetEConst* eval_tree(); + virtual NetNet* synthesize(Design*); + private: NetEConst*eval_eqeq_(); NetEConst*eval_leeq_(); @@ -2353,6 +2374,12 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.123 2000/04/16 23:32:19 steve + * Synthesis of comparator in expressions. + * + * Connect the NetEvent and related classes + * together better. + * * Revision 1.122 2000/04/15 19:51:30 steve * fork-join support in vvm. *