From 6446add9cd3fdc2fa03cc72456a10a5a89781ed9 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 23 Apr 2000 21:15:07 +0000 Subject: [PATCH] Emit code for the bufif devices. --- netlist.h | 8 ++++++-- t-xnf.cc | 44 ++++++++++++++++++++++++++++++++++++-------- vvm/vvm_gates.cc | 43 ++++++++++++++++++++++++++++++++++++++++--- vvm/vvm_gates.h | 19 ++++++++++++++++++- 4 files changed, 100 insertions(+), 14 deletions(-) diff --git a/netlist.h b/netlist.h index 7bc8255e4..82db0b469 100644 --- a/netlist.h +++ b/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.128 2000/04/23 03:45:24 steve Exp $" +#ident "$Id: netlist.h,v 1.129 2000/04/23 21:15:07 steve Exp $" #endif /* @@ -823,7 +823,8 @@ class NetConst : public NetNode { /* * This class represents all manner of logic gates. Pin 0 is OUTPUT and - * all the remaining pins are INPUT + * all the remaining pins are INPUT. The BUFIF[01] gates have the + * additional restriction that pin 1 is the enable. */ class NetLogic : public NetNode { @@ -2440,6 +2441,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.129 2000/04/23 21:15:07 steve + * Emit code for the bufif devices. + * * Revision 1.128 2000/04/23 03:45:24 steve * Add support for the procedural release statement. * diff --git a/t-xnf.cc b/t-xnf.cc index 17d72d68d..c4272ec22 100644 --- a/t-xnf.cc +++ b/t-xnf.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-xnf.cc,v 1.24 2000/04/20 02:34:47 steve Exp $" +#ident "$Id: t-xnf.cc,v 1.25 2000/04/23 21:15:07 steve Exp $" #endif /* XNF BACKEND @@ -773,21 +773,46 @@ void target_xnf::logic(ostream&os, const NetLogic*net) case NetLogic::XOR: os << "XOR"; break; + case NetLogic::BUFIF0: + case NetLogic::BUFIF1: + os << "TBUF"; + break; default: - cerr << "XNF: Unhandled logic type." << endl; + cerr << "internal error: XNF: Unhandled logic type." << endl; break; } os << ", LIBVER=2.0.0" << endl; + /* All of these kinds of devices have an output on pin 0. */ draw_pin(os, "O", net->pin(0)); - if (net->pin_count() == 2) { + /* Most devices have inputs called I for all the remaining + pins. The TBUF devices are slightly different, but + essentially the same structure. */ + switch (net->type()) { + + case NetLogic::BUFIF0: + assert(net->pin_count() == 3); + draw_pin(os, "I", net->pin(1)); + draw_pin(os, "~T", net->pin(2)); + break; + + case NetLogic::BUFIF1: + assert(net->pin_count() == 3); draw_pin(os, "I", net->pin(1)); - } else for (unsigned idx = 1 ; idx < net->pin_count() ; idx += 1) { - string name = "I"; - assert(net->pin_count() <= 11); - name += (char)('0'+idx-1); - draw_pin(os, name, net->pin(idx)); + draw_pin(os, "T", net->pin(2)); + break; + + default: + if (net->pin_count() == 2) { + draw_pin(os, "I", net->pin(1)); + } else for (unsigned idx = 1; idx < net->pin_count(); idx += 1) { + string name = "I"; + assert(net->pin_count() <= 11); + name += (char)('0'+idx-1); + draw_pin(os, name, net->pin(idx)); + } + break; } os << "END" << endl; @@ -828,6 +853,9 @@ extern const struct target tgt_xnf = { "xnf", &target_xnf_obj }; /* * $Log: t-xnf.cc,v $ + * Revision 1.25 2000/04/23 21:15:07 steve + * Emit code for the bufif devices. + * * Revision 1.24 2000/04/20 02:34:47 steve * Generate code for identity compare. Use gates. * diff --git a/vvm/vvm_gates.cc b/vvm/vvm_gates.cc index 0b389ffc6..e0a97823f 100644 --- a/vvm/vvm_gates.cc +++ b/vvm/vvm_gates.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_gates.cc,v 1.12 2000/03/22 04:26:41 steve Exp $" +#ident "$Id: vvm_gates.cc,v 1.13 2000/04/23 21:15:07 steve Exp $" #endif # include "vvm_gates.h" @@ -149,6 +149,38 @@ void vvm_buf::take_value(unsigned, vpip_bit_t val) output(outval); } +vvm_bufif0::vvm_bufif0(unsigned long d) +: vvm_1bit_out(d) +{ + input_[0] = StX; + input_[1] = StX; +} + +vvm_bufif0::~vvm_bufif0() +{ +} + +void vvm_bufif0::init_I(unsigned key, vpip_bit_t val) +{ + assert(key < 2); + input_[key] = val; +} + +void vvm_bufif0::take_value(unsigned key, vpip_bit_t val) +{ + if (input_[key] == val) return; + input_[key] = val; + + if (! B_IS0(input_[1])) + output(HiZ); + else if (B_ISXZ(input_[0])) + output(StX); + else if (B_IS1(input_[0])) + output(St1); + else + output(St0); +} + vvm_bufif1::vvm_bufif1(unsigned long d) : vvm_1bit_out(d) { @@ -160,8 +192,10 @@ vvm_bufif1::~vvm_bufif1() { } -void vvm_bufif1::init_I(unsigned, vpip_bit_t) +void vvm_bufif1::init_I(unsigned key, vpip_bit_t val) { + assert(key < 2); + input_[key] = val; } void vvm_bufif1::take_value(unsigned key, vpip_bit_t val) @@ -173,7 +207,7 @@ void vvm_bufif1::take_value(unsigned key, vpip_bit_t val) output(HiZ); else if (B_ISXZ(input_[0])) output(StX); - else if (B_IS1(val)) + else if (B_IS1(input_[0])) output(St1); else output(St0); @@ -285,6 +319,9 @@ void vvm_not::take_value(unsigned, vpip_bit_t val) /* * $Log: vvm_gates.cc,v $ + * Revision 1.13 2000/04/23 21:15:07 steve + * Emit code for the bufif devices. + * * Revision 1.12 2000/03/22 04:26:41 steve * Replace the vpip_bit_t with a typedef and * define values for all the different bit diff --git a/vvm/vvm_gates.h b/vvm/vvm_gates.h index 47a87b377..e307a2df2 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) && !defined(macintosh) -#ident "$Id: vvm_gates.h,v 1.59 2000/04/23 03:45:25 steve Exp $" +#ident "$Id: vvm_gates.h,v 1.60 2000/04/23 21:15:07 steve Exp $" #endif # include "vvm.h" @@ -567,6 +567,20 @@ class vvm_buf : public vvm_1bit_out, public vvm_nexus::recvr_t { void take_value(unsigned, vpip_bit_t val); }; +class vvm_bufif0 : public vvm_1bit_out, public vvm_nexus::recvr_t { + + public: + explicit vvm_bufif0(unsigned long d); + ~vvm_bufif0(); + + void init_I(unsigned, vpip_bit_t); + void start() { } + + private: + vpip_bit_t input_[2]; + void take_value(unsigned key, vpip_bit_t val); +}; + class vvm_bufif1 : public vvm_1bit_out, public vvm_nexus::recvr_t { public: @@ -916,6 +930,9 @@ class vvm_posedge : public vvm_nexus::recvr_t { /* * $Log: vvm_gates.h,v $ + * Revision 1.60 2000/04/23 21:15:07 steve + * Emit code for the bufif devices. + * * Revision 1.59 2000/04/23 03:45:25 steve * Add support for the procedural release statement. *