Skip to content

Commit

Permalink
Handle wide events, such as @(a) where a has
Browse files Browse the repository at this point in the history
 many bits in it.

 Add to vvm the binary ^ and unary & operators.

 Dump events a bit more completely.
  • Loading branch information
steve committed May 1, 1999
1 parent 41f9a84 commit 5d00f17
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 48 deletions.
13 changes: 11 additions & 2 deletions design_dump.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.19 1999/05/01 02:57:52 steve Exp $" #ident "$Id: design_dump.cc,v 1.20 1999/05/01 20:43:55 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -251,6 +251,7 @@ void NetNEvent::dump_node(ostream&o, unsigned ind) const
o << setw(ind) << "" << "event: "; o << setw(ind) << "" << "event: ";
switch (edge_) { switch (edge_) {
case ANYEDGE: case ANYEDGE:
o << "anyedge ";
break; break;
case POSEDGE: case POSEDGE:
o << "posedge "; o << "posedge ";
Expand All @@ -263,7 +264,7 @@ void NetNEvent::dump_node(ostream&o, unsigned ind) const
break; break;
} }


o << name() << endl; o << name() << " --> " << fore_ptr()->name() << endl;


dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
} }
Expand Down Expand Up @@ -562,6 +563,14 @@ void Design::dump(ostream&o) const


/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.20 1999/05/01 20:43:55 steve
* Handle wide events, such as @(a) where a has
* many bits in it.
*
* Add to vvm the binary ^ and unary & operators.
*
* Dump events a bit more completely.
*
* Revision 1.19 1999/05/01 02:57:52 steve * Revision 1.19 1999/05/01 02:57:52 steve
* Handle much more complex event expressions. * Handle much more complex event expressions.
* *
Expand Down
23 changes: 19 additions & 4 deletions elaborate.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.22 1999/05/01 02:57:53 steve Exp $" #ident "$Id: elaborate.cc,v 1.23 1999/05/01 20:43:55 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -883,7 +883,9 @@ NetProc* PEventStatement::elaborate(Design*des, const string&path) const
} }


/* Create a single NetPEvent, and a unique NetNEvent for each /* Create a single NetPEvent, and a unique NetNEvent for each
conjuctive event. */ conjuctive event. An NetNEvent can have many pins only if
it is an ANYEDGE detector. Otherwise, only connect to the
least significant bit of the expression. */


NetPEvent*pe = new NetPEvent(des->local_symbol(path), enet); NetPEvent*pe = new NetPEvent(des->local_symbol(path), enet);
for (unsigned idx = 0 ; idx < expr_.count() ; idx += 1) { for (unsigned idx = 0 ; idx < expr_.count() ; idx += 1) {
Expand All @@ -896,10 +898,15 @@ NetProc* PEventStatement::elaborate(Design*des, const string&path) const
return 0; return 0;
} }
assert(expr); assert(expr);

unsigned pins = (expr_[idx]->type() == NetNEvent::ANYEDGE)
? expr->pin_count() : 1;
NetNEvent*ne = new NetNEvent(des->local_symbol(path), NetNEvent*ne = new NetNEvent(des->local_symbol(path),
expr_[idx]->type(), pe); pins, expr_[idx]->type(), pe);

for (unsigned p = 0 ; p < pins ; p += 1)
connect(ne->pin(p), expr->pin(p));


connect(ne->pin(0), expr->pin(0));
des->add_node(ne); des->add_node(ne);
} }


