elaborate the binary plus operator.

This commit is contained in:
steve 1999-09-03 04:28:38 +00:00
parent 6fb7120158
commit 41a1c6bb02
7 changed files with 154 additions and 8 deletions

View File

@ -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.37 1999/09/01 20:46:19 steve Exp $" #ident "$Id: design_dump.cc,v 1.38 1999/09/03 04:28:38 steve Exp $"
#endif #endif
/* /*
@ -121,6 +121,12 @@ void NetObj::dump_obj_attr(ostream&o, unsigned ind) const
} }
} }
void NetAddSub::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "Adder (NetAddSub): " << name() << endl;
dump_node_pins(o, ind+4);
}
void NetAssign::dump_node(ostream&o, unsigned ind) const void NetAssign::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "Procedural assign (NetAssign): " << o << setw(ind) << "" << "Procedural assign (NetAssign): " <<
@ -722,6 +728,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.38 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.37 1999/09/01 20:46:19 steve * Revision 1.37 1999/09/01 20:46:19 steve
* Handle recursive functions and arbitrary function * Handle recursive functions and arbitrary function
* references to other functions, properly pass * references to other functions, properly pass

View File

@ -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.76 1999/09/02 01:59:27 steve Exp $" #ident "$Id: elaborate.cc,v 1.77 1999/09/03 04:28:38 steve Exp $"
#endif #endif
/* /*
@ -639,7 +639,7 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
} }
NetNet*osig; NetNet*osig;
NetLogic*gate; NetNode*gate;
switch (op_) { switch (op_) {
case '^': // XOR case '^': // XOR
@ -716,6 +716,27 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
des->add_node(gate); des->add_node(gate);
break; break;
// Elaborate the structural + as an AddSub
// object. Connect DataA and DataB to the parameters,
// and connect the output signal to the Result.
case '+': {
assert(lsig->pin_count() == rsig->pin_count());
string name = des->local_symbol(path);
unsigned width = lsig->pin_count();
osig = new NetNet(des->local_symbol(path),
NetNet::WIRE, width);
NetAddSub*adder = new NetAddSub(name, width);
for (unsigned idx = 0 ; idx < width ; idx += 1) {
connect(lsig->pin(idx), adder->pin_DataA(idx));
connect(rsig->pin(idx), adder->pin_DataB(idx));
connect(osig->pin(idx), adder->pin_Result(idx));
}
gate = adder;
des->add_signal(osig);
des->add_node(gate);
break;
}
default: default:
cerr << "Unhandled BINARY '" << op_ << "'" << endl; cerr << "Unhandled BINARY '" << op_ << "'" << endl;
osig = 0; osig = 0;
@ -2171,6 +2192,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.77 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.76 1999/09/02 01:59:27 steve * Revision 1.76 1999/09/02 01:59:27 steve
* Parse non-blocking assignment delays. * Parse non-blocking assignment delays.
* *

10
emit.cc
View File

@ -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: emit.cc,v 1.19 1999/08/31 22:38:29 steve Exp $" #ident "$Id: emit.cc,v 1.20 1999/09/03 04:28:38 steve Exp $"
#endif #endif
/* /*
@ -45,6 +45,11 @@ void NetUDP::emit_node(ostream&o, struct target_t*tgt) const
tgt->udp(o, this); tgt->udp(o, this);
} }
void NetAddSub::emit_node(ostream&o, struct target_t*tgt) const
{
tgt->lpm_add_sub(o, this);
}
void NetAssign::emit_node(ostream&o, struct target_t*tgt) const void NetAssign::emit_node(ostream&o, struct target_t*tgt) const
{ {
tgt->net_assign(o, this); tgt->net_assign(o, this);
@ -321,6 +326,9 @@ void emit(ostream&o, const Design*des, const char*type)
/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.20 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.19 1999/08/31 22:38:29 steve * Revision 1.19 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions. * Elaborate and emit to vvm procedural functions.
* *

View File

@ -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: netlist.cc,v 1.55 1999/09/01 20:46:19 steve Exp $" #ident "$Id: netlist.cc,v 1.56 1999/09/03 04:28:38 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -296,6 +296,60 @@ const NetProc* NetProcTop::statement() const
return statement_; return statement_;
} }
/*
* The NetAddSub class represents an LPM ADD_SUB device. The pinout is
* assigned like so:
* 0 -- Add_Sub
* 1 -- Aclr
* 2 -- Clock
* 3 -- Cin
* 4 -- Cout
* 5 -- Overflow
* 6 -- DataA[0]
* 7 -- DataB[0]
* 8 -- Result[0]
*/
NetAddSub::NetAddSub(const string&n, unsigned w)
: NetNode(n, w*3+6)
{
pin(0).set_dir(NetObj::Link::INPUT);
pin(1).set_dir(NetObj::Link::INPUT);
pin(2).set_dir(NetObj::Link::INPUT);
pin(3).set_dir(NetObj::Link::INPUT);
pin(4).set_dir(NetObj::Link::OUTPUT);
pin(5).set_dir(NetObj::Link::OUTPUT);
for (unsigned idx = 0 ; idx < w ; idx += 1) {
pin_DataA(idx).set_dir(NetObj::Link::INPUT);
pin_DataB(idx).set_dir(NetObj::Link::INPUT);
pin_Result(idx).set_dir(NetObj::Link::OUTPUT);
}
}
NetAddSub::~NetAddSub()
{
}
NetObj::Link& NetAddSub::pin_DataA(unsigned idx)
{
idx = 6 + idx*3;
assert(idx < pin_count());
return pin(idx);
}
NetObj::Link& NetAddSub::pin_DataB(unsigned idx)
{
idx = 7 + idx*3;
assert(idx < pin_count());
return pin(idx);
}
NetObj::Link& NetAddSub::pin_Result(unsigned idx)
{
idx = 8 + idx*3;
assert(idx < pin_count());
return pin(idx);
}
NetAssign_::NetAssign_(const string&n, unsigned w) NetAssign_::NetAssign_(const string&n, unsigned w)
: NetNode(n, w) : NetNode(n, w)
{ {
@ -1695,6 +1749,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.56 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.55 1999/09/01 20:46:19 steve * Revision 1.55 1999/09/01 20:46:19 steve
* Handle recursive functions and arbitrary function * Handle recursive functions and arbitrary function
* references to other functions, properly pass * references to other functions, properly pass

View File

@ -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.59 1999/09/01 20:46:19 steve Exp $" #ident "$Id: netlist.h,v 1.60 1999/09/03 04:28:38 steve Exp $"
#endif #endif
/* /*
@ -280,6 +280,36 @@ class NetNet : public NetObj, public LineInfo {
verinum::V*ivalue_; verinum::V*ivalue_;
}; };
/*
* This class implements the LPM_ADD_SUB component as described in the
* EDIF LPM Version 2 1 0 standard. It is used as a structural
* implementation of the + and - operators.
*/
class NetAddSub : public NetNode {
public:
NetAddSub(const string&n, unsigned width);
~NetAddSub();
// Get the width of the device (that is, the width of the
// operands and results.)
unsigned width() const;
NetObj::Link& pin_Aclr();
NetObj::Link& pin_Add_Sub();
NetObj::Link& pin_Clock();
NetObj::Link& pin_Cin();
NetObj::Link& pin_Cout();
NetObj::Link& pin_Overflow();
NetObj::Link& pin_DataA(unsigned idx);
NetObj::Link& pin_DataB(unsigned idx);
NetObj::Link& pin_Result(unsigned idx);
virtual void dump_node(ostream&, unsigned ind) const;
virtual void emit_node(ostream&, struct target_t*) const;
};
/* /*
* This class represents the declared memory object. The parser * This class represents the declared memory object. The parser
* creates one of these for each declared memory in the elaborated * creates one of these for each declared memory in the elaborated
@ -1518,6 +1548,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.60 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.59 1999/09/01 20:46:19 steve * Revision 1.59 1999/09/01 20:46:19 steve
* Handle recursive functions and arbitrary function * Handle recursive functions and arbitrary function
* references to other functions, properly pass * references to other functions, properly pass

View File

@ -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: target.cc,v 1.17 1999/08/31 22:38:29 steve Exp $" #ident "$Id: target.cc,v 1.18 1999/09/03 04:28:38 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
@ -69,6 +69,12 @@ void target_t::udp(ostream&os, const NetUDP*)
"Unhandled UDP." << endl; "Unhandled UDP." << endl;
} }
void target_t::lpm_add_sub(ostream&, const NetAddSub*)
{
cerr << "target (" << typeid(*this).name() << "): "
"Unhandled NetAddSub." << endl;
}
void target_t::net_assign(ostream&os, const NetAssign*) void target_t::net_assign(ostream&os, const NetAssign*)
{ {
} }
@ -256,6 +262,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/* /*
* $Log: target.cc,v $ * $Log: target.cc,v $
* Revision 1.18 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.17 1999/08/31 22:38:29 steve * Revision 1.17 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions. * Elaborate and emit to vvm procedural functions.
* *

View File

@ -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: target.h,v 1.16 1999/08/31 22:38:29 steve Exp $" #ident "$Id: target.h,v 1.17 1999/09/03 04:28:38 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -65,6 +65,9 @@ struct target_t {
virtual void task_def(ostream&, const NetTaskDef*); virtual void task_def(ostream&, const NetTaskDef*);
virtual void func_def(ostream&, const NetFuncDef*); virtual void func_def(ostream&, const NetFuncDef*);
/* LPM style components are handled here. */
virtual void lpm_add_sub(ostream&os, const NetAddSub*);
/* Output a gate (called for each gate) */ /* Output a gate (called for each gate) */
virtual void logic(ostream&os, const NetLogic*); virtual void logic(ostream&os, const NetLogic*);
virtual void bufz(ostream&os, const NetBUFZ*); virtual void bufz(ostream&os, const NetBUFZ*);
@ -132,6 +135,9 @@ extern const struct target *target_table[];
/* /*
* $Log: target.h,v $ * $Log: target.h,v $
* Revision 1.17 1999/09/03 04:28:38 steve
* elaborate the binary plus operator.
*
* Revision 1.16 1999/08/31 22:38:29 steve * Revision 1.16 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions. * Elaborate and emit to vvm procedural functions.
* *