Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for modulus (Eric Aardoom)

  • Loading branch information...
commit 89d7176734bbd726e78d91a04d95e6b70043888b 1 parent f8478a4
steve authored
View
6 Makefile.in
@@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.65 2000/09/09 15:21:26 steve Exp $"
+#ident "$Id: Makefile.in,v 1.66 2000/09/17 21:26:15 steve Exp $"
#
#
SHELL = /bin/sh
@@ -76,8 +76,8 @@ O = main.o cprop.o design_dump.o dup_expr.o elaborate.o elab_expr.o \
elab_lval.o elab_net.o elab_pexpr.o elab_scope.o elab_sig.o emit.o eval.o \
eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
mangle.o netlist.o net_assign.o \
-net_design.o net_event.o net_force.o net_link.o net_proc.o net_scope.o \
-net_udp.o \
+net_design.o net_event.o net_force.o net_link.o net_modulo.o net_proc.o \
+net_scope.o net_udp.o \
pad_to_width.o \
parse.o parse_misc.o pform.o pform_dump.o \
set_width.o \
View
12 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.43 2000/09/09 15:21:26 steve Exp $"
+#ident "$Id: PExpr.h,v 1.44 2000/09/17 21:26:15 steve Exp $"
#endif
# include <string>
@@ -146,7 +146,7 @@ class PEEvent : public PExpr {
edge_t type() const;
PExpr* expr() const;
-
+
virtual void dump(ostream&) const;
private:
@@ -324,6 +324,11 @@ class PEBinary : public PExpr {
unsigned long rise,
unsigned long fall,
unsigned long decay) const;
+ NetNet* elaborate_net_mod_(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,
@@ -392,6 +397,9 @@ class PECallFunction : public PExpr {
/*
* $Log: PExpr.h,v $
+ * Revision 1.44 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.43 2000/09/09 15:21:26 steve
* move lval elaboration to PExpr virtual methods.
*
View
12 design_dump.cc
@@ -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.96 2000/09/10 02:18:16 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.97 2000/09/17 21:26:15 steve Exp $"
#endif
/*
@@ -297,6 +297,13 @@ void NetLogic::dump_node(ostream&o, unsigned ind) const
dump_obj_attr(o, ind+4);
}
+void NetModulo::dump_node(ostream&o, unsigned ind) const
+{
+ o << setw(ind) << "" << "NET_MODULO (NetModulo): " << name() << endl;
+ dump_node_pins(o, ind+4);
+ dump_obj_attr(o, ind+4);
+}
+
void NetRamDq::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "LPM_RAM_DQ (" << mem_->name() << "): "
@@ -969,6 +976,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.97 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.96 2000/09/10 02:18:16 steve
* elaborate complex l-values
*
View
60 elab_net.cc
@@ -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.46 2000/09/07 21:28:51 steve Exp $"
+#ident "$Id: elab_net.cc,v 1.47 2000/09/17 21:26:15 steve Exp $"
#endif
# include "PExpr.h"
@@ -41,7 +41,8 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
switch (op_) {
case '*':
return elaborate_net_mul_(des, path, width, rise, fall, decay);
- //case '%':
+ case '%':
+ return elaborate_net_mod_(des, path, width, rise, fall, decay);
case '/':
return elaborate_net_div_(des, path, width, rise, fall, decay);
case '+':
@@ -584,6 +585,58 @@ NetNet* PEBinary::elaborate_net_div_(Design*des, const string&path,
return osig;
}
+/*
+ * Elaborate a modulo gate.
+ */
+NetNet* PEBinary::elaborate_net_mod_(Design*des, const string&path,
+ unsigned lwidth,
+ unsigned long rise,
+ unsigned long fall,
+ unsigned long decay) const
+{
+ NetScope*scope = des->find_scope(path);
+ assert(scope);
+ 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();
+ NetModulo*mod = new NetModulo(des->local_symbol(path), rwidth,
+ lsig->pin_count(),
+ rsig->pin_count());
+ des->add_node(mod);
+
+ for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
+ connect(mod->pin_DataA(idx), lsig->pin(idx));
+ for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1)
+ connect(mod->pin_DataB(idx), rsig->pin(idx));
+
+ if (lwidth == 0) lwidth = rwidth;
+ NetNet*osig = new NetNet(scope, des->local_symbol(path),
+ NetNet::IMPLICIT, lwidth);
+ osig->local_flag(true);
+
+ unsigned cnt = osig->pin_count();
+ if (cnt > rwidth) cnt = rwidth;
+
+ for (unsigned idx = 0 ; idx < cnt ; idx += 1)
+ connect(mod->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,
@@ -1693,6 +1746,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/*
* $Log: elab_net.cc,v $
+ * Revision 1.47 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.46 2000/09/07 21:28:51 steve
* more robust abut ternary bit widths.
*
View
11 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.52 2000/09/02 20:54:20 steve Exp $"
+#ident "$Id: emit.cc,v 1.53 2000/09/17 21:26:15 steve Exp $"
#endif
/*
@@ -112,6 +112,12 @@ bool NetForce::emit_node(struct target_t*tgt) const
return true;
}
+bool NetModulo::emit_node(struct target_t*tgt) const
+{
+ tgt->lpm_modulo(this);
+ return true;
+}
+
bool NetMult::emit_node(struct target_t*tgt) const
{
tgt->lpm_mult(this);
@@ -475,6 +481,9 @@ bool emit(const Design*des, const char*type)
/*
* $Log: emit.cc,v $
+ * Revision 1.53 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.52 2000/09/02 20:54:20 steve
* Rearrange NetAssign to make NetAssign_ separate.
*
View
14 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.21 2000/08/01 02:48:41 steve Exp $"
+#ident "$Id: functor.cc,v 1.22 2000/09/17 21:26:15 steve Exp $"
#endif
# include "functor.h"
@@ -55,6 +55,10 @@ void functor_t::lpm_divide(class Design*, class NetDivide*)
{
}
+void functor_t::lpm_modulo(class Design*, class NetModulo*)
+{
+}
+
void functor_t::lpm_ff(class Design*, class NetFF*)
{
}
@@ -172,6 +176,11 @@ void NetLogic::functor_node(Design*des, functor_t*fun)
fun->lpm_logic(des, this);
}
+void NetModulo::functor_node(Design*des, functor_t*fun)
+{
+ fun->lpm_modulo(des, this);
+}
+
void NetMult::functor_node(Design*des, functor_t*fun)
{
fun->lpm_mult(des, this);
@@ -265,6 +274,9 @@ int proc_match_t::event_wait(NetEvWait*)
/*
* $Log: functor.cc,v $
+ * Revision 1.22 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.21 2000/08/01 02:48:41 steve
* Support <= in synthesis of DFF and ram devices.
*
View
8 functor.h
@@ -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.16 2000/08/01 02:48:42 steve Exp $"
+#ident "$Id: functor.h,v 1.17 2000/09/17 21:26:15 steve Exp $"
#endif
/*
@@ -63,6 +63,9 @@ struct functor_t {
/* This method is called for each structural constant. */
virtual void lpm_divide(class Design*des, class NetDivide*);
+ /* This method is called for each structural constant. */
+ virtual void lpm_modulo(class Design*des, class NetModulo*);
+
/* This method is called for each FF in the design. */
virtual void lpm_ff(class Design*des, class NetFF*);
@@ -91,6 +94,9 @@ struct proc_match_t {
/*
* $Log: functor.h,v $
+ * Revision 1.17 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.16 2000/08/01 02:48:42 steve
* Support <= in synthesis of DFF and ram devices.
*
View
105 net_modulo.cc
@@ -0,0 +1,105 @@
+/*
+ * 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_modulo.cc,v 1.1 2000/09/17 21:26:15 steve Exp $"
+#endif
+
+# include <typeinfo>
+# include <iostream>
+# include <iomanip>
+# include <cassert>
+
+# include "netlist.h"
+
+
+NetModulo::NetModulo(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(Link::OUTPUT);
+ pin(p).set_name("Result", idx);
+ }
+ for (unsigned idx = 0 ; idx < width_a_ ; idx += 1, p += 1) {
+ pin(p).set_dir(Link::INPUT);
+ pin(p).set_name("DataA", idx);
+ }
+ for (unsigned idx = 0 ; idx < width_b_ ; idx += 1, p += 1) {
+ pin(p).set_dir(Link::INPUT);
+ pin(p).set_name("DataB", idx);
+ }
+}
+
+NetModulo::~NetModulo()
+{
+}
+
+unsigned NetModulo::width_r() const
+{
+ return width_r_;
+}
+
+unsigned NetModulo::width_a() const
+{
+ return width_a_;
+}
+
+unsigned NetModulo::width_b() const
+{
+ return width_b_;
+}
+
+Link& NetModulo::pin_Result(unsigned idx)
+{
+ assert(idx < width_r_);
+ return pin(idx);
+}
+
+const Link& NetModulo::pin_Result(unsigned idx) const
+{
+ assert(idx < width_r_);
+ return pin(idx);
+}
+
+Link& NetModulo::pin_DataA(unsigned idx)
+{
+ assert(idx < width_a_);
+ return pin(idx+width_r_);
+}
+
+const Link& NetModulo::pin_DataA(unsigned idx) const
+{
+ assert(idx < width_a_);
+ return pin(idx+width_r_);
+}
+
+Link& NetModulo::pin_DataB(unsigned idx)
+{
+ assert(idx < width_b_);
+ return pin(idx+width_r_+width_a_);
+}
+
+const Link& NetModulo::pin_DataB(unsigned idx) const
+{
+ assert(idx < width_b_);
+ return pin(idx+width_r_+width_a_);
+}
+
+
View
43 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.162 2000/09/10 02:18:16 steve Exp $"
+#ident "$Id: netlist.h,v 1.163 2000/09/17 21:26:15 steve Exp $"
#endif
/*
@@ -514,6 +514,44 @@ class NetDivide : public NetNode {
};
/*
+ * This class represents a theoretical (though not necessarily
+ * practical) integer modulo gate. This is not to represent any real
+ * hardware, but to support the % operator in Verilog, when it shows
+ * up in structural contexts.
+ *
+ * The operands of the operation are the DataA<i> and DataB<i> inputs,
+ * and the Result<i> output reflects the value DataA%DataB.
+ */
+
+class NetModulo : public NetNode {
+
+ public:
+ NetModulo(const string&n, unsigned width, unsigned wa, unsigned wb);
+ ~NetModulo();
+
+ unsigned width_r() const;
+ unsigned width_a() const;
+ unsigned width_b() const;
+
+ Link& pin_DataA(unsigned idx);
+ Link& pin_DataB(unsigned idx);
+ Link& pin_Result(unsigned idx);
+
+ const Link& pin_DataA(unsigned idx) const;
+ const Link& pin_DataB(unsigned idx) const;
+ const Link& pin_Result(unsigned idx) const;
+
+ virtual void dump_node(ostream&, unsigned ind) const;
+ virtual bool emit_node(struct target_t*) const;
+ virtual void functor_node(Design*des, functor_t*fun);
+
+ private:
+ unsigned width_r_;
+ unsigned width_a_;
+ unsigned width_b_;
+};
+
+/*
* This class represents an LPM_FF device. There is no literal gate
* type in Verilog that maps, but gates of this type can be inferred.
*/
@@ -2762,6 +2800,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
+ * Revision 1.163 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.162 2000/09/10 02:18:16 steve
* elaborate complex l-values
*
View
44 t-vvm.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: t-vvm.cc,v 1.174 2000/09/16 21:28:14 steve Exp $"
+#ident "$Id: t-vvm.cc,v 1.175 2000/09/17 21:26:15 steve Exp $"
#endif
# include <iostream>
@@ -156,6 +156,7 @@ class target_vvm : public target_t {
virtual void lpm_clshift(const NetCLShift*);
virtual void lpm_compare(const NetCompare*);
virtual void lpm_divide(const NetDivide*);
+ virtual void lpm_modulo(const NetModulo*);
virtual void lpm_ff(const NetFF*);
virtual void lpm_mult(const NetMult*);
virtual void lpm_mux(const NetMux*);
@@ -1535,6 +1536,44 @@ void target_vvm::lpm_divide(const NetDivide*mul)
}
}
+void target_vvm::lpm_modulo(const NetModulo*mul)
+{
+ string mname = mangle(mul->name());
+
+ out << "static vvm_imod " << mname << "(" << mul->width_r() <<
+ "," << mul->width_a() << "," << mul->width_b() << ");" << endl;
+
+
+ /* Connect the DataA inputs... */
+ for (unsigned idx = 0 ; idx < mul->width_a() ; idx += 1) {
+ string nexus = mul->pin_DataA(idx).nexus()->name();
+ unsigned ncode = nexus_wire_map[nexus];
+
+ init_code << " nexus_wire_table["<<ncode<<"].connect(&"
+ << mname << ", " << mname << ".key_DataA("
+ << idx << "));" << endl;
+ }
+
+ /* Connect the DataB inputs... */
+ for (unsigned idx = 0 ; idx < mul->width_b() ; idx += 1) {
+ string nexus = mul->pin_DataB(idx).nexus()->name();
+ unsigned ncode = nexus_wire_map[nexus];
+
+ init_code << " nexus_wire_table["<<ncode<<"].connect(&"
+ << mname << ", " << mname << ".key_DataB("
+ << idx << "));" << endl;
+ }
+
+ /* Connect the output pins... */
+ for (unsigned idx = 0 ; idx < mul->width_r() ; idx += 1) {
+ string nexus = mul->pin_Result(idx).nexus()->name();
+ unsigned ncode = nexus_wire_map[nexus];
+
+ init_code << " nexus_wire_table["<<ncode<<"].connect("
+ << mname << ".config_rout(" << idx << "));" << endl;
+ }
+}
+
void target_vvm::lpm_ff( const NetFF*gate)
{
string nexus;
@@ -3346,6 +3385,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
+ * Revision 1.175 2000/09/17 21:26:15 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.174 2000/09/16 21:28:14 steve
* full featured l-values for non-blocking assiginment.
*
View
11 target.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: target.cc,v 1.47 2000/09/03 17:57:53 steve Exp $"
+#ident "$Id: target.cc,v 1.48 2000/09/17 21:26:16 steve Exp $"
#endif
# include "target.h"
@@ -102,6 +102,12 @@ void target_t::lpm_divide(const NetDivide*)
"Unhandled NetDivide." << endl;
}
+void target_t::lpm_modulo(const NetModulo*)
+{
+ cerr << "target (" << typeid(*this).name() << "): "
+ "Unhandled NetModulo." << endl;
+}
+
void target_t::lpm_ff(const NetFF*)
{
cerr << "target (" << typeid(*this).name() << "): "
@@ -388,6 +394,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/*
* $Log: target.cc,v $
+ * Revision 1.48 2000/09/17 21:26:16 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.47 2000/09/03 17:57:53 steve
* Slightly more helpful warning.
*
View
6 target.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: target.h,v 1.45 2000/09/02 20:54:21 steve Exp $"
+#ident "$Id: target.h,v 1.46 2000/09/17 21:26:16 steve Exp $"
#endif
# include "netlist.h"
@@ -77,6 +77,7 @@ struct target_t {
virtual void lpm_clshift(const NetCLShift*);
virtual void lpm_compare(const NetCompare*);
virtual void lpm_divide(const NetDivide*);
+ virtual void lpm_modulo(const NetModulo*);
virtual void lpm_ff(const NetFF*);
virtual void lpm_mult(const NetMult*);
virtual void lpm_mux(const NetMux*);
@@ -159,6 +160,9 @@ extern const struct target *target_table[];
/*
* $Log: target.h,v $
+ * Revision 1.46 2000/09/17 21:26:16 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.45 2000/09/02 20:54:21 steve
* Rearrange NetAssign to make NetAssign_ separate.
*
View
33 vvm/vvm_gates.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: vvm_gates.h,v 1.64 2000/05/11 23:37:28 steve Exp $"
+#ident "$Id: vvm_gates.h,v 1.65 2000/09/17 21:26:16 steve Exp $"
#endif
# include "vvm.h"
@@ -355,6 +355,34 @@ class vvm_idiv : public vvm_nexus::recvr_t {
};
/*
+ * This class behaves like a combinational modulo operator. There isn't really
+ * such a practical device, but this is useful for simulating code
+ * that includes a / operator in structural contexts.
+ */
+class vvm_imod : public vvm_nexus::recvr_t {
+
+ public:
+ explicit vvm_imod(unsigned rwid, unsigned awid, unsigned bwid);
+ ~vvm_imod();
+
+ void init_DataA(unsigned idx, vpip_bit_t val);
+ void init_DataB(unsigned idx, vpip_bit_t val);
+
+ vvm_nexus::drive_t* config_rout(unsigned idx);
+ unsigned key_DataA(unsigned idx) const;
+ unsigned key_DataB(unsigned idx) const;
+
+ private:
+ void take_value(unsigned key, vpip_bit_t val);
+
+ unsigned rwid_;
+ unsigned awid_;
+ unsigned bwid_;
+ vpip_bit_t*bits_;
+ vvm_nexus::drive_t*out_;
+};
+
+/*
* This class behaves like a combinational multiplier. The device
* behaves like the LPM_MULT device.
*/
@@ -948,6 +976,9 @@ class vvm_posedge : public vvm_nexus::recvr_t {
/*
* $Log: vvm_gates.h,v $
+ * Revision 1.65 2000/09/17 21:26:16 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.64 2000/05/11 23:37:28 steve
* Add support for procedural continuous assignment.
*
View
71 vvm/vvm_imod.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: vvm_imod.cc,v 1.2 2000/08/20 17:49:05 steve Exp $"
+#ident "$Id: vvm_imod.cc,v 1.3 2000/09/17 21:26:16 steve Exp $"
#endif
@@ -75,8 +75,77 @@ void vvm_binop_imod(vvm_bitset_t&v, const vvm_bitset_t&l, const vvm_bitset_t&r)
}
+vvm_imod::vvm_imod(unsigned rwid, unsigned awid, unsigned bwid)
+: rwid_(rwid), awid_(awid), bwid_(bwid)
+{
+ bits_ = new vpip_bit_t[rwid_+awid_+bwid_];
+ for (unsigned idx = 0 ; idx < rwid_+awid_+bwid_ ; idx += 1)
+ bits_[idx] = StX;
+
+ out_ = new vvm_nexus::drive_t[rwid];
+}
+
+vvm_imod::~vvm_imod()
+{
+ delete[]out_;
+ delete[]bits_;
+}
+
+void vvm_imod::init_DataA(unsigned idx, vpip_bit_t val)
+{
+ assert(idx < awid_);
+ bits_[rwid_+idx] = val;
+}
+
+void vvm_imod::init_DataB(unsigned idx, vpip_bit_t val)
+{
+ assert(idx < bwid_);
+ bits_[rwid_+awid_+idx] = val;
+}
+
+vvm_nexus::drive_t* vvm_imod::config_rout(unsigned idx)
+{
+ assert(idx < rwid_);
+ return out_+idx;
+}
+
+unsigned vvm_imod::key_DataA(unsigned idx) const
+{
+ assert(idx < awid_);
+ return rwid_+idx;
+}
+
+unsigned vvm_imod::key_DataB(unsigned idx) const
+{
+ assert(idx < bwid_);
+ return rwid_+awid_+idx;
+}
+
+void vvm_imod::take_value(unsigned key, vpip_bit_t val)
+{
+ if (B_EQ(bits_[key], val)) {
+ bits_[key] = val;
+ return;
+ }
+
+ bits_[key] = val;
+
+ vvm_bitset_t r (bits_, rwid_);
+ vvm_bitset_t a (bits_+rwid_, awid_);
+ vvm_bitset_t b (bits_+rwid_+awid_, bwid_);
+ vvm_binop_imod(r, a, b);
+
+ for (unsigned idx = 0 ; idx < rwid_ ; idx += 1)
+ out_[idx].set_value(bits_[idx]);
+
+}
+
+
/*
* $Log: vvm_imod.cc,v $
+ * Revision 1.3 2000/09/17 21:26:16 steve
+ * Add support for modulus (Eric Aardoom)
+ *
* Revision 1.2 2000/08/20 17:49:05 steve
* Clean up warnings and portability issues.
*
Please sign in to comment.
Something went wrong with that request. Please try again.