From a4298df776ea269e096f239555102cffb4e46796 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 9 Oct 1999 19:24:36 +0000 Subject: [PATCH] NOR device. --- vvm/vvm_gates.h | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/vvm/vvm_gates.h b/vvm/vvm_gates.h index 690edb8a2..e1946ba3f 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.12 1999/07/17 03:07:27 steve Exp $" +#ident "$Id: vvm_gates.h,v 1.13 1999/10/09 19:24:36 steve Exp $" #endif # include "vvm.h" @@ -131,6 +131,47 @@ template class vvm_or { vvm_out_event::action_t output_; }; +template class vvm_nor { + + public: + explicit vvm_nor(vvm_out_event::action_t o) + : output_(o) { } + + void init(unsigned idx, vvm_bit_t val) + { input_[idx-1] = val; } + + void start(vvm_simulation*sim) + { vvm_event*ev = new vvm_out_event(sim, compute_(), output_); + if (DELAY > 0) + sim->insert_event(DELAY, ev); + else + sim->active_event(ev); + } + + void set(vvm_simulation*sim, unsigned idx, vvm_bit_t val) + { if (input_[idx-1] == val) + return; + input_[idx-1] = val; + + vvm_event*ev = new vvm_out_event(sim, compute_(), output_); + if (DELAY > 0) + sim->insert_event(DELAY, ev); + else + sim->active_event(ev); + } + + private: + vvm_bit_t compute_() const + { vvm_bit_t outval = input_[0]; + for (unsigned i = 1 ; i < WIDTH ; i += 1) + outval = outval | input_[i]; + return not(outval); + } + + vvm_bit_t input_[WIDTH]; + vvm_out_event::action_t output_; +}; + template class vvm_bufif1 { public: @@ -455,6 +496,9 @@ template class vvm_pevent { /* * $Log: vvm_gates.h,v $ + * Revision 1.13 1999/10/09 19:24:36 steve + * NOR device. + * * Revision 1.12 1999/07/17 03:07:27 steve * pevent objects have initial values. *