Get rid of gate templates.

This commit is contained in:
steve 2001-01-16 03:57:46 +00:00
parent 65020bc6de
commit 5f292e546d
3 changed files with 257 additions and 115 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) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-vvm.cc,v 1.200 2001/01/12 04:20:18 steve Exp $" #ident "$Id: t-vvm.cc,v 1.201 2001/01/16 03:57:46 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -1926,64 +1926,70 @@ void target_vvm::logic(const NetLogic*gate)
switch (gate->type()) { switch (gate->type()) {
case NetLogic::AND: case NetLogic::AND:
if ((gate->pin_count()-1) == 2) if ((gate->pin_count()-1) == 2)
out << "static vvm_and2 "; out << "static vvm_and2 " << mname << "(";
else else
out << "static vvm_and" << "<" << gate->pin_count()-1 << "> "; out << "static vvm_and " << mname << "("
<< (gate->pin_count()-1 ) << ", ";
break; break;
case NetLogic::BUF: case NetLogic::BUF:
out << "static vvm_buf "; out << "static vvm_buf " << mname << "(";
break; break;
case NetLogic::BUFIF0: case NetLogic::BUFIF0:
out << "static vvm_bufif0 "; out << "static vvm_bufif0 " << mname << "(";
break; break;
case NetLogic::BUFIF1: case NetLogic::BUFIF1:
out << "static vvm_bufif1 "; out << "static vvm_bufif1 " << mname << "(";
break; break;
case NetLogic::NAND: case NetLogic::NAND:
out << "static vvm_nand" << "<" << gate->pin_count()-1 << "> "; out << "static vvm_nand " << mname << "("
<< (gate->pin_count()-1 ) << ", ";
break; break;
case NetLogic::NMOS: case NetLogic::NMOS:
out << "static vvm_nmos "; out << "static vvm_nmos " << mname << "(";
break; break;
case NetLogic::NOR: case NetLogic::NOR:
if ((gate->pin_count()-1) == 2) if ((gate->pin_count()-1) == 2)
out << "static vvm_nor2 "; out << "static vvm_nor2 " << mname << "(";
else else
out << "static vvm_nor" << "<" << gate->pin_count()-1 << "> "; out << "static vvm_nor " << mname << "("
<< (gate->pin_count()-1 ) << ", ";
break; break;
case NetLogic::NOT: case NetLogic::NOT:
out << "static vvm_not "; out << "static vvm_not " << mname << "(";
break; break;
case NetLogic::NOTIF0: case NetLogic::NOTIF0:
out << "static vvm_notif0 "; out << "static vvm_notif0 " << mname << "(";
break; break;
case NetLogic::NOTIF1: case NetLogic::NOTIF1:
out << "static vvm_notif1 "; out << "static vvm_notif1 " << mname << "(";
break; break;
case NetLogic::OR: case NetLogic::OR:
out << "static vvm_or" << "<" << gate->pin_count()-1 << "> "; out << "static vvm_or " << mname << "("
<< (gate->pin_count()-1 ) << ", ";
break; break;
case NetLogic::RNMOS: case NetLogic::RNMOS:
out << "static vvm_rnmos "; out << "static vvm_rnmos " << mname << "(";
break; break;
case NetLogic::RPMOS: case NetLogic::RPMOS:
out << "static vvm_rpmos "; out << "static vvm_rpmos " << mname << "(";
break; break;
case NetLogic::PMOS: case NetLogic::PMOS:
out << "static vvm_pmos "; out << "static vvm_pmos " << mname << "(";
break; break;
case NetLogic::XNOR: case NetLogic::XNOR:
out << "static vvm_xnor" << "<" << gate->pin_count()-1 << "> "; out << "static vvm_xnor " << mname << "("
<< (gate->pin_count()-1 ) << ", ";
break; break;
case NetLogic::XOR: case NetLogic::XOR:
out << "static vvm_xor" << "<" << gate->pin_count()-1 << "> "; out << "static vvm_xor " << mname << "("
<< (gate->pin_count()-1 ) << ", ";
break; break;
default: default:
out << "#error \"internal ivl error:bad gate type for " << out << "#error \"internal ivl error:bad gate type for " <<
gate->name() << "\"" << endl; gate->name() << "\"" << endl;
} }
out << mname << " (" << gate->rise_time() << ");" << endl; out << gate->rise_time() << ");" << endl;
/* Write the code to invoke startup for this object. */ /* Write the code to invoke startup for this object. */
@ -3621,6 +3627,9 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.201 2001/01/16 03:57:46 steve
* Get rid of gate templates.
*
* Revision 1.200 2001/01/12 04:20:18 steve * Revision 1.200 2001/01/12 04:20:18 steve
* Generated function prototype. (PR#107) * Generated function prototype. (PR#107)
* *

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) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_gates.cc,v 1.20 2000/12/10 06:42:00 steve Exp $" #ident "$Id: vvm_gates.cc,v 1.21 2001/01/16 03:57:46 steve Exp $"
#endif #endif
# include "vvm_gates.h" # include "vvm_gates.h"
@ -174,6 +174,35 @@ vpip_bit_t reduce_strength(vpip_bit_t val)
return(HiZ); return(HiZ);
} }
vvm_and::vvm_and(unsigned wid, unsigned long d)
: vvm_1bit_out(d), width_(wid)
{
input_ = new vpip_bit_t[wid];
}
vvm_and::~vvm_and()
{
delete [] input_;
}
void vvm_and::init_I(unsigned idx, vpip_bit_t val)
{
input_[idx] = val;
}
void vvm_and::start()
{
output(compute_and(input_,width_));
}
void vvm_and::take_value(unsigned key, vpip_bit_t val)
{
assert(key < width_);
if (input_[key] == val) return;
input_[key] = val;
output(compute_and(input_,width_));
}
vvm_and2::vvm_and2(unsigned long d) vvm_and2::vvm_and2(unsigned long d)
: vvm_1bit_out(d) : vvm_1bit_out(d)
{ {
@ -367,6 +396,93 @@ vpip_bit_t vvm_eeq::compute_() const
return outval; return outval;
} }
vvm_nand::vvm_nand(unsigned wid, unsigned long d)
: vvm_1bit_out(d), width_(wid)
{
input_ = new vpip_bit_t[wid];
}
vvm_nand::~vvm_nand()
{
delete [] input_;
}
void vvm_nand::init_I(unsigned idx, vpip_bit_t val)
{
input_[idx] = val;
}
void vvm_nand::start()
{
output(compute_nand(input_,width_));
}
void vvm_nand::take_value(unsigned key, vpip_bit_t val)
{
assert(key < width_);
if (input_[key] == val) return;
input_[key] = val;
output(compute_nand(input_, width_));
}
vvm_nor::vvm_nor(unsigned wid, unsigned long d)
: vvm_1bit_out(d), width_(wid)
{
input_ = new vpip_bit_t[wid];
}
vvm_nor::~vvm_nor()
{
delete [] input_;
}
void vvm_nor::init_I(unsigned idx, vpip_bit_t val)
{
input_[idx] = val;
}
void vvm_nor::start()
{
output(compute_nor(input_,width_));
}
void vvm_nor::take_value(unsigned key, vpip_bit_t val)
{
assert(key < width_);
if (input_[key] == val) return;
input_[key] = val;
output(compute_nor(input_, width_));
}
vvm_or::vvm_or(unsigned wid, unsigned long d)
: vvm_1bit_out(d), width_(wid)
{
input_ = new vpip_bit_t[wid];
}
vvm_or::~vvm_or()
{
delete [] input_;
}
void vvm_or::init_I(unsigned idx, vpip_bit_t val)
{
input_[idx] = val;
}
void vvm_or::start()
{
output(compute_or(input_,width_));
}
void vvm_or::take_value(unsigned key, vpip_bit_t val)
{
assert(key < width_);
if (input_[key] == val) return;
input_[key] = val;
output(compute_or(input_, width_));
}
vvm_nmos::vvm_nmos(unsigned long d) vvm_nmos::vvm_nmos(unsigned long d)
: vvm_1bit_out(d) : vvm_1bit_out(d)
{ {
@ -663,8 +779,69 @@ void vvm_notif1::take_value(unsigned key, vpip_bit_t val)
} }
} }
vvm_xnor::vvm_xnor(unsigned wid, unsigned long d)
: vvm_1bit_out(d), width_(wid)
{
input_ = new vpip_bit_t[wid];
}
vvm_xnor::~vvm_xnor()
{
delete [] input_;
}
void vvm_xnor::init_I(unsigned idx, vpip_bit_t val)
{
input_[idx] = val;
}
void vvm_xnor::start()
{
output(compute_xnor(input_,width_));
}
void vvm_xnor::take_value(unsigned key, vpip_bit_t val)
{
assert(key < width_);
if (input_[key] == val) return;
input_[key] = val;
output(compute_xnor(input_, width_));
}
vvm_xor::vvm_xor(unsigned wid, unsigned long d)
: vvm_1bit_out(d), width_(wid)
{
input_ = new vpip_bit_t[wid];
}
vvm_xor::~vvm_xor()
{
delete [] input_;
}
void vvm_xor::init_I(unsigned idx, vpip_bit_t val)
{
input_[idx] = val;
}
void vvm_xor::start()
{
output(compute_xor(input_,width_));
}
void vvm_xor::take_value(unsigned key, vpip_bit_t val)
{
assert(key < width_);
if (input_[key] == val) return;
input_[key] = val;
output(compute_xor(input_, width_));
}
/* /*
* $Log: vvm_gates.cc,v $ * $Log: vvm_gates.cc,v $
* Revision 1.21 2001/01/16 03:57:46 steve
* Get rid of gate templates.
*
* Revision 1.20 2000/12/10 06:42:00 steve * Revision 1.20 2000/12/10 06:42:00 steve
* Support delays on continuous assignment from idents. (PR#40) * Support delays on continuous assignment from idents. (PR#40)
* *

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) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_gates.h,v 1.69 2000/12/15 20:05:16 steve Exp $" #ident "$Id: vvm_gates.h,v 1.70 2001/01/16 03:57:46 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -136,30 +136,22 @@ class vvm_add_sub : public vvm_nexus::recvr_t {
* parameter. The vvm_andN classes are versions that have specific * parameter. The vvm_andN classes are versions that have specific
* widths. The latter should be preferred over the generic form. * widths. The latter should be preferred over the generic form.
*/ */
template <unsigned WIDTH>
class vvm_and : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_and : public vvm_1bit_out, public vvm_nexus::recvr_t {
public: public:
explicit vvm_and(unsigned d) explicit vvm_and(unsigned wid, unsigned long d);
: vvm_1bit_out(d) { } ~vvm_and();
void init_I(unsigned idx, vpip_bit_t val) void init_I(unsigned idx, vpip_bit_t val);
{ input_[idx] = val; }
void start();
void take_value(unsigned key, vpip_bit_t val);
void start()
{ output(compute_and(input_,WIDTH)); }
private: private:
void take_value(unsigned key, vpip_bit_t val) { set_I(key, val); } unsigned width_;
vpip_bit_t*input_;
void set_I(unsigned idx, vpip_bit_t val)
{ if (input_[idx] == val) return;
input_[idx] = val;
output(compute_and(input_,WIDTH));
}
private:
vpip_bit_t input_[WIDTH];
}; };
class vvm_and2 : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_and2 : public vvm_1bit_out, public vvm_nexus::recvr_t {
@ -450,57 +442,40 @@ class vvm_mux : public vvm_nexus::recvr_t {
vvm_mux& operator= (vvm_mux&); vvm_mux& operator= (vvm_mux&);
}; };
template <unsigned WIDTH>
class vvm_or : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_or : public vvm_1bit_out, public vvm_nexus::recvr_t {
public: public:
explicit vvm_or(unsigned long d) explicit vvm_or(unsigned wid, unsigned long d);
: vvm_1bit_out(d) { } ~vvm_or();
void init_I(unsigned idx, vpip_bit_t val) void init_I(unsigned idx, vpip_bit_t val);
{ input_[idx] = val; }
void start() void start();
{ output(compute_or(input_,WIDTH)); }
private: private:
void take_value(unsigned key, vpip_bit_t val) { set_I(key, val); } void take_value(unsigned key, vpip_bit_t val);
void set_I(unsigned idx, vpip_bit_t val)
{ if (input_[idx] == val)
return;
input_[idx] = val;
output(compute_or(input_,WIDTH));
}
private: private:
vpip_bit_t input_[WIDTH]; unsigned width_;
vpip_bit_t*input_;
}; };
template <unsigned WIDTH>
class vvm_nor : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_nor : public vvm_1bit_out, public vvm_nexus::recvr_t {
public: public:
explicit vvm_nor(unsigned long d) explicit vvm_nor(unsigned wid, unsigned long d);
: vvm_1bit_out(d) { } ~vvm_nor();
void init_I(unsigned idx, vpip_bit_t val) void init_I(unsigned idx, vpip_bit_t val);
{ input_[idx] = val; }
void start() void start();
{ output(compute_nor(input_,WIDTH)); }
private: private:
void take_value(unsigned key, vpip_bit_t val) { set_I(key, val); } void take_value(unsigned key, vpip_bit_t val);
void set_I(unsigned idx, vpip_bit_t val) private:
{ if (input_[idx] == val) unsigned width_;
return; vpip_bit_t*input_;
input_[idx] = val;
output(compute_nor(input_,WIDTH));
}
vpip_bit_t input_[WIDTH];
}; };
class vvm_nor2 : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_nor2 : public vvm_1bit_out, public vvm_nexus::recvr_t {
@ -671,30 +646,23 @@ class vvm_notif1 : public vvm_1bit_out, public vvm_nexus::recvr_t {
void take_value(unsigned key, vpip_bit_t val); void take_value(unsigned key, vpip_bit_t val);
}; };
template <unsigned WIDTH>
class vvm_nand : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_nand : public vvm_1bit_out, public vvm_nexus::recvr_t {
public: public:
explicit vvm_nand(unsigned long d) explicit vvm_nand(unsigned wid, unsigned long d);
: vvm_1bit_out(d) { } ~vvm_nand();
void init_I(unsigned idx, vpip_bit_t val) void init_I(unsigned idx, vpip_bit_t val);
{ input_[idx] = val; }
void start() void start();
{ output(compute_nand(input_,WIDTH)); }
private: private:
void take_value(unsigned key, vpip_bit_t val) { set_I(key, val); } void take_value(unsigned key, vpip_bit_t val);
void set_I(unsigned idx, vpip_bit_t val)
{ if (input_[idx] == val) return;
input_[idx] = val;
output(compute_nand(input_,WIDTH));
}
private: private:
vpip_bit_t input_[WIDTH]; unsigned width_;
vpip_bit_t*input_;
}; };
/* /*
@ -765,56 +733,41 @@ class vvm_rpmos : public vvm_1bit_out, public vvm_nexus::recvr_t {
}; };
template <unsigned WIDTH>
class vvm_xnor : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_xnor : public vvm_1bit_out, public vvm_nexus::recvr_t {
public: public:
explicit vvm_xnor(unsigned long d) explicit vvm_xnor(unsigned wid, unsigned long d);
: vvm_1bit_out(d) { } ~vvm_xnor();
void init_I(unsigned idx, vpip_bit_t val) { input_[idx] = val; } void init_I(unsigned idx, vpip_bit_t val);
void start() void start();
{ output(compute_xnor(input_,WIDTH)); }
private: private:
void take_value(unsigned key, vpip_bit_t val) { set_I(key, val); } void take_value(unsigned key, vpip_bit_t val);
void set_I(unsigned idx, vpip_bit_t val)
{ if (input_[idx] == val)
return;
input_[idx] = val;
output(compute_xnor(input_,WIDTH));
}
private: private:
vpip_bit_t input_[WIDTH]; unsigned width_;
vpip_bit_t*input_;
}; };
template <unsigned WIDTH>
class vvm_xor : public vvm_1bit_out, public vvm_nexus::recvr_t { class vvm_xor : public vvm_1bit_out, public vvm_nexus::recvr_t {
public: public:
explicit vvm_xor(unsigned long d) explicit vvm_xor(unsigned wid, unsigned long d);
: vvm_1bit_out(d) { } ~vvm_xor();
void init_I(unsigned idx, vpip_bit_t val) void init_I(unsigned idx, vpip_bit_t val);
{ input_[idx] = val; }
void start() void start();
{ output(compute_xor(input_,WIDTH)); }
private: private:
void take_value(unsigned key, vpip_bit_t val) { set_I(key, val); } void take_value(unsigned key, vpip_bit_t val);
void set_I(unsigned idx, vpip_bit_t val)
{ if (input_[idx] == val)
return;
input_[idx] = val;
output(compute_xor(input_,WIDTH)); }
private: private:
vpip_bit_t input_[WIDTH]; unsigned width_;
vpip_bit_t*input_;
}; };
/* /*
@ -1006,6 +959,9 @@ class vvm_posedge : public vvm_nexus::recvr_t {
/* /*
* $Log: vvm_gates.h,v $ * $Log: vvm_gates.h,v $
* Revision 1.70 2001/01/16 03:57:46 steve
* Get rid of gate templates.
*
* Revision 1.69 2000/12/15 20:05:16 steve * Revision 1.69 2000/12/15 20:05:16 steve
* Fix memory access in vvm. (PR#70) * Fix memory access in vvm. (PR#70)
* *