Support the LPM_MUX in vvm.

This commit is contained in:
steve 1999-11-13 03:46:52 +00:00
parent 82f3f0f741
commit 2602505885
3 changed files with 107 additions and 4 deletions

View File

@ -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 <cassert>
@ -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

View File

@ -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 <iostream>
@ -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.
*

View File

@ -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 <unsigned WIDTH> 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 <unsigned WIDTH, unsigned SIZE, unsigned SELWID> 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<<idx);
break;
default:
tmp = SIZE;
break;
}
if (tmp > 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 <unsigned WIDTH, unsigned long DELAY> class vvm_or {
public:
@ -649,6 +727,9 @@ template <unsigned WIDTH> 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