Expand Down Expand Up @@ -1050,6 +1057,14 @@ Design* elaborate(const map<string,Module*>&modules,


/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.23 1999/05/01 20:43:55 steve
* Handle wide events, such as @(a) where a has
* many bits in it.
*
* Add to vvm the binary ^ and unary & operators.
*
* Dump events a bit more completely.
*
* Revision 1.22 1999/05/01 02:57:53 steve * Revision 1.22 1999/05/01 02:57:53 steve
* Handle much more complex event expressions. * Handle much more complex event expressions.
* *
Expand Down
17 changes: 14 additions & 3 deletions netlist.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: netlist.h,v 1.27 1999/05/01 02:57:53 steve Exp $" #ident "$Id: netlist.h,v 1.28 1999/05/01 20:43:55 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -745,14 +745,17 @@ class NetPEvent : public NetProc, public sref_back<NetPEvent,NetNEvent> {
* The NetNEvent is a NetNode that connects to the structural part of * The NetNEvent is a NetNode that connects to the structural part of
* the design. It has only inputs, which cause the side effect of * the design. It has only inputs, which cause the side effect of
* triggering an event that the procedural part of the design can use. * triggering an event that the procedural part of the design can use.
*
* The NetNEvent may have wide input if is is an ANYEDGE type
* device. This allows detecting changes in wide expressions.
*/ */
class NetNEvent : public NetNode, public sref<NetPEvent,NetNEvent> { class NetNEvent : public NetNode, public sref<NetPEvent,NetNEvent> {


public: public:
enum Type { ANYEDGE, POSEDGE, NEGEDGE, POSITIVE }; enum Type { ANYEDGE, POSEDGE, NEGEDGE, POSITIVE };


NetNEvent(const string&ev, Type e, NetPEvent*pe) NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe)
: NetNode(ev, 1), sref<NetPEvent,NetNEvent>(pe), edge_(e) { } : NetNode(ev, wid), sref<NetPEvent,NetNEvent>(pe), edge_(e) { }


Type type() const { return edge_; } Type type() const { return edge_; }


Expand Down Expand Up @@ -1152,6 +1155,14 @@ extern ostream& operator << (ostream&, NetNet::Type);


/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.28 1999/05/01 20:43:55 steve
* Handle wide events, such as @(a) where a has
* many bits in it.
*
* Add to vvm the binary ^ and unary & operators.
*
* Dump events a bit more completely.
*
* Revision 1.27 1999/05/01 02:57:53 steve * Revision 1.27 1999/05/01 02:57:53 steve
* Handle much more complex event expressions. * Handle much more complex event expressions.
* *
Expand Down
28 changes: 22 additions & 6 deletions t-vvm.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.18 1999/05/01 02:57:53 steve Exp $" #ident "$Id: t-vvm.cc,v 1.19 1999/05/01 20:43:55 steve Exp $"
#endif #endif


# include <iostream> # include <iostream>
Expand Down Expand Up @@ -176,6 +176,10 @@ void vvm_proc_rval::expr_unary(const NetEUnary*expr)
os_ << "vvm_unop_not(" << result << ");" os_ << "vvm_unop_not(" << result << ");"
<< endl; << endl;
break; break;
case '&':
os_ << "vvm_unop_and(" << result << ");"
<< endl;
break;
case '!': case '!':
os_ << "vvm_unop_lnot(" << result << ");" os_ << "vvm_unop_lnot(" << result << ");"
<< endl; << endl;
Expand Down Expand Up @@ -230,6 +234,10 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
os_ << setw(indent_) << "" << result << " = vvm_binop_or(" os_ << setw(indent_) << "" << result << " = vvm_binop_or("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case '^':
os_ << setw(indent_) << "" << result << " = vvm_binop_xor("
<< lres << "," << rres << ");" << endl;
break;
default: default:
cerr << "vvm: Unhandled binary op `" << expr->op() << "': " cerr << "vvm: Unhandled binary op `" << expr->op() << "': "
<< *expr << endl; << *expr << endl;
Expand Down Expand Up @@ -603,17 +611,17 @@ void target_vvm::net_event(ostream&os, const NetNEvent*gate)
os << "static vvm_sync " << pevent << ";" << endl; os << "static vvm_sync " << pevent << ";" << endl;
os << "#endif" << endl; os << "#endif" << endl;


os << "static vvm_pevent " << mangle(gate->name()) << "(&" << os << "static vvm_pevent<" << gate->pin_count() << "> " <<
pevent << ", "; mangle(gate->name()) << "(&" << pevent << ", ";
switch (gate->type()) { switch (gate->type()) {
case NetNEvent::POSEDGE: case NetNEvent::POSEDGE:
os << "vvm_pevent::POSEDGE"; os << "vvm_pevent<" << gate->pin_count() << ">::POSEDGE";
break; break;
case NetNEvent::NEGEDGE: case NetNEvent::NEGEDGE:
os << "vvm_pevent::NEGEDGE"; os << "vvm_pevent<"<< gate->pin_count() << ">::NEGEDGE";
break; break;
case NetNEvent::ANYEDGE: case NetNEvent::ANYEDGE:
os << "vvm_pevent::ANYEDGE"; os << "vvm_pevent<" << gate->pin_count() << ">::ANYEDGE";
break; break;
default: default:
assert(0); assert(0);
Expand Down Expand Up @@ -957,6 +965,14 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.19 1999/05/01 20:43:55 steve
* Handle wide events, such as @(a) where a has
* many bits in it.
*
* Add to vvm the binary ^ and unary & operators.
*
* Dump events a bit more completely.
*
* Revision 1.18 1999/05/01 02:57:53 steve * Revision 1.18 1999/05/01 02:57:53 steve
* Handle much more complex event expressions. * Handle much more complex event expressions.
* *
Expand Down
42 changes: 40 additions & 2 deletions vvm/vvm_func.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vvm_func.h,v 1.3 1999/03/16 04:43:46 steve Exp $" #ident "$Id: vvm_func.h,v 1.4 1999/05/01 20:43:55 steve Exp $"
#endif #endif


# include "vvm.h" # include "vvm.h"
Expand All @@ -45,6 +45,21 @@ vvm_bitset_t<WIDTH> vvm_unop_not(const vvm_bitset_t<WIDTH>&p)
return result; return result;
} }


/*
* The unary AND is the reduction AND. It returns a single bit.
*/
template <unsigned WIDTH>
vvm_bitset_t<1> vvm_unop_and(const vvm_bitset_t<WIDTH>&r)
{
vvm_bitset_t<1> res;
res[0] = r[0];

for (unsigned idx = 1 ; idx < WIDTH ; idx += 1) {
res[0] = res[0] & r[idx];
}
return res;
}

/* /*
* The unary OR is the reduction OR. It returns a single bit. * The unary OR is the reduction OR. It returns a single bit.
*/ */
Expand Down Expand Up @@ -124,7 +139,7 @@ vvm_bitset_t<WIDTH> vvm_binop_plus(const vvm_bitset_t<WIDTH>&l,
*/ */
template <unsigned WIDTH> template <unsigned WIDTH>
vvm_bitset_t<WIDTH> vvm_binop_minus(const vvm_bitset_t<WIDTH>&l, vvm_bitset_t<WIDTH> vvm_binop_minus(const vvm_bitset_t<WIDTH>&l,
const vvm_bitset_t<WIDTH>&r) const vvm_bitset_t<WIDTH>&r)
{ {
vvm_bitset_t<WIDTH> res; vvm_bitset_t<WIDTH> res;
res = vvm_unop_not(r); res = vvm_unop_not(r);
Expand All @@ -135,6 +150,21 @@ vvm_bitset_t<WIDTH> vvm_binop_minus(const vvm_bitset_t<WIDTH>&l,
return res; return res;
} }


/*
* The binary ^ (xor) operator is a bitwise XOR of equal width inputs
* to generate the corresponsing output.
*/
template <unsigned WIDTH>
vvm_bitset_t<WIDTH> vvm_binop_xor(const vvm_bitset_t<WIDTH>&l,
const vvm_bitset_t<WIDTH>&r)
{
vvm_bitset_t<WIDTH> result;
for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
result[idx] = l[idx] ^ r[idx];

return result;
}

/* /*
* Tests for equality are a bit tricky, as they allow for the left and * Tests for equality are a bit tricky, as they allow for the left and
* right subexpressions to have different size. The shorter bitset is * right subexpressions to have different size. The shorter bitset is
Expand Down Expand Up @@ -240,6 +270,14 @@ vvm_bitset_t<1> vvm_binop_lor(const vvm_bitset_t<LW>&l,


/* /*
* $Log: vvm_func.h,v $ * $Log: vvm_func.h,v $
* Revision 1.4 1999/05/01 20:43:55 steve
* Handle wide events, such as @(a) where a has
* many bits in it.
*
* Add to vvm the binary ^ and unary & operators.
*
* Dump events a bit more completely.
*
* Revision 1.3 1999/03/16 04:43:46 steve * Revision 1.3 1999/03/16 04:43:46 steve
* Add some logical operators. * Add some logical operators.
* *
Expand Down
41 changes: 35 additions & 6 deletions vvm/vvm_gates.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vvm_gates.h,v 1.8 1999/05/01 02:57:53 steve Exp $" #ident "$Id: vvm_gates.h,v 1.9 1999/05/01 20:43:55 steve Exp $"
#endif #endif


# include "vvm.h" # include "vvm.h"
Expand Down Expand Up @@ -367,18 +367,39 @@ class vvm_sync {
vvm_sync& operator= (const vvm_sync&); vvm_sync& operator= (const vvm_sync&);
}; };


class vvm_pevent { template <unsigned WIDTH> class vvm_pevent {
public: public:
enum EDGE { ANYEDGE, POSEDGE, NEGEDGE }; enum EDGE { ANYEDGE, POSEDGE, NEGEDGE };


explicit vvm_pevent(vvm_sync*tgt, EDGE e); explicit vvm_pevent(vvm_sync*tgt, EDGE e)
: target_(tgt), edge_(e)
{ for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
value_[idx] = Vz;
}


void set(vvm_simulation*sim, unsigned, vvm_bit_t val); vvm_bitset_t<WIDTH> get() const { return value_; }
vvm_bit_t get() const { return value_; }
void set(vvm_simulation*sim, unsigned idx, vvm_bit_t val)
{ if (value_[idx] == val) return;
switch (edge_) {
case ANYEDGE:
target_->wakeup(sim);
break;
case POSEDGE:
if (val == V1)
target_->wakeup(sim);
break;
case NEGEDGE:
if (val == V0)
target_->wakeup(sim);
break;
}
value_[idx] = val;
}


private: private:
vvm_sync*target_; vvm_sync*target_;
vvm_bit_t value_; vvm_bit_t value_[WIDTH];
EDGE edge_; EDGE edge_;


private: // not implemented private: // not implemented
Expand All @@ -388,6 +409,14 @@ class vvm_pevent {


/* /*
* $Log: vvm_gates.h,v $ * $Log: vvm_gates.h,v $
* Revision 1.9 1999/05/01 20:43:55 steve
* Handle wide events, such as @(a) where a has
* many bits in it.
*
* Add to vvm the binary ^ and unary & operators.
*
* Dump events a bit more completely.
*
* Revision 1.8 1999/05/01 02:57:53 steve * Revision 1.8 1999/05/01 02:57:53 steve
* Handle much more complex event expressions. * Handle much more complex event expressions.
* *
Expand Down
Loading

0 comments on commit 5d00f17

Please sign in to comment.