From 76a141c9994f1b7197d53dd6062f19524c32c284 Mon Sep 17 00:00:00 2001 From: Ludovic Jacomme Date: Wed, 20 Mar 2002 12:34:02 +0000 Subject: [PATCH] Maintenant c'est le tour des VEX --- alliance/src/vex/Makefile.am | 1 + alliance/src/vex/configure.in | 45 + alliance/src/vex/src/Makefile.am | 12 + alliance/src/vex/src/main.c | 155 ++++ alliance/src/vex/src/vex.h | 693 ++++++++++++++ alliance/src/vex/src/vexadd.c | 115 +++ alliance/src/vex/src/vexadd.h | 75 ++ alliance/src/vex/src/vexalloc.c | 123 +++ alliance/src/vex/src/vexalloc.h | 75 ++ alliance/src/vex/src/vexcreate.c | 530 +++++++++++ alliance/src/vex/src/vexcreate.h | 75 ++ alliance/src/vex/src/vexdel.c | 144 +++ alliance/src/vex/src/vexdel.h | 75 ++ alliance/src/vex/src/vexdup.c | 115 +++ alliance/src/vex/src/vexdup.h | 75 ++ alliance/src/vex/src/vexenv.c | 270 ++++++ alliance/src/vex/src/vexenv.h | 75 ++ alliance/src/vex/src/vexerror.c | 113 +++ alliance/src/vex/src/vexerror.h | 85 ++ alliance/src/vex/src/vexeval.c | 303 +++++++ alliance/src/vex/src/vexeval.h | 75 ++ alliance/src/vex/src/vexextend.c | 261 ++++++ alliance/src/vex/src/vexextend.h | 75 ++ alliance/src/vex/src/vexfree.c | 119 +++ alliance/src/vex/src/vexfree.h | 75 ++ alliance/src/vex/src/vexget.c | 1151 ++++++++++++++++++++++++ alliance/src/vex/src/vexget.h | 75 ++ alliance/src/vex/src/vexis.c | 634 +++++++++++++ alliance/src/vex/src/vexis.h | 79 ++ alliance/src/vex/src/vexoptim.c | 218 +++++ alliance/src/vex/src/vexoptim.h | 75 ++ alliance/src/vex/src/vexshift.c | 240 +++++ alliance/src/vex/src/vexshift.h | 75 ++ alliance/src/vex/src/vexsimp.c | 1449 ++++++++++++++++++++++++++++++ alliance/src/vex/src/vexsimp.h | 75 ++ alliance/src/vex/src/vexslice.c | 162 ++++ alliance/src/vex/src/vexslice.h | 75 ++ alliance/src/vex/src/vexunflat.c | 142 +++ alliance/src/vex/src/vexunflat.h | 75 ++ alliance/src/vex/src/vexview.c | 586 ++++++++++++ alliance/src/vex/src/vexview.h | 79 ++ 41 files changed, 8949 insertions(+) create mode 100644 alliance/src/vex/Makefile.am create mode 100644 alliance/src/vex/configure.in create mode 100644 alliance/src/vex/src/Makefile.am create mode 100644 alliance/src/vex/src/main.c create mode 100644 alliance/src/vex/src/vex.h create mode 100644 alliance/src/vex/src/vexadd.c create mode 100644 alliance/src/vex/src/vexadd.h create mode 100644 alliance/src/vex/src/vexalloc.c create mode 100644 alliance/src/vex/src/vexalloc.h create mode 100644 alliance/src/vex/src/vexcreate.c create mode 100644 alliance/src/vex/src/vexcreate.h create mode 100644 alliance/src/vex/src/vexdel.c create mode 100644 alliance/src/vex/src/vexdel.h create mode 100644 alliance/src/vex/src/vexdup.c create mode 100644 alliance/src/vex/src/vexdup.h create mode 100644 alliance/src/vex/src/vexenv.c create mode 100644 alliance/src/vex/src/vexenv.h create mode 100644 alliance/src/vex/src/vexerror.c create mode 100644 alliance/src/vex/src/vexerror.h create mode 100644 alliance/src/vex/src/vexeval.c create mode 100644 alliance/src/vex/src/vexeval.h create mode 100644 alliance/src/vex/src/vexextend.c create mode 100644 alliance/src/vex/src/vexextend.h create mode 100644 alliance/src/vex/src/vexfree.c create mode 100644 alliance/src/vex/src/vexfree.h create mode 100644 alliance/src/vex/src/vexget.c create mode 100644 alliance/src/vex/src/vexget.h create mode 100644 alliance/src/vex/src/vexis.c create mode 100644 alliance/src/vex/src/vexis.h create mode 100644 alliance/src/vex/src/vexoptim.c create mode 100644 alliance/src/vex/src/vexoptim.h create mode 100644 alliance/src/vex/src/vexshift.c create mode 100644 alliance/src/vex/src/vexshift.h create mode 100644 alliance/src/vex/src/vexsimp.c create mode 100644 alliance/src/vex/src/vexsimp.h create mode 100644 alliance/src/vex/src/vexslice.c create mode 100644 alliance/src/vex/src/vexslice.h create mode 100644 alliance/src/vex/src/vexunflat.c create mode 100644 alliance/src/vex/src/vexunflat.h create mode 100644 alliance/src/vex/src/vexview.c create mode 100644 alliance/src/vex/src/vexview.h diff --git a/alliance/src/vex/Makefile.am b/alliance/src/vex/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/vex/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/vex/configure.in b/alliance/src/vex/configure.in new file mode 100644 index 00000000..d19f8716 --- /dev/null +++ b/alliance/src/vex/configure.in @@ -0,0 +1,45 @@ +dnl +/* +dnl This file is part of the Alliance CAD System +dnl Copyright (C) Laboratoire LIP6 - Département ASIM +dnl Universite Pierre et Marie Curie +dnl +dnl Home page : http://www-asim.lip6.fr/alliance/ +dnl E-mail support : mailto:alliance-support@asim.lip6.fr +dnl +dnl This library is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU Library General Public License as published +dnl by the Free Software Foundation; either version 2 of the License, or (at +dnl your option) any later version. +dnl +dnl Alliance VLSI CAD System is distributed in the hope that it will be +dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with the GNU C Library; see the file COPYING. If not, write to the Free +dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl +dnl Purpose : Auto stuffing Alliance +dnl Almost ten years since I wrote this stuff, I just can't +dnl believe it +dnl Date : 01/02/2002 +dnl Author : Frederic Petrot +dnl $Id: configure.in,v 1.1 2002/03/20 12:34:01 ludo Exp $ +dnl +dnl +AC_INIT(src/vex.h) +AM_INIT_AUTOMAKE(vex, 1.3) +AC_PROG_INSTALL +AC_PROG_CC +AC_HEADER_STDC +AC_C_CONST +AC_PROG_RANLIB + +AM_ALLIANCE + +AC_OUTPUT([ +Makefile +src/Makefile +]) diff --git a/alliance/src/vex/src/Makefile.am b/alliance/src/vex/src/Makefile.am new file mode 100644 index 00000000..6cf04568 --- /dev/null +++ b/alliance/src/vex/src/Makefile.am @@ -0,0 +1,12 @@ +CFLAGS = @CFLAGS@ \ + -DALLIANCE_TOP=\"${ALLIANCE_TOP}\" +lib_LIBRARIES = libVex.a +include_HEADERS = vex.h +libVex_a_SOURCES = \ +vexcreate.h vexerror.c vexfree.h vexshift.c vexunflat.h \ +vex.h vexdel.c vexerror.h vexget.c vexshift.h vexview.c \ +vexadd.c vexdel.h vexeval.c vexget.h vexsimp.c vexview.h \ +vexadd.h vexdup.c vexeval.h vexis.c vexsimp.h \ +vexalloc.c vexdup.h vexextend.c vexis.h vexslice.c \ +vexalloc.h vexenv.c vexextend.h vexoptim.c vexslice.h \ +vexcreate.c vexenv.h vexfree.c vexoptim.h vexunflat.c diff --git a/alliance/src/vex/src/main.c b/alliance/src/vex/src/main.c new file mode 100644 index 00000000..8a998d1d --- /dev/null +++ b/alliance/src/vex/src/main.c @@ -0,0 +1,155 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +int main( argc, argv ) + + int argc; + char **argv; +{ + long Integer; + long Value; + vexexpr *Vex; + vexexpr *Atom; + int Width = 8; + + mbkenv(); + autenv(); + vexenv(); + + if ( argc > 1 ) Width = atoi( argv[ 1 ] ); + +fprintf( stdout, "Width %d\n", Width ); + +fprintf( stdout, "width 0, signed 0\n" ); + for ( Integer = -10; Integer < 10; Integer++ ) + { + Vex = createvexatomlong( Integer, 0, 0 ); + fprintf( stdout, "%ld -> ", Integer ); + viewvexexprboundln( Vex ); + + if ( evalvexatomlong( Vex, &Value ) != -1 ) + fprintf( stdout, "<- %ld\n", Value ); + else + fprintf( stdout, "<- ERROR\n" ); + + Vex = extendvexatomsign( Vex, Width ); + if ( Vex != (vexexpr *)0 ) + { + viewvexexprboundln( Vex ); + fprintf( stdout, "\n" ); + } + else + fprintf( stdout, "<- ERROR\n" ); + } + +fprintf( stdout, "width 0, signed 1\n" ); + for ( Integer = -10; Integer < 10; Integer++ ) + { + Vex = createvexatomlong( Integer, 0, 1 ); + fprintf( stdout, "%ld -> ", Integer ); + viewvexexprboundln( Vex ); + if ( evalvexatomlong( Vex, &Value ) != -1 ) + fprintf( stdout, "<- %ld\n", Value ); + else + fprintf( stdout, "<- ERROR\n" ); + + Vex = extendvexatomsign( Vex, Width ); + if ( Vex != (vexexpr *)0 ) + { + viewvexexprboundln( Vex ); + fprintf( stdout, "\n" ); + } + else + fprintf( stdout, "<- ERROR\n" ); + } + +fprintf( stdout, "width 6, signed 0\n" ); + for ( Integer = -10; Integer < 10; Integer++ ) + { + Vex = createvexatomlong( Integer, 6, 0 ); + fprintf( stdout, "%ld -> ", Integer ); + viewvexexprboundln( Vex ); + if ( evalvexatomlong( Vex, &Value ) != -1 ) + fprintf( stdout, "<- %ld\n", Value ); + else + fprintf( stdout, "<- ERROR\n" ); + + Vex = extendvexatomsign( Vex, Width ); + if ( Vex != (vexexpr *)0 ) + { + viewvexexprboundln( Vex ); + fprintf( stdout, "\n" ); + } + else + fprintf( stdout, "<- ERROR\n" ); + } + +fprintf( stdout, "width 6, signed 1\n" ); + for ( Integer = -10; Integer < 10; Integer++ ) + { + Vex = createvexatomlong( Integer, 6, 1 ); + fprintf( stdout, "%ld -> ", Integer ); + viewvexexprboundln( Vex ); + if ( evalvexatomlong( Vex, &Value ) != -1 ) + fprintf( stdout, "<- %ld\n", Value ); + else + fprintf( stdout, "<- ERROR\n" ); + + Vex = extendvexatomsign( Vex, Width ); + if ( Vex != (vexexpr *)0 ) + { + viewvexexprboundln( Vex ); + fprintf( stdout, "\n" ); + } + else + fprintf( stdout, "<- ERROR\n" ); + } + + Atom = createvexatomvec( "v", 3, 0 ); + viewvexexprboundln( Atom ); + fprintf( stdout, "\n ici " ); + Vex = extendvexatomsign( Atom, 5 ); + viewvexexprboundln( Vex ); + fprintf( stdout, "\n" ); + + Atom = createvexatomvec( "v", 3, 0 ); + SetVexNodeSigned( Atom ); + viewvexexprboundln( Atom ); + fprintf( stdout, "\n" ); + Vex = extendvexatomsign( Atom, 5 ); + viewvexexprboundln( Vex ); + fprintf( stdout, "\n" ); + + return( 1 ); +} diff --git a/alliance/src/vex/src/vex.h b/alliance/src/vex/src/vex.h new file mode 100644 index 00000000..a90f7db3 --- /dev/null +++ b/alliance/src/vex/src/vex.h @@ -0,0 +1,693 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Title : Structures and fonctions for VEX | +| | +| Date : 04.02.97 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------*/ + +# ifndef VEX_103_H +# define VEX_103_H + +/*------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------*/ + +# ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +# endif + +/*------------------------------------------------------\ +| | +| View Mode | +| | +\------------------------------------------------------*/ + +# define VEX_VIEW_VHDL 0 +# define VEX_VIEW_VERILOG 1 + +/*------------------------------------------------------\ +| | +| Node Type | +| | +\------------------------------------------------------*/ + +# define VEX_NODE_ATOM_MASK (unsigned short)(0x1000) +# define VEX_NODE_OPER_MASK (unsigned short)(0x2000) +# define VEX_NODE_FUNC_MASK (unsigned short)(0x4000) +# define VEX_NODE_TYPE_MASK (unsigned short)(0x7000) + +# define VEX_NODE_TAG_MASK (unsigned short)(0x8000) + +# define VEX_ATOM_LITERAL_MASK (unsigned short)(0x0100) /*Literal Name */ +# define VEX_NODE_SIGNED_MASK (unsigned short)(0x0200) /*Signed Unsigned */ +# define VEX_NODE_BIT_MASK (unsigned short)(0x0400) /*Bit Vector */ +# define VEX_NODE_DOWN_MASK (unsigned short)(0x0800) /*Down Up */ +# define VEX_NODE_VAR_WIDTH_MASK (unsigned short)(0x0080) /*Variable Width */ + +# define VEX_NODE_USER1_MASK (unsigned short)(0x0020) +# define VEX_NODE_USER2_MASK (unsigned short)(0x0040) + +# define VEX_NODE_VHDL_TYPE_MASK (unsigned short)(0x001f) + +/*------------------------------------------------------\ +| | +| Macro Node Type | +| | +\------------------------------------------------------*/ + +# define IsVexNodeAtom( N ) ( (N)->TYPE & VEX_NODE_ATOM_MASK ) +# define SetVexNodeAtom( N ) ( (N)->TYPE = ((N)->TYPE & ~VEX_NODE_TYPE_MASK )\ + | VEX_NODE_ATOM_MASK ) +# define IsVexNodeOper( N ) ( (N)->TYPE & VEX_NODE_OPER_MASK ) +# define SetVexNodeOper( N ) ( (N)->TYPE = ((N)->TYPE & ~VEX_NODE_TYPE_MASK )\ + | VEX_NODE_OPER_MASK ) +# define IsVexNodeFunc( N ) ( (N)->TYPE & VEX_NODE_FUNC_MASK ) +# define SetVexNodeFunc( N ) ( (N)->TYPE = ((N)->TYPE & ~VEX_NODE_TYPE_MASK )\ + | VEX_NODE_FUNC_MASK ) + +/*------------------------------------------------------\ +| | +| Macro Node Width | +| | +\------------------------------------------------------*/ + +# define IsVexNodeVarWidth( N ) ( (N)->TYPE & VEX_NODE_VAR_WIDTH_MASK ) +# define SetVexNodeVarWidth( N ) ( (N)->TYPE |= VEX_NODE_VAR_WIDTH_MASK ) +# define ClearVexNodeVarWidth( N ) ( (N)->TYPE &= ~VEX_NODE_VAR_WIDTH_MASK ) + +/*------------------------------------------------------\ +| | +| Macro Node Signed | +| | +\------------------------------------------------------*/ + +# define IsVexNodeSigned( N ) ( (N)->TYPE & VEX_NODE_SIGNED_MASK ) +# define SetVexNodeSigned( N ) ( (N)->TYPE |= VEX_NODE_SIGNED_MASK ) +# define ClearVexNodeSigned( N ) ( (N)->TYPE &= ~VEX_NODE_SIGNED_MASK ) + +/*------------------------------------------------------\ +| | +| Macro Node Bit | +| | +\------------------------------------------------------*/ + +# define IsVexNodeBit( N ) ( (N)->TYPE & VEX_NODE_BIT_MASK ) +# define SetVexNodeBit( N ) ( (N)->TYPE |= VEX_NODE_BIT_MASK ) +# define ClearVexNodeBit( N ) ( (N)->TYPE &= ~VEX_NODE_BIT_MASK ) + +/*------------------------------------------------------\ +| | +| Macro Node Direction | +| | +\------------------------------------------------------*/ + +# define IsVexNodeDown( N ) ( (N)->TYPE & VEX_NODE_DOWN_MASK ) +# define SetVexNodeDown( N ) ( (N)->TYPE |= VEX_NODE_DOWN_MASK ) +# define ClearVexNodeDown( N ) ( (N)->TYPE &= ~VEX_NODE_DOWN_MASK ) + +/*------------------------------------------------------\ +| | +| Macro Node Tag | +| | +\------------------------------------------------------*/ + +# define IsVexNodeTag( N ) ( (N)->TYPE & VEX_NODE_TAG_MASK ) +# define SetVexNodeTag( N ) ( (N)->TYPE |= VEX_NODE_TAG_MASK ) +# define ClearVexNodeTag( N ) ( (N)->TYPE &= ~VEX_NODE_TAG_MASK ) + +/*------------------------------------------------------\ +| | +| Macro Atom | +| | +\------------------------------------------------------*/ + +# define IsVexAtomLiteral( N ) ( (N)->TYPE & VEX_ATOM_LITERAL_MASK ) +# define SetVexAtomLiteral( N ) ( (N)->TYPE |= VEX_ATOM_LITERAL_MASK ) +# define ClearVexAtomLiteral( N ) ( (N)->TYPE &= ~VEX_ATOM_LITERAL_MASK ) + +# define IsVexAtomVarWidth( N ) ( IsVexNodeVarWidth( N ) ) +# define SetVexAtomVarWidth( N ) ( SetVexNodeVarWidth( N ) ) +# define IsVexAtomStaWidth( N ) ( ! IsVexNodeVarWidth( N ) ) +# define SetVexAtomStaWidth( N ) ( ClearVexNodeVarWidth( N ) ) + +# define IsVexAtomBit( N ) ( IsVexNodeBit( N ) ) +# define SetVexAtomBit( N ) ( SetVexNodeBit( N ) ) +# define IsVexAtomVector( N ) ( ! IsVexNodeBit( N ) ) +# define SetVexAtomVector( N ) ( ClearVexNodeBit( N ) ) + +# define IsVexAtomSigned( N ) ( IsVexNodeSigned( N ) ) +# define SetVexAtomSigned( N ) ( SetVexNodeSigned( N ) ) +# define IsVexAtomUnsigned( N ) ( ! IsVexNodeSigned( N ) ) +# define SetVexAtomUnsigned( N ) ( ClearVexNodeSigned( N ) ) + +# define IsVexAtomDown( N ) ( IsVexNodeDown( N ) ) +# define SetVexAtomDown( N ) ( SetVexNodeDown( N ) ) +# define IsVexAtomUp( N ) ( ! IsVexNodeDown( N ) ) +# define SetVexAtomUp( N ) ( ClearVexNodeDown( N ) ) + +/*------------------------------------------------------\ +| | +| Macro Oper | +| | +\------------------------------------------------------*/ + +# define IsVexOperVarWidth( N ) ( IsVexNodeVarWidth( N ) ) +# define SetVexOperVarWidth( N ) ( SetVexNodeVarWidth( N ) ) +# define IsVexOperStaWidth( N ) ( ! IsVexNodeVarWidth( N ) ) +# define SetVexOperStaWidth( N ) ( ClearVexNodeVarWidth( N ) ) + +# define IsVexOperBit( N ) ( IsVexNodeBit( N ) ) +# define SetVexOperBit( N ) ( SetVexNodeBit( N ) ) +# define IsVexOperVector( N ) ( ! IsVexNodeBit( N ) ) +# define SetVexOperVector( N ) ( ClearVexNodeBit( N ) ) + +# define IsVexOperSigned( N ) ( IsVexNodeSigned( N ) ) +# define SetVexOperSigned( N ) ( SetVexNodeSigned( N ) ) +# define IsVexOperUnsigned( N ) ( ! IsVexNodeSigned( N ) ) +# define SetVexOperUnsigned( N ) ( ClearVexNodeSigned( N ) ) + +# define IsVexOperDown( N ) ( IsVexNodeDown( N ) ) +# define SetVexOperDown( N ) ( SetVexNodeDown( N ) ) +# define IsVexOperUp( N ) ( ! IsVexNodeDown( N ) ) +# define SetVexOperUp( N ) ( ClearVexNodeDown( N ) ) + +/*------------------------------------------------------\ +| | +| Macro Func | +| | +\------------------------------------------------------*/ + +# define IsVexFuncVarWidth( N ) ( IsVexNodeVarWidth( N ) ) +# define SetVexFuncVarWidth( N ) ( SetVexNodeVarWidth( N ) ) +# define IsVexFuncStaWidth( N ) ( ! IsVexNodeVarWidth( N ) ) +# define SetVexFuncStaWidth( N ) ( ClearVexNodeVarWidth( N ) ) + +# define IsVexFuncBit( N ) ( IsVexNodeBit( N ) ) +# define SetVexFuncBit( N ) ( SetVexNodeBit( N ) ) +# define IsVexFuncVector( N ) ( ! IsVexNodeBit( N ) ) +# define SetVexFuncVector( N ) ( ClearVexNodeBit( N ) ) + +# define IsVexFuncSigned( N ) ( IsVexNodeSigned( N ) ) +# define SetVexFuncSigned( N ) ( SetVexNodeSigned( N ) ) +# define IsVexFuncUnsigned( N ) ( ! IsVexNodeSigned( N ) ) +# define SetVexFuncUnsigned( N ) ( ClearVexNodeSigned( N ) ) + +# define IsVexFuncDown( N ) ( IsVexNodeDown( N ) ) +# define SetVexFuncDown( N ) ( SetVexNodeDown( N ) ) +# define IsVexFuncUp( N ) ( ! IsVexNodeDown( N ) ) +# define SetVexFuncUp( N ) ( ClearVexNodeDown( N ) ) + +/*------------------------------------------------------\ +| | +| Macro Type | +| | +\------------------------------------------------------*/ + +# define SetVexVhdlType( N, T ) ((N)->TYPE = ((N)->TYPE & ~VEX_NODE_VHDL_TYPE_MASK)|(T)) +# define GetVexVhdlType( N ) ((N)->TYPE & VEX_NODE_VHDL_TYPE_MASK) + +/*------------------------------------------------------\ +| | +| Operators | +| | +\------------------------------------------------------*/ + +# define VEX_CONCAT 0 +# define VEX_NOT 1 +# define VEX_NEG 2 +# define VEX_EVENT 3 +# define VEX_OR 4 +# define VEX_AND 5 +# define VEX_XOR 6 +# define VEX_NOR 7 +# define VEX_NAND 8 +# define VEX_NXOR 9 +# define VEX_EQ 10 +# define VEX_NE 11 +# define VEX_LT 12 +# define VEX_LE 13 +# define VEX_GT 14 +# define VEX_GE 15 +# define VEX_ADD 16 +# define VEX_SUB 17 +# define VEX_MUL 18 +# define VEX_DIV 19 +# define VEX_EXP 20 +# define VEX_MOD 21 +# define VEX_REM 22 +# define VEX_TO 23 +# define VEX_DOWNTO 24 +# define VEX_INDEX 25 +# define VEX_LEFT 26 +# define VEX_RIGHT 27 +# define VEX_LOW 28 +# define VEX_HIGH 29 +# define VEX_LENGTH 30 +# define VEX_RANGE 31 +# define VEX_REV_RANGE 32 +# define VEX_DRIVER 33 +# define VEX_IFT 34 +# define VEX_ARRAY 35 +# define VEX_INDEX_N 36 +# define VEX_OTHERS 37 +# define VEX_NUM_BIT 38 +# define VEX_ABS 39 + +# define VEX_MAX_OPERATOR 40 + +/*------------------------------------------------------\ +| | +| Vhdl Type | +| | +\------------------------------------------------------*/ + +# define VEX_TYPE_SEVERITY 0 +# define VEX_TYPE_BOOLEAN 1 +# define VEX_TYPE_CHARACTER 2 +# define VEX_TYPE_STRING 3 +# define VEX_TYPE_BIT 4 +# define VEX_TYPE_INTEGER 5 +# define VEX_TYPE_NATURAL 6 +# define VEX_TYPE_BIT_VECTOR 7 +# define VEX_TYPE_STD_ULOGIC 8 +# define VEX_TYPE_STD_LOGIC 9 +# define VEX_TYPE_STD_ULOGIC_VECTOR 10 +# define VEX_TYPE_STD_LOGIC_VECTOR 11 +# define VEX_TYPE_X01 12 +# define VEX_TYPE_X01Z 13 +# define VEX_TYPE_UX01 14 +# define VEX_TYPE_UX01Z 15 +# define VEX_TYPE_UNSIGNED 16 +# define VEX_TYPE_SIGNED 17 +# define VEX_TYPE_SMALL_INT 18 +# define VEX_TYPE_REG_BIT 19 +# define VEX_TYPE_REG_VECTOR 20 +# define VEX_TYPE_MUX_BIT 21 +# define VEX_TYPE_MUX_VECTOR 22 +# define VEX_TYPE_WOR_BIT 23 +# define VEX_TYPE_WOR_VECTOR 24 +# define VEX_TYPE_ENUMERATE 25 +# define VEX_TYPE_ARRAY 26 + +# define VEX_MAX_TYPE 27 + +/*------------------------------------------------------\ +| | +| Std Function | +| | +\------------------------------------------------------*/ + +# define VEX_STD_TO_BIT 0 +# define VEX_STD_TO_BITVECTOR 1 +# define VEX_STD_TO_STDULOGIC 2 +# define VEX_STD_TO_STDLOGICVECTOR 3 +# define VEX_STD_TO_STDULOGICVECTOR 4 +# define VEX_STD_TO_X01 5 +# define VEX_STD_TO_X01Z 6 +# define VEX_STD_TO_UX01 7 +# define VEX_STD_RISING_EDGE 8 +# define VEX_STD_FALLING_EDGE 9 +# define VEX_STD_IS_X 10 +# define VEX_STD_ABS 11 +# define VEX_STD_SHL 12 +# define VEX_STD_SHR 13 +# define VEX_STD_CONV_INTEGER 14 +# define VEX_STD_CONV_UNSIGNED 15 +# define VEX_STD_CONV_SIGNED 16 +# define VEX_STD_CONV_STD_LOGIC_VECTOR 17 +# define VEX_STD_EXT 18 +# define VEX_STD_SXT 19 +# define VEX_STD_SHIFT_LEFT 20 +# define VEX_STD_SHIFT_RIGHT 21 +# define VEX_STD_ROTATE_LEFT 22 +# define VEX_STD_ROTATE_RIGHT 23 +# define VEX_STD_RESIZE 24 +# define VEX_STD_TO_INTEGER 25 +# define VEX_STD_TO_UNSIGNED 26 +# define VEX_STD_TO_SIGNED 27 +# define VEX_STD_STD_LOGIC_VECTOR 28 +# define VEX_STD_STD_ULOGIC_VECTOR 29 +# define VEX_STD_SIGNED 30 +# define VEX_STD_UNSIGNED 31 + +# define VEX_MAX_STD_FUNC 32 + +/*------------------------------------------------------\ +| | +| Literals 9 | +| | +\------------------------------------------------------*/ + +# define VEX_UNINIT_ID 0 /* Uninitialized */ +# define VEX_UNKNOWN_ID 1 /* Forcing Unknown */ +# define VEX_ZERO_ID 2 /* Forcing 0 */ +# define VEX_ONE_ID 3 /* Forcing 1 */ +# define VEX_TRISTATE_ID 4 /* High Impedance */ +# define VEX_WEAK_UNKNOWN_ID 5 /* Weak Unknown */ +# define VEX_WEAK_ZERO_ID 6 /* Weak 0 */ +# define VEX_WEAK_ONE_ID 7 /* Weak 1 */ +# define VEX_DC_ID 8 /* Don't care */ +# define VEX_MAX_ID 9 + +/*------------------------------------------------------\ +| | +| Macro Literals 9 | +| | +\------------------------------------------------------*/ + +# define VEX_UNINIT VEX_LITERAL_BY_ID[ VEX_UNINIT_ID ] +# define VEX_UNKNOWN VEX_LITERAL_BY_ID[ VEX_UNKNOWN_ID ] +# define VEX_ZERO VEX_LITERAL_BY_ID[ VEX_ZERO_ID ] +# define VEX_ONE VEX_LITERAL_BY_ID[ VEX_ONE_ID ] +# define VEX_TRISTATE VEX_LITERAL_BY_ID[ VEX_TRISTATE_ID ] +# define VEX_WEAK_UNKNOWN VEX_LITERAL_BY_ID[ VEX_WEAK_UNKNOWN_ID ] +# define VEX_WEAK_ZERO VEX_LITERAL_BY_ID[ VEX_WEAK_ZERO_ID ] +# define VEX_WEAK_ONE VEX_LITERAL_BY_ID[ VEX_WEAK_ONE_ID ] +# define VEX_DC VEX_LITERAL_BY_ID[ VEX_DC_ID ] + +/*------------------------------------------------------\ +| | +| Macro Atom Literals 9 | +| | +\------------------------------------------------------*/ + +# define VEX_ATOM_UNINIT VEX_ATOM_BY_ID[ VEX_UNINIT_ID ] +# define VEX_ATOM_UNKNOWN VEX_ATOM_BY_ID[ VEX_UNKNOWN_ID ] +# define VEX_ATOM_ZERO VEX_ATOM_BY_ID[ VEX_ZERO_ID ] +# define VEX_ATOM_ONE VEX_ATOM_BY_ID[ VEX_ONE_ID ] +# define VEX_ATOM_TRISTATE VEX_ATOM_BY_ID[ VEX_TRISTATE_ID ] +# define VEX_ATOM_WEAK_UNKNOWN VEX_ATOM_BY_ID[ VEX_WEAK_UNKNOWN_ID ] +# define VEX_ATOM_WEAK_ZERO VEX_ATOM_BY_ID[ VEX_WEAK_ZERO_ID ] +# define VEX_ATOM_WEAK_ONE VEX_ATOM_BY_ID[ VEX_WEAK_ONE_ID ] +# define VEX_ATOM_DC VEX_ATOM_BY_ID[ VEX_DC_ID ] + +/*------------------------------------------------------\ +| | +| Macro Oper Types | +| | +\------------------------------------------------------*/ + +# define GetVexFuncValue( N ) ( (char *)(N)->VALUE ) +# define SetVexFuncValue( N, F ) ( (N)->VALUE = (void *)(F) ) + +# define GetVexOperValue( N ) ( (long )(N)->VALUE ) +# define SetVexOperValue( N, O ) ( (N)->VALUE = (void *)(O) ) + +# define GetVexAtomValue( N ) ( (char *)(N)->VALUE ) +# define SetVexAtomValue( N, A ) ( (N)->VALUE = (void *)(A) ) + +# define GetVexOperand( C ) ( (vexexpr *)(C)->DATA ) +# define SetVexOperand( C, O ) ( (C)->DATA = (void *)(O) ) + +/*------------------------------------------------------\ +| | +| Type | +| | +\------------------------------------------------------*/ + + typedef struct vexexpr + { + chain_list *OPERAND; + void *VALUE; + short TYPE; + short LEFT; + short RIGHT; + short WIDTH; + + } vexexpr; + +/*------------------------------------------------------\ +| | +| Global Variable | +| | +\------------------------------------------------------*/ + + extern char *VEX_OPER_NAME[ VEX_MAX_OPERATOR ]; + extern char *VEX_OPER_UPPER_NAME[ VEX_MAX_OPERATOR ]; + extern char *VEX_OPER_VERILOG_NAME[ VEX_MAX_OPERATOR ]; + extern char *VEX_TYPE_NAME[ VEX_MAX_TYPE ]; + extern long VEX_OPER_NOT[ VEX_MAX_OPERATOR ]; + extern char VEX_LITERAL_BY_ID[ VEX_MAX_ID ]; + extern char *VEX_ATOM_BY_ID[ VEX_MAX_ID ]; + extern char *VEX_STD_FUNC_NAME[ VEX_MAX_STD_FUNC ]; + extern char *VEX_STD_FUNC_UPPER_NAME[ VEX_MAX_STD_FUNC ]; + +/*------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Initialize Functions | +| | +\------------------------------------------------------*/ + + extern void vexenv __P(()); + +/*------------------------------------------------------\ +| | +| Node Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *allocvexnode __P(()); + extern vexexpr *dupvexnode __P((vexexpr *Node)); + extern vexexpr *copyvexnode __P((vexexpr *Target, vexexpr *Source)); + extern void freevexnode __P((vexexpr *Node)); + +/*------------------------------------------------------\ +| | +| Create Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *createvexatombit __P((char *Name)); + extern vexexpr *createvexatomvec __P((char *Name, short Left, short Right)); + extern vexexpr *createvexatomlit __P((char *Name)); + extern vexexpr *createvexatomveclit __P((unsigned char Literal, short Width)); + extern vexexpr *createvexatomlong __P((long Integer, short Width, short Signed)); + extern vexexpr *createvexatomlongarray __P((long *Array, short Size, short Width, short Signed)); + + extern vexexpr *createvexoper __P((long Oper, short Width)); + extern vexexpr *createvexbinexpr __P((long Oper, short Width, vexexpr *Expr1, vexexpr *Expr2)); + extern vexexpr *createvexternaryexpr __P((long Oper, short Width, \ + vexexpr *Expr1, vexexpr *Expr2, vexexpr *Expr3)); + extern vexexpr *createvexunaryexpr __P((long Oper, short Width, vexexpr *Expr)); + + extern vexexpr *createvexfunc __P((char *Func, short Width)); + +/*------------------------------------------------------\ +| | +| Simplify Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *simpvexexpr __P((vexexpr *Expr)); + extern vexexpr *simpvexexpreq __P((vexexpr *Expr)); + extern vexexpr *simpvexexprothers __P((vexexpr *Expr, short Width )); + +/*------------------------------------------------------\ +| | +| Optimize Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *optimvexnotexpr __P((vexexpr *Expr)); + extern vexexpr *optimvexbinexpr __P((long Oper, short Width, vexexpr *Expr1, vexexpr *Expr2)); + +/*------------------------------------------------------\ +| | +| Add Functions | +| | +\------------------------------------------------------*/ + + extern void addvexqexpr __P((vexexpr *Expr1, vexexpr *Expr2)); + extern void addvexhexpr __P((vexexpr *Expr1, vexexpr *Expr2)); + +/*------------------------------------------------------\ +| | +| Duplicate Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *dupvexexpr __P((vexexpr *Expr)); + +/*------------------------------------------------------\ +| | +| Del Functions | +| | +\------------------------------------------------------*/ + + extern void delvexexpr __P((vexexpr *Expr)); + extern void delvexexprnum __P((vexexpr *Expr, int Number)); + +/*------------------------------------------------------\ +| | +| Free Functions | +| | +\------------------------------------------------------*/ + + extern void freevexexpr __P((vexexpr *Expr)); + +/*------------------------------------------------------\ +| | +| Is Functions | +| | +\------------------------------------------------------*/ + + extern int isvexunaryoper __P((long Oper)); + extern int isvexbinaryoper __P((long Oper)); + extern int isvexternaryoper __P((long Oper)); + extern int isvexoperinexpr __P((vexexpr *Expr, long Oper)); + extern int isvexarithoperinexpr __P((vexexpr *Expr)); + extern int isvexnameinexpr __P((vexexpr *Expr, char *Name)); + extern int isvexpositiveoper __P((long Oper)); + extern int isvexnegativeoper __P((long Oper)); + extern int isvexequalexpr __P((vexexpr *Expr1, vexexpr *Expr2)); + extern int isvextypedivisible __P((int Type)); + extern int isvextypevector __P((int Type)); + +/*------------------------------------------------------\ +| | +| Get Functions | +| | +\------------------------------------------------------*/ + + extern char *getvexvectorname __P((char *Vector, long *Index)); + extern char *getvexopername __P((long Oper)); + extern char *getvexatomname __P((vexexpr *Expr)); + extern char *getvexoperuppername __P((long Oper)); + extern char *getvexoperverilogname __P((long Oper)); + extern long getvexoperbyname __P((char *Name)); + extern long getvexnotoper __P((long Oper)); + + extern char *getvexarrayname __P((vexexpr *Atom)); + extern vexexpr *getvexarrayatom __P((vexexpr *Expr)); + + extern chain_list *getvexatombitname __P((vexexpr *Expr)); + extern chain_list *getvexexprsupport __P((vexexpr *Expr)); + extern chain_list *unionvexexprsupport __P((chain_list *Support, vexexpr *Expr)); + + extern ptype_list *getvexatombitnameptype __P((vexexpr *Expr)); + extern ptype_list *getvexexprsupportptype __P((vexexpr *Expr)); + extern ptype_list *unionvexexprsupportptype __P((ptype_list *Support, vexexpr *Expr)); + + extern chain_list *getvexexprallname __P((vexexpr *Expr)); + extern chain_list *unionvexexprallname __P((chain_list *AllName, vexexpr *Expr)); + + extern int getvextypescalar __P((int Type)); + + extern long getvexexprdepth __P((vexexpr *Expr)); + extern long getvexexprnumnode __P((vexexpr *Expr)); + extern int getvexliteralid __P((char Literal)); + extern int getvexstdfuncid __P((char *FuncName)); + + extern int getvexvectorpos __P((vexexpr *Vector, short Index)); + extern int getvexvectorindex __P((vexexpr *Atom, short Position)); + extern int getvexvectormin __P((vexexpr *Expr)); + extern int getvexvectormax __P((vexexpr *Expr)); + + extern int getvexintnumbit __P((long Size)); + extern int getvexintervalnumbit __P((long Left, long Right)); + +/*------------------------------------------------------\ +| | +| Eval Functions | +| | +\------------------------------------------------------*/ + + extern int evalvexatomlong __P((vexexpr *Expr, long *PLong)); + + extern int evalvexnotliteral __P((char Literal, char *PChar)); + extern int evalvexandliteral __P((char Literal1, char Literal2, char *PChar)); + extern int evalvexorliteral __P((char Literal1, char Literal2, char *PChar)); + extern int evalvexxorliteral __P((char Literal1, char Literal2, char *PChar)); + +/*------------------------------------------------------\ +| | +| Extend Sign Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *extendvexatomsign __P((vexexpr *Expr, short Width)); + +/*------------------------------------------------------\ +| | +| Shift Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *shiftvexatomleft __P((vexexpr *Expr, short Count )); + extern vexexpr *shiftvexatomright __P((vexexpr *Expr, short Count )); + +/*------------------------------------------------------\ +| | +| Slice Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *slicevexatomvec __P((vexexpr *Expr, short Left, short Right)); + +/*------------------------------------------------------\ +| | +| Unflat Functions | +| | +\------------------------------------------------------*/ + + extern vexexpr *unflatvexexpr __P((vexexpr *Expr)); + +/*------------------------------------------------------\ +| | +| View Functions | +| | +\------------------------------------------------------*/ + + extern void viewvexexprfile __P((FILE *VexFile, vexexpr *Expr)); + extern void viewvexexpr __P((vexexpr *Expr)); + extern void viewvexexprln __P((vexexpr *Expr)); + extern void viewvexexprbound __P((vexexpr *Expr)); + extern void viewvexexprboundln __P((vexexpr *Expr)); + + extern char *viewvexexprstr __P((vexexpr *Expr)); + extern char *viewvexexprstrbound __P((vexexpr *Expr)); + + extern int getvexviewmode __P(()); + extern void setvexviewmode __P((int Mode)); + +# endif diff --git a/alliance/src/vex/src/vexadd.c b/alliance/src/vex/src/vexadd.c new file mode 100644 index 00000000..2608d790 --- /dev/null +++ b/alliance/src/vex/src/vexadd.c @@ -0,0 +1,115 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexadd.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexadd.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Add Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Add Vex Queue Expr | +| | +\------------------------------------------------------------*/ + +void addvexqexpr( Expr1, Expr2 ) + + vexexpr *Expr1; + vexexpr *Expr2; +{ + chain_list *ScanOper; + chain_list **PrevOper; + + PrevOper = &Expr1->OPERAND; + + for ( ScanOper = Expr1->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + PrevOper = &ScanOper->NEXT; + } + + *PrevOper = addchain( (chain_list *)0, (void *)Expr2 ); +} + +/*------------------------------------------------------------\ +| | +| Add Vex Head Expr | +| | +\------------------------------------------------------------*/ + +void addvexhexpr( Expr1, Expr2 ) + + vexexpr *Expr1; + vexexpr *Expr2; +{ + Expr1->OPERAND = addchain( Expr1->OPERAND, (void *)Expr2 ); +} diff --git a/alliance/src/vex/src/vexadd.h b/alliance/src/vex/src/vexadd.h new file mode 100644 index 00000000..e0f228b5 --- /dev/null +++ b/alliance/src/vex/src/vexadd.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexadd.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_ADD_H +# define VEX_ADD_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexalloc.c b/alliance/src/vex/src/vexalloc.c new file mode 100644 index 00000000..ef1d2063 --- /dev/null +++ b/alliance/src/vex/src/vexalloc.c @@ -0,0 +1,123 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexalloc.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include +# include "vexalloc.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Vex Alloc Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Vex Alloc Node | +| | +\------------------------------------------------------------*/ + +vexexpr *allocvexnode() +{ + return( (vexexpr *)autallocheap( sizeof( vexexpr ) ) ); +} + +/*------------------------------------------------------------\ +| | +| Vex Copy Node | +| | +\------------------------------------------------------------*/ + +vexexpr *copyvexnode( Target, Source ) + + vexexpr *Target; + vexexpr *Source; +{ + memcpy( (char *)Target, (char *)Source, sizeof( vexexpr ) ); + + return( Target ); +} + +/*------------------------------------------------------------\ +| | +| Vex Duplicate Node | +| | +\------------------------------------------------------------*/ + +vexexpr *dupvexnode( Node ) + + vexexpr *Node; +{ + vexexpr *DupNode; + + DupNode = (vexexpr *)autallocheap( sizeof( vexexpr ) ); + DupNode = copyvexnode( DupNode, Node ); + + return( DupNode ); +} + diff --git a/alliance/src/vex/src/vexalloc.h b/alliance/src/vex/src/vexalloc.h new file mode 100644 index 00000000..ce72f0a5 --- /dev/null +++ b/alliance/src/vex/src/vexalloc.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexalloc.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_ALLOC_H +# define VEX_ALLOC_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexcreate.c b/alliance/src/vex/src/vexcreate.c new file mode 100644 index 00000000..ca6187db --- /dev/null +++ b/alliance/src/vex/src/vexcreate.c @@ -0,0 +1,530 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexcreate.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexcreate.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Create Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Create Vex Atom Vector | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexatomvec( Name, Left, Right ) + + char *Name; + short Left; + short Right; +{ + vexexpr *Node; + short Width; + + Name = namealloc( Name ); + Node = allocvexnode(); + + SetVexNodeAtom( Node ); + SetVexAtomValue( Node, Name ); + SetVexAtomVector( Node ); + + if ( ( Left < 0 ) || + ( Right < 0 ) ) + { + Node->WIDTH = 1; + SetVexNodeVarWidth( Node ); + } + else + { + if ( Left < Right ) + { + Width = 1 + Right - Left; + } + else + { + Width = 1 + Left - Right; + SetVexAtomDown( Node ); + } + + Node->LEFT = Left; + Node->RIGHT = Right; + Node->WIDTH = Width; + } + + if ( Name[ 0 ] == '"' ) + { + SetVexAtomLiteral( Node ); + } + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Atom Literal | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexatomlit( Name ) + + char *Name; +{ + vexexpr *Node; + short Width; + + Name = namealloc( Name ); + Node = allocvexnode(); + + SetVexNodeAtom( Node ); + SetVexAtomValue( Node, Name ); + SetVexAtomLiteral( Node ); + + Width = strlen( Name ) - 2; + + Node->LEFT = Width - 1; + Node->RIGHT = 0; + Node->WIDTH = Width; + + if ( Width > 1 ) SetVexAtomVector( Node ); + else SetVexAtomBit( Node ); + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Atom Literal Vector | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexatomveclit( Literal, Width ) + + unsigned char Literal; + short Width; +{ + vexexpr *Node; + char *Name; + char Buffer[ 512 ]; + char Cote; + + if ( Width > 1 ) Cote = '\"'; + else Cote = '\''; + + Buffer[ 0 ] = Cote; + Buffer[ Width + 1 ] = Cote; + Buffer[ Width + 2 ] = '\0'; + + memset( Buffer + 1, Literal, Width ); + + Name = namealloc( Buffer ); + Node = allocvexnode(); + + SetVexNodeAtom( Node ); + SetVexAtomValue( Node, Name ); + SetVexAtomLiteral( Node ); + + Node->LEFT = Width - 1; + Node->RIGHT = 0; + Node->WIDTH = Width; + + if ( Width > 1 ) SetVexAtomVector( Node ); + else SetVexAtomBit( Node ); + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Atom Bit | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexatombit( Name ) + + char *Name; +{ + vexexpr *Node; + + Name = namealloc( Name ); + + Node = allocvexnode(); + + SetVexNodeAtom( Node ); + SetVexAtomValue( Node, Name ); + SetVexAtomBit( Node ); + + Node->WIDTH = 1; + + if ( Name[ 0 ] == '\'' ) + { + SetVexAtomLiteral( Node ); + } + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Oper | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexoper( Oper, Width ) + + long Oper; + short Width; +{ + vexexpr *Node; + + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + Node = allocvexnode(); + + if ( Width <= 0 ) + { + Width = 1; + SetVexNodeVarWidth( Node ); + } + + Node->WIDTH = Width; + Node->LEFT = Width - 1; + + SetVexNodeOper( Node ); + SetVexOperValue( Node, Oper ); + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Bin Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexbinexpr( Oper, Width, Expr1, Expr2 ) + + long Oper; + short Width; + vexexpr *Expr1; + vexexpr *Expr2; +{ + vexexpr *Expr; + + if ( ! isvexbinaryoper( Oper ) ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + Expr = createvexoper( Oper, Width ); + + addvexhexpr( Expr, Expr2 ); + addvexhexpr( Expr, Expr1 ); + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Unary Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexunaryexpr( Oper, Width, Expr ) + + long Oper; + short Width; + vexexpr *Expr; +{ + vexexpr *Expr1; + + if ( ! isvexunaryoper( Oper ) ) + { + vexerror( VEX_NOT_UNARY_ERROR, Oper ); + } + + Expr1 = createvexoper( Oper, Width ); + addvexhexpr( Expr1, Expr ); + + return( Expr1 ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Ternary Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexternaryexpr( Oper, Width, Expr1, Expr2, Expr3 ) + + long Oper; + short Width; + vexexpr *Expr1; + vexexpr *Expr2; + vexexpr *Expr3; +{ + vexexpr *Expr; + + if ( ! isvexternaryoper( Oper ) ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + Expr = createvexoper( Oper, Width ); + + addvexhexpr( Expr, Expr3 ); + addvexhexpr( Expr, Expr2 ); + addvexhexpr( Expr, Expr1 ); + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Func | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexfunc( Func, Width ) + + char *Func; + short Width; +{ + vexexpr *Node; + + Node = allocvexnode(); + + if ( Width <= 0 ) + { + Width = 1; + SetVexNodeVarWidth( Node ); + } + + Node->WIDTH = Width; + Node->LEFT = Width - 1; + + SetVexNodeFunc( Node ); + SetVexFuncValue( Node, Func ); + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Atom Long Array | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexatomlongarray( Array, Size, Width, Signed ) + + long *Array; + short Size; + short Width; + short Signed; +{ + vexexpr *Node; + char Buffer[ 512 ]; + long Integer; + short Index; + short MaxWidth; + int Scan; + unsigned long Mask; + + if ( Size == 0 ) return( (vexexpr *)0 ); + + Node = allocvexnode(); + + MaxWidth = Size * 32; + + if ( Width == 0 ) + { + Width = MaxWidth; + Index = 0; + Mask = 1L << 31; + + Integer = Array[ 0 ]; + + if ( Integer & Mask ) + { + if ( Signed ) + { + while ( ( Integer & Mask ) != 0 ) + { + Width--; Mask = Mask >> 1; + + if ( Mask == 0 ) + { + Index++; + + if ( Index == Size ) break; + + Integer = Array[ Index ]; + Mask = 1L << 31; + } + } + + Width++; + + Signed = 1; + } + } + else + { + while ( ( Integer & Mask ) == 0 ) + { + Width--; Mask = Mask >> 1; + + if ( Mask == 0 ) + { + Index++; + + if ( Index == Size ) break; + + Integer = Array[ Index ]; + Mask = 1L << 31; + } + } + + if ( ( Signed == 1 ) || + ( Width == 0 ) ) Width++; + } + } + + if ( Width > MaxWidth ) return( (vexexpr *)0 ); + + Node->WIDTH = Width; + Node->LEFT = Width - 1; + Node->RIGHT = 0; + + Scan = 1; + Index = Size - ((Width + 31) / 32); + Mask = 1L << ((Width - 1) % 32); + + do + { + if ( Array[ Index ] & Mask ) Buffer[ Scan ] = '1'; + else Buffer[ Scan ] = '0'; + + Scan = Scan + 1; + Mask = Mask >> 1; + + if ( Mask == 0 ) + { + Mask = 1L << 31; Index++; + } + } + while ( Index < Size ); + + if ( Width == 1 ) + { + Buffer[ 0 ] = '\''; + Buffer[ Scan++ ] = '\''; + + SetVexAtomBit( Node ); + } + else + { + Buffer[ 0 ] = '"'; + Buffer[ Scan++ ] = '"'; + + SetVexAtomVector( Node ); + } + + Buffer[ Scan ] = '\0'; + + if ( Signed == 1 ) SetVexNodeSigned( Node ); + + SetVexNodeAtom( Node ); + SetVexAtomValue( Node, namealloc( Buffer ) ); + SetVexAtomLiteral( Node ); + + return( Node ); +} + +/*------------------------------------------------------------\ +| | +| Create Vex Atom Long | +| | +\------------------------------------------------------------*/ + +vexexpr *createvexatomlong( Integer, Width, Signed ) + + long Integer; + short Width; + short Signed; +{ + return( createvexatomlongarray( &Integer, 1, Width, Signed ) ); +} + diff --git a/alliance/src/vex/src/vexcreate.h b/alliance/src/vex/src/vexcreate.h new file mode 100644 index 00000000..06b4c64f --- /dev/null +++ b/alliance/src/vex/src/vexcreate.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexcreate.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_CREATE_H +# define VEX_CREATE_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexdel.c b/alliance/src/vex/src/vexdel.c new file mode 100644 index 00000000..200b212e --- /dev/null +++ b/alliance/src/vex/src/vexdel.c @@ -0,0 +1,144 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexdel.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexdel.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Del Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Del Vex Expr | +| | +\------------------------------------------------------------*/ + +void delvexexpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( ! IsVexNodeAtom( Expr ) ) + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + freevexexpr( GetVexOperand( ScanOper ) ); + } + + freechain( Expr->OPERAND ); + } + + freevexnode( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Del Vex Expr Number | +| | +\------------------------------------------------------------*/ + +void delvexexprnum( Expr, Number ) + + vexexpr *Expr; + int Number; +{ + chain_list **PrevOper; + chain_list *ScanOper; + int Counter; + + if ( ! IsVexNodeAtom( Expr ) ) + { + PrevOper = &Expr->OPERAND; + Counter = 0; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + if ( Counter == Number ) + { + *PrevOper = ScanOper->NEXT; + ScanOper->NEXT = (chain_list *)0; + + delvexexpr( GetVexOperand( ScanOper ) ); + freechain( ScanOper ); + + return; + } + + Counter = Counter + 1; + PrevOper = &ScanOper->NEXT; + ScanOper = ScanOper->NEXT; + } + } +} diff --git a/alliance/src/vex/src/vexdel.h b/alliance/src/vex/src/vexdel.h new file mode 100644 index 00000000..b1cf533f --- /dev/null +++ b/alliance/src/vex/src/vexdel.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexdel.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_DEL_H +# define VEX_DEL_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexdup.c b/alliance/src/vex/src/vexdup.c new file mode 100644 index 00000000..5b297c87 --- /dev/null +++ b/alliance/src/vex/src/vexdup.c @@ -0,0 +1,115 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexdup.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexdup.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Dup Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Duplicate Vex Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *dupvexexpr( Expr ) + + vexexpr *Expr; +{ + vexexpr *ExprDup; + chain_list *ScanOper; + chain_list *DupOper; + chain_list **PrevOper; + + if ( Expr == (vexexpr *) 0) + { + return( (vexexpr *)0 ); + } + + ExprDup = dupvexnode( Expr ); + + if ( ! IsVexNodeAtom( Expr ) ) + { + PrevOper = &ExprDup->OPERAND; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + DupOper = addchain( (chain_list *)0, + (void *)dupvexexpr( GetVexOperand( ScanOper ) ) ); + *PrevOper = DupOper; + PrevOper = &DupOper->NEXT; + } + } + + return( ExprDup ); +} diff --git a/alliance/src/vex/src/vexdup.h b/alliance/src/vex/src/vexdup.h new file mode 100644 index 00000000..5f74024c --- /dev/null +++ b/alliance/src/vex/src/vexdup.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexdup.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_DUP_H +# define VEX_DUP_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexenv.c b/alliance/src/vex/src/vexenv.c new file mode 100644 index 00000000..5e420b40 --- /dev/null +++ b/alliance/src/vex/src/vexenv.c @@ -0,0 +1,270 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexenv.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexenv.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + char *VEX_OPER_UPPER_NAME[ VEX_MAX_OPERATOR ] = + { + "&" , + "NOT" , + "NEG" , + "EVENT" , + "OR" , + "AND" , + "XOR" , + "NOR" , + "NAND" , + "XNOR" , + "=" , + "/=" , + "<" , + "<=" , + ">" , + ">=" , + "+" , + "-" , + "*" , + "/" , + "**" , + "MOD" , + "REM" , + "TO" , + "DOWNTO", + "INDEX" , + "LEFT" , + "RIGHT", + "LOW", + "HIGH", + "LENGTH", + "RANGE", + "REV_RANGE", + "DRIVER", + "IFT", + "ARRAY", + "INDEX_N", + "OTHERS =>", + "NUM_BIT", + "ABS" + }; + +/* A few declaration that should be in vexenv I believe, but I leave + * this kind of update to Mr Jacomme, master of these sources */ +/* A sharp '#' is used where an operator exists but has to be + * treated specifically. + * Quite a few VHDL operators have no equivalent in verilog for my + * current knowledge: NULL indicates that! */ + + char *VEX_OPER_VERILOG_NAME[ VEX_MAX_OPERATOR ] = + { + "," , /* VEX_CONCAT */ + "~" , /* VEX_NOT */ + "-" , /* VEX_NEG */ + NULL, /* VEX_EVENT */ + "|" , /* VEX_OR */ + "&" , /* VEX_AND */ + "^" , /* VEX_XOR */ + "#" , /* VEX_NOR */ + "#" , /* VEX_NAND */ + "#" , /* VEX_NXOR */ + "==", /* VEX_EQ */ + "!=", /* VEX_NE */ + "<" , /* VEX_LT */ + "<=", /* VEX_LE */ + ">" , /* VEX_GT */ + ">=", /* VEX_GE */ + "+" , /* VEX_ADD */ + "-" , /* VEX_SUB */ + "*" , /* VEX_MUL */ + "/" , /* VEX_DIV */ + "**", /* VEX_EXP */ + "%" , /* VEX_MOD */ + "%" , /* VEX_REM */ + NULL, /* VEX_TO */ + NULL, /* VEX_DOWNTO */ + NULL, /* VEX_INDEX */ + NULL, /* VEX_LEFT */ + NULL, /* VEX_RIGHT */ + NULL, /* VEX_LOW */ + NULL, /* VEX_HIGH */ + NULL, /* VEX_LENGTH */ + NULL, /* VEX_RANGE */ + NULL, /* VEX_REV_RANGE */ + NULL, /* VEX_DRIVER */ + "IFT", /* VEX_IFT */ + NULL , /* VEX_ARRAY */ + NULL , /* VEX_INDEX_N */ + NULL , /* VEX_OTHERS */ + NULL , /* VEX_NUM_BIT */ + NULL /* VEX_ABS */ + }; + + char VEX_LITERAL_BY_ID[ VEX_MAX_ID ] = + { + 'u', 'x', '0', '1', 'z', 'w', 'l', 'h', '-' + }; + + char *VEX_TYPE_NAME[ VEX_MAX_TYPE ] = + { + "SEVERITY", + "BOOLEAN", + "CHARACTER", + "STRING", + "BIT", + "INTEGER", + "NATURAL", + "BIT_VECTOR", + "STD_ULOGIC", + "STD_LOGIC", + "STD_ULOGIC_VECTOR", + "STD_LOGIC_VECTOR", + "X01", + "X01Z", + "UX01", + "UX01Z", + "UNSIGNED", + "SIGNED", + "SMALL_INT", + "REG_BIT", + "REG_VECTOR", + "MUX_BIT", + "MUX_VECTOR", + "WOR_BIT", + "WOR_VECTOR", + "ENUMERATE", + "ARRAY" + }; + + char *VEX_STD_FUNC_UPPER_NAME[ VEX_MAX_STD_FUNC ] = + { + "TO_BIT", + "TO_BITVECTOR", + "TO_STDULOGIC", + "TO_STDLOGICVECTOR", + "TO_STDULOGICVECTOR", + "TO_X01", + "TO_X01Z", + "TO_UX01", + "RISING_EDGE", + "FALLING_EDGE", + "IS_X", + "ABS", + "SHL", + "SHR", + "CONV_INTEGER", + "CONV_UNSIGNED", + "CONV_SIGNED", + "CONV_STD_LOGIC_VECTOR", + "EXT", + "SXT", + "SHIFT_LEFT", + "SHIFT_RIGHT", + "ROTATE_LEFT", + "ROTATE_RIGHT", + "RESIZE", + "TO_INTEGER", + "TO_UNSIGNED", + "TO_SIGNED", + "STD_LOGIC_VECTOR", + "STD_ULOGIC_VECTOR", + "SIGNED", + "UNSIGNED" + }; + + char *VEX_ATOM_BY_ID[ VEX_MAX_ID ]; + char *VEX_OPER_NAME[ VEX_MAX_OPERATOR ]; + char *VEX_STD_FUNC_NAME[ VEX_MAX_STD_FUNC ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Vex Env | +| | +\------------------------------------------------------------*/ + +void vexenv() +{ + char Buffer[ 16 ]; + int Index; + + for ( Index = 0; Index < VEX_MAX_ID; Index++ ) + { + sprintf( Buffer, "'%c'", VEX_LITERAL_BY_ID[ Index ] ); + VEX_ATOM_BY_ID[ Index ] = namealloc( Buffer ); + } + + for ( Index = 0; Index < VEX_MAX_OPERATOR; Index++ ) + { + VEX_OPER_NAME[ Index ] = namealloc( VEX_OPER_UPPER_NAME[ Index ] ); + } + + for ( Index = 0; Index < VEX_MAX_STD_FUNC; Index++ ) + { + VEX_STD_FUNC_NAME[ Index ] = namealloc( VEX_STD_FUNC_UPPER_NAME[ Index ] ); + } +} diff --git a/alliance/src/vex/src/vexenv.h b/alliance/src/vex/src/vexenv.h new file mode 100644 index 00000000..f3ca1b12 --- /dev/null +++ b/alliance/src/vex/src/vexenv.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexenv.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_ENV_H +# define VEX_ENV_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexerror.c b/alliance/src/vex/src/vexerror.c new file mode 100644 index 00000000..5ecd072a --- /dev/null +++ b/alliance/src/vex/src/vexerror.c @@ -0,0 +1,113 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : Vex Errors | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void vex_error( Error, Text, File, Line ) + + int Error; + char *Text; + char *File; + long Line; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%ld ", Name, Line ); + + switch( Error ) + { + case VEX_OPERATOR_ERROR : + + fprintf( stderr, "bad operator %ld !\n", (long)Text ); + + break; + + case VEX_NOT_UNARY_ERROR : + + fprintf( stderr, "not unary operator %ld !\n", (long)Text ); + + break; + + case VEX_NOT_LITERAL_ERROR : + + fprintf( stderr, "not literal atom !\n" ); + + break; + + default : + + fprintf( stderr, "unknown internal error %d !\n", Error ); + } + + autexit( 1 ); +} diff --git a/alliance/src/vex/src/vexerror.h b/alliance/src/vex/src/vexerror.h new file mode 100644 index 00000000..53a99816 --- /dev/null +++ b/alliance/src/vex/src/vexerror.h @@ -0,0 +1,85 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : Vex Errors | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_ERROR_H +# define VEX_ERROR_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VEX_OPERATOR_ERROR 0 +# define VEX_NOT_UNARY_ERROR 1 +# define VEX_NOT_LITERAL_ERROR 2 + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macros | +| | +\------------------------------------------------------------*/ + +# define vexerror( E, V ) (vex_error( (int)(E), (char*)(long)(V), __FILE__, __LINE__ )) + +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void vex_error __P((int Error, char *Text, char *File, long Line)); + +# endif diff --git a/alliance/src/vex/src/vexeval.c b/alliance/src/vex/src/vexeval.c new file mode 100644 index 00000000..abb81e82 --- /dev/null +++ b/alliance/src/vex/src/vexeval.c @@ -0,0 +1,303 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexeval.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexeval.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + char VexNotLiteral[ VEX_MAX_ID ] = + { +/* ------------------------------------------ */ +/* U X 0 1 Z W L H - */ +/* ------------------------------------------ */ + 'u', 'x', '1', '0', 'x', 'x', '1', '0', 'x' + }; + + char VexAndLiteral[ VEX_MAX_ID ][ VEX_MAX_ID ] = + { +/* ------------------------------------------ */ +/* U X 0 1 Z W L H - */ +/* ------------------------------------------ */ + { 'u', 'u', '0', 'u', 'u', 'u', '0', 'u', 'u' }, /* | u | */ + { 'u', 'x', '0', 'x', 'x', 'x', '0', 'x', 'x' }, /* | x | */ + { '0', '0', '0', '0', '0', '0', '0', '0', '0' }, /* | 0 | */ + { 'u', 'x', '0', '1', 'x', 'x', '0', '1', 'x' }, /* | 1 | */ + { 'u', 'x', '0', 'x', 'x', 'x', '0', 'x', 'x' }, /* | z | */ + { 'u', 'x', '0', 'x', 'x', 'x', '0', 'x', 'x' }, /* | w | */ + { '0', '0', '0', '0', '0', '0', '0', '0', '0' }, /* | l | */ + { 'u', 'x', '0', '1', 'x', 'x', '0', '1', 'x' }, /* | h | */ + { 'u', 'x', '0', 'x', 'x', 'x', '0', 'x', 'x' } /* | - | */ + }; + + char VexOrLiteral[ VEX_MAX_ID ][ VEX_MAX_ID ] = + { +/* ------------------------------------------ */ +/* U X 0 1 Z W L H - */ +/* ------------------------------------------ */ + { 'u', 'u', 'u', '1', 'u', 'u', 'u', '1', 'u' }, /* | u | */ + { 'u', 'x', 'x', '1', 'x', 'x', 'x', '1', 'x' }, /* | x | */ + { 'u', 'x', '0', '1', 'x', 'x', '0', '1', 'x' }, /* | 0 | */ + { '1', '1', '1', '1', '1', '1', '1', '1', '1' }, /* | 1 | */ + { 'u', 'x', 'x', '1', 'x', 'x', 'x', '1', 'x' }, /* | z | */ + { 'u', 'x', 'x', '1', 'x', 'x', 'x', '1', 'x' }, /* | w | */ + { 'u', 'x', '0', '1', 'x', 'x', '0', '1', 'x' }, /* | l | */ + { '1', '1', '1', '1', '1', '1', '1', '1', '1' }, /* | h | */ + { 'u', 'x', 'x', '1', 'x', 'x', 'x', '1', 'x' } /* | - | */ + }; + + char VexXorLiteral[ VEX_MAX_ID ][ VEX_MAX_ID ] = + { +/* ------------------------------------------ */ +/* U X 0 1 Z W L H - */ +/* ------------------------------------------ */ + { 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u' }, /* | u | */ + { 'u', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' }, /* | x | */ + { 'u', 'x', '0', '1', 'x', 'x', '0', '1', 'x' }, /* | 0 | */ + { 'u', 'x', '1', '0', 'x', 'x', '1', '0', 'x' }, /* | 1 | */ + { 'u', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' }, /* | z | */ + { 'u', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' }, /* | w | */ + { 'u', 'x', '0', '1', 'x', 'x', '0', '1', 'x' }, /* | l | */ + { 'u', 'x', '1', '0', 'x', 'x', '1', '0', 'x' }, /* | h | */ + { 'u', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' } /* | - | */ + }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Eval Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Eval Vex Atom Long | +| | +\------------------------------------------------------------*/ + +int evalvexatomlong( Expr, PLong ) + + vexexpr *Expr; + long *PLong; +{ + char *Literal; + long Value; + int Index; + int IndexStep; + int IndexMax; + int Error; + + if ( ( ! IsVexNodeAtom( Expr ) ) || + ( ! IsVexAtomLiteral( Expr ) ) ) + { + return( -1 ); + } + + Literal = GetVexAtomValue( Expr ); + Error = 0; + + Index = 1; + IndexStep = 1; + IndexMax = Expr->WIDTH + 1; + + if ( ( IsVexNodeSigned( Expr ) ) && + ( Literal[ Index ] == '1' ) ) Value = -1; + else Value = 0; + + do + { + Value = Value << 1; + + if ( Literal[ Index ] == '1' ) + { + Value |= 1; + } + else + if ( Literal[ Index ] != '0' ) + { + Error = -1; + } + + Index += IndexStep; + } + while ( Index != IndexMax ); + + *PLong = Value; + + return( Error ); +} + +/*------------------------------------------------------------\ +| | +| Eval Vex Not Literal | +| | +\------------------------------------------------------------*/ + +int evalvexnotliteral( Literal, PChar ) + + char Literal; + char *PChar; +{ + int Index; + + Index = getvexliteralid( Literal ); + + if ( Index == -1 ) + { + return( -1 ); + } + + *PChar = VexNotLiteral[ Index ]; + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Eval Vex And Literal | +| | +\------------------------------------------------------------*/ + +int evalvexandliteral( Literal1, Literal2, PChar ) + + char Literal1; + char Literal2; + char *PChar; +{ + int Index1; + int Index2; + + Index1 = getvexliteralid( Literal1 ); + Index2 = getvexliteralid( Literal2 ); + + if ( ( Index1 == -1 ) || + ( Index2 == -1 ) ) + { + return( -1 ); + } + + *PChar = VexAndLiteral[ Index1 ][ Index2 ]; + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Eval Vex Or Literal | +| | +\------------------------------------------------------------*/ + +int evalvexorliteral( Literal1, Literal2, PChar ) + + char Literal1; + char Literal2; + char *PChar; +{ + int Index1; + int Index2; + + Index1 = getvexliteralid( Literal1 ); + Index2 = getvexliteralid( Literal2 ); + + if ( ( Index1 == -1 ) || + ( Index2 == -1 ) ) + { + return( -1 ); + } + + *PChar = VexOrLiteral[ Index1 ][ Index2 ]; + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Eval Vex Xor Literal | +| | +\------------------------------------------------------------*/ + +int evalvexxorliteral( Literal1, Literal2, PChar ) + + char Literal1; + char Literal2; + char *PChar; +{ + int Index1; + int Index2; + + Index1 = getvexliteralid( Literal1 ); + Index2 = getvexliteralid( Literal2 ); + + if ( ( Index1 == -1 ) || + ( Index2 == -1 ) ) + { + return( -1 ); + } + + *PChar = VexXorLiteral[ Index1 ][ Index2 ]; + + return( 0 ); +} diff --git a/alliance/src/vex/src/vexeval.h b/alliance/src/vex/src/vexeval.h new file mode 100644 index 00000000..09c9bba8 --- /dev/null +++ b/alliance/src/vex/src/vexeval.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexeval.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_EVAL_H +# define VEX_EVAL_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexextend.c b/alliance/src/vex/src/vexextend.c new file mode 100644 index 00000000..84cf581b --- /dev/null +++ b/alliance/src/vex/src/vexextend.c @@ -0,0 +1,261 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexextend.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexextend.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Extend Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Extend Vex Atom Sign | +| | +\------------------------------------------------------------*/ + +vexexpr *extendvexatomsign( Expr, Width ) + + vexexpr *Expr; + short Width; +{ + char *Value; + vexexpr *Atom; + vexexpr *Result; + char Buffer[ 128 ]; + int Index; + int Target; + int Extend; + char Sign; + char Limit; + + if ( IsVexNodeAtom( Expr ) ) + { + Value = GetVexAtomValue( Expr ); + + if ( IsVexAtomLiteral( Expr ) ) + { + if ( Expr->WIDTH < Width ) + { +/* +** "1xxxx" -> "1111xxxx" +*/ + Extend = Width - Expr->WIDTH; + + if ( IsVexNodeSigned( Expr ) ) Sign = Value[ 1 ]; + else Sign = '0'; + + Target = 0; + Buffer[ Target++ ] = '"'; + + for ( Index = 1; Index <= Extend; Index++ ) + { + Buffer[ Target++ ] = Sign; + } + + for ( Index = 1; Index <= Expr->WIDTH; Index++ ) + { + Buffer[ Target++ ] = Value[ Index ]; + } + + Buffer[ Target++ ] = '"'; + Buffer[ Target++ ] = '\0'; + + SetVexAtomValue( Expr, namealloc( Buffer ) ); + + Expr->WIDTH = Width; + Expr->LEFT = Width - 1; + Expr->RIGHT = 0; + } + else + if ( Expr->WIDTH > Width ) + { +/* +** "1111xxxx" -> "1xxxx" +*/ + Extend = (Expr->WIDTH + 1) - Width; + + if ( IsVexNodeSigned( Expr ) ) Sign = Value[ 1 ]; + else Sign = '0'; + + Target = 0; + + if ( Width > 1 ) Limit = '"'; + else Limit = '\''; + + Buffer[ Target++ ] = Limit; + + for ( Index = 1; Index <= Extend; Index++ ) + { + if ( Value[ Index ] != Sign ) return( (vexexpr *)0 ); + } + + for ( Index = Extend; Index <= Expr->WIDTH; Index++ ) + { + Buffer[ Target++ ] = Value[ Index ]; + } + + Buffer[ Target++ ] = Limit; + Buffer[ Target++ ] = '\0'; + + SetVexAtomValue( Expr, namealloc( Buffer ) ); + + Expr->WIDTH = Width; + Expr->LEFT = Width - 1; + Expr->RIGHT = 0; + } + + return( Expr ); + } + else + { + if ( Expr->WIDTH < Width ) + { +/* +** "1xxxx" -> "1111xxxx" +*/ + Extend = Width - Expr->WIDTH; + + if ( IsVexNodeSigned( Expr ) ) + { + Value = GetVexAtomValue( Expr ); + Result = createvexoper( VEX_CONCAT, Width ); + + addvexhexpr( Result, Expr ); + + for ( Index = 1; Index <= Extend; Index++ ) + { + if ( IsVexAtomVector( Expr ) ) + { + Atom = createvexatomvec( Value, Expr->LEFT, Expr->LEFT ); + } + else + { + Atom = createvexatombit( Value ); + } + + addvexhexpr( Result, Atom ); + } + + Expr = Result; + + Expr->WIDTH = Width; + Expr->LEFT = Width - 1; + Expr->RIGHT = 0; + + SetVexNodeSigned( Expr ); + } + else + { + Target = 0; + + if ( Extend > 1 ) Limit = '"'; + else Limit = '\''; + + Buffer[ Target++ ] = Limit; + + for ( Index = 1; Index <= Extend; Index++ ) + { + Buffer[ Target++ ] = '0'; + } + + Buffer[ Target++ ] = Limit; + Buffer[ Target++ ] = '\0'; + + Atom = createvexatomlit( Buffer ); + Expr = createvexbinexpr( VEX_CONCAT, 0, Atom, Expr ); + + Expr->LEFT = Width - 1; + Expr->RIGHT = 0; + Expr->WIDTH = Width; + } + + return( Expr ); + } + else + { + Expr->WIDTH = Width; + + if ( IsVexAtomDown( Expr ) ) + { + Expr->LEFT = Expr->RIGHT + Width - 1; + } + else + { + Expr->LEFT = Expr->RIGHT - Width + 1; + } + + return( Expr ); + } + } + } + + return( (vexexpr *)0 ); +} diff --git a/alliance/src/vex/src/vexextend.h b/alliance/src/vex/src/vexextend.h new file mode 100644 index 00000000..3e7b7733 --- /dev/null +++ b/alliance/src/vex/src/vexextend.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexextend.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_EXTEND_H +# define VEX_EXTEND_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexfree.c b/alliance/src/vex/src/vexfree.c new file mode 100644 index 00000000..b4d551f3 --- /dev/null +++ b/alliance/src/vex/src/vexfree.c @@ -0,0 +1,119 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexfree.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexfree.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Vex Free Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Vex Free Node | +| | +\------------------------------------------------------------*/ + +void freevexnode( Node ) + + vexexpr *Node; +{ + autfreeheap( Node, sizeof( vexexpr ) ); +} + +/*------------------------------------------------------------\ +| | +| Vex Free Expr | +| | +\------------------------------------------------------------*/ + +void freevexexpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( Expr != (vexexpr *)0 ) + { + if ( ! IsVexNodeAtom( Expr ) ) + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + freevexexpr( GetVexOperand( ScanOper ) ); + } + + freechain( Expr->OPERAND ); + } + + freevexnode( Expr ); + } +} diff --git a/alliance/src/vex/src/vexfree.h b/alliance/src/vex/src/vexfree.h new file mode 100644 index 00000000..dcca5603 --- /dev/null +++ b/alliance/src/vex/src/vexfree.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexfree.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_FREE_H +# define VEX_FREE_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexget.c b/alliance/src/vex/src/vexget.c new file mode 100644 index 00000000..76b46545 --- /dev/null +++ b/alliance/src/vex/src/vexget.c @@ -0,0 +1,1151 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexget.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include +# include "vexget.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + long VEX_NOT_OPER[ VEX_MAX_OPERATOR ] = + { + -1, /* VEX_CONCAT */ + -1, /* VEX_NOT */ + -1, /* VEX_NEG */ + -1, /* VEX_EVENT */ + VEX_NOR, /* VEX_OR */ + VEX_NAND, /* VEX_AND */ + VEX_NXOR, /* VEX_XOR */ + VEX_OR, /* VEX_NOR */ + VEX_AND, /* VEX_NAND */ + VEX_XOR, /* VEX_NXOR */ + VEX_NE, /* VEX_EQ */ + VEX_EQ, /* VEX_NE */ + VEX_GE, /* VEX_LT */ + VEX_GT, /* VEX_LE */ + VEX_LE, /* VEX_GT */ + VEX_LT, /* VEX_GE */ + -1, /* VEX_ADD */ + -1, /* VEX_SUB */ + -1, /* VEX_MUL */ + -1, /* VEX_DIV */ + -1, /* VEX_EXP */ + -1, /* VEX_MOD */ + -1, /* VEX_REM */ + -1, /* VEX_TO */ + -1, /* VEX_DOWNTO */ + -1, /* VEX_INDEX */ + -1, /* VEX_LEFT */ + -1, /* VEX_RIGHT */ + -1, /* VEX_LOW */ + -1, /* VEX_HIGH */ + -1, /* VEX_LENGTH */ + -1, /* VEX_RANGE */ + -1, /* VEX_REV_RANGE */ + -1, /* VEX_DRIVER */ + -1, /* VEX_IFT */ + -1, /* VEX_ARRAY */ + -1, /* VEX_INDEX_N */ + -1, /* VEX_OTHERS */ + -1, /* VEX_NUM_BIT */ + -1 /* VEX_ABS */ + }; + + short VexTypeScalar[ VEX_MAX_TYPE ] = + { + VEX_TYPE_SEVERITY , /* SEVERITY */ + VEX_TYPE_BOOLEAN , /* BOOLEAN */ + VEX_TYPE_CHARACTER , /* CHARACTER */ + VEX_TYPE_CHARACTER , /* STRING */ + VEX_TYPE_BIT , /* BIT */ + VEX_TYPE_INTEGER , /* INTEGER */ + VEX_TYPE_NATURAL , /* NATURAL */ + VEX_TYPE_BIT , /* BIT_VECTOR */ + VEX_TYPE_STD_ULOGIC , /* STD_ULOGIC */ + VEX_TYPE_STD_LOGIC , /* STD_LOGIC */ + VEX_TYPE_STD_ULOGIC , /* STD_ULOGIC_VECTOR */ + VEX_TYPE_STD_LOGIC , /* STD_LOGIC_VECTOR */ + VEX_TYPE_X01 , /* X01 */ + VEX_TYPE_X01Z , /* X01Z */ + VEX_TYPE_UX01 , /* UX01 */ + VEX_TYPE_UX01Z , /* UX01Z */ + VEX_TYPE_UNSIGNED , /* UNSIGNED */ + VEX_TYPE_SIGNED , /* SIGNED */ + VEX_TYPE_SMALL_INT , /* SMALL_INT */ + VEX_TYPE_REG_BIT , /* REG_BIT */ + VEX_TYPE_REG_BIT , /* REG_VECTOR */ + VEX_TYPE_MUX_BIT , /* MUX_BIT */ + VEX_TYPE_MUX_BIT , /* MUX_VECTOR */ + VEX_TYPE_WOR_BIT , /* WOR_BIT */ + VEX_TYPE_WOR_BIT , /* WOR_VECTOR */ + VEX_TYPE_ENUMERATE , /* ENUMERATE */ + VEX_TYPE_ARRAY /* ARRAY */ + }; + + static chain_list *VexGetHeadChain = (chain_list *)0; + static ptype_list *VexGetHeadPtype = (ptype_list *)0; + static char VexBuffer[ 128 ]; + + static authtable *VexHashStdFunc = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Get Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Get Vex Int Number Bit | +| | +\------------------------------------------------------------*/ + +int getvexintnumbit( Size ) + + long Size; +{ + long Mask; + int NumberBit; + + if ( Size < 0 ) return( 0 ); + if ( Size == 0 ) return( 1 ); + + Mask = 1L << 31; + + for ( NumberBit = 32; NumberBit > 0; NumberBit-- ) + { + if ( Mask & Size ) break; + + Mask = Mask >> 1; + } + + return( NumberBit ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Interval Number Bits | +| | +\------------------------------------------------------------*/ + +int getvexintervalnumbit( Left, Right ) + + long Left; + long Right; +{ + long NumberBit; + long Swap; + long Max; + + if ( Left > Right ) + { + Swap = Left; + Left = Right; + Right = Swap; + } + + if ( Left >= 0 ) + { + NumberBit = 0; + Max = Right; + } + else + { + NumberBit = 1; + Max = - Left; + + if ( Max < Right ) Max = Right; + } + + NumberBit += getvexintnumbit( Max ); + + return( NumberBit ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Type Scalar | +| | +\------------------------------------------------------------*/ + +int getvextypescalar( Type ) + + int Type; +{ + if ( ( Type < 0 ) || + ( Type >= VEX_MAX_TYPE ) ) + { + return( -1 ); + } + + return( VexTypeScalar[ Type ] ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Vector Name | +| | +\------------------------------------------------------------*/ + +char *getvexvectorname( Vector, Index ) + + char *Vector; + long *Index; +{ + char *LeftParen; + char *RightParen; + + if ( Vector == (char *)0 ) + { + return( (char *)0 ); + } + + strcpy( VexBuffer, Vector ); + LeftParen = strchr( VexBuffer, '(' ); + + if ( LeftParen == (char *)0 ) + { + return( (char *)0 ); + } + + *LeftParen = '\0'; + RightParen = strchr( LeftParen + 1, ')' ); + + if ( RightParen == (char *)0 ) + { + return( (char *)0 ); + } + + *RightParen = '\0'; + + if ( *(LeftParen + 1) == '?' ) + { + *Index = -1; + } + else + { + *Index = atoi( LeftParen + 1 ); + } + + Vector = namealloc( VexBuffer ); + + return( Vector ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Atom Bit Name | +| | +\------------------------------------------------------------*/ + +chain_list *getvexatombitname( Expr ) + + vexexpr *Expr; +{ + chain_list *HeadList; + chain_list *NewChain; + chain_list **PrevChain; + char *ScanChar; + char *Name; + long Index; + long Step; + long Width; + + if ( ! IsVexNodeAtom( Expr ) ) + { + return( (chain_list *)0 ); + } + + Name = GetVexAtomValue( Expr ); + + if ( IsVexNodeBit( Expr ) ) + { + HeadList = addchain( (chain_list *)0, Name ); + } + else + { + if ( Expr->LEFT > Expr->RIGHT ) Step = -1; + else Step = 1; + + Index = Expr->LEFT; + + if ( IsVexAtomLiteral( Expr ) ) + { + VexBuffer[ 0 ] = '\''; + VexBuffer[ 2 ] = '\''; + VexBuffer[ 3 ] = '\0'; + + ScanChar = &VexBuffer[ 1 ]; + } + else + { + strcpy( VexBuffer, Name ); + ScanChar = VexBuffer + strlen( VexBuffer ); + } + + PrevChain = &HeadList; + + for ( Width = Expr->WIDTH; Width > 0; Width-- ) + { + if ( IsVexAtomLiteral( Expr ) ) + { + if ( Step > 0 ) *ScanChar = Name[ Width ]; + else *ScanChar = Name[ Expr->WIDTH - Width ]; + } + else + if ( IsVexNodeVarWidth( Expr ) ) + { + strcpy( ScanChar, "(??)" ); + } + else + { + sprintf( ScanChar, "(%ld)", Index ); + } + + NewChain = addchain( (chain_list *)0, namealloc( VexBuffer ) ); + *PrevChain = NewChain; + PrevChain = &NewChain->NEXT; + + Index += Step; + } + } + + return( HeadList ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Atom Bit Name Ptype | +| | +\------------------------------------------------------------*/ + +ptype_list *getvexatombitnameptype( Expr ) + + vexexpr *Expr; +{ + ptype_list *HeadList; + ptype_list *NewChain; + ptype_list **PrevChain; + char *Name; + long Index; + long Step; + long Width; + + if ( ( ! IsVexNodeAtom( Expr ) ) || + ( IsVexAtomLiteral( Expr ) ) ) + { + return( (ptype_list *)0 ); + } + + Name = GetVexAtomValue( Expr ); + + if ( IsVexNodeBit( Expr ) ) + { + HeadList = addptype( (ptype_list *)0, -1, Name ); + } + else + { + if ( Expr->LEFT > Expr->RIGHT ) Step = -1; + else Step = 1; + + Index = Expr->LEFT; + + PrevChain = &HeadList; + + for ( Width = Expr->WIDTH; Width > 0; Width-- ) + { + NewChain = addptype( (ptype_list *)0, Index, Name ); + *PrevChain = NewChain; + PrevChain = &NewChain->NEXT; + + Index += Step; + } + } + + return( HeadList ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Operator Name | +| | +\------------------------------------------------------------*/ + +char *getvexopername( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( (char *)0 ); + } + + return( VEX_OPER_NAME[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Verilog Operator Name | +| | +\------------------------------------------------------------*/ + +char *getvexoperverilogname( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( (char *)0 ); + } + + return( VEX_OPER_VERILOG_NAME[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Upper Operator Name | +| | +\------------------------------------------------------------*/ + +char *getvexoperuppername( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( (char *)0 ); + } + + return( VEX_OPER_UPPER_NAME[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Operator By Name | +| | +\------------------------------------------------------------*/ + +long getvexoperbyname( Name ) + + char *Name; +{ + int Oper; + + Name = namealloc( Name ); + + for ( Oper = 0; Oper < VEX_MAX_OPERATOR; Oper++ ) + { + if ( VEX_OPER_NAME[ Oper ] == Name ) + { + return( Oper ); + } + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Depth | +| | +\------------------------------------------------------------*/ + +long getvexexprdepth( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + long MaxDepth; + long CarDepth; + + if ( IsVexNodeAtom( Expr ) ) + { + return( 0 ); + } + + MaxDepth = 0; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + CarDepth = getvexexprdepth( GetVexOperand( ScanOper ) ); + if ( CarDepth > MaxDepth ) MaxDepth = CarDepth; + } + + return( MaxDepth + 1 ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Number Node | +| | +\------------------------------------------------------------*/ + +long getvexexprnumnode( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + long NumNode; + + if ( IsVexNodeAtom( Expr ) ) + { + return( 1 ); + } + + NumNode = 1; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + NumNode += getvexexprnumnode( GetVexOperand( ScanOper ) ); + } + + return( NumNode ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Not Operator | +| | +\------------------------------------------------------------*/ + +long getvexnotoper( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( -1 ); + } + + return( VEX_NOT_OPER[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Atom Support | +| | +\------------------------------------------------------------*/ + +static void loc_getvexsupportatom( Expr ) + + vexexpr *Expr; +{ + chain_list *BitList; + chain_list *ScanChain; + chain_list *ScanName; + chain_list **PrevName; + + if ( ! IsVexAtomLiteral( Expr ) ) + { + BitList = getvexatombitname( Expr ); + + for ( ScanChain = BitList; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + PrevName = &VexGetHeadChain; + + for ( ScanName = VexGetHeadChain; + ScanName != (chain_list *)0; + ScanName = ScanName->NEXT ) + { + if ( ScanName->DATA == ScanChain->DATA ) break; + + PrevName = &ScanName->NEXT; + } + + if ( ScanName == (chain_list *)0 ) + { + *PrevName = addchain( (chain_list *)0, ScanChain->DATA ); + } + } + + freechain( BitList ); + } +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Support | +| | +\------------------------------------------------------------*/ + +static void loc_getvexsupport( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( IsVexNodeAtom( Expr ) ) + { + loc_getvexsupportatom( Expr ); + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_getvexsupport( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Support | +| | +\------------------------------------------------------------*/ + +chain_list *getvexexprsupport( Expr ) + + vexexpr *Expr; +{ + VexGetHeadChain = (chain_list *)0; + + if ( Expr != (vexexpr *)0 ) loc_getvexsupport( Expr ); + + return( VexGetHeadChain ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Atom Support Ptype | +| | +\------------------------------------------------------------*/ + +static void loc_getvexsupportatomptype( Expr ) + + vexexpr *Expr; +{ + ptype_list *BitList; + ptype_list *ScanChain; + ptype_list *ScanName; + ptype_list **PrevName; + + if ( ! IsVexAtomLiteral( Expr ) ) + { + BitList = getvexatombitnameptype( Expr ); + + for ( ScanChain = BitList; + ScanChain != (ptype_list *)0; + ScanChain = ScanChain->NEXT ) + { + PrevName = &VexGetHeadPtype; + + for ( ScanName = VexGetHeadPtype; + ScanName != (ptype_list *)0; + ScanName = ScanName->NEXT ) + { + if ( ( ScanName->DATA == ScanChain->DATA ) && + ( ScanName->TYPE == ScanChain->TYPE ) ) break; + + PrevName = &ScanName->NEXT; + } + + if ( ScanName == (ptype_list *)0 ) + { + *PrevName = addptype( (ptype_list *)0, ScanChain->TYPE, ScanChain->DATA ); + } + } + + freeptype( BitList ); + } +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Support Ptype | +| | +\------------------------------------------------------------*/ + +static void loc_getvexsupportptype( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( IsVexNodeAtom( Expr ) ) + { + loc_getvexsupportatomptype( Expr ); + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_getvexsupportptype( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Support Ptype | +| | +\------------------------------------------------------------*/ + +ptype_list *getvexexprsupportptype( Expr ) + + vexexpr *Expr; +{ + VexGetHeadPtype = (ptype_list *)0; + + if ( Expr != (vexexpr *)0 ) loc_getvexsupportptype( Expr ); + + return( VexGetHeadPtype ); +} + +/*------------------------------------------------------------\ +| | +| Union Vex Expr Support Ptype | +| | +\------------------------------------------------------------*/ + +ptype_list *unionvexexprsupportptype( Support, Expr ) + + ptype_list *Support; + vexexpr *Expr; +{ + VexGetHeadPtype = Support; + + if ( Expr != (vexexpr *)0 ) loc_getvexsupportptype( Expr ); + + return( VexGetHeadPtype ); +} + + +/*------------------------------------------------------------\ +| | +| Get Vex Expr Support | +| | +\------------------------------------------------------------*/ + +chain_list *unionvexexprsupport( Support, Expr ) + + chain_list *Support; + vexexpr *Expr; +{ + VexGetHeadChain = Support; + + if ( Expr != (vexexpr *)0 ) loc_getvexsupport( Expr ); + + return( VexGetHeadChain ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Atom All Name | +| | +\------------------------------------------------------------*/ + +static void loc_getvexallnameatom( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanName; + char *AtomName; + + if ( ! IsVexAtomLiteral( Expr ) ) + { + AtomName = GetVexAtomValue( Expr ); + + for ( ScanName = VexGetHeadChain; + ScanName != (chain_list *)0; + ScanName = ScanName->NEXT ) + { + if ( ScanName->DATA == AtomName ) return; + } + + VexGetHeadChain = addchain( VexGetHeadChain, AtomName ); + } +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr All Name | +| | +\------------------------------------------------------------*/ + +static void loc_getvexallname( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( IsVexNodeAtom( Expr ) ) + { + loc_getvexallnameatom( Expr ); + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_getvexallname( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| Get Vex Expr All Name | +| | +\------------------------------------------------------------*/ + +chain_list *getvexexprallname( Expr ) + + vexexpr *Expr; +{ + VexGetHeadChain = (chain_list *)0; + + if ( Expr != (vexexpr *)0 ) loc_getvexallname( Expr ); + + return( VexGetHeadChain ); +} + +/*------------------------------------------------------------\ +| | +| Union Vex Expr Support | +| | +\------------------------------------------------------------*/ + +chain_list *unionvexexprallname( AllName, Expr ) + + chain_list *AllName; + vexexpr *Expr; +{ + VexGetHeadChain = AllName; + + if ( Expr != (vexexpr *)0 ) loc_getvexallname( Expr ); + + return( VexGetHeadChain ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Atom Name | +| | +\------------------------------------------------------------*/ + +char *getvexatomname( Expr ) + + vexexpr *Expr; +{ + long Oper; + + if ( IsVexNodeAtom( Expr ) ) + { + return( GetVexAtomValue( Expr ) ); + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( ( Oper == VEX_ARRAY ) || + ( Oper == VEX_INDEX ) || + ( Oper == VEX_INDEX_N ) || + ( Oper == VEX_DOWNTO ) || + ( Oper == VEX_TO ) ) + { + return( getvexatomname( GetVexOperand( Expr->OPERAND ) ) ); + } + } + + return( (char *)0 ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Literal Id | +| | +\------------------------------------------------------------*/ + +int getvexliteralid( Literal ) + + char Literal; +{ + int Index; + + for ( Index = 0; Index < VEX_MAX_ID; Index++ ) + { + if ( Literal == VEX_LITERAL_BY_ID[ Index ] ) break; + } + + if ( Index == VEX_MAX_ID ) Index = -1; + + return( Index ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Vector Position | +| | +\------------------------------------------------------------*/ + +int getvexvectorpos( Vector, Index ) + + vexexpr *Vector; + short Index; +{ + int Bound; + + if ( IsVexNodeBit( Vector ) ) + { + return( 0 ); + } + + Bound = Vector->WIDTH - 1; + + if ( IsVexNodeDown( Vector ) ) + { + if ( ( Index <= Vector->LEFT ) && + ( Index >= Vector->RIGHT ) ) + { + Index -= Vector->RIGHT; + + return( Bound - Index ); + } + } + else + { + if ( ( Index >= Vector->LEFT ) && + ( Index <= Vector->RIGHT ) ) + { + Index -= Vector->LEFT; + + return( Index ); + } + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Vector Index | +| | +\------------------------------------------------------------*/ + +int getvexvectorindex( Atom, Position ) + + vexexpr *Atom; + short Position; +{ + if ( Position < Atom->WIDTH ) + { + if ( IsVexNodeDown( Atom ) ) return( Atom->LEFT - Position ); + else return( Atom->LEFT + Position ); + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Vector Min | +| | +\------------------------------------------------------------*/ + +int getvexvectormin( Expr ) + + vexexpr *Expr; +{ + if ( IsVexNodeDown( Expr ) ) return( Expr->RIGHT ); + + return( Expr->LEFT ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Vector Max | +| | +\------------------------------------------------------------*/ + +int getvexvectormax( Expr ) + + vexexpr *Expr; +{ + if ( IsVexNodeDown( Expr ) ) return( Expr->LEFT ); + + return( Expr->RIGHT ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Std Func Id | +| | +\------------------------------------------------------------*/ + +int getvexstdfuncid( FuncName ) + + char *FuncName; +{ + authelem *Element; + long Index; + + if ( VexHashStdFunc == (authtable *)0 ) + { + VexHashStdFunc = createauthtable( VEX_MAX_STD_FUNC << 1 ); + + for ( Index = 0; Index < VEX_MAX_STD_FUNC; Index++ ) + { + addauthelem( VexHashStdFunc, VEX_STD_FUNC_NAME[ Index ], Index ); + } + } + + Element = searchauthelem( VexHashStdFunc, FuncName ); + + if ( Element != (authelem *)0 ) return( Element->VALUE ); + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Array Name | +| | +\------------------------------------------------------------*/ + +char *getvexarrayname( Atom ) + + vexexpr *Atom; +{ + char *Name; + long Oper; + + Name = (char *)0; + + if ( IsVexNodeAtom( Atom ) ) + { + Name = GetVexAtomValue( Atom ); + } + else + if ( IsVexNodeOper( Atom ) ) + { + Oper = GetVexOperValue( Atom ); + + if ( ( Oper == VEX_ARRAY ) || + ( Oper == VEX_DOWNTO ) || + ( Oper == VEX_TO ) ) + { + Atom = GetVexOperand( Atom->OPERAND ); + Name = getvexarrayname( Atom ); + } + } + + return( Name ); +} + +/*------------------------------------------------------------\ +| | +| Get Vex Array Atom | +| | +\------------------------------------------------------------*/ + +vexexpr *getvexarrayatom( Expr ) + + vexexpr *Expr; +{ + vexexpr *Atom; + long Oper; + + Atom = (vexexpr *)0; + + if ( IsVexNodeAtom( Expr ) ) + { + Atom = Expr; + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( ( Oper == VEX_ARRAY ) || + ( Oper == VEX_DOWNTO ) || + ( Oper == VEX_TO ) ) + { + Expr = GetVexOperand( Expr->OPERAND ); + Atom = getvexarrayatom( Expr ); + } + } + + return( Atom ); +} + + diff --git a/alliance/src/vex/src/vexget.h b/alliance/src/vex/src/vexget.h new file mode 100644 index 00000000..ce7a817a --- /dev/null +++ b/alliance/src/vex/src/vexget.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexget.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_GET_H +# define VEX_GET_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexis.c b/alliance/src/vex/src/vexis.c new file mode 100644 index 00000000..e5534ffa --- /dev/null +++ b/alliance/src/vex/src/vexis.c @@ -0,0 +1,634 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexis.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexis.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ + + short VexOperBinary[ VEX_MAX_OPERATOR ] = + { + 3, /* VEX_CONCAT */ + 0, /* VEX_NOT */ + 0, /* VEX_NEG */ + 0, /* VEX_EVENT */ + 3, /* VEX_OR */ + 3, /* VEX_AND */ + 3, /* VEX_XOR */ + 3, /* VEX_NOR */ + 3, /* VEX_NAND */ + 3, /* VEX_NXOR */ + 2, /* VEX_EQ */ + 2, /* VEX_NE */ + 2, /* VEX_LT */ + 2, /* VEX_LE */ + 2, /* VEX_GT */ + 2, /* VEX_GE */ + 3, /* VEX_ADD */ + 2, /* VEX_SUB */ + 3, /* VEX_MUL */ + 2, /* VEX_DIV */ + 2, /* VEX_EXP */ + 2, /* VEX_MOD */ + 2, /* VEX_REM */ + 3, /* VEX_TO */ + 3, /* VEX_DOWNTO */ + 2, /* VEX_INDEX */ + 0, /* VEX_LEFT */ + 0, /* VEX_RIGHT */ + 0, /* VEX_LOW */ + 0, /* VEX_HIGH */ + 0, /* VEX_LENGTH */ + 0, /* VEX_RANGE */ + 0, /* VEX_REV_RANGE */ + 0, /* VEX_DRIVER */ + 2, /* VEX_IFT */ + 4, /* VEX_ARRAY */ + 3, /* VEX_INDEX_N */ + 0, /* VEX_OTHERS */ + 2, /* VEX_NUM_BIT */ + 0 /* VEX_ABS */ + }; + + short VexOperArith[ VEX_MAX_OPERATOR ] = + { + 0, /* VEX_CONCAT */ + 0, /* VEX_NOT */ + 1, /* VEX_NEG */ + 0, /* VEX_EVENT */ + 0, /* VEX_OR */ + 0, /* VEX_AND */ + 0, /* VEX_XOR */ + 0, /* VEX_NOR */ + 0, /* VEX_NAND */ + 0, /* VEX_NXOR */ + 1, /* VEX_EQ */ + 1, /* VEX_NE */ + 1, /* VEX_LT */ + 1, /* VEX_LE */ + 1, /* VEX_GT */ + 1, /* VEX_GE */ + 1, /* VEX_ADD */ + 1, /* VEX_SUB */ + 1, /* VEX_MUL */ + 1, /* VEX_DIV */ + 1, /* VEX_EXP */ + 1, /* VEX_MOD */ + 1, /* VEX_REM */ + 0, /* VEX_TO */ + 0, /* VEX_DOWNTO */ + 0, /* VEX_INDEX */ + 0, /* VEX_LEFT */ + 0, /* VEX_RIGHT */ + 0, /* VEX_LOW */ + 0, /* VEX_HIGH */ + 0, /* VEX_LENGTH */ + 0, /* VEX_RANGE */ + 0, /* VEX_REV_RANGE */ + 0, /* VEX_DRIVER */ + 0, /* VEX_IFT */ + 0, /* VEX_ARRAY */ + 0, /* VEX_INDEX_N */ + 1, /* VEX_OTHERS */ + 0, /* VEX_NUM_BIT */ + 1 /* VEX_ABS */ + }; + + short VexOperNegative[ VEX_MAX_OPERATOR ] = + { + 0, /* VEX_CONCAT */ + 1, /* VEX_NOT */ + 0, /* VEX_NEG */ + 0, /* VEX_EVENT */ + 0, /* VEX_OR */ + 0, /* VEX_AND */ + 0, /* VEX_XOR */ + 1, /* VEX_NOR */ + 1, /* VEX_NAND */ + 1, /* VEX_NXOR */ + 0, /* VEX_EQ */ + 0, /* VEX_NE */ + 0, /* VEX_LT */ + 0, /* VEX_LE */ + 0, /* VEX_GT */ + 0, /* VEX_GE */ + 0, /* VEX_ADD */ + 0, /* VEX_SUB */ + 0, /* VEX_MUL */ + 0, /* VEX_DIV */ + 0, /* VEX_EXP */ + 0, /* VEX_MOD */ + 0, /* VEX_REM */ + 0, /* VEX_TO */ + 0, /* VEX_DOWNTO */ + 0, /* VEX_INDEX */ + 0, /* VEX_LEFT */ + 0, /* VEX_RIGHT */ + 0, /* VEX_LOW */ + 0, /* VEX_HIGH */ + 0, /* VEX_LENGTH */ + 0, /* VEX_RANGE */ + 0, /* VEX_REV_RANGE */ + 0, /* VEX_DRIVER */ + 0, /* VEX_IFT */ + 0, /* VEX_ARRAY */ + 0, /* VEX_INDEX_N */ + 0, /* VEX_OTHERS */ + 0, /* VEX_NUM_BIT */ + 0, /* VEX_ABS */ + }; + + short VexTypeDivisible[ VEX_MAX_TYPE ] = + { + 0, /* SEVERITY */ + 0, /* BOOLEAN */ + 0, /* CHARACTER */ + 1, /* STRING */ + 0, /* BIT */ + 0, /* INTEGER */ + 0, /* NATURAL */ + 1, /* BIT_VECTOR */ + 0, /* STD_ULOGIC */ + 0, /* STD_LOGIC */ + 1, /* STD_ULOGIC_VECTOR */ + 1, /* STD_LOGIC_VECTOR */ + 0, /* X01 */ + 0, /* X01Z */ + 0, /* UX01 */ + 0, /* UX01Z */ + 1, /* UNSIGNED */ + 1, /* SIGNED */ + 0, /* SMALL_INT */ + 0, /* REG_BIT */ + 1, /* REG_VECTOR */ + 0, /* MUX_BIT */ + 1, /* MUX_VECTOR */ + 0, /* WOR_BIT */ + 1, /* WOR_VECTOR */ + 0, /* ENUMERATE */ + 1 /* ARRAY */ + }; + + short VexTypeVector[ VEX_MAX_TYPE ] = + { + 0, /* SEVERITY */ + 0, /* BOOLEAN */ + 0, /* CHARACTER */ + 1, /* STRING */ + 0, /* BIT */ + 1, /* INTEGER */ + 1, /* NATURAL */ + 1, /* BIT_VECTOR */ + 0, /* STD_ULOGIC */ + 0, /* STD_LOGIC */ + 1, /* STD_ULOGIC_VECTOR */ + 1, /* STD_LOGIC_VECTOR */ + 0, /* X01 */ + 0, /* X01Z */ + 0, /* UX01 */ + 0, /* UX01Z */ + 1, /* UNSIGNED */ + 1, /* SIGNED */ + 0, /* SMALL_INT */ + 0, /* REG_BIT */ + 1, /* REG_VECTOR */ + 0, /* MUX_BIT */ + 1, /* MUX_VECTOR */ + 0, /* WOR_BIT */ + 1, /* WOR_VECTOR */ + 1, /* ENUMERATE */ + 1 /* ARRAY */ + }; + + static char *VexIsName = (char *)0; + static long VexIsOper = (long )0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Is Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Is Vex Type Vector | +| | +\------------------------------------------------------------*/ + +int isvextypevector( Type ) + + int Type; +{ + if ( ( Type < 0 ) || + ( Type >= VEX_MAX_TYPE ) ) + { + return( -1 ); + } + + return( VexTypeVector[ Type ] ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Type Divisible | +| | +\------------------------------------------------------------*/ + +int isvextypedivisible( Type ) + + int Type; +{ + if ( ( Type < 0 ) || + ( Type >= VEX_MAX_TYPE ) ) + { + return( -1 ); + } + + return( VexTypeDivisible[ Type ] ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Positive Operator | +| | +\------------------------------------------------------------*/ + +int isvexpositiveoper( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( -1 ); + } + + return( ! VexOperNegative[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Negative Operator | +| | +\------------------------------------------------------------*/ + +int isvexnegativeoper( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( -1 ); + } + + return( VexOperNegative[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Unary Operator | +| | +\------------------------------------------------------------*/ + +int isvexunaryoper( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( -1 ); + } + + return( ! VexOperBinary[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Binary Operator | +| | +\------------------------------------------------------------*/ + +int isvexbinaryoper( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( -1 ); + } + + return( VexOperBinary[ Oper ] ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Ternary Operator | +| | +\------------------------------------------------------------*/ + +int isvexternaryoper( Oper ) + + long Oper; +{ + if ( ( Oper < 0 ) || + ( Oper >= VEX_MAX_OPERATOR ) ) + { + return( -1 ); + } + + return( VexOperBinary[ Oper ] == 3 ); +} + +/*------------------------------------------------------------\ +| | +| Is Local Operator In Expr | +| | +\------------------------------------------------------------*/ + +static int loc_isvexoperinexpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( IsVexNodeAtom( Expr ) ) + { + return( 0 ); + } + + if ( IsVexNodeOper( Expr ) ) + { + if ( GetVexOperValue( Expr ) == VexIsOper ) + { + return( 1 ); + } + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + if ( loc_isvexoperinexpr( GetVexOperand( ScanOper ) ) ) + { + return( 1 ); + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Operator In Expr | +| | +\------------------------------------------------------------*/ + +int isvexoperinexpr( Expr, Oper ) + + vexexpr *Expr; + long Oper; +{ + VexIsOper = Oper; + + return( loc_isvexoperinexpr( Expr ) ); +} + +/*------------------------------------------------------------\ +| | +| Is Local Arithmetic Operator In Expr | +| | +\------------------------------------------------------------*/ + +static int loc_isvexarithoperinexpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + vexexpr *Operand1; + vexexpr *Operand2; + long Oper; + + if ( IsVexNodeAtom( Expr ) ) + { + return( 0 ); + } + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( VexOperArith[ Oper ] ) + { + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) ) + { + Operand1 = GetVexOperand( Expr->OPERAND ); + Operand2 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( Operand1->WIDTH == Operand2->WIDTH ) + { + return( 0 ); + } + } + + return( 1 ); + } + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + if ( loc_isvexarithoperinexpr( GetVexOperand( ScanOper ) ) ) + { + return( 1 ); + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Arithmetic Operator In Expr | +| | +\------------------------------------------------------------*/ + +int isvexarithoperinexpr( Expr ) + + vexexpr *Expr; +{ + return( loc_isvexarithoperinexpr( Expr ) ); +} + + +/*------------------------------------------------------------\ +| | +| Is Local Name In Expr | +| | +\------------------------------------------------------------*/ + +static int loc_isvexnameinexpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( GetVexAtomValue( Expr ) == VexIsName ) return( 1 ); + + return( 0 ); + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + if ( loc_isvexnameinexpr( GetVexOperand( ScanOper ) ) ) + { + return( 1 ); + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Name In Expr | +| | +\------------------------------------------------------------*/ + +int isvexnameinexpr( Expr, Name ) + + vexexpr *Expr; + char *Name; +{ + VexIsName = namealloc( Name ); + + return( loc_isvexnameinexpr( Expr ) ); +} + +/*------------------------------------------------------------\ +| | +| Is Vex Equal Expr | +| | +\------------------------------------------------------------*/ + +int isvexequalexpr( Expr1, Expr2 ) + + vexexpr *Expr1; + vexexpr *Expr2; +{ + chain_list *ScanOper1; + chain_list *ScanOper2; + + if ( ( Expr1 == (vexexpr *)0 ) || + ( Expr2 == (vexexpr *)0 ) ) + { + return( 0 ); + } + + if ( ( Expr1->VALUE != Expr2->VALUE ) || + ( Expr1->TYPE != Expr2->TYPE ) || + ( Expr1->LEFT != Expr2->LEFT ) || + ( Expr1->RIGHT != Expr2->RIGHT ) ) + { + return( 0 ); + } + + + if ( ! IsVexNodeAtom( Expr1 ) ) + { + ScanOper1 = Expr1->OPERAND; + ScanOper2 = Expr2->OPERAND; + + while ( ( ScanOper1 != (chain_list *)0 ) && + ( ScanOper2 != (chain_list *)0 ) ) + { + if ( ! isvexequalexpr( GetVexOperand( ScanOper1 ), + GetVexOperand( ScanOper2 ) ) ) + { + return( 0 ); + } + + ScanOper1 = ScanOper1->NEXT; + ScanOper2 = ScanOper2->NEXT; + } + + if ( ( ScanOper1 != (chain_list *)0 ) || + ( ScanOper2 != (chain_list *)0 ) ) + { + return( 0 ); + } + } + + return( 1 ); +} diff --git a/alliance/src/vex/src/vexis.h b/alliance/src/vex/src/vexis.h new file mode 100644 index 00000000..a3c2191e --- /dev/null +++ b/alliance/src/vex/src/vexis.h @@ -0,0 +1,79 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexis.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_IS_H +# define VEX_IS_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ + + extern short VexOperBinary[ VEX_MAX_OPERATOR ]; + extern short VexOperNegative[ VEX_MAX_OPERATOR ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexoptim.c b/alliance/src/vex/src/vexoptim.c new file mode 100644 index 00000000..172d21cc --- /dev/null +++ b/alliance/src/vex/src/vexoptim.c @@ -0,0 +1,218 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexoptim.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexoptim.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Optim Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Optim Vex Not Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *optimvexnotexpr( Expr ) + + vexexpr *Expr; +{ + vexexpr *Expr1; + char *Value; + char Buffer[ 128 ]; + short Index; + long Oper; + long NotOper; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( IsVexAtomLiteral( Expr ) ) + { + Value = GetVexAtomValue( Expr ); + + Buffer[ 0 ] = Value[ 0 ]; + + for ( Index = 1; Index <= Expr->WIDTH; Index++ ) + { + evalvexnotliteral( Value[ Index ], &Buffer[ Index ] ); + } + + Buffer[ Index++ ] = Value[ 0 ]; + Buffer[ Index++ ] = '\0'; + + SetVexAtomValue( Expr, namealloc( Buffer ) ); + + return( Expr ); + } + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + NotOper = getvexnotoper( Oper ); + + if ( Oper == VEX_NOT ) + { + Expr1 = GetVexOperand( Expr->OPERAND ); + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + return( Expr1 ); + } + else + if ( NotOper != -1 ) + { + SetVexOperValue( Expr, NotOper ); + + return( Expr ); + } + } + + Expr1 = createvexoper( VEX_NOT, Expr->WIDTH ); + addvexhexpr( Expr1, Expr ); + + return( Expr1 ); +} + +/*------------------------------------------------------------\ +| | +| Optim Vex Bin Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *optimvexbinexpr( Oper, Width, Expr1, Expr2 ) + + long Oper; + short Width; + vexexpr *Expr1; + vexexpr *Expr2; +{ + vexexpr *Expr; + chain_list *ScanOper; + long Oper1; + long Oper2; + int Binary; + int Negative; + + Binary = isvexbinaryoper( Oper ); + + if ( ! Binary ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + Negative = isvexnegativeoper( Oper ); + + if ( IsVexNodeOper( Expr1 ) ) Oper1 = GetVexOperValue( Expr1 ); + else Oper1 = -1; + + if ( IsVexNodeOper( Expr2 ) ) Oper2 = GetVexOperValue( Expr2 ); + else Oper2 = -1; + + if ( ( Negative ) || + ( Binary == 2 ) || + ( Oper2 != Oper ) || + ( ( Expr2->WIDTH != Width ) && + ( Oper != VEX_CONCAT ) ) ) + { + Expr = createvexoper( Oper, Width ); + addvexhexpr( Expr, Expr2 ); + } + else + { + Expr = Expr2; + } + + if ( ( Negative ) || + ( Binary == 2 ) || + ( Oper1 != Oper ) || + ( ( Expr2->WIDTH != Width ) && + ( Oper != VEX_CONCAT ) ) ) + { + addvexhexpr( Expr, Expr1 ); + } + else + { + ScanOper = Expr1->OPERAND; + + while ( ScanOper->NEXT != (chain_list *)0 ) + { + ScanOper = ScanOper->NEXT; + } + + ScanOper->NEXT = Expr->OPERAND; + Expr->OPERAND = Expr1->OPERAND; + Expr1->OPERAND = (chain_list *)0; + + freevexexpr( Expr1 ); + } + + return( Expr ); +} diff --git a/alliance/src/vex/src/vexoptim.h b/alliance/src/vex/src/vexoptim.h new file mode 100644 index 00000000..31769458 --- /dev/null +++ b/alliance/src/vex/src/vexoptim.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexoptim.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_OPTIM_H +# define VEX_OPTIM_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexshift.c b/alliance/src/vex/src/vexshift.c new file mode 100644 index 00000000..27f491b2 --- /dev/null +++ b/alliance/src/vex/src/vexshift.c @@ -0,0 +1,240 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexshift.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexshift.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Shift Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Shift Vex Atom Left | +| | +\------------------------------------------------------------*/ + +vexexpr *shiftvexatomleft( Expr, Count ) + + vexexpr *Expr; + short Count; +{ + char *Value; + vexexpr *VexZero; + short Width; + + if ( IsVexNodeAtom( Expr ) ) + { + Value = GetVexAtomValue( Expr ); + Width = Expr->WIDTH; + + if ( Count >= Width ) + { +/* +** "xxxx...x" -> "0000...0" +*/ + VexZero = createvexatomveclit( VEX_ZERO, Width ); + freevexexpr( Expr ); + + Expr = VexZero; + } + else + if ( Count >= 1 ) + { +/* +** "xxxx...x" -> "xxxx...0" +*/ + VexZero = createvexatomveclit( VEX_ZERO, Count ); + + if ( IsVexAtomDown( Expr ) ) + { + Expr = slicevexatomvec( Expr, Expr->LEFT - Count, Expr->RIGHT ); + } + else + { + Expr = slicevexatomvec( Expr, Expr->LEFT + Count, Expr->RIGHT ); + } + + Expr = createvexbinexpr( VEX_CONCAT, Width, Expr, VexZero ); + Expr = simpvexexpr( Expr ); + } + + return( Expr ); + } + + return( (vexexpr *)0 ); +} + +/*------------------------------------------------------------\ +| | +| Shift Vex Atom Right | +| | +\------------------------------------------------------------*/ + +vexexpr *shiftvexatomright( Expr, Count ) + + vexexpr *Expr; + short Count; +{ + char *Value; + vexexpr *VexSign; + vexexpr *VexSignBit; + short Width; + short Index; + + if ( IsVexNodeAtom( Expr ) ) + { + Value = GetVexAtomValue( Expr ); + Width = Expr->WIDTH; + + if ( Count >= Width ) + { + if ( IsVexAtomSigned( Expr ) ) + { +/* +** "sxxx...x" -> "ssss...s" +*/ + if ( IsVexAtomLiteral( Expr ) ) + { + VexSign = createvexatomveclit( Value[ 1 ], Width ); + } + else + { + VexSignBit = createvexatomvec( Value, Expr->LEFT, Expr->LEFT ); + VexSign = VexSignBit; + + for ( Index = 1; Index < Width; Index++ ) + { + VexSign = createvexbinexpr( VEX_CONCAT, VexSign->WIDTH + 1, + VexSign, dupvexexpr( VexSignBit ) ); + } + } + } + else + { +/* +** "xxxx...x" -> "0000...0" +*/ + VexSign = createvexatomveclit( VEX_ZERO, Width ); + freevexexpr( Expr ); + } + + Expr = VexSign; + } + else + if ( Count >= 1 ) + { + if ( IsVexAtomSigned( Expr ) ) + { +/* +** "sxxx...x" -> "ss..xxxx" +*/ + if ( IsVexAtomLiteral( Expr ) ) + { + VexSign = createvexatomveclit( Value[ 1 ], Count ); + } + else + { + VexSignBit = createvexatomvec( Value, Expr->LEFT, Expr->LEFT ); + VexSign = VexSignBit; + + for ( Index = 1; Index < Count; Index++ ) + { + VexSign = createvexbinexpr( VEX_CONCAT, VexSign->WIDTH + 1, + VexSign, dupvexexpr( VexSignBit ) ); + } + } + } + else + { +/* +** "xxxx...x" -> "00..xxxx" +*/ + VexSign = createvexatomveclit( VEX_ZERO, Count ); + } + + if ( IsVexAtomDown( Expr ) ) + { + Expr = slicevexatomvec( Expr, Expr->LEFT, Expr->RIGHT + Count ); + } + else + { + Expr = slicevexatomvec( Expr, Expr->LEFT, Expr->RIGHT - Count ); + } + + Expr = createvexbinexpr( VEX_CONCAT, Width, VexSign, Expr ); + Expr = simpvexexpr( Expr ); + } + + return( Expr ); + } + + return( (vexexpr *)0 ); +} diff --git a/alliance/src/vex/src/vexshift.h b/alliance/src/vex/src/vexshift.h new file mode 100644 index 00000000..10936f65 --- /dev/null +++ b/alliance/src/vex/src/vexshift.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexshift.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_SHIFT_H +# define VEX_SHIFT_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexsimp.c b/alliance/src/vex/src/vexsimp.c new file mode 100644 index 00000000..a0471495 --- /dev/null +++ b/alliance/src/vex/src/vexsimp.c @@ -0,0 +1,1449 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexoptim.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexoptim.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static char SimpBuffer[ 512 ]; + static int SimpVexEqual = 0; + + static vexexpr *loc_simpvexconcat(); + static vexexpr *loc_simpvexnot(); + static vexexpr *loc_simpvexconcat(); + static vexexpr *loc_simpvexneg(); + static vexexpr *loc_simpvexabs(); + static vexexpr *loc_simpvexbool3(); + static vexexpr *loc_simpvexequal2(); + static vexexpr *loc_simpvexcomp2(); + static vexexpr *loc_simpvexarith3(); + static vexexpr *loc_simpvexarith2(); + static vexexpr *loc_simpvexslice(); + static vexexpr *loc_simpvexift(); + static vexexpr *loc_simpvexnop(); + static vexexpr *loc_simpvexnumbit(); + + static vexexpr *(*SimpFuncArray[ VEX_MAX_OPERATOR ])() = + { + loc_simpvexconcat, /* VEX_CONCAT */ + loc_simpvexnot, /* VEX_NOT */ + loc_simpvexneg, /* VEX_NEG */ + loc_simpvexnop, /* VEX_EVENT */ + loc_simpvexbool3, /* VEX_OR */ + loc_simpvexbool3, /* VEX_AND */ + loc_simpvexbool3, /* VEX_XOR */ + loc_simpvexbool3, /* VEX_NOR */ + loc_simpvexbool3, /* VEX_NAND */ + loc_simpvexbool3, /* VEX_NXOR */ + loc_simpvexequal2, /* VEX_EQ */ + loc_simpvexequal2, /* VEX_NE */ + loc_simpvexcomp2, /* VEX_LT */ + loc_simpvexcomp2, /* VEX_LE */ + loc_simpvexcomp2, /* VEX_GT */ + loc_simpvexcomp2, /* VEX_GE */ + loc_simpvexarith3, /* VEX_ADD */ + loc_simpvexarith2, /* VEX_SUB */ + loc_simpvexarith3, /* VEX_MUL */ + loc_simpvexarith2, /* VEX_DIV */ + loc_simpvexarith2, /* VEX_EXP */ + loc_simpvexarith2, /* VEX_MOD */ + loc_simpvexarith2, /* VEX_REM */ + loc_simpvexslice, /* VEX_TO */ + loc_simpvexslice, /* VEX_DOWNTO */ + loc_simpvexslice, /* VEX_INDEX */ + loc_simpvexnop, /* VEX_LEFT */ + loc_simpvexnop, /* VEX_RIGHT */ + loc_simpvexnop, /* VEX_LOW */ + loc_simpvexnop, /* VEX_HIGH */ + loc_simpvexnop, /* VEX_LENGTH */ + loc_simpvexnop, /* VEX_RANGE */ + loc_simpvexnop, /* VEX_REV_RANGE */ + loc_simpvexnop, /* VEX_DRIVER */ + loc_simpvexift, /* VEX_IFT */ + loc_simpvexnop, /* VEX_ARRAY */ + loc_simpvexnop, /* VEX_INDEX_N */ + loc_simpvexnop, /* VEX_OTHERS */ + loc_simpvexnumbit, /* VEX_NUM_BIT */ + loc_simpvexabs /* VEX_ABS */ + }; + + static short SimpBool3Table[ 3 ][ 3 ] = + { + /* Scotch Neutral Polarity */ + + { VEX_ONE_ID, VEX_ZERO_ID, -1 }, /* VEX_OR */ + { VEX_ZERO_ID, VEX_ONE_ID, -1 }, /* VEX_AND */ + { VEX_UNINIT_ID, VEX_ZERO_ID, VEX_ONE_ID } /* VEX_XOR */ + }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Simplify Vex Nop | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexnop( Expr ) + + vexexpr *Expr; +{ + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Concat | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexconcat( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + chain_list *DelOper; + chain_list **PrevOper; + vexexpr *Operand1; + vexexpr *Operand2; + char *Value1; + char *Value2; + long Left1; + long Left2; + long Right1; + long Right2; + int Width; + int Index; + + Operand1 = (vexexpr *)0; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand2 = GetVexOperand( ScanOper ); + + if ( ( IsVexNodeAtom( Operand2 ) ) && + ( ( IsVexAtomVector( Operand2 ) ) || + ( IsVexAtomLiteral( Operand2 ) ) ) ) + { + if ( Operand1 == (vexexpr *)0 ) + { + Operand1 = Operand2; + } + else +/* +** Verify Operand1 and Operand2 +*/ + if ( ( IsVexAtomLiteral( Operand1 ) ) && + ( IsVexAtomLiteral( Operand2 ) ) ) + { +/* +** Literal concatenation +*/ + Width = 1; + SimpBuffer[ 0 ] = '"'; + + Value1 = GetVexAtomValue( Operand1 ); + + for ( Index = 1; Index <= Operand1->WIDTH; Index++ ) + { + SimpBuffer[ Width++ ] = Value1[ Index ]; + } + + Value2 = GetVexAtomValue( Operand2 ); + + for ( Index = 1; Index <= Operand2->WIDTH; Index++ ) + { + SimpBuffer[ Width++ ] = Value2[ Index ]; + } + + SimpBuffer[ Width++ ] = '"'; + SimpBuffer[ Width ] = '\0'; + + Width = Width - 2; + + SetVexAtomValue( Operand1, namealloc( SimpBuffer ) ); + Operand1->WIDTH = Width; + Operand1->LEFT = 0; + Operand1->RIGHT = Width - 1; + + SetVexNodeTag( Operand2 ); + } + else + if ( ( ! IsVexAtomLiteral( Operand1 ) ) && + ( ! IsVexAtomLiteral( Operand2 ) ) ) + { +/* +** Vector concatenation +*/ + Value1 = GetVexAtomValue( Operand1 ); + Value2 = GetVexAtomValue( Operand2 ); + + if ( Value1 == Value2 ) + { + Left1 = Operand1->LEFT; + Right1 = Operand1->RIGHT; + Left2 = Operand2->LEFT; + Right2 = Operand2->RIGHT; + + if ( ( ( Right1 - 1 ) == Left2 ) && + ( Left1 >= Right1 ) && + ( Right1 >= Right2 ) ) + { + Operand1->LEFT = Left1; + Operand1->RIGHT = Right2; + Operand1->WIDTH = (Left1 - Right2) + 1; + + SetVexAtomDown( Operand1 ); + SetVexNodeTag( Operand2 ); + } + else + if ( ( ( Right1 + 1 ) == Left2 ) && + ( Left1 <= Right1 ) && + ( Right1 <= Right2 ) ) + { + Operand1->LEFT = Left1; + Operand1->RIGHT = Right2; + Operand1->WIDTH = (Right2 - Left1) + 1; + + SetVexAtomUp( Operand1 ); + SetVexNodeTag( Operand2 ); + } + else + { + Operand1 = Operand2; + } + } + else + { + Operand1 = Operand2; + } + } + else + { + Operand1 = Operand2; + } + } + else + { + Operand1 = (vexexpr *)0; + } + } + + PrevOper = &Expr->OPERAND; + ScanOper = Expr->OPERAND; + + while ( ScanOper != (chain_list *)0 ) + { + Operand1 = GetVexOperand( ScanOper ); + + if ( IsVexNodeTag( Operand1 ) ) + { + *PrevOper = ScanOper->NEXT; + DelOper = ScanOper; + ScanOper = ScanOper->NEXT; + + DelOper->NEXT = (chain_list *)0; + freechain( DelOper ); + + freevexexpr( Operand1 ); + } + else + { + PrevOper = &ScanOper->NEXT; + ScanOper = ScanOper->NEXT; + } + } + + if ( Expr->OPERAND->NEXT == (chain_list *)0 ) + { + Operand1 = GetVexOperand( Expr->OPERAND ); + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + + freevexexpr( Expr ); + Expr = Operand1; + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Not | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexnot( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand; + vexexpr *Operand2; + char *Value; + long Oper; + int Index; + + Operand = GetVexOperand( Expr->OPERAND ); + + if ( ( IsVexNodeAtom( Operand ) ) && + ( IsVexAtomLiteral( Operand ) ) ) + { + Value = GetVexAtomValue( Operand ); + + SimpBuffer[ 0 ] = Value[ 0 ]; + + for ( Index = 1; Index <= Operand->WIDTH; Index++ ) + { + evalvexnotliteral( Value[ Index ], &SimpBuffer[ Index ] ); + } + + SimpBuffer[ Index++ ] = Value[ 0 ]; + SimpBuffer[ Index++ ] = '\0'; + + SetVexAtomValue( Operand, namealloc( SimpBuffer ) ); + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + Expr = Operand; + } + else + if ( IsVexNodeOper( Operand ) ) + { + Oper = GetVexOperValue( Operand ); + + if ( Oper == VEX_NOT ) + { + Operand2 = GetVexOperand( Operand->OPERAND ); + SetVexOperand( Operand->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + Expr = Operand2; + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Abs | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexabs( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand; + long Value; + + Operand = GetVexOperand( Expr->OPERAND ); + + if ( evalvexatomlong( Operand, &Value ) != -1 ) + { + if ( Value < 0 ) Value = - Value; + freevexexpr( Expr ); + + Expr = createvexatomlong( Value, 0, 1 ); + } + + return( Expr ); +} + + +/*------------------------------------------------------------\ +| | +| Simplify Vex Neg | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexneg( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand; + long Value; + + Operand = GetVexOperand( Expr->OPERAND ); + + if ( evalvexatomlong( Operand, &Value ) != -1 ) + { + Value = - Value; + freevexexpr( Expr ); + + Expr = createvexatomlong( Value, 0, 1 ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Is Operand Same Width | +| | +\------------------------------------------------------------*/ + +static int loc_isoperandsamewidth( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + vexexpr *Operand; + int Width; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + + if ( ScanOper == Expr->OPERAND ) + { + Width = Operand->WIDTH; + } + else + if ( Width != Operand->WIDTH ) + { + return( 0 ); + } + } + + return( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Boolean 3 | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexbool3( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + chain_list **PrevOper; + chain_list *DelOper; + vexexpr *Operand; + vexexpr *VexSum; + int NumOper; + int NumSum; + int Index; + int AllSame; + int Negative; + int LiteralId; + char Literal; + long Oper; + char *Sum; + char *Value; + + Oper = GetVexOperValue( Expr ); + + NumOper = 0; + NumSum = 0; + Sum = 0; + VexSum = (vexexpr *)0; + + if ( ! loc_isoperandsamewidth( Expr ) ) + { + return( Expr ); + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + NumOper++; + + if ( ( IsVexNodeAtom( Operand ) ) && + ( IsVexAtomLiteral( Operand ) ) ) + { + Value = GetVexAtomValue( Operand ); + SetVexNodeTag( Operand ); + + if ( NumSum == 0 ) + { + Sum = Value; + VexSum = Operand; + } + else + { + SimpBuffer[ 0 ] = Value[ 0 ]; + + for ( Index = 1; Index <= Operand->WIDTH; Index++ ) + { + if ( ( Oper == VEX_AND ) || ( Oper == VEX_NAND ) ) + evalvexandliteral( Sum[ Index ], Value[ Index ], &SimpBuffer[ Index ] ); + else + if ( ( Oper == VEX_OR ) || ( Oper == VEX_NOR ) ) + evalvexorliteral( Sum[ Index ], Value[ Index ], &SimpBuffer[ Index ] ); + else + if ( ( Oper == VEX_XOR ) || ( Oper == VEX_NXOR ) ) + evalvexxorliteral( Sum[ Index ], Value[ Index ], &SimpBuffer[ Index ] ); + else + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + SimpBuffer[ Index++ ] = Value[ 0 ]; + SimpBuffer[ Index++ ] = '\0'; + + Sum = namealloc( SimpBuffer ); + } + + NumSum++; + } + } + + if ( NumSum > 1 ) + { + VexSum = dupvexnode( VexSum ); + ClearVexNodeTag( VexSum ); + SetVexAtomValue( VexSum, Sum ); + + if ( NumSum == NumOper ) + { + if ( isvexnegativeoper( Oper ) ) + { + VexSum = optimvexnotexpr( VexSum ); + } + + freevexexpr( Expr ); + + Expr = VexSum; + } + else + { + PrevOper = &Expr->OPERAND; + ScanOper = Expr->OPERAND; + + while ( ScanOper != (chain_list *)0 ) + { + Operand = GetVexOperand( ScanOper ); + + if ( IsVexNodeTag( Operand ) ) + { + *PrevOper = ScanOper->NEXT; + DelOper = ScanOper; + ScanOper = ScanOper->NEXT; + + DelOper->NEXT = (chain_list *)0; + freechain( DelOper ); + + freevexexpr( Operand ); + } + else + { + PrevOper = &ScanOper->NEXT; + ScanOper = ScanOper->NEXT; + } + } + + addvexhexpr( Expr, VexSum ); + } + } + else + if ( NumSum == 1 ) + { + ClearVexNodeTag( VexSum ); + } + + if ( NumSum > 0 ) + { + NumSum = 0; + Negative = isvexnegativeoper( Oper ); + + if ( Negative ) + { + Oper = getvexnotoper( Oper ); + SetVexOperValue( Expr, Oper ); + } + + Oper = Oper - VEX_OR; + ScanOper = Expr->OPERAND; + PrevOper = &Expr->OPERAND; + + while ( ScanOper != (chain_list *)0 ) + { + Operand = GetVexOperand( ScanOper ); + + if ( ( IsVexNodeAtom( Operand ) ) && + ( IsVexAtomLiteral( Operand ) ) ) + { + Value = GetVexAtomValue( Operand ); + Literal = Value[ 1 ]; + AllSame = 1; + + for ( Index = 2; Index <= Operand->WIDTH; Index++ ) + { + if ( Literal != Value[ Index ] ) + { + AllSame = 0; break; + } + } + + if ( AllSame ) + { + LiteralId = getvexliteralid( Literal ); +/* +** The literal is equal to the "scotch" literal +*/ + if ( SimpBool3Table[ Oper ][ 0 ] == LiteralId ) + { + SetVexOperand( ScanOper, (vexexpr *)0 ); + freevexexpr( Expr ); + + if ( Negative ) + { + Operand = optimvexnotexpr( Operand ); + } + + return( Operand ); + } +/* +** The literal is equal to the neutral or polarity inverse literal +*/ + if ( ( SimpBool3Table[ Oper ][ 1 ] == LiteralId ) || + ( SimpBool3Table[ Oper ][ 2 ] == LiteralId ) ) + { + *PrevOper = ScanOper->NEXT; + DelOper = ScanOper; + ScanOper = ScanOper->NEXT; + + DelOper->NEXT = (chain_list *)0; + freechain( DelOper ); + + freevexexpr( Operand ); + + if ( SimpBool3Table[ Oper ][ 2 ] == LiteralId ) + { + Negative = ! Negative; + } + + continue; + } + } + } + + NumSum++; + + PrevOper = &ScanOper->NEXT; + ScanOper = ScanOper->NEXT; + } + + if ( NumSum == 1 ) + { + Operand = GetVexOperand( Expr->OPERAND ); + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + Expr = Operand; + } + + if ( Negative ) + { + Expr = optimvexnotexpr( Expr ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Ift | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexift( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanCond; + chain_list *ScanData; + vexexpr *VexCond; + vexexpr *VexData; + char *Value; + int Index; + int LiteralId; + int AllSame; + char Literal; + + ScanCond = Expr->OPERAND; + VexCond = GetVexOperand( ScanCond ); + ScanData = ScanCond->NEXT; + VexData = GetVexOperand( ScanData ); + + if ( VexData->WIDTH != Expr->WIDTH ) return( Expr ); + + if ( ( IsVexNodeAtom( VexCond ) ) && + ( IsVexAtomLiteral( VexCond ) ) ) + { + Value = GetVexAtomValue( VexCond ); + Literal = Value[ 1 ]; + LiteralId = getvexliteralid( Literal ); + + if ( LiteralId == VEX_ONE_ID ) + { + SetVexOperand( ScanData, (vexexpr *)0 ); + freevexexpr( Expr ); + + return( VexData ); + } + else + if ( LiteralId == VEX_ZERO_ID ) + { + SimpBuffer[ 0 ] = Value[ 0 ]; + + for ( Index = 1; Index <= Expr->WIDTH; Index++ ) + { + SimpBuffer[ Index ] = VEX_ZERO; + } + + SimpBuffer[ Index++ ] = Value[ 0 ]; + SimpBuffer[ Index++ ] = '\0'; + + freevexexpr( Expr ); + VexData = createvexatomlit( SimpBuffer ); + + return( VexData ); + } + } + + if ( ( IsVexNodeAtom( VexData ) ) && + ( IsVexAtomLiteral( VexData ) ) ) + { + Value = GetVexAtomValue( VexData ); + Literal = Value[ 1 ]; + + AllSame = 1; + + for ( Index = 2; Index <= VexData->WIDTH; Index++ ) + { + if ( Literal != Value[ Index ] ) + { + AllSame = 0; break; + } + } + + if ( AllSame ) + { + LiteralId = getvexliteralid( Literal ); + + if ( LiteralId == VEX_ZERO_ID ) + { + SetVexOperand( ScanData, (vexexpr *)0 ); + freevexexpr( Expr ); + + return( VexData ); + } + + if ( ( LiteralId == VEX_ONE_ID ) && + ( VexData->WIDTH == 1 ) ) + { + SetVexOperand( ScanCond, (vexexpr *)0 ); + freevexexpr( Expr ); + + return( VexCond ); + } + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Compare 2 | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexcomp2( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand1; + vexexpr *Operand2; + long Value1; + long Value2; + long Value; + long Oper; + + Oper = GetVexOperValue( Expr ); + Value = 0; + + Operand1 = GetVexOperand( Expr->OPERAND ); + Operand2 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( ( evalvexatomlong( Operand1, &Value1 ) != -1 ) && + ( evalvexatomlong( Operand2, &Value2 ) != -1 ) ) + { + if ( Oper == VEX_LT ) Value = (Value1 < Value2); + else + if ( Oper == VEX_LE ) Value = (Value1 <= Value2); + else + if ( Oper == VEX_GT ) Value = (Value1 > Value2); + else + if ( Oper == VEX_GE ) Value = (Value1 >= Value2); + else + vexerror( VEX_OPERATOR_ERROR, Oper ); + + freevexexpr( Expr ); + + if ( Value ) Expr = createvexatombit( VEX_ATOM_ONE ); + else Expr = createvexatombit( VEX_ATOM_ZERO ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Equal 2 | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexequal2( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand1; + vexexpr *Operand2; + vexexpr *NewExpr; + vexexpr *Atom1; + vexexpr *Atom2; + vexexpr *XorExpr; + char *Value1; + char *Value2; + int ScanPos; + int Index1; + int Index2; + int NumSum; + char Literal; + long Value; + long Oper; + + Oper = GetVexOperValue( Expr ); + + Operand1 = GetVexOperand( Expr->OPERAND ); + Operand2 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( ( IsVexNodeAtom( Operand1 ) ) && + ( IsVexAtomLiteral( Operand1 ) ) && + ( IsVexNodeAtom( Operand2 ) ) && + ( IsVexAtomLiteral( Operand2 ) ) ) + { + if ( Operand1->WIDTH != Operand2->WIDTH ) + { + if ( Operand1->WIDTH > Operand2->WIDTH ) + { + extendvexatomsign( Operand2, Operand1->WIDTH ); + } + else + { + extendvexatomsign( Operand1, Operand2->WIDTH ); + } + } + + Value1 = GetVexAtomValue( Operand1 ); + Value2 = GetVexAtomValue( Operand2 ); + + Value = ! strcmp( Value1, Value2 ); + + if ( Oper == VEX_NE ) Value = ! Value; + else + if ( Oper != VEX_EQ ) vexerror( VEX_OPERATOR_ERROR, Oper ); + + freevexexpr( Expr ); + + if ( Value ) Expr = createvexatombit( VEX_ATOM_ONE ); + else Expr = createvexatombit( VEX_ATOM_ZERO ); + } + else + if ( ( SimpVexEqual ) && + ( ! IsVexNodeVarWidth( Operand1 ) ) && + ( ! IsVexNodeVarWidth( Operand2 ) ) ) + { + if ( ( Operand1->WIDTH == 1 ) && + ( Operand2->WIDTH == 1 ) ) + { + if ( Oper == VEX_EQ ) SetVexOperValue( Expr, VEX_NXOR ); + else SetVexOperValue( Expr, VEX_XOR ); + + Expr = loc_simpvexbool3( Expr ); + } + else + if ( ( IsVexNodeAtom( Operand1 ) ) && + ( IsVexNodeAtom( Operand2 ) ) ) + { + if ( ( Operand1->WIDTH == Operand2->WIDTH ) || + ( IsVexAtomLiteral( Operand1 ) ) || + ( IsVexAtomLiteral( Operand2 ) ) ) + { + if ( IsVexAtomLiteral( Operand2 ) ) + { + NewExpr = Operand1; + Operand1 = Operand2; + Operand2 = NewExpr; + } + + if ( Operand1->WIDTH != Operand2->WIDTH ) + { + extendvexatomsign( Operand1, Operand2->WIDTH ); + } + + Value1 = GetVexAtomValue( Operand1 ); + Value2 = GetVexAtomValue( Operand2 ); + + if ( Oper == VEX_EQ ) NewExpr = createvexoper( VEX_AND, 1 ); + else NewExpr = createvexoper( VEX_OR , 1 ); + + NumSum = 0; + + for ( ScanPos = 0; ScanPos < Operand2->WIDTH; ScanPos++ ) + { + Index2 = getvexvectorindex( Operand2, ScanPos ); + Atom2 = createvexatomvec( Value2, Index2, Index2 ); + + if ( IsVexAtomLiteral( Operand1 ) ) + { + Literal = Value1[ ScanPos + 1 ]; + + if ( Literal == VEX_DC ) continue; + + XorExpr = Atom2; + + if ( Literal != VEX_ONE ) + { + XorExpr = optimvexnotexpr( XorExpr ); + } + } + else + { + Index1 = getvexvectorindex( Operand1, ScanPos ); + Atom1 = createvexatomvec( Value1, Index1, Index1 ); + + XorExpr = createvexbinexpr( VEX_NXOR, 1, Atom1, Atom2 ); + } + + addvexhexpr( NewExpr, XorExpr ); + + NumSum++; + } + + freevexexpr( Expr ); + + if ( NumSum == 0 ) + { + freevexexpr( NewExpr ); + + if ( Oper == VEX_EQ ) Expr = createvexatomlit( VEX_ATOM_ONE ); + else Expr = createvexatomlit( VEX_ATOM_ZERO ); + } + else + if ( NumSum == 1 ) + { + Expr = GetVexOperand( NewExpr->OPERAND ); + + SetVexOperand( NewExpr->OPERAND, (vexexpr *)0 ); + freevexexpr( NewExpr ); + } + else + { + Expr = NewExpr; + } + } + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Arithmetic > 2 Operand | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexarith3( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + chain_list **PrevOper; + chain_list *DelOper; + vexexpr *Operand; + vexexpr *VexInt; + int NumOper; + int NumSum; + long Oper; + long Sum; + long Value; + + Oper = GetVexOperValue( Expr ); + + NumOper = 0; + NumSum = 0; + Sum = 0; + VexInt = (vexexpr *)0; + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + NumOper++; + + if ( evalvexatomlong( Operand, &Value ) != -1 ) + { + SetVexNodeTag( Operand ); + + if ( NumSum == 0 ) + { + Sum = Value; + VexInt = Operand; + } + else + { + if ( Oper == VEX_ADD ) Sum += Value; + else + if ( Oper == VEX_MUL ) Sum *= Value; + else + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + NumSum++; + } + } + + if ( NumSum > 1 ) + { + VexInt = createvexatomlong( Sum, 0, IsVexAtomSigned( Expr ) ); + + if ( NumSum == NumOper ) + { + freevexexpr( Expr ); + + Expr = VexInt; + } + else + { + PrevOper = &Expr->OPERAND; + ScanOper = Expr->OPERAND; + + while ( ScanOper != (chain_list *)0 ) + { + Operand = GetVexOperand( ScanOper ); + + if ( IsVexNodeTag( Operand ) ) + { + *PrevOper = ScanOper->NEXT; + DelOper = ScanOper; + ScanOper = ScanOper->NEXT; + + DelOper->NEXT = (chain_list *)0; + freechain( DelOper ); + + freevexexpr( Operand ); + } + else + { + PrevOper = &ScanOper->NEXT; + ScanOper = ScanOper->NEXT; + } + } + + addvexhexpr( Expr, VexInt ); + } + } + else + if ( NumSum == 1 ) + { + ClearVexNodeTag( VexInt ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Arithmetic 2 Operands | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexarith2( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand1; + vexexpr *Operand2; + vexexpr *VexInt; + long Value1; + long Value2; + long Value; + long Oper; + + Oper = GetVexOperValue( Expr ); + Value = 0; + + Operand1 = GetVexOperand( Expr->OPERAND ); + Operand2 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( ( evalvexatomlong( Operand1, &Value1 ) != -1 ) && + ( evalvexatomlong( Operand2, &Value2 ) != -1 ) ) + { + if ( Oper == VEX_SUB ) + { + Value = Value1 - Value2; + } + else + if ( Oper == VEX_EXP ) + { + if ( Value1 != 2 ) vexerror( VEX_OPERATOR_ERROR, Oper ); + + if ( Value2 == 0 ) Value = 1; + else + if ( Value2 < 0 ) Value = 0; + else + Value = 2L << (Value2 - 1); + } + else + if ( Oper == VEX_MOD ) + { + if ( ( ( Value1 > 0 ) && + ( Value2 > 0 ) ) || + ( ( Value1 < 0 ) && + ( Value2 < 0 ) ) ) + { + Value = Value1 % Value2; + } + else + if ( Value1 < 0 ) + { + Value = -((-Value1) % Value2); + } + else + { + Value = -(Value1 % (-Value2)); + } + } + else + if ( Oper == VEX_REM ) + { + Value = Value1 % Value2; + } + else + if ( Oper == VEX_DIV ) + { + if ( Value2 == 0 ) vexerror( VEX_OPERATOR_ERROR, Oper ); + + Value = Value1 / Value2; + } + else vexerror( VEX_OPERATOR_ERROR, Oper ); + + VexInt = createvexatomlong( Value, 0, IsVexAtomSigned( Expr ) ); + + freevexexpr( Expr ); Expr = VexInt; + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Number Bit | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexnumbit( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand1; + vexexpr *Operand2; + long Value1; + long Value2; + int Size; + + Operand1 = GetVexOperand( Expr->OPERAND ); + Operand2 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( ( evalvexatomlong( Operand1, &Value1 ) != -1 ) && + ( evalvexatomlong( Operand2, &Value2 ) != -1 ) ) + { + Size = getvexintervalnumbit( Value1, Value2 ); + + freevexexpr( Expr ); + Expr = createvexatomlong( Size - 1, 0, 0 ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Slice | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexslice( Expr ) + + vexexpr *Expr; +{ + vexexpr *Atom; + vexexpr *Operand1; + vexexpr *Operand2; + long Oper; + long Value1; + long Value2; + char *Value; + + Oper = GetVexOperValue( Expr ); + Atom = GetVexOperand( Expr->OPERAND ); + Operand1 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( Oper != VEX_INDEX ) + { + Operand2 = GetVexOperand( Expr->OPERAND->NEXT->NEXT ); + } + else + { + Operand2 = Operand1; + } + + if ( ( IsVexNodeAtom( Atom ) ) && + ( evalvexatomlong( Operand1, &Value1 ) != -1 ) && + ( evalvexatomlong( Operand2, &Value2 ) != -1 ) ) + { + if ( ( Oper == VEX_TO ) || + ( Oper == VEX_DOWNTO ) || + ( Oper == VEX_INDEX ) ) + { + if ( ( Value1 < 0 ) || + ( Value2 < 0 ) ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + if ( ( ( Oper == VEX_TO ) && + ( Value1 > Value2 ) ) || + ( ( Oper == VEX_DOWNTO ) && + ( Value1 < Value2 ) ) ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + Value = GetVexAtomValue( Atom ); + freevexexpr( Expr ); + Expr = createvexatomvec( Value, Value1, Value2 ); + } + else vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Expr | +| | +\------------------------------------------------------------*/ + +static vexexpr *loc_simpvexexpr( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand; + chain_list *ScanOper; + long Oper; + + if ( ! IsVexNodeAtom( Expr ) ) + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = loc_simpvexexpr( GetVexOperand( ScanOper ) ); + SetVexOperand( ScanOper, Operand ); + } + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper < VEX_MAX_OPERATOR ) + { + Expr = (*SimpFuncArray[ Oper ])( Expr ); + } + else + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *simpvexexpr( Expr ) + + vexexpr *Expr; +{ + if ( Expr != (vexexpr *)0 ) + { + Expr = loc_simpvexexpr( Expr ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Expr Equal | +| | +\------------------------------------------------------------*/ + +vexexpr *simpvexexpreq( Expr ) + + vexexpr *Expr; +{ + if ( Expr != (vexexpr *)0 ) + { + SimpVexEqual = 1; + Expr = loc_simpvexexpr( Expr ); + SimpVexEqual = 0; + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| Simplify Vex Expr Others | +| | +\------------------------------------------------------------*/ + +vexexpr *simpvexexprothers( Expr, Width ) + + vexexpr *Expr; + short Width; +{ + vexexpr *Operand; + vexexpr *VexAtom; + chain_list *ScanOper; + char *Value; + short ScanWidth; + long Oper; + + if ( ( Width >= 0 ) && + ( Expr != (vexexpr *)0 ) ) + { + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_OTHERS ) + { + Operand = GetVexOperand( Expr->OPERAND ); + + if ( ( IsVexNodeAtom( Operand ) ) && + ( IsVexAtomLiteral( Operand ) ) ) + { + Value = GetVexAtomValue( Operand ); + VexAtom = createvexatomveclit( Value[ 1 ], Width ); + + freevexexpr( Expr ); + Expr = VexAtom; + } + } + else + if ( Oper == VEX_CONCAT ) + { + ScanWidth = 0; + + for ( ScanOper = Expr->OPERAND; + ScanOper->NEXT != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + ScanWidth += Operand->WIDTH; + } + + Operand = GetVexOperand( ScanOper ); + Operand = simpvexexprothers( Operand, Width - ScanWidth ); + SetVexOperand( ScanOper, Operand ); + } + } + } + + return( Expr ); +} diff --git a/alliance/src/vex/src/vexsimp.h b/alliance/src/vex/src/vexsimp.h new file mode 100644 index 00000000..424ad293 --- /dev/null +++ b/alliance/src/vex/src/vexsimp.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexsimp.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef ABL_SIMP_H +# define ABL_SIMP_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexslice.c b/alliance/src/vex/src/vexslice.c new file mode 100644 index 00000000..3d1eecdb --- /dev/null +++ b/alliance/src/vex/src/vexslice.c @@ -0,0 +1,162 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexslice.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexslice.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static char VexBuffer[ 128 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Slice Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Slice Vex Atom Vector | +| | +\------------------------------------------------------------*/ + +vexexpr *slicevexatomvec( Expr, Left, Right ) + + vexexpr *Expr; + short Left; + short Right; +{ + short Width; + short PosLeft; + short PosRight; + short PosMin; + short PosMax; + char Separ; + +/*\ +fprintf( stdout, "slicevexatomvec %d %d\n", Left, Right ); +viewvexexprbound( Expr ); +fprintf( stdout, " --> " ); +\*/ + + if ( ( IsVexNodeAtom( Expr ) ) && + ( IsVexAtomVector( Expr ) ) ) + { + PosLeft = getvexvectorpos( Expr, Left ); + PosRight = getvexvectorpos( Expr, Right ); + + if ( ( PosLeft >= 0 ) && + ( PosRight >= 0 ) ) + { + if ( Left < Right ) + { + Width = 1 + Right - Left; + SetVexAtomUp( Expr ); + } + else + { + Width = 1 + Left - Right; + SetVexAtomDown( Expr ); + } + + if ( IsVexAtomLiteral( Expr ) ) + { + if ( Width == 1 ) Separ = '\''; + else Separ = '"'; + + if ( PosLeft > PosRight ) + { + PosMin = PosRight; + PosMax = PosLeft; + } + else + { + PosMin = PosLeft; + PosMax = PosRight; + } + + strcpy( VexBuffer, GetVexAtomValue( Expr ) ); + VexBuffer[ PosMin ] = Separ; + VexBuffer[ PosMax + 2 ] = Separ; + VexBuffer[ PosMax + 3 ] = '\0'; + + SetVexAtomValue( Expr, namealloc( &VexBuffer[ PosMin ] ) ); + } + + Expr->LEFT = Left; + Expr->RIGHT = Right; + Expr->WIDTH = Width; +/*\ +viewvexexprbound( Expr ); +fprintf( stdout, "\n" ); +\*/ + return( Expr ); + } + } + + return( (vexexpr *)0 ); +} diff --git a/alliance/src/vex/src/vexslice.h b/alliance/src/vex/src/vexslice.h new file mode 100644 index 00000000..ba50f7a8 --- /dev/null +++ b/alliance/src/vex/src/vexslice.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexslice.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_SLICE_H +# define VEX_SLICE_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexunflat.c b/alliance/src/vex/src/vexunflat.c new file mode 100644 index 00000000..e5fad9d5 --- /dev/null +++ b/alliance/src/vex/src/vexunflat.c @@ -0,0 +1,142 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexunflat.c | +| | +| Date : 03.12.99 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include "vexunflat.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Unflat Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Unflat Vex Expr | +| | +\------------------------------------------------------------*/ + +vexexpr *unflatvexexpr( Expr ) + + vexexpr *Expr; +{ + vexexpr *ScanExpr; + chain_list *ScanChain; + long Oper; + + if ( ( Expr == (vexexpr *)0 ) || + ( IsVexNodeAtom( Expr ) ) ) + { + return( Expr ); + } + + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( ( Oper == VEX_OR ) || + ( Oper == VEX_AND ) || + ( Oper == VEX_XOR ) || + ( Oper == VEX_NOR ) || + ( Oper == VEX_NAND ) || + ( Oper == VEX_NXOR ) || + ( Oper == VEX_ADD ) || + ( Oper == VEX_MUL ) ) + { + if ( Expr->OPERAND->NEXT->NEXT != (chain_list *)0 ) + { + if ( isvexnegativeoper( Oper ) ) + { + Oper = getvexnotoper( Oper ); + SetVexOperValue( Expr, Oper ); + + ScanExpr = createvexoper( VEX_NOT, Expr->WIDTH ); + addvexhexpr( ScanExpr, Expr ); + Expr = ScanExpr; + } + else + { + ScanExpr = createvexoper( Oper, Expr->WIDTH ); + ScanExpr->OPERAND = Expr->OPERAND->NEXT; + Expr->OPERAND->NEXT = addchain( (chain_list *)0, (void *)ScanExpr ); + } + } + } + } + + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanExpr = GetVexOperand( ScanChain ); + ScanExpr = unflatvexexpr( ScanExpr ); + SetVexOperand( ScanChain, ScanExpr ); + } + + return( Expr ); +} diff --git a/alliance/src/vex/src/vexunflat.h b/alliance/src/vex/src/vexunflat.h new file mode 100644 index 00000000..0f996715 --- /dev/null +++ b/alliance/src/vex/src/vexunflat.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexunflat.h | +| | +| Date : 03.12.99 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_UNFLAT_H +# define VEX_UNFLAT_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/vex/src/vexview.c b/alliance/src/vex/src/vexview.c new file mode 100644 index 00000000..936a1486 --- /dev/null +++ b/alliance/src/vex/src/vexview.c @@ -0,0 +1,586 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexview.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +| Modified: Frédéric Pétrot | +| Add support for Verilog expressions | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" + +# include +# include +# include "vexview.h" +# include "vexerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static FILE *VexViewFile = (FILE *)0; + static int VexViewLength = 0; + static void (*VexViewFunction)(); + + static char *VexStringBuffer = (char *)0; + static int VexStringSize = 0; + static int VexStringLength = 0; + static int VexViewBound = 0; + static int VexViewLanguage = VEX_VIEW_VHDL; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| View Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| View Local Vex File | +| | +\------------------------------------------------------------*/ + +static void loc_viewvexfile( String, Length ) + + char *String; + int Length; +{ + VexViewLength += Length; + + if ( VexViewLength >= VEX_VIEW_MAX_LENGTH ) + { + fprintf( VexViewFile, "\n" ); + VexViewLength = 0; + } + + if ( *String ) + { + fwrite( String, sizeof( char ), Length, VexViewFile ); + } +} + +/*------------------------------------------------------------\ +| | +| View Local Vex String | +| | +\------------------------------------------------------------*/ + +static void loc_viewvexstr( String, Length ) + + char *String; + int Length; +{ + char *Buffer; + + if ( ( VexStringLength + Length ) >= VexStringSize ) + { + VexStringSize = VexStringSize << 1; + Buffer = (char *)autallocblock( VexStringSize ); + strcpy( Buffer, VexStringBuffer ); + autfreeblock( VexStringBuffer ); + VexStringBuffer = Buffer; + } + + VexViewLength += Length; + + if ( VexViewLength >= VEX_VIEW_MAX_LENGTH ) + { + VexViewLength = 0; + loc_viewvexstr( "\n", 1 ); + } + + strcpy( VexStringBuffer + VexStringLength, String ); + VexStringLength += Length; +} + +/*------------------------------------------------------------\ +| | +| View Local Expr Vhdl All | +| | +\------------------------------------------------------------*/ + +static void loc_viewvexexprbound( Expr ) + + vexexpr *Expr; +{ + char Buffer[ 32 ]; + char Signed; + + if ( IsVexNodeSigned( Expr ) ) Signed = 's'; + else Signed = 'u'; + + if ( IsVexNodeVarWidth( Expr ) ) + { + sprintf( Buffer, "{?:?:?:%c}", Signed ); + } + else + { + sprintf( Buffer, "{%d:%d:%d:%c}", Expr->LEFT, Expr->RIGHT, Expr->WIDTH, Signed ); + } + + (*VexViewFunction)( Buffer, strlen( Buffer ) ); +} + +/*------------------------------------------------------------\ +| | +| View Local Expr Vhdl Atom | +| | +\------------------------------------------------------------*/ + +static void loc_viewvexatom( Expr ) + + vexexpr *Expr; +{ + char *String; + char Buffer[ 32 ]; + int Index; + + switch (VexViewLanguage) + { + case VEX_VIEW_VHDL: + String = GetVexAtomValue( Expr ); + (*VexViewFunction)( String, strlen( String ) ); + break; + + case VEX_VIEW_VERILOG: + String = GetVexAtomValue( Expr ); + if ( IsVexAtomLiteral ( Expr ) ) + { + sprintf( Buffer, "%d'b", Expr->WIDTH ); + (*VexViewFunction)( Buffer, strlen( Buffer ) ); + + for ( Index = 1; + Index < strlen ( String ) - 1; + Index++ ) + { + if ( String[ Index ] == '-' ) + { + (*VexViewFunction)( "?", 1 ); + } + else + { + (*VexViewFunction)( String + Index, 1 ); + } + } + } + else + { + (*VexViewFunction)( String, strlen( String ) ); + } + break; + } + + if ( VexViewBound ) + { + loc_viewvexexprbound( Expr ); + } + + if ( ( IsVexAtomVector( Expr ) ) && + ( ! IsVexAtomLiteral( Expr ) ) ) + { + if ( IsVexNodeVarWidth( Expr ) ) + { + switch (VexViewLanguage) + { + case VEX_VIEW_VHDL: + strcpy( Buffer, "(??)" ); + break; + + case VEX_VIEW_VERILOG: + strcpy( Buffer, "[??]" ); + break; + } + } + else + if ( Expr->LEFT == Expr->RIGHT ) + { + switch (VexViewLanguage) + { + case VEX_VIEW_VHDL: + sprintf( Buffer, "(%d)", Expr->LEFT ); + break; + + case VEX_VIEW_VERILOG: + sprintf( Buffer, "[%d]", Expr->LEFT ); + break; + } + } + else + { + switch (VexViewLanguage) + { + case VEX_VIEW_VHDL: + if ( Expr->LEFT < Expr->RIGHT ) + { + sprintf( Buffer, "(%d to %d)", Expr->LEFT, Expr->RIGHT ); + } + else + { + sprintf( Buffer, "(%d downto %d)", Expr->LEFT, Expr->RIGHT ); + } + break; + + case VEX_VIEW_VERILOG: + sprintf( Buffer, "[%d:%d]", Expr->LEFT, Expr->RIGHT ); + break; + } + } + + (*VexViewFunction)( Buffer, strlen( Buffer ) ); + } +} + +/*------------------------------------------------------------\ +| | +| View Local Expr Vhdl | +| | +\------------------------------------------------------------*/ + +static void loc_viewvex( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + long Oper; + char *String; + int Length; + + if ( IsVexNodeAtom( Expr ) ) + { + loc_viewvexatom( Expr ); + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + String = (char *)0; + + switch (VexViewLanguage) + { + case VEX_VIEW_VHDL: + String = getvexoperuppername( Oper ); + break; + + case VEX_VIEW_VERILOG: + String = getvexoperverilogname( Oper ); + break; + } + + if ( String == (char *)0 ) + { + vexerror( VEX_OPERATOR_ERROR, Oper ); + } + + Length = strlen( String ); + + if ( VexViewBound ) + { + loc_viewvexexprbound( Expr ); + } + + if ( isvexunaryoper( Oper ) ) + { + if ( ( Oper == VEX_EVENT ) || + ( Oper == VEX_DRIVER ) ) + { + (*VexViewFunction)( "(", 1 ); + + loc_viewvex( GetVexOperand( Expr->OPERAND ) ); + + (*VexViewFunction)( "'", 1 ); + (*VexViewFunction)( String, Length ); + } + else + { + (*VexViewFunction)( String, Length ); + (*VexViewFunction)( "(", 1 ); + + loc_viewvex( GetVexOperand( Expr->OPERAND ) ); + } + } + else + { + if ( ( VexViewBound ) || + ( isvexpositiveoper( Oper ) ) ) + { + if ( Oper == VEX_CONCAT && VexViewLanguage == VEX_VIEW_VERILOG ) + { + (*VexViewFunction)( "{", 1 ); + } + else + { + (*VexViewFunction)( "(", 1 ); + } + } + else + { + switch (VexViewLanguage) + { + case VEX_VIEW_VHDL: + (*VexViewFunction)( "NOT(", 4 ); + String = getvexoperuppername( getvexnotoper( Oper ) ); + break; + + case VEX_VIEW_VERILOG: + (*VexViewFunction)( "~(", 2 ); + String = getvexoperverilogname( getvexnotoper( Oper ) ); + break; + } + Length = strlen( String ); + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_viewvex( GetVexOperand( ScanOper ) ); + + if ( ScanOper->NEXT != (chain_list *)0 ) + { + (*VexViewFunction)( " ", 1 ); + (*VexViewFunction)( String, Length ); + (*VexViewFunction)( " ", 1 ); + } + } + } + + if ( Oper == VEX_CONCAT && VexViewLanguage == VEX_VIEW_VERILOG ) + { + (*VexViewFunction)( "}", 1 ); + } + else + { + (*VexViewFunction)( ")", 1 ); + } + } + else + { + String = GetVexFuncValue( Expr ); + Length = strlen( String ); + + if ( VexViewBound ) + { + if ( getvexstdfuncid( String ) != -1 ) + { + (*VexViewFunction)( "(std)", 5 ); + } + + loc_viewvexexprbound( Expr ); + } + + (*VexViewFunction)( String, Length ); + (*VexViewFunction)( "(", 1 ); + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_viewvex( GetVexOperand( ScanOper ) ); + + if ( ScanOper->NEXT != (chain_list *)0 ) + { + (*VexViewFunction)( ",", 1 ); + } + } + + (*VexViewFunction)( ")", 1 ); + } +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr File | +| | +\------------------------------------------------------------*/ + +void viewvexexprfile( VexFile, Expr ) + + FILE *VexFile; + vexexpr *Expr; +{ + VexViewFile = VexFile; + VexViewLength = 0; + VexViewFunction = loc_viewvexfile; + + if ( Expr != (vexexpr *)0 ) loc_viewvex( Expr ); +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr | +| | +\------------------------------------------------------------*/ + +void viewvexexpr( Expr ) + + vexexpr *Expr; +{ + viewvexexprfile( stdout, Expr ); +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr NewLine | +| | +\------------------------------------------------------------*/ + +void viewvexexprln( Expr ) + + vexexpr *Expr; +{ + viewvexexprfile( stdout, Expr ); + fprintf( stdout, "\n" ); +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr Bound | +| | +\------------------------------------------------------------*/ + +void viewvexexprbound( Expr ) + + vexexpr *Expr; +{ + VexViewBound = 1; + viewvexexprfile( stdout, Expr ); + VexViewBound = 0; +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr Bound NewLine | +| | +\------------------------------------------------------------*/ + +void viewvexexprboundln( Expr ) + + vexexpr *Expr; +{ + VexViewBound = 1; + viewvexexprfile( stdout, Expr ); + fprintf( stdout, "\n" ); + VexViewBound = 0; +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr String | +| | +\------------------------------------------------------------*/ + +char *viewvexexprstr( Expr ) + + vexexpr *Expr; +{ + if ( VexStringBuffer == (char *)0 ) + { + VexStringBuffer = (char *)autallocblock( VEX_STRING_BUFFER_SIZE ); + VexStringSize = VEX_STRING_BUFFER_SIZE; + } + + VexStringLength = 0; + VexStringBuffer[ 0 ] = '\0'; + + VexViewLength = 0; + VexViewFunction = loc_viewvexstr; + + if ( Expr != (vexexpr *)0 ) loc_viewvex( Expr ); + + return( VexStringBuffer ); +} + +/*------------------------------------------------------------\ +| | +| View Vex Expr String Bound | +| | +\------------------------------------------------------------*/ + +char *viewvexexprstrbound( Expr ) + + vexexpr *Expr; +{ + VexViewBound = 1; + viewvexexprstr( Expr ); + VexViewBound = 0; + + return( VexStringBuffer ); +} + +/*------------------------------------------------------------\ +| | +| Set View Mode | +| | +\------------------------------------------------------------*/ + +void setvexviewmode( Mode ) + + int Mode; +{ + VexViewLanguage = Mode; +} + +/*------------------------------------------------------------\ +| | +| Get View Mode | +| | +\------------------------------------------------------------*/ + +int getvexviewmode() +{ + return( VexViewLanguage ); +} diff --git a/alliance/src/vex/src/vexview.h b/alliance/src/vex/src/vexview.h new file mode 100644 index 00000000..9437bb4d --- /dev/null +++ b/alliance/src/vex/src/vexview.h @@ -0,0 +1,79 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Vex | +| | +| File : vexview.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ + +# ifndef VEX_VIEW_H +# define VEX_VIEW_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VEX_VIEW_MAX_LENGTH 80 +# define VEX_STRING_BUFFER_SIZE 512 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varivexes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif