From 260250588517615efc016e87d3da490ec3886c2f Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 13 Nov 1999 03:46:52 +0000 Subject: [PATCH] Support the LPM_MUX in vvm. --- netlist.cc | 7 +++-- t-vvm.cc | 21 ++++++++++++- vvm/vvm_gates.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 107 insertions(+), 4 deletions(-) diff --git a/netlist.cc b/netlist.cc index 3f6eedeb2..fe56bf5a5 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) -#ident "$Id: netlist.cc,v 1.83 1999/11/05 04:40:40 steve Exp $" +#ident "$Id: netlist.cc,v 1.84 1999/11/13 03:46:52 steve Exp $" #endif # include @@ -603,7 +603,7 @@ NetMux::NetMux(const string&n, unsigned wi, unsigned si, unsigned sw) : NetNode(n, 2+wi+sw+wi*si), width_(wi), size_(si), swidth_(sw) { pin(0).set_dir(NetObj::Link::INPUT); pin(0).set_name("Aclr", 0); - pin(1).set_dir(NetObj::Link::INPUT); pin(0).set_name("Clock", 0); + pin(1).set_dir(NetObj::Link::INPUT); pin(1).set_name("Clock", 0); for (unsigned idx = 0 ; idx < width_ ; idx += 1) { pin_Result(idx).set_dir(NetObj::Link::OUTPUT); @@ -2104,6 +2104,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*)) /* * $Log: netlist.cc,v $ + * Revision 1.84 1999/11/13 03:46:52 steve + * Support the LPM_MUX in vvm. + * * Revision 1.83 1999/11/05 04:40:40 steve * Patch to synthesize LPM_ADD_SUB from expressions, * Thanks to Larry Doolittle. Also handle constants diff --git a/t-vvm.cc b/t-vvm.cc index 763b828f5..0155a318b 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: t-vvm.cc,v 1.73 1999/11/10 02:52:24 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.74 1999/11/13 03:46:52 steve Exp $" #endif # include @@ -61,6 +61,7 @@ class target_vvm : public target_t { virtual void lpm_add_sub(ostream&os, const NetAddSub*); virtual void lpm_ff(ostream&os, const NetFF*); + virtual void lpm_mux(ostream&os, const NetMux*); virtual void logic(ostream&os, const NetLogic*); virtual void bufz(ostream&os, const NetBUFZ*); @@ -882,6 +883,21 @@ void target_vvm::lpm_ff(ostream&os, const NetFF*gate) } } +void target_vvm::lpm_mux(ostream&os, const NetMux*mux) +{ + string mname = mangle(mux->name()); + os << "static vvm_mux<" << mux->width() << "," << mux->size() << + "," << mux->sel_width() << "> " << mname << ";" << endl; + + for (unsigned idx = 0 ; idx < mux->width() ; idx += 1) { + unsigned pin = mux->pin_Result(idx).get_pin(); + string outfun = defn_gate_outputfun_(os, mux, pin); + init_code << " " << mangle(mux->name()) << + ".config_rout(" << idx << ", &" << outfun << ");" << endl; + emit_gate_outputfun_(mux, pin); + } +} + void target_vvm::logic(ostream&os, const NetLogic*gate) { string outfun = defn_gate_outputfun_(os, gate, 0); @@ -1847,6 +1863,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.74 1999/11/13 03:46:52 steve + * Support the LPM_MUX in vvm. + * * Revision 1.73 1999/11/10 02:52:24 steve * Create the vpiMemory handle type. * diff --git a/vvm/vvm_gates.h b/vvm/vvm_gates.h index e1c2f9c54..504fe20a7 100644 --- a/vvm/vvm_gates.h +++ b/vvm/vvm_gates.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvm_gates.h,v 1.18 1999/11/01 02:07:41 steve Exp $" +#ident "$Id: vvm_gates.h,v 1.19 1999/11/13 03:46:52 steve Exp $" #endif # include "vvm.h" @@ -202,6 +202,84 @@ template class vvm_ff { } }; +/* + * This class supports mux devices. The width is the width of the data + * (or bus) path, SIZE is the number of alternative inputs and SELWID + * is the size (in bits) of the selector input. + */ +template class vvm_mux { + + public: + explicit vvm_mux() + { sel_val_ = SIZE; + for (unsigned idx = 0;idx < WIDTH; idx += 1) + out_[idx] = 0; + } + + void init_Sel(unsigned idx, vpip_bit_t val) + { sel_[idx] = val; } + + void init_Data(unsigned idx, vpip_bit_t val) + { input_[idx] = val; } + + void set_Sel(vvm_simulation*sim, unsigned idx, vpip_bit_t val) + { if (sel_[idx] == val) return; + sel_[idx] = val; + evaluate_(sim); + } + + void set_Data(vvm_simulation*sim, unsigned idx, vpip_bit_t val) + { if (input_[idx] == val) return; + input_[idx] = val; + unsigned sel = idx / WIDTH; + if (sel != sel_val_) return; + unsigned off = idx % WIDTH; + vvm_event*ev = new vvm_out_event(sim, val, out_[off]); + sim->active_event(ev); + } + + void config_rout(unsigned idx, vvm_out_event::action_t o) + { out_[idx] = o; } + + private: + vpip_bit_t sel_[SELWID]; + vpip_bit_t input_[WIDTH * SIZE]; + vvm_out_event::action_t out_[WIDTH]; + + unsigned sel_val_; + void evaluate_(vvm_simulation*sim) + { unsigned tmp = 0; + for (unsigned idx = 0 ; idx < SELWID ; idx += 1) + switch (sel_[idx]) { + case V0: + break; + case V1: + tmp |= (1< SIZE) tmp = SIZE; + if (tmp == sel_val_) return; + sel_val_ = tmp; + if (sel_val_ == SIZE) { + for (unsigned idx = 0; idx < WIDTH ; idx += 1) { + vvm_event*ev = new vvm_out_event(sim, Vx, out_[idx]); + sim->active_event(ev); + } + } else { + unsigned b = sel_val_ * WIDTH; + for (unsigned idx = 0; idx < WIDTH ; idx += 1) { + vvm_event*ev = new vvm_out_event(sim, + input_[idx+b], + out_[idx]); + sim->active_event(ev); + } + } + } +}; + template class vvm_or { public: @@ -649,6 +727,9 @@ template class vvm_pevent { /* * $Log: vvm_gates.h,v $ + * Revision 1.19 1999/11/13 03:46:52 steve + * Support the LPM_MUX in vvm. + * * Revision 1.18 1999/11/01 02:07:41 steve * Add the synth functor to do generic synthesis * and add the LPM_FF device to handle rows of