From 431b16639da20c5f433a66a0fd3cff06707b320c Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 29 Apr 2001 23:13:33 +0000 Subject: [PATCH] Add bufif0 and bufif1 functors. --- vvp/compile.cc | 11 +++++++- vvp/draw_tt.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++- vvp/functor.h | 7 ++++- 3 files changed, 90 insertions(+), 3 deletions(-) diff --git a/vvp/compile.cc b/vvp/compile.cc index 409591a16..f6e258004 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: compile.cc,v 1.45 2001/04/29 22:59:46 steve Exp $" +#ident "$Id: compile.cc,v 1.46 2001/04/29 23:13:33 steve Exp $" #endif # include "compile.h" @@ -282,6 +282,12 @@ void compile_functor(char*label, char*type, unsigned init, } else if (strcmp(type, "BUF") == 0) { obj->table = ft_BUF; + } else if (strcmp(type, "BUFIF0") == 0) { + obj->table = ft_BUFIF0; + + } else if (strcmp(type, "BUFIF1") == 0) { + obj->table = ft_BUFIF1; + } else if (strcmp(type, "MUXZ") == 0) { obj->table = ft_MUXZ; @@ -931,6 +937,9 @@ void compile_dump(FILE*fd) /* * $Log: compile.cc,v $ + * Revision 1.46 2001/04/29 23:13:33 steve + * Add bufif0 and bufif1 functors. + * * Revision 1.45 2001/04/29 22:59:46 steve * Support .net constant inputs. * diff --git a/vvp/draw_tt.c b/vvp/draw_tt.c index d60d21671..c2f26fee2 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 */ #if !defined(WINNT) -#ident "$Id: draw_tt.c,v 1.7 2001/04/26 05:12:02 steve Exp $" +#ident "$Id: draw_tt.c,v 1.8 2001/04/29 23:13:34 steve Exp $" #endif # include @@ -122,6 +122,74 @@ static void draw_BUF(void) printf("};\n"); } +static void draw_BUFIF0(void) +{ + unsigned i0, i1, i2, i3; + + printf("const unsigned char ft_BUFIF0[64] = {"); + + for (i3 = 0 ; i3 < 4 ; i3 += 1) + for (i2 = 0 ; i2 < 4 ; i2 += 1) { + printf("\n "); + for (i1 = 0 ; i1 < 4 ; i1 += 1) { + unsigned idx = (i3 << 4) | (i2 << 2) | i1; + unsigned char byte = 0; + + for (i0 = 0 ; i0 < 4 ; i0 += 1) { + unsigned val; + if (i2 == 0) + val = 3; + else if (i0 == 1) + val = 1; + else if (i0 == 0) + val = 0; + else + val = 2; + + byte |= val << (i0*2); + } + + printf("0x%02x, ", byte); + } + } + + printf("};\n"); +} + +static void draw_BUFIF1(void) +{ + unsigned i0, i1, i2, i3; + + printf("const unsigned char ft_BUFIF1[64] = {"); + + for (i3 = 0 ; i3 < 4 ; i3 += 1) + for (i2 = 0 ; i2 < 4 ; i2 += 1) { + printf("\n "); + for (i1 = 0 ; i1 < 4 ; i1 += 1) { + unsigned idx = (i3 << 4) | (i2 << 2) | i1; + unsigned char byte = 0; + + for (i0 = 0 ; i0 < 4 ; i0 += 1) { + unsigned val; + if (i2 == 1) + val = 3; + else if (i0 == 1) + val = 1; + else if (i0 == 0) + val = 0; + else + val = 2; + + byte |= val << (i0*2); + } + + printf("0x%02x, ", byte); + } + } + + printf("};\n"); +} + static void draw_MUXZ(void) { unsigned i0, i1, i2, i3; @@ -429,6 +497,8 @@ main() printf("# include \"functor.h\"\n"); draw_AND(); draw_BUF(); + draw_BUFIF0(); + draw_BUFIF1(); draw_MUXZ(); draw_NAND(); draw_NOR(); @@ -443,6 +513,9 @@ main() /* * $Log: draw_tt.c,v $ + * Revision 1.8 2001/04/29 23:13:34 steve + * Add bufif0 and bufif1 functors. + * * Revision 1.7 2001/04/26 05:12:02 steve * Implement simple MUXZ for ?: operators. * diff --git a/vvp/functor.h b/vvp/functor.h index 198c02cea..86dc46aa9 100644 --- a/vvp/functor.h +++ b/vvp/functor.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: functor.h,v 1.16 2001/04/26 15:52:22 steve Exp $" +#ident "$Id: functor.h,v 1.17 2001/04/29 23:13:34 steve Exp $" #endif # include "pointers.h" @@ -190,6 +190,8 @@ extern void functor_dump(FILE*fd); extern const unsigned char ft_AND[]; extern const unsigned char ft_BUF[]; +extern const unsigned char ft_BUFIF0[]; +extern const unsigned char ft_BUFIF1[]; extern const unsigned char ft_MUXZ[]; extern const unsigned char ft_NAND[]; extern const unsigned char ft_NOR[]; @@ -201,6 +203,9 @@ extern const unsigned char ft_var[]; /* * $Log: functor.h,v $ + * Revision 1.17 2001/04/29 23:13:34 steve + * Add bufif0 and bufif1 functors. + * * Revision 1.16 2001/04/26 15:52:22 steve * Add the mode-42 functor concept to UDPs. *