From 4f8a7ea84a902c4ec0a1ed4d7bb004a0d4b1da5b Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 28 Nov 2006 05:57:20 +0000 Subject: [PATCH] Use new vvp_fun_XXX in place of old functor table for NAND/NOR/XNOR/EEQ. --- vvp/draw_tt.c | 24 ++++++++--------- vvp/logic.cc | 73 ++++++++++++++++++++++++++++++++++++++------------- vvp/logic.h | 28 +++++++++++++++----- 3 files changed, 88 insertions(+), 37 deletions(-) diff --git a/vvp/draw_tt.c b/vvp/draw_tt.c index 2c86f5639..0f04cd1f3 100644 --- a/vvp/draw_tt.c +++ b/vvp/draw_tt.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: draw_tt.c,v 1.22 2005/09/19 21:45:09 steve Exp $" +#ident "$Id: draw_tt.c,v 1.23 2006/11/28 05:57:20 steve Exp $" #endif # include @@ -57,7 +57,7 @@ static void draw_AND(void) printf("};\n"); } #endif - +#if 0 static void draw_NAND(void) { unsigned i0, i1, i2, i3; @@ -91,7 +91,7 @@ static void draw_NAND(void) printf("};\n"); } - +#endif #if 0 static void draw_BUF(void) { @@ -373,7 +373,7 @@ static void draw_MUXZ(void) printf("};\n"); } #endif - +#if 0 static void draw_EEQ(void) { unsigned i0, i1, i2, i3; @@ -405,7 +405,8 @@ static void draw_EEQ(void) printf("};\n"); } - +#endif +#if 0 static void draw_NOR(void) { unsigned i0, i1, i2, i3; @@ -439,7 +440,7 @@ static void draw_NOR(void) printf("};\n"); } - +#endif #if 0 static void draw_NOT(void) { @@ -508,7 +509,7 @@ static void draw_OR(void) printf("};\n"); } #endif - +#if 0 static void draw_XNOR(void) { unsigned i0, i1, i2, i3; @@ -540,7 +541,7 @@ static void draw_XNOR(void) printf("};\n"); } - +#endif #if 0 static void draw_XOR(void) { @@ -750,12 +751,8 @@ main() { printf("# include \"logic.h\"\n"); draw_MUXX(); - draw_EEQ(); - draw_NAND(); - draw_NOR(); draw_TRIAND(); draw_TRIOR(); - draw_XNOR(); draw_hex_table(); draw_oct_table(); return 0; @@ -763,6 +760,9 @@ main() /* * $Log: draw_tt.c,v $ + * Revision 1.23 2006/11/28 05:57:20 steve + * Use new vvp_fun_XXX in place of old functor table for NAND/NOR/XNOR/EEQ. + * * Revision 1.22 2005/09/19 21:45:09 steve * Use lazy eval of BUF/NOT/OR/XOR gates. * diff --git a/vvp/logic.cc b/vvp/logic.cc index 6caeadba6..97f3588c7 100644 --- a/vvp/logic.cc +++ b/vvp/logic.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: logic.cc,v 1.36 2006/01/02 05:32:07 steve Exp $" +#ident "$Id: logic.cc,v 1.37 2006/11/28 05:57:20 steve Exp $" #endif # include "logic.h" @@ -104,8 +104,8 @@ void vvp_fun_boolean_::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit) } } -vvp_fun_and::vvp_fun_and(unsigned wid) -: vvp_fun_boolean_(wid) +vvp_fun_and::vvp_fun_and(unsigned wid, bool invert) +: vvp_fun_boolean_(wid), invert_(invert) { } @@ -129,6 +129,8 @@ void vvp_fun_and::run_run() } bitbit = bitbit & input_[pdx].value(idx); + if (invert_) + bitbit = ~bitbit; } result.set_bit(idx, bitbit); @@ -137,6 +139,34 @@ void vvp_fun_and::run_run() vvp_send_vec4(ptr->out, result); } +vvp_fun_eeq::vvp_fun_eeq(unsigned wid, bool invert) +: vvp_fun_boolean_(wid), invert_(invert) +{ +} + +vvp_fun_eeq::~vvp_fun_eeq() +{ +} + +void vvp_fun_eeq::run_run() +{ + vvp_net_t*ptr = net_; + net_ = 0; + + vvp_vector4_t result (input_[0]); + + for (unsigned idx = 0 ; idx < result.size() ; idx += 1) { + vvp_bit4_t bitbit = result.value(idx); + bitbit = (bitbit == input_[1].value(idx))? BIT4_1 : BIT4_0; + if (invert_) + bitbit = ~bitbit; + + result.set_bit(idx, bitbit); + } + + vvp_send_vec4(ptr->out, result); +} + vvp_fun_buf::vvp_fun_buf() { net_ = 0; @@ -400,8 +430,8 @@ void vvp_fun_not::run_run() vvp_send_vec4(ptr->out, result); } -vvp_fun_or::vvp_fun_or(unsigned wid) -: vvp_fun_boolean_(wid) +vvp_fun_or::vvp_fun_or(unsigned wid, bool invert) +: vvp_fun_boolean_(wid), invert_(invert) { } @@ -427,14 +457,16 @@ void vvp_fun_or::run_run() bitbit = bitbit | input_[pdx].value(idx); } + if (invert_) + bitbit = ~bitbit; result.set_bit(idx, bitbit); } vvp_send_vec4(ptr->out, result); } -vvp_fun_xor::vvp_fun_xor(unsigned wid) -: vvp_fun_boolean_(wid) +vvp_fun_xor::vvp_fun_xor(unsigned wid, bool invert) +: vvp_fun_boolean_(wid), invert_(invert) { } @@ -460,6 +492,8 @@ void vvp_fun_xor::run_run() bitbit = bitbit ^ input_[pdx].value(idx); } + if (invert_) + bitbit = ~bitbit; result.set_bit(idx, bitbit); } @@ -480,10 +514,10 @@ void compile_functor(char*label, char*type, unsigned width, bool strength_aware = false; if (strcmp(type, "OR") == 0) { - obj = new vvp_fun_or(width); + obj = new vvp_fun_or(width, false); } else if (strcmp(type, "AND") == 0) { - obj = new vvp_fun_and(width); + obj = new vvp_fun_and(width, false); } else if (strcmp(type, "BUF") == 0) { obj = new vvp_fun_buf(); @@ -496,6 +530,12 @@ void compile_functor(char*label, char*type, unsigned width, obj = new vvp_fun_bufif(false,false, ostr0, ostr1); strength_aware = true; + } else if (strcmp(type, "NAND") == 0) { + obj = new vvp_fun_and(width, true); + + } else if (strcmp(type, "NOR") == 0) { + obj = new vvp_fun_or(width, true); + } else if (strcmp(type, "NOTIF0") == 0) { obj = new vvp_fun_bufif(true,true, ostr0, ostr1); strength_aware = true; @@ -529,22 +569,16 @@ void compile_functor(char*label, char*type, unsigned width, obj = new vvp_fun_rpmos(false); } else if (strcmp(type, "EEQ") == 0) { - obj = new table_functor_s(ft_EEQ); - - } else if (strcmp(type, "NAND") == 0) { - obj = new table_functor_s(ft_NAND); - - } else if (strcmp(type, "NOR") == 0) { - obj = new table_functor_s(ft_NOR); + obj = new vvp_fun_eeq(width, false); } else if (strcmp(type, "NOT") == 0) { obj = new vvp_fun_not(); } else if (strcmp(type, "XNOR") == 0) { - obj = new table_functor_s(ft_XNOR); + obj = new vvp_fun_xor(width, true); } else if (strcmp(type, "XOR") == 0) { - obj = new vvp_fun_xor(width); + obj = new vvp_fun_xor(width, false); } else { yyerror("invalid functor type."); @@ -586,6 +620,9 @@ void compile_functor(char*label, char*type, unsigned width, /* * $Log: logic.cc,v $ + * Revision 1.37 2006/11/28 05:57:20 steve + * Use new vvp_fun_XXX in place of old functor table for NAND/NOR/XNOR/EEQ. + * * Revision 1.36 2006/01/02 05:32:07 steve * Require explicit delay node from source. * diff --git a/vvp/logic.h b/vvp/logic.h index cd2b6b0cf..4e8f6cc9a 100644 --- a/vvp/logic.h +++ b/vvp/logic.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: logic.h,v 1.24 2005/09/19 21:45:09 steve Exp $" +#ident "$Id: logic.h,v 1.25 2006/11/28 05:57:20 steve Exp $" #endif # include "vvp_net.h" @@ -64,11 +64,23 @@ class vvp_fun_boolean_ : public vvp_net_fun_t, protected vvp_gen_event_s { class vvp_fun_and : public vvp_fun_boolean_ { public: - explicit vvp_fun_and(unsigned wid); + explicit vvp_fun_and(unsigned wid, bool invert); ~vvp_fun_and(); private: void run_run(); + bool invert_; +}; + +class vvp_fun_eeq : public vvp_fun_boolean_ { + + public: + explicit vvp_fun_eeq(unsigned wid, bool invert); + ~vvp_fun_eeq(); + + private: + void run_run(); + bool invert_; }; /* @@ -168,35 +180,37 @@ class vvp_fun_not: public vvp_net_fun_t, private vvp_gen_event_s { class vvp_fun_or : public vvp_fun_boolean_ { public: - explicit vvp_fun_or(unsigned wid); + explicit vvp_fun_or(unsigned wid, bool invert); ~vvp_fun_or(); private: void run_run(); + bool invert_; }; class vvp_fun_xor : public vvp_fun_boolean_ { public: - explicit vvp_fun_xor(unsigned wid); + explicit vvp_fun_xor(unsigned wid, bool invert); ~vvp_fun_xor(); private: void run_run(); + bool invert_; }; // table functor types extern const unsigned char ft_MUXX[]; extern const unsigned char ft_EEQ[]; -extern const unsigned char ft_NAND[]; -extern const unsigned char ft_NOR[]; extern const unsigned char ft_TRIAND[]; extern const unsigned char ft_TRIOR[]; -extern const unsigned char ft_XNOR[]; /* * $Log: logic.h,v $ + * Revision 1.25 2006/11/28 05:57:20 steve + * Use new vvp_fun_XXX in place of old functor table for NAND/NOR/XNOR/EEQ. + * * Revision 1.24 2005/09/19 21:45:09 steve * Use lazy eval of BUF/NOT/OR/XOR gates. *