Permalink
Browse files

Add support for integer division.

  • Loading branch information...
steve
steve committed Apr 1, 2000
1 parent 2dd010d commit 694ff934af660275d1f0797ce7dfc70af05dd1ea
Showing with 482 additions and 115 deletions.
  1. +9 −1 PExpr.h
  2. +11 −1 design_dump.cc
  3. +58 −3 elab_net.cc
  4. +9 −1 emit.cc
  5. +13 −1 functor.cc
  6. +7 −16 functor.h
  7. +78 −1 netlist.cc
  8. +42 −1 netlist.h
  9. +47 −5 t-vvm.cc
  10. +10 −1 target.cc
  11. +5 −80 target.h
  12. +2 −2 vvm/Makefile.in
  13. +11 −1 vvm/vvm_func.h
  14. +32 −1 vvm/vvm_gates.h
  15. +148 −0 vvm/vvm_idiv.cc
View
10 PExpr.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: PExpr.h,v 1.33 2000/04/01 19:31:57 steve Exp $"
+#ident "$Id: PExpr.h,v 1.34 2000/04/01 21:40:22 steve Exp $"
#endif
# include <string>
@@ -289,6 +289,11 @@ class PEBinary : public PExpr {
unsigned long rise,
unsigned long fall,
unsigned long decay) const;
+ NetNet* elaborate_net_div_(Design*des, const string&path,
+ unsigned lwidth,
+ unsigned long rise,
+ unsigned long fall,
+ unsigned long decay) const;
NetNet* elaborate_net_log_(Design*des, const string&path,
unsigned lwidth,
unsigned long rise,
@@ -353,6 +358,9 @@ class PECallFunction : public PExpr {
/*
* $Log: PExpr.h,v $
+ * Revision 1.34 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.33 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.70 2000/03/29 04:37:10 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.71 2000/04/01 21:40:22 steve Exp $"
#endif
/*
@@ -147,6 +147,13 @@ void NetCompare::dump_node(ostream&o, unsigned ind) const
dump_obj_attr(o, ind+4);
}
+void NetDivide::dump_node(ostream&o, unsigned ind) const
+{
+ o << setw(ind) << "" << "NET_DIVIDE (NetDivide): " << name() << endl;
+ dump_node_pins(o, ind+4);
+ dump_obj_attr(o, ind+4);
+}
+
void NetMult::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "LPM_MULT (NetMult): " << name() << endl;
@@ -897,6 +904,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.71 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.70 2000/03/29 04:37:10 steve
* New and improved combinational primitives.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: elab_net.cc,v 1.28 2000/03/27 04:38:15 steve Exp $"
+#ident "$Id: elab_net.cc,v 1.29 2000/04/01 21:40:22 steve Exp $"
#endif
# include "PExpr.h"
@@ -38,9 +38,10 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
{
switch (op_) {
case '*':
- //case '/':
- //case '%':
return elaborate_net_mul_(des, path, width, rise, fall, decay);
+ //case '%':
+ case '/':
+ return elaborate_net_div_(des, path, width, rise, fall, decay);
case '+':
case '-':
return elaborate_net_add_(des, path, width, rise, fall, decay);
@@ -500,6 +501,57 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
return osig;
}
+/*
+ * Elaborate a divider gate.
+ */
+NetNet* PEBinary::elaborate_net_div_(Design*des, const string&path,
+ unsigned lwidth,
+ unsigned long rise,
+ unsigned long fall,
+ unsigned long decay) const
+{
+ NetNet*lsig = left_->elaborate_net(des, path, 0, 0, 0, 0);
+ if (lsig == 0) return 0;
+ NetNet*rsig = right_->elaborate_net(des, path, 0, 0, 0, 0);
+ if (rsig == 0) return 0;
+
+ unsigned rwidth = lsig->pin_count();
+ if (rsig->pin_count() > rwidth)
+ rwidth = rsig->pin_count();
+ NetDivide*div = new NetDivide(des->local_symbol(path), rwidth,
+ lsig->pin_count(),
+ rsig->pin_count());
+ des->add_node(div);
+
+ for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
+ connect(div->pin_DataA(idx), lsig->pin(idx));
+ for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1)
+ connect(div->pin_DataB(idx), rsig->pin(idx));
+
+ if (lwidth == 0) lwidth = rwidth;
+ NetNet*osig = new NetNet(0, des->local_symbol(path),
+ NetNet::IMPLICIT, lwidth);
+ osig->local_flag(true);
+ des->add_signal(osig);
+
+ unsigned cnt = osig->pin_count();
+ if (cnt > rwidth) cnt = rwidth;
+
+ for (unsigned idx = 0 ; idx < cnt ; idx += 1)
+ connect(div->pin_Result(idx), osig->pin(idx));
+
+ /* If the lvalue is larger then the result, then pad the
+ output with constant 0. */
+ if (cnt < osig->pin_count()) {
+ NetConst*tmp = new NetConst(des->local_symbol(path), verinum::V0);
+ des->add_node(tmp);
+ for (unsigned idx = cnt ; idx < osig->pin_count() ; idx += 1)
+ connect(osig->pin(idx), tmp->pin(0));
+ }
+
+ return osig;
+}
+
NetNet* PEBinary::elaborate_net_log_(Design*des, const string&path,
unsigned lwidth,
unsigned long rise,
@@ -1356,6 +1408,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/*
* $Log: elab_net.cc,v $
+ * Revision 1.29 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.28 2000/03/27 04:38:15 steve
* Speling error.
*
View
10 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.35 2000/03/29 04:37:11 steve Exp $"
+#ident "$Id: emit.cc,v 1.36 2000/04/01 21:40:22 steve Exp $"
#endif
/*
@@ -85,6 +85,11 @@ void NetConst::emit_node(ostream&o, struct target_t*tgt) const
tgt->net_const(o, this);
}
+void NetDivide::emit_node(ostream&o, struct target_t*tgt) const
+{
+ tgt->lpm_divide(o, this);
+}
+
void NetFF::emit_node(ostream&o, struct target_t*tgt) const
{
tgt->lpm_ff(o, this);
@@ -402,6 +407,9 @@ bool emit(ostream&o, const Design*des, const char*type)
/*
* $Log: emit.cc,v $
+ * Revision 1.36 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.35 2000/03/29 04:37:11 steve
* New and improved combinational primitives.
*
View
@@ -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.12 2000/02/23 02:56:54 steve Exp $"
+#ident "$Id: functor.cc,v 1.13 2000/04/01 21:40:22 steve Exp $"
#endif
# include "functor.h"
@@ -43,6 +43,10 @@ void functor_t::lpm_const(class Design*, class NetConst*)
{
}
+void functor_t::lpm_divide(class Design*, class NetDivide*)
+{
+}
+
void functor_t::lpm_ff(class Design*, class NetFF*)
{
}
@@ -101,6 +105,11 @@ void NetConst::functor_node(Design*des, functor_t*fun)
fun->lpm_const(des, this);
}
+void NetDivide::functor_node(Design*des, functor_t*fun)
+{
+ fun->lpm_divide(des, this);
+}
+
void NetFF::functor_node(Design*des, functor_t*fun)
{
fun->lpm_ff(des, this);
@@ -180,6 +189,9 @@ int NetPEvent::match_proc(proc_match_t*that)
/*
* $Log: functor.cc,v $
+ * Revision 1.13 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.12 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: functor.h,v 1.9 2000/02/23 02:56:54 steve Exp $"
+#ident "$Id: functor.h,v 1.10 2000/04/01 21:40:22 steve Exp $"
#endif
/*
@@ -48,6 +48,9 @@ struct functor_t {
/* This method is called for each structural constant. */
virtual void lpm_const(class Design*des, class NetConst*);
+ /* This method is called for each structural constant. */
+ virtual void lpm_divide(class Design*des, class NetDivide*);
+
/* This method is called for each FF in the design. */
virtual void lpm_ff(class Design*des, class NetFF*);
@@ -71,6 +74,9 @@ struct proc_match_t {
/*
* $Log: functor.h,v $
+ * Revision 1.10 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.9 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*
@@ -85,20 +91,5 @@ struct proc_match_t {
*
* Revision 1.5 1999/12/17 06:18:16 steve
* Rewrite the cprop functor to use the functor_t interface.
- *
- * Revision 1.4 1999/12/05 02:24:08 steve
- * Synthesize LPM_RAM_DQ for writes into memories.
- *
- * Revision 1.3 1999/12/01 06:06:16 steve
- * Redo synth to use match_proc_t scanner.
- *
- * Revision 1.2 1999/11/01 02:07:40 steve
- * Add the synth functor to do generic synthesis
- * and add the LPM_FF device to handle rows of
- * flip-flops.
- *
- * Revision 1.1 1999/07/17 22:01:13 steve
- * Add the functor interface for functor transforms.
- *
*/
#endif
View
@@ -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.109 2000/03/29 04:37:11 steve Exp $"
+#ident "$Id: netlist.cc,v 1.110 2000/04/01 21:40:22 steve Exp $"
#endif
# include <cassert>
@@ -932,6 +932,80 @@ const NetObj::Link& NetCompare::pin_DataB(unsigned idx) const
return pin(8+width_+idx);
}
+NetDivide::NetDivide(const string&n, unsigned wr,
+ unsigned wa, unsigned wb)
+: NetNode(n, wr+wa+wb), width_r_(wr), width_a_(wa), width_b_(wb)
+{
+ unsigned p = 0;
+ for (unsigned idx = 0 ; idx < width_r_ ; idx += 1, p += 1) {
+ pin(p).set_dir(NetObj::Link::OUTPUT);
+ pin(p).set_name("Result", idx);
+ }
+ for (unsigned idx = 0 ; idx < width_a_ ; idx += 1, p += 1) {
+ pin(p).set_dir(NetObj::Link::INPUT);
+ pin(p).set_name("DataA", idx);
+ }
+ for (unsigned idx = 0 ; idx < width_b_ ; idx += 1, p += 1) {
+ pin(p).set_dir(NetObj::Link::INPUT);
+ pin(p).set_name("DataB", idx);
+ }
+}
+
+NetDivide::~NetDivide()
+{
+}
+
+unsigned NetDivide::width_r() const
+{
+ return width_r_;
+}
+
+unsigned NetDivide::width_a() const
+{
+ return width_a_;
+}
+
+unsigned NetDivide::width_b() const
+{
+ return width_b_;
+}
+
+NetObj::Link& NetDivide::pin_Result(unsigned idx)
+{
+ assert(idx < width_r_);
+ return pin(idx);
+}
+
+const NetObj::Link& NetDivide::pin_Result(unsigned idx) const
+{
+ assert(idx < width_r_);
+ return pin(idx);
+}
+
+NetObj::Link& NetDivide::pin_DataA(unsigned idx)
+{
+ assert(idx < width_a_);
+ return pin(idx+width_r_);
+}
+
+const NetObj::Link& NetDivide::pin_DataA(unsigned idx) const
+{
+ assert(idx < width_a_);
+ return pin(idx+width_r_);
+}
+
+NetObj::Link& NetDivide::pin_DataB(unsigned idx)
+{
+ assert(idx < width_b_);
+ return pin(idx+width_r_+width_a_);
+}
+
+const NetObj::Link& NetDivide::pin_DataB(unsigned idx) const
+{
+ assert(idx < width_b_);
+ return pin(idx+width_r_+width_a_);
+}
+
NetMult::NetMult(const string&n, unsigned wr, unsigned wa, unsigned wb,
unsigned ws)
: NetNode(n, 2+wr+wa+wb+ws), width_r_(wr), width_a_(wa), width_b_(wb),
@@ -2523,6 +2597,9 @@ bool NetUDP::sequ_glob_(string input, char output)
/*
* $Log: netlist.cc,v $
+ * Revision 1.110 2000/04/01 21:40:22 steve
+ * Add support for integer division.
+ *
* Revision 1.109 2000/03/29 04:37:11 steve
* New and improved combinational primitives.
*
Oops, something went wrong.

0 comments on commit 694ff93

Please sign in to comment.