diff --git a/alliance/src/vasy/Makefile.am b/alliance/src/vasy/Makefile.am new file mode 100644 index 00000000..56bc8bd2 --- /dev/null +++ b/alliance/src/vasy/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src man1 man5 diff --git a/alliance/src/vasy/configure.in b/alliance/src/vasy/configure.in new file mode 100644 index 00000000..8f46bc8f --- /dev/null +++ b/alliance/src/vasy/configure.in @@ -0,0 +1,36 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(src/vasy_main.c) + +VASY_MAJOR_VERSION=1 +VASY_MINOR_VERSION=5 +VASY_VERSION=$VASY_MAJOR_VERSION.$VASY_MINOR_VERSION + +AC_SUBST(VASY_MAJOR_VERSION) +AC_SUBST(VASY_MINOR_VERSION) +AC_SUBST(VASY_VERSION) + +# For automake. +VERSION=$VASY_VERSION +PACKAGE=vasy + +dnl Initialize automake stuff +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) + +dnl Checks for programs. +AC_PROG_CC +AM_PROG_LEX +AC_PROG_YACC +AC_PROG_RANLIB +AC_PROG_MAKE_SET + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +AM_ALLIANCE + +AC_OUTPUT([ +Makefile +man1/Makefile +man5/Makefile +src/Makefile +]) diff --git a/alliance/src/vasy/man1/Makefile.am b/alliance/src/vasy/man1/Makefile.am new file mode 100644 index 00000000..ea3ceccf --- /dev/null +++ b/alliance/src/vasy/man1/Makefile.am @@ -0,0 +1,2 @@ +man_MANS = vasy.1 +EXTRA_DIST = $(man_MANS) diff --git a/alliance/src/vasy/man1/vasy.1 b/alliance/src/vasy/man1/vasy.1 new file mode 100644 index 00000000..28ab6c46 --- /dev/null +++ b/alliance/src/vasy/man1/vasy.1 @@ -0,0 +1,114 @@ +.\" $Id: vasy.1,v 1.1 2002/03/26 15:17:15 ludo Exp $ +.\" @(#)Labo.l 2.2 95/09/24 UPMC; Author: Jacomme L. +.pl -.4 +.TH VASY 1 "November 26, 1999" "ASIM/LIP6" "CAO\-VLSI Reference Manual" +.SH NAME +.TP +VASY \- VHDL Analyzer for Synthesis +.so man1/alc_origin.1 +.SH SYNOPSIS +.TP +\f4vasy [\-VpavsoipSHL] [\-C num] [\-E num] [\-I format] [\-P file] filename [outname] +.br +.SH DESCRIPTION +.br +\fBVASY\fp is a hierarchical VHDL Analyzer for Synthesis. +\fBVASY\fp performs a semantic analysis of a VHDL RTL description +\fBfilename\fP, with a VHDL subset much more extended than the Alliance one +(see vasy(5) for more details), and identifies with precision all the +memorizing elements and tristate buffers. +.br +During its analysis, \fBVASY\fp expands generic parameters, executes generic map +and generate statements, and also unrolls static FOR loops. +.br +At the end, \fBVASY\fp drives an equivalent description +\fBoutname\fP (in Verilog or VHDL format) accepted by most of +synthesis tools. +.br + +.SH ENVIRONMENT VARIABLES +.br +.TP 10 +\f4MBK_WORK_LIB\fR(1) +indicates the path to the read/write directory for the session. +.br + +.SH OPTIONS +.TP 10 +\f4\-V\fP +Verbose mode on. +Each step of the analysis is displayed on the standard output. +.TP 10 +\f4\-v\fP +Drives an equivalent description in \fBVerilog\fP format. +.TP 10 +\f4\-a\fP +Drives an equivalent description in Alliance VHDL format \fBvbe\fP(5) and/or +\fBvst\fP(5). +We can note that with this option, all arithmetic operators are expanded in an +equivalent set of boolean expressions, because these operators don't belong to +the Alliance VHDL subset. +.TP 10 +\f4\-s\fP +Drives an equivalent VHDL description (with the extention \fB.vhd\fP) +accepted by most of industrial synthesis tools. +.TP 10 +\f4\-S\fP +Uses Std_logic instead of Bit (taken into account only with option -s). +.TP 10 +\f4\-i\fP +Drives initial signal values (taken into account only with option -s). +.TP 10 +\f4\-I format\fP +Specifies the VHDL input format such as Alliance VHDL format \fBvbe\fP(5), +\fBvst\fP(5) or industrial VHDL format \fBvhd\fP or \fBvhdl\fP. +.TP 10 +\f4\-H\fP +In a structural description, all model of instances are recursively analyzed. +(By default \fBVASY\fp analyzes only models with generic parameters) +The leaves cells are defined by a file called CATAL (see catal(5) for details). +.TP 10 +\f4\-o\fP +Authorizes to overwrite existing files. +.TP 10 +\f4\-p\fP +Adds power supply connectors (vdd and vss). Usefull option to enter in Alliance. +.TP 10 +\f4\-C num\fP +When the size of the adder is greater or equal to \fBnum\fP a Carry Look Ahead +adder is generated, instead of a Ripple Carry adder. +(taken into account only with option -a). +.TP 10 +\f4\-E num\fP +Comparators are expanded in an equivalent set of boolean expressions, when their +size is greater than \fBnum\fP +(taken into account only with option -a). +.TP 10 +\f4\-L\fP +A file .lax (see lax(5) for details) is generated. This file contains the list of +all signals that must be kept during the synthesis step, using \fBbop\fP (see +bop(1) for details). (taken into account only with option -a). +.TP 10 +\f4\-P file\fP +Specifies a file containing a list of logical and physical package name: +.nf +# Example +work.constants.all : pkg_constants +work.components.all : pkg_components +.fi +.ti 7 + +.SH SEE ALSO +.BR vasy (5), +.BR vbe (5), +.BR vhdl (5), +.BR catal (5). +.BR lax (5). +.BR asimut (1), +.BR bop (1), +.BR MBK_WORK_LIB (1). +.BR MBK_CATA_LIB (1). +.BR MBK_CATAL_NAME (1). + +.so man1/alc_bug_report.1 + diff --git a/alliance/src/vasy/man5/Makefile.am b/alliance/src/vasy/man5/Makefile.am new file mode 100644 index 00000000..98f78cf3 --- /dev/null +++ b/alliance/src/vasy/man5/Makefile.am @@ -0,0 +1,2 @@ +man_MANS = vasy.5 +EXTRA_DIST = $(man_MANS) diff --git a/alliance/src/vasy/man5/vasy.5 b/alliance/src/vasy/man5/vasy.5 new file mode 100644 index 00000000..69479a98 --- /dev/null +++ b/alliance/src/vasy/man5/vasy.5 @@ -0,0 +1,261 @@ +.\" $Id: vasy.5,v 1.1 2002/03/26 15:17:16 ludo Exp $ +.\" @(#)VASY.5 1.0 Jan 28 1992 UPMC ; Ludovic Jacomme +.TH VASY 5 "December 11, 1999" "ASIM/LIP6" "VHDL subset of VASY." + +.SH NAME +.PP +\fBvasy\fP VHDL RTL subset. + +.so man1/alc_origin.1 +.SH DESCRIPTION +.PP +This document describes the VHDL subset accepted by VASY for RTL descriptions. + +.PP +\fBCONCURRENT STATEMENTS\fP +.br +In an RTL architecture most of the concurrent statements are supported. + +.PP +Allowed concurrent statements are: +.RS +block +.br +concurrent assertion +.br +process +.br +concurrent signal assignment +.br +component instantiation statement +.RE +generate statement +.RE + +.PP +\fBSEQUENTIAL STATEMENTS\fP +.br +Inside a process, all sequential statements including loops, signal assignment, +variable assignment are supported. + +.PP +\fBTYPE\fP +.br +All types usefull for synthesis are accepted (IEEE-1164 and IEEE-1076.3), and +all types defined in the VHDL Alliance subset (see vbe(5) for more details). + +.PP +\fBOPERATORS\fP +.br +All operators usefull for synthesis are accepted, such as arithmetic, logical and relationnal operators (IEEE-1164 and IEEE-1076.3), and those defined in the VHDL Alliance subset +(see vbe(5) for more details). + +.PP +\fBHARDWARE DESCRIPTION EXAMPLES\fP +.br +.PP +A MULTIPLEXER may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +entity mux is +port( + sel,a,b : in std_logic; + mux_out : out std_logic ); +end mux; + +architecture rtl_1 of mux is +begin + process( sel,a,b ) + begin + if (sel='1') then mux_out <= a; + else mux_out <= b; + end if; + end process; +end rtl_1; + +architecture rtl_2 of mux is +begin + mux_out <= a when sel='1' else b; +end rtl_2; +.fi + +.PP +A LATCH may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +entity latch is +port( + en,a : in std_logic; + latch_out : out std_logic ); +end latch; + +architecture rtl_1 of latch is +begin + process( en, a ) + begin + if (en='1') then latch_out <= a; + end if; + end process; +end rtl_1; +.fi + +.PP +A D-FLIP-FLOP may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +entity d_ff is +port( + ck,a : in std_logic; + d_ff_out : out std_logic ); +end d_ff; + +architecture rtl_1 of d_ff is +begin + process( ck ) + begin + if (ck='1') then d_ff_out <= a; + end if; + end process; +end rtl_1; + +architecture rtl_2 of d_ff is +begin + process( ck ) + begin + if (ck='1' and ck'event) + then d_ff_out <= a; + end if; + end process; +end rtl_2; + +architecture rtl_3 of d_ff is +begin + process + begin + wait until ck='1'; + d_ff_out <= a; + end process; +end rtl_3; +.fi + +.PP +A TRISTATE BUFFER may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +entity trs is +port( + en,a : in std_logic; + trs_out : out std_logic ); +end trs; + +architecture rtl_1 of trs is +begin + process( en,a ) + begin + if (en='1') then trs_out <= a; + else trs_out <= 'Z'; + end if; + end process; +end rtl_1; + +architecture rtl_2 of d_ff is +begin + trs_out <= a when en='1' else 'Z'; +end rtl_2; +.fi + +.PP +A RAM may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.numeric_std.all; + +entity ram is +port( clk,wr : in std_logic; + adr : std_logic_vector(1 downto 0); + i0 : in std_logic_vector(3 downto 0); + o0 : out std_logic_vector(3 downto 0) + ); +end ram; + +architecture rtl_1 of ram is + type my_array is array (0 to 3) of std_logic_vector(3 downto 0); + signal s : my_array; +begin + process + begin + wait until (clk='0' and clk'event); + if (wr='1') + then s(to_integer(unsigned(adr))) <= I0; + end if; + end process; + o0 <= s(to_integer(unsigned(adr))); +end rtl_1; +.fi + +.PP +A ROM may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.numeric_std.all; + +entity rom is +port( adr : in std_logic_vector(1 downto 0); + o0 : out std_logic_vector(3 downto 0) + ); +end rom; + +architecture rtl_1 of rom is + subtype my_word is std_logic_vector(3 downto 0); + type my_array is array (0 to 3) of my_word; + constant s : my_array := ( "0000", "0001", "0010", "0011" ); +begin + o0 <= s(to_integer(unsigned(adr))); +end rtl_1; +.fi + +.PP +A PRIORITY DECODER may be described as follow: +.nf + +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.numeric_std.all; + +entity decod is +port( A : in std_logic_vector(3 downto 0); + B : out std_logic_vector(2 downto 0)); +end decod; +architecture rtl_1 of decod is +begin + process( a ) + begin + b <= "111"; + for i in a'range -- Static For Loop are unrolled ! + loop + exit when a(i)='1'; + b <= std_logic_vector(to_unsigned(i,3)); + end loop; + end process; +end rtl_1; +.fi + +.SH SEE ALSO +.PP +vasy(1), vbe(5), vhdl(5), vst(5), bop(1), glop(1), scmap(1), c4map(1), asimut(1), proof(1), yagle(1) + + +.so man1/alc_bug_report.1 + diff --git a/alliance/src/vasy/src/Makefile.am b/alliance/src/vasy/src/Makefile.am new file mode 100644 index 00000000..9e9a8106 --- /dev/null +++ b/alliance/src/vasy/src/Makefile.am @@ -0,0 +1,24 @@ +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = vasy + +vasy_LDADD = @LIBS@ \ + -lRtd -lRtn -lVtl -lVvh -lVpd -lVpn -lVbl -lVbh \ + -lVex -lBdd -lAbl -lAut -lMut \ + +vasy_SOURCES = \ +vasy_analys.c vasy_drvvlog.h vasy_mulwait.c vasy_redwait.h \ +vasy_analys.h vasy_elabo.c vasy_mulwait.h vasy_shared.c \ +vasy_array.c vasy_elabo.h vasy_onewait.c vasy_shared.h \ +vasy_array.h vasy_error.c vasy_onewait.h vasy_simprtl.c \ +vasy_debug.c vasy_error.h vasy_parse.c vasy_simprtl.h \ +vasy_debug.h vasy_func.c vasy_parse.h vasy_simul.c \ +vasy_drvalc.c vasy_func.h vasy_preanal.c vasy_simul.h \ +vasy_drvalc.h vasy_generate.c vasy_preanal.h vasy_support.c \ +vasy_drvrtl.c vasy_generate.h vasy_redact.c vasy_support.h \ +vasy_drvrtl.h vasy_generic.c vasy_redact.h vasy_synth.c \ +vasy_drvsyn.c vasy_generic.h vasy_redinst.c vasy_synth.h \ +vasy_drvsyn.h vasy_loop.c vasy_redinst.h vasy_vexbdd.c \ +vasy_drvvex.c vasy_loop.h vasy_reduce.c vasy_vexbdd.h \ +vasy_drvvex.h vasy_main.c vasy_reduce.h \ +vasy_drvvlog.c vasy_main.h vasy_redwait.c diff --git a/alliance/src/vasy/src/vasy_analys.c b/alliance/src/vasy/src/vasy_analys.c new file mode 100644 index 00000000..ef845284 --- /dev/null +++ b/alliance/src/vasy/src/vasy_analys.c @@ -0,0 +1,256 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_analys.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_shared.h" +# include "vasy_onewait.h" +# include "vasy_mulwait.h" +# include "vasy_synth.h" +# include "vasy_analys.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyAnalysisVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyAnalysisVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpnact_list *VpnAction; + vasyprocinfo *ProcInfo; + vexexpr *VexAtom; + long NumberWait; + long NumberAction; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyAnalysisVpnProc %s\n", VpnProc->NAME ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + NumberWait = 0; + NumberAction = 0; + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) NumberWait++; + else + if ( ( VpnTrans->TYPE == VPN_TRANS_ACT_EXEC ) || + ( VpnTrans->TYPE == VPN_TRANS_ACT_GUARDED ) ) NumberAction++; + + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + if ( ( VpnAction->TYPE == VPN_ACT_CALL ) || + ( VpnAction->TYPE == VPN_ACT_RETURN ) ) + { + VasyErrorLine( VASY_NOT_YET_IMPLEMENTED_ERROR, VpnAction->LINE, "Call/Return" ); + } + + VexAtom = VpnAction->VEX_ATOM; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + VasyErrorLine( VASY_NOT_YET_IMPLEMENTED_ERROR, VpnAction->LINE, "Indirect assignment" ); + } + } + } + + ProcInfo->NUMBER_WAIT = NumberWait; + ProcInfo->NUMBER_ACTION = NumberAction; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Proc %s NumWait : %ld\n", VpnProc->NAME, NumberWait ); + VasyPrintf( stdout, " +++ Proc %s NumAction : %ld\n", VpnProc->NAME, NumberAction ); + } +/* +** No action in process, nothing more to do ! +*/ + if ( ProcInfo->NUMBER_ACTION == 0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ No action in process nothing to do\n" ); + } + + ProcInfo->TYPE = VASY_PROC_UNUSED; + + return; + } + + if ( ProcInfo->NUMBER_WAIT != 1 ) + { + VasyMultiWaitVpnProc( VpnFigure, RtlFigure, VpnProc ); + } + else + { + VasyOneWaitVpnProc( VpnFigure, RtlFigure, VpnProc ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyAnalysisVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyAnalysisVpnFig | +| | +\------------------------------------------------------------*/ + +rtlfig_list *VasyAnalysisVpnFig( VpnFigure ) + + vpnfig_list *VpnFigure; +{ + rtlfig_list *RtlFigure; + rtlasg_list *RtlAssign; + vpnproc_list *VpnProc; + long NumberReg; + long NumberTrs; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyAnalysisVpnFig %s\n", VpnFigure->NAME ); + } + + RtlFigure = addrtlfig( VpnFigure->NAME ); + + VasySynthesisVpnDecl( VpnFigure, RtlFigure ); + VasySynthesisVpnModel( VpnFigure, RtlFigure ); + VasySynthesisVpnInstance( VpnFigure, RtlFigure ); + + if ( IsVasyDebugStatistics() ) + { + VasyDebugStartChrono(1); + } + + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + if ( IsVasyVpnProcToAnalyse( VpnProc ) ) + { + VasyAnalysisVpnProc( VpnFigure, RtlFigure, VpnProc ); + } + else + { + VasySynthesisCombinatorialVpnProc( VpnFigure, RtlFigure, VpnProc ); + } + } + + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Semantic Analysis : %ld sec\n", + VasyDebugReadChrono(1) ); + + NumberReg = 0; + NumberTrs = 0; + + for ( RtlAssign = RtlFigure->ASSIGN; + RtlAssign != (rtlasg_list *)0; + RtlAssign = RtlAssign->NEXT ) + { + if ( RtlAssign->TYPE == RTL_ASG_REGISTER ) NumberReg++; + else + if ( ( RtlAssign->TYPE == RTL_ASG_TRISTATE ) || + ( RtlAssign->TYPE == RTL_ASG_PULL_UP ) || + ( RtlAssign->TYPE == RTL_ASG_PULL_DOWN ) ) NumberTrs++; + } + + VasyPrintf( stdout, "--> Number Register : %ld\n", NumberReg ); + VasyPrintf( stdout, "--> Number Tristate : %ld\n", NumberTrs ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyAnalysisVpnFig %s\n\n", VpnFigure->NAME ); + } + + return( RtlFigure ); +} diff --git a/alliance/src/vasy/src/vasy_analys.h b/alliance/src/vasy/src/vasy_analys.h new file mode 100644 index 00000000..fd49804c --- /dev/null +++ b/alliance/src/vasy/src/vasy_analys.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_analys.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_ANALYS_H +# define VASY_ANALYS_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern rtlfig_list *VasyAnalysisVpnFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_array.c b/alliance/src/vasy/src/vasy_array.c new file mode 100644 index 00000000..294743eb --- /dev/null +++ b/alliance/src/vasy/src/vasy_array.c @@ -0,0 +1,1420 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_array.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vbh.h" + +# include "vasy_array.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashNameArray = (authtable *)0; + static authtable *VasyHashNameVector = (authtable *)0; + static authtable *VasyHashDeclar = (authtable *)0; + static ptype_list **VasyPrevInst = (ptype_list **)0; + static vbpcs_list *VasyProcess = (vbpcs_list *)0; + static long VasyNumberVar = 0; + static vbtyp_list *VasyTypeNatural = (vbtyp_list *)0; + + static char VasyBuffer[ 512 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyArrayGetIndexName | +| | +\------------------------------------------------------------*/ + +static char *VasyArrayGetIndexName( Name, Index ) + + char *Name; + int Index; +{ + sprintf( VasyBuffer, "%s_idx_%d", Name, Index ); + return( namealloc( VasyBuffer ) ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanSens | +| | +\------------------------------------------------------------*/ + +static chain_list *VasyArrayScanSens( SensList ) + + chain_list *SensList; +{ + vbtyp_list *VbhType; + vbtyp_list *VbhBase; + authelem *Element; + vexexpr *VexAtom; + chain_list *ScanList; + chain_list **PrevList; + chain_list *DelList; + char *Name; + char *IndexName; + char *NewName; + long Index; + int Step; + int Bit; + int ArrayMin; + int ArrayStep; + int ArrayMax; + + + for ( ScanList = SensList; + ScanList != (chain_list *)0; + ScanList = ScanList->NEXT ) + { + Name = getvexvectorname( ScanList->DATA, &Index ); + + if ( Name == (char *)0 ) continue; + + Element = searchauthelem( VasyHashNameArray, Name ); + + if ( Element != (authelem *)0 ) + { + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + + if ( Index == -1 ) + { + ArrayMin = VbhType->LEFT; + ArrayMax = VbhType->RIGHT; + + if ( ArrayMin < ArrayMax ) ArrayStep = 1; + else ArrayStep = -1; + } + else + { + ArrayMin = Index; + ArrayMax = Index; + ArrayStep = 1; + } + + for ( Index = ArrayMin; Index != (ArrayMax + ArrayStep); Index += ArrayStep ) + { + IndexName = VasyArrayGetIndexName( Name, Index ); + + if ( VbhBase->LEFT > VbhBase->RIGHT ) Step = -1; + else Step = 1; + + for ( Bit = VbhBase->LEFT; Bit != (VbhBase->RIGHT + Step); Bit += Step ) + { + sprintf( VasyBuffer, "%s(%d)", IndexName, Bit ); + NewName = namealloc( VasyBuffer ); + SensList = addchain( SensList, (void *)NewName ); + } + } + + ScanList->DATA = (void *)0; + } + else + if ( Index == -1 ) + { + Element = searchauthelem( VasyHashDeclar, Name ); + + if ( Element != (authelem *)0 ) + { + VexAtom = (vexexpr *)Element->VALUE; + + ArrayMin = VexAtom->LEFT; + ArrayMax = VexAtom->RIGHT; + + if ( ArrayMin < ArrayMax ) ArrayStep = 1; + else ArrayStep = -1; + + for ( Index = ArrayMin; Index != (ArrayMax + ArrayStep); Index += ArrayStep ) + { + sprintf( VasyBuffer, "%s(%ld)", Name, Index ); + NewName = namealloc( VasyBuffer ); + SensList = addchain( SensList, (void *)NewName ); + } + + ScanList->DATA = (void *)0; + } + else + { + ScanList->DATA = (void *)Name; + } + } + } + + ScanList = SensList; + PrevList = &SensList; + + while ( ScanList != (chain_list *)0 ) + { + if ( ScanList->DATA == (void *)0 ) + { + DelList = ScanList; + ScanList = ScanList->NEXT; + *PrevList = ScanList; + + DelList->NEXT = (chain_list *)0; + freechain( DelList ); + } + else + { + PrevList = &ScanList->NEXT; + ScanList = ScanList->NEXT; + } + } + + return( SensList ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayAddVariable | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyArrayAddVariable( BaseType, Width ) + + vbtyp_list *BaseType; + int Width; +{ + vexexpr *VexAtom; + char *Name; + + sprintf( VasyBuffer, "array_var_%ld", VasyNumberVar++ ); + Name = namealloc( VasyBuffer ); + + if ( Width == 0 ) + { + VexAtom = createvexatomvec( Name, BaseType->LEFT, BaseType->RIGHT ); + } + else + if ( Width > 0 ) + { + VexAtom = createvexatomvec( Name, Width - 1, 0 ); + } + else + { + VexAtom = createvexatombit( Name ); + } + + VasyProcess->VARIABLE = + vbh_addvbvar( VasyProcess->VARIABLE, VexAtom, (vexexpr *)0, BaseType, VasyProcess->LINE ); + + SetVbhProcSequential( VasyProcess ); + + return( dupvexexpr( VexAtom ) ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanVexAtom | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyArrayScanVexAtom( VexExpr ) + + vexexpr *VexExpr; +{ + char *AtomValue; + authelem *Element; + vbtyp_list *VbhType; + vbtyp_list *VbhBase; + vexexpr *Operand; + + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashNameArray, AtomValue ); + + if ( Element != (authelem *)0 ) + { + if ( VexExpr->WIDTH != 1 ) + { + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "array in expression" ); + } + + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + AtomValue = VasyArrayGetIndexName( AtomValue, VexExpr->LEFT ); + + Operand = createvexatomvec( AtomValue, VbhBase->LEFT, VbhBase->RIGHT ); + freevexexpr( VexExpr ); + + VexExpr = Operand; + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanVexIndex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyArrayScanVexIndex( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *VexAtom; + vexexpr *VexDeclar; + vexexpr *Operand; + vexexpr *VexVar; + vexexpr *VexData; + vexexpr *VexCond; + vexexpr *VexValue; + authelem *Element; + char *AtomValue; + char *ChoiceValue; + vbtyp_list *VbhType; + vbtyp_list *VbhBase; + vbcho_list *VbhChoice; + vbcas_list *VbhCase; + ptype_list *ScanPType; + int ArraySize; + int Vector; + int Step; + int SizeValue; + int IntValue; + int Index; + + VexAtom = GetVexOperand( VexExpr->OPERAND ); + Operand = GetVexOperand( VexExpr->OPERAND->NEXT ); + + AtomValue = GetVexAtomValue( VexAtom ); + Element = searchauthelem( VasyHashNameArray, AtomValue ); + + if ( Element == (authelem *)0 ) + { + Element = searchauthelem( VasyHashNameVector, AtomValue ); + + if ( Element == (authelem *)0 ) + { + viewvexexprboundln( VexExpr ); + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "slice operator" ); + } + + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + + Element = searchauthelem( VasyHashDeclar, AtomValue ); + + if ( Element == (authelem *)0 ) + { + viewvexexprboundln( VexExpr ); + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "slice operator" ); + } + + VexDeclar = (vexexpr *)Element->VALUE; + ArraySize = VexDeclar->WIDTH; + + if ( IsVexNodeDown( VexDeclar ) ) Step = -1; + else Step = 1; + + SizeValue = getvexintervalnumbit( VexDeclar->LEFT, VexDeclar->RIGHT ); + Vector = -1; + } + else + { + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + + if ( VbhType->LEFT > VbhType->RIGHT ) + { + ArraySize = VbhType->LEFT - VbhType->RIGHT + 1; + Step = -1; + } + else + { + ArraySize = VbhType->RIGHT - VbhType->LEFT + 1; + Step = 1; + } + + SizeValue = getvexintervalnumbit( VbhType->LEFT, VbhType->RIGHT ); + Vector = 0; + } + + VexVar = VasyArrayAddVariable( VbhBase, Vector ); + + if ( ! IsVexNodeAtom( Operand ) ) + { + VexCond = VasyArrayAddVariable( VasyTypeNatural, SizeValue ); + } + else + { + VexCond = Operand; + } + + ScanPType = vbh_addvbcas( *VasyPrevInst, dupvexexpr( VexCond ), + VasyTypeNatural, VasyProcess->LINE ); + *VasyPrevInst = ScanPType; + VbhCase = (vbcas_list *)ScanPType->DATA; + + if ( ! IsVexNodeAtom( Operand ) ) + { + ScanPType = vbh_addvbvar( *VasyPrevInst, VexCond, dupvexexpr( Operand ), + VasyTypeNatural, VasyProcess->LINE ); + *VasyPrevInst = ScanPType; + } + + VbhChoice = (vbcho_list *)autallocblock( sizeof( vbcho_list ) * ArraySize ); + VbhCase->SIZE = ArraySize; + VbhCase->CHOICE = VbhChoice; + + IntValue = VbhType->LEFT; + + for ( Index = 0; Index < ArraySize; Index++ ) + { + VexValue = createvexatomlong( IntValue, SizeValue, 0 ); + ChoiceValue = GetVexAtomValue( VexValue ); + freevexexpr( VexValue ); + + if ( Vector != -1 ) + { + VexData = createvexatomvec( + VasyArrayGetIndexName( AtomValue, Index ), VbhBase->LEFT, VbhBase->RIGHT ); + } + else + { + VexData = createvexatomvec( AtomValue, Index, Index ); + } + + ScanPType = vbh_addvbvar( (ptype_list *)0, + dupvexexpr( VexVar ), VexData, VbhBase, VasyProcess->LINE ); + + VbhChoice[ Index ].INSTRUCTION = ScanPType; + VbhChoice[ Index ].SIZE = SizeValue; + VbhChoice[ Index ].VALUES = addchain( NULL, (void *)ChoiceValue ); + + IntValue += Step; + } + + freevexexpr( VexExpr ); + + return( VexVar ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyArrayScanVex( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand; + chain_list *ScanChain; + long Oper; + + if ( IsVexNodeAtom( VexExpr ) ) + { + return( VasyArrayScanVexAtom( VexExpr ) ); + } + + if ( IsVexNodeOper( VexExpr ) ) + { + Oper = GetVexOperValue( VexExpr ); + + if ( Oper == VEX_INDEX ) + { + VexExpr = VasyArrayScanVexIndex( VexExpr ); + } + else + if ( ( Oper == VEX_TO ) || + ( Oper == VEX_DOWNTO ) ) + { + viewvexexprln( VexExpr ); + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "array slice in expression" ); + } + } + + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Operand = VasyArrayScanVex( Operand ); + SetVexOperand( ScanChain, Operand ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanVexCond | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyArrayScanVexCond( PrevInst, VexExpr ) + + ptype_list **PrevInst; + vexexpr *VexExpr; +{ + if ( VexExpr != (vexexpr *)0 ) + { + VasyPrevInst = PrevInst; + VexExpr = VasyArrayScanVex( VexExpr ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanAsg | +| | +\------------------------------------------------------------*/ + +static void VasyArrayScanAsg( PrevInst, CurInst, Variable ) + + ptype_list **PrevInst; + ptype_list *CurInst; + int Variable; +{ + vbasg_list *ScanAsg; + vbvar_list *ScanVar; + vbvar_list *NewVar; + vbifs_list *ScanIfs; + vexexpr *VexTarget; + vexexpr *VexDeclar; + vexexpr *VexAtom; + vexexpr *VexVar; + vexexpr *VexExpr; + vexexpr *VexValue; + vexexpr *VexData; + vexexpr *VexCond; + vexexpr *Operand; + vbtyp_list *VbhType; + vbtyp_list *VbhBase; + ptype_list *ScanPType; + char *AtomValue; + char *DataValue; + char *Name; + authelem *Element; + long Oper; + int Vector; + int ArraySize; + int Step; + int SizeValue; + int IntValue; + int Index; + int Pos; + int PosMin; + int PosMax; + int PosStep; + long Line; + + + VasyPrevInst = PrevInst; + + if ( Variable ) + { + ScanVar = (vbvar_list *)CurInst->DATA; + ScanAsg = (vbasg_list *)0; + Line = ScanVar->LINE; + VexTarget = ScanVar->TARGET; + } + else + { + ScanAsg = (vbasg_list *)CurInst->DATA; + ScanVar = (vbvar_list *)0; + Line = ScanAsg->LINE; + VexTarget = ScanAsg->TARGET; + } + + if ( IsVexNodeAtom( VexTarget ) ) + { + AtomValue = GetVexAtomValue( VexTarget ); + Element = searchauthelem( VasyHashNameArray, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + + if ( VexTarget->WIDTH != 1 ) + { + if ( Variable ) VexExpr = ScanVar->VEX; + else VexExpr = ScanAsg->VEX; + + if ( ( ! IsVexNodeAtom( VexExpr ) ) || + ( IsVexAtomLiteral( VexExpr ) ) ) + { + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "slice assignation" ); + } + + DataValue = GetVexAtomValue( VexExpr ); + + PosMin = VexTarget->WIDTH - 1; + PosMax = -1; + PosStep = -1; + + /* Check order for a same array variable assignation */ + + if ( ( Variable ) && + ( DataValue == AtomValue ) ) + { + if ( ( ( IsVexAtomDown( VexTarget ) ) && + ( VexTarget->LEFT < VexExpr->LEFT ) ) || + ( ( IsVexAtomUp( VexTarget ) ) && + ( VexTarget->LEFT > VexExpr->LEFT ) ) ) + { + PosMin = 0; + PosMax = VexTarget->WIDTH; + PosStep = 1; + } + } + + for ( Pos = PosMin; Pos != PosMax; Pos += PosStep ) + { + Index = getvexvectorindex( VexTarget, Pos ); + Name = VasyArrayGetIndexName( AtomValue, Index ); + VexVar = createvexatomvec( Name, VbhBase->LEFT, VbhBase->RIGHT ); + Index = getvexvectorindex( VexExpr, Pos ); + Name = VasyArrayGetIndexName( DataValue, Index ); + VexData = createvexatomvec( Name, VbhBase->LEFT, VbhBase->RIGHT ); + + if ( Variable ) + { + ScanPType = vbh_addvbvar( (ptype_list *)0, VexVar, VexData, VbhBase, Line ); + } + else + { + ScanPType = vbh_addvbasg( (ptype_list *)0, VexVar, VexData, VbhBase, Line ); + } + + if ( CurInst != (ptype_list *)0 ) + { + CurInst->TYPE = ScanPType->TYPE; + CurInst->DATA = ScanPType->DATA; + + ScanPType->NEXT = (ptype_list *)0; + freeptype( ScanPType ); + + CurInst = (ptype_list *)0; + } + else + { + ScanPType->NEXT = *PrevInst; + *PrevInst = ScanPType; + } + } + } + else + { + AtomValue = VasyArrayGetIndexName( AtomValue, VexTarget->LEFT ); + + Operand = createvexatomvec( AtomValue, VbhBase->LEFT, VbhBase->RIGHT ); + freevexexpr( VexTarget ); + VexTarget = Operand; + + if ( Variable ) + { + ScanVar->TARGET = VexTarget; + ScanVar->VEX = VasyArrayScanVex( ScanVar->VEX ); + } + else + { + ScanAsg->TARGET = VexTarget; + ScanAsg->VEX = VasyArrayScanVex( ScanAsg->VEX ); + } + } + } + else + { + if ( Variable ) ScanVar->VEX = VasyArrayScanVex( ScanVar->VEX ); + else ScanAsg->VEX = VasyArrayScanVex( ScanAsg->VEX ); + } + } + else + if ( IsVexNodeOper( VexTarget ) ) + { + Oper = GetVexOperValue( VexTarget ); + + if ( Oper == VEX_INDEX ) + { + if ( Variable ) + { + ScanVar->VEX = VasyArrayScanVex( ScanVar->VEX ); + VexExpr = ScanVar->VEX; + } + else + { + ScanAsg->VEX = VasyArrayScanVex( ScanAsg->VEX ); + VexExpr = ScanAsg->VEX; + } + + VexAtom = GetVexOperand( VexTarget->OPERAND ); + Operand = GetVexOperand( VexTarget->OPERAND->NEXT ); + + AtomValue = GetVexAtomValue( VexAtom ); + Element = searchauthelem( VasyHashNameArray, AtomValue ); + + if ( Element == (authelem *)0 ) + { + Element = searchauthelem( VasyHashNameVector, AtomValue ); + + if ( Element == (authelem *)0 ) + { + viewvexexprboundln( VexTarget ); + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "slice operator" ); + } + + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + + Element = searchauthelem( VasyHashDeclar, AtomValue ); + + if ( Element == (authelem *)0 ) + { + viewvexexprboundln( VexTarget ); + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "slice operator" ); + } + + VexDeclar = (vexexpr *)Element->VALUE; + + ArraySize = VexDeclar->WIDTH; + + if ( IsVexNodeDown( VexDeclar ) ) Step = -1; + else Step = 1; + + SizeValue = getvexintervalnumbit( VexDeclar->LEFT, VexDeclar->RIGHT ); + Vector = -1; + } + else + { + VbhType = (vbtyp_list *)Element->VALUE; + VbhBase = VbhType->BASE; + + if ( VbhType->LEFT > VbhType->RIGHT ) + { + ArraySize = VbhType->LEFT - VbhType->RIGHT + 1; + Step = -1; + } + else + { + ArraySize = VbhType->RIGHT - VbhType->LEFT + 1; + Step = 1; + } + + SizeValue = getvexintervalnumbit( VbhType->LEFT, VbhType->RIGHT ); + Vector = 0; + } + + VexVar = VasyArrayAddVariable( VbhBase, Vector ); + ScanPType = vbh_addvbvar( (ptype_list *)0, VexVar, + dupvexexpr( VexExpr ), VbhBase, Line ); + + CurInst->TYPE = ScanPType->TYPE; + CurInst->DATA = ScanPType->DATA; + + ScanPType->NEXT = (ptype_list *)0; + freeptype( ScanPType ); + + NewVar = (vbvar_list *)CurInst->DATA; + NewVar->VEX = VasyArrayScanVex( NewVar->VEX ); + + ScanPType = CurInst->NEXT; + + if ( ! IsVexNodeAtom( Operand ) ) + { + VexCond = VasyArrayAddVariable( VasyTypeNatural, SizeValue ); + ScanPType = vbh_addvbvar( ScanPType, VexCond, + dupvexexpr( Operand ), VasyTypeNatural, Line ); + } + + if ( Vector == -1 ) VbhBase = VbhType; + + IntValue = VbhType->LEFT; + + for ( Index = 0; Index < ArraySize; Index++ ) + { + VexValue = createvexatomlong( IntValue, SizeValue, 0 ); + VexCond = createvexbinexpr( VEX_EQ, 1, dupvexexpr( Operand ), VexValue ); + + if ( Vector != -1 ) + { + VexData = createvexatomvec( + VasyArrayGetIndexName( AtomValue, Index ), VbhBase->LEFT, VbhBase->RIGHT ); + } + else + { + VexData = createvexatomvec( AtomValue, Index, Index ); + } + + ScanPType = vbh_addvbifs( ScanPType, VexCond, Line ); + ScanIfs = (vbifs_list *)ScanPType->DATA; + + if ( Variable ) + { + ScanIfs->CNDTRUE = vbh_addvbvar( (ptype_list *)0, + VexData, dupvexexpr( VexVar ), VbhBase, Line ); + } + else + { + ScanIfs->CNDTRUE = vbh_addvbasg( (ptype_list *)0, + VexData, dupvexexpr( VexVar ), VbhBase, Line ); + } + + IntValue += Step; + } + + CurInst->NEXT = ScanPType; + + if ( Variable ) vbh_frevbasg( ScanVar ); + else vbh_frevbasg( ScanAsg ); + } + else + if ( ( Oper == VEX_TO ) || + ( Oper == VEX_DOWNTO ) ) + { + viewvexexprboundln( VexTarget ); + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "array slice in assignation" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyArrayScanInstruction | +| | +\------------------------------------------------------------*/ + +static ptype_list *VasyArrayScanInstruction( Instruction ) + + ptype_list *Instruction; +{ + ptype_list *ScanPType; + ptype_list **PrevPType; + vbifs_list *ScanIfs; + vbcas_list *ScanCase; + vbcho_list *ScanChoice; + vblop_list *ScanLoop; + vbfor_list *ScanFor; + vbwhi_list *ScanWhile; + vbwas_list *ScanWait; + vbnxt_list *ScanNext; + vbext_list *ScanExit; + int Offset; + + ScanPType = Instruction; + PrevPType = &Instruction; + + while ( ScanPType != (ptype_list *)0 ) + { + switch ( ScanPType->TYPE ) + { + case VBH_BEIFS : + + ScanIfs = (vbifs_list *)ScanPType->DATA; + ScanIfs->CND = VasyArrayScanVexCond( PrevPType, ScanIfs->CND ); + ScanIfs->CNDTRUE = VasyArrayScanInstruction( ScanIfs->CNDTRUE ); + ScanIfs->CNDFALSE = VasyArrayScanInstruction( ScanIfs->CNDFALSE ); + + break; + + case VBH_BECAS : + + ScanCase = (vbcas_list *)ScanPType->DATA; + ScanCase->VEX = VasyArrayScanVexCond( PrevPType, ScanCase->VEX ); + + for ( Offset = 0; Offset < ScanCase->SIZE; Offset++ ) + { + ScanChoice = &ScanCase->CHOICE[ Offset ]; + ScanChoice->INSTRUCTION = VasyArrayScanInstruction( ScanChoice->INSTRUCTION ); + } + + break; + + case VBH_BEFOR : + + ScanFor = (vbfor_list *)ScanPType->DATA; + ScanFor->INSTRUCTION = VasyArrayScanInstruction( ScanFor->INSTRUCTION ); + + continue; + + break; + + case VBH_BEWHI : + + ScanWhile = (vbwhi_list *)ScanPType->DATA; + ScanWhile->CND = VasyArrayScanVexCond( PrevPType, ScanWhile->CND ); + ScanWhile->INSTRUCTION = VasyArrayScanInstruction( ScanWhile->INSTRUCTION ); + + break; + + case VBH_BELOP : + + ScanLoop = (vblop_list *)ScanPType->DATA; + ScanLoop->INSTRUCTION = VasyArrayScanInstruction( ScanLoop->INSTRUCTION ); + + break; + + case VBH_BEASG : + + VasyArrayScanAsg( PrevPType, ScanPType, 0 ); + + break; + + case VBH_BEVAR : + + VasyArrayScanAsg( PrevPType, ScanPType, 1 ); + + break; + + case VBH_BEWAS : + + ScanWait = (vbwas_list *)ScanPType->DATA; + ScanWait->CND = VasyArrayScanVexCond( PrevPType, ScanWait->CND ); + ScanWait->SEN = VasyArrayScanSens( ScanWait->SEN ); + + break; + + case VBH_BENXT : + + ScanNext = (vbnxt_list *)ScanPType->DATA; + ScanNext->CND = VasyArrayScanVexCond( PrevPType, ScanNext->CND ); + + break; + + case VBH_BEEXT : + + ScanExit = (vbext_list *)ScanPType->DATA; + ScanExit->CND = VasyArrayScanVexCond( PrevPType, ScanExit->CND ); + + break; + + case VBH_BEAGR : + + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "aggregate assignation" ); + + break; + } + + PrevPType = &ScanPType->NEXT; + ScanPType = ScanPType->NEXT; + } + + return( Instruction ); +} + +/*------------------------------------------------------------\ +| | +| VasyExpandArrayScanProcess | +| | +\------------------------------------------------------------*/ + +static void VasyArrayScanProcess( BePcs ) + + vbpcs_list *BePcs; +{ + VasyProcess = BePcs; + + BePcs->INSTRUCTION = VasyArrayScanInstruction( BePcs->INSTRUCTION ); + BePcs->SENSITIVITY = VasyArrayScanSens( BePcs->SENSITIVITY ); +} + + +/*------------------------------------------------------------\ +| | +| VasyArrayCheckType | +| | +\------------------------------------------------------------*/ + +static int VasyArrayCheckType( VexAtom, VbhType ) + + vexexpr *VexAtom; + vbtyp_list *VbhType; +{ + vbtyp_list *VbhBaseType; + char *AtomValue; + short Array; + short Vector; + + Array = 0; + Vector = 0; + + if ( IsVasyVbhTypeArray( VbhType ) ) + { + Array = 1; + } + else + if ( IsVasyVbhTypeVector( VbhType ) ) + { + Vector = 1; + } + else + if ( VbhType->INDEX >= VBH_MAX_TYPE ) + { + if ( VbhType->DYNAMIC ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "dynamic size user type" ); + } + + if ( VbhType->CLASS == 'U' ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "user unconstrained array type" ); + } + else + if ( VbhType->CLASS == 'A' ) + { + VbhBaseType = VbhType->BASE; + + if ( VbhBaseType->INDEX >= VBH_MAX_TYPE ) + { + if ( VbhBaseType->DYNAMIC ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "dynamic size user type" ); + } + + if ( VbhBaseType->CLASS == 'A' ) + { + Array = 1; + SetVasyVbhTypeArray( VbhType ); + } + else + if ( VbhBaseType->CLASS == 'U' ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "user unconstrained array subtype" ); + } + } + else + if ( isvextypevector( VbhType->INDEX ) ) + { + Array = 1; + SetVasyVbhTypeArray( VbhType ); + } + else + { + Vector = 1; + SetVasyVbhTypeVector( VbhType ); + } + } + } + else + if ( isvextypevector( VbhType->INDEX ) ) + { + Vector = 1; + SetVasyVbhTypeVector( VbhType ); + } + + if ( Array ) + { + AtomValue = GetVexAtomValue( VexAtom ); + addauthelem( VasyHashNameArray, AtomValue, (long)VbhType ); + } + else + if ( Vector ) + { + AtomValue = GetVexAtomValue( VexAtom ); + addauthelem( VasyHashNameVector, AtomValue, (long)VbhType ); + addauthelem( VasyHashDeclar , AtomValue, (long)VexAtom ); + } + + return( Array ); +} + +/*------------------------------------------------------------\ +| | +| VasyArrayCleanDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyArrayCleanDeclar( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbcst_list *BeCst; + vbcst_list *DelCst; + vbcst_list **PrevCst; + vbaux_list *BeAux; + vbaux_list *DelAux; + vbaux_list **PrevAux; + vbpcs_list *BePcs; + vbvar_list *BeVar; + vbtyp_list *BeType; + ptype_list *ScanPtype; + ptype_list **PrevPType; + ptype_list *DelPType; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyArrayCleanDeclar %s\n", VbhFigure->NAME ); + } + + BeCst = VbhFigure->BECST; + PrevCst = &VbhFigure->BECST; + + while ( BeCst != (vbcst_list *)0 ) + { + BeType = BeCst->TYPE; + + if ( IsVasyVbhTypeArray( BeType ) ) + { + DelCst = BeCst; + BeCst = BeCst->NEXT; + *PrevCst = BeCst; + + DelCst->NEXT = (vbcst_list *)0; + vbh_frevbcst( DelCst ); + } + else + { + PrevCst = &BeCst->NEXT; + BeCst = BeCst->NEXT; + } + } + + BeAux = VbhFigure->BEAUX; + PrevAux = &VbhFigure->BEAUX; + + while ( BeAux != (vbaux_list *)0 ) + { + BeType = BeAux->TYPE; + + if ( IsVasyVbhTypeArray( BeType ) ) + { + DelAux = BeAux; + BeAux = BeAux->NEXT; + *PrevAux = BeAux; + + DelAux->NEXT = (vbaux_list *)0; + vbh_frevbaux( DelAux ); + } + else + { + PrevAux = &BeAux->NEXT; + BeAux = BeAux->NEXT; + } + } + + for ( BePcs = VbhFigure->BEPCS; + BePcs != (vbpcs_list *)0; + BePcs = BePcs->NEXT ) + { + ScanPtype = BePcs->VARIABLE; + PrevPType = &BePcs->VARIABLE; + + while ( ScanPtype != (ptype_list *)0 ) + { + BeVar = (vbvar_list *)ScanPtype->DATA; + BeType = BeVar->TYPE; + + if ( IsVasyVbhTypeArray( BeType ) ) + { + vbh_frevbvar( BeVar ); + + DelPType = ScanPtype; + ScanPtype = ScanPtype->NEXT; + *PrevPType = ScanPtype; + + DelPType->NEXT = (ptype_list *)0; + freeptype( DelPType ); + } + else + { + PrevPType = &ScanPtype->NEXT; + ScanPtype = ScanPtype->NEXT; + } + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyArrayCleanDeclar\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyArrayCheckDeclar | +| | +\------------------------------------------------------------*/ + +static int VasyArrayCheckDeclar( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbpor_list *BePor; + vbaux_list *BeAux; + vbcst_list *BeCst; + vbpcs_list *BePcs; + vbvar_list *BeVar; + vbtyp_list *BeType; + vbtyp_list *BaseType; + ptype_list *ScanPtype; + chain_list *ScanOper; + vexexpr *VexAtom; + vexexpr *NewAtom; + vexexpr *VexInit; + vexexpr *Operand; + char *AtomValue; + char *NewName; + int Found; + int Step; + int Index; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyArrayCheckDeclar %s\n", VbhFigure->NAME ); + } + + Found = 0; + + for ( BePor = VbhFigure->BEPOR; + BePor != (vbpor_list *)0; + BePor = BePor->NEXT ) + { + BeType = BePor->TYPE; + VexAtom = BePor->TARGET; + + if ( VasyArrayCheckType( VexAtom, BeType ) ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "port: array type" ); + } + } + + for ( BeAux = VbhFigure->BEAUX; + BeAux != (vbaux_list *)0; + BeAux = BeAux->NEXT ) + { + BeType = BeAux->TYPE; + VexAtom = BeAux->TARGET; + + if ( VasyArrayCheckType( VexAtom, BeType ) ) + { + if ( BeAux->VEX != (vexexpr *)0 ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "array initialisation" ); + } + + BaseType = BeType->BASE; + AtomValue = GetVexAtomValue( VexAtom ); + + if ( BeType->LEFT < BeType->RIGHT ) Step = 1; + else Step = -1; + + for ( Index = BeType->LEFT; Index != (BeType->RIGHT + Step); Index += Step ) + { + NewName = VasyArrayGetIndexName( AtomValue, Index ); + NewAtom = createvexatomvec( NewName, BaseType->LEFT, BaseType->RIGHT ); + + VbhFigure->BEAUX = vbh_addvbaux( VbhFigure->BEAUX, NewAtom, (vexexpr *)0, + BeAux->KIND, BaseType, BeAux->LINE ); + } + + Found = 1; + } + } + + for ( BeCst = VbhFigure->BECST; + BeCst != (vbcst_list *)0; + BeCst = BeCst->NEXT ) + { + BeType = BeCst->TYPE; + VexAtom = BeCst->TARGET; + + if ( VasyArrayCheckType( VexAtom, BeType ) ) + { + BaseType = BeType->BASE; + AtomValue = GetVexAtomValue( VexAtom ); + VexInit = BeCst->VEX; + + if ( ( VexInit == (vexexpr *)0 ) || + ( ! IsVexNodeOper( VexInit ) ) || + ( GetVexOperValue( VexInit ) != VEX_ARRAY ) ) + { + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "constant array initialisation" ); + } + + ScanOper = VexInit->OPERAND; + + if ( BeType->LEFT < BeType->RIGHT ) Step = 1; + else Step = -1; + + for ( Index = BeType->LEFT; Index != (BeType->RIGHT + Step); Index += Step ) + { + if ( ScanOper == (chain_list *)0 ) + { + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "constant array initialisation" ); + } + + Operand = GetVexOperand( ScanOper ); + SetVexOperand( ScanOper, (vexexpr *)0 ); + + NewName = VasyArrayGetIndexName( AtomValue, Index ); + NewAtom = createvexatomvec( NewName, BaseType->LEFT, BaseType->RIGHT ); + + VbhFigure->BECST = vbh_addvbcst( VbhFigure->BECST, NewAtom, Operand, + BaseType, BeCst->LINE ); + + ScanOper = ScanOper->NEXT; + } + + freevexexpr( VexInit ); + BeCst->VEX = (vexexpr *)0; + + Found = 1; + } + } + + for ( BePcs = VbhFigure->BEPCS; + BePcs != (vbpcs_list *)0; + BePcs = BePcs->NEXT ) + { + for ( ScanPtype = BePcs->VARIABLE; + ScanPtype != (ptype_list *)0; + ScanPtype = ScanPtype->NEXT ) + { + BeVar = (vbvar_list *)ScanPtype->DATA; + BeType = BeVar->TYPE; + VexAtom = BeVar->TARGET; + + if ( VasyArrayCheckType( BeVar->TARGET, BeVar->TYPE ) ) + { + BaseType = BeType->BASE; + AtomValue = GetVexAtomValue( VexAtom ); + + if ( BeType->LEFT < BeType->RIGHT ) Step = 1; + else Step = -1; + + for ( Index = BeType->LEFT; Index != (BeType->RIGHT + Step); Index += Step ) + { + NewName = VasyArrayGetIndexName( AtomValue, Index ); + NewAtom = createvexatomvec( NewName, BaseType->LEFT, BaseType->RIGHT ); + + BePcs->VARIABLE = vbh_addvbvar( BePcs->VARIABLE, NewAtom, (vexexpr *)0, + BaseType, BeVar->LINE ); + } + + Found = 1; + } + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyArrayCheckDeclar %d\n", Found ); + } + + return( Found ); +} + +/*------------------------------------------------------------\ +| | +| VasyExpandArrayVbhFig | +| | +\------------------------------------------------------------*/ + +void VasyExpandArrayVbhFig( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbpcs_list *BePcs; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyExpandArrayVbhFig %s\n", VbhFigure->NAME ); + } + + VasyHashNameArray = createauthtable( 100 ); + VasyHashNameVector = createauthtable( 100 ); + VasyHashDeclar = createauthtable( 100 ); + + VasyTypeNatural = vbh_getvbtypbyindex( VbhFigure, VBH_TYPE_NATURAL ); + + VasyArrayCheckDeclar( VbhFigure ); + + for ( BePcs = VbhFigure->BEPCS; + BePcs != (vbpcs_list *)0; + BePcs = BePcs->NEXT ) + { + VasyArrayScanProcess( BePcs ); + } + + VasyArrayCleanDeclar( VbhFigure ); + + if ( IsVasyDebugLevel1() ) + { + vbh_viewvbfig( VbhFigure ); + } + + destroyauthtable( VasyHashNameArray ); + destroyauthtable( VasyHashNameVector ); + destroyauthtable( VasyHashDeclar ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyExpandArrayVbhFig %s\n\n", VbhFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_array.h b/alliance/src/vasy/src/vasy_array.h new file mode 100644 index 00000000..2158cb32 --- /dev/null +++ b/alliance/src/vasy/src/vasy_array.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 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 : VASY | +| | +| File : vasy_array.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 13.12.99 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_ARRAY_H +# define VASY_ARRAY_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_VBH_TYPE_ARRAY_MASK 0x1 +# define VASY_VBH_TYPE_VECTOR_MASK 0x2 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define IsVasyVbhTypeArray( T ) ((T)->FLAGS & VASY_VBH_TYPE_ARRAY_MASK) +# define SetVasyVbhTypeArray( T ) ((T)->FLAGS |= VASY_VBH_TYPE_ARRAY_MASK) +# define ClearVasyVbhTypeArray( T ) ((T)->FLAGS &= ~VASY_VBH_TYPE_ARRAY_MASK) + +# define IsVasyVbhTypeVector( T ) ((T)->FLAGS & VASY_VBH_TYPE_VECTOR_MASK) +# define SetVasyVbhTypeVector( T ) ((T)->FLAGS |= VASY_VBH_TYPE_VECTOR_MASK) +# define ClearVasyVbhTypeVector( T ) ((T)->FLAGS &= ~VASY_VBH_TYPE_VECTOR_MASK) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyExpandArrayVbhFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_debug.c b/alliance/src/vasy/src/vasy_debug.c new file mode 100644 index 00000000..58c6e6b6 --- /dev/null +++ b/alliance/src/vasy/src/vasy_debug.c @@ -0,0 +1,309 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_debug.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_error.h" +# include "vasy_debug.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + int VasyDebugFlag = 0; + int VasyDebugOption = 0; + time_t VasyDebugChrono[ VASY_DEBUG_MAX_CHRONO ]; + +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static char *VasyDebugItemName[ ] = + { + "vasy_analys.c", + "vasy_array.c", + "vasy_debug.c", + "vasy_drvalc.c", + "vasy_drvrtl.c", + "vasy_drvsyn.c", + "vasy_drvvlog.c", + "vasy_elabo.c", + "vasy_error.c", + "vasy_func.c", + "vasy_generate.c", + "vasy_generic.c", + "vasy_loop.c", + "vasy_main.c", + "vasy_mulwait.c", + "vasy_onewait.c", + "vasy_parse.c", + "vasy_preanal.c", + "vasy_redact.c", + "vasy_redinst.c", + "vasy_reduce.c", + "vasy_redwait.c", + "vasy_shared.c", + "vasy_simprtl.c", + "vasy_simul.c", + "vasy_support.c", + "vasy_synth.c", + "vasy_vexbdd.c", + (char *)0 + }; + + static char *VasyDebugItemFlag = (char *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyDebugSetOption | +| | +\------------------------------------------------------------*/ + +int VasyDebugSetOption( Name ) + + char *Name; +{ + if ( ! strcmp( Name, "no_redinst" ) ) + { + SetVasyDebugNoRedInst(); return( 1 ); + } + else + if ( ! strcmp( Name, "stat" ) ) + { + SetVasyDebugStatistics(); return( 1 ); + } + else + if ( ! strcmp( Name, "stdout" ) ) + { + SetVasyDebugDriveStdout(); return( 1 ); + } + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyDebugAddItem | +| | +\------------------------------------------------------------*/ + +int VasyDebugAddItem( Name, Mode ) + + char *Name; + int Mode; +{ + char Buffer[ 64 ]; + char *Item; + int Index; + + if ( VasyDebugItemFlag == (char *)0 ) + { + Index = 0; + + while ( VasyDebugItemName[ Index ] != (char *)0 ) + { + VasyDebugItemName[ Index ] = namealloc( VasyDebugItemName[ Index ] ); + + Index++; + } + + VasyDebugItemFlag = autallocblock( Index ); + } + + if ( ! strcmp( Name, "all" ) ) + { + VasyDebugFlag |= Mode; + + Index = 0; + + while ( VasyDebugItemName[ Index ] != (char *)0 ) + { + VasyDebugItemFlag[ Index ] |= Mode; + + Index++; + } + + return( 1 ); + } + else + { + sprintf( Buffer, "vasy_%s.c", Name ); + Item = namealloc( Buffer ); + Index = 0; + + while ( VasyDebugItemName[ Index ] != (char *)0 ) + { + if ( Item == VasyDebugItemName[ Index ] ) + { + VasyDebugItemFlag[ Index ] |= Mode; + VasyDebugFlag |= Mode; + + return( 1 ); + } + + Index++; + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyDebugSearchItem | +| | +\------------------------------------------------------------*/ + +int VasyDebugSearchItem( Item, Mode ) + + char *Item; + int Mode; +{ + int Index; + + if ( ( Mode & VasyDebugFlag ) == Mode ) + { + Item = namealloc( Item ); + Index = 0; + + while ( VasyDebugItemName[ Index ] != (char *)0 ) + { + if ( Item == VasyDebugItemName[ Index ] ) + { + return( ( VasyDebugItemFlag[ Index ] & Mode ) == Mode ); + } + + Index++; + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyDebugLocSaveVpnFig | +| | +\------------------------------------------------------------*/ + +void VasyDebugLocSaveVpnFig( VpnFigure, FileName, Line ) + + vpnfig_list *VpnFigure; + char *FileName; + int Line; +{ + static char Buffer[ 32 ]; + static int Number = 0; + + char *Name; + char *VpnOut; + int Length; + + Name = VpnFigure->NAME; + VpnOut = VPN_OUT; + + sprintf( Buffer, "%03d_%04d", Number++, Line ); + Length = strlen( Buffer ); + + FileName = FileName + 4; + strcpy( Buffer + Length, FileName ); + Length += strlen( FileName ); + Buffer[ Length - 2 ] = '\0'; + + VpnFigure->NAME = namealloc( Buffer ); + VPN_OUT = namealloc( "vpn" ); + + fprintf( stdout, " +++ VasyDebugSaveVpnFig %s.vpn\n", VpnFigure->NAME ); + savevpnfig( VpnFigure ); + + VpnFigure->NAME = Name; + VPN_OUT = VpnOut; +} + +/*------------------------------------------------------------\ +| | +| VasyDebugPrint | +| | +\------------------------------------------------------------*/ + +void VasyDebugPrint( FileName, Line ) + + char *FileName; + int Line; +{ + char Buffer[ 32 ]; + int Length; + + FileName = FileName + 5; + Length = strlen( FileName ); + strcpy( Buffer, FileName ); + Buffer[ Length - 2 ] = '\0'; + + fprintf( stdout, "%-8s%4d ", Buffer, Line ); +} diff --git a/alliance/src/vasy/src/vasy_debug.h b/alliance/src/vasy/src/vasy_debug.h new file mode 100644 index 00000000..890b69c7 --- /dev/null +++ b/alliance/src/vasy/src/vasy_debug.h @@ -0,0 +1,163 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_debug.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_DEBUG_H +# define VASY_DEBUG_H + +# include + +/*------------------------------------------------------------\ +| | +| Debug Mode | +| | +\------------------------------------------------------------*/ + +# define VASY_DEBUG_LEVEL0 0x01 +# define VASY_DEBUG_LEVEL1 0x03 +# define VASY_DEBUG_LEVEL2 0x07 + +/*------------------------------------------------------------\ +| | +| Debug Option | +| | +\------------------------------------------------------------*/ + +# define VASY_DEBUG_NO_RED_INST 0x01 +# define VASY_DEBUG_STATISTICS 0x02 +# define VASY_DEBUG_DRIVE_STDOUT 0x04 + +/*------------------------------------------------------------\ +| | +| Chrono | +| | +\------------------------------------------------------------*/ + +# define VASY_DEBUG_MAX_CHRONO 10 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Save Macro | +| | +\------------------------------------------------------------*/ + +# define VasyDebugSaveVpnFig( F ) \ + \ + (VasyDebugLocSaveVpnFig( (F), __FILE__, __LINE__ )) + +/*------------------------------------------------------------\ +| | +| Debug Macro | +| | +\------------------------------------------------------------*/ + +# define IsVasyDebugLevel0() (VasyDebugSearchItem( __FILE__, VASY_DEBUG_LEVEL0)) +# define IsVasyDebugLevel1() (VasyDebugSearchItem( __FILE__, VASY_DEBUG_LEVEL1)) +# define IsVasyDebugLevel2() (VasyDebugSearchItem( __FILE__, VASY_DEBUG_LEVEL2)) + +/*------------------------------------------------------------\ +| | +| Print Macro | +| | +\------------------------------------------------------------*/ + +# define VasyPrintf VasyDebugPrint( __FILE__, __LINE__ ); fprintf + +/*------------------------------------------------------------\ +| | +| Debug Option Macro | +| | +\------------------------------------------------------------*/ + +# define IsVasyDebugNoRedInst() (VasyDebugOption & VASY_DEBUG_NO_RED_INST) +# define SetVasyDebugNoRedInst() (VasyDebugOption |= VASY_DEBUG_NO_RED_INST) +# define IsVasyDebugStatistics() (VasyDebugOption & VASY_DEBUG_STATISTICS) +# define SetVasyDebugStatistics() (VasyDebugOption |= VASY_DEBUG_STATISTICS) +# define IsVasyDebugDriveStdout() (VasyDebugOption & VASY_DEBUG_DRIVE_STDOUT) +# define SetVasyDebugDriveStdout() (VasyDebugOption |= VASY_DEBUG_DRIVE_STDOUT) + +/*------------------------------------------------------------\ +| | +| Time Macro | +| | +\------------------------------------------------------------*/ + +# define VasyDebugStartChrono(N) (void)time(&VasyDebugChrono[(N)]) +# define VasyDebugReadChrono(N) (time((void *)0) - VasyDebugChrono[(N)]) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern int VasyDebugFlag; + extern int VasyDebugOption; + extern time_t VasyDebugChrono[ VASY_DEBUG_MAX_CHRONO ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern int VasyDebugSearchItem(); + extern int VasyDebugAddItem(); + + extern int VasyDebugSetOption(); + + extern void VasyDebugLocSaveVpnFig(); + extern void VasyDebugPrint(); + +# endif diff --git a/alliance/src/vasy/src/vasy_drvalc.c b/alliance/src/vasy/src/vasy_drvalc.c new file mode 100644 index 00000000..cb470772 --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvalc.c @@ -0,0 +1,2964 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvalc.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_debug.h" +# include "vasy_error.h" +# include "vasy_shared.h" +# include "vasy_simprtl.h" +# include "vasy_drvvex.h" +# include "vasy_drvalc.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static FILE *VasyFile = (FILE *)0; + static FILE *VasyLaxFile = (FILE *)0; + static FILE *VasyBoomFile = (FILE *)0; + + static long VasyNumberBlock = 0; + static chain_list *VasyKeepSignal = (chain_list *)0; + + static short VasyConvertType[ VEX_MAX_TYPE ] = + { + VEX_TYPE_SEVERITY , /* SEVERITY */ + VEX_TYPE_BIT , /* BOOLEAN */ + VEX_TYPE_CHARACTER , /* CHARACTER */ + VEX_TYPE_STRING , /* STRING */ + VEX_TYPE_BIT , /* BIT */ + VEX_TYPE_BIT_VECTOR , /* INTEGER */ + VEX_TYPE_BIT_VECTOR , /* NATURAL */ + VEX_TYPE_BIT_VECTOR , /* BIT_VECTOR */ + VEX_TYPE_BIT , /* STD_ULOGIC */ + VEX_TYPE_BIT , /* STD_LOGIC */ + VEX_TYPE_BIT_VECTOR , /* STD_ULOGIC_VECTOR */ + VEX_TYPE_BIT_VECTOR , /* STD_LOGIC_VECTOR */ + VEX_TYPE_BIT , /* X01 */ + VEX_TYPE_BIT , /* X01Z */ + VEX_TYPE_BIT , /* UX01 */ + VEX_TYPE_BIT , /* UX01Z */ + VEX_TYPE_BIT_VECTOR , /* UNSIGNED */ + VEX_TYPE_BIT_VECTOR , /* SIGNED */ + VEX_TYPE_BIT , /* SMALL_INT */ + VEX_TYPE_REG_BIT , /* REG_BIT */ + VEX_TYPE_REG_VECTOR , /* REG_VECTOR */ + VEX_TYPE_MUX_BIT , /* MUX_BIT */ + VEX_TYPE_MUX_VECTOR , /* MUX_VECTOR */ + VEX_TYPE_WOR_BIT , /* WOR_BIT */ + VEX_TYPE_WOR_VECTOR , /* WOR_VECTOR */ + VEX_TYPE_BIT_VECTOR /* ENUMERATE */ + }; + + static rtlfig_list *VasyRtlFigure = (rtlfig_list *)0; + + static rtlasg_list *VasyRtlAsg = (rtlasg_list *)0; + static long VasyNumberDef = 0; + + static char VasyBuffer[ 512 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyAllianceDriveLaxFile | +| | +\------------------------------------------------------------*/ + +static void VasyAllianceDriveLaxFile() +{ + chain_list *ScanList; + vexexpr *VexAtom; + char *Name; + int Step; + int Index; + int Width; + + fprintf( VasyLaxFile, "##\n" ); + fprintf( VasyLaxFile, "## Generated by VASY\n" ); + fprintf( VasyLaxFile, "##\n" ); + + if ( VasyKeepSignal != (chain_list *)0 ) + { + fprintf( VasyLaxFile, "#S{\n" ); + + for ( ScanList = VasyKeepSignal; + ScanList != (chain_list *)0; + ScanList = ScanList->NEXT ) + { + VexAtom = (vexexpr *)ScanList->DATA; + Name = GetVexAtomValue( VexAtom ); + + if ( IsVexAtomVector( VexAtom ) ) + { + if ( VexAtom->LEFT > VexAtom->RIGHT ) Step = -1; + else Step = 1; + + Index = VexAtom->LEFT; + + for ( Width = VexAtom->WIDTH; Width > 0; Width-- ) + { + fprintf( VasyLaxFile, "%s_%d;\n", Name, Index ); + Index += Step; + } + } + else + { + fprintf( VasyLaxFile, "%s;\n", Name ); + } + } + + fprintf( VasyLaxFile, "}\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceDriveBoomFile | +| | +\------------------------------------------------------------*/ + +static void VasyAllianceDriveBoomFile() +{ + chain_list *ScanList; + vexexpr *VexAtom; + char *Name; + + fprintf( VasyBoomFile, "#\n" ); + fprintf( VasyBoomFile, "# Generated by VASY\n" ); + fprintf( VasyBoomFile, "#\n" ); + + if ( VasyKeepSignal != (chain_list *)0 ) + { + fprintf( VasyBoomFile, "begin_keep\n" ); + + for ( ScanList = VasyKeepSignal; + ScanList != (chain_list *)0; + ScanList = ScanList->NEXT ) + { + VexAtom = (vexexpr *)ScanList->DATA; + Name = GetVexAtomValue( VexAtom ); + + if ( IsVexAtomVector( VexAtom ) ) + { + if ( VexAtom->WIDTH > 1 ) + { + fprintf( VasyBoomFile, "%s[%d:%d]\n", Name, VexAtom->LEFT, VexAtom->RIGHT ); + } + else + { + fprintf( VasyBoomFile, "%s[%d]\n", Name, VexAtom->LEFT ); + } + } + else + { + fprintf( VasyBoomFile, "%s\n", Name ); + } + } + + fprintf( VasyBoomFile, "end_keep\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexOperandAtom | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexOperandAtom( Operand ) + + vexexpr *Operand; +{ + vexexpr *VexAtom; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + char Buffer[ 32 ]; + + if ( ! IsVexNodeAtom( Operand ) ) + { + sprintf( Buffer, "rtlatom_%ld", VasyNumberDef++ ); + VexAtom = createvexatomvec( Buffer, Operand->WIDTH - 1, 0 ); + + if ( IsVexNodeSigned( Operand ) ) SetVexNodeSigned( VexAtom ); + + RtlDeclar = addrtldecl( VasyRtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + RtlDeclar->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + RtlAssign = addrtlasgafter( VasyRtlFigure, VasyRtlAsg, + dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = dupvexexpr( Operand ); + Operand = VexAtom; + } + + return( Operand ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceAddKeepSignal | +| | +\------------------------------------------------------------*/ + +static void VasyAllianceAddKeepSignal( VexAtom ) + + vexexpr *VexAtom; +{ + if ( ( IsVexNodeAtom( VexAtom ) ) && + ( ! IsVexAtomLiteral( VexAtom ) ) ) + { + VasyKeepSignal = addchain( VasyKeepSignal, (void *)dupvexexpr( VexAtom ) ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceFreeKeepSignal | +| | +\------------------------------------------------------------*/ + +static void VasyAllianceFreeKeepSignal() +{ + chain_list *ScanChain; + + + for ( ScanChain = VasyKeepSignal; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + freevexexpr( (vexexpr *)ScanChain->DATA ); + } + + freechain( VasyKeepSignal ); + VasyKeepSignal = (chain_list *)0; +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceCreateVexCarry | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceCreateVexCarry( Operand ) + + vexexpr *Operand; +{ + vexexpr *VexAtom; + short Left; + + if ( ! IsVexAtomLiteral( Operand ) ) + { + if ( IsVexNodeDown( Operand ) ) Left = Operand->LEFT - 1; + else Left = Operand->LEFT + 1; + + VexAtom = createvexatomvec( GetVexAtomValue( Operand ), Left, Operand->RIGHT ); + } + else + { + strcpy( VasyBuffer, GetVexAtomValue( Operand ) ); + + if ( Operand->WIDTH > 2 ) VasyBuffer[ 1 ] = '"'; + else VasyBuffer[ 1 ] = '\''; + + VexAtom = createvexatomlit( &VasyBuffer[ 1 ] ); + } + + return( VexAtom ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexArith | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexArith( VexExpr ) + + vexexpr *VexExpr; +{ + rtldecl_list *RtlDeclCarry; + rtldecl_list *RtlDeclSum; + rtldecl_list *RtlDeclGen; + rtldecl_list *RtlDeclProp; + rtlasg_list *RtlAsgCarry; + rtlasg_list *RtlAsgSum; + rtlasg_list *RtlAsgProp; + rtlasg_list *RtlAsgGen; + vexexpr *Operand1; + vexexpr *Operand2; + vexexpr *VexSum; + vexexpr *VexGen; + vexexpr *VexProp; + vexexpr *VexCarry; + vexexpr *VexAtomCarry; + vexexpr *VexAtomSum; + vexexpr *VexAtomGen; + vexexpr *VexAtomProp; + vexexpr *VexAnd1; + vexexpr *VexAnd2; + vexexpr *VexAnd3; + vexexpr *VexAtom0; + vexexpr *VexAtom1; + vexexpr *VexAtom2; + vexexpr *VexAtom3; + vexexpr *VexAtom4; + char Buffer[ 32 ]; + int MaxWidth; + int Index; + long Oper; + + VexAtom1 = (vexexpr *)0; + VexAtom2 = (vexexpr *)0; + VexAtom3 = (vexexpr *)0; + VexAtom4 = (vexexpr *)0; + + Oper = GetVexOperValue( VexExpr ); + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Operand2 = GetVexOperand( VexExpr->OPERAND->NEXT ); + + MaxWidth = Operand1->WIDTH; + if ( Operand2->WIDTH > MaxWidth ) MaxWidth = Operand2->WIDTH; + + sprintf( Buffer, "rtlcarry_%ld", VasyNumberDef ); + VexAtomCarry = createvexatomvec( Buffer, MaxWidth - 1, 0 ); + + RtlDeclCarry = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomCarry ), RTL_DECLAR_SIGNAL ); + RtlDeclCarry->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclCarry->KIND = RTL_KIND_NONE; + RtlDeclCarry->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclCarry ); + SetVasyRtlDeclarAsg( RtlDeclCarry ); + + sprintf( Buffer, "rtlsum_%ld", VasyNumberDef ); + VexAtomSum = createvexatomvec( Buffer, MaxWidth - 1, 0 ); + + RtlDeclSum = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomSum ), RTL_DECLAR_SIGNAL ); + RtlDeclSum->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclSum->KIND = RTL_KIND_NONE; + RtlDeclSum->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclSum ); + SetVasyRtlDeclarAsg( RtlDeclSum ); + + if ( ( MaxWidth > 1 ) && + ( VasyFlagCLA ) && + ( MaxWidth >= VasyFlagCLA ) ) + { +/* +** Generation +*/ + sprintf( Buffer, "rtlgen_%ld", VasyNumberDef ); + VexAtomGen = createvexatomvec( Buffer, MaxWidth - 1, 1 ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtomGen ); + + RtlDeclGen = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomGen ), RTL_DECLAR_SIGNAL ); + RtlDeclGen->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclGen->KIND = RTL_KIND_NONE; + RtlDeclGen->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclGen ); + SetVasyRtlDeclarAsg( RtlDeclGen ); +/* +** Propagation +*/ + sprintf( Buffer, "rtlprop_%ld", VasyNumberDef ); + VexAtomProp = createvexatomvec( Buffer, MaxWidth - 1, 1 ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtomProp ); + + RtlDeclProp = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomProp ), RTL_DECLAR_SIGNAL ); + RtlDeclProp->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclProp->KIND = RTL_KIND_NONE; + RtlDeclProp->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclProp ); + SetVasyRtlDeclarAsg( RtlDeclProp ); + } + + VasyNumberDef++; +/* +** The two operands should be transformed to atomic expressions with the same widths +*/ + Operand1 = dupvexexpr( VasyAllianceTreatVexOperandAtom( Operand1 ) ); + Operand2 = dupvexexpr( VasyAllianceTreatVexOperandAtom( Operand2 ) ); + + if ( MaxWidth > 1 ) + { + VexAtom1 = VasyAllianceCreateVexCarry( Operand1 ); + VexAtom2 = VasyAllianceCreateVexCarry( Operand2 ); + } + + if ( Oper == VEX_SUB ) + { + Operand2 = createvexunaryexpr( VEX_NOT, MaxWidth, Operand2 ); + + if ( MaxWidth > 1 ) + { + VexAtom2 = createvexunaryexpr( VEX_NOT, MaxWidth - 1, VexAtom2 ); + } + } + + if ( MaxWidth > 1 ) + { + if ( ( VasyFlagCLA ) && + ( MaxWidth >= VasyFlagCLA ) ) + { +/* +** Generation +*/ + VexGen = createvexbinexpr( VEX_AND, MaxWidth - 1, + dupvexexpr( VexAtom1 ), dupvexexpr( VexAtom2 ) ); + + RtlAsgGen = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomGen ), RTL_ASG_COMBINATORIAL ); + RtlAsgGen->VEX_DATA = simpvexexpr( VexGen ); +/* +** Propagation +*/ + VexProp = createvexbinexpr( VEX_OR, MaxWidth - 1, + VexAtom1, VexAtom2 ); + + RtlAsgProp = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomProp ), + RTL_ASG_COMBINATORIAL ); + RtlAsgProp->VEX_DATA = simpvexexpr( VexProp ); +/* +** Carry-Look ahead +*/ + for ( Index = 1; Index < MaxWidth; Index++ ) + { + VexGen = createvexatomvec( GetVexAtomValue( VexAtomGen ), Index, Index ); + VexProp = createvexatomvec( GetVexAtomValue( VexAtomProp ), Index, Index ); + + if ( Index == 1 ) + { + VexCarry = createvexatomvec( GetVexAtomValue( VexAtomCarry ), 0, 0 ); + } + else + { + VexCarry = dupvexexpr( VexCarry ); + } + + VexCarry = createvexbinexpr( VEX_AND, 1, VexProp , VexCarry ); + VexCarry = createvexbinexpr( VEX_OR , 1, VexCarry, VexGen ); + + VexAtom3 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), Index , Index ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtom3 ); + + RtlAsgCarry = addrtlasg( VasyRtlFigure, VexAtom3, RTL_ASG_COMBINATORIAL ); + RtlAsgCarry->VEX_DATA = VexCarry; + } + } + else + { +/* +** Ripple Carry +*/ + VexAtom3 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), MaxWidth - 2, 0 ); + VexAtom4 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), MaxWidth - 1, 1 ); + + VexAnd1 = createvexbinexpr( VEX_AND, MaxWidth - 1, dupvexexpr( VexAtom1 ), + dupvexexpr( VexAtom2 ) ); + VexAnd2 = createvexbinexpr( VEX_AND, MaxWidth - 1, VexAtom1, dupvexexpr( VexAtom3 ) ); + VexAnd3 = createvexbinexpr( VEX_AND, MaxWidth - 1, VexAtom2, VexAtom3 ); + + VexCarry = createvexbinexpr( VEX_OR, MaxWidth - 1, VexAnd1 , VexAnd2 ); + VexCarry = createvexbinexpr( VEX_OR, MaxWidth - 1, VexCarry, VexAnd3 ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtom4 ); + + RtlAsgCarry = addrtlasg( VasyRtlFigure, VexAtom4, RTL_ASG_COMBINATORIAL ); + RtlAsgCarry->VEX_DATA = simpvexexpr( VexCarry ); + } + } +/* +** Sum +*/ + VexSum = createvexbinexpr( VEX_XOR, MaxWidth, Operand1, Operand2 ); + VexSum = createvexbinexpr( VEX_XOR, MaxWidth, + VexSum, dupvexexpr( VexAtomCarry ) ); + + RtlAsgSum = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomSum ), RTL_ASG_COMBINATORIAL ); + RtlAsgSum->VEX_DATA = simpvexexpr( VexSum ); +/* +** Carry In +*/ + VexAtom0 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), 0, 0 ); + RtlAsgCarry = addrtlasg( VasyRtlFigure, VexAtom0, RTL_ASG_COMBINATORIAL ); + + if ( Oper == VEX_ADD ) + { + RtlAsgCarry->VEX_DATA = createvexatomlit( VEX_ATOM_ZERO ); + } + else + { + RtlAsgCarry->VEX_DATA = createvexatomlit( VEX_ATOM_ONE ); + } + + freevexexpr( VexExpr ); + + return( VexAtomSum ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexAbs | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexAbs( VexExpr ) + + vexexpr *VexExpr; +{ + rtldecl_list *RtlDeclAbs; + rtlasg_list *RtlAsgAbs; + vexexpr *Operand; + vexexpr *VexNeg; + vexexpr *VexSign; + vexexpr *VexAtomAbs; + char Buffer[ 32 ]; + short Width; + + Width = VexExpr->WIDTH; + Operand = GetVexOperand( VexExpr->OPERAND ); + SetVexOperand( VexExpr->OPERAND, NULL ); + freevexexpr( VexExpr ); + + Operand = dupvexexpr( VasyAllianceTreatVexOperandAtom( Operand ) ); + VexSign = createvexatomvec( GetVexAtomValue( Operand ), Width - 1, Width - 1 ); + + VexNeg = createvexoper( VEX_SUB, Width ); + addvexhexpr( VexNeg, dupvexexpr( Operand ) ); + addvexhexpr( VexNeg, createvexatomveclit( VEX_ZERO, Width ) ); + VexNeg = VasyAllianceTreatVexArith( VexNeg ); + + sprintf( Buffer, "rtlabs_%ld", VasyNumberDef++ ); + VexAtomAbs = createvexatomvec( Buffer, Width - 1, 0 ); + + RtlDeclAbs = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomAbs ), RTL_DECLAR_SIGNAL ); + RtlDeclAbs->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclAbs->KIND = RTL_KIND_NONE; + RtlDeclAbs->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclAbs ); + SetVasyRtlDeclarAsg( RtlDeclAbs ); + + RtlAsgAbs = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomAbs ), RTL_ASG_CONDITIONAL ); + + addrtlasgbivex( VasyRtlFigure, RtlAsgAbs, VexSign , VexNeg , RTL_BIVEX_CONDITIONAL ); + addrtlasgbivex( VasyRtlFigure, RtlAsgAbs, (vexexpr *)0, Operand, RTL_BIVEX_CONDITIONAL ); + + return( VexAtomAbs ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexNeg | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexNeg( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand; + short Width; + + Width = VexExpr->WIDTH; + Operand = GetVexOperand( VexExpr->OPERAND ); + SetVexOperand( VexExpr->OPERAND, NULL ); + freevexexpr( VexExpr ); + + VexExpr = createvexoper( VEX_SUB, Width ); + addvexhexpr( VexExpr, Operand ); + Operand = createvexatomveclit( VEX_ZERO, Width ); + addvexhexpr( VexExpr, Operand ); + + return( VasyAllianceTreatVexArith( VexExpr ) ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceExtendSignVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceExtendSignVex( VexExpr, Width ) + + vexexpr *VexExpr; + int Width; +{ + vexexpr *VexAtom; + vexexpr *VexConcat; + vexexpr *VexBit; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + char *AtomValue; + int Left; + int Index; + + if ( VexExpr->WIDTH != Width ) + { + VexAtom = (vexexpr *)0; + + if ( ! IsVexNodeAtom( VexExpr ) ) + { + sprintf( VasyBuffer, "alcexts_%ld", VasyNumberDef++ ); + VexAtom = createvexatomvec( VasyBuffer, VexExpr->WIDTH - 1, 0 ); + + RtlDeclar = addrtldecl( VasyRtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + + if ( IsVexNodeSigned( VexExpr ) ) RtlDeclar->BASE = VEX_TYPE_SIGNED; + else RtlDeclar->BASE = VEX_TYPE_UNSIGNED; + + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + RtlAssign = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexExpr; + + VexExpr = dupvexexpr( VexAtom ); + } + + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + sprintf( VasyBuffer, "alcexts_%ld", VasyNumberDef++ ); + VexAtom = createvexatomvec( VasyBuffer, Width - 1, 0 ); + + RtlDeclar = addrtldecl( VasyRtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + if ( IsVexNodeSigned( VexExpr ) ) RtlDeclar->BASE = VEX_TYPE_SIGNED; + else RtlDeclar->BASE = VEX_TYPE_UNSIGNED; + + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + } + + if ( VexExpr->WIDTH < Width ) + { + VexConcat = createvexoper( VEX_CONCAT, Width ); + addvexhexpr( VexConcat, dupvexexpr( VexExpr ) ); + + if ( IsVexNodeSigned( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + + if ( IsVexAtomLiteral( VexExpr ) ) + { + VexBit = createvexatomveclit( AtomValue[ 1 ], Width - VexExpr->WIDTH ); + addvexhexpr( VexConcat, dupvexexpr( VexBit ) ); + } + else + { + VexBit = createvexatomvec( AtomValue, VexExpr->LEFT, VexExpr->LEFT ); + + for ( Index = VexExpr->WIDTH; Index < Width; Index++ ) + { + addvexhexpr( VexConcat, dupvexexpr( VexBit ) ); + } + + freevexexpr( VexBit ); + } + + SetVexNodeSigned( VexConcat ); + } + else + { + VexBit = createvexatomveclit( VEX_ZERO, Width - VexExpr->WIDTH ); + addvexhexpr( VexConcat, VexBit ); + } + + VexConcat = simpvexexpr( VexConcat ); + } + else + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + if ( IsVexNodeDown( VexExpr ) ) + { + Left = Width + VexExpr->RIGHT - 1; + } + else + { + Left = VexExpr->RIGHT - Width + 1; + } + + VexConcat = createvexatomvec( GetVexAtomValue( VexExpr ), Left, VexExpr->RIGHT ); + } + else + { + strcpy( VasyBuffer, GetVexAtomValue( VexExpr ) ); + + Left = VexExpr->WIDTH - Width; +/* +** Should Verify the correctness of the sign ... TO BE DONE +*/ + if ( Width > 1 ) VasyBuffer[ Left ] = '"'; + else VasyBuffer[ Left ] = '\''; + + VexConcat = createvexatomlit( &VasyBuffer[ Left ] ); + } + } + + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + RtlAssign = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexConcat; + + freevexexpr( VexExpr ); + VexExpr = dupvexexpr( VexAtom ); + } + else + { + freevexexpr( VexExpr ); + VexExpr = VexConcat; + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexRelational | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexRelational( VexExpr ) + + vexexpr *VexExpr; +{ + rtldecl_list *RtlDecl; + rtldecl_list *RtlDeclCarry; + rtldecl_list *RtlDeclGen; + rtldecl_list *RtlDeclProp; + rtldecl_list *RtlDeclSub; + rtlasg_list *RtlAsgCarry; + rtlasg_list *RtlAsgSub; + rtlasg_list *RtlAsgGen; + rtlasg_list *RtlAsgProp; + vexexpr *Operand1; + vexexpr *Operand2; + vexexpr *Operand3; + vexexpr *VexSub; + vexexpr *VexProp; + vexexpr *VexGen; + vexexpr *VexCarry; + vexexpr *VexAtomCarry; + vexexpr *VexAtomGen; + vexexpr *VexAtomProp; + vexexpr *VexAtomSub; + vexexpr *VexAnd1; + vexexpr *VexAnd2; + vexexpr *VexAnd3; + vexexpr *VexAtom0; + vexexpr *VexAtom1; + vexexpr *VexAtom2; + vexexpr *VexAtom3; + vexexpr *VexAtom4; + vexexpr *VexAtom5; + vexexpr *VexAtom6; + vexexpr *VexAtom7; + char Buffer[ 32 ]; + int MaxWidth; + int Index; + long Oper; + + Oper = GetVexOperValue( VexExpr ); + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Operand2 = GetVexOperand( VexExpr->OPERAND->NEXT ); + + SetVexOperand( VexExpr->OPERAND , (vexexpr *)0 ); + SetVexOperand( VexExpr->OPERAND->NEXT, (vexexpr *)0 ); + + MaxWidth = Operand1->WIDTH; + if ( Operand2->WIDTH > MaxWidth ) MaxWidth = Operand2->WIDTH; + + MaxWidth = MaxWidth + 1; + + Operand1 = VasyAllianceExtendSignVex( Operand1, MaxWidth ); + Operand2 = VasyAllianceExtendSignVex( Operand2, MaxWidth ); + + if ( ( IsVexNodeAtom( Operand1 ) ) && + ( ! IsVexAtomLiteral( Operand1 ) ) ) + { + RtlDecl = searchrtldecl( VasyRtlFigure, GetVexAtomValue( Operand1 ) ); + + if ( RtlDecl != (rtldecl_list *)0 ) + { + SetVasyRtlDeclarRead( RtlDecl ); + SetVasyRtlDeclarAsg( RtlDecl ); + } + } + + if ( ( IsVexNodeAtom( Operand2 ) ) && + ( ! IsVexAtomLiteral( Operand2 ) ) ) + { + RtlDecl = searchrtldecl( VasyRtlFigure, GetVexAtomValue( Operand2 ) ); + + if ( RtlDecl != (rtldecl_list *)0 ) + { + SetVasyRtlDeclarRead( RtlDecl ); + SetVasyRtlDeclarAsg( RtlDecl ); + } + } + + sprintf( Buffer, "rtlcarry_%ld", VasyNumberDef ); + VexAtomCarry = createvexatomvec( Buffer, MaxWidth - 1, 0 ); + + RtlDeclCarry = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomCarry ), RTL_DECLAR_SIGNAL ); + RtlDeclCarry->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclCarry->KIND = RTL_KIND_NONE; + RtlDeclCarry->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclCarry ); + SetVasyRtlDeclarAsg( RtlDeclCarry ); + + sprintf( Buffer, "rtlltgt_%ld", VasyNumberDef ); + VexAtomSub = createvexatombit( Buffer ); + + RtlDeclSub = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomSub ), RTL_DECLAR_SIGNAL ); + RtlDeclSub->BASE = VEX_TYPE_BIT; + RtlDeclSub->KIND = RTL_KIND_NONE; + RtlDeclSub->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclSub ); + SetVasyRtlDeclarAsg( RtlDeclSub ); + + if ( ( VasyFlagCLA ) && + ( MaxWidth >= VasyFlagCLA ) ) + { +/* +** Generation +*/ + sprintf( Buffer, "rtlgen_%ld", VasyNumberDef ); + VexAtomGen = createvexatomvec( Buffer, MaxWidth - 1, 1 ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtomGen ); + + RtlDeclGen = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomGen ), RTL_DECLAR_SIGNAL ); + RtlDeclGen->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclGen->KIND = RTL_KIND_NONE; + RtlDeclGen->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclGen ); + SetVasyRtlDeclarAsg( RtlDeclGen ); +/* +** Propagation +*/ + sprintf( Buffer, "rtlprop_%ld", VasyNumberDef ); + VexAtomProp = createvexatomvec( Buffer, MaxWidth - 1, 1 ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtomProp ); + + RtlDeclProp = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomProp ), RTL_DECLAR_SIGNAL ); + RtlDeclProp->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclProp->KIND = RTL_KIND_NONE; + RtlDeclProp->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclProp ); + SetVasyRtlDeclarAsg( RtlDeclProp ); + } + + VasyNumberDef++; +/* +** The two operands should be transformed to atomic expressions with the same widths +*/ + Operand1 = VasyAllianceTreatVexOperandAtom( Operand1 ); + Operand2 = VasyAllianceTreatVexOperandAtom( Operand2 ); + + if ( ( Oper == VEX_GT ) || + ( Oper == VEX_LE ) ) + { + Operand3 = Operand1; + Operand1 = Operand2; + Operand2 = Operand3; + } + + VexAtom5 = createvexatomvec( GetVexAtomValue( Operand1 ), MaxWidth - 1, MaxWidth - 1 ); + VexAtom6 = createvexatomvec( GetVexAtomValue( Operand2 ), MaxWidth - 1, MaxWidth - 1 ); + VexAtom6 = createvexunaryexpr( VEX_NOT, 1, VexAtom6 ); + VexAtom7 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), MaxWidth -1, MaxWidth - 1 ); + + VexSub = createvexbinexpr( VEX_XOR, 1, VexAtom5, VexAtom6 ); + VexSub = createvexbinexpr( VEX_XOR, 1, VexSub , VexAtom7 ); + + if ( ( Oper == VEX_GE ) || + ( Oper == VEX_LE ) ) + { + VexSub = createvexunaryexpr( VEX_NOT, 1, VexSub ); + } + + RtlAsgSub = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomSub ), RTL_ASG_COMBINATORIAL ); + RtlAsgSub->VEX_DATA = simpvexexpr( VexSub ); + + VexAtom1 = VasyAllianceCreateVexCarry( Operand1 ); + VexAtom2 = VasyAllianceCreateVexCarry( Operand2 ); + VexAtom2 = createvexunaryexpr( VEX_NOT, MaxWidth - 1, VexAtom2 ); +/* +** Carry +*/ + if ( ( VasyFlagCLA ) && + ( MaxWidth >= VasyFlagCLA ) ) + { +/* +** Generation +*/ + VexGen = createvexbinexpr( VEX_AND, MaxWidth - 1, + dupvexexpr( VexAtom1 ), dupvexexpr( VexAtom2 ) ); + + RtlAsgGen = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomGen ), RTL_ASG_COMBINATORIAL ); + RtlAsgGen->VEX_DATA = simpvexexpr( VexGen ); +/* +** Propagation +*/ + VexProp = createvexbinexpr( VEX_OR, MaxWidth - 1, + VexAtom1, VexAtom2 ); + + RtlAsgProp = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtomProp ), + RTL_ASG_COMBINATORIAL ); + RtlAsgProp->VEX_DATA = simpvexexpr( VexProp ); +/* +** Carry-Look ahead +*/ + for ( Index = 1; Index < MaxWidth; Index++ ) + { + VexGen = createvexatomvec( GetVexAtomValue( VexAtomGen ), Index, Index ); + VexProp = createvexatomvec( GetVexAtomValue( VexAtomProp ), Index, Index ); + + if ( Index == 1 ) + { + VexCarry = createvexatomvec( GetVexAtomValue( VexAtomCarry ), 0, 0 ); + } + else + { + VexCarry = dupvexexpr( VexCarry ); + } + + VexCarry = createvexbinexpr( VEX_AND, 1, VexProp , VexCarry ); + VexCarry = createvexbinexpr( VEX_OR , 1, VexCarry, VexGen ); + + VexAtom3 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), Index , Index ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtom3 ); + + RtlAsgCarry = addrtlasg( VasyRtlFigure, VexAtom3, RTL_ASG_COMBINATORIAL ); + RtlAsgCarry->VEX_DATA = VexCarry; + } + } + else + { +/* +** Ripple Carry +*/ + VexAtom3 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), MaxWidth - 2, 0 ); + VexAtom4 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), MaxWidth - 1, 1 ); + + VexAnd1 = createvexbinexpr( VEX_AND, MaxWidth - 1, dupvexexpr( VexAtom1 ), + dupvexexpr( VexAtom2 ) ); + VexAnd2 = createvexbinexpr( VEX_AND, MaxWidth - 1, VexAtom1, dupvexexpr( VexAtom3 ) ); + VexAnd3 = createvexbinexpr( VEX_AND, MaxWidth - 1, VexAtom2, VexAtom3 ); + + VexCarry = createvexbinexpr( VEX_OR, MaxWidth - 1, VexAnd1 , VexAnd2 ); + VexCarry = createvexbinexpr( VEX_OR, MaxWidth - 1, VexCarry, VexAnd3 ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtom4 ); + + RtlAsgCarry = addrtlasg( VasyRtlFigure, VexAtom4, RTL_ASG_COMBINATORIAL ); + RtlAsgCarry->VEX_DATA = simpvexexpr( VexCarry ); + } +/* +** Carry In +*/ + VexAtom0 = createvexatomvec( GetVexAtomValue( VexAtomCarry ), 0, 0 ); + RtlAsgCarry = addrtlasg( VasyRtlFigure, VexAtom0, RTL_ASG_COMBINATORIAL ); + RtlAsgCarry->VEX_DATA = createvexatomlit( VEX_ATOM_ONE ); + + freevexexpr( VexExpr ); + + return( VexAtomSub ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexEqual | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexEqual( VexExpr ) + + vexexpr *VexExpr; +{ + rtldecl_list *RtlDeclNXor; + rtlasg_list *RtlAsgNXor; + vexexpr *Operand1; + vexexpr *Operand2; + vexexpr *VexNXor; + vexexpr *VexAnd; + vexexpr *VexAtomNXor; + vexexpr *VexAtom; + char Buffer[ 32 ]; + int MaxWidth; + int Index; + long Oper; + + if ( ! VasyFlagEqual ) + { + return( VexExpr ); + } + + Oper = GetVexOperValue( VexExpr ); + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Operand2 = GetVexOperand( VexExpr->OPERAND->NEXT ); + + MaxWidth = Operand1->WIDTH; + if ( Operand2->WIDTH > MaxWidth ) MaxWidth = Operand2->WIDTH; + + if ( ( MaxWidth <= 1 ) || + ( MaxWidth < VasyFlagEqual ) ) + { + return( VexExpr ); + } + + sprintf( Buffer, "rtlnxor_%ld", VasyNumberDef++ ); + VexAtomNXor = createvexatomvec( Buffer, MaxWidth - 1, 0 ); + + RtlDeclNXor = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtomNXor ), RTL_DECLAR_SIGNAL ); + RtlDeclNXor->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclNXor->KIND = RTL_KIND_NONE; + RtlDeclNXor->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclNXor ); + SetVasyRtlDeclarAsg( RtlDeclNXor ); +/* +** The two operands should be transformed to atomic expressions with the same widths +*/ + Operand1 = VasyAllianceTreatVexOperandAtom( Operand1 ); + Operand2 = VasyAllianceTreatVexOperandAtom( Operand2 ); + + VexNXor = createvexbinexpr( VEX_NXOR, MaxWidth, + dupvexexpr( Operand1 ), dupvexexpr( Operand2 ) ); + + if ( VasyFlagLax ) VasyAllianceAddKeepSignal( VexAtomNXor ); + + RtlAsgNXor = addrtlasg( VasyRtlFigure, VexAtomNXor, RTL_ASG_COMBINATORIAL ); + RtlAsgNXor->VEX_DATA = VexNXor; + + if ( Oper == VEX_EQ ) VexAnd = createvexoper( VEX_AND , MaxWidth ); + else VexAnd = createvexoper( VEX_NAND, MaxWidth ); + + for ( Index = 0; Index < MaxWidth; Index++ ) + { + VexAtom = createvexatomvec( GetVexAtomValue( VexAtomNXor ), Index, Index ); + addvexhexpr( VexAnd, VexAtom ); + } + + freevexexpr( VexExpr ); + + return( VexAnd ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVexAtomDontCare | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVexAtomDontCare( VexAtom ) + + vexexpr *VexAtom; +{ + char *Value; + int Index; + char Char; + + Value = GetVexAtomValue( VexAtom ); + + for ( Index = 0; Value[ Index ] != '\0'; Index++ ) + { + Char = Value[ Index ]; + + if ( ( Char != '0' ) && + ( Char != '1' ) && + ( Char != '\'' ) && + ( Char != '"' ) ) + { + for ( Index = 0; Value[ Index ] != '\0'; Index++ ) + { + Char = Value[ Index ]; + + if ( ( Char != '0' ) && + ( Char != '1' ) && + ( Char != '\'' ) && + ( Char != '"' ) ) VasyBuffer[ Index ] = '0'; + else VasyBuffer[ Index ] = Char; + } + + VasyBuffer[ Index ] = '\0'; + + Value = namealloc( VasyBuffer ); + SetVexAtomValue( VexAtom, Value ); + + break; + } + } + + return( VexAtom ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyAllianceTreatVex( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanChain; + vexexpr *Operand; + long Oper; + + if ( VexExpr == (vexexpr *)0 ) + { + return( VexExpr ); + } + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( IsVexAtomLiteral( VexExpr ) ) + { + VexExpr = VasyAllianceTreatVexAtomDontCare( VexExpr ); + } + + return( VexExpr ); + } + else + if ( IsVexNodeOper( VexExpr ) ) + { + Oper = GetVexOperValue( VexExpr ); + + if ( ( Oper == VEX_ADD ) || + ( Oper == VEX_SUB ) ) + { + return( VasyAllianceTreatVexArith( VexExpr ) ); + } + else + if ( ( Oper == VEX_LT ) || + ( Oper == VEX_GT ) || + ( Oper == VEX_LE ) || + ( Oper == VEX_GE ) ) + { + return( VasyAllianceTreatVexRelational( VexExpr ) ); + } + else + if ( Oper == VEX_NEG ) + { + return( VasyAllianceTreatVexNeg( VexExpr ) ); + } + else + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) ) + { + return( VasyAllianceTreatVexEqual( VexExpr ) ); + } + else + if ( Oper == VEX_ABS ) + { + return( VasyAllianceTreatVexAbs( VexExpr ) ); + } + } + + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Operand = VasyAllianceTreatVex( Operand ); + SetVexOperand( ScanChain, Operand ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatAsg | +| | +\------------------------------------------------------------*/ + +static void VasyAllianceTreatAsg( RtlAsg ) + + rtlasg_list *RtlAsg; +{ + rtlbivex_list *RtlBiVex; + rtldecl_list *RtlDeclar; + char *Name; + + Name = getvexatomname( RtlAsg->VEX_ATOM ); + + if ( Name == (char *)0 ) return; + + RtlDeclar = searchrtldecl( VasyRtlFigure, Name ); + + if ( ( RtlDeclar == (rtldecl_list *)0 ) || + ( ! IsVasyRtlDeclarUsed( RtlDeclar ) ) ) return; + + VasyRtlAsg = RtlAsg; + + RtlAsg->VEX_DATA = VasyAllianceTreatVex( RtlAsg->VEX_DATA ); + + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + RtlBiVex->VEX_COND = VasyAllianceTreatVex( RtlBiVex->VEX_COND ); + RtlBiVex->VEX_DATA = VasyAllianceTreatVex( RtlBiVex->VEX_DATA ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyAllianceTreatMap | +| | +\------------------------------------------------------------*/ + +static void VasyAllianceTreatMap( RtlInst ) + + rtlins_list *RtlInst; +{ + rtlmap_list **PrevRtlMap; + rtlmap_list *RtlHeadMap; + rtlmap_list *ScanRtlMap; + rtlmap_list *RtlMap; + rtlport_list *RtlPort; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + vexexpr *ScanVexFormal; + vexexpr *VexFormal; + vexexpr *ScanVexActual; + vexexpr *VexActual; + vexexpr *VexAtom; + char *AtomValue; + char *ScanAtomValue; + char Buffer[ 64 ]; + int Type; + int Left; + int Right; + int ScanLeft; + int ScanRight; + int NextStep; + int Modified; +/* +** Check actual port map +*/ + for ( RtlMap = RtlInst->MAP; + RtlMap != (rtlmap_list *)0; + RtlMap = RtlMap->NEXT ) + { + VexFormal = RtlMap->VEX_FORMAL; + AtomValue = GetVexAtomValue( VexFormal ); + RtlPort = searchrtlmodport( VasyRtlFigure, RtlInst->MODEL, AtomValue ); + VexAtom = RtlPort->VEX_ATOM; + + VexActual = RtlMap->VEX_ACTUAL; + + if ( ( ! IsVexNodeAtom( VexActual ) ) || + ( IsVexAtomLiteral( VexActual ) ) ) + { + sprintf( Buffer, "rtl_map_%ld", VasyNumberDef++ ); + + if ( isvextypevector( Type ) ) + { + VexAtom = createvexatomvec( Buffer, VexActual->WIDTH - 1, 0 ); + } + else + { + VexAtom = createvexatombit( Buffer ); + } + + RtlDeclar = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_DECLAR_SIGNAL ); + RtlDeclar->BASE = RtlPort->BASE; + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + RtlAssign = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexActual; + + VexActual = VexAtom; + } + + RtlMap->VEX_ACTUAL = VexActual; + } +/* +** Split formal port map list in two lists : Bit and Vector +*/ + RtlHeadMap = (rtlmap_list *)0; + PrevRtlMap = &RtlInst->MAP; + RtlMap = RtlInst->MAP; + + while ( RtlMap != (rtlmap_list *)0 ) + { + VexFormal = RtlMap->VEX_FORMAL; + AtomValue = GetVexAtomValue( VexFormal ); + RtlPort = searchrtlmodport( VasyRtlFigure, RtlInst->MODEL, AtomValue ); + VexAtom = RtlPort->VEX_ATOM; + + if ( ( IsVexAtomBit( VexAtom ) ) || + ( VexAtom->WIDTH <= 1 ) ) + { + ScanRtlMap = RtlMap->NEXT; + *PrevRtlMap = ScanRtlMap; + + RtlMap->NEXT = RtlHeadMap; + RtlHeadMap = RtlMap; + + RtlMap = ScanRtlMap; + } + else + { + RtlMap->USER = (void *)VexAtom; + + PrevRtlMap = &RtlMap->NEXT; + RtlMap = RtlMap->NEXT; + } + } +/* +** Compact formal port map +*/ + for ( RtlMap = RtlInst->MAP; + RtlMap != (rtlmap_list *)0; + RtlMap = RtlMap->NEXT ) + { + if ( RtlMap->FLAGS ) continue; + + VexFormal = RtlMap->VEX_FORMAL; + AtomValue = GetVexAtomValue( VexFormal ); + Left = VexFormal->LEFT; + Right = VexFormal->RIGHT; + + VexActual = RtlMap->VEX_ACTUAL; + + VexAtom = (vexexpr *)RtlMap->USER; + + if ( IsVexAtomDown( VexAtom ) ) NextStep = -1; + else NextStep = 1; + + Modified = 0; + + for ( ScanRtlMap = RtlInst->MAP; + ScanRtlMap != (rtlmap_list *)0; + ScanRtlMap = ScanRtlMap->NEXT ) + { + if ( ( ScanRtlMap->FLAGS ) || + ( ScanRtlMap == RtlMap ) ) continue; + + ScanVexFormal = ScanRtlMap->VEX_FORMAL; + ScanAtomValue = GetVexAtomValue( ScanVexFormal ); + ScanLeft = ScanVexFormal->LEFT; + ScanRight = ScanVexFormal->RIGHT; + + ScanVexActual = ScanRtlMap->VEX_ACTUAL; + + if ( AtomValue == ScanAtomValue ) + { + if ( Left - NextStep == ScanRight ) + { + Modified = 1; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Should Concat !\n" ); + viewvexexprln( ScanVexFormal ); + viewvexexprln( VexFormal ); + } + + VexFormal->LEFT = ScanVexFormal->LEFT; + VexFormal->WIDTH += ScanVexFormal->WIDTH; + + if ( NextStep == -1 ) SetVexAtomDown( VexFormal ); + else SetVexAtomUp ( VexFormal ); + + VexActual = optimvexbinexpr( VEX_CONCAT, VexActual->WIDTH + ScanVexActual->WIDTH, + dupvexexpr( ScanVexActual ), VexActual ); + + ScanRtlMap->FLAGS = 1; + } + else + if ( Right + NextStep == ScanLeft ) + { + Modified = 1; + + if ( IsVasyDebugLevel1() ) + { + fprintf( stdout, "Should Concat !\n" ); + viewvexexprln( VexFormal ); + viewvexexprln( ScanVexFormal ); + } + + VexFormal->RIGHT = ScanVexFormal->RIGHT; + VexFormal->WIDTH += ScanVexFormal->WIDTH; + + if ( NextStep == -1 ) SetVexAtomDown( VexFormal ); + else SetVexAtomUp ( VexFormal ); + + VexActual = optimvexbinexpr( VEX_CONCAT, VexActual->WIDTH + ScanVexActual->WIDTH, + VexActual, dupvexexpr( ScanVexActual ) ); + + ScanRtlMap->FLAGS = 1; + } + } + } + + if ( Modified ) + { + RtlMap->VEX_FORMAL = VexFormal; + RtlMap->VEX_ACTUAL = simpvexexpr( VexActual ); + } + } +/* +** Concat Bit and Vector port map lists +*/ + *PrevRtlMap = RtlHeadMap; +/* +** Delete old formal port map +*/ + PrevRtlMap = &RtlInst->MAP; + RtlMap = RtlInst->MAP; + + while ( RtlMap != RtlHeadMap ) + { + if ( RtlMap->FLAGS ) + { + ScanRtlMap = RtlMap; + RtlMap = RtlMap->NEXT; + *PrevRtlMap = RtlMap; + + freevexexpr( ScanRtlMap->VEX_FORMAL ); + freevexexpr( ScanRtlMap->VEX_ACTUAL ); + freertlmap( ScanRtlMap ); + } + else + { + PrevRtlMap = &RtlMap->NEXT; + RtlMap->USER = (void *)0; + RtlMap = RtlMap->NEXT; + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceTreatDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceTreatDeclar( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + rtlasg_list *NewAssign; + vexexpr *RegAtom; + vexexpr *VexAtom; + vexexpr *VexDeclar; + vexexpr *VexExpr; + vexexpr *VexInit; + char *AtomValue; + char *AtomName; + char Buffer[ 32 ]; + int Type; + int ScanPos; + char Literal; + + for ( Type = 0; Type < RTL_MAX_DECLAR_TYPE; Type++ ) + { + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + RtlDeclar->BASE = VasyConvertType[ RtlDeclar->BASE ]; + RtlDeclar->KIND = RTL_KIND_NONE; + + if ( Type == RTL_DECLAR_PORT ) + { + if ( RtlDeclar->BASE == VEX_TYPE_REG_VECTOR ) + { + RtlDeclar->BASE = VEX_TYPE_BIT_VECTOR; + } + else + if ( RtlDeclar->BASE == VEX_TYPE_REG_BIT ) + { + RtlDeclar->BASE = VEX_TYPE_BIT; + } + } + + if ( ( RtlDeclar->DIR == RTL_DIR_IN ) || + ( ( ! IsVasyRtlDeclarUsed( RtlDeclar ) ) && + ( Type != RTL_DECLAR_PORT ) ) ) continue; + + VexDeclar = RtlDeclar->VEX_ATOM; + VexInit = RtlDeclar->VEX_INIT; + + AtomName = GetVexAtomValue( VexDeclar ); + + if ( VexInit != (vexexpr *)0 ) AtomValue = GetVexAtomValue( VexInit ); + else AtomValue = (char *)0; + + for ( ScanPos = 0; ScanPos < VexDeclar->WIDTH; ScanPos++ ) + { + RtlSymbol = &RtlDeclar->DECL_SYM[ ScanPos ]; + + if ( ( ( IsVasyRtlDeclarRead( RtlSymbol ) ) || + ( Type == RTL_DECLAR_PORT ) ) && + ( ! IsVasyRtlDeclarAsg( RtlSymbol ) ) ) + { + if ( Type == RTL_DECLAR_PORT ) + { + if ( RtlSymbol->INDEX != -1 ) + { + VasyPrintf( stdout, "WARNING add default assignment for port %s(%d)\n", + RtlSymbol->NAME, RtlSymbol->INDEX ); + } + else + { + VasyPrintf( stdout, "WARNING add default assignment for port %s\n", + RtlSymbol->NAME ); + } + } + + if ( AtomValue != (char *)0 ) Literal = AtomValue[ ScanPos + 1 ]; + else Literal = '0'; + + sprintf( Buffer, "'%c'", Literal ); + VexExpr = createvexatombit( Buffer ); + + if ( RtlSymbol->INDEX != -1 ) + { + VexAtom = createvexatomvec( AtomName, RtlSymbol->INDEX, RtlSymbol->INDEX ); + RtlAsg = addrtlasg( RtlFigure, VexAtom, RTL_ASG_COMBINATORIAL ); + } + else + { + VexAtom = createvexatombit( AtomName ); + RtlAsg = addrtlasg( RtlFigure, VexAtom, RTL_ASG_COMBINATORIAL ); + } + + RtlAsg->VEX_DATA = VexExpr; + } + } + } + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + if ( ( RtlAsg->TYPE == RTL_ASG_REGISTER ) || + ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) ) + { + VexAtom = RtlAsg->VEX_ATOM; + AtomValue = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomValue ); + + if ( RtlAsg->TYPE == RTL_ASG_REGISTER ) + { +/* +** Special treatments for out port registers (they are not authorized in vbe !) +*/ + if ( RtlDeclar->TYPE == RTL_DECLAR_PORT ) + { + sprintf( Buffer, "rtlalc_%ld", VasyNumberDef++ ); + + if ( VexAtom->WIDTH > 1 ) + { + RegAtom = createvexatomvec( Buffer, VexAtom->LEFT, VexAtom->RIGHT ); + } + else + { + RegAtom = createvexatombit( Buffer ); + } + + RtlDeclar = addrtldecl( RtlFigure, dupvexexpr( RegAtom ), RTL_DECLAR_SIGNAL ); + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + RtlDeclar->DIR = RTL_DIR_INOUT; + + if ( VexAtom->WIDTH > 1 ) RtlDeclar->BASE = VEX_TYPE_BIT_VECTOR; + else RtlDeclar->BASE = VEX_TYPE_BIT; + + RtlAsg->VEX_ATOM = dupvexexpr( RegAtom ); + + NewAssign = addrtlasg( RtlFigure, VexAtom, RTL_ASG_COMBINATORIAL ); + NewAssign->VEX_DATA = RegAtom; + + VexAtom = RegAtom; + } + + RtlDeclar->KIND = RTL_KIND_REGISTER; + + if ( isvextypevector( RtlDeclar->BASE ) ) RtlDeclar->BASE = VEX_TYPE_REG_VECTOR; + else RtlDeclar->BASE = VEX_TYPE_REG_BIT; + } + else + { + RtlDeclar->KIND = RTL_KIND_BUS; + + if ( isvextypevector( RtlDeclar->BASE ) ) RtlDeclar->BASE = VEX_TYPE_MUX_VECTOR; + else RtlDeclar->BASE = VEX_TYPE_MUX_BIT; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceTreatFigure | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceTreatFigure( RtlFigure, FileName, PRtlFigureVbe, PRtlFigureVst ) + + + rtlfig_list *RtlFigure; + char *FileName; + rtlfig_list **PRtlFigureVbe; + rtlfig_list **PRtlFigureVst; +{ + rtldecl_list *RtlDeclar; + rtldecl_list *DelDeclar; + rtldecl_list *NewDeclar; + rtldecl_list *PortDeclar; + rtldecl_list **PrevDeclar; + rtlins_list *RtlInst; + rtlmap_list *RtlMap; + rtlmod_list *RtlModel; + rtlport_list *RtlPort; + rtlasg_list *RtlAsg; + vexexpr *VexAtom; + vexexpr *VexActual; + vexexpr *VexFormal; + char *AtomValue; + char *NewName; + char *InsName; + rtlfig_list *NewFigure; + int Type; + int Dir; + + RtlFigure->NAME = namealloc( FileName ); + + *PRtlFigureVbe = (rtlfig_list *)0; + *PRtlFigureVst = (rtlfig_list *)0; + + VasyRtlFigure = RtlFigure; + VasyKeepSignal = (chain_list *)0; + + for ( RtlModel = RtlFigure->MODEL; + RtlModel != (rtlmod_list *)0; + RtlModel = RtlModel->NEXT ) + { + for ( RtlPort = RtlModel->PORT; + RtlPort != (rtlport_list *)0; + RtlPort = RtlPort->NEXT ) + { + RtlPort->BASE = VasyConvertType[ RtlPort->BASE ]; + } + } + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + VasyAllianceTreatMap( RtlInst ); + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VasyAllianceTreatAsg( RtlAsg ); + } + + VasyDriveAllianceTreatDeclar( RtlFigure ); + + if ( RtlFigure->MODEL != (rtlmod_list *)0 ) + { + if ( RtlFigure->ASSIGN == (rtlasg_list *)0 ) + { + *PRtlFigureVst = RtlFigure; + RtlFigure->NAME = namealloc( FileName ); + } + else + { + *PRtlFigureVst = RtlFigure; + + NewName = autallocblock( strlen( FileName ) + 10 ); + sprintf( NewName, "%s_model", FileName ); + + NewFigure = addrtlfig( NewName ); + + autfreeblock( NewName ); + NewName = NewFigure->NAME; + + *PRtlFigureVbe = NewFigure; + + NewFigure->ASSIGN = RtlFigure->ASSIGN; + RtlFigure->ASSIGN = (rtlasg_list *)0; + + for ( Type = 0; Type < RTL_MAX_DECLAR_TYPE; Type++ ) + { + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + ClearVasyRtlDeclarUsed( RtlDeclar ); + + VexAtom = dupvexexpr( RtlDeclar->VEX_ATOM ); + NewDeclar = addrtldecl( NewFigure, VexAtom, RtlDeclar->TYPE ); + + NewDeclar->DIR = RtlDeclar->DIR; + NewDeclar->KIND = RtlDeclar->KIND; + NewDeclar->BASE = RtlDeclar->BASE; + NewDeclar->FLAGS = RtlDeclar->FLAGS; + + if ( ( Type == RTL_DECLAR_PORT ) && + ( VasyFlagPower ) && + ( IsVexNodeAtom( VexAtom ) ) ) + { + AtomValue = GetVexAtomValue( VexAtom ); + + if ( ( AtomValue == VasyPowerVdd ) || + ( AtomValue == VasyPowerVss ) ) + { + SetVasyRtlDeclarRead( NewDeclar ); + } + } + else + if ( Type == RTL_DECLAR_CONSTANT ) + { + NewDeclar->VEX_INIT = dupvexexpr( RtlDeclar->VEX_INIT ); + } + } + } + + VasySimplifyRtlFig( NewFigure ); + VasySimplifyRtlFig( RtlFigure ); + + PrevDeclar = &NewFigure->DECLAR[ RTL_DECLAR_SIGNAL ]; + NewDeclar = NewFigure->DECLAR[ RTL_DECLAR_SIGNAL ]; + + while ( NewDeclar != (rtldecl_list *)0 ) + { + if ( IsVasyRtlDeclarUsed( NewDeclar ) ) + { + VexAtom = NewDeclar->VEX_ATOM; + AtomValue = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomValue ); + + if ( ( RtlDeclar != (rtldecl_list *)0 ) && + ( IsVasyRtlDeclarUsed( RtlDeclar ) ) ) + { + Dir = RTL_DIR_OUT; + + if ( ( IsVasyRtlDeclarAsg( NewDeclar ) ) && + ( IsVasyRtlDeclarRead( NewDeclar ) ) ) Dir = RTL_DIR_INOUT; + else + if ( IsVasyRtlDeclarRead( NewDeclar ) ) Dir = RTL_DIR_IN; + + PortDeclar = NewDeclar; + PortDeclar->DIR = Dir; + PortDeclar->TYPE = RTL_DECLAR_PORT; + + *PrevDeclar = NewDeclar->NEXT; + NewDeclar = NewDeclar->NEXT; + + PortDeclar->NEXT = NewFigure->DECLAR[ RTL_DECLAR_PORT ]; + NewFigure->DECLAR[ RTL_DECLAR_PORT ] = PortDeclar; + + continue; + } + } + + PrevDeclar = &NewDeclar->NEXT; + NewDeclar = NewDeclar->NEXT; + } + + InsName = autallocblock( strlen( FileName ) + 10 ); + sprintf( InsName, "%s_inst", FileName ); + + RtlModel = addrtlmod( RtlFigure, NewName ); + RtlInst = addrtlins( RtlFigure, InsName, RtlModel ); + + autfreeblock( InsName ); + InsName = RtlInst->NAME; + + NewDeclar = NewFigure->DECLAR[ RTL_DECLAR_PORT ]; + PrevDeclar = &NewFigure->DECLAR[ RTL_DECLAR_PORT ]; + + while ( NewDeclar != (rtldecl_list *)0 ) + { + if ( ! IsVasyRtlDeclarUsed( NewDeclar ) ) + { + VexAtom = NewDeclar->VEX_ATOM; + AtomValue = GetVexAtomValue( VexAtom ); + + freevexexpr( NewDeclar->VEX_ATOM ); + freevexexpr( NewDeclar->VEX_INIT ); + freertlsym( NewDeclar->DECL_SYM ); + + DelDeclar = NewDeclar; + NewDeclar = NewDeclar->NEXT; + *PrevDeclar = NewDeclar; + + delauthelem( NewFigure->HASH_DECLAR, AtomValue ); + + freertldecl( DelDeclar ); + } + else + { + PrevDeclar = &NewDeclar->NEXT; + NewDeclar = NewDeclar->NEXT; + } + } + + VasyDriveAllianceTreatDeclar( NewFigure ); + + for ( NewDeclar = NewFigure->DECLAR[ RTL_DECLAR_PORT ]; + NewDeclar != (rtldecl_list *)0; + NewDeclar = NewDeclar->NEXT ) + { + Dir = RTL_DIR_OUT; + + if ( ( IsVasyRtlDeclarAsg( NewDeclar ) ) && + ( IsVasyRtlDeclarRead( NewDeclar ) ) ) Dir = RTL_DIR_INOUT; + else + if ( IsVasyRtlDeclarRead( NewDeclar ) ) Dir = RTL_DIR_IN; + + NewDeclar->DIR = Dir; + + VexAtom = dupvexexpr( NewDeclar->VEX_ATOM ); + RtlPort = addrtlmodport( RtlFigure, RtlModel, VexAtom, + NewDeclar->BASE, NewDeclar->DIR ); + + VexFormal = dupvexexpr( NewDeclar->VEX_ATOM ); + VexActual = dupvexexpr( NewDeclar->VEX_ATOM ); + + RtlMap = addrtlinsmap( RtlFigure, RtlInst, VexFormal, VexActual ); + } + } +/* +** In a vst figure REG_BIT and REG_VECTOR are not supported ! +*/ + for ( Type = 0; Type < RTL_MAX_DECLAR_TYPE; Type++ ) + { + for ( RtlDeclar = (*PRtlFigureVst)->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + if ( RtlDeclar->BASE == VEX_TYPE_REG_VECTOR ) + { + RtlDeclar->BASE = VEX_TYPE_BIT_VECTOR; + RtlDeclar->KIND = RTL_KIND_NONE; + } + else + if ( RtlDeclar->BASE == VEX_TYPE_REG_BIT ) + { + RtlDeclar->BASE = VEX_TYPE_BIT; + RtlDeclar->KIND = RTL_KIND_NONE; + } + } + } + } + else + { + *PRtlFigureVbe = RtlFigure; + RtlFigure->NAME = namealloc( FileName ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAlliancePort | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAlliancePort( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + vexexpr *VexPort; + char *PortName; + char *PortDir; + char *PortBase; + char *PortKind; + char *PortVecDir; + + RtlDeclar = RtlFigure->DECLAR[ RTL_DECLAR_PORT ]; + + if ( RtlDeclar != (rtldecl_list *)0 ) + { + fprintf( VasyFile, "PORT(\n" ); + + while ( RtlDeclar != (rtldecl_list *)0 ) + { + VexPort = RtlDeclar->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + PortDir = RTL_DIR_TYPE[ RtlDeclar->DIR ]; + PortKind = RTL_KIND_TYPE[ RtlDeclar->KIND ]; + PortBase = VEX_TYPE_NAME[ RtlDeclar->BASE ]; + + fprintf( VasyFile, " %s\t: %s %s", PortName, PortDir, PortBase ); + + if ( isvextypevector( RtlDeclar->BASE ) ) + { + if ( IsVexAtomUp( VexPort ) ) PortVecDir = "TO"; + else PortVecDir = "DOWNTO"; + + fprintf( VasyFile, "(%d %s %d)", VexPort->LEFT, PortVecDir, VexPort->RIGHT ); + } + + if ( RtlDeclar->KIND != RTL_KIND_NONE ) fprintf( VasyFile, " %s", PortKind ); + + if ( RtlDeclar->NEXT != (rtldecl_list *)0 ) + { + fprintf( VasyFile, ";\n" ); + } + + RtlDeclar = RtlDeclar->NEXT; + } + + fprintf( VasyFile, "\n);\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceDeclar( RtlFigure, Type ) + + rtlfig_list *RtlFigure; + int Type; +{ + rtldecl_list *RtlDeclar; + vexexpr *VexDeclar; + char *AtomValue; + vexexpr *VexInit; + char *DeclarName; + char *DeclarDir; + char *DeclarBase; + char *DeclarVecDir; + char *DeclarKind; + + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + if ( ! IsVasyRtlDeclarUsed( RtlDeclar ) ) continue; + + VexDeclar = RtlDeclar->VEX_ATOM; + VexInit = RtlDeclar->VEX_INIT; + DeclarName = GetVexAtomValue( VexDeclar ); + DeclarDir = RTL_DIR_TYPE[ RtlDeclar->DIR ]; + DeclarBase = VEX_TYPE_NAME[ RtlDeclar->BASE ]; + DeclarKind = RTL_KIND_TYPE[ RtlDeclar->KIND ]; + + if ( Type == RTL_DECLAR_CONSTANT ) + { + fprintf( VasyFile, " CONSTANT %s\t: %s", DeclarName, DeclarBase ); + } + else + { + fprintf( VasyFile, " SIGNAL %s\t: %s", DeclarName, DeclarBase ); + } + + if ( isvextypevector( RtlDeclar->BASE ) ) + { + if ( IsVexAtomUp( VexDeclar ) ) DeclarVecDir = "TO"; + else DeclarVecDir = "DOWNTO"; + + fprintf( VasyFile, "(%d %s %d)", VexDeclar->LEFT, DeclarVecDir, VexDeclar->RIGHT ); + } + + if ( RtlDeclar->KIND != RTL_KIND_NONE ) fprintf( VasyFile, " %s", DeclarKind ); + + if ( Type == RTL_DECLAR_CONSTANT ) + { + fprintf( VasyFile, " := " ); + + if ( RtlDeclar->BASE == VEX_TYPE_BOOLEAN ) + { + if ( IsVexNodeAtom( VexInit ) ) + { + AtomValue = GetVexAtomValue( VexInit ); + + if ( AtomValue == VEX_ATOM_ONE ) fprintf( VasyFile, " TRUE" ); + else fprintf( VasyFile, " FALSE" ); + } + else + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexInit ); + } + } + else + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexInit ); + } + } + + fprintf( VasyFile, ";\n" ); + + if ( RtlDeclar->NEXT == (rtldecl_list *)0 ) + { + fprintf( VasyFile, "\n" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceFsmDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceFsmDeclar( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlfsm_list *RtlFsm; + rtlfsmstate_list *RtlState; + + for ( RtlFsm = RtlFigure->FSM; + RtlFsm != (rtlfsm_list *)0; + RtlFsm = RtlFsm->NEXT ) + { + fprintf( VasyFile, " TYPE STATE_TYPE_%s IS (", RtlFsm->NAME ); + + for ( RtlState = RtlFsm->STATE; + RtlState != (rtlfsmstate_list *)0; + RtlState = RtlState->NEXT ) + { + fprintf( VasyFile, " %s", RtlState->NAME ); + + if ( RtlState->NEXT != (rtlfsmstate_list *)0 ) + { + fprintf( VasyFile, "," ); + } + } + + fprintf( VasyFile, " );\n" ); + fprintf( VasyFile, " SIGNAL CS_%s : STATE_TYPE_%s;\n\n", RtlFsm->NAME, RtlFsm->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceComponent | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceComponent( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlmod_list *RtlModel; + rtlport_list *RtlPort; + vexexpr *VexPort; + char *PortName; + char *PortDir; + char *PortBase; + char *PortVecDir; + + for ( RtlModel = RtlFigure->MODEL; + RtlModel != (rtlmod_list *)0; + RtlModel = RtlModel->NEXT ) + { + fprintf( VasyFile, " COMPONENT %s\n", RtlModel->NAME ); + + RtlPort = RtlModel->PORT; + + if ( RtlPort != (rtlport_list *)0 ) + { + fprintf( VasyFile, " PORT(\n" ); + + while ( RtlPort != (rtlport_list *)0 ) + { + VexPort = RtlPort->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + PortDir = RTL_DIR_TYPE[ RtlPort->DIR ]; + PortBase = VEX_TYPE_NAME[ RtlPort->BASE ]; + + fprintf( VasyFile, " %s\t: %s %s", PortName, PortDir, PortBase ); + + if ( isvextypevector( RtlPort->BASE ) ) + { + if ( IsVexAtomUp( VexPort ) ) PortVecDir = "TO"; + else PortVecDir = "DOWNTO"; + + fprintf( VasyFile, "(%d %s %d)", VexPort->LEFT, PortVecDir, VexPort->RIGHT ); + } + + if ( ( RtlPort->BASE == VEX_TYPE_MUX_BIT ) || + ( RtlPort->BASE == VEX_TYPE_MUX_VECTOR ) || + ( RtlPort->BASE == VEX_TYPE_WOR_BIT ) || + ( RtlPort->BASE == VEX_TYPE_WOR_VECTOR ) ) + { + fprintf( VasyFile, " %s ", RTL_KIND_TYPE[ RTL_KIND_BUS ] ); + } + + if ( RtlPort->NEXT != (rtlport_list *)0 ) + { + fprintf( VasyFile, ";\n" ); + } + + RtlPort = RtlPort->NEXT; + } + + fprintf( VasyFile, "\n );\n" ); + } + + fprintf( VasyFile, " END COMPONENT;\n\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAlliancePortMap | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAlliancePortMap( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlmod_list *RtlModel; + rtlins_list *RtlInst; + rtlmap_list *RtlMap; + vexexpr *VexFormal; + vexexpr *VexActual; + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + RtlModel = RtlInst->MODEL; + + fprintf( VasyFile, " %s : %s\n", RtlInst->NAME, RtlModel->NAME ); + fprintf( VasyFile, " PORT MAP (\n" ); + RtlMap = RtlInst->MAP; + + while ( RtlMap != (rtlmap_list *)0 ) + { + VexFormal = RtlMap->VEX_FORMAL; + VexActual = RtlMap->VEX_ACTUAL; + + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexFormal ); + fprintf( VasyFile, " => " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexActual ); + + if ( RtlMap->NEXT != (rtlmap_list *)0 ) + { + fprintf( VasyFile, ",\n" ); + } + + RtlMap = RtlMap->NEXT; + } + + fprintf( VasyFile, "\n );\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceEntity | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceEntity( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + fprintf( VasyFile, "--\n" ); + fprintf( VasyFile, "-- Generated by VASY\n" ); + fprintf( VasyFile, "--\n" ); + + fprintf( VasyFile, "ENTITY %s IS\n", RtlFigure->NAME ); + + VasyDriveAlliancePort( RtlFigure ); + + fprintf( VasyFile, "END %s;\n\n", RtlFigure->NAME ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceGetVexCond | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceVexCond( RtlFigure, VexExpr, Positive ) + + rtlfig_list *RtlFigure; + vexexpr *VexExpr; + int Positive; +{ + vexexpr *VexCond; + long Oper; + char CharEqual0; + char CharEqual1; + char CharEqual; + + VexCond = VexExpr; + + if ( Positive ) + { + CharEqual0 = '0'; + CharEqual1 = '1'; + } + else + { + CharEqual0 = '1'; + CharEqual1 = '0'; + } + + CharEqual = CharEqual1; + + if ( IsVexNodeOper( VexCond ) ) + { + Oper = GetVexOperValue( VexCond ); + + if ( Oper == VEX_NOT ) + { + CharEqual = CharEqual0; + VexCond = dupvexexpr( GetVexOperand( VexCond->OPERAND ) ); + } + else + if ( isvexnegativeoper( Oper ) ) + { + CharEqual = CharEqual0; + Oper = getvexnotoper( Oper ); + VexCond = dupvexexpr( VexCond ); + + SetVexOperValue( VexCond, Oper ); + } + } + + fprintf( VasyFile, "(" ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexCond ); + fprintf( VasyFile, " = '%c')", CharEqual ); + + if ( VexCond != VexExpr ) + { + freevexexpr( VexCond ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceAssign | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceAssign( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg; + rtlbivex_list *ScanBiVex; + vexexpr *VexAtom; + vexexpr *VexSumAsync; + vexexpr *VexData; + vexexpr *VexAsync; + vexexpr *VexSync; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + if ( RtlAsg->TYPE == RTL_ASG_COMBINATORIAL ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + else + if ( RtlAsg->TYPE == RTL_ASG_MULTIPLEXOR ) + { + fprintf( VasyFile, " WITH " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_DATA ); + fprintf( VasyFile, " SELECT\n " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_DATA ); + fprintf( VasyFile, " WHEN " ); + + if ( ScanBiVex->VEX_COND != (vexexpr *)0 ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + } + else + { + fprintf( VasyFile, " OTHERS " ); + } + + if ( ScanBiVex->NEXT != (rtlbivex_list *)0 ) + { + fprintf( VasyFile, ",\n " ); + } + } + + fprintf( VasyFile, ";\n" ); + } + else + if ( RtlAsg->TYPE == RTL_ASG_CONDITIONAL ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_DATA ); + + if ( ScanBiVex->NEXT != (rtlbivex_list *)0 ) + { + fprintf( VasyFile, " WHEN " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, " ELSE\n " ); + } + } + + fprintf( VasyFile, ";\n" ); + } + else + if ( ( RtlAsg->TYPE == RTL_ASG_REGISTER ) || + ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) ) + { + VexAtom = RtlAsg->VEX_ATOM; + VexSumAsync = (vexexpr *)0; + + ScanBiVex = RtlAsg->BIVEX; + + while ( ScanBiVex != (rtlbivex_list *)0 ) + { + VexData = ScanBiVex->VEX_DATA; + VexAsync = (vexexpr *)0; + + if ( ScanBiVex->TYPE == RTL_BIVEX_ASYNC_RESET ) + { + VexAsync = ScanBiVex->VEX_COND; + VexData = createvexatomveclit( VEX_ZERO, VexAtom->WIDTH ); + } + else + if ( ScanBiVex->TYPE == RTL_BIVEX_ASYNC_SET ) + { + VexAsync = ScanBiVex->VEX_COND; + VexData = createvexatomveclit( VEX_ONE, VexAtom->WIDTH ); + } + else + if ( ScanBiVex->TYPE == RTL_BIVEX_ASYNC_WEN ) + { + VexAsync = ScanBiVex->VEX_COND; + } + else break; + + fprintf( VasyFile, " LABEL%ld : BLOCK ", VasyNumberBlock ); + VasyDriveAllianceVexCond( RtlFigure, VexAsync, 1 ); + fprintf( VasyFile, "\n" ); + fprintf( VasyFile, " BEGIN\n" ); + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexAtom ); + fprintf( VasyFile, " <= GUARDED " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexData ); + fprintf( VasyFile, ";\n" ); + fprintf( VasyFile, " END BLOCK LABEL%ld;\n", VasyNumberBlock ); + VasyNumberBlock++; + + if ( VexAsync != (vexexpr *)0 ) + { + if ( VexSumAsync == (vexexpr *)0 ) + { + VexSumAsync = dupvexexpr( VexAsync ); + } + else + { + VexSumAsync = optimvexbinexpr( VEX_OR, 1, VexSumAsync, dupvexexpr( VexAsync ) ); + } + } + + if ( VexData != ScanBiVex->VEX_DATA ) + { + freevexexpr( VexData ); + } + + ScanBiVex = ScanBiVex->NEXT; + } + + if ( ( ScanBiVex != (rtlbivex_list *)0 ) && + ( RtlAsg->TYPE != RTL_ASG_TRISTATE ) ) + { + fprintf( VasyFile, " LABEL%ld : BLOCK ", VasyNumberBlock ); + fprintf( VasyFile, " (" ); + + if ( VexSumAsync != (vexexpr *)0 ) + { + fprintf( VasyFile, " (" ); + VasyDriveAllianceVexCond( RtlFigure, VexSumAsync, 0 ); + fprintf( VasyFile, " AND " ); + } + + if ( ScanBiVex->TYPE == RTL_BIVEX_FALLING_EDGE ) + { + VasyDriveAllianceVexCond( RtlFigure, ScanBiVex->VEX_COND, 0 ); + fprintf( VasyFile, " AND NOT(" ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, "'STABLE)" ); + } + else + if ( ScanBiVex->TYPE == RTL_BIVEX_RISING_EDGE ) + { + VasyDriveAllianceVexCond( RtlFigure, ScanBiVex->VEX_COND, 1 ); + fprintf( VasyFile, " AND NOT(" ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, "'STABLE)" ); + } + + if ( VexSumAsync != (vexexpr *)0 ) + { + fprintf( VasyFile, " )" ); + freevexexpr( VexSumAsync ); + } + + fprintf( VasyFile, " )\n" ); + fprintf( VasyFile, " BEGIN\n" ); + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexAtom ); + fprintf( VasyFile, " <= GUARDED " ); + + ScanBiVex = ScanBiVex->NEXT; + + while ( ScanBiVex != (rtlbivex_list *)0 ) + { + VexData = ScanBiVex->VEX_DATA; + + if ( ScanBiVex->TYPE == RTL_BIVEX_SYNC_RESET ) + { + VexSync = ScanBiVex->VEX_COND; + VexData = createvexatomveclit( VEX_ZERO, VexAtom->WIDTH ); + } + else + if ( ScanBiVex->TYPE == RTL_BIVEX_SYNC_SET ) + { + VexSync = ScanBiVex->VEX_COND; + VexData = createvexatomveclit( VEX_ONE, VexAtom->WIDTH ); + } + else + if ( ScanBiVex->TYPE == RTL_BIVEX_SYNC_WEN ) + { + VexSync = ScanBiVex->VEX_COND; + } + else break; + + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexData ); + + if ( VexSync != (vexexpr *)0 ) + { + fprintf( VasyFile, " WHEN " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexSync ); + + if ( ScanBiVex->NEXT != (rtlbivex_list *)0 ) + { + fprintf( VasyFile, " ELSE\n " ); + } + else + { + fprintf( VasyFile, " ELSE " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexAtom ); + } + } + + if ( VexData != ScanBiVex->VEX_DATA ) + { + freevexexpr( VexData ); + } + + ScanBiVex = ScanBiVex->NEXT; + } + + fprintf( VasyFile, ";\n" ); + fprintf( VasyFile, " END BLOCK LABEL%ld;\n", VasyNumberBlock ); + VasyNumberBlock++; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceFsm | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceFsm( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlfsm_list *RtlFsm; + rtlfsmstate_list *FsmState; + rtlfsmtrans_list *FsmTrans; + int ElseIf; + rtlfsmasg_list *FsmAsg; + chain_list *Support; + chain_list *ScanChain; + + for ( RtlFsm = RtlFigure->FSM; + RtlFsm != (rtlfsm_list *)0; + RtlFsm = RtlFsm->NEXT ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "Driver Alliance: FSM" ); +/* +** Drive The transition process +*/ + fprintf( VasyFile, " PROCESS ( " ); + + /* TO BE DONE + Support = getvexexprsupport( RtlFsm->VEX_COND ); + Support = unionvexexprsupport( Support, RtlFsm->VEX_WEN ); + */ + Support = (chain_list *)0; + + for ( ScanChain = Support; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + fprintf( VasyFile, "%s", (char *)ScanChain->DATA ); + + if ( ScanChain->NEXT != (chain_list *)0 ) + { + fprintf( VasyFile, ", " ); + } + } + + freechain( Support ); + + fprintf( VasyFile, " )\n" ); + fprintf( VasyFile, " BEGIN\n" ); + + /* TO BE DONE + fprintf( VasyFile, " IF (" ); + VasyDriveAllianceVexCond( RtlFigure, RtlFsm->VEX_COND ); + fprintf( VasyFile, " AND " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlFsm->VEX_EDGE ); + fprintf( VasyFile, ")\n" ); + fprintf( VasyFile, " THEN\n" ); + + if ( RtlFsm->VEX_WEN != (vexexpr *)0 ) + { + fprintf( VasyFile, "\n" ); + fprintf( VasyFile, " IF " ); + VasyDriveAllianceVexCond( RtlFigure, RtlFsm->VEX_WEN ); + fprintf( VasyFile, "\n" ); + fprintf( VasyFile, " THEN\n" ); + } + */ + + fprintf( VasyFile, " CASE ( CS_%s ) IS\n", RtlFsm->NAME ); + + for ( FsmState = RtlFsm->STATE; + FsmState != (rtlfsmstate_list *)0; + FsmState = FsmState->NEXT ) + { + fprintf( VasyFile, "\n WHEN %s =>\n\n", FsmState->NAME ); + + ElseIf = 0; + + for ( ScanChain = FsmState->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + FsmTrans = GetRtlFsmTrans( ScanChain ); + + if ( FsmTrans->VEX_COND != (vexexpr *)0 ) + { + if ( ! ElseIf ) + { + fprintf( VasyFile, " IF " ); + } + else + if ( ScanChain->NEXT != (chain_list *)0 ) + { + fprintf( VasyFile, " ELSIF " ); + } + else + { + fprintf( VasyFile, " ELSE\n" ); + } + + if ( ScanChain->NEXT != (chain_list *)0 ) + { + VasyDriveAllianceVexCond( RtlFigure, FsmTrans->VEX_COND ); + fprintf( VasyFile, "\n THEN\n" ); + } + + ElseIf = 1; + } + + fprintf( VasyFile, " CS_%s <= %s;\n", RtlFsm->NAME, FsmTrans->TO->NAME ); + + for ( FsmAsg = FsmTrans->ASSIGN; + FsmAsg != (rtlfsmasg_list *)0; + FsmAsg = FsmAsg->NEXT ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, FsmAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, FsmAsg->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + } + + if ( ElseIf ) + { + fprintf( VasyFile, " END IF;\n" ); + } + } + + fprintf( VasyFile, "\n END CASE;\n" ); + + /* TO BE DONE + if ( RtlFsm->VEX_WEN != (vexexpr *)0 ) + { + fprintf( VasyFile, " END IF;\n" ); + } + */ + + fprintf( VasyFile, " END IF;\n" ); + fprintf( VasyFile, " END PROCESS;\n\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceArchi | +| | +\------------------------------------------------------------*/ + +static void VasyDriveAllianceArchi( RtlFigure, ArchName ) + + rtlfig_list *RtlFigure; + char *ArchName; +{ + fprintf( VasyFile, "ARCHITECTURE %s OF %s IS\n\n", ArchName, RtlFigure->NAME ); + + VasyDriveAllianceDeclar( RtlFigure, RTL_DECLAR_CONSTANT ); + VasyDriveAllianceDeclar( RtlFigure, RTL_DECLAR_SIGNAL ); + VasyDriveAllianceFsmDeclar( RtlFigure ); + VasyDriveAllianceComponent( RtlFigure ); + + fprintf( VasyFile, "BEGIN\n\n" ); + + VasyDriveAllianceAssign( RtlFigure ); + VasyDriveAllianceFsm( RtlFigure ); + VasyDriveAlliancePortMap( RtlFigure ); + + fprintf( VasyFile, "END %s;\n", ArchName ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveAllianceRtlFig | +| | +\------------------------------------------------------------*/ + +void VasyDriveAllianceRtlFig( RtlFigure, FileName ) + + rtlfig_list *RtlFigure; + char *FileName; +{ + rtlfig_list *RtlFigureVbe; + rtlfig_list *RtlFigureVst; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyDriveAllianceRtlFig %s\n", FileName ); + } +/* +** Special treatments for Alliance +*/ + VasyDriveAllianceTreatFigure( RtlFigure, FileName, &RtlFigureVbe, &RtlFigureVst ); +/* +** Drive behavioral description +*/ + if ( RtlFigureVbe != (rtlfig_list *)0 ) + { + if ( IsVasyDebugDriveStdout() ) + { + VasyFile = stdout; + } + else + { +/* +** First checks to avoid overwriting an existing file ! +*/ + if ( ! VasyFlagOver ) + { + VasyFile = mbkfopen( RtlFigureVbe->NAME, "vbe", "r" ); + + if ( VasyFile != (FILE *)0 ) + { + fclose( VasyFile ); + VasyPrintf( stdout, "ERROR file %s.vbe already exists, remove it first !\n", + RtlFigureVbe->NAME ); + autexit( 1 ); + } + } + + VasyFile = mbkfopen( RtlFigureVbe->NAME, "vbe", "w" ); + } + + if ( VasyFile != (FILE *)0 ) + { + VasyDriveAllianceEntity( RtlFigureVbe ); + VasyDriveAllianceArchi( RtlFigureVbe, "VBE" ); + + if ( ! IsVasyDebugDriveStdout() ) + { + fclose( VasyFile ); + } + } + else + { + VasyPrintf( stdout, "ERROR unable to open file %s.vbe for writting\n", + RtlFigureVbe->NAME ); + autexit( 1 ); + } + + if ( VasyFlagLax ) + { + if ( IsVasyDebugDriveStdout() ) + { + VasyLaxFile = stdout; + } + else + { + if ( ! VasyFlagOver ) + { + VasyLaxFile = mbkfopen( RtlFigureVbe->NAME, "lax", "r" ); + + if ( VasyLaxFile != (FILE *)0 ) + { + fclose( VasyLaxFile ); + VasyPrintf( stdout, "ERROR file %s.lax already exists, remove it first !\n", + RtlFigureVbe->NAME ); + autexit( 1 ); + } + } + + VasyLaxFile = mbkfopen( RtlFigureVbe->NAME, "lax", "w" ); + } + + if ( VasyLaxFile == (FILE *)0 ) + { + VasyPrintf( stdout, "ERROR unable to open file %s.lax for writting\n", + RtlFigureVbe->NAME ); + autexit( 1 ); + } + + VasyAllianceDriveLaxFile(); + + if ( ! IsVasyDebugDriveStdout() ) + { + fclose( VasyLaxFile ); + } + } + + if ( VasyFlagBoom ) + { + if ( IsVasyDebugDriveStdout() ) + { + VasyBoomFile = stdout; + } + else + { + if ( ! VasyFlagOver ) + { + VasyBoomFile = mbkfopen( RtlFigureVbe->NAME, "boom", "r" ); + + if ( VasyBoomFile != (FILE *)0 ) + { + fclose( VasyBoomFile ); + VasyPrintf( stdout, "ERROR file %s.boom already exists, remove it first !\n", + RtlFigureVbe->NAME ); + autexit( 1 ); + } + } + + VasyBoomFile = mbkfopen( RtlFigureVbe->NAME, "boom", "w" ); + } + + if ( VasyBoomFile == (FILE *)0 ) + { + VasyPrintf( stdout, "ERROR unable to open file %s.boom for writting\n", + RtlFigureVbe->NAME ); + autexit( 1 ); + } + + VasyAllianceDriveBoomFile(); + + if ( ! IsVasyDebugDriveStdout() ) + { + fclose( VasyBoomFile ); + } + } + } + + if ( RtlFigureVst != (rtlfig_list *)0 ) + { + if ( IsVasyDebugDriveStdout() ) + { + VasyFile = stdout; + } + else + { +/* +** First checks to avoid overwriting an existing file ! +*/ + if ( ! VasyFlagOver ) + { + VasyFile = mbkfopen( RtlFigureVst->NAME, "vst", "r" ); + + if ( VasyFile != (FILE *)0 ) + { + fclose( VasyFile ); + VasyPrintf( stdout, "ERROR file %s.vst already exists, remove it first !\n", + RtlFigureVst->NAME ); + autexit( 1 ); + } + } + + VasyFile = mbkfopen( RtlFigureVst->NAME, "vst", "w" ); + } + + if ( VasyFile != (FILE *)0 ) + { + VasyDriveAllianceEntity( RtlFigureVst ); + VasyDriveAllianceArchi( RtlFigureVst, "VST" ); + + if ( ! IsVasyDebugDriveStdout() ) + { + fclose( VasyFile ); + } + } + else + { + VasyPrintf( stdout, "ERROR unable to open file %s.vst for writting\n", + RtlFigureVst->NAME ); + autexit( 1 ); + } + } + + VasyAllianceFreeKeepSignal(); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyDriveAllianceRtlFig %s\n\n", FileName ); + } +} diff --git a/alliance/src/vasy/src/vasy_drvalc.h b/alliance/src/vasy/src/vasy_drvalc.h new file mode 100644 index 00000000..27def47b --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvalc.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvalc.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_DRVALC_H +# define VASY_DRVALC_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyDriveAllianceRtlFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_drvrtl.c b/alliance/src/vasy/src/vasy_drvrtl.c new file mode 100644 index 00000000..db6d20c8 --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvrtl.c @@ -0,0 +1,131 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvrtl.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" +# include "rtd.h" + +# include "vasy_debug.h" +# include "vasy_error.h" +# include "vasy_simprtl.h" +# include "vasy_shared.h" +# include "vasy_drvrtl.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyDriveRtlCheck | +| | +\------------------------------------------------------------*/ + +static void VasyDriveRtlCheck( RtlFigure ) + + rtlfig_list *RtlFigure; +{ +} + +/*------------------------------------------------------------\ +| | +| VasyDriveRtlRtlFig | +| | +\------------------------------------------------------------*/ + +void VasyDriveRtlRtlFig( RtlFigure, FileName ) + + rtlfig_list *RtlFigure; + char *FileName; +{ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyDriveRtlRtlFig %s\n", FileName ); + } + + RtlFigure->NAME = namealloc( FileName ); + + VasyDriveRtlCheck( RtlFigure ); + savertlfig( RtlFigure ); + + if ( IsVasyDebugLevel1() ) + { + viewrtlfig( RtlFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyDriveRtlRtlFig %s\n\n", FileName ); + } +} diff --git a/alliance/src/vasy/src/vasy_drvrtl.h b/alliance/src/vasy/src/vasy_drvrtl.h new file mode 100644 index 00000000..f47c11fc --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvrtl.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvrtl.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_DRVRTL_H +# define VASY_DRVRTL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyDriveRtlRtlFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_drvsyn.c b/alliance/src/vasy/src/vasy_drvsyn.c new file mode 100644 index 00000000..a1ff2dfd --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvsyn.c @@ -0,0 +1,2505 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvsyn.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_debug.h" +# include "vasy_error.h" +# include "vasy_simprtl.h" +# include "vasy_shared.h" +# include "vasy_drvvex.h" +# include "vasy_drvsyn.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static FILE *VasyFile = (FILE *)0; + + static short VasyConvertDeclType[ VEX_MAX_TYPE ] = + { + VEX_TYPE_SEVERITY , /* SEVERITY */ + VEX_TYPE_BOOLEAN , /* BOOLEAN */ + VEX_TYPE_CHARACTER , /* CHARACTER */ + VEX_TYPE_STRING , /* STRING */ + VEX_TYPE_BIT , /* BIT */ + VEX_TYPE_SIGNED , /* INTEGER */ + VEX_TYPE_UNSIGNED , /* NATURAL */ + VEX_TYPE_BIT_VECTOR , /* BIT_VECTOR */ + VEX_TYPE_STD_ULOGIC , /* STD_ULOGIC */ + VEX_TYPE_STD_LOGIC , /* STD_LOGIC */ + VEX_TYPE_STD_ULOGIC_VECTOR , /* STD_ULOGIC_VECTOR */ + VEX_TYPE_STD_LOGIC_VECTOR , /* 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_BIT , /* SMALL_INT */ + VEX_TYPE_BIT , /* REG_BIT */ + VEX_TYPE_BIT_VECTOR , /* REG_VECTOR */ + VEX_TYPE_STD_LOGIC , /* MUX_BIT */ + VEX_TYPE_STD_LOGIC_VECTOR , /* MUX_VECTOR */ + VEX_TYPE_STD_LOGIC , /* WOR_BIT */ + VEX_TYPE_STD_LOGIC_VECTOR , /* WOR_VECTOR */ + VEX_TYPE_BIT_VECTOR /* ENUMERATE */ + }; + + static short VasyConvertVexType[ VEX_MAX_TYPE ] = + { + VEX_TYPE_SEVERITY , /* SEVERITY */ + VEX_TYPE_BOOLEAN , /* BOOLEAN */ + VEX_TYPE_CHARACTER , /* CHARACTER */ + VEX_TYPE_STRING , /* STRING */ + VEX_TYPE_BIT , /* BIT */ + VEX_TYPE_SIGNED , /* INTEGER */ + VEX_TYPE_UNSIGNED , /* NATURAL */ + VEX_TYPE_BIT_VECTOR , /* BIT_VECTOR */ + VEX_TYPE_STD_LOGIC , /* STD_ULOGIC */ + VEX_TYPE_STD_LOGIC , /* STD_LOGIC */ + VEX_TYPE_STD_LOGIC_VECTOR , /* STD_ULOGIC_VECTOR */ + VEX_TYPE_STD_LOGIC_VECTOR , /* STD_LOGIC_VECTOR */ + VEX_TYPE_STD_LOGIC , /* X01 */ + VEX_TYPE_STD_LOGIC , /* X01Z */ + VEX_TYPE_STD_LOGIC , /* UX01 */ + VEX_TYPE_STD_LOGIC , /* UX01Z */ + VEX_TYPE_UNSIGNED , /* UNSIGNED */ + VEX_TYPE_SIGNED , /* SIGNED */ + VEX_TYPE_BIT , /* SMALL_INT */ + VEX_TYPE_BIT , /* REG_BIT */ + VEX_TYPE_BIT_VECTOR , /* REG_VECTOR */ + VEX_TYPE_STD_LOGIC , /* MUX_BIT */ + VEX_TYPE_STD_LOGIC_VECTOR , /* MUX_VECTOR */ + VEX_TYPE_STD_LOGIC , /* WOR_BIT */ + VEX_TYPE_STD_LOGIC_VECTOR , /* WOR_VECTOR */ + VEX_TYPE_BIT_VECTOR /* ENUMERATE */ + }; + + static short VasyConvertVasyType[ VEX_MAX_TYPE ] = + { + VASY_TYPE_ERROR , /* SEVERITY */ + VASY_TYPE_BOOLEAN , /* BOOLEAN */ + VASY_TYPE_ERROR , /* CHARACTER */ + VASY_TYPE_ERROR , /* STRING */ + VASY_TYPE_BIT , /* BIT */ + VASY_TYPE_SIGNED , /* INTEGER */ + VASY_TYPE_UNSIGNED , /* NATURAL */ + VASY_TYPE_BIT , /* BIT_VECTOR */ + VASY_TYPE_LOGIC , /* STD_ULOGIC */ + VASY_TYPE_LOGIC , /* STD_LOGIC */ + VASY_TYPE_LOGIC , /* STD_ULOGIC_VECTOR */ + VASY_TYPE_LOGIC , /* STD_LOGIC_VECTOR */ + VASY_TYPE_LOGIC , /* X01 */ + VASY_TYPE_LOGIC , /* X01Z */ + VASY_TYPE_LOGIC , /* UX01 */ + VASY_TYPE_LOGIC , /* UX01Z */ + VASY_TYPE_UNSIGNED , /* UNSIGNED */ + VASY_TYPE_SIGNED , /* SIGNED */ + VASY_TYPE_BIT , /* SMALL_INT */ + VASY_TYPE_BIT , /* REG_BIT */ + VASY_TYPE_BIT , /* REG_VECTOR */ + VASY_TYPE_LOGIC , /* MUX_BIT */ + VASY_TYPE_LOGIC , /* MUX_VECTOR */ + VASY_TYPE_LOGIC , /* WOR_BIT */ + VASY_TYPE_LOGIC , /* WOR_VECTOR */ + VASY_TYPE_BIT /* ENUMERATE */ + }; + + static rtlfig_list *VasyRtlFigure = (rtlfig_list *)0; + static rtlasg_list *VasyRtlAsg = (rtlasg_list *)0; + static short VasyTargetType = 0; + + static vexexpr *VasySynopsysConvertVexConcat(); + static vexexpr *VasySynopsysConvertVexNot(); + static vexexpr *VasySynopsysConvertVexNeg(); + static vexexpr *VasySynopsysConvertVexAbs(); + static vexexpr *VasySynopsysConvertVexBool2(); + static vexexpr *VasySynopsysConvertVexEvent(); + static vexexpr *VasySynopsysConvertVexArith(); + static vexexpr *VasySynopsysConvertVexError(); + static vexexpr *VasySynopsysConvertVexEqual(); + static vexexpr *VasySynopsysConvertVexComp(); + + static vexexpr *(*VasyConvertFuncArray[ VEX_MAX_OPERATOR ])() = + { + VasySynopsysConvertVexConcat, /* VEX_CONCAT */ + VasySynopsysConvertVexNot, /* VEX_NOT */ + VasySynopsysConvertVexNeg, /* VEX_NEG */ + VasySynopsysConvertVexEvent, /* VEX_EVENT */ + VasySynopsysConvertVexBool2, /* VEX_OR */ + VasySynopsysConvertVexBool2, /* VEX_AND */ + VasySynopsysConvertVexBool2, /* VEX_XOR */ + VasySynopsysConvertVexBool2, /* VEX_NOR */ + VasySynopsysConvertVexBool2, /* VEX_NAND */ + VasySynopsysConvertVexBool2, /* VEX_NXOR */ + VasySynopsysConvertVexEqual, /* VEX_EQ */ + VasySynopsysConvertVexEqual, /* VEX_NE */ + VasySynopsysConvertVexComp, /* VEX_LT */ + VasySynopsysConvertVexComp, /* VEX_LE */ + VasySynopsysConvertVexComp, /* VEX_GT */ + VasySynopsysConvertVexComp, /* VEX_GE */ + VasySynopsysConvertVexArith, /* VEX_ADD */ + VasySynopsysConvertVexArith, /* VEX_SUB */ + VasySynopsysConvertVexArith, /* VEX_MUL */ + VasySynopsysConvertVexArith, /* VEX_DIV */ + VasySynopsysConvertVexArith, /* VEX_EXP */ + VasySynopsysConvertVexArith, /* VEX_MOD */ + VasySynopsysConvertVexArith, /* VEX_REM */ + VasySynopsysConvertVexError, /* VEX_TO */ + VasySynopsysConvertVexError, /* VEX_DOWNTO */ + VasySynopsysConvertVexError, /* VEX_INDEX */ + VasySynopsysConvertVexError, /* VEX_LEFT */ + VasySynopsysConvertVexError, /* VEX_RIGHT */ + VasySynopsysConvertVexError, /* VEX_LOW */ + VasySynopsysConvertVexError, /* VEX_HIGH */ + VasySynopsysConvertVexError, /* VEX_LENGTH */ + VasySynopsysConvertVexError, /* VEX_RANGE */ + VasySynopsysConvertVexError, /* VEX_REV_RANGE */ + VasySynopsysConvertVexError, /* VEX_DRIVER */ + VasySynopsysConvertVexError, /* VEX_IFT */ + VasySynopsysConvertVexError, /* VEX_ARRAY */ + VasySynopsysConvertVexError, /* VEX_INDEX_N */ + VasySynopsysConvertVexError, /* VEX_OTHERS */ + VasySynopsysConvertVexError, /* VEX_NUM_BIT */ + VasySynopsysConvertVexAbs /* VEX_ABS */ + }; + + static short VasyConvertBoolType[ VASY_MAX_TYPE ][ VASY_MAX_TYPE ] = + { + /* BOOL BIT LOGIC SIGNED UNSIGNED */ + {VASY_TYPE_BOOLEAN,VASY_TYPE_BOOLEAN ,VASY_TYPE_BOOLEAN ,VASY_TYPE_BOOLEAN,VASY_TYPE_BOOLEAN }, + {VASY_TYPE_BOOLEAN,VASY_TYPE_BIT ,VASY_TYPE_LOGIC ,VASY_TYPE_SIGNED ,VASY_TYPE_UNSIGNED}, + {VASY_TYPE_BOOLEAN,VASY_TYPE_LOGIC ,VASY_TYPE_LOGIC ,VASY_TYPE_SIGNED ,VASY_TYPE_UNSIGNED}, + {VASY_TYPE_BOOLEAN,VASY_TYPE_SIGNED ,VASY_TYPE_SIGNED ,VASY_TYPE_SIGNED ,VASY_TYPE_SIGNED }, + {VASY_TYPE_BOOLEAN,VASY_TYPE_UNSIGNED,VASY_TYPE_UNSIGNED,VASY_TYPE_SIGNED ,VASY_TYPE_UNSIGNED} + }; + + static short VasyConvertArithType[ VASY_MAX_TYPE ][ VASY_MAX_TYPE ] = + { + /* BOOL BIT LOGIC SIGNED UNSIGNED */ + {VASY_TYPE_ERROR,VASY_TYPE_ERROR ,VASY_TYPE_ERROR ,VASY_TYPE_ERROR ,VASY_TYPE_ERROR }, + {VASY_TYPE_ERROR,VASY_TYPE_UNSIGNED,VASY_TYPE_UNSIGNED,VASY_TYPE_SIGNED,VASY_TYPE_UNSIGNED}, + {VASY_TYPE_ERROR,VASY_TYPE_UNSIGNED,VASY_TYPE_UNSIGNED,VASY_TYPE_SIGNED,VASY_TYPE_UNSIGNED}, + {VASY_TYPE_ERROR,VASY_TYPE_SIGNED ,VASY_TYPE_SIGNED ,VASY_TYPE_SIGNED,VASY_TYPE_SIGNED }, + {VASY_TYPE_ERROR,VASY_TYPE_UNSIGNED,VASY_TYPE_UNSIGNED,VASY_TYPE_SIGNED,VASY_TYPE_UNSIGNED} + }; + + static short VasyConvertPropagateVecType[ VASY_MAX_TYPE ] = + { + VEX_TYPE_BOOLEAN, + VEX_TYPE_BIT_VECTOR, + VEX_TYPE_STD_LOGIC_VECTOR, + VEX_TYPE_SIGNED, + VEX_TYPE_UNSIGNED + }; + + static short VasyConvertPropagateBitType[ VASY_MAX_TYPE ] = + { + VEX_TYPE_BOOLEAN, + VEX_TYPE_BIT, + VEX_TYPE_STD_LOGIC, + VEX_TYPE_SIGNED, + VEX_TYPE_UNSIGNED + }; + + static short VasyConvertConcatType[ VASY_MAX_TYPE ][ VASY_MAX_TYPE ] = + { + /* BOOL BIT LOGIC SIGNED UNSIGNED */ + {VASY_TYPE_ERROR,VASY_TYPE_ERROR,VASY_TYPE_ERROR,VASY_TYPE_ERROR,VASY_TYPE_ERROR}, + {VASY_TYPE_ERROR,VASY_TYPE_BIT ,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC}, + {VASY_TYPE_ERROR,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC}, + {VASY_TYPE_ERROR,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC}, + {VASY_TYPE_ERROR,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC,VASY_TYPE_LOGIC} + }; + + static long VasyNumberDef = 0; + + static ptype_list *VasyListBoolean = (ptype_list *)0; + static ptype_list *VasyBooleanLastMatch = (ptype_list *)0; + static ptype_list *VasyListConvert = (ptype_list *)0; + static ptype_list *VasyConvertLastMatch = (ptype_list *)0; + + static char VasyBuffer[ 512 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysConvertDeclType | +| | +\------------------------------------------------------------*/ + +static int VasyDriveSynopsysConvertDeclType( Base ) + + int Base; +{ + int Type; + + Type = VasyConvertDeclType[ Base ]; + + if ( VasyFlagStdLogic ) + { + if ( Type == VEX_TYPE_BIT ) Type = VEX_TYPE_STD_LOGIC; + else + if ( Type == VEX_TYPE_BIT_VECTOR ) Type = VEX_TYPE_STD_LOGIC_VECTOR; + } + + return( Type ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysPropagateVexType | +| | +\------------------------------------------------------------*/ + +static void VasySynopsysPropagateVexType( VexExpr, VasyType ) + + vexexpr *VexExpr; + int VasyType; +{ + chain_list *ScanChain; + vexexpr *Operand; + int Type; + + if ( VexExpr == (vexexpr *)0 ) return; + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( IsVexAtomLiteral( VexExpr ) ) + { + if ( VexExpr->WIDTH > 1 ) Type = VasyConvertPropagateVecType[ VasyType ]; + else Type = VasyConvertPropagateBitType[ VasyType ]; + + SetVexVhdlType( VexExpr, Type ); + } + } + else + { + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + VasySynopsysPropagateVexType( Operand, VasyType ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertBooleanToBit | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertBooleanToBit( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *VexAtom; + vexexpr *VexAtomOne; + vexexpr *VexAtomZero; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + char Buffer[ 64 ]; + ptype_list *ScanList; + short Type; + + VexAtom = (vexexpr *)0; + + if ( ( VasyBooleanLastMatch != (ptype_list *)0 ) && + ( isvexequalexpr( VexExpr, (vexexpr *)VasyBooleanLastMatch->TYPE ) ) ) + { + freevexexpr( VexExpr ); + VexAtom = (vexexpr *)VasyBooleanLastMatch->DATA; + + ScanList = VasyBooleanLastMatch; + } + else + for ( ScanList = VasyListBoolean; + ScanList != (ptype_list *)0; + ScanList = ScanList->NEXT ) + { + if ( isvexequalexpr( VexExpr, (vexexpr *)ScanList->TYPE ) ) + { + freevexexpr( VexExpr ); + VexAtom = (vexexpr *)ScanList->DATA; break; + } + } + + if ( ScanList == (ptype_list *)0 ) + { + if ( VasyFlagStdLogic ) Type = VEX_TYPE_STD_LOGIC; + else Type = VEX_TYPE_BIT; + + sprintf( Buffer, "rtl_%s_%ld", VEX_TYPE_NAME[ Type ], VasyNumberDef++ ); + VexAtom = createvexatombit( Buffer ); + + SetVexVhdlType( VexAtom, Type ); + + RtlDeclar = addrtldecl( VasyRtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + RtlDeclar->BASE = Type; + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + RtlAssign = addrtlasgafter( VasyRtlFigure, VasyRtlAsg, + dupvexexpr( VexAtom ), RTL_ASG_CONDITIONAL ); + + VexAtomOne = createvexatomlit( VEX_ATOM_ONE ); + VexAtomZero = createvexatomlit( VEX_ATOM_ZERO ); + + addrtlasgbivex( VasyRtlFigure, RtlAssign, VexExpr , VexAtomOne , RTL_BIVEX_CONDITIONAL ); + addrtlasgbivex( VasyRtlFigure, RtlAssign, (vexexpr *)0, VexAtomZero, RTL_BIVEX_CONDITIONAL ); + + VasyListBoolean = addptype( VasyListBoolean, (long)VexExpr, (void *)VexAtom ); + ScanList = VasyListBoolean; + } + + VasyBooleanLastMatch = ScanList; + + return( dupvexexpr( VexAtom ) ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysPostTreatVex | +| | +\------------------------------------------------------------*/ + +static short VasySynopsysPostTreatVex( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand; + chain_list *ScanOper; + char *Value; + short Type; + short FuncId; + short Literal; + int Index; + + Literal = 0; + + if ( VexExpr != (vexexpr *)0 ) + { + Type = GetVexVhdlType( VexExpr ); + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( IsVexAtomLiteral( VexExpr ) ) + { + if ( ( VexExpr->WIDTH == 1 ) && + ( ( Type == VEX_TYPE_UNSIGNED ) || + ( Type == VEX_TYPE_SIGNED ) || + ( Type == VEX_TYPE_STD_LOGIC_VECTOR ) ) ) + { + Value = GetVexAtomValue( VexExpr ); + + VasyBuffer[ 0 ] = '\"'; + VasyBuffer[ 1 ] = Value[ 1 ]; + VasyBuffer[ 2 ] = '\"'; + VasyBuffer[ 3 ] = '\0'; + + Value = namealloc( VasyBuffer ); + SetVexAtomValue( VexExpr, Value ); + } + else + if ( ( Type == VEX_TYPE_BIT ) || + ( Type == VEX_TYPE_BIT_VECTOR ) ) + { + Value = GetVexAtomValue( VexExpr ); + + for ( Index = 0; Value[ Index ] != '\0'; Index++ ) + { + if ( Value[ Index ] == '1' ) VasyBuffer[ Index ] = '1'; + else + if ( ( Value[ Index ] != '\'' ) && + ( Value[ Index ] != '"' ) ) VasyBuffer[ Index ] = '0'; + else VasyBuffer[ Index ] = Value[ Index ]; + } + + VasyBuffer[ Index ] = '\0'; + Value = namealloc( VasyBuffer ); + SetVexAtomValue( VexExpr, Value ); + } + + Literal = 1; + } + } + else + { + Literal = 1; + + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Literal &= VasySynopsysPostTreatVex( Operand ); + } + + if ( ( Literal ) && + ( IsVexNodeFunc( VexExpr ) ) ) + { + Value = GetVexFuncValue( VexExpr ); + FuncId = getvexstdfuncid( Value ); + + if ( FuncId == VEX_STD_SIGNED ) + { + Value = namealloc( "signed'" ); + } + else + if ( FuncId == VEX_STD_UNSIGNED ) + { + Value = namealloc( "unsigned'" ); + } + else + if ( FuncId == VEX_STD_STD_LOGIC_VECTOR ) + { + Value = namealloc( "std_logic_vector'" ); + } + + SetVexFuncValue( VexExpr, Value ); + Literal = 0; + } + } + } + + return( Literal ); +} + + +/*------------------------------------------------------------\ +| | +| VasySynopsysAddRtlAssign | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysAddRtlAssign( VexExpr, Type ) + + vexexpr *VexExpr; + int Type; +{ + vexexpr *VexAtom; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + char Buffer[ 64 ]; + ptype_list *ScanList; + + SetVexVhdlType( VexExpr, Type ); + + VexAtom = (vexexpr *)0; + + if ( ( VasyConvertLastMatch != (ptype_list *)0 ) && + ( isvexequalexpr( VexExpr, (vexexpr *)VasyConvertLastMatch->TYPE ) ) ) + { + freevexexpr( VexExpr ); + VexAtom = (vexexpr *)VasyConvertLastMatch->DATA; + + ScanList = VasyConvertLastMatch; + } + else + for ( ScanList = VasyListConvert; + ScanList != (ptype_list *)0; + ScanList = ScanList->NEXT ) + { + if ( isvexequalexpr( VexExpr, (vexexpr *)ScanList->TYPE ) ) + { + freevexexpr( VexExpr ); + VexAtom = (vexexpr *)ScanList->DATA; break; + } + } + + if ( ScanList == (ptype_list *)0 ) + { + sprintf( Buffer, "rtl_%s_%ld", VEX_TYPE_NAME[ Type ], VasyNumberDef++ ); + + if ( isvextypevector( Type ) ) + { + VexAtom = createvexatomvec( Buffer, VexExpr->WIDTH - 1, 0 ); + } + else + { + VexAtom = createvexatombit( Buffer ); + } + + if ( Type == VEX_TYPE_SIGNED ) SetVexNodeSigned( VexAtom ); + SetVexVhdlType( VexAtom, Type ); + + RtlDeclar = addrtldecl( VasyRtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + RtlDeclar->BASE = Type; + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + VasySynopsysPostTreatVex( VexExpr ); + + RtlAssign = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = dupvexexpr( VexExpr ); + + VasyListConvert = addptype( VasyListConvert, (long)VexExpr, (void *)VexAtom ); + ScanList = VasyListConvert; + } + + VasyConvertLastMatch = ScanList; + + return( dupvexexpr( VexAtom ) ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexType | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexType( VexExpr, ConvertType ) + + vexexpr *VexExpr; + int ConvertType; +{ + vexexpr *VexFunc; + int Type; + + if ( VexExpr == (vexexpr *)0 ) return( (vexexpr *)0 ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexType %d\n", ConvertType ); + viewvexexprboundln( VexExpr ); + } + + Type = GetVexVhdlType( VexExpr ); + + if ( ConvertType == VASY_TYPE_ERROR ) + { + VasyError( VASY_ERROR_CONVERT_WRONG_TYPE, VEX_TYPE_NAME[ Type ] ); + } + + if ( ConvertType == VASY_TYPE_BOOLEAN ) + { + if ( Type != VEX_TYPE_BOOLEAN ) + { + VexExpr = createvexbinexpr( VEX_EQ, 1, VexExpr, createvexatombit( VEX_ATOM_ONE ) ); + Type = VEX_TYPE_BOOLEAN; + + SetVexVhdlType( VexExpr, Type ); + } + } + else + { + if ( Type == VEX_TYPE_BOOLEAN ) + { + VexExpr = VasySynopsysConvertBooleanToBit( VexExpr ); + Type = GetVexVhdlType( VexExpr ); + } + + if ( ConvertType == VASY_TYPE_BIT ) + { + if ( ( Type != VEX_TYPE_BIT ) && + ( Type != VEX_TYPE_BIT_VECTOR ) ) + { + if ( ( Type == VEX_TYPE_SIGNED ) || + ( Type == VEX_TYPE_UNSIGNED ) ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_STD_LOGIC_VECTOR ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC_VECTOR ); + Type = VEX_TYPE_STD_LOGIC_VECTOR; + } + + if ( Type == VEX_TYPE_STD_LOGIC ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_BIT ], 1 ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_BIT ); + } + else + if ( Type == VEX_TYPE_STD_LOGIC_VECTOR ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_BITVECTOR ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_BIT_VECTOR ); + } + else + if ( Type == VEX_MAX_TYPE ) + { + VasySynopsysPropagateVexType( VexExpr, VASY_TYPE_BIT ); + } + else + { + VasyError( VASY_ERROR_CONVERT_WRONG_TYPE, VEX_TYPE_NAME[ Type ] ); + } + } + } + else + if ( ConvertType == VASY_TYPE_LOGIC ) + { + if ( ( Type != VEX_TYPE_STD_LOGIC ) && + ( Type != VEX_TYPE_STD_LOGIC_VECTOR ) ) + { + if ( ( Type == VEX_TYPE_SIGNED ) || + ( Type == VEX_TYPE_UNSIGNED ) ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_STD_LOGIC_VECTOR ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC_VECTOR ); + } + else + if ( Type == VEX_TYPE_BIT ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_STDULOGIC ], 1 ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC ); + } + else + if ( Type == VEX_TYPE_BIT_VECTOR ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_STDLOGICVECTOR ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC_VECTOR ); + } + else + if ( Type == VEX_MAX_TYPE ) + { + VasySynopsysPropagateVexType( VexExpr, VASY_TYPE_LOGIC ); + } + else + { + VasyError( VASY_ERROR_CONVERT_WRONG_TYPE, VEX_TYPE_NAME[ Type ] ); + } + } + } + else + if ( ConvertType == VASY_TYPE_SIGNED ) + { + if ( Type != VEX_TYPE_SIGNED ) + { + if ( Type == VEX_TYPE_BIT ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_STDULOGIC ], 1 ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC ); + Type = VEX_TYPE_STD_LOGIC; + } + else + if ( Type == VEX_TYPE_BIT_VECTOR ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_STDLOGICVECTOR ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC_VECTOR ); + Type = VEX_TYPE_STD_LOGIC_VECTOR; + } + + if ( Type == VEX_TYPE_STD_LOGIC ) + { + VexExpr = VasySynopsysAddRtlAssign( VexExpr, VEX_TYPE_SIGNED ); + Type = VEX_TYPE_SIGNED; + } + else + if ( ( Type == VEX_TYPE_STD_LOGIC_VECTOR ) || + ( Type == VEX_TYPE_UNSIGNED ) || + ( Type == VEX_MAX_TYPE ) ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_SIGNED ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + if ( Type == VEX_MAX_TYPE ) + { + VasySynopsysPropagateVexType( VexFunc, VASY_TYPE_SIGNED ); + } + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_SIGNED ); + } + else + { + VasyError( VASY_ERROR_CONVERT_WRONG_TYPE, VEX_TYPE_NAME[ Type ] ); + } + } + } + else + if ( ConvertType == VASY_TYPE_UNSIGNED ) + { + if ( Type != VEX_TYPE_UNSIGNED ) + { + if ( Type == VEX_TYPE_BIT ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_STDULOGIC ], 1 ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC ); + Type = VEX_TYPE_STD_LOGIC; + } + else + if ( Type == VEX_TYPE_BIT_VECTOR ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_TO_STDLOGICVECTOR ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_STD_LOGIC_VECTOR ); + Type = VEX_TYPE_STD_LOGIC_VECTOR; + } + + if ( Type == VEX_TYPE_STD_LOGIC ) + { + VexExpr = VasySynopsysAddRtlAssign( VexExpr, VEX_TYPE_UNSIGNED ); + Type = VEX_TYPE_UNSIGNED; + } + else + if ( ( Type == VEX_TYPE_STD_LOGIC_VECTOR ) || + ( Type == VEX_TYPE_SIGNED ) || + ( Type == VEX_MAX_TYPE ) ) + { + VexFunc = createvexfunc( VEX_STD_FUNC_NAME[ VEX_STD_UNSIGNED ], VexExpr->WIDTH ); + addvexhexpr( VexFunc, VexExpr ); + + if ( Type == VEX_MAX_TYPE ) + { + VasySynopsysPropagateVexType( VexFunc, VASY_TYPE_UNSIGNED ); + } + + VexExpr = VasySynopsysAddRtlAssign( VexFunc, VEX_TYPE_UNSIGNED ); + } + else + { + VasyError( VASY_ERROR_CONVERT_WRONG_TYPE, VEX_TYPE_NAME[ Type ] ); + } + } + } + } + + if ( IsVasyDebugLevel2() ) + { + Type = GetVexVhdlType( VexExpr ); + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexType %s\n", VEX_TYPE_NAME[ Type ] ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexError | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexError( VexExpr ) + + vexexpr *VexExpr; +{ + long Oper; + + Oper = GetVexOperValue( VexExpr ); + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, getvexoperuppername( Oper ) ); + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexConcat | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexConcat( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanChain; + vexexpr *Operand; + short Unknown; + short SameType; + short FirstType; + short ScanType; + short VasyType; + short Type; + short NewType; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexConcat " ); + viewvexexprboundln( VexExpr ); + } +/* +** Verify if all operands have the same type +*/ + Unknown = 0; + SameType = 1; + FirstType = 1; + ScanType = VASY_TYPE_ERROR; + + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Type = GetVexVhdlType( Operand ); + + if ( Type == VEX_MAX_TYPE ) Unknown = 1; + else + { + VasyType = VasyConvertVasyType[ Type ]; + VasyType = VasyConvertConcatType[ VasyType ][ VasyType ]; + + if ( VasyType == VASY_TYPE_ERROR ) + { + VasyError( VASY_ERROR_CONVERT_WRONG_TYPE, VEX_TYPE_NAME[ Type ] ); + } + + if ( FirstType ) + { + ScanType = VasyType; + FirstType = 0; + } + else + if ( ScanType != VasyType ) + { + SameType = 0; + ScanType = VasyConvertConcatType[ VasyType ][ ScanType ]; + } + } + } + + if ( ScanType == VASY_TYPE_BIT ) NewType = VEX_TYPE_BIT_VECTOR; + else NewType = VEX_TYPE_STD_LOGIC_VECTOR; + + SetVexVhdlType( VexExpr, NewType ); + + if ( Unknown || ( ! SameType ) ) + { + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Type = GetVexVhdlType( Operand ); + + if ( ! SameType ) + { + VasyType = VasyConvertVasyType[ Type ]; + VasyType = VasyConvertConcatType[ VasyType ][ VasyType ]; + + if ( VasyType != ScanType ) + { + Operand = VasySynopsysConvertVexType( Operand, ScanType ); + SetVexOperand( ScanChain, Operand ); + } + } + else + if ( Type == VEX_MAX_TYPE ) + { + VasySynopsysPropagateVexType( Operand, ScanType ); + } + } + } + + VexExpr = VasySynopsysAddRtlAssign( VexExpr, NewType ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "<-- VasySynopsysConvertVexConcat " ); + viewvexexprboundln( VexExpr ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexNot | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexNot( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand; + int Type; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexNot\n" ); + viewvexexprboundln( VexExpr ); + } + + Operand = GetVexOperand( VexExpr->OPERAND ); + Type = GetVexVhdlType( Operand ); + SetVexVhdlType( VexExpr, Type ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexNot\n" ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexEvent | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexEvent( VexExpr ) + + vexexpr *VexExpr; +{ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexEvent\n" ); + viewvexexprboundln( VexExpr ); + } + + SetVexVhdlType( VexExpr, VEX_TYPE_BOOLEAN ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexEvent\n" ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexBool2 | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexBool2( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand1; + vexexpr *Operand2; + int Type1; + int Type2; + int Type; + short VasyType; + short VasyType1; + short VasyType2; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexBool2\n" ); + viewvexexprboundln( VexExpr ); + } + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Type1 = GetVexVhdlType( Operand1 ); + Operand2 = GetVexOperand( VexExpr->OPERAND->NEXT ); + Type2 = GetVexVhdlType( Operand2 ); + + if ( ( Type1 == VEX_MAX_TYPE ) || + ( Type2 == VEX_MAX_TYPE ) ) + { + if ( Type1 == VEX_MAX_TYPE ) Type = Type2; + else Type = Type1; + } + else + { + VasyType1 = VasyConvertVasyType[ Type1 ]; + VasyType2 = VasyConvertVasyType[ Type2 ]; + + if ( ( VasyType1 == VASY_TYPE_BOOLEAN ) || + ( VasyType2 == VASY_TYPE_BOOLEAN ) ) + { + if ( VasyTargetType != VASY_TYPE_BOOLEAN ) + { + if ( VasyType1 == VASY_TYPE_BOOLEAN ) + { + VasyType1 = VASY_TYPE_BIT; + Operand1 = VasySynopsysConvertVexType( Operand1, VasyType1 ); + } + + if ( VasyType2 == VASY_TYPE_BOOLEAN ) + { + VasyType2 = VASY_TYPE_BIT; + Operand2 = VasySynopsysConvertVexType( Operand2, VasyType2 ); + } + } + } + + VasyType = VasyConvertBoolType[ VasyType1 ][ VasyType2 ]; + + Operand1 = VasySynopsysConvertVexType( Operand1, VasyType ); + Operand2 = VasySynopsysConvertVexType( Operand2, VasyType ); + + SetVexOperand( VexExpr->OPERAND , Operand1 ); + SetVexOperand( VexExpr->OPERAND->NEXT, Operand2 ); + + Type = GetVexVhdlType( Operand1 ); + } + + SetVexVhdlType( VexExpr, Type ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexBool2\n" ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexEqual | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexEqual( VexExpr ) + + vexexpr *VexExpr; +{ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexEqual\n" ); + viewvexexprboundln( VexExpr ); + } + + VexExpr = VasySynopsysConvertVexBool2( VexExpr ); + SetVexVhdlType( VexExpr, VEX_TYPE_BOOLEAN ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexEqual\n" ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexAbs | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexAbs( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand1; + int Type1; + int Type; + short VasyType; + short VasyType1; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexAbs\n" ); + viewvexexprboundln( VexExpr ); + } + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Type1 = GetVexVhdlType( Operand1 ); + + if ( Type1 == VEX_MAX_TYPE ) + { + Type1 = VEX_TYPE_SIGNED; + SetVexVhdlType( Operand1, Type1 ); + } + + VasyType1 = VasyConvertVasyType[ Type1 ]; + + if ( VasyType1 == VASY_TYPE_BOOLEAN ) VasyType = VASY_TYPE_ERROR; + else VasyType = VASY_TYPE_SIGNED; + + Operand1 = VasySynopsysConvertVexType( Operand1, VasyType ); + SetVexOperand( VexExpr->OPERAND, Operand1 ); + + Type = GetVexVhdlType( Operand1 ); + SetVexVhdlType( VexExpr, Type ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexAbs\n" ); + } + + return( VexExpr ); +} + + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexNeg | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexNeg( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand1; + int Type1; + int Type; + short VasyType; + short VasyType1; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexNeg\n" ); + viewvexexprboundln( VexExpr ); + } + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Type1 = GetVexVhdlType( Operand1 ); + + if ( Type1 == VEX_MAX_TYPE ) + { + Type1 = VEX_TYPE_UNSIGNED; + SetVexVhdlType( Operand1, Type1 ); + } + + VasyType1 = VasyConvertVasyType[ Type1 ]; + + if ( VasyType1 == VASY_TYPE_BOOLEAN ) VasyType = VASY_TYPE_ERROR; + else VasyType = VASY_TYPE_SIGNED; + + Operand1 = VasySynopsysConvertVexType( Operand1, VasyType ); + SetVexOperand( VexExpr->OPERAND, Operand1 ); + + Type = GetVexVhdlType( Operand1 ); + SetVexVhdlType( VexExpr, Type ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexNeg\n" ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexArith | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexArith( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand1; + vexexpr *Operand2; + int Type1; + int Type2; + int Type; + short VasyType; + short VasyType1; + short VasyType2; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexArith\n" ); + viewvexexprboundln( VexExpr ); + } + + Operand1 = GetVexOperand( VexExpr->OPERAND ); + Type1 = GetVexVhdlType( Operand1 ); + Operand2 = GetVexOperand( VexExpr->OPERAND->NEXT ); + Type2 = GetVexVhdlType( Operand2 ); + + if ( Type1 == VEX_MAX_TYPE ) + { + Operand1 = VasySynopsysConvertVexType( Operand1, VASY_TYPE_UNSIGNED ); + Type1 = GetVexVhdlType( Operand1 ); + } + + if ( Type2 == VEX_MAX_TYPE ) + { + Operand2 = VasySynopsysConvertVexType( Operand2, VASY_TYPE_UNSIGNED ); + Type2 = GetVexVhdlType( Operand2 ); + } + + VasyType1 = VasyConvertVasyType[ Type1 ]; + VasyType2 = VasyConvertVasyType[ Type2 ]; + VasyType = VasyConvertArithType[ VasyType1 ][ VasyType2 ]; + + Operand1 = VasySynopsysConvertVexType( Operand1, VasyType ); + Operand2 = VasySynopsysConvertVexType( Operand2, VasyType ); + + SetVexOperand( VexExpr->OPERAND , Operand1 ); + SetVexOperand( VexExpr->OPERAND->NEXT, Operand2 ); + + Type = GetVexVhdlType( Operand1 ); + SetVexVhdlType( VexExpr, Type ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexArith\n" ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysConvertVexComp | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysConvertVexComp( VexExpr ) + + vexexpr *VexExpr; +{ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasySynopsysConvertVexComp\n" ); + viewvexexprboundln( VexExpr ); + } + + VexExpr = VasySynopsysConvertVexArith( VexExpr ); + SetVexVhdlType( VexExpr, VEX_TYPE_BOOLEAN ); + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, "<-- VasySynopsysConvertVexComp\n" ); + } + + return( VexExpr ); +} + + +/*------------------------------------------------------------\ +| | +| VasySynopsysTreatVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysTreatVex( VexExpr ) + + vexexpr *VexExpr; +{ + rtldecl_list *RtlDeclar; + char *AtomValue; + chain_list *ScanChain; + vexexpr *Operand; + int Type; + long Oper; + + if ( VexExpr != (vexexpr *)0 ) + { + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( IsVexAtomLiteral( VexExpr ) ) + { + if ( IsVexNodeSigned( VexExpr ) ) Type = VEX_TYPE_SIGNED; + else Type = VEX_MAX_TYPE; + } + else + { + AtomValue = GetVexAtomValue( VexExpr ); + RtlDeclar = searchrtldecl( VasyRtlFigure, AtomValue ); + Type = VasyConvertVexType[ RtlDeclar->BASE ]; + + if ( isvextypevector( Type ) ) + { + if ( VexExpr->WIDTH == 1 ) + { + if ( Type == VEX_TYPE_BIT_VECTOR ) Type = VEX_TYPE_BIT; + else + if ( Type == VEX_TYPE_STD_LOGIC_VECTOR ) Type = VEX_TYPE_STD_LOGIC; + } + } + } + + SetVexVhdlType( VexExpr, Type ); + } + else + { + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Operand = VasySynopsysTreatVex( Operand ); + SetVexOperand( ScanChain, Operand ); + } + + if ( IsVexNodeOper( VexExpr ) ) + { + Oper = GetVexOperValue( VexExpr ); + VexExpr = (*VasyConvertFuncArray[ Oper ])( VexExpr ); + } + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysTreatVexType | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySynopsysTreatVexType( VexExpr, VasyType ) + + vexexpr *VexExpr; + short VasyType; +{ + VasyTargetType = VasyType; + + VexExpr = unflatvexexpr( VexExpr ); + VexExpr = VasySynopsysTreatVex( VexExpr ); + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysTreatAsg | +| | +\------------------------------------------------------------*/ + +static void VasySynopsysTreatAsg( RtlAsg ) + + rtlasg_list *RtlAsg; +{ + rtldecl_list *RtlDeclar; + rtlbivex_list *RtlBiVex; + vexexpr *VexAtom; + vexexpr *VexExpr; + char *AtomValue; + int Type; + short VasyType; + short RtlType; + + VasyRtlAsg = RtlAsg; + + VexAtom = RtlAsg->VEX_ATOM; + AtomValue = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( VasyRtlFigure, AtomValue ); + Type = VasyConvertVexType[ RtlDeclar->BASE ]; + VasyType = VasyConvertVasyType[ Type ]; + + VexExpr = VasySynopsysTreatVexType( RtlAsg->VEX_DATA, VasyType ); + VexExpr = VasySynopsysConvertVexType( VexExpr, VasyType ); + RtlAsg->VEX_DATA = VexExpr; + + VasySynopsysPostTreatVex( VexExpr ); + + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + RtlType = RtlBiVex->TYPE; + + if ( ( RtlType != RTL_BIVEX_RISING_EDGE ) && + ( RtlType != RTL_BIVEX_FALLING_EDGE ) ) + { + VexExpr = VasySynopsysTreatVexType( RtlBiVex->VEX_COND, VASY_TYPE_BOOLEAN ); + VexExpr = VasySynopsysConvertVexType( VexExpr, VASY_TYPE_BOOLEAN ); + RtlBiVex->VEX_COND = VexExpr; + + VasySynopsysPostTreatVex( VexExpr ); + } + + VexExpr = VasySynopsysTreatVexType( RtlBiVex->VEX_DATA, VasyType ); + VexExpr = VasySynopsysConvertVexType( VexExpr, VasyType ); + RtlBiVex->VEX_DATA = VexExpr; + + VasySynopsysPostTreatVex( VexExpr ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySynopsysTreatMap | +| | +\------------------------------------------------------------*/ + +static void VasySynopsysTreatMap( RtlInst, RtlMap ) + + rtlins_list *RtlInst; + rtlmap_list *RtlMap; +{ + rtlport_list *RtlPort; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + vexexpr *VexFormal; + vexexpr *VexActual; + vexexpr *VexAtom; + char *AtomValue; + char Buffer[ 64 ]; + int Type; + short VasyType; + + VasyRtlAsg = (rtlasg_list *)0; + + VexFormal = RtlMap->VEX_FORMAL; + + if ( ! IsVexNodeAtom( VexFormal ) ) + { + viewvexexprln( VexFormal ); + autexit(1); + } + + AtomValue = GetVexAtomValue( VexFormal ); + RtlPort = searchrtlmodport( VasyRtlFigure, RtlInst->MODEL, AtomValue ); + Type = VasyConvertVexType[ RtlPort->BASE ]; + VasyType = VasyConvertVasyType[ Type ]; + + SetVexVhdlType( VexFormal, Type ); + + VexActual = RtlMap->VEX_ACTUAL; + VasyType = VasyConvertVasyType[ Type ]; + VexActual = VasySynopsysTreatVexType( VexActual, VasyType ); + VexActual = VasySynopsysConvertVexType( VexActual, VasyType ); + + if ( ( ! IsVexNodeAtom( VexActual ) ) || + ( IsVexAtomLiteral( VexActual ) ) ) + { + sprintf( Buffer, "rtl_map_%ld", VasyNumberDef++ ); + + if ( isvextypevector( Type ) ) + { + VexAtom = createvexatomvec( Buffer, VexActual->WIDTH - 1, 0 ); + } + else + { + VexAtom = createvexatombit( Buffer ); + } + + if ( Type == VEX_TYPE_SIGNED ) SetVexNodeSigned( VexAtom ); + SetVexVhdlType( VexAtom, Type ); + + RtlDeclar = addrtldecl( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_DECLAR_SIGNAL ); + RtlDeclar->BASE = Type; + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + RtlAssign = addrtlasg( VasyRtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexActual; + + VexActual = VexAtom; + } + + RtlMap->VEX_ACTUAL = VexActual; +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysTreatFigure | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysTreatFigure( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlmod_list *RtlModel; + rtlins_list *RtlInst; + rtlport_list *RtlPort; + rtlmap_list *RtlMap; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAsg; + int Index; + int Type; + + for ( Index = 0; Index < RTL_MAX_DECLAR_TYPE; Index++ ) + { + for ( RtlDeclar = RtlFigure->DECLAR[ Index ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + Type = VasyDriveSynopsysConvertDeclType( RtlDeclar->BASE ); + + RtlDeclar->BASE = Type; + RtlDeclar->KIND = RTL_KIND_NONE; + + SetVexVhdlType( RtlDeclar->VEX_ATOM, Type ); + } + } + + for ( RtlModel = RtlFigure->MODEL; + RtlModel != (rtlmod_list *)0; + RtlModel = RtlModel->NEXT ) + { + for ( RtlPort = RtlModel->PORT; + RtlPort != (rtlport_list *)0; + RtlPort = RtlPort->NEXT ) + { + Type = VasyDriveSynopsysConvertDeclType( RtlPort->BASE ); + + RtlPort->BASE = Type; + + SetVexVhdlType( RtlPort->VEX_ATOM, Type ); + } + } + + VasyConvertLastMatch = (ptype_list *)0; + VasyBooleanLastMatch = (ptype_list *)0; + + VasyRtlFigure = RtlFigure; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VasySynopsysTreatAsg( RtlAsg ); + } + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + for ( RtlMap = RtlInst->MAP; + RtlMap != (rtlmap_list *)0; + RtlMap = RtlMap->NEXT ) + { + VasySynopsysTreatMap( RtlInst, RtlMap ); + } + } + + freeptype( VasyListConvert ); + freeptype( VasyListBoolean ); + + VasyListBoolean = (ptype_list *)0; + VasyListConvert = (ptype_list *)0; +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysPort | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysPort( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + vexexpr *VexPort; + char *PortName; + char *PortDir; + char *PortBase; + char *PortVecDir; + + RtlDeclar = RtlFigure->DECLAR[ RTL_DECLAR_PORT ]; + + if ( RtlDeclar != (rtldecl_list *)0 ) + { + fprintf( VasyFile, "PORT(\n" ); + + while ( RtlDeclar != (rtldecl_list *)0 ) + { + VexPort = RtlDeclar->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + PortDir = RTL_DIR_TYPE[ RtlDeclar->DIR ]; + PortBase = VEX_TYPE_NAME[ RtlDeclar->BASE ]; + + fprintf( VasyFile, " %s\t: %s %s", PortName, PortDir, PortBase ); + + if ( isvextypevector( RtlDeclar->BASE ) ) + { + if ( IsVexAtomUp( VexPort ) ) PortVecDir = "TO"; + else PortVecDir = "DOWNTO"; + + fprintf( VasyFile, "(%d %s %d)", VexPort->LEFT, PortVecDir, VexPort->RIGHT ); + } + + if ( RtlDeclar->NEXT != (rtldecl_list *)0 ) + { + fprintf( VasyFile, ";\n" ); + } + + RtlDeclar = RtlDeclar->NEXT; + } + + fprintf( VasyFile, "\n);\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysDeclar( RtlFigure, Type ) + + rtlfig_list *RtlFigure; + int Type; +{ + rtldecl_list *RtlDeclar; + vexexpr *VexDeclar; + vexexpr *VexInit; + char *AtomValue; + char *DeclarName; + char *DeclarDir; + char *DeclarBase; + char *DeclarVecDir; + + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + if ( ! IsVasyRtlDeclarUsed( RtlDeclar ) ) continue; + + VexDeclar = RtlDeclar->VEX_ATOM; + VexInit = RtlDeclar->VEX_INIT; + DeclarName = GetVexAtomValue( VexDeclar ); + DeclarDir = RTL_DIR_TYPE[ RtlDeclar->DIR ]; + DeclarBase = VEX_TYPE_NAME[ RtlDeclar->BASE ]; + + if ( Type == RTL_DECLAR_CONSTANT ) + { + fprintf( VasyFile, " CONSTANT %s\t: %s", DeclarName, DeclarBase ); + } + else + { + fprintf( VasyFile, " SIGNAL %s\t: %s", DeclarName, DeclarBase ); + } + + if ( isvextypevector( RtlDeclar->BASE ) ) + { + if ( IsVexAtomUp( VexDeclar ) ) DeclarVecDir = "TO"; + else DeclarVecDir = "DOWNTO"; + + fprintf( VasyFile, "(%d %s %d)", VexDeclar->LEFT, DeclarVecDir, VexDeclar->RIGHT ); + } + + if ( ( Type == RTL_DECLAR_CONSTANT ) || + ( ( VexInit != (vexexpr *)0 ) && + ( VasyFlagInitial ) ) ) + { + fprintf( VasyFile, " := " ); + + if ( RtlDeclar->BASE == VEX_TYPE_BOOLEAN ) + { + if ( IsVexNodeAtom( VexInit ) ) + { + AtomValue = GetVexAtomValue( VexInit ); + + if ( AtomValue == VEX_ATOM_ONE ) fprintf( VasyFile, " TRUE" ); + else fprintf( VasyFile, " FALSE" ); + } + else + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexInit ); + } + } + else + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexInit ); + } + } + + fprintf( VasyFile, ";\n" ); + + if ( RtlDeclar->NEXT == (rtldecl_list *)0 ) + { + fprintf( VasyFile, "\n" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysFsmDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysFsmDeclar( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlfsm_list *RtlFsm; + rtlfsmstate_list *RtlState; + + for ( RtlFsm = RtlFigure->FSM; + RtlFsm != (rtlfsm_list *)0; + RtlFsm = RtlFsm->NEXT ) + { + fprintf( VasyFile, " TYPE STATE_TYPE_%s IS (", RtlFsm->NAME ); + + for ( RtlState = RtlFsm->STATE; + RtlState != (rtlfsmstate_list *)0; + RtlState = RtlState->NEXT ) + { + fprintf( VasyFile, " %s", RtlState->NAME ); + + if ( RtlState->NEXT != (rtlfsmstate_list *)0 ) + { + fprintf( VasyFile, "," ); + } + } + + fprintf( VasyFile, " );\n" ); + fprintf( VasyFile, " SIGNAL CS_%s : STATE_TYPE_%s;\n\n", RtlFsm->NAME, RtlFsm->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysComponent | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysComponent( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlmod_list *RtlModel; + rtlport_list *RtlPort; + vexexpr *VexPort; + char *PortName; + char *PortDir; + char *PortBase; + char *PortVecDir; + + for ( RtlModel = RtlFigure->MODEL; + RtlModel != (rtlmod_list *)0; + RtlModel = RtlModel->NEXT ) + { + fprintf( VasyFile, " COMPONENT %s\n", RtlModel->NAME ); + + RtlPort = RtlModel->PORT; + + if ( RtlPort != (rtlport_list *)0 ) + { + fprintf( VasyFile, " PORT(\n" ); + + while ( RtlPort != (rtlport_list *)0 ) + { + VexPort = RtlPort->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + PortDir = RTL_DIR_TYPE[ RtlPort->DIR ]; + PortBase = VEX_TYPE_NAME[ RtlPort->BASE ]; + + fprintf( VasyFile, " %s\t: %s %s", PortName, PortDir, PortBase ); + + if ( isvextypevector( RtlPort->BASE ) ) + { + if ( IsVexAtomUp( VexPort ) ) PortVecDir = "TO"; + else PortVecDir = "DOWNTO"; + + fprintf( VasyFile, "(%d %s %d)", VexPort->LEFT, PortVecDir, VexPort->RIGHT ); + } + + if ( RtlPort->NEXT != (rtlport_list *)0 ) + { + fprintf( VasyFile, ";\n" ); + } + + RtlPort = RtlPort->NEXT; + } + + fprintf( VasyFile, "\n );\n" ); + } + + fprintf( VasyFile, " END COMPONENT;\n\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysEntity | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysEntity( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + fprintf( VasyFile, "--\n" ); + fprintf( VasyFile, "-- Generated by VASY\n" ); + fprintf( VasyFile, "--\n" ); + fprintf( VasyFile, "LIBRARY IEEE;\n" ); + fprintf( VasyFile, "USE IEEE.std_logic_1164.ALL;\n" ); + fprintf( VasyFile, "USE IEEE.numeric_std.ALL;\n\n" ); + + fprintf( VasyFile, "ENTITY %s IS\n", RtlFigure->NAME ); + + VasyDriveSynopsysPort( RtlFigure ); + + fprintf( VasyFile, "END %s;\n\n", RtlFigure->NAME ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysPortMap | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysPortMap( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlmod_list *RtlModel; + rtlins_list *RtlInst; + rtlmap_list *RtlMap; + vexexpr *VexFormal; + vexexpr *VexActual; + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + RtlModel = RtlInst->MODEL; + + fprintf( VasyFile, " %s : %s\n", RtlInst->NAME, RtlModel->NAME ); + fprintf( VasyFile, " PORT MAP (\n" ); + RtlMap = RtlInst->MAP; + + while ( RtlMap != (rtlmap_list *)0 ) + { + VexFormal = RtlMap->VEX_FORMAL; + VexActual = RtlMap->VEX_ACTUAL; + + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexFormal ); + fprintf( VasyFile, " => " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, VexActual ); + + if ( RtlMap->NEXT != (rtlmap_list *)0 ) + { + fprintf( VasyFile, ",\n" ); + } + + RtlMap = RtlMap->NEXT; + } + + fprintf( VasyFile, "\n );\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysAssign | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysAssign( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + rtlbivex_list *ScanBiVex; + char *AtomValue; + char *AtomName; + chain_list *AllName; + chain_list *ScanChain; + vexexpr *VexDeclar; + vexexpr *VexInit; + int Type; + int ElseIf; + int EndIf; + int Edge; + int RtlType; + int ScanPos; + char Literal; + int First; + + for ( Type = 0; Type < RTL_MAX_DECLAR_TYPE; Type++ ) + { + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + if ( ( RtlDeclar->DIR == RTL_DIR_IN ) || + ( ! IsVasyRtlDeclarUsed( RtlDeclar ) ) ) continue; + + VexDeclar = RtlDeclar->VEX_ATOM; + VexInit = RtlDeclar->VEX_INIT; + + if ( VexInit == (vexexpr *)0 ) continue; + + AtomName = GetVexAtomValue( VexDeclar ); + AtomValue = GetVexAtomValue( VexInit ); + + for ( ScanPos = 0; ScanPos < VexDeclar->WIDTH; ScanPos++ ) + { + RtlSymbol = &RtlDeclar->DECL_SYM[ ScanPos ]; + + if ( ( IsVasyRtlDeclarRead( RtlSymbol ) ) && + ( ! IsVasyRtlDeclarAsg( RtlSymbol ) ) ) + { + Literal = AtomValue[ ScanPos + 1 ]; + + fprintf( VasyFile, " " ); + + if ( RtlSymbol->INDEX != -1 ) + { + fprintf( VasyFile, " %s(%d) <= '%c';\n", AtomName, RtlSymbol->INDEX, Literal ); + } + else + { + fprintf( VasyFile, " %s <= '%c';\n", AtomName, Literal ); + } + } + } + } + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + if ( RtlAsg->TYPE == RTL_ASG_COMBINATORIAL ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + else + if ( RtlAsg->TYPE == RTL_ASG_MULTIPLEXOR ) + { + fprintf( VasyFile, " WITH " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_DATA ); + fprintf( VasyFile, " SELECT\n " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_DATA ); + fprintf( VasyFile, " WHEN " ); + + if ( ScanBiVex->VEX_COND != (vexexpr *)0 ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + } + else + { + fprintf( VasyFile, " OTHERS " ); + } + + if ( ScanBiVex->NEXT != (rtlbivex_list *)0 ) + { + fprintf( VasyFile, ",\n " ); + } + } + + fprintf( VasyFile, ";\n" ); + } + else + if ( RtlAsg->TYPE == RTL_ASG_CONDITIONAL ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_DATA ); + + if ( ScanBiVex->NEXT != (rtlbivex_list *)0 ) + { + fprintf( VasyFile, " WHEN " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, " ELSE\n " ); + } + } + + fprintf( VasyFile, ";\n" ); + } + else + if ( ( RtlAsg->TYPE == RTL_ASG_REGISTER ) || + ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_UP ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_DOWN ) ) + { + AllName = (chain_list *)0; + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + RtlType = ScanBiVex->TYPE; + + if ( ( RtlType == RTL_BIVEX_ASYNC_RESET ) || + ( RtlType == RTL_BIVEX_ASYNC_SET ) || + ( RtlType == RTL_BIVEX_ASYNC_WEN ) || + ( RtlType == RTL_BIVEX_RISING_EDGE ) || + ( RtlType == RTL_BIVEX_FALLING_EDGE ) ) + { + AllName = unionvexexprallname( AllName, ScanBiVex->VEX_COND ); + AllName = unionvexexprallname( AllName, ScanBiVex->VEX_DATA ); + } + } + + fprintf( VasyFile, " PROCESS ( " ); + + First = 1; + + for ( ScanChain = AllName; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + RtlDeclar = searchrtldecl( RtlFigure, (char *)ScanChain->DATA ); + + if ( RtlDeclar->TYPE == RTL_DECLAR_CONSTANT ) continue; + + if ( ! First ) fprintf( VasyFile, ", " ); + First = 0; + + fprintf( VasyFile, "%s", (char *)ScanChain->DATA ); + } + + freechain( AllName ); + + fprintf( VasyFile, " )\n" ); + fprintf( VasyFile, " BEGIN\n" ); + + ElseIf = 0; + EndIf = 0; + Edge = 0; + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + RtlType = ScanBiVex->TYPE; + + if ( ScanBiVex->VEX_COND != (vexexpr *)0 ) + { + if ( Edge ) fprintf( VasyFile, "\n" ); + + Edge = 0; + + if ( ElseIf == 1 ) fprintf( VasyFile, " ELSIF " ); + else fprintf( VasyFile, " IF " ); + + if ( RtlType == RTL_BIVEX_RISING_EDGE ) + { + fprintf( VasyFile, " ((" ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, " = '1') AND " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, "'EVENT)" ); + + ElseIf = 0; + Edge = 1; + } + else + if ( RtlType == RTL_BIVEX_FALLING_EDGE ) + { + fprintf( VasyFile, " ((" ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, " = '0') AND " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, "'EVENT)" ); + + ElseIf = 0; + Edge = 1; + } + else + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + + ElseIf = 1; + } + + fprintf( VasyFile, "\n" ); + fprintf( VasyFile, " THEN " ); + } + + if ( ( RtlType != RTL_BIVEX_FALLING_EDGE ) && + ( RtlType != RTL_BIVEX_RISING_EDGE ) ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + } + + if ( ( RtlType == RTL_BIVEX_ASYNC_SET ) || + ( RtlType == RTL_BIVEX_SYNC_SET ) ) + { + if ( RtlAsg->VEX_ATOM->WIDTH > 1 ) fprintf( VasyFile, " <= (OTHERS => '1');\n" ); + else fprintf( VasyFile, " <= '1';\n" ); + } + else + if ( ( RtlType == RTL_BIVEX_ASYNC_RESET ) || + ( RtlType == RTL_BIVEX_SYNC_RESET ) ) + { + if ( RtlAsg->VEX_ATOM->WIDTH > 1 ) fprintf( VasyFile, " <= (OTHERS => '0');\n" ); + else fprintf( VasyFile, " <= '0';\n" ); + } + else + if ( ( RtlType == RTL_BIVEX_ASYNC_WEN ) || + ( RtlType == RTL_BIVEX_SYNC_WEN ) ) + { + fprintf( VasyFile, " <= " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + + if ( ( RtlType == RTL_BIVEX_SYNC_WEN ) || + ( RtlType == RTL_BIVEX_SYNC_RESET ) || + ( RtlType == RTL_BIVEX_SYNC_SET ) ) + { + if ( ScanBiVex->VEX_COND != (vexexpr *)0 ) + { + EndIf = 1; + } + } + } + + if ( ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_UP ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_DOWN ) ) + { + fprintf( VasyFile, " ELSE " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + + if ( RtlAsg->TYPE == RTL_ASG_PULL_UP ) Literal = 'H'; + else + if ( RtlAsg->TYPE == RTL_ASG_PULL_DOWN ) Literal = 'L'; + else + Literal = 'Z'; + + if ( RtlAsg->VEX_ATOM->WIDTH > 1 ) + { + fprintf( VasyFile, " <= (OTHERS => '%c');\n", Literal ); + } + else + { + fprintf( VasyFile, " <= '%c';\n", Literal ); + } + } + + if ( EndIf ) + { + fprintf( VasyFile, " END IF;\n" ); + } + + fprintf( VasyFile, " END IF;\n" ); + fprintf( VasyFile, " END PROCESS;\n" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysFsm | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysFsm( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlfsm_list *RtlFsm; + rtlfsmstate_list *FsmState; + rtlfsmtrans_list *FsmTrans; + int ElseIf; + rtlfsmasg_list *FsmAsg; + rtlbivex_list *ScanBiVex; + int RtlType; + chain_list *AllName; + chain_list *ScanChain; + + for ( RtlFsm = RtlFigure->FSM; + RtlFsm != (rtlfsm_list *)0; + RtlFsm = RtlFsm->NEXT ) + { +/* +** Drive The transition process +*/ + ScanBiVex = RtlFsm->BIVEX; + RtlType = ScanBiVex->TYPE; + AllName = getvexexprallname( ScanBiVex->VEX_COND ); + + fprintf( VasyFile, " PROCESS ( " ); + + for ( ScanChain = AllName; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + fprintf( VasyFile, "%s", (char *)ScanChain->DATA ); + + if ( ScanChain->NEXT != (chain_list *)0 ) + { + fprintf( VasyFile, ", " ); + } + } + + freechain( AllName ); + + fprintf( VasyFile, " )\n" ); + fprintf( VasyFile, " BEGIN\n" ); + fprintf( VasyFile, " IF (" ); + + if ( RtlType == RTL_BIVEX_RISING_EDGE ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, " AND " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, "'EVENT)" ); + } + else + if ( RtlType == RTL_BIVEX_FALLING_EDGE ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, " AND " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, ScanBiVex->VEX_COND ); + fprintf( VasyFile, "'EVENT)" ); + } + + fprintf( VasyFile, ")\n" ); + fprintf( VasyFile, " THEN\n" ); + + fprintf( VasyFile, " CASE ( CS_%s ) IS\n", RtlFsm->NAME ); + + for ( FsmState = RtlFsm->STATE; + FsmState != (rtlfsmstate_list *)0; + FsmState = FsmState->NEXT ) + { + fprintf( VasyFile, "\n WHEN %s =>\n\n", FsmState->NAME ); + + ElseIf = 0; + + for ( ScanChain = FsmState->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + FsmTrans = GetRtlFsmTrans( ScanChain ); + + if ( FsmTrans->VEX_COND != (vexexpr *)0 ) + { + if ( ! ElseIf ) + { + fprintf( VasyFile, " IF " ); + } + else + if ( ScanChain->NEXT != (chain_list *)0 ) + { + fprintf( VasyFile, " ELSIF " ); + } + else + { + fprintf( VasyFile, " ELSE\n" ); + } + + if ( ScanChain->NEXT != (chain_list *)0 ) + { + VasyDriveVexExprVhdl( VasyFile, RtlFigure, FsmTrans->VEX_COND ); + fprintf( VasyFile, "\n THEN\n" ); + } + + ElseIf = 1; + } + + fprintf( VasyFile, " CS_%s <= %s;\n", RtlFsm->NAME, FsmTrans->TO->NAME ); + + for ( FsmAsg = FsmTrans->ASSIGN; + FsmAsg != (rtlfsmasg_list *)0; + FsmAsg = FsmAsg->NEXT ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, FsmAsg->VEX_ATOM ); + fprintf( VasyFile, " <= " ); + VasyDriveVexExprVhdl( VasyFile, RtlFigure, FsmAsg->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + } + + if ( ElseIf ) + { + fprintf( VasyFile, " END IF;\n" ); + } + } + + fprintf( VasyFile, "\n END CASE;\n" ); + fprintf( VasyFile, " END IF;\n" ); + fprintf( VasyFile, " END PROCESS;\n\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysArchi | +| | +\------------------------------------------------------------*/ + +static void VasyDriveSynopsysArchi( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + fprintf( VasyFile, "ARCHITECTURE RTL OF %s IS\n", RtlFigure->NAME ); + + VasyDriveSynopsysDeclar( RtlFigure, RTL_DECLAR_CONSTANT ); + VasyDriveSynopsysDeclar( RtlFigure, RTL_DECLAR_SIGNAL ); + VasyDriveSynopsysFsmDeclar( RtlFigure ); + VasyDriveSynopsysComponent( RtlFigure ); + + fprintf( VasyFile, "BEGIN\n" ); + + VasyDriveSynopsysAssign( RtlFigure ); + VasyDriveSynopsysFsm( RtlFigure ); + VasyDriveSynopsysPortMap( RtlFigure ); + + fprintf( VasyFile, "END RTL;\n" ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveSynopsysRtlFig | +| | +\------------------------------------------------------------*/ + +void VasyDriveSynopsysRtlFig( RtlFigure, FileName ) + + rtlfig_list *RtlFigure; + char *FileName; +{ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyDriveSynopsysRtlFig %s\n", FileName ); + } + + if ( IsVasyDebugDriveStdout() ) + { + VasyFile = stdout; + } + else + { +/* +** First checks to avoid overwriting an existing file ! +*/ + if ( ! VasyFlagOver ) + { + VasyFile = mbkfopen( FileName, "vhd", "r" ); + + if ( VasyFile != (FILE *)0 ) + { + fclose( VasyFile ); + VasyPrintf( stdout, "ERROR file %s.vhd already exists, remove it first !\n", + FileName ); + autexit( 1 ); + } + } + + VasyFile = mbkfopen( FileName, "vhd", "w" ); + } + + if ( VasyFile != (FILE *)0 ) + { +/* +** Special treatments for Synopsys +*/ + VasyDriveSynopsysTreatFigure( RtlFigure ); + VasyDriveSynopsysEntity( RtlFigure ); + VasyDriveSynopsysArchi( RtlFigure ); + + if ( ! IsVasyDebugDriveStdout() ) + { + fclose( VasyFile ); + } + } + else + { + VasyPrintf( stdout, "ERROR unable to open file %s.vhd for writting\n", FileName ); + autexit( 1 ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyDriveSynopsysRtlFig %s\n\n", FileName ); + } +} diff --git a/alliance/src/vasy/src/vasy_drvsyn.h b/alliance/src/vasy/src/vasy_drvsyn.h new file mode 100644 index 00000000..b62fc79d --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvsyn.h @@ -0,0 +1,81 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvsyn.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_DRVSYN_H +# define VASY_DRVSYN_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_TYPE_ERROR -1 +# define VASY_TYPE_BOOLEAN 0 +# define VASY_TYPE_BIT 1 +# define VASY_TYPE_LOGIC 2 +# define VASY_TYPE_SIGNED 3 +# define VASY_TYPE_UNSIGNED 4 + +# define VASY_MAX_TYPE 5 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyDriveSynopsysRtlFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_drvvex.c b/alliance/src/vasy/src/vasy_drvvex.c new file mode 100644 index 00000000..374dc87c --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvvex.c @@ -0,0 +1,351 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvvex.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_debug.h" +# include "vasy_error.h" +# include "vasy_simprtl.h" +# include "vasy_shared.h" +# include "vasy_drvvex.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static FILE *VasyFile = (FILE *)0; + static rtlfig_list *VasyFigure = (rtlfig_list *)0; + static long VasyDriveLength = 0; + static int VasyVerilog = 0; + + static int VasyDriveVexAtomLock = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyDriveVexFile | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVexFile( String, Length ) + + char *String; + int Length; +{ + VasyDriveLength += Length; + + if ( ( ! VasyDriveVexAtomLock ) && + ( VasyDriveLength >= VASY_DRIVE_VEX_LENGTH ) ) + { + fprintf( VasyFile, "\n" ); + VasyDriveLength = 0; + } + + if ( *String ) + { + fwrite( String, sizeof(char), Length, VasyFile ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVexAtom | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVexAtom( Expr ) + + vexexpr *Expr; +{ + rtldecl_list *RtlDeclar; + vexexpr *RtlAtom; + char *String; + char Buffer[32]; + int Index; + int Length; + + VasyDriveVexAtomLock = 1; + + String = GetVexAtomValue( Expr ); + Length = strlen( String ); + + if ( ( VasyVerilog ) && + ( IsVexAtomLiteral ( Expr ) ) ) + { + sprintf( Buffer, "%d'b", Expr->WIDTH ); + VasyDriveVexFile( Buffer, strlen( Buffer ) ); + + for ( Index = 1; Index < Length - 1; Index++ ) + { + if ( ( String[ Index ] == '-' ) || + ( String[ Index ] == 'd' ) ) VasyDriveVexFile( "?", 1 ); + else VasyDriveVexFile( String + Index, 1 ); + } + } + else + { + VasyDriveVexFile( String, Length ); + } + + if ( ( IsVexAtomVector( Expr ) ) && + ( ! IsVexAtomLiteral( Expr ) ) ) + { + if ( Expr->LEFT == Expr->RIGHT ) + { + if ( VasyVerilog ) sprintf( Buffer, "[%d]", Expr->LEFT ); + else sprintf( Buffer, "(%d)", Expr->LEFT ); + } + else + { + RtlDeclar = searchrtldecl( VasyFigure, String ); + + if ( RtlDeclar != (rtldecl_list *)0 ) + { + RtlAtom = RtlDeclar->VEX_ATOM; + + if ( ( Expr->LEFT == RtlAtom->LEFT ) && + ( Expr->RIGHT == RtlAtom->RIGHT ) ) return; + } + + if ( VasyVerilog ) + { + sprintf( Buffer, "[%d:%d]", Expr->LEFT, Expr->RIGHT ); + } + else + if ( Expr->LEFT < Expr->RIGHT ) + { + sprintf( Buffer, "(%d to %d)", Expr->LEFT, Expr->RIGHT ); + } + else + { + sprintf( Buffer, "(%d downto %d)", Expr->LEFT, Expr->RIGHT ); + } + } + + VasyDriveVexFile( Buffer, strlen( Buffer ) ); + } + + VasyDriveVexAtomLock = 0; +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVexExpr | +| | +\------------------------------------------------------------*/ + +static void loc_VasyDriveVexExpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + long Oper; + char *String; + int Length; + + if ( IsVexNodeAtom( Expr ) ) + { + VasyDriveVexAtom( Expr ); + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( VasyVerilog ) String = getvexoperverilogname( Oper ); + else String = getvexoperuppername( Oper ); + + if ( String == (char *)0 ) + { + VasyError( VASY_ERROR_IN_DRVVEX, Oper ); + } + + Length = strlen( String ); + + if ( isvexunaryoper( Oper ) ) + { + if ( ( Oper == VEX_EVENT ) || + ( Oper == VEX_DRIVER ) ) + { + VasyDriveVexFile( "(", 1 ); + + loc_VasyDriveVexExpr( GetVexOperand( Expr->OPERAND ) ); + + VasyDriveVexFile( "'", 1 ); + VasyDriveVexFile( String, Length ); + } + else + if ( Oper == VEX_NEG ) + { + VasyDriveVexFile( "(-", 2 ); + loc_VasyDriveVexExpr( GetVexOperand( Expr->OPERAND ) ); + } + else + { + VasyDriveVexFile( String, Length ); + VasyDriveVexFile( "(", 1 ); + loc_VasyDriveVexExpr( GetVexOperand( Expr->OPERAND ) ); + } + } + else + { + if ( isvexpositiveoper( Oper ) ) + { + if ( ( VasyVerilog ) && + ( Oper == VEX_CONCAT ) ) VasyDriveVexFile( "{", 1 ); + else VasyDriveVexFile( "(", 1 ); + } + else + { + if ( VasyVerilog ) + { + VasyDriveVexFile( "~(", 2 ); + String = getvexoperverilogname( getvexnotoper( Oper ) ); + } + else + { + VasyDriveVexFile( "NOT(", 4 ); + String = getvexoperuppername( getvexnotoper( Oper ) ); + } + + Length = strlen( String ); + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_VasyDriveVexExpr( GetVexOperand( ScanOper ) ); + + if ( ScanOper->NEXT != (chain_list *)0 ) + { + VasyDriveVexFile( " ", 1 ); + VasyDriveVexFile( String, Length ); + VasyDriveVexFile( " ", 1 ); + } + } + } + + if ( ( VasyVerilog ) && + ( Oper == VEX_CONCAT ) ) VasyDriveVexFile( "}", 1 ); + else VasyDriveVexFile( ")", 1 ); + } + else + { + String = GetVexFuncValue( Expr ); + Length = strlen( String ); + + VasyDriveVexFile( String, Length ); + VasyDriveVexFile( "(", 1 ); + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + loc_VasyDriveVexExpr( GetVexOperand( ScanOper ) ); + + if ( ScanOper->NEXT != (chain_list *)0 ) + { + VasyDriveVexFile( ",", 1 ); + } + } + + VasyDriveVexFile( ")", 1 ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVexExpr | +| | +\------------------------------------------------------------*/ + +void VasyDriveVexExpr( File, RtlFigure, Expr, Verilog ) + + FILE *File; + rtlfig_list *RtlFigure; + vexexpr *Expr; + int Verilog; +{ + if ( Expr != (vexexpr *)0 ) + { + VasyFigure = RtlFigure; + VasyFile = File; + VasyDriveLength = 0; + VasyVerilog = Verilog; + + loc_VasyDriveVexExpr( Expr ); + } +} diff --git a/alliance/src/vasy/src/vasy_drvvex.h b/alliance/src/vasy/src/vasy_drvvex.h new file mode 100644 index 00000000..3d697470 --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvvex.h @@ -0,0 +1,84 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvvex.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_DRVVEX_H +# define VASY_DRVVEX_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_DRIVE_VEX_LENGTH 80 + +# define VASY_DRIVE_VEX_VECTOR_MASK VEX_NODE_USER1_MASK + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define VasyDriveVexExprVhdl( F, R, E ) (VasyDriveVexExpr( (F), (R), (E), 0 )) +# define VasyDriveVexExprVerilog( F, R, E ) (VasyDriveVexExpr( (F), (R), (E), 1 )) + +# define IsVasyDriveVexVector( N ) ( (N)->TYPE & VASY_DRIVE_VEX_VECTOR_MASK ) +# define SetVasyDriveVexVector( N ) ( (N)->TYPE |= VASY_DRIVE_VEX_VECTOR_MASK ) +# define ClearVasyDriveVexVector( N ) ( (N)->TYPE &= ~VASY_DRIVE_VEX_VECTOR_MASK ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyDriveVexExpr(); + +# endif diff --git a/alliance/src/vasy/src/vasy_drvvlog.c b/alliance/src/vasy/src/vasy_drvvlog.c new file mode 100644 index 00000000..49f1b5ac --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvvlog.c @@ -0,0 +1,1260 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvvlog.c | +| | +| Authors : Frédéric Pétrot | +| This file is a basic modification of vasy_drvsyn | +| Modified by Ludovic Jacomme | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_debug.h" +# include "vasy_error.h" +# include "vasy_simprtl.h" +# include "vasy_shared.h" +# include "vasy_drvvex.h" +# include "vasy_drvvlog.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static FILE *VasyFile = (FILE *)NULL; + + static char *VERILOG_DIR_TYPE[ RTL_MAX_DIR_TYPE ] = + { + "input", + "output", + "inout" + }; + + static long VasyVerilogDef = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Ln2p | +| | +\------------------------------------------------------------*/ + +/* Ln2p: computes ln2(n) by excess : for example ln2(512) = 9, ln2(513) = 10 */ + +static long Ln2p( Value ) + + long Value; +{ + long i = 0L, j = ( Value & 1 ) ? 1L : 0L; + + if ( Value ) + { + for ( i = -1; + Value > 0L; + Value >>= 1 ) + { + if ( Value & 1L ) + { + j++; + } + i++; + } + } + return i + ( j > 1L ? 1L : 0L ); +} + +/*------------------------------------------------------------\ +| | +| VasyVerilogBinary | +| | +\------------------------------------------------------------*/ + +static char *VasyVerilogBinary ( Range, Value ) + + long Range; + long Value; +{ + static char Buffer[ 256 ]; + int Index; + int Shift; + + sprintf( Buffer, "%ld'b", Range ); + + /* Do not use the system depend result of sprintf */ + Shift = strlen( Buffer ); + + for ( Index = Range - 1; + Index >= 0; + Index -- ) + { + Buffer[ Shift + Range - 1 - Index ] = (( Value << Index ) & 1) + '0' ; + } + + Buffer[ Shift + Range ] = (char)0; + + return Buffer; +} + +/*------------------------------------------------------------\ +| | +| VasyVerilogBinaryZXU | +| | +\------------------------------------------------------------*/ + +static char *VasyVerilogBinaryZXU ( Range, Zxu ) + + long Range; + char Zxu; +{ + static char Buffer[ 256 ]; + int Index; + int Shift; + + sprintf( Buffer, "%ld'b", Range ); + + /* Do not use the system depend result of sprintf */ + Shift = strlen( Buffer ); + + for ( Index = Range - 1; + Index >= 0; + Index -- ) + { + Buffer[ Shift + Range - 1 - Index ] = Zxu ; + } + + Buffer[ Shift + Range ] = (char)0; + + return Buffer; +} + +static char *VasyGetVerilogNetType( RtlDeclar ) + + rtldecl_list *RtlDeclar; +{ + char *NetType; + + if ( IsVasyRtlDeclVerilogReg( RtlDeclar ) ) NetType = "reg"; + else NetType = "wire"; + + return( NetType ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogAddRtlDefine | +| | +\------------------------------------------------------------*/ + +vexexpr *VasyDriveVerilogAddRtlDefine( RtlFigure, VexCond ) + + rtlfig_list *RtlFigure; + vexexpr *VexCond; +{ + rtldecl_list *DefDeclar; + rtlasg_list *DefAssign; + vexexpr *VexAtom; + char Buffer[ 32 ]; + + sprintf( Buffer, "rtlvlog_%ld", VasyVerilogDef++ ); + VexAtom = createvexatombit( Buffer ); + + DefDeclar = addrtldecl( RtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + SetVasyRtlDeclarRead( DefDeclar ); + SetVasyRtlDeclarAsg( DefDeclar ); + + DefDeclar->BASE = VEX_TYPE_BOOLEAN; + DefDeclar->KIND = RTL_KIND_NONE; + DefDeclar->DIR = RTL_DIR_INOUT; + + DefAssign = addrtlasg( RtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + DefAssign->VEX_DATA = VexCond; + + return( dupvexexpr( VexAtom ) ); +} + +/*------------------------------------------------------------\ +| | +| VasyVerilogTreatMap | +| | +\------------------------------------------------------------*/ + +static void VasyVerilogTreatMap( RtlFigure, RtlInst ) + + rtlfig_list *RtlFigure; + rtlins_list *RtlInst; +{ + rtlmap_list *RtlMap; + rtlport_list *RtlPort; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + vexexpr *VexFormal; + vexexpr *VexActual; + vexexpr *VexAtom; + char *AtomValue; + char Buffer[ 64 ]; + int Type; + + for ( RtlMap = RtlInst->MAP; + RtlMap != (rtlmap_list *)0; + RtlMap = RtlMap->NEXT ) + { + VexFormal = RtlMap->VEX_FORMAL; + AtomValue = GetVexAtomValue( VexFormal ); + RtlPort = searchrtlmodport( RtlFigure, RtlInst->MODEL, AtomValue ); + VexAtom = RtlPort->VEX_ATOM; + + VexActual = RtlMap->VEX_ACTUAL; + + if ( ( ! IsVexNodeAtom( VexActual ) ) || + ( IsVexAtomLiteral( VexActual ) ) ) + { + sprintf( Buffer, "rtl_map_%ld", VasyVerilogDef++ ); + + if ( isvextypevector( Type ) ) + { + VexAtom = createvexatomvec( Buffer, VexActual->WIDTH - 1, 0 ); + } + else + { + VexAtom = createvexatombit( Buffer ); + } + + RtlDeclar = addrtldecl( RtlFigure, dupvexexpr( VexAtom ), RTL_DECLAR_SIGNAL ); + RtlDeclar->BASE = RtlPort->BASE; + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarRead( RtlDeclar ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + RtlAssign = addrtlasg( RtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexActual; + + VexActual = VexAtom; + } + + RtlMap->VEX_ACTUAL = VexActual; + } +} + +/*------------------------------------------------------------\ +| | +| VasyVerilogTreatAsg | +| | +\------------------------------------------------------------*/ + +static void VasyVerilogTreatAsg( RtlFigure, RtlAsg ) + + rtlfig_list *RtlFigure; + rtlasg_list *RtlAsg; +{ + rtldecl_list *RtlDeclar; + rtlbivex_list *RtlBiVex; + chain_list *AllName; + chain_list *ScanChain; + ptype_list *SensList; + char *SensName; + vexexpr *VexAtom; + vexexpr *VexCond; + vexexpr *Operand; + long Oper; + long SensType; + int RtlType; + + SensType = 0; + + VexAtom = RtlAsg->VEX_ATOM; + RtlDeclar = searchrtldecl( RtlFigure, GetVexAtomValue( VexAtom ) ); +/* +** Compute the sensisitivity list for each register assignment +*/ + if ( RtlAsg->TYPE == RTL_ASG_REGISTER ) + { + SetVasyRtlDeclVerilogReg( RtlDeclar ); + + SensList = (ptype_list *)0; + + if ( RtlAsg->REG_TYPE == RTL_ASG_REGISTER_MIXED ) + { + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + RtlType = RtlBiVex->TYPE; + VexCond = RtlBiVex->VEX_COND; + SensName = (char *)0; +/* +** Special treatments for register's asynchronous conditions +*/ + if ( ( RtlType == RTL_BIVEX_ASYNC_SET ) || + ( RtlType == RTL_BIVEX_ASYNC_RESET ) ) + { + if ( ! IsVexNodeAtom( VexCond ) ) + { + if ( IsVexNodeOper( VexCond ) ) + { + Oper = GetVexOperValue( VexCond ); + Operand = GetVexOperand( VexCond->OPERAND ); + + if ( ( Oper == VEX_NOT ) && + ( IsVexNodeAtom( Operand ) ) ) + { + SensType = VASY_VERILOG_SENS_NEGEDGE; + SensName = GetVexAtomValue( Operand ); + } + } + + if ( SensName == (char *)0 ) + { + VexCond = VasyDriveVerilogAddRtlDefine( RtlFigure, VexCond ); + RtlBiVex->VEX_COND = VexCond; + + SensType = VASY_VERILOG_SENS_POSEDGE; + SensName = GetVexAtomValue( VexCond ); + } + } + else + { + SensType = VASY_VERILOG_SENS_POSEDGE; + SensName = GetVexAtomValue( VexCond ); + } + + SensList = addptype( SensList, SensType, SensName ); + } + else + if ( RtlType == RTL_BIVEX_ASYNC_WEN ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "Driver Verilog: ASYNC WEN" ); +/* +** Should be transformed to an equivalent Set/Reset condition TO BE DONE +*/ + VasyPrintf( stdout, "Must be transformed to an equivalent Set/Reset condition\n" ); + } + else + if ( ( RtlType == RTL_BIVEX_RISING_EDGE ) || + ( RtlType == RTL_BIVEX_FALLING_EDGE ) ) + { + if ( RtlType == RTL_BIVEX_FALLING_EDGE ) SensType = VASY_VERILOG_SENS_NEGEDGE; + else SensType = VASY_VERILOG_SENS_POSEDGE; + + SensName = GetVexAtomValue( VexCond ); + SensList = addptype( SensList, SensType, SensName ); + } + else break; + } + } + else + { + AllName = (chain_list *)0; + + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + RtlType = RtlBiVex->TYPE; + + if ( ( RtlType == RTL_BIVEX_ASYNC_RESET ) || + ( RtlType == RTL_BIVEX_ASYNC_SET ) || + ( RtlType == RTL_BIVEX_ASYNC_WEN ) ) + { + AllName = unionvexexprallname( AllName, RtlBiVex->VEX_COND ); + AllName = unionvexexprallname( AllName, RtlBiVex->VEX_DATA ); + } + else + if ( ( RtlType == RTL_BIVEX_RISING_EDGE ) || + ( RtlType == RTL_BIVEX_FALLING_EDGE ) ) + { + VexCond = RtlBiVex->VEX_COND; + SensName = GetVexAtomValue( VexCond ); + + if ( RtlType == RTL_BIVEX_FALLING_EDGE ) SensType = VASY_VERILOG_SENS_POSEDGE; + else SensType = VASY_VERILOG_SENS_NEGEDGE; + + SensList = addptype( SensList, SensType, SensName ); + } + } + + for ( ScanChain = AllName; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + SensList = addptype( SensList, VASY_VERILOG_SENS_NOEDGE, ScanChain->DATA ); + } + + freechain( AllName ); + } + + SensList = (ptype_list *)reverse( (chain_list *)SensList ); + SetVasyRtlAsgVerilogSens( RtlAsg, SensList ); + } + else +/* +** Compute the sensisitivity list for each tristate assignment +*/ + if ( ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_UP ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_DOWN ) || + ( RtlAsg->TYPE == RTL_ASG_CONDITIONAL ) || + ( RtlAsg->TYPE == RTL_ASG_MULTIPLEXOR ) ) + { + SetVasyRtlDeclVerilogReg( RtlDeclar ); + + SensList = (ptype_list *)0; + AllName = (chain_list *)0; + + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + AllName = unionvexexprallname( AllName, RtlBiVex->VEX_COND ); + AllName = unionvexexprallname( AllName, RtlBiVex->VEX_DATA ); + } + + for ( ScanChain = AllName; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + SensList = addptype( SensList, VASY_VERILOG_SENS_NOEDGE, ScanChain->DATA ); + } + + freechain( AllName ); + + SensList = (ptype_list *)reverse( (chain_list *)SensList ); + SetVasyRtlAsgVerilogSens( RtlAsg, SensList ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogTreatFigure | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogTreatFigure( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg; + rtlins_list *RtlInst; + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + VasyVerilogTreatMap( RtlFigure, RtlInst ); + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)NULL; + RtlAsg = RtlAsg->NEXT ) + { + VasyVerilogTreatAsg( RtlFigure, RtlAsg ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogPort | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogPort( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + vexexpr *VexPort; + char *PortName; + char *PortDir; + + fprintf( VasyFile, "("); + + for ( RtlDeclar = RtlFigure->DECLAR[ RTL_DECLAR_PORT ]; + RtlDeclar != (rtldecl_list *)NULL; + RtlDeclar = RtlDeclar->NEXT ) + { + VexPort = RtlDeclar->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + fprintf( VasyFile, "%s", PortName ); + if ( RtlDeclar->NEXT != NULL ) + { + fprintf( VasyFile, ", " ); + } + } + + fprintf( VasyFile, ");\n\n" ); + + for ( RtlDeclar = RtlFigure->DECLAR[ RTL_DECLAR_PORT ]; + RtlDeclar != (rtldecl_list *)NULL; + RtlDeclar = RtlDeclar->NEXT ) + { + VexPort = RtlDeclar->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + PortDir = VERILOG_DIR_TYPE[ RtlDeclar->DIR ]; + + fprintf( VasyFile, " %-6s ", PortDir ); + + if ( IsVexAtomVector( VexPort ) ) + { + fprintf( VasyFile, "[%d:%d]", VexPort->LEFT, VexPort->RIGHT ); + } + + fprintf( VasyFile, "\t%s;\n", PortName ); + } + + /* Beware: from what I understood from verilog, if a port is a + * register or three state, it should also be redefined afterwood + * with the correct type. */ + + for ( RtlDeclar = RtlFigure->DECLAR[ RTL_DECLAR_PORT ]; + RtlDeclar != (rtldecl_list *)NULL; + RtlDeclar = RtlDeclar->NEXT ) + { + if ( ! IsVasyRtlDeclType( RtlDeclar, VASY_RTL_DECL_COMBINATORIAL ) ) + { + VexPort = RtlDeclar->VEX_ATOM; + PortName = GetVexAtomValue( VexPort ); + + fprintf( VasyFile, " %-6s ", VasyGetVerilogNetType( RtlDeclar ) ); + if ( IsVexAtomVector( VexPort ) ) + { + fprintf( VasyFile, "[%d:%d]", VexPort->LEFT, VexPort->RIGHT ); + } + fprintf( VasyFile, "\t%s;\n", PortName ); + } + } + fprintf( VasyFile, "\n" ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogDeclar( RtlFigure, Type ) + + rtlfig_list *RtlFigure; + int Type; +{ + rtldecl_list *RtlDeclar; + vexexpr *VexDeclar; + vexexpr *VexInit; + char *DeclarName; + char *DeclarDir; + char *DeclarKind; + + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)NULL; + RtlDeclar = RtlDeclar->NEXT ) + { + VexDeclar = RtlDeclar->VEX_ATOM; + VexInit = RtlDeclar->VEX_INIT; + DeclarName = GetVexAtomValue( VexDeclar ); + DeclarDir = VERILOG_DIR_TYPE[ RtlDeclar->DIR ]; + DeclarKind = VasyGetVerilogNetType( RtlDeclar ); + + if ( ! IsVasyRtlDeclarUsed( RtlDeclar ) ) continue; + + fprintf( VasyFile, " %-4s\t", DeclarKind ); + + if ( IsVexAtomVector( VexDeclar ) ) + { + fprintf( VasyFile, "[%d:%d]", VexDeclar->LEFT, VexDeclar->RIGHT ); + } + + fprintf( VasyFile, " %s;\n", DeclarName ); + + if ( Type == RTL_DECLAR_CONSTANT ) + { + fprintf( VasyFile, " assign %s = \t", DeclarName ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, VexInit ); + fprintf( VasyFile, ";\n" ); + } + + if ( RtlDeclar->NEXT == (rtldecl_list *)NULL ) + { + fprintf( VasyFile, "\n" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogFsmDeclar | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogFsmDeclar( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlfsm_list *RtlFsm; + rtlfsmstate_list *RtlState; + int StateNumber; /* No enumeration in verilog ? */ + int StateRegisterRange; + + for ( RtlFsm = RtlFigure->FSM; + RtlFsm != (rtlfsm_list *)NULL; + RtlFsm = RtlFsm->NEXT ) + { + + for ( RtlState = RtlFsm->STATE, StateNumber = 0; + RtlState != (rtlfsmstate_list *)NULL; + RtlState = RtlState->NEXT, StateNumber++ ); + + StateRegisterRange = Ln2p( StateNumber ); + + for ( RtlState = RtlFsm->STATE, StateNumber = 0; + RtlState != (rtlfsmstate_list *)NULL; + RtlState = RtlState->NEXT, StateNumber++ ) + { + fprintf( VasyFile, + "parameter %s_%s = %s;\n", + RtlFsm->NAME, + RtlState->NAME, + VasyVerilogBinary( StateRegisterRange, StateNumber ) + ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogEntity | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogEntity( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + VasyDriveVerilogPort( RtlFigure ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogVexCond | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogVexCond( RtlFigure, VexExpr, Positive ) + + rtlfig_list *RtlFigure; + vexexpr *VexExpr; + int Positive; + +{ + vexexpr *VexCond; + long Oper; + int NoEqual; + + VexCond = VexExpr; + NoEqual = 0; + + if ( IsVexNodeOper( VexCond ) ) + { + Oper = GetVexOperValue( VexCond ); + + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) || + ( Oper == VEX_LT ) || + ( Oper == VEX_LE ) || + ( Oper == VEX_GT ) || + ( Oper == VEX_GE ) ) + { + NoEqual = 1; + + if ( ! Positive ) + { + Oper = getvexnotoper( Oper ); + VexCond = dupvexexpr( VexCond ); + SetVexOperValue( VexCond, Oper ); + } + } + else + if ( Oper == VEX_NOT ) + { + Positive = ! Positive; + VexCond = dupvexexpr( GetVexOperand( VexCond->OPERAND ) ); + } + else + if ( isvexnegativeoper( Oper ) ) + { + Positive = ! Positive; + Oper = getvexnotoper( Oper ); + VexCond = dupvexexpr( VexCond ); + + SetVexOperValue( VexCond, Oper ); + } + } + + if ( ! NoEqual ) fprintf( VasyFile, "(" ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, VexCond ); + if ( ! NoEqual ) fprintf( VasyFile, " == 1'b%c)", ( Positive ) ? '1' : '0' ); + + fprintf( VasyFile, " " ); + + if ( VexCond != VexExpr ) + { + freevexexpr( VexCond ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogAssign | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogAssign( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg; + rtlbivex_list *RtlBiVex; + ptype_list *SensList; + ptype_list *ScanPtype; + int RtlType; + int ElseIf; + int Edge; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)NULL; + RtlAsg = RtlAsg->NEXT ) + { + if ( RtlAsg->TYPE == RTL_ASG_COMBINATORIAL ) + { + fprintf( VasyFile, " " ); + fprintf( VasyFile, "assign\t" ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " = " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlAsg->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + else + if ( ( RtlAsg->TYPE == RTL_ASG_REGISTER ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_UP ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_DOWN ) || + ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) || + ( RtlAsg->TYPE == RTL_ASG_CONDITIONAL ) || + ( RtlAsg->TYPE == RTL_ASG_MULTIPLEXOR ) ) + { + fprintf( VasyFile, "\n always @ ( " ); + SensList = GetVasyRtlAsgVerilogSens( RtlAsg ); + + for ( ScanPtype = SensList; + ScanPtype != (ptype_list *)0; + ScanPtype = ScanPtype->NEXT ) + { + if ( ScanPtype->TYPE == VASY_VERILOG_SENS_POSEDGE ) + { + fprintf( VasyFile, "posedge %s", (char *)ScanPtype->DATA ); + } + else + if ( ScanPtype->TYPE == VASY_VERILOG_SENS_NEGEDGE ) + { + fprintf( VasyFile, "negedge %s", (char *)ScanPtype->DATA ); + } + else + { + fprintf( VasyFile, "%s", (char *)ScanPtype->DATA ); + } + + if ( ScanPtype->NEXT != (ptype_list *)NULL ) + { + fprintf( VasyFile, " or " ); + } + } + + freeptype( SensList ); + SetVasyRtlAsgVerilogSens( RtlAsg, NULL ); + + fprintf( VasyFile, " )\n" ); + } + + if ( RtlAsg->TYPE == RTL_ASG_REGISTER ) + { + ElseIf = 0; + Edge = 0; + + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + RtlType = RtlBiVex->TYPE; + + if ( Edge ) fprintf( VasyFile, " " ); + + if ( RtlBiVex->VEX_COND != (vexexpr *)0 ) + { + if ( ( RtlType != RTL_BIVEX_RISING_EDGE ) && + ( RtlType != RTL_BIVEX_FALLING_EDGE ) ) + { + if ( ElseIf == 1 ) fprintf( VasyFile, " else if " ); + else fprintf( VasyFile, " if " ); + } + + if ( ( RtlType == RTL_BIVEX_RISING_EDGE ) || + ( RtlType == RTL_BIVEX_FALLING_EDGE ) ) + { + if ( ElseIf == 1 ) fprintf( VasyFile, " else\n" ); + + fprintf( VasyFile, " begin\n" ); + + ElseIf = 0; + Edge = 1; + } + else + { + VasyDriveVerilogVexCond( RtlFigure, RtlBiVex->VEX_COND, 1 ); + + ElseIf = 1; + } + } + + if ( ( RtlType != RTL_BIVEX_FALLING_EDGE ) && + ( RtlType != RTL_BIVEX_RISING_EDGE ) ) + { + if ( ( RtlType == RTL_BIVEX_SYNC_WEN ) && + ( RtlBiVex->VEX_COND == (vexexpr *)0 ) ) + { + fprintf( VasyFile, " " ); + } + + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + } + + if ( ( RtlType == RTL_BIVEX_ASYNC_SET ) || + ( RtlType == RTL_BIVEX_SYNC_SET ) ) + { + fprintf( VasyFile, " = %s;\n", + VasyVerilogBinary( RtlAsg->VEX_ATOM->WIDTH, 1 ) ); + } + else + if ( ( RtlType == RTL_BIVEX_ASYNC_RESET ) || + ( RtlType == RTL_BIVEX_SYNC_RESET ) ) + { + fprintf( VasyFile, " = %s;\n", + VasyVerilogBinary( RtlAsg->VEX_ATOM->WIDTH, 0 ) ); + } + else + if ( ( RtlType == RTL_BIVEX_ASYNC_WEN ) || + ( RtlType == RTL_BIVEX_SYNC_WEN ) ) + { + fprintf( VasyFile, " = " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlBiVex->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + } + + if ( Edge ) + { + fprintf( VasyFile, " end\n" ); + } + } + else + if ( ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_UP ) || + ( RtlAsg->TYPE == RTL_ASG_PULL_DOWN ) ) + { + RtlBiVex = RtlAsg->BIVEX; + + fprintf( VasyFile, " if " ); + VasyDriveVerilogVexCond( RtlFigure, RtlBiVex->VEX_COND, 1 ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " = " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlBiVex->VEX_DATA ); + fprintf( VasyFile, ";\n else " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " = %s;\n", + VasyVerilogBinaryZXU( RtlAsg->VEX_ATOM->WIDTH, 'z' ) ); + } + else + if ( RtlAsg->TYPE == RTL_ASG_CONDITIONAL ) + { + ElseIf = 0; + + for ( RtlBiVex = RtlAsg->BIVEX; + RtlBiVex != (rtlbivex_list *)0; + RtlBiVex = RtlBiVex->NEXT ) + { + RtlType = RtlBiVex->TYPE; + + if ( RtlBiVex->VEX_COND != (vexexpr *)0 ) + { + if ( ElseIf == 1 ) fprintf( VasyFile, " else if " ); + else fprintf( VasyFile, " if " ); + + VasyDriveVerilogVexCond( RtlFigure, RtlBiVex->VEX_COND, 1 ); + + ElseIf = 1; + } + else + if ( ElseIf == 1 ) + { + fprintf( VasyFile, " else " ); + } + + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlAsg->VEX_ATOM ); + fprintf( VasyFile, " = " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, RtlBiVex->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + } + else + if ( RtlAsg->TYPE == RTL_ASG_MULTIPLEXOR ) + { + /* TO BE DONE */ + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogFsm | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogFsm( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlfsm_list *RtlFsm; + /* + rtlfsmstate_list *FsmState; + rtlfsmtrans_list *FsmTrans; + int ElseIf; + rtlfsmasg_list *FsmAsg; + chain_list *ScanChain; + */ + + for ( RtlFsm = RtlFigure->FSM; + RtlFsm != (rtlfsm_list *)NULL; + RtlFsm = RtlFsm->NEXT ) + { + VasyError( VASY_NOT_YET_IMPLEMENTED_ERROR, "Driver Verilog: FSM" ); +/* +** Drive The transition process +*/ + /* TO BE DONE + + fprintf( VasyFile, " always @ ( " ); + + if ( RtlFsm->VEX_EDGE != (vexexpr *)NULL ) + { + Support = getvexexprsupport( RtlFsm->VEX_EDGE ); + if ( VasyVerilogEdgeDirection( RtlFsm->VEX_COND ) == EDGE_UP ) + { + fprintf( VasyFile, "posedge %s", (char *)Support->DATA ); + } + else + { + fprintf( VasyFile, "negedge %s", (char *)Support->DATA ); + } + Support = NULL; + } + else + { + Support = getvexexprsupport( RtlFsm->VEX_COND ); + } + + Support = unionvexexprsupport( Support, RtlFsm->VEX_WEN ); + + for ( ScanChain = Support; + ScanChain != (chain_list *)NULL; + ScanChain = ScanChain->NEXT ) + { + fprintf( VasyFile, "%s", (char *)ScanChain->DATA ); + + if ( ScanChain->NEXT != (chain_list *)NULL ) + { + fprintf( VasyFile, " or " ); + } + } + + freechain( Support ); + + fprintf( VasyFile, " )\n" ); + fprintf( VasyFile, " begin\n" ); + + if ( RtlFsm->VEX_WEN != (vexexpr *)NULL ) + { + fprintf( VasyFile, "\n" ); + fprintf( VasyFile, " if " ); + VasyDriveVerilogVexCond( RtlFsm->VEX_WEN ); + fprintf( VasyFile, "\n" ); + fprintf( VasyFile, " begin\n" ); + } + + fprintf( VasyFile, " case (%s)\n", RtlFsm->NAME ); + + for ( FsmState = RtlFsm->STATE; + FsmState != (rtlfsmstate_list *)NULL; + FsmState = FsmState->NEXT ) + { + fprintf( VasyFile, "\n %s_%s:\n", RtlFsm->NAME, FsmState->NAME ); + fprintf( VasyFile, " begin\n" ); + + ElseIf = 0; + + for ( ScanChain = FsmState->FROM; + ScanChain != (chain_list *)NULL; + ScanChain = ScanChain->NEXT ) + { + FsmTrans = GetRtlFsmTrans( ScanChain ); + + if ( FsmTrans->VEX_COND != (vexexpr *)NULL ) + { + if ( ! ElseIf ) + { + fprintf( VasyFile, " if " ); + } + else + if ( ScanChain->NEXT != (chain_list *)NULL ) + { + fprintf( VasyFile, " else if " ); + } + else + { + fprintf( VasyFile, " else\n" ); + } + + if ( ScanChain->NEXT != (chain_list *)NULL ) + { + VasyDriveVerilogVexCond( FsmTrans->VEX_COND, 1 ); + fprintf( VasyFile, "\n begin\n" ); + } + + ElseIf = 1; + } + + fprintf( VasyFile, " %s = %s;\n", RtlFsm->NAME, FsmTrans->TO->NAME ); + + for ( FsmAsg = FsmTrans->ASSIGN; + FsmAsg != (rtlfsmasg_list *)NULL; + FsmAsg = FsmAsg->NEXT ) + { + fprintf( VasyFile, " " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, FsmAsg->VEX_ATOM ); + fprintf( VasyFile, " = " ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, FsmAsg->VEX_DATA ); + fprintf( VasyFile, ";\n" ); + } + } + + if ( ElseIf ) + { + fprintf( VasyFile, " end\n" ); + } + fprintf( VasyFile, " end\n" ); + } + + fprintf( VasyFile, "\n endcase\n" ); + + if ( RtlFsm->VEX_WEN != (vexexpr *)NULL ) + { + fprintf( VasyFile, " end\n" ); + } + + fprintf( VasyFile, " end\n\n" ); + */ + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogPortMap | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogPortMap( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlmod_list *RtlModel; + rtlins_list *RtlInst; + rtlmap_list *RtlMap; + vexexpr *VexFormal; + vexexpr *VexActual; + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + RtlModel = RtlInst->MODEL; + + fprintf( VasyFile, " %s %s (\n", RtlModel->NAME, RtlInst->NAME ); + RtlMap = RtlInst->MAP; + + while ( RtlMap != (rtlmap_list *)0 ) + { + VexFormal = RtlMap->VEX_FORMAL; + VexActual = RtlMap->VEX_ACTUAL; + + fprintf( VasyFile, " .%s(", GetVexAtomValue( VexFormal ) ); + VasyDriveVexExprVerilog( VasyFile, RtlFigure, VexActual ); + fprintf( VasyFile, ")" ); + + if ( RtlMap->NEXT != (rtlmap_list *)0 ) + { + fprintf( VasyFile, ",\n" ); + } + + RtlMap = RtlMap->NEXT; + } + + fprintf( VasyFile, "\n );\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogArchi | +| | +\------------------------------------------------------------*/ + +static void VasyDriveVerilogArchi( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + VasyDriveVerilogDeclar( RtlFigure, RTL_DECLAR_CONSTANT ); + VasyDriveVerilogDeclar( RtlFigure, RTL_DECLAR_SIGNAL ); + VasyDriveVerilogFsmDeclar( RtlFigure ); + + VasyDriveVerilogAssign( RtlFigure ); + VasyDriveVerilogFsm( RtlFigure ); + VasyDriveVerilogPortMap( RtlFigure ); +} + +/*------------------------------------------------------------\ +| | +| VasyDriveVerilogRtlFig | +| | +\------------------------------------------------------------*/ + +void VasyDriveVerilogRtlFig( RtlFigure, FileName ) + + rtlfig_list *RtlFigure; + char *FileName; +{ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyDriveVerilogRtlFig %s\n", FileName ); + } + + if ( IsVasyDebugDriveStdout() ) + { + VasyFile = stdout; + } + else + { + if ( ! VasyFlagOver ) + { +/* +** First checks to avoid overwriting an existing file ! +*/ + VasyFile = mbkfopen( FileName, "v", "r" ); + + if ( VasyFile != (FILE *)0 ) + { + fclose( VasyFile ); + VasyPrintf( stdout, "ERROR file %s.v already exists, remove it first !\n", + FileName ); + autexit( 1 ); + } + } + + VasyFile = mbkfopen( FileName, "v", "w" ); + } + + if ( VasyFile != (FILE *)NULL ) + { +/* +** Special treatments for verilog +*/ + VasyDriveVerilogTreatFigure( RtlFigure ); + + fprintf( VasyFile, "module %s ", RtlFigure->NAME ); + VasyDriveVerilogEntity( RtlFigure ); + VasyDriveVerilogArchi( RtlFigure ); + fprintf( VasyFile, "\nendmodule\n" ); + + if ( ! IsVasyDebugDriveStdout() ) + { + fclose( VasyFile ); + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyDriveVerilogRtlFig %s\n\n", FileName ); + } +} diff --git a/alliance/src/vasy/src/vasy_drvvlog.h b/alliance/src/vasy/src/vasy_drvvlog.h new file mode 100644 index 00000000..d7e48b0c --- /dev/null +++ b/alliance/src/vasy/src/vasy_drvvlog.h @@ -0,0 +1,87 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_drvvlog.h | +| | +| Authors : Frédéric Pétrot | +| This file is a basic modification of vasy_drvsyn | +| Modified by Ludovic Jacomme | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_DRVVLOG_H +# define VASY_DRVVLOG_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_VERILOG_SENS_NOEDGE 0 +# define VASY_VERILOG_SENS_NEGEDGE 1 +# define VASY_VERILOG_SENS_POSEDGE 2 + +/*------------------------------------------------------------\ +| | +| Rtl Assign Sens | +| | +\------------------------------------------------------------*/ + +# define SetVasyRtlAsgVerilogSens( A, S ) ((A)->USER = (void *)(S)) +# define GetVasyRtlAsgVerilogSens( A ) ((ptype_list *)(A)->USER) + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyDriveVerilogRtlFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_elabo.c b/alliance/src/vasy/src/vasy_elabo.c new file mode 100644 index 00000000..7b43cdbb --- /dev/null +++ b/alliance/src/vasy/src/vasy_elabo.c @@ -0,0 +1,208 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_elabo.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_elabo.h" +# include "vasy_simul.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyElaborateVpnFig | +| | +\------------------------------------------------------------*/ + +void VasyElaborateVpnFig( VpnFigure ) + + vpnfig_list *VpnFigure; +{ + vpnproc_list *VpnProc; + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + vexexpr *DeclAtom; + vexexpr *DeclInit; + vasysimul *SimulInit; + char *SimulValue; + char Buffer[ 2048 ]; + int LiteralId; + short Width; + short Position; + short Type; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyElaborateVpnFig %s\n", VpnFigure->NAME ); + } + + SimulInit = (vasysimul *)0; +/* +** For all declarations set initial value +*/ + for ( Type = 0; Type < VPN_MAX_DECLAR_TYPE; Type++ ) + { + for ( VpnDeclar = VpnFigure->DECLAR[ Type ]; + VpnDeclar != (vpndecl_list *)0; + VpnDeclar = VpnDeclar->NEXT ) + { + DeclAtom = VpnDeclar->VEX_ATOM; + DeclInit = VpnDeclar->VEX_INIT; + Width = DeclAtom->WIDTH; + + if ( DeclInit != (vexexpr *)0 ) + { + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> Initial value of " ); + viewvexexprboundln( DeclAtom ); + } + + SimulInit = VasySimulateVexExpr( VpnFigure, DeclAtom, DeclInit ); + SimulValue = SimulInit->VALUE; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- Initial value\n" ); + } + } + else + { + SimulValue = (char *)0; + } + + for ( Position = 0; Position < Width; Position++ ) + { + VpnSymbol = &VpnDeclar->DECL_SYM[ Position ]; + + if ( SimulValue != (char *)0 ) VpnSymbol->INIT = SimulValue[ Position ]; + else VpnSymbol->INIT = VEX_ZERO_ID; + + VpnSymbol->EFFEC = VpnSymbol->INIT; + VpnSymbol->DRIVE = VpnSymbol->INIT; + VpnSymbol->EVENT = 1; + } + + if ( SimulValue != (char *)0 ) VasySimulateDelSimul( SimulInit ); + } + } +/* +** For all process make elaboration +*/ + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + VasySimulateVpnProc( VpnFigure, VpnProc ); + } +/* +** For all declarations set new init value +*/ + for ( Type = 0; Type < VPN_MAX_DECLAR_TYPE; Type++ ) + { + for ( VpnDeclar = VpnFigure->DECLAR[ Type ]; + VpnDeclar != (vpndecl_list *)0; + VpnDeclar = VpnDeclar->NEXT ) + { + DeclAtom = VpnDeclar->VEX_ATOM; + Width = DeclAtom->WIDTH; + + for ( Position = 0; Position < Width; Position++ ) + { + VpnSymbol = &VpnDeclar->DECL_SYM[ Position ]; + + if ( ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) || + ( VpnDeclar->TYPE == VPN_DECLAR_VARIABLE ) ) LiteralId = VpnSymbol->EFFEC; + else LiteralId = VpnSymbol->DRIVE; + + Buffer[ Position + 1 ] = VEX_LITERAL_BY_ID[ LiteralId ]; + } + + Position++; + + if ( IsVexAtomVector( DeclAtom ) ) + { + Buffer[ 0 ] = '\"'; + Buffer[ Position ] = '\"'; + } + else + { + Buffer[ 0 ] = '\''; + Buffer[ Position ] = '\''; + } + + Buffer[ Position + 1 ] = '\0'; + + freevexexpr( VpnDeclar->VEX_INIT ); + VpnDeclar->VEX_INIT = createvexatomlit( Buffer ); + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyElaborateVpnFig %s\n", VpnFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_elabo.h b/alliance/src/vasy/src/vasy_elabo.h new file mode 100644 index 00000000..c755028c --- /dev/null +++ b/alliance/src/vasy/src/vasy_elabo.h @@ -0,0 +1,93 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_elabo.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_ELABO_H +# define VASY_ELABO_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tag | +| | +\------------------------------------------------------------*/ + +# define VASY_ELABORATE_TAG_MASK (long)0x01 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define SetVasyElaborateTag( O ) ((O)->FLAGS |= VASY_ELABORATE_TAG_MASK) +# define ClearVasyElaborateTag( O ) ((O)->FLAGS &= ~VASY_ELABORATE_TAG_MASK) +# define IsVasyElaborateTag( O ) ((O)->FLAGS & VASY_ELABORATE_TAG_MASK) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ + + typedef struct vasyelab + { + char *VALUE; + unsigned short WIDTH; + unsigned short SIGNED; + + } vasyelab; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyElaborateVpnFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_error.c b/alliance/src/vasy/src/vasy_error.c new file mode 100644 index 00000000..59e0ede3 --- /dev/null +++ b/alliance/src/vasy/src/vasy_error.c @@ -0,0 +1,221 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_error.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Local Display Lines | +| | +\------------------------------------------------------------*/ + +void VasyDisplayLines( VpnLine ) + + vpnline_list *VpnLine; +{ + if ( VpnLine != (vpnline_list *)0 ) + { + fprintf( stderr, " in line [" ); + + while ( VpnLine != (vpnline_list *)0 ) + { + fprintf( stderr, "%ld", VpnLine->LINE ); + + if ( VpnLine->NEXT != (vpnline_list *)0 ) + { + fprintf( stderr, "," ); + } + + VpnLine = VpnLine->NEXT; + } + + fprintf( stderr, "]" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyDisplayError | +| | +\------------------------------------------------------------*/ + +void VasyDisplayError( File, Line, Error, VpnLine, Text ) + + char *File; + int Line; + int Error; + vpnline_list *VpnLine; + char *Text; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%d ", Name, Line ); + mbkfree( Name ); + + switch( Error ) + { + case VASY_ILLEGAL_ASSIGN_ERROR : + fprintf( stderr, "Illegal dynamic assignation of symbol %s", Text ); + break; + case VASY_NO_WAIT_IN_PROCESS_ERROR : + fprintf( stderr, "No wait in process %s", Text ); + break; + case VASY_NOT_YET_IMPLEMENTED_ERROR : + fprintf( stderr, "%s not yet implemented", Text ); + break; + case VASY_LOOP_IN_SIMULATION : + fprintf( stderr, "Loop in elaborate place %s", Text ); + break; + case VASY_ERROR_IN_SIMULATION : + fprintf( stderr, "Elaborate error %s", Text ); + break; + case VASY_ERROR_IN_SUPPORT : + fprintf( stderr, "Support error bad operator %s", Text ); + break; + case VASY_ERROR_IN_VEX2BDD : + fprintf( stderr, "Vex2Bdd error bad operator %s", Text ); + break; + case VASY_ERROR_IN_ABL2VEX : + fprintf( stderr, "Abl2Vex error bad operator %s", Text ); + break; + case VASY_ERROR_IN_DRVVEX : + fprintf( stderr, "DrvVex error bad operator %ld", (long)Text ); + break; + case VASY_ERROR_OPERATOR_NOT_SUPPORTED : + fprintf( stderr, "SimpRtl error bad operator %s", Text ); + break; + case VASY_ERROR_IN_UNROLL_LOOP : + fprintf( stderr, "Non static range in FOR loop" ); + break; + case VASY_LOOP_IN_REDUCTION : + fprintf( stderr, "Loop in reduction transition %s", Text ); + break; + case VASY_ERROR_ILLEGAL_USE_OF : + fprintf( stderr, "Illegale use of %s", Text ); + break; + case VASY_ERROR_CONVERT_WRONG_TYPE : + fprintf( stderr, "Unable to convert, wrong type %s", Text ); + return; + break; + + default : fprintf( stderr, "Internal error number %d", Error ); + } + + VasyDisplayLines( VpnLine ); + fprintf( stderr, "\n" ); + + autexit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| VasyDisplayWarning | +| | +\------------------------------------------------------------*/ + +void VasyDisplayWarning( File, Line, Warning, VpnLine, Text ) + + char *File; + int Line; + int Warning; + vpnline_list *VpnLine; + char *Text; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%d ", Name, Line ); + + switch ( Warning ) + { + case VASY_WARNING_IN_SIMULATION : + fprintf( stderr, "Elaborate warning %s", Text ); + break; + default : fprintf( stderr, "Internal warning number %d", Warning ); + } + + VasyDisplayLines( VpnLine ); + fprintf( stderr, "\n" ); +} diff --git a/alliance/src/vasy/src/vasy_error.h b/alliance/src/vasy/src/vasy_error.h new file mode 100644 index 00000000..b65e860e --- /dev/null +++ b/alliance/src/vasy/src/vasy_error.h @@ -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 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 : VASY | +| | +| File : vasy_error.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_ERROR_H +# define VASY_ERROR_H + +/*------------------------------------------------------------\ +| | +| Errors | +| | +\------------------------------------------------------------*/ + +# define VASY_ILLEGAL_ASSIGN_ERROR 0 +# define VASY_NO_WAIT_IN_PROCESS_ERROR 1 +# define VASY_NOT_YET_IMPLEMENTED_ERROR 2 +# define VASY_LOOP_IN_SIMULATION 3 +# define VASY_ERROR_IN_SIMULATION 4 +# define VASY_ERROR_IN_SUPPORT 5 +# define VASY_ERROR_IN_VEX2BDD 6 +# define VASY_ERROR_IN_ABL2VEX 7 +# define VASY_ERROR_IN_DRVVEX 8 +# define VASY_ERROR_OPERATOR_NOT_SUPPORTED 9 +# define VASY_ERROR_IN_UNROLL_LOOP 10 +# define VASY_LOOP_IN_REDUCTION 11 +# define VASY_ERROR_ILLEGAL_USE_OF 12 +# define VASY_ERROR_CONVERT_WRONG_TYPE 13 + +# define VASY_WARNING_IN_SIMULATION 1 + +/*------------------------------------------------------------\ +| | +| Warnings | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define VasyError( E, T ) \ + \ + VasyDisplayError( __FILE__, __LINE__, (E), (vpnline_list *)0, (T) ) + +# define VasyWarning( W, T ) \ + \ + VasyDisplayWarning( __FILE__, __LINE__, (W), (vpnline_list *)0, (T) ) + +# define VasyErrorLine( E, L, T ) \ + \ + VasyDisplayError( __FILE__, __LINE__, (E), (vpnline_list *)(L), (T) ) + +# define VasyWarningLine( W, L, T ) \ + \ + VasyDisplayWarning( __FILE__, __LINE__, (W), (vpnline_list *)(L), (T) ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyDisplayError(); + extern void VasyDisplayWarning(); + extern void VasyDisplayLines(); + +# endif diff --git a/alliance/src/vasy/src/vasy_func.c b/alliance/src/vasy/src/vasy_func.c new file mode 100644 index 00000000..63247871 --- /dev/null +++ b/alliance/src/vasy/src/vasy_func.c @@ -0,0 +1,454 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_func.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_func.h" +# include "vasy_redact.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static vpnline_list *VasyVpnLine = (vpnline_list *)0; + +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# if 0 +/*------------------------------------------------------------\ +| | +| VasyFuncAddVpnDefine | +| | +\------------------------------------------------------------*/ + +static vpndecl_list *VasyFuncAddVpnDefine( VpnFigure, VpnProc, Width, DefBase ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + unsigned short Width; + unsigned char DefBase; +{ + vpndecl_list *DefDeclar; + vexexpr *DefAtom; + char *FatherName; + char Buffer[ 128 ]; + unsigned char NewBase; + long Number; + + FatherName = VpnProc->NAME; + Number = GetVpnNumDeclDef( VpnFigure ); + + sprintf( Buffer, "%s_std_%ld", FatherName, Number ); + + NewBase = getvextypescalar( DefBase ); + + if ( ( isvextypevector( DefBase ) ) && + ( ( Width > 1 ) || + ( NewBase == DefBase ) ) ) + { + DefAtom = createvexatomvec( Buffer, Width - 1, 0 ); + } + else + { + DefAtom = createvexatombit( Buffer ); + DefBase = NewBase; + } + + DefDeclar = addvpndeclprocdef( VpnFigure, VpnProc, DefAtom, DefBase ); + + return( DefDeclar ); +} +# endif + +/*------------------------------------------------------------\ +| | +| VasyFuncSubstVexStdFunc | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyFuncSubstVexStdFunc( Expr ) + + vexexpr *Expr; +{ + vexexpr *Operand; + vexexpr *VexInt; + chain_list *ScanChain; + long Length; + int FuncId; + char *FuncName; + + if ( ( IsVexNodeOper( Expr ) ) || + ( IsVexNodeFunc( Expr ) ) ) + { + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Operand = VasyFuncSubstVexStdFunc( Operand ); + SetVexOperand( ScanChain, Operand ); + } + + if ( IsVexNodeFunc( Expr ) ) + { + FuncName = GetVexFuncValue( Expr ); + + FuncId = getvexstdfuncid( FuncName ); + + if ( FuncId != -1 ) + { + switch ( FuncId ) + { + case VEX_STD_TO_BIT : + case VEX_STD_TO_BITVECTOR : + case VEX_STD_TO_STDULOGIC : + case VEX_STD_TO_STDLOGICVECTOR : + case VEX_STD_TO_STDULOGICVECTOR : + case VEX_STD_TO_X01 : + case VEX_STD_TO_X01Z : + case VEX_STD_TO_UX01 : + case VEX_STD_CONV_INTEGER : + case VEX_STD_RISING_EDGE : + case VEX_STD_FALLING_EDGE : + case VEX_STD_STD_LOGIC_VECTOR : + case VEX_STD_STD_ULOGIC_VECTOR : + case VEX_STD_SIGNED : + case VEX_STD_UNSIGNED : + case VEX_STD_TO_INTEGER : + + Operand = GetVexOperand( Expr->OPERAND ); + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + if ( FuncId == VEX_STD_FALLING_EDGE ) + { + Expr = createvexunaryexpr( VEX_EVENT, 1, dupvexexpr( Operand ) ); + Operand = createvexunaryexpr( VEX_NOT , 1, Operand ); + Expr = createvexbinexpr( VEX_AND , 1, Expr, Operand ); + } + else + if ( FuncId == VEX_STD_RISING_EDGE ) + { + Expr = createvexunaryexpr( VEX_EVENT, 1, dupvexexpr( Operand ) ); + Expr = createvexbinexpr( VEX_AND , 1, Expr, Operand ); + } + else + { + Expr = Operand; + + if ( FuncId == VEX_STD_SIGNED ) + { + SetVexNodeSigned( Expr ); + } + else + if ( FuncId == VEX_STD_UNSIGNED ) + { + ClearVexNodeSigned( Expr ); + } + } + + break; + + case VEX_STD_ABS : + + SetVexNodeOper( Expr ); + SetVexOperValue( Expr, VEX_ABS ); + + break; + + case VEX_STD_TO_UNSIGNED : + case VEX_STD_TO_SIGNED : + case VEX_STD_CONV_UNSIGNED : + case VEX_STD_CONV_SIGNED : + case VEX_STD_CONV_STD_LOGIC_VECTOR : + case VEX_STD_EXT : + case VEX_STD_SXT : + case VEX_STD_RESIZE : + + Operand = GetVexOperand( Expr->OPERAND ); + VexInt = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( evalvexatomlong( VexInt, &Length ) ) + { + VasyErrorLine( VASY_ERROR_ILLEGAL_USE_OF, + VasyVpnLine, GetVexFuncValue( Expr ) ); + } + + if ( ( Operand->WIDTH != Length ) && + ( IsVexNodeAtom( Operand ) ) ) + { + if ( FuncId == VEX_STD_SXT ) SetVexNodeSigned( Operand ); + + Operand = extendvexatomsign( Operand, Length ); + } + + if ( Operand->WIDTH == Length ) + { + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + Expr = Operand; + } + else + { + VasyErrorLine( VASY_ERROR_ILLEGAL_USE_OF, + VasyVpnLine, GetVexFuncValue( Expr ) ); + } + + + if ( ( FuncId == VEX_STD_TO_SIGNED ) || + ( FuncId == VEX_STD_CONV_SIGNED ) ) + { + SetVexNodeSigned( Expr ); + } + else + if ( FuncId != VEX_STD_RESIZE ) + { + ClearVexNodeSigned( Expr ); + } + + break; + + case VEX_STD_SHL : + case VEX_STD_SHIFT_LEFT : + case VEX_STD_SHR : + case VEX_STD_SHIFT_RIGHT : + + Operand = GetVexOperand( Expr->OPERAND ); + VexInt = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( evalvexatomlong( VexInt, &Length ) ) + { + VasyErrorLine( VASY_ERROR_ILLEGAL_USE_OF, + VasyVpnLine, GetVexFuncValue( Expr ) ); + } + + if ( IsVexNodeAtom( Operand ) ) + { + if ( ( FuncId == VEX_STD_SHL ) || + ( FuncId == VEX_STD_SHIFT_LEFT ) ) + { + Operand = shiftvexatomleft( Operand, Length ); + } + else + { + Operand = shiftvexatomright( Operand, Length ); + } + + SetVexOperand( Expr->OPERAND, (vexexpr *)0 ); + freevexexpr( Expr ); + + Expr = Operand; + } + else + { + VasyErrorLine( VASY_ERROR_ILLEGAL_USE_OF, + VasyVpnLine, GetVexFuncValue( Expr ) ); + } + + break; + + default : + + VasyErrorLine( VASY_NOT_YET_IMPLEMENTED_ERROR, VasyVpnLine, "standard function" ); + + /* VEX_STD_IS_X + VEX_STD_ROTATE_LEFT + VEX_STD_ROTATE_RIGHT + */ + } + } + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasyFuncVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyFuncVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpnact_list *VpnAction; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyFuncVpnProc %s\n", VpnProc->NAME ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + VasyVpnLine = VpnAction->LINE; + VpnAction->VEX_EXPR = VasyFuncSubstVexStdFunc( VpnAction->VEX_EXPR ); + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyFuncVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyFuncVpnInst | +| | +\------------------------------------------------------------*/ + +static void VasyFuncVpnInst( VpnFigure, VpnInst ) + + vpnfig_list *VpnFigure; + vpnins_list *VpnInst; +{ + vpnmap_list *VpnMap; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyFuncVpnInst %s\n", VpnInst->NAME ); + } + + for ( VpnMap = VpnInst->MAP; + VpnMap != (vpnmap_list *)0; + VpnMap = VpnMap->NEXT ) + { + VasyVpnLine = VpnMap->LINE; + VpnMap->VEX_ACTUAL = VasyFuncSubstVexStdFunc( VpnMap->VEX_ACTUAL ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyFuncVpnInst %s\n", VpnInst->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyFuncVpnFig | +| | +\------------------------------------------------------------*/ + +void VasyFuncVpnFig( VpnFigure ) + + vpnfig_list *VpnFigure; +{ + vpnproc_list *VpnProc; + vpnins_list *VpnInst; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyFuncVpnFig %s\n", VpnFigure->NAME ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + VasyFuncVpnProc( VpnFigure, VpnProc ); + } + + for ( VpnInst = VpnFigure->INSTANCE; + VpnInst != (vpnins_list *)0; + VpnInst = VpnInst->NEXT ) + { + VasyFuncVpnInst( VpnFigure, VpnInst ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyFuncVpnFig %s\n\n", VpnFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_func.h b/alliance/src/vasy/src/vasy_func.h new file mode 100644 index 00000000..da581d14 --- /dev/null +++ b/alliance/src/vasy/src/vasy_func.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_func.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_FUNC_H +# define VASY_FUNC_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyFuncVpnFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_generate.c b/alliance/src/vasy/src/vasy_generate.c new file mode 100644 index 00000000..18c66b80 --- /dev/null +++ b/alliance/src/vasy/src/vasy_generate.c @@ -0,0 +1,970 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_generate.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.02.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vbh.h" + +# include "vasy_generate.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashConstant = (authtable *)0; + static authtable *VasyHashGeneric = (authtable *)0; + static authtable *VasyHashForIndex = (authtable *)0; + + static char *VasyGenerateLabel = (char *)0; + + static char VasyBuffer[ 512 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyGenerateSubstAllConst | +| | +\------------------------------------------------------------*/ + +static void VasyGenerateSubstAllConst( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + vbcst_list *VbhConst; + vbgen_list *VbhGen; + char *AtomValue; + vexexpr *VexConst; + authelem *Element; + /* ICI BIG BUG !! + short Signed; + */ + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashConstant, AtomValue ); + + if ( Element == (authelem *)0 ) + { + Element = searchauthelem( VasyHashGeneric, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VbhGen = (vbgen_list *)Element->VALUE; + + VasyGenerateSubstAllConst( VbhGen->VEX ); + VbhGen->VEX = simpvexexpr( VbhGen->VEX ); + + VexConst = VbhGen->VEX; + } + } + else + { + VbhConst = (vbcst_list *)Element->VALUE; + + VasyGenerateSubstAllConst( VbhConst->VEX ); + VbhConst->VEX = simpvexexpr( VbhConst->VEX ); + + VexConst = VbhConst->VEX; + } + + if ( Element != (authelem *)0 ) + { + /* ICI BIG BUG !! + if ( IsVexNodeSigned( VexExpr ) ) Signed = 1; + else Signed = 0; + */ + + VexExpr->VALUE = VexConst->VALUE; + VexExpr->TYPE = VexConst->TYPE; + VexExpr->WIDTH = VexConst->WIDTH; + VexExpr->LEFT = VexConst->LEFT; + VexExpr->RIGHT = VexConst->RIGHT; + + /* ICI BIG BUG !! + if ( Signed ) SetVexNodeSigned( VexExpr ); + else ClearVexNodeSigned( VexExpr ); + */ + } + } + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasyGenerateSubstAllConst( GetVexOperand( ScanOper ) ); + } + } +} +/*------------------------------------------------------------\ +| | +| VasyGenerateSubstConst | +| | +\------------------------------------------------------------*/ + +static void VasyGenerateSubstConst( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + vbcst_list *VbhConst; + vbgen_list *VbhGen; + char *AtomValue; + vexexpr *VexConst; + authelem *Element; + /* ICI BIG BUG !! + short Signed; + */ + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashConstant, AtomValue ); + + if ( Element == (authelem *)0 ) + { + Element = searchauthelem( VasyHashGeneric, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VbhGen = (vbgen_list *)Element->VALUE; + VexConst = VbhGen->VEX; + } + } + else + { + VbhConst = (vbcst_list *)Element->VALUE; + VexConst = VbhConst->VEX; + } + + if ( Element != (authelem *)0 ) + { + /* ICI BIG BUG !! + if ( IsVexNodeSigned( VexExpr ) ) Signed = 1; + else Signed = 0; + */ + + VexExpr->VALUE = VexConst->VALUE; + VexExpr->TYPE = VexConst->TYPE; + VexExpr->WIDTH = VexConst->WIDTH; + VexExpr->LEFT = VexConst->LEFT; + VexExpr->RIGHT = VexConst->RIGHT; + + /* ICI BIG BUG !! + if ( Signed ) SetVexNodeSigned( VexExpr ); + else ClearVexNodeSigned( VexExpr ); + */ + } + } + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasyGenerateSubstConst( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateVexExpr | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyGenerateVexExpr( VexExpr ) + + vexexpr *VexExpr; +{ + authelem *Element; + chain_list *ScanOper; + vexexpr *Operand; + char *Name; + int Width; + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + Name = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashForIndex, Name ); + + if ( Element != (authelem *)0 ) + { + Width = VexExpr->WIDTH; + freevexexpr( VexExpr ); + + VexExpr = createvexatomlong( Element->VALUE, Width, 2 ); + } + } + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasyGenerateVexExpr( Operand ); + SetVexOperand( ScanOper, Operand ); + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateForVexExpr | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyGenerateForVexExpr( VexExpr ) + + vexexpr *VexExpr; +{ + if ( VexExpr != (vexexpr *)0 ) + { + VexExpr = dupvexexpr( VexExpr ); + VexExpr = VasyGenerateVexExpr( VexExpr ); + VexExpr = simpvexexpr( VexExpr ); + } + + return( VexExpr ); +} + + +/*------------------------------------------------------------\ +| | +| VasyGenerateIsVexCondTrue | +| | +\------------------------------------------------------------*/ + +static int VasyGenerateIsVexCondTrue( VexExpr ) + + vexexpr *VexExpr; +{ + char *AtomValue; + + if ( ( IsVexNodeAtom( VexExpr ) ) && + ( IsVexAtomLiteral( VexExpr ) ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + + if ( AtomValue == VEX_ATOM_ONE ) return( 1 ); + if ( AtomValue == VEX_ATOM_ZERO ) return( 0 ); + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateForRenameLabel | +| | +\------------------------------------------------------------*/ + +static char *VasyGenerateForRenameLabel( Label ) + + char *Label; +{ + sprintf( VasyBuffer, "%s_%s", VasyGenerateLabel, Label ); + Label = namealloc( VasyBuffer ); + + return( Label ); +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateForDupInst | +| | +\------------------------------------------------------------*/ + +static ptype_list *VasyGenerateForDupInst( Instruction ) + + ptype_list *Instruction; +{ + vbasg_list *ScanAsg; + vbagr_list *ScanAgr; + vbvar_list *ScanVar; + vbwas_list *ScanWait; + vbnxt_list *ScanNext; + vbext_list *ScanExit; + vbret_list *ScanReturn; + vbcal_list *ScanCall; + vbifs_list *ScanIfs; + vbcas_list *ScanCase; + vbcho_list *ScanChoice; + vblop_list *ScanLoop; + vbfor_list *ScanFor; + vbwhi_list *ScanWhile; + vbasg_list *NewAsg; + vbagr_list *NewAgr; + vbvar_list *NewVar; + vbwas_list *NewWait; + vbnxt_list *NewNext; + vbext_list *NewExit; + vbret_list *NewReturn; + vbcal_list *NewCall; + vbifs_list *NewIfs; + vbcas_list *NewCase; + vbcho_list *NewChoice; + vblop_list *NewLoop; + vbfor_list *NewFor; + vbwhi_list *NewWhile; + ptype_list *NewInstruction; + chain_list *ScanChain; + chain_list *ScanValue; + void *Pointer; + int InstType; + int Offset; + + NewInstruction = (ptype_list *)0; + + while ( Instruction != (ptype_list *)0 ) + { + InstType = Instruction->TYPE; + Pointer = (void *)0; + + switch ( InstType ) + { + case VBH_BEASG : + + ScanAsg = (vbasg_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbasg_list ) ); + NewAsg = (vbasg_list *)Pointer; + + NewAsg->TARGET = VasyGenerateForVexExpr( ScanAsg->TARGET ); + NewAsg->VEX = VasyGenerateForVexExpr( ScanAsg->VEX ); + NewAsg->TYPE = ScanAsg->TYPE; + NewAsg->LINE = ScanAsg->LINE; + + break; + + case VBH_BEVAR : + + ScanVar = (vbvar_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbvar_list ) ); + NewVar = (vbvar_list *)Pointer; + + NewVar->TARGET = VasyGenerateForVexExpr( ScanVar->TARGET ); + NewVar->VEX = VasyGenerateForVexExpr( ScanVar->VEX ); + NewVar->TYPE = ScanVar->TYPE; + NewVar->LINE = ScanVar->LINE; + + break; + + case VBH_BENXT : + + ScanNext = (vbnxt_list *)Instruction->DATA; + + Pointer = autallocheap( sizeof( vbnxt_list ) ); + NewNext = (vbnxt_list *)Pointer; + + NewNext->LINE = ScanNext->LINE; + NewNext->CND = VasyGenerateForVexExpr( ScanNext->CND ); + NewNext->LABEL = VasyGenerateForRenameLabel( ScanNext->LABEL ); + + break; + + case VBH_BEEXT : + + ScanExit = (vbext_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbext_list ) ); + NewExit = (vbext_list *)Pointer; + + NewExit->LINE = ScanExit->LINE; + NewExit->CND = VasyGenerateForVexExpr( ScanExit->CND ); + NewExit->LABEL = VasyGenerateForRenameLabel( ScanExit->LABEL ); + + break; + + case VBH_BEWAS : + + ScanWait = (vbwas_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbwas_list ) ); + NewWait = (vbwas_list *)Pointer; + + for ( ScanChain = ScanWait->SEN; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + NewWait->SEN = addchain( NewWait->SEN, ScanChain->DATA ); + } + + NewWait->CND = VasyGenerateForVexExpr( ScanWait->CND ); + NewWait->TIME_UNIT = ScanWait->TIME_UNIT; + NewWait->TIMEOUT = ScanWait->TIMEOUT; + NewWait->LINE = ScanWait->LINE; + + break; + + case VBH_BERET : + + ScanReturn = (vbret_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbret_list ) ); + NewReturn = (vbret_list *)Pointer; + + NewReturn->RET = VasyGenerateForVexExpr( ScanReturn->RET ); + NewReturn->LINE = ScanReturn->LINE; + + break; + + case VBH_BECAL : + + ScanCall = (vbcal_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbcal_list ) ); + NewCall = (vbcal_list *)Pointer; + + NewCall->CALL = VasyGenerateForVexExpr( ScanCall->CALL ); + NewCall->LINE = ScanCall->LINE; + + break; + + case VBH_BEAGR : + + ScanAgr = (vbagr_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbagr_list ) ); + NewAgr = (vbagr_list *)Pointer; + + NewAgr->ASSIGN = VasyGenerateForDupInst( ScanAgr->ASSIGN ); + NewAgr->LINE = ScanAgr->LINE; + + break; + + case VBH_BEIFS : + + ScanIfs = (vbifs_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbifs_list ) ); + NewIfs = (vbifs_list *)Pointer; + + NewIfs->CND = VasyGenerateForVexExpr( ScanIfs->CND ); + NewIfs->CNDTRUE = VasyGenerateForDupInst( ScanIfs->CNDTRUE ); + NewIfs->CNDFALSE = VasyGenerateForDupInst( ScanIfs->CNDFALSE ); + NewIfs->LINE = ScanIfs->LINE; + + break; + + case VBH_BECAS : + + ScanCase = (vbcas_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbcas_list ) ); + NewCase = (vbcas_list *)Pointer; + + NewCase->VEX = VasyGenerateForVexExpr( ScanCase->VEX ); + NewCase->TYPE = ScanCase->TYPE; + NewCase->LINE = ScanCase->LINE; + + NewCase->SIZE = ScanCase->SIZE; + NewCase->CHOICE = (vbcho_list *)autallocblock( ScanCase->SIZE * sizeof( vbcho_list ) ); + + for ( Offset = 0; Offset < ScanCase->SIZE; Offset++ ) + { + ScanChoice = &ScanCase->CHOICE[ Offset ]; + NewChoice = &NewCase->CHOICE[ Offset ]; + + NewChoice->INSTRUCTION = VasyGenerateForDupInst( ScanChoice->INSTRUCTION ); + + NewChoice->VALUES = (chain_list *)0; + + for ( ScanValue = ScanChoice->VALUES; + ScanValue != (chain_list *)0; + ScanValue = ScanValue->NEXT ) + { + NewChoice->VALUES = addchain( NewChoice->VALUES, ScanValue->DATA ); + } + + NewChoice->SIZE = ScanChoice->SIZE ; + NewChoice->LINE = ScanChoice->LINE; + } + + break; + + case VBH_BEFOR : + + ScanFor = (vbfor_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbfor_list ) ); + NewFor = (vbfor_list *)Pointer; + + NewFor->INSTRUCTION = VasyGenerateForDupInst( ScanFor->INSTRUCTION ); + NewFor->LABEL = VasyGenerateForRenameLabel( ScanFor->LABEL ); + NewFor->VARIABLE = VasyGenerateForVexExpr( ScanFor->VARIABLE ); + NewFor->LEFT = VasyGenerateForVexExpr( ScanFor->LEFT ); + NewFor->RIGHT = VasyGenerateForVexExpr( ScanFor->RIGHT ); + NewFor->UP = ScanFor->UP; + NewFor->LINE = ScanFor->LINE; + + break; + + case VBH_BEWHI : + + ScanWhile = (vbwhi_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbwhi_list ) ); + NewWhile = (vbwhi_list *)Pointer; + + NewWhile->INSTRUCTION = VasyGenerateForDupInst( ScanWhile->INSTRUCTION ); + NewWhile->LABEL = VasyGenerateForRenameLabel( ScanWhile->LABEL ); + NewWhile->CND = VasyGenerateForVexExpr( ScanWhile->CND ); + NewWhile->LINE = ScanWhile->LINE; + + break; + + case VBH_BELOP : + + ScanLoop = (vblop_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vblop_list ) ); + NewLoop = (vblop_list *)Pointer; + + NewLoop->INSTRUCTION = VasyGenerateForDupInst( ScanLoop->INSTRUCTION ); + NewLoop->LABEL = VasyGenerateForRenameLabel( ScanLoop->LABEL ); + NewLoop->LINE = ScanLoop->LINE; + + break; + } + + if ( Pointer != (void *)0 ) + { + NewInstruction = addptype( NewInstruction, InstType, Pointer ); + } + + Instruction = Instruction->NEXT; + } + + NewInstruction = (ptype_list *)reverse( (chain_list *)NewInstruction ); + + return( NewInstruction ); +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateForDupInstance | +| | +\------------------------------------------------------------*/ + +static void VasyGenerateForDupInstance( VbhFigure, VbhGenerate ) + + + vbfig_list *VbhFigure; + vbgnr_list *VbhGenerate; +{ + vbins_list *ScanInstance; + vbmap_list *ScanMap; + vbins_list *NewInstance; + + for ( ScanInstance = VbhGenerate->BEINS; + ScanInstance != (vbins_list *)0; + ScanInstance = ScanInstance->NEXT ) + { + sprintf( VasyBuffer, "%s_%s", VasyGenerateLabel, ScanInstance->NAME ); + + VbhFigure->BEINS = vbh_addvbins( VbhFigure->BEINS, + VasyBuffer, ScanInstance->MODEL, ScanInstance->LINE ); + + NewInstance = VbhFigure->BEINS; + + for ( ScanMap = ScanInstance->PORT_MAP; + ScanMap != (vbmap_list *)0; + ScanMap = ScanMap->NEXT ) + { + NewInstance->PORT_MAP = vbh_addvbmap( NewInstance->PORT_MAP, + VasyGenerateForVexExpr( ScanMap->FORMAL ), + VasyGenerateForVexExpr( ScanMap->ACTUAL ), ScanMap->LINE ); + } + + for ( ScanMap = ScanInstance->GEN_MAP; + ScanMap != (vbmap_list *)0; + ScanMap = ScanMap->NEXT ) + { + NewInstance->GEN_MAP = vbh_addvbmap( NewInstance->GEN_MAP, + VasyGenerateForVexExpr( ScanMap->FORMAL ), + VasyGenerateForVexExpr( ScanMap->ACTUAL ), ScanMap->LINE ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateForDupProcess | +| | +\------------------------------------------------------------*/ + +static void VasyGenerateForDupProcess( VbhFigure, VbhGenerate ) + + + vbfig_list *VbhFigure; + vbgnr_list *VbhGenerate; +{ + vbpcs_list *ScanProcess; + vbpcs_list *NewProcess; + chain_list *NewSens; + chain_list *ScanSens; + + for ( ScanProcess = VbhGenerate->BEPCS; + ScanProcess != (vbpcs_list *)0; + ScanProcess = ScanProcess->NEXT ) + { + sprintf( VasyBuffer, "%s_%s", VasyGenerateLabel, ScanProcess->LABEL ); + + VbhFigure->BEPCS = vbh_addvbpcs( VbhFigure->BEPCS, + VasyBuffer, (chain_list *)0, (ptype_list *)0, ScanProcess->LINE ); + + NewProcess = VbhFigure->BEPCS; + NewProcess->TYPE = ScanProcess->TYPE; +/* +** Process sensitivity list +*/ + NewSens = (chain_list *)0; + + for ( ScanSens = ScanProcess->SENSITIVITY; + ScanSens != (chain_list *)0; + ScanSens = ScanSens->NEXT ) + { + NewSens = addchain( NewSens, ScanSens->DATA ); + } + + NewProcess->SENSITIVITY = NewSens; +/* +** Process variables +*/ + NewProcess->VARIABLE = VasyGenerateForDupInst( ScanProcess->VARIABLE ); +/* +** Process instruction +*/ + NewProcess->INSTRUCTION = VasyGenerateForDupInst( ScanProcess->INSTRUCTION ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateIf | +| | +\------------------------------------------------------------*/ + +static void VasyGenerateFor(); + +static void VasyGenerateIf( VbhFigure, VbhGenerate ) + + vbfig_list *VbhFigure; + vbgnr_list *VbhGenerate; +{ + vbgnr_list *ScanGenerate; + char *OldLabel; + vexexpr *VexCond; + int TrueFalse; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyGenerateIf %s\n", VbhGenerate->LABEL ); + } + + VexCond = VbhGenerate->IF_COND; + VasyGenerateSubstConst( VexCond ); + VexCond = simpvexexpr( VexCond ); + VbhGenerate->IF_COND = VexCond; + + VexCond = VasyGenerateForVexExpr( VexCond ); + TrueFalse = VasyGenerateIsVexCondTrue( VexCond ); + + if ( TrueFalse == -1 ) + { + viewvexexprboundln( VexCond ); + VasyError( VASY_ERROR_ILLEGAL_USE_OF, "if generate condition" ); + } + else + if ( TrueFalse == 1 ) + { + OldLabel = VasyGenerateLabel; + sprintf( VasyBuffer, "%s_%s_if", OldLabel, VbhGenerate->LABEL ); + VasyGenerateLabel = namealloc( VasyBuffer ); + + for ( ScanGenerate = VbhGenerate->BEGNR; + ScanGenerate != (vbgnr_list *)0; + ScanGenerate = ScanGenerate->NEXT ) + { + if ( VbhGenerate->TYPE == VBH_GENERATE_FOR ) + { + VasyGenerateFor( &VbhGenerate->BEPCS, &VbhGenerate->BEINS, ScanGenerate ); + } + else + { + VasyGenerateIf( &VbhGenerate->BEPCS, &VbhGenerate->BEINS, ScanGenerate ); + } + } + + VasyGenerateForDupProcess( VbhFigure, VbhGenerate ); + VasyGenerateForDupInstance( VbhFigure, VbhGenerate ); + + VasyGenerateLabel = OldLabel; + } + + freevexexpr( VexCond ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyGenerateIf %s\n", VbhGenerate->LABEL ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateFor | +| | +\------------------------------------------------------------*/ + +static void VasyGenerateFor( VbhFigure, VbhGenerate ) + + vbfig_list *VbhFigure; + vbgnr_list *VbhGenerate; +{ + vbgnr_list *ScanGenerate; + vexexpr *VexLeft; + vexexpr *VexRight; + vexexpr *VexAtom; + char *OldLabel; + char *IndexName; + long IndexValue; + long Left; + long Right; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyGenerateFor %s\n", VbhGenerate->LABEL ); + } + + VexAtom = VbhGenerate->FOR_VARIABLE; + + VexLeft = VbhGenerate->FOR_LEFT; + VasyGenerateSubstConst( VexLeft ); + VexLeft = simpvexexpr( VexLeft ); + VbhGenerate->FOR_LEFT = VexLeft; + + VexRight = VbhGenerate->FOR_RIGHT; + VasyGenerateSubstConst( VexRight ); + VexRight = simpvexexpr( VexRight ); + VbhGenerate->FOR_RIGHT = VexRight; + + IndexName = GetVexAtomValue( VexAtom ); + + if ( ( evalvexatomlong( VexLeft, &Left ) ) || + ( evalvexatomlong( VexRight, &Right ) ) ) + { + VasyError( VASY_ERROR_IN_UNROLL_LOOP, (char *)0 ); + } + + OldLabel = VasyGenerateLabel; + IndexValue = Left; + + while ( ( ( IndexValue <= Right ) && ( VbhGenerate->FOR_UP ) ) || + ( ( IndexValue >= Right ) && ( ! VbhGenerate->FOR_UP ) ) ) + { + sprintf( VasyBuffer, "%s_%s_%ld", OldLabel, VbhGenerate->LABEL, IndexValue ); + VasyGenerateLabel = namealloc( VasyBuffer ); + + addauthelem( VasyHashForIndex, IndexName, IndexValue ); + + if ( IsVasyDebugLevel0() ) + { + fprintf( stdout, "%s = %ld\n", IndexName, IndexValue ); + } + + for ( ScanGenerate = VbhGenerate->BEGNR; + ScanGenerate != (vbgnr_list *)0; + ScanGenerate = ScanGenerate->NEXT ) + { + if ( ScanGenerate->TYPE == VBH_GENERATE_FOR ) + { + VasyGenerateFor( VbhFigure, ScanGenerate ); + } + else + { + VasyGenerateIf( VbhFigure, ScanGenerate ); + } + } + + VasyGenerateForDupInstance( VbhFigure, VbhGenerate ); + VasyGenerateForDupProcess( VbhFigure, VbhGenerate ); + + if ( VbhGenerate->FOR_UP ) IndexValue++; + else IndexValue--; + } + + delauthelem( VasyHashForIndex, IndexName ); + + VasyGenerateLabel = OldLabel; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyGenerateFor %s\n", VbhGenerate->LABEL ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenerateVbhFig | +| | +\------------------------------------------------------------*/ + +void VasyGenerateVbhFig( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbgnr_list *VbhGenerate; + vbgen_list *VbhGeneric; + vbcst_list *VbhConstant; + char *Name; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyGenerateVbhFig %s\n", VbhFigure->NAME ); + } + + VasyHashConstant = createauthtable( 100 ); + VasyHashGeneric = createauthtable( 100 ); + VasyHashForIndex = createauthtable( 100 ); + + VasyGenerateLabel = VbhFigure->NAME; + + for ( VbhGeneric = VbhFigure->BEGEN; + VbhGeneric != (vbgen_list *)0; + VbhGeneric = VbhGeneric->NEXT ) + { + Name = getvexatomname( VbhGeneric->TARGET ); + addauthelem( VasyHashGeneric, Name, (long)VbhGeneric ); + VasyGenerateSubstConst( VbhGeneric->VEX ); + } + + for ( VbhConstant = VbhFigure->BECST; + VbhConstant != (vbcst_list *)0; + VbhConstant = VbhConstant->NEXT ) + { + Name = getvexatomname( VbhConstant->TARGET ); + addauthelem( VasyHashConstant, Name, (long)VbhConstant ); + } +/* +** Propagates all constants and generic values in their own declarations +*/ + for ( VbhGeneric = VbhFigure->BEGEN; + VbhGeneric != (vbgen_list *)0; + VbhGeneric = VbhGeneric->NEXT ) + { + VasyGenerateSubstAllConst( VbhGeneric->VEX ); + } + + for ( VbhConstant = VbhFigure->BECST; + VbhConstant != (vbcst_list *)0; + VbhConstant = VbhConstant->NEXT ) + { + VasyGenerateSubstAllConst( VbhConstant->VEX ); + } +/* +** Generate +*/ + for ( VbhGenerate = VbhFigure->BEGNR; + VbhGenerate != (vbgnr_list *)0; + VbhGenerate = VbhGenerate->NEXT ) + { + if ( VbhGenerate->TYPE == VBH_GENERATE_FOR ) + { + VasyGenerateFor( VbhFigure, VbhGenerate ); + } + else + { + VasyGenerateIf( VbhFigure, VbhGenerate ); + } + } + + vbh_frevbgnr( VbhFigure->BEGNR ); + VbhFigure->BEGNR = (vbgnr_list *)0; + + destroyauthtable( VasyHashConstant ); + destroyauthtable( VasyHashGeneric ); + destroyauthtable( VasyHashForIndex ); + + if ( IsVasyDebugLevel1() ) + { + vbh_viewvbfig( VbhFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyGenerateVbhFig %s\n\n", VbhFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_generate.h b/alliance/src/vasy/src/vasy_generate.h new file mode 100644 index 00000000..4e2b2662 --- /dev/null +++ b/alliance/src/vasy/src/vasy_generate.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_generate.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_GENERATE_H +# define VASY_GENERATE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyGenerateVbhFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_generic.c b/alliance/src/vasy/src/vasy_generic.c new file mode 100644 index 00000000..990e9f06 --- /dev/null +++ b/alliance/src/vasy/src/vasy_generic.c @@ -0,0 +1,462 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_generic.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.02.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vbh.h" + +# include "vasy_generic.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashGeneric = (authtable *)0; + static authtable *VasyHashConstant = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyGenericSubstVexExprConst | +| | +\------------------------------------------------------------*/ + +static void VasyGenericSubstVexExprConst( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + char *AtomValue; + vexexpr *VexConst; + vexexpr *VexOperand; + authelem *Element; + long Oper; + /* ICI BIG BUG !! + short Signed; + */ + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashGeneric, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VexConst = (vexexpr *)Element->VALUE; + } + else + { + Element = searchauthelem( VasyHashConstant, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VexConst = (vexexpr *)Element->VALUE; + } + } + + if ( Element != (authelem *)0 ) + { + if ( ( IsVexNodeAtom( VexConst ) ) && + ( IsVexAtomLiteral( VexConst ) ) ) + { + /* ICI BIG BUG !!! + if ( IsVexNodeSigned( VexExpr ) ) Signed = 1; + else Signed = 0; + */ + + VexExpr->VALUE = VexConst->VALUE; + VexExpr->TYPE = VexConst->TYPE; + VexExpr->WIDTH = VexConst->WIDTH; + VexExpr->LEFT = VexConst->LEFT; + VexExpr->RIGHT = VexConst->RIGHT; + + /* ICI BIG BUG !! + if ( Signed ) SetVexNodeSigned( VexExpr ); + else ClearVexNodeSigned( VexExpr ); + */ + } + } + } + } + else + { + if ( IsVexNodeOper( VexExpr ) ) Oper = GetVexOperValue( VexExpr ); + else Oper = -1; + + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + + if ( ( Oper == VEX_INDEX ) || + ( Oper == VEX_TO ) || + ( Oper == VEX_DOWNTO ) ) + { + if ( ( ScanOper != VexExpr->OPERAND ) || + ( ! IsVexNodeAtom( VexOperand ) ) ) + { + VasyGenericSubstVexExprConst( VexOperand ); + } + } + else + { + VasyGenericSubstVexExprConst( VexOperand ); + } + } + } +} +/*------------------------------------------------------------\ +| | +| VasyGenericSubstVexExpr | +| | +\------------------------------------------------------------*/ + +static void VasyGenericSubstVexExpr( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + char *AtomValue; + vexexpr *VexConst; + vexexpr *VexOperand; + authelem *Element; + long Oper; + /* ICI BIG BUG !! + short Signed; + */ + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashGeneric, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VexConst = (vexexpr *)Element->VALUE; + + if ( ( IsVexNodeAtom( VexConst ) ) && + ( IsVexAtomLiteral( VexConst ) ) ) + { + /* ICI BIG BUG !! + if ( IsVexNodeSigned( VexExpr ) ) Signed = 1; + else Signed = 0; + */ + + VexExpr->VALUE = VexConst->VALUE; + VexExpr->TYPE = VexConst->TYPE; + VexExpr->WIDTH = VexConst->WIDTH; + VexExpr->LEFT = VexConst->LEFT; + VexExpr->RIGHT = VexConst->RIGHT; + + /* ICI BIG BUG !! + if ( Signed ) SetVexNodeSigned( VexExpr ); + else ClearVexNodeSigned( VexExpr ); + */ + } + } + } + } + else + { + if ( IsVexNodeOper( VexExpr ) ) Oper = GetVexOperValue( VexExpr ); + else Oper = -1; + + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + + if ( ( ( Oper == VEX_INDEX ) || + ( Oper == VEX_TO ) || + ( Oper == VEX_DOWNTO ) ) && + ( ( ScanOper != VexExpr->OPERAND ) || + ( ! IsVexNodeAtom( VexOperand ) ) ) ) + { + VasyGenericSubstVexExprConst( VexOperand ); + } + else + { + VasyGenericSubstVexExpr( VexOperand ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenericSubstSimpConst | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyGenericSubstSimpVexConst( VexExpr ) + + vexexpr *VexExpr; +{ + VasyGenericSubstVexExprConst( VexExpr ); + VexExpr = simpvexexpr( VexExpr ); + + return( VexExpr ); +} + + +/*------------------------------------------------------------\ +| | +| VasyGenericSubstSimpVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyGenericSubstSimpVex( VexExpr ) + + vexexpr *VexExpr; +{ + VasyGenericSubstVexExpr( VexExpr ); + VexExpr = simpvexexpr( VexExpr ); + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyGenericSubstSimpTarget | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyGenericSubstSimpTarget( VexTarget ) + + vexexpr *VexTarget; +{ + if ( ! IsVexNodeAtom( VexTarget ) ) + { + VasyGenericSubstVexExprConst( VexTarget ); + VexTarget = simpvexexpr( VexTarget ); + } + + return( VexTarget ); +} + +/*------------------------------------------------------------\ +| | +| VasyGenericVbhInstance | +| | +\------------------------------------------------------------*/ + +void VasyGenericVbhInstance( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbins_list *VbhInstance; + vbmap_list *VbhGenMap; + vbmap_list *VbhPortMap; + char *Name; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyGenericVbhInstance %s\n", VbhFigure->NAME ); + } + + for ( VbhInstance = VbhFigure->BEINS; + VbhInstance != (vbins_list *)0; + VbhInstance = VbhInstance->NEXT ) + { + for ( VbhGenMap = VbhInstance->GEN_MAP; + VbhGenMap != (vbmap_list *)0; + VbhGenMap = VbhGenMap->NEXT ) + { + if ( IsVexNodeAtom( VbhGenMap->ACTUAL ) ) + { + Name = GetVexAtomValue( VbhGenMap->FORMAL ); + addauthelem( VasyHashGeneric, Name, (long)VbhGenMap->ACTUAL ); + } + } + + for ( VbhPortMap = VbhInstance->PORT_MAP; + VbhPortMap != (vbmap_list *)0; + VbhPortMap = VbhPortMap->NEXT ) + { + if ( VbhPortMap->FORMAL != (vexexpr *)0 ) + { + VbhPortMap->FORMAL = VasyGenericSubstSimpTarget( VbhPortMap->FORMAL ); + } + + if ( VbhPortMap->ACTUAL != (vexexpr *)0 ) + { + VbhPortMap->ACTUAL = VasyGenericSubstSimpVex( VbhPortMap->ACTUAL ); + } + } + + for ( VbhGenMap = VbhInstance->GEN_MAP; + VbhGenMap != (vbmap_list *)0; + VbhGenMap = VbhGenMap->NEXT ) + { + if ( IsVexNodeAtom( VbhGenMap->ACTUAL ) ) + { + Name = GetVexAtomValue( VbhGenMap->ACTUAL ); + delauthelem( VasyHashGeneric, Name ); + } + } + + vbh_frevbmap( VbhInstance->GEN_MAP ); + VbhInstance->GEN_MAP = (vbmap_list *)0; + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyGenericVbhInstance %s\n\n", VbhFigure->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyGenericVbhFig | +| | +\------------------------------------------------------------*/ + +void VasyGenericVbhFig( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbgen_list *VbhGeneric; + vbcst_list *VbhConstant; + char *Name; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyGenericVbhFig %s\n", VbhFigure->NAME ); + } + + VasyHashGeneric = createauthtable( 100 ); + VasyHashConstant = createauthtable( 100 ); + + VasyGenericVbhInstance( VbhFigure ); + + for ( VbhConstant = VbhFigure->BECST; + VbhConstant != (vbcst_list *)0; + VbhConstant = VbhConstant->NEXT ) + { + VbhConstant->TARGET = VasyGenericSubstSimpTarget( VbhConstant->TARGET ); + Name = getvexatomname( VbhConstant->TARGET ); + VbhConstant->VEX = VasyGenericSubstSimpVex( VbhConstant->VEX ); + + addauthelem( VasyHashConstant, Name, (long)VbhConstant->VEX ); + } + + for ( VbhGeneric = VbhFigure->BEGEN; + VbhGeneric != (vbgen_list *)0; + VbhGeneric = VbhGeneric->NEXT ) + { + VbhGeneric->TARGET = VasyGenericSubstSimpTarget( VbhGeneric->TARGET ); + + if ( VbhGeneric->VEX != (vexexpr *)0 ) + { + VbhGeneric->VEX = VasyGenericSubstSimpVex( VbhGeneric->VEX ); + + if ( IsVexNodeAtom( VbhGeneric->TARGET ) ) + { + Name = GetVexAtomValue( VbhGeneric->TARGET ); + addauthelem( VasyHashGeneric, Name, (long)VbhGeneric->VEX ); + } + } + } + + for ( VbhConstant = VbhFigure->BECST; + VbhConstant != (vbcst_list *)0; + VbhConstant = VbhConstant->NEXT ) + { + VbhConstant->TARGET = VasyGenericSubstSimpTarget( VbhConstant->TARGET ); + Name = getvexatomname( VbhConstant->TARGET ); + VbhConstant->VEX = VasyGenericSubstSimpVex( VbhConstant->VEX ); + + addauthelem( VasyHashConstant, Name, (long)VbhConstant->VEX ); + } + + vbh_forallvexvbfig( VbhFigure, VasyGenericSubstSimpTarget, + VasyGenericSubstSimpVexConst ); + + destroyauthtable( VasyHashGeneric ); + destroyauthtable( VasyHashConstant ); + + if ( IsVasyDebugLevel1() ) + { + vbh_viewvbfig( VbhFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyGenericVbhFig %s\n\n", VbhFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_generic.h b/alliance/src/vasy/src/vasy_generic.h new file mode 100644 index 00000000..97a35d21 --- /dev/null +++ b/alliance/src/vasy/src/vasy_generic.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_generic.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_GENERIC_H +# define VASY_GENERIC_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyGenericVbhFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_loop.c b/alliance/src/vasy/src/vasy_loop.c new file mode 100644 index 00000000..f935ff4e --- /dev/null +++ b/alliance/src/vasy/src/vasy_loop.c @@ -0,0 +1,959 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_loop.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vbh.h" + +# include "vasy_loop.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static char *VasyForIndexName = (char *)0; + static long VasyForIndexValue = 0; + static short VasyForIndexSigned = 0; + static char *VasyForLabel = (char *)0; + static char *VasyForLabelNext = (char *)0; + static char *VasyForLabelExit = (char *)0; + static short VasyForFoundExit = 0; + static short VasyForFoundNext = 0; + static long VasyForEnterNewLoop = 0; + + static authtable *VasyHashLabel = (authtable *)0; + static authtable *VasyHashConstant = (authtable *)0; + static authtable *VasyHashGeneric = (authtable *)0; + + static char VasyBuffer[ 512 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyUnrollSubstConst | +| | +\------------------------------------------------------------*/ + +static void VasyUnrollSubstConst( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + vbcst_list *VbhConst; + vbgen_list *VbhGen; + char *AtomValue; + vexexpr *VexConst; + authelem *Element; + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashConstant, AtomValue ); + + if ( Element == (authelem *)0 ) + { + Element = searchauthelem( VasyHashGeneric, AtomValue ); + + if ( Element != (authelem *)0 ) + { + VbhGen = (vbgen_list *)Element->VALUE; + VexConst = VbhGen->VEX; + } + } + else + { + VbhConst = (vbcst_list *)Element->VALUE; + VexConst = VbhConst->VEX; + } + + if ( Element != (authelem *)0 ) + { + VexExpr->VALUE = VexConst->VALUE; + VexExpr->TYPE = VexConst->TYPE; + VexExpr->WIDTH = VexConst->WIDTH; + VexExpr->LEFT = VexConst->LEFT; + VexExpr->RIGHT = VexConst->RIGHT; + } + } + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasyUnrollSubstConst( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollForAddLabel | +| | +\------------------------------------------------------------*/ + +static char *VasyUnrollForAddLabel( Label ) + + char *Label; +{ + char *NewLabel; + + if ( Label != (char *)0 ) + { + sprintf( VasyBuffer, "unroll_%s_%ld", Label, VasyForIndexValue ); + NewLabel = namealloc( VasyBuffer ); + addauthelem( VasyHashLabel, Label, (long)NewLabel ); + } + else + { + NewLabel = (char *)0; + } + + return( NewLabel ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollForDelLabel | +| | +\------------------------------------------------------------*/ + +static void VasyUnrollForDelLabel( Label ) + + char *Label; +{ + if ( Label != (char *)0 ) + { + delauthelem( VasyHashLabel, Label ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollForRenameLabel | +| | +\------------------------------------------------------------*/ + +static char *VasyUnrollForRenameLabel( Label ) + + char *Label; +{ + authelem *Element; + + if ( Label != (char *)0 ) + { + Element = searchauthelem( VasyHashLabel, Label ); + if ( Element != (authelem *)0 ) + { + Label = (char *)Element->VALUE; + } + } + + return( Label ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollVexExpr | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyUnrollVexExpr( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + vexexpr *Operand; + char *Name; + int Width; + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + Name = GetVexAtomValue( VexExpr ); + + if ( Name == VasyForIndexName ) + { + Width = VexExpr->WIDTH; + freevexexpr( VexExpr ); + + VexExpr = createvexatomlong( VasyForIndexValue, Width, VasyForIndexSigned ); + } + } + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasyUnrollVexExpr( Operand ); + SetVexOperand( ScanOper, Operand ); + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollIsVexCondTrueFalse | +| | +\------------------------------------------------------------*/ + +static int VasyUnrollIsVexCondTrueFalse( VexExpr ) + + vexexpr *VexExpr; +{ + char *AtomValue; + + if ( VexExpr == (vexexpr *)0 ) return( 1 ); + + if ( ( IsVexNodeAtom( VexExpr ) ) && + ( IsVexAtomLiteral( VexExpr ) ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + + if ( AtomValue == VEX_ATOM_ONE ) return( 1 ); + if ( AtomValue == VEX_ATOM_ZERO ) return( 0 ); + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollForBodyVexExpr | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyUnrollForBodyVexExpr( VexExpr ) + + vexexpr *VexExpr; +{ + if ( VexExpr != (vexexpr *)0 ) + { + VexExpr = dupvexexpr( VexExpr ); + VexExpr = VasyUnrollVexExpr( VexExpr ); + VexExpr = simpvexexpr( VexExpr ); + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollForBody | +| | +\------------------------------------------------------------*/ + +static ptype_list *VasyUnrollForBody( Instruction ) + + ptype_list *Instruction; +{ + vbasg_list *ScanAsg; + vbagr_list *ScanAgr; + vbvar_list *ScanVar; + vbwas_list *ScanWait; + vbnxt_list *ScanNext; + vbext_list *ScanExit; + vbret_list *ScanReturn; + vbcal_list *ScanCall; + vbifs_list *ScanIfs; + vbcas_list *ScanCase; + vbcho_list *ScanChoice; + vblop_list *ScanLoop; + vbfor_list *ScanFor; + vbwhi_list *ScanWhile; + vbasg_list *NewAsg; + vbagr_list *NewAgr; + vbvar_list *NewVar; + vbwas_list *NewWait; + vbnxt_list *NewNext; + vbext_list *NewExit; + vbret_list *NewReturn; + vbcal_list *NewCall; + vbifs_list *NewIfs; + vbcas_list *NewCase; + vbcho_list *NewChoice; + vblop_list *NewLoop; + vbfor_list *NewFor; + vbwhi_list *NewWhile; + ptype_list *NewInstruction; + chain_list *ScanChain; + chain_list *ScanValue; + void *Pointer; + int InstType; + int Offset; + int TrueFalse; + + NewInstruction = (ptype_list *)0; + + while ( Instruction != (ptype_list *)0 ) + { + InstType = Instruction->TYPE; + Pointer = (void *)0; + + switch ( InstType ) + { + case VBH_BEASG : + + ScanAsg = (vbasg_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbasg_list ) ); + NewAsg = (vbasg_list *)Pointer; + + NewAsg->TARGET = VasyUnrollForBodyVexExpr( ScanAsg->TARGET ); + NewAsg->VEX = VasyUnrollForBodyVexExpr( ScanAsg->VEX ); + NewAsg->TYPE = ScanAsg->TYPE; + NewAsg->LINE = ScanAsg->LINE; + + break; + + case VBH_BEVAR : + + ScanVar = (vbvar_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbvar_list ) ); + NewVar = (vbvar_list *)Pointer; + + NewVar->TARGET = VasyUnrollForBodyVexExpr( ScanVar->TARGET ); + NewVar->VEX = VasyUnrollForBodyVexExpr( ScanVar->VEX ); + NewVar->TYPE = ScanVar->TYPE; + NewVar->LINE = ScanVar->LINE; + + break; + + case VBH_BENXT : + + ScanNext = (vbnxt_list *)Instruction->DATA; +/* +** Special treatments for NEXT instruction +*/ + if ( ( ScanNext->LABEL == VasyForLabel ) || + ( ( ScanNext->LABEL == (char *)0 ) && + ( VasyForEnterNewLoop == 0 ) ) ) + { + InstType = VBH_BEEXT; + + ScanExit = (vbext_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbext_list ) ); + NewExit = (vbext_list *)Pointer; + + NewExit->LINE = ScanNext->LINE; + NewExit->CND = VasyUnrollForBodyVexExpr( ScanNext->CND ); + + TrueFalse = VasyUnrollIsVexCondTrueFalse( NewExit->CND ); + + if ( TrueFalse == 0 ) + { + freevexexpr( NewExit->CND ); + autfreeheap( Pointer, sizeof( vbext_list ) ); + Pointer = (void *)0; + } + else + { + if ( TrueFalse == 1 ) + { + freevexexpr( NewExit->CND ); + NewExit->CND = (vexexpr *)0; + } + + NewExit->LABEL = VasyForLabelNext; + } + + VasyForFoundNext = 1; + } + else + { + Pointer = autallocheap( sizeof( vbnxt_list ) ); + NewNext = (vbnxt_list *)Pointer; + + NewNext->LINE = ScanNext->LINE; + NewNext->CND = VasyUnrollForBodyVexExpr( ScanNext->CND ); + + TrueFalse = VasyUnrollIsVexCondTrueFalse( NewNext->CND ); + + if ( TrueFalse == 0 ) + { + freevexexpr( NewNext->CND ); + autfreeheap( Pointer, sizeof( vbnxt_list ) ); + Pointer = (void *)0; + } + else + { + if ( TrueFalse == 1 ) + { + freevexexpr( NewNext->CND ); + NewNext->CND = (vexexpr *)0; + } + + NewNext->LABEL = VasyUnrollForRenameLabel( ScanNext->LABEL ); + } + + } + + break; + + case VBH_BEEXT : +/* +** Special treatments for EXIT instruction +*/ + ScanExit = (vbext_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbext_list ) ); + NewExit = (vbext_list *)Pointer; + + NewExit->LINE = ScanExit->LINE; + NewExit->CND = VasyUnrollForBodyVexExpr( ScanExit->CND ); + + if ( ( ScanExit->LABEL == VasyForLabel ) || + ( ( ScanExit->LABEL == (char *)0 ) && + ( VasyForEnterNewLoop == 0 ) ) ) + { + VasyForFoundExit = 1; + NewExit->LABEL = VasyForLabelExit; + } + else + { + NewExit->LABEL = VasyUnrollForRenameLabel( ScanExit->LABEL ); + } + + TrueFalse = VasyUnrollIsVexCondTrueFalse( NewExit->CND ); + + if ( TrueFalse == 0 ) + { + freevexexpr( NewExit->CND ); + autfreeheap( Pointer, sizeof( vbext_list ) ); + Pointer = (void *)0; + } + else + if ( TrueFalse == 1 ) + { + freevexexpr( NewExit->CND ); + NewExit->CND = (vexexpr *)0; + } + + break; + + case VBH_BEWAS : + + ScanWait = (vbwas_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbwas_list ) ); + NewWait = (vbwas_list *)Pointer; + + for ( ScanChain = ScanWait->SEN; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + NewWait->SEN = addchain( NewWait->SEN, ScanChain->DATA ); + } + + NewWait->CND = VasyUnrollForBodyVexExpr( ScanWait->CND ); + NewWait->TIME_UNIT = ScanWait->TIME_UNIT; + NewWait->TIMEOUT = ScanWait->TIMEOUT; + NewWait->LINE = ScanWait->LINE; + + break; + + case VBH_BERET : + + ScanReturn = (vbret_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbret_list ) ); + NewReturn = (vbret_list *)Pointer; + + NewReturn->RET = VasyUnrollForBodyVexExpr( ScanReturn->RET ); + NewReturn->LINE = ScanReturn->LINE; + + break; + + case VBH_BECAL : + + ScanCall = (vbcal_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbcal_list ) ); + NewCall = (vbcal_list *)Pointer; + + NewCall->CALL = VasyUnrollForBodyVexExpr( ScanCall->CALL ); + NewCall->LINE = ScanCall->LINE; + + break; + + case VBH_BEAGR : + + ScanAgr = (vbagr_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbagr_list ) ); + NewAgr = (vbagr_list *)Pointer; + + NewAgr->ASSIGN = VasyUnrollForBody( ScanAgr->ASSIGN ); + NewAgr->LINE = ScanAgr->LINE; + + break; + + case VBH_BEIFS : + + ScanIfs = (vbifs_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbifs_list ) ); + NewIfs = (vbifs_list *)Pointer; + + NewIfs->CND = VasyUnrollForBodyVexExpr( ScanIfs->CND ); + NewIfs->CNDTRUE = VasyUnrollForBody( ScanIfs->CNDTRUE ); + NewIfs->CNDFALSE = VasyUnrollForBody( ScanIfs->CNDFALSE ); + NewIfs->LINE = ScanIfs->LINE; + + break; + + case VBH_BECAS : + + ScanCase = (vbcas_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbcas_list ) ); + NewCase = (vbcas_list *)Pointer; + + NewCase->VEX = VasyUnrollForBodyVexExpr( ScanCase->VEX ); + NewCase->TYPE = ScanCase->TYPE; + NewCase->LINE = ScanCase->LINE; + + NewCase->SIZE = ScanCase->SIZE; + NewCase->CHOICE = (vbcho_list *)autallocblock( ScanCase->SIZE * sizeof( vbcho_list ) ); + + for ( Offset = 0; Offset < ScanCase->SIZE; Offset++ ) + { + ScanChoice = &ScanCase->CHOICE[ Offset ]; + NewChoice = &NewCase->CHOICE[ Offset ]; + + NewChoice->INSTRUCTION = VasyUnrollForBody( ScanChoice->INSTRUCTION ); + + NewChoice->VALUES = (chain_list *)0; + + for ( ScanValue = ScanChoice->VALUES; + ScanValue != (chain_list *)0; + ScanValue = ScanValue->NEXT ) + { + NewChoice->VALUES = addchain( NewChoice->VALUES, ScanValue->DATA ); + } + + NewChoice->SIZE = ScanChoice->SIZE ; + NewChoice->LINE = ScanChoice->LINE; + } + + break; + + case VBH_BEFOR : + + ScanFor = (vbfor_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbfor_list ) ); + NewFor = (vbfor_list *)Pointer; + + VasyUnrollForAddLabel( ScanFor->LABEL ); + + VasyForEnterNewLoop++; + NewFor->INSTRUCTION = VasyUnrollForBody( ScanFor->INSTRUCTION ); + VasyForEnterNewLoop--; + + NewFor->LABEL = VasyUnrollForRenameLabel( ScanFor->LABEL ); + NewFor->VARIABLE = VasyUnrollForBodyVexExpr( ScanFor->VARIABLE ); + NewFor->LEFT = VasyUnrollForBodyVexExpr( ScanFor->LEFT ); + NewFor->RIGHT = VasyUnrollForBodyVexExpr( ScanFor->RIGHT ); + NewFor->UP = ScanFor->UP; + NewFor->LINE = ScanFor->LINE; + + VasyUnrollForDelLabel( ScanFor->LABEL ); + + break; + + case VBH_BEWHI : + + ScanWhile = (vbwhi_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vbwhi_list ) ); + NewWhile = (vbwhi_list *)Pointer; + + VasyUnrollForAddLabel( ScanWhile->LABEL ); + + VasyForEnterNewLoop++; + NewWhile->INSTRUCTION = VasyUnrollForBody( ScanWhile->INSTRUCTION ); + VasyForEnterNewLoop--; + + NewWhile->LABEL = VasyUnrollForRenameLabel( ScanWhile->LABEL ); + NewWhile->CND = VasyUnrollForBodyVexExpr( ScanWhile->CND ); + NewWhile->LINE = ScanWhile->LINE; + + VasyUnrollForDelLabel( ScanWhile->LABEL ); + + break; + + case VBH_BELOP : + + ScanLoop = (vblop_list *)Instruction->DATA; + Pointer = autallocheap( sizeof( vblop_list ) ); + NewLoop = (vblop_list *)Pointer; + + VasyUnrollForAddLabel( ScanLoop->LABEL ); + + VasyForEnterNewLoop++; + NewLoop->INSTRUCTION = VasyUnrollForBody( ScanLoop->INSTRUCTION ); + VasyForEnterNewLoop--; + + NewLoop->LABEL = VasyUnrollForRenameLabel( ScanLoop->LABEL ); + NewLoop->LINE = ScanLoop->LINE; + + VasyUnrollForDelLabel( ScanLoop->LABEL ); + + break; + } + + if ( Pointer != (void *)0 ) + { + NewInstruction = addptype( NewInstruction, InstType, Pointer ); + } + + Instruction = Instruction->NEXT; + } + + NewInstruction = (ptype_list *)reverse( (chain_list *)NewInstruction ); + + return( NewInstruction ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollForInstruction | +| | +\------------------------------------------------------------*/ + +static ptype_list *VasyUnrollForInstruction( Instruction ) + + ptype_list *Instruction; +{ + ptype_list *NewBody; + ptype_list **PrevPType; + ptype_list **PrevPType2; + ptype_list *ScanPType; + vblop_list *NewLoop; + ptype_list *NewExit; + vbfor_list *ScanFor; + vexexpr *VexLeft; + vexexpr *VexRight; + vexexpr *VexAtom; + ptype_list *HeadBody; + long Left; + long Right; + + ScanFor = (vbfor_list *)Instruction->DATA; + VexAtom = ScanFor->VARIABLE; + + VexLeft = ScanFor->LEFT; + VasyUnrollSubstConst( VexLeft ); + VexLeft = simpvexexpr( VexLeft ); + ScanFor->LEFT = VexLeft; + + VexRight = ScanFor->RIGHT; + VasyUnrollSubstConst( VexRight ); + VexRight = simpvexexpr( VexRight ); + ScanFor->RIGHT = VexRight; + + VasyForIndexName = GetVexAtomValue( VexAtom ); + + if ( ( evalvexatomlong( VexLeft, &Left ) ) || + ( evalvexatomlong( VexRight, &Right ) ) ) + { + viewvexexprln( VexLeft ); viewvexexprln( VexRight ); + VasyError( VASY_ERROR_IN_UNROLL_LOOP, (char *)0 ); + } + + if ( ( Left < 0 ) || + ( Right < 0 ) ) VasyForIndexSigned = 1; + else VasyForIndexSigned = 0; + + VasyForIndexValue = Left; + VasyForFoundNext = 0; + VasyForFoundExit = 0; + VasyForLabel = ScanFor->LABEL; + + PrevPType = &HeadBody; + HeadBody = (ptype_list *)0; + + sprintf( VasyBuffer, "%s_exit", ScanFor->LABEL ); + VasyForLabelExit = namealloc( VasyBuffer ); + + while ( ( ( VasyForIndexValue <= Right ) && ( ScanFor->UP ) ) || + ( ( VasyForIndexValue >= Right ) && ( ! ScanFor->UP ) ) ) + { + sprintf( VasyBuffer, "%s_next_%ld", ScanFor->LABEL, VasyForIndexValue ); + VasyForLabelNext = namealloc( VasyBuffer ); + + NewBody = VasyUnrollForBody( ScanFor->INSTRUCTION ); + + if ( VasyForFoundNext ) + { + ScanPType = vbh_addvblop( (ptype_list *)0, VasyForLabelNext, ScanFor->LINE ); + NewLoop = (vblop_list *)ScanPType->DATA; + NewLoop->INSTRUCTION = NewBody; + + *PrevPType = ScanPType; + PrevPType = &ScanPType->NEXT; + + PrevPType2 = &NewBody; + + for ( ScanPType = NewBody; + ScanPType != (ptype_list *)0; + ScanPType = ScanPType->NEXT ) + { + PrevPType2 = &ScanPType->NEXT; + } + + NewExit = addptype( (ptype_list *)0, VBH_BEEXT, + vbh_addvbext( VasyForLabelNext, (vexexpr *)0, ScanFor->LINE ) ); + *PrevPType2 = NewExit; + } + else + { + *PrevPType = NewBody; + + for ( ScanPType = NewBody; + ScanPType != (ptype_list *)0; + ScanPType = ScanPType->NEXT ) + { + PrevPType = &ScanPType->NEXT; + } + } + + if ( ScanFor->UP ) VasyForIndexValue++; + else VasyForIndexValue--; + } + + if ( VasyForFoundExit ) + { + NewExit = addptype( (ptype_list *)0, VBH_BEEXT, + vbh_addvbext( VasyForLabelExit, (vexexpr *)0, ScanFor->LINE ) ); + *PrevPType = NewExit; + + ScanPType = vbh_addvblop( (ptype_list *)0, VasyForLabelExit, ScanFor->LINE ); + NewLoop = (vblop_list *)ScanPType->DATA; + NewLoop->INSTRUCTION = HeadBody; + + HeadBody = ScanPType; + PrevPType = &ScanPType->NEXT; + } + + if ( IsVasyDebugLevel2() ) + { + vbh_viewvbinst( HeadBody ); + } + + *PrevPType = Instruction->NEXT; + + Instruction->NEXT = (ptype_list *)0; + vbh_frevbinst( Instruction ); + + return( HeadBody ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollScanInstruction | +| | +\------------------------------------------------------------*/ + +static ptype_list *VasyUnrollScanInstruction( Instruction ) + + ptype_list *Instruction; +{ + ptype_list *ScanPType; + ptype_list **PrevPType; + vbifs_list *ScanIfs; + vbcas_list *ScanCase; + vbcho_list *ScanChoice; + vblop_list *ScanLoop; + vbwhi_list *ScanWhile; + int Offset; + + ScanPType = Instruction; + PrevPType = &Instruction; + + while ( ScanPType != (ptype_list *)0 ) + { + switch ( ScanPType->TYPE ) + { + case VBH_BEIFS : + + ScanIfs = (vbifs_list *)ScanPType->DATA; + ScanIfs->CNDTRUE = VasyUnrollScanInstruction( ScanIfs->CNDTRUE ); + ScanIfs->CNDFALSE = VasyUnrollScanInstruction( ScanIfs->CNDFALSE ); + + break; + + case VBH_BECAS : + + ScanCase = (vbcas_list *)ScanPType->DATA; + for ( Offset = 0; Offset < ScanCase->SIZE; Offset++ ) + { + ScanChoice = &ScanCase->CHOICE[ Offset ]; + ScanChoice->INSTRUCTION = VasyUnrollScanInstruction( ScanChoice->INSTRUCTION ); + } + + break; + + case VBH_BEFOR : + + ScanPType = VasyUnrollForInstruction( ScanPType ); + *PrevPType = ScanPType; + + continue; + + break; + + case VBH_BEWHI : + + ScanWhile = (vbwhi_list *)ScanPType->DATA; + ScanWhile->INSTRUCTION = VasyUnrollScanInstruction( ScanWhile->INSTRUCTION ); + + break; + + case VBH_BELOP : + + ScanLoop = (vblop_list *)ScanPType->DATA; + ScanLoop->INSTRUCTION = VasyUnrollScanInstruction( ScanLoop->INSTRUCTION ); + + break; + } + + PrevPType = &ScanPType->NEXT; + ScanPType = ScanPType->NEXT; + } + + return( Instruction ); +} + +/*------------------------------------------------------------\ +| | +| VasyUnrollLoopVbhFig | +| | +\------------------------------------------------------------*/ + +void VasyUnrollLoopVbhFig( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbpcs_list *VbhProcess; + vbgen_list *VbhGeneric; + vbcst_list *VbhConstant; + char *Name; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyUnrollLoopVbhFig %s\n", VbhFigure->NAME ); + } + + VasyHashLabel = createauthtable( 100 ); + VasyHashConstant = createauthtable( 100 ); + VasyHashGeneric = createauthtable( 100 ); + + for ( VbhGeneric = VbhFigure->BEGEN; + VbhGeneric != (vbgen_list *)0; + VbhGeneric = VbhGeneric->NEXT ) + { + Name = getvexatomname( VbhGeneric->TARGET ); + addauthelem( VasyHashGeneric, Name, (long)VbhGeneric ); + } + + for ( VbhConstant = VbhFigure->BECST; + VbhConstant != (vbcst_list *)0; + VbhConstant = VbhConstant->NEXT ) + { + Name = getvexatomname( VbhConstant->TARGET ); + addauthelem( VasyHashConstant, Name, (long)VbhConstant ); + } + + for ( VbhProcess = VbhFigure->BEPCS; + VbhProcess != (vbpcs_list *)0; + VbhProcess = VbhProcess->NEXT ) + { + if ( ! IsVbhProcSequential( VbhProcess ) ) continue; + + VbhProcess->INSTRUCTION = VasyUnrollScanInstruction( VbhProcess->INSTRUCTION ); + } + + destroyauthtable( VasyHashLabel ); + destroyauthtable( VasyHashConstant ); + destroyauthtable( VasyHashGeneric ); + + if ( IsVasyDebugLevel1() ) + { + vbh_viewvbfig( VbhFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyUnrollLoopVbhFig %s\n\n", VbhFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_loop.h b/alliance/src/vasy/src/vasy_loop.h new file mode 100644 index 00000000..a9e58f11 --- /dev/null +++ b/alliance/src/vasy/src/vasy_loop.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_loop.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_LOOP_H +# define VASY_LOOP_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyUnrollLoopVbhFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_main.c b/alliance/src/vasy/src/vasy_main.c new file mode 100644 index 00000000..a0887501 --- /dev/null +++ b/alliance/src/vasy/src/vasy_main.c @@ -0,0 +1,461 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_main.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vbh.h" +# include "vbl.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_shared.h" +# include "vasy_parse.h" +# include "vasy_preanal.h" +# include "vasy_func.h" +# include "vasy_elabo.h" +# include "vasy_reduce.h" +# include "vasy_analys.h" +# include "vasy_simprtl.h" +# include "vasy_drvalc.h" +# include "vasy_drvsyn.h" +# include "vasy_drvvlog.h" +# include "vasy_drvrtl.h" +# include "vasy_main.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Vasy Usage | +| | +\------------------------------------------------------------*/ + +void VasyUsage() +{ + fprintf( stderr, " vasy [Options] Input_name Output_name\n\n" ); + + fprintf( stdout, " Options : -D [Level] [File] Sets Debug mode on\n" ); + fprintf( stdout, " -V Sets Verbose mode on\n" ); + fprintf( stdout, " -I Extention Input file format\n" ); + fprintf( stdout, " -H Sets Hierarchical mode on\n" ); + fprintf( stdout, " -P File Specifies package list file\n" ); + fprintf( stdout, " -v Verilog output\n" ); + fprintf( stdout, " -a Alliance output\n" ); + fprintf( stdout, " -s Standard VHDL output\n" ); + fprintf( stdout, " -r Rtl output\n" ); + fprintf( stdout, " -o Overwrites existing files\n" ); + fprintf( stdout, " -i Drives initials values\n" ); + fprintf( stdout, " -p Adds power supply connectors\n" ); + fprintf( stdout, " -S Uses Std_logic instead of Bit\n" ); + fprintf( stdout, " -C Number_bit Uses CLA adder (with -a only)\n" ); + fprintf( stdout, " -E Number_bit Expands equal operator (with -a only)\n" ); + fprintf( stdout, " -L Drives a .lax file (with -a only)\n" ); + fprintf( stdout, " -B Drives a .boom file (with -a only)\n" ); + fprintf( stdout, "\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| VasyMainTreatModel | +| | +\------------------------------------------------------------*/ + +vbfig_list *VasyMainTreatModel( InputFileName, OutputFileName, GenMap, Deep ) + + char *InputFileName; + char *OutputFileName; + vbmap_list *GenMap; + int Deep; +{ + vbfig_list *VbhFigure; + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + int Index; + char Tab[ 32 ]; + + if ( Deep > 30 ) Deep = 30; + + Tab[ 0 ] = '\t'; + + for ( Index = 1; Index < Deep; Index++ ) + { + Tab[ Index ] = ' '; + } + + Tab[ Index ] = '\0'; + + fprintf( stdout, "%s--> Run VHDL Compiler\n", Tab ); + fprintf( stdout, "%s--> Compile file %s\n", Tab, InputFileName ); + + VbhFigure = VasyParseVbhFig( InputFileName, GenMap, Deep ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> Translate to VPN\n", Tab ); + } + + VpnFigure = VasyParseVbh2VpnFig( VbhFigure ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> Preliminary Analysis\n", Tab ); + } + + VasyPreAnalysisVpnFig( VpnFigure ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> In-Line function\n", Tab ); + } + + VasyFuncVpnFig( VpnFigure ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> Elaboration\n", Tab ); + } + + VasyElaborateVpnFig( VpnFigure ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> Petri Net Reduction\n", Tab ); + } + + VasyReduceVpnFig( VpnFigure ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> Analysis and Synthesis\n", Tab ); + } + + RtlFigure = VasyAnalysisVpnFig( VpnFigure ); + + if ( VasyFlagVerbose ) + { + fprintf( stdout, "%s--> Simplify RTL figure\n", Tab ); + } + + VasySimplifyRtlFig( RtlFigure ); + + RtlFigure->NAME = namealloc( OutputFileName ); + + if ( VasyFlagDrive == 0 ) + { + fprintf( stdout, "%s--> Drive Verilog file %s\n", Tab, OutputFileName ); + + VasyDriveVerilogRtlFig( RtlFigure, OutputFileName ); + } + else + if ( VasyFlagDrive == 1 ) + { + fprintf( stdout, "%s--> Drive Alliance file %s\n", Tab, OutputFileName ); + + VasyDriveAllianceRtlFig( RtlFigure, OutputFileName ); + } + else + if ( VasyFlagDrive == 2 ) + { + fprintf( stdout, "%s--> Drive Standard VHDL file %s\n", Tab, OutputFileName ); + + VasyDriveSynopsysRtlFig( RtlFigure, OutputFileName, VasyFlagStdLogic, VasyFlagInitial, VasyFlagOver ); + } + else + { + fprintf( stdout, "%s--> Drive Rtl file %s\n", Tab, OutputFileName ); + + VasyDriveRtlRtlFig( RtlFigure, OutputFileName ); + } + + return( VbhFigure ); +} + +/*------------------------------------------------------------\ +| | +| Main | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char *argv[]; +{ + char *InputFileName; + char *OutputFileName; + char *PackageFileName; + char *InputFormat; + char Option; + int Number; + int Index; + + + alliancebanner_with_contrib( + "VASY", VASY_VERSION, "VHDL Analyzer for SYnthesis", + "2000", ALLIANCE_VERSION, "Ludovic Jacomme", "Frederic Petrot" ); + + mbkenv(); + autenv(); + ablenv(); + bddenv(); + vexenv(); + vpnenv(); + + if ( argc < 2 ) VasyUsage(); + + InputFileName = (char *)0; + OutputFileName = (char *)0; + PackageFileName = (char *)0; + + for ( Number = 1; Number < argc; Number++ ) + { + if ( argv[ Number ][ 0 ] == '-' ) + { + for ( Index = 1; argv[ Number ][ Index ] != '\0'; Index++ ) + { + Option = argv[ Number ][ Index ]; + + if ( VasyFlagDebug ) + { + if ( ! VasyDebugAddItem( &argv[ Number ][ Index ], VasyFlagDebug ) ) + { + VasyUsage(); + } + + break; + } + else + if ( VasyFlagOption ) + { + if ( ! VasyDebugSetOption( &argv[ Number ][ Index ] ) ) + { + VasyUsage(); + } + + break; + } + else + { + if ( Option == 'I' ) + { + Number = Number + 1; + + if ( Number < argc ) + { + if ( argv[ Number ][ 0 ] == '.' ) + { + InputFormat = &argv[ Number ][ 1 ]; + } + else + { + InputFormat = argv[ Number ]; + } + + VPN_IN = namealloc( InputFormat ); + } + else VasyUsage(); + + break; + } + else + if ( Option == 'P' ) + { + Number = Number + 1; + + if ( Number < argc ) + { + PackageFileName = argv[ Number ]; + } + else VasyUsage(); + + break; + } + else + if ( Option == 'C' ) + { + Number = Number + 1; + + if ( Number < argc ) + { + VasyFlagCLA = atoi( argv[ Number ] ); + } + else VasyUsage(); + + break; + } + else + if ( Option == 'E' ) + { + Number = Number + 1; + + if ( Number < argc ) + { + VasyFlagEqual = atoi( argv[ Number ] ); + } + else VasyUsage(); + + break; + } + + switch ( Option ) + { + case 'V' : VasyFlagVerbose = 1; + break; + case 'L' : VasyFlagLax = 1; + break; + case 'B' : VasyFlagBoom = 1; + break; + case 'H' : VasyFlagHier = 1; + break; + case 'S' : VasyFlagStdLogic = 1; + break; + case 'p' : VasyFlagPower = 1; + break; + case 'i' : VasyFlagInitial = 1; + break; + case 'o' : VasyFlagOver = 1; + break; + case 'v' : VasyFlagDrive = 0; + break; + case 'a' : VasyFlagDrive = 1; + break; + case 's' : VasyFlagDrive = 2; + break; + case 'r' : VasyFlagDrive = 3; + break; + case 'D' : + + Index = Index + 1; + Option = argv[ Number ][ Index ]; + + if ( Option == '0' ) VasyFlagDebug = VASY_DEBUG_LEVEL0; + else + if ( Option == '1' ) VasyFlagDebug = VASY_DEBUG_LEVEL1; + else + if ( Option == '2' ) VasyFlagDebug = VASY_DEBUG_LEVEL2; + else + VasyUsage(); + break; + + case 'O' : + VasyFlagOption = 1; + break; + + default : VasyUsage(); + } + } + } + + VasyFlagDebug = 0; + VasyFlagOption = 0; + } + else + if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ]; + else + if ( OutputFileName == (char *)0 ) OutputFileName = argv[ Number ]; + else + VasyUsage(); + } + + if ( InputFileName == (char *)0 ) VasyUsage(); + + InputFileName = autbasename( InputFileName, VPN_IN ); + + if ( OutputFileName == (char *)0 ) + { + OutputFileName = InputFileName; + } + + if ( IsVasyDebugStatistics() ) VasyDebugStartChrono(0); + + if ( PackageFileName != (char *)0 ) + { + VasyParsePackage( PackageFileName ); + } + + VasyMainTreatModel( InputFileName, OutputFileName, (vbmap_list *)0, 1 ); + + vbh_frevbfig( VBL_HEADFIG ); + + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Total time : %ld sec\n", VasyDebugReadChrono(0) ); + } + + fprintf( stdout, "\n" ); + + + return( 0 ); +} diff --git a/alliance/src/vasy/src/vasy_main.h b/alliance/src/vasy/src/vasy_main.h new file mode 100644 index 00000000..33488961 --- /dev/null +++ b/alliance/src/vasy/src/vasy_main.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_main.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_MAIN_H +# define VASY_MAIN_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern vbfig_list *VasyMainTreatModel(); +# endif diff --git a/alliance/src/vasy/src/vasy_mulwait.c b/alliance/src/vasy/src/vasy_mulwait.c new file mode 100644 index 00000000..c2874369 --- /dev/null +++ b/alliance/src/vasy/src/vasy_mulwait.c @@ -0,0 +1,1066 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_mulwait.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_shared.h" +# include "vasy_support.h" +# include "vasy_vexbdd.h" +# include "vasy_synth.h" +# include "vasy_mulwait.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashSens = (authtable *)0; + static authtable *VasyHashClock = (authtable *)0; + static authtable *VasyHashWrite = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyMultiWaitCreateVexEvent | +| | +\------------------------------------------------------------*/ + +vexexpr *VasyMultiWaitCreateVexEvent( SensSymbol ) + + vpnsym *SensSymbol; +{ + vexexpr *VexEvent; + + if ( SensSymbol->INDEX == -1 ) + { + VexEvent = createvexatombit( SensSymbol->NAME ); + } + else + { + VexEvent = createvexatomvec( SensSymbol->NAME, SensSymbol->INDEX, SensSymbol->INDEX ); + } + + VexEvent = createvexunaryexpr( VEX_EVENT, 1, VexEvent ); + + return( VexEvent ); +} +/*------------------------------------------------------------\ +| | +| VasyMultiWaitViewWrite | +| | +\------------------------------------------------------------*/ + +static void VasyMultiWaitViewWrite( Element ) + + authelem *Element; +{ + vpnsym *VpnSymbol; + + VpnSymbol = (vpnsym *)Element->VALUE; + fprintf( stdout, " %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); +} + +/*------------------------------------------------------------\ +| | +| VasyMultiWaitHashWrite | +| | +\------------------------------------------------------------*/ + +static void VasyMultiWaitHashWrite( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vasyactinfo *ActInfo; + vpntrans_list *VpnTrans; + vpnact_list *VpnAction; + vpndecl_list *AsgDeclar; + vpnsym *AsgSymbol; + vexexpr *AsgAtom; + char *AtomName; + unsigned char *Flags; + chain_list **Support; + int AsgIndex; + int AsgMin; + int AsgMax; + int AsgPos; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitHashWrite %s\n", VpnProc->NAME ); + } + + if ( VasyHashWrite == (authtable *)0 ) + { + VasyHashWrite = createauthtable( 100 ); + } + else + { + resetauthtable( VasyHashWrite ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + if ( VpnAction->TYPE == VPN_ACT_ASG_DEFINE ) continue; + + ActInfo = GetVasyVpnActInfo( VpnAction ); + Support = ActInfo->SUPPORT; + Flags = ActInfo->FLAGS; + + AsgAtom = VpnAction->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + if ( IsVasyVpnActInfoUsed( Flags[ AsgPos ] ) ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + addauthelem( VasyHashWrite, (char*)AsgSymbol, (long)AsgSymbol ); + } + else + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "UNUSED %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + } + } + } + } + + if ( IsVasyDebugLevel0() ) + { + viewauthtable( VasyHashWrite, VasyMultiWaitViewWrite ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyMultiWaitHashWrite %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyMultiWaitArcWait2Wait | +| | +\------------------------------------------------------------*/ + +static void VasyMultiWaitArcWait2Wait( VpnFigure, VpnProc, BeginTrans, AsgTrans, EndTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *BeginTrans; + vpntrans_list *AsgTrans; + vpntrans_list *EndTrans; +{ + vasyprocinfo *ProcInfo; + vasytransinfo *TransInfo; + vasyactinfo *ActInfo; + vasysyminfo *SymInfo; + vpnact_list *VpnAction; + vpnsym *AsgSymbol; + vpnsym *VpnSymbol; + vpndecl_list *AsgDeclar; + vexexpr *AsgAtom; + char *AtomName; + chain_list **Support; + chain_list **Literal; + chain_list **Event; + chain_list *ScanChain; + unsigned char *Flags; + int AsgIndex; + int AsgMin; + int AsgMax; + int AsgPos; + auth2table *HashSupport; + int NumberWrite; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitArcWait2Wait %s (%s) %s\n", + BeginTrans->NAME, AsgTrans->NAME, EndTrans->NAME ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " Arc from %s to %s\n", BeginTrans->NAME, EndTrans->NAME ); + VasyPrintf( stdout, " Condition : " ); + viewvexexprboundln( AsgTrans->VEX_GUARD ); + } + + if ( VasyHashSens == (authtable *)0 ) + { + VasyHashSens = createauthtable( 100 ); + } + + for ( ScanChain = BeginTrans->WAIT_SYM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = GetVpnSymbol( ScanChain ); + addauthelem( VasyHashSens, (char*)VpnSymbol, (long)VpnSymbol ); + } + + TransInfo = GetVasyVpnTransInfo( AsgTrans ); + HashSupport = TransInfo->HASH_SUPPORT; + + NumberWrite = 0; + + for ( VpnAction = AsgTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + if ( VpnAction->TYPE == VPN_ACT_ASG_DEFINE ) continue; + + ActInfo = GetVasyVpnActInfo( VpnAction ); + Support = ActInfo->SUPPORT; + Literal = ActInfo->LITERAL; + Event = ActInfo->EVENT; + Flags = ActInfo->FLAGS; + + AsgAtom = VpnAction->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + SymInfo = &ActInfo->SYM_INFO[ AsgPos ]; + SymInfo->TYPE = VASY_SYM_UNKNOWN; +/* +** Symbol is not used just skip it ! +*/ + if ( ! IsVasyVpnActInfoUsed( Flags[ AsgPos ] ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " Skip Symbol %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + SymInfo->TYPE = VASY_SYM_UNUSED; continue; + } + else + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " Treat Symbol %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + } +/* +** No event should appear in the assignation ! +*/ + if ( Event[ AsgPos ] != (chain_list *)0 ) + { + VasyPrintf( stdout, "ERROR Event in %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } +/* +** Check if there is a Tristate literal in the assignation +*/ + for ( ScanChain = Literal[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + if ( ScanChain->DATA == VEX_ATOM_TRISTATE ) + { + VasyPrintf( stdout, "ERROR Tristate in %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + } +# if 0 +/* +** Check if there is a Cycle in the assignation +*/ + Element2 = searchauth2elem( HashSupport, (char*)&Support[ AsgPos ], (char*)AsgSymbol ); + + if ( Element2 != (auth2elem *)0 ) + { + VasyPrintf( stdout, "ERROR Loop in %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } +# endif + + NumberWrite++; + } + } + + if ( NumberWrite != VasyHashWrite->NUMBER_ELEM ) + { + VasyPrintf( stdout, "WARNING Output assignation missing in %s (%s) %s\n", + BeginTrans->NAME, AsgTrans->NAME, EndTrans->NAME ); + } + + resetauthtable( VasyHashSens ); + + ProcInfo->TYPE = VASY_PROC_FSM; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitArcWait2Wait %s (%s) %s\n", + BeginTrans->NAME, AsgTrans->NAME, EndTrans->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyMultiWaitCreateVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasyMultiWaitCreateVpnTrans( VpnFigure, VpnProc, BeginTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *BeginTrans; +{ + vasywaitinfo *WaitInfo; + vpnplace_list *BeginPlace; + vpnplace_list *VpnPlace; + vpnplace_list *EndPlace; + vpntrans_list *VpnTrans; + vpntrans_list *DefTrans; + vpntrans_list *AsgTrans; + vpntrans_list *EndTrans; + vpnarc *VpnArc; + chain_list *ScanChain; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitCreateVpnTrans %s\n", BeginTrans->NAME ); + } + + WaitInfo = VasyAddVpnWaitInfo( BeginTrans ); + VpnArc = GetVpnArc( BeginTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + BeginPlace = VpnPlace; + DefTrans = (vpntrans_list *)0; + + if ( VpnPlace->NUMBER_OUT == 1 ) + { + VpnArc = GetVpnArc( VpnPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( VpnTrans->TYPE != VPN_TRANS_IMMEDIATE ) + { + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( VpnPlace->NUMBER_OUT > 1 ) + { + BeginPlace = VpnPlace; + DefTrans = VpnTrans; + } + } + } + + WaitInfo->DEF_TRANS = DefTrans; + WaitInfo->WAIT_PLACE = BeginPlace; + + if ( DefTrans != (vpntrans_list *)0 ) + { +/* +** Initialize all define action's for support computation +*/ + VasySupportCreateVpnTrans( VpnFigure, VpnProc, DefTrans ); +/* +** Hash and compute the support and cycle of all actions +*/ + VasySupportVpnTrans( VpnFigure, VpnProc, DefTrans, 0 ); + } + + for ( ScanChain = BeginPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( AsgTrans->PLACE_OUT ); + EndPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + EndTrans = GetVpnArcTargetTrans( VpnArc ); +/* +** Initialize all action's for support computation +*/ + VasySupportCreateVpnTrans( VpnFigure, VpnProc, AsgTrans ); + + if ( DefTrans != (vpntrans_list *)0 ) + { +/* +** Merge define assignation with all actions +*/ + VasySupportMergeVpnTrans( VpnFigure, VpnProc, DefTrans, AsgTrans ); + } +/* +** Hash and compute the support and cycle of all actions +*/ + VasySupportVpnTrans( VpnFigure, VpnProc, AsgTrans, 0 ); +/* +** Compute all the used symbols for all actions +*/ + VasySupportUsedVpnTrans( VpnFigure, VpnProc, AsgTrans ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyMultiWaitCreateVpnTrans %s\n", BeginTrans->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyMultiWaitDestroyVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasyMultiWaitDestroyVpnTrans( VpnFigure, VpnProc, BeginTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *BeginTrans; +{ + vasywaitinfo *WaitInfo; + vpnplace_list *BeginPlace; + vpntrans_list *DefTrans; + vpntrans_list *AsgTrans; + vpnarc *VpnArc; + chain_list *ScanChain; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitDestroyVpnTrans %s\n", BeginTrans->NAME ); + } + + WaitInfo = GetVasyVpnWaitInfo( BeginTrans ); + + DefTrans = WaitInfo->DEF_TRANS; + BeginPlace = WaitInfo->WAIT_PLACE; + + if ( DefTrans != (vpntrans_list *)0 ) + { +/* +** Destroy all define action's information +*/ + VasySupportDestroyVpnTrans( VpnFigure, VpnProc, DefTrans ); + } + + for ( ScanChain = BeginPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); +/* +** Destroy all action's information +*/ + VasySupportDestroyVpnTrans( VpnFigure, VpnProc, AsgTrans ); + } + + VasyDelVpnWaitInfo( BeginTrans ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyMultiWaitDestroyVpnTrans %s\n", BeginTrans->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyMultiWaitFsmVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyMultiWaitFsmVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vasyprocinfo *ProcInfo; + vasywaitinfo *WaitInfo; + vpnplace_list *WaitPlace; + vpnplace_list *EndPlace; + vpntrans_list *LoopTrans; + vpntrans_list *WaitTrans; + vpntrans_list *AsgTrans; + vpntrans_list *EndTrans; + vpnsym *SensSymbol; + vpnsym *EventSymbol; + vpnarc *VpnArc; + vexexpr *VexGuard; + vexexpr *VexLoop; + vexexpr *VexEvent; + vexexpr *VexEnable; + chain_list *ScanChain; + chain_list *DelChain; + chain_list **PrevChain; + chain_list *SupportBdd; + chain_list *SupportVex; + authelem *Element; + bddcircuit *BddCircuit; + bddsystem *BddSystem; + bddassoc *BddAssoc; + bddnode *BddStable; + bddnode *BddNode; + bddnode *BddGuard; + bddnode *BddLoop; + bddnode *BddAux0; + bddnode *BddAux1; + bddvar BddVar; + long NumberLoop; + long MissLoop; + long NumberSens; + int ClockType; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitFsmVpnProc %s\n", VpnProc->NAME ); + } +/* +** Hash All Written and Used Vpn symbol +*/ + VasyMultiWaitHashWrite( VpnFigure, VpnProc ); +/* +** Create Bdd Circuit for the process +*/ + VasyVexBddCreateBddCircuit( VpnFigure, VpnProc ); + + if ( VasyHashClock == (authtable *)0 ) + { + VasyHashClock = createauthtable( 100 ); + } + else + { + resetauthtable( VasyHashClock ); + } +/* +** Compute the Fsm's clock condition +*/ + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + BddSystem = ProcInfo->BDD_SYSTEM; + + BddLoop = BddSystem->ONE; + SupportBdd = (chain_list *)0; + NumberLoop = 0; + MissLoop = 0; + + for ( WaitTrans = VpnProc->TRANS; + WaitTrans != (vpntrans_list *)0; + WaitTrans = WaitTrans->NEXT ) + { + if ( WaitTrans->TYPE != VPN_TRANS_INF_WAIT ) continue; + + NumberSens = 0; + SensSymbol = (vpnsym *)0; + + for ( ScanChain = WaitTrans->WAIT_SYM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + SensSymbol = GetVpnSymbol( ScanChain ); + NumberSens++; + } + + if ( NumberSens != 1 ) SensSymbol = (vpnsym *)0; + + WaitInfo = GetVasyVpnWaitInfo( WaitTrans ); + WaitPlace = WaitInfo->WAIT_PLACE; + LoopTrans = (vpntrans_list *)0; + + for ( ScanChain = WaitPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + + VpnArc = GetVpnArc( AsgTrans->PLACE_OUT ); + EndPlace = GetVpnArcTargetPlace( VpnArc ); + + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + EndTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( EndTrans == WaitTrans ) + { + if ( ( LoopTrans == (vpntrans_list *)0 ) || + ( AsgTrans->ACT == (vpnact_list *)0 ) ) + { + LoopTrans = AsgTrans; + } + } + } + + if ( LoopTrans == (vpntrans_list *)0 ) + { + VasyPrintf( stdout, "ERROR missing loop arc in wait trans %s\n", WaitTrans->NAME ); + MissLoop++; + } + else + { + WaitInfo->LOOP_TRANS = LoopTrans; +/* +** If there is only one signal in the sensitivity list => Add event +*/ + if ( SensSymbol != (vpnsym *)0 ) + { + VexEvent = VasyMultiWaitCreateVexEvent( SensSymbol ); + VexEvent = createvexunaryexpr( VEX_NOT, 1, VexEvent ); + + LoopTrans->VEX_GUARD = createvexbinexpr( VEX_OR, 1, LoopTrans->VEX_GUARD, VexEvent ); + } + + VexGuard = LoopTrans->VEX_GUARD; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " Loop condition in wait %s\n", WaitTrans->NAME ); + VasyPrintf( stdout, " > " ); + viewvexexprboundln( LoopTrans->VEX_GUARD ); + } + + BddGuard = VasyVexBddConvertVex2Bdd( VpnFigure, VpnProc, LoopTrans, VexGuard, 0 ); +/* +** Build a Bdd association with all symbols of the BddGuard +*/ + freechain( SupportBdd ); + SupportBdd = getbddnodesupportchain( BddSystem, BddGuard ); + + PrevChain = &SupportBdd; + ScanChain = SupportBdd; + + while ( ScanChain != (chain_list *)0 ) + { + BddNode = (bddnode *)ScanChain->DATA; + + if ( NumberLoop == 0 ) + { + addauthelem( VasyHashClock, (char*)BddNode, 1 ); + + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + } + else + { + Element = searchauthelem( VasyHashClock, (char*)BddNode ); + + if ( ( Element != (authelem *)0 ) && + ( Element->VALUE == NumberLoop ) ) + { + Element->VALUE++; + + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + } + else + { + DelChain = ScanChain; + ScanChain = ScanChain->NEXT; + *PrevChain = ScanChain; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + } + } + + addbddcircuitout( BddCircuit, WaitTrans->NAME, BddGuard ); + + BddLoop = applybddnode( BddSystem, ABL_AND, + decbddrefext( BddLoop ), + decbddrefext( BddGuard ) ); + NumberLoop++; + } + } + + if ( MissLoop ) + { + VasyPrintf( stdout, "ERROR missing loop condition in %s !\n", VpnProc->NAME ); + return; /* Should EXIT ! */ + } + + ProcInfo->TYPE = VASY_PROC_FSM; + + BddAssoc = addbddassoc( BddSystem ); + + for ( ScanChain = SupportBdd; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + BddNode = (bddnode *)ScanChain->DATA; + BddVar = getbddvarbyindex( BddSystem, BddNode->INDEX ); + addbddnodeassoc( BddSystem, BddAssoc, BddVar, BddNode ); + } + + freechain( SupportBdd ); + + BddLoop = forallbddnodemissassoc( BddSystem, decbddrefext( BddLoop ), BddAssoc ); + BddLoop = applybddnodenot( BddSystem, decbddrefext( BddLoop ) ); + + if ( IsVasyDebugLevel1() ) + { + addbddcircuitout( BddCircuit, "loop", BddLoop ); + testbddcircuit( BddCircuit ); + BddLoop = decbddrefext( BddLoop ); + BddLoop = searchbddcircuitout( BddCircuit, "loop" ); + BddLoop = incbddrefext( BddLoop ); + delbddcircuitout( BddCircuit, "loop" ); + } + + delbddassoc( BddSystem, BddAssoc ); +/* +** Check if there is an edge in the loop condition +*/ + VexLoop = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddLoop ); + SupportVex = VasySupportVpnTransEventBitVex( VpnFigure, VpnProc, VexLoop ); + freevexexpr( VexLoop ); + + if ( SupportVex == (chain_list *)0 ) + { + VasyPrintf( stdout, "ERROR missing edge in the FSM condition !\n" ); + + return; /* Should EXIT ! */ + } + else + if ( SupportVex->NEXT != (chain_list *)0 ) + { + VasyPrintf( stdout, "ERROR too many events in the FSM condition !\n" ); + + return; /* Should EXIT ! */ + } + + EventSymbol = (vpnsym *)SupportVex->DATA; + freechain( SupportVex ); +/* +** Modify all Guard's Transitions with BddLoop +*/ + for ( WaitTrans = VpnProc->TRANS; + WaitTrans != (vpntrans_list *)0; + WaitTrans = WaitTrans->NEXT ) + { + if ( WaitTrans->TYPE != VPN_TRANS_INF_WAIT ) continue; + + WaitInfo = GetVasyVpnWaitInfo( WaitTrans ); + WaitPlace = WaitInfo->WAIT_PLACE; + + DelChain = (chain_list *)0; + + for ( ScanChain = WaitPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( AsgTrans->PLACE_OUT ); + EndPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + EndTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Arc %s -> %s -> %s\n", + WaitTrans->NAME, AsgTrans->NAME, EndTrans->NAME ); + } + + VexGuard = AsgTrans->VEX_GUARD; + BddGuard = VasyVexBddConvertVex2Bdd( VpnFigure, VpnProc, AsgTrans, VexGuard, 0 ); + BddGuard = cofactorbddnode( BddSystem, decbddrefext( BddGuard ), BddLoop ); + + addbddcircuitout( BddCircuit, AsgTrans->NAME, BddGuard ); + + if ( BddGuard != BddSystem->ZERO ) + { + if ( BddGuard == BddSystem->ONE ) + { + freevexexpr( AsgTrans->VEX_GUARD ); + AsgTrans->VEX_GUARD = (vexexpr *)0; + + if ( AsgTrans->TYPE == VPN_TRANS_GUARDED ) + { + AsgTrans->TYPE = VPN_TRANS_IMMEDIATE; + } + else + { + AsgTrans->TYPE = VPN_TRANS_ACT_EXEC; + } + } + else + { + VexGuard = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddGuard ); + freevexexpr( AsgTrans->VEX_GUARD ); + AsgTrans->VEX_GUARD = VexGuard; + + decbddrefext( BddGuard ); + } + + VasyMultiWaitArcWait2Wait( VpnFigure, VpnProc, WaitTrans, AsgTrans, EndTrans ); + } + else + { + DelChain = addchain( DelChain, AsgTrans ); + } + } + + for ( ScanChain = DelChain; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + AsgTrans = (vpntrans_list *)ScanChain->DATA; + delvpntrans( VpnFigure, AsgTrans ); + } + + freechain( DelChain ); + } + + VexEvent = (vexexpr *)0; + VexLoop = (vexexpr *)0; + VexEnable = (vexexpr *)0; + + BddStable = VasyVexBddSearchBddCircuitStable( VpnFigure, VpnProc, EventSymbol ); + BddVar = getbddvarbyindex( BddSystem, BddStable->INDEX ); + + BddAux0 = restrictbddnode( BddSystem, BddLoop, BddVar, BddSystem->ZERO ); + BddAux1 = restrictbddnode( BddSystem, BddLoop, BddVar, BddSystem->ONE ); +/* +** Check the correctness of the event attribute in the loop condition +*/ + if ( BddAux1 == BddAux0 ) + { + VasyPrintf( stdout, "ERROR missing edge in the FSM condition !\n" ); + } +/* +** Stable True => Loop = 0 and Stable False => Loop != 0 ! +*/ + if ( BddAux1 != BddSystem->ZERO ) + { + VasyPrintf( stdout, "ERROR Illegal use of the event attribute !\n" ); + } + + if ( BddAux0 == BddSystem->ONE ) + { + VasyPrintf( stdout, "ERROR Illegal use of the event attribute !\n" ); + } + + VexEvent = VasyMultiWaitCreateVexEvent( EventSymbol ); + + decbddrefext( BddLoop ); + BddLoop = incbddrefext( BddAux0 ); + + decbddrefext( BddAux0 ); + decbddrefext( BddAux1 ); +/* +** Check if there is a write enable condition in the follow condition +*/ + BddNode = VasyVexBddSearchBddCircuitInput( VpnFigure, VpnProc, EventSymbol ); + BddVar = getbddvarbyindex( BddSystem, BddNode->INDEX ); + + BddAux0 = restrictbddnode( BddSystem, BddLoop, BddVar, BddSystem->ZERO ); + BddAux1 = restrictbddnode( BddSystem, BddLoop, BddVar, BddSystem->ONE ); +/* +** Positive Edge Condition -> CK'event and CK and WEN +*/ + ClockType = 0; + + if ( BddAux0 == BddSystem->ZERO ) + { + if ( BddAux1 != BddSystem->ONE ) + { + VexEnable = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddAux1 ); + + decbddrefext( BddLoop ); + BddLoop = cofactorbddnode( BddSystem, BddLoop, BddAux1 ); + } + + ClockType = VASY_BIVEX_RISING_EDGE; + } + else +/* +** Negative Edge Condition -> CK'event and CK and WEN +*/ + if ( BddAux1 == BddSystem->ZERO ) + { + if ( BddAux0 != BddSystem->ONE ) + { + VexEnable = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddAux0 ); + + decbddrefext( BddLoop ); + BddLoop = cofactorbddnode( BddSystem, BddLoop, BddAux0 ); + } + + decbddrefext( BddLoop ); + BddLoop = applybddnodenot( BddSystem, BddLoop ); + + ClockType = VASY_BIVEX_FALLING_EDGE; + } + else + { + VasyPrintf( stdout, "ERROR Illegal edge condition !\n" ); + } + + decbddrefext( BddAux0 ); + decbddrefext( BddAux1 ); + + VexLoop = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddLoop ); + + VasyAddVpnProcBiVex( ProcInfo, VexLoop, (vexexpr *)0, ClockType ); + + if ( VexEnable != (vexexpr *)0 ) + { + VasyAddVpnProcBiVex( ProcInfo, VexEnable, (vexexpr *)0, VASY_BIVEX_SYNC_WEN ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " Loop : " ); + viewvexexprboundln( VexLoop ); + VasyPrintf( stdout, " Event : " ); + viewvexexprboundln( VexEvent ); + VasyPrintf( stdout, " Enable : " ); + viewvexexprboundln( VexEnable ); + } +/* +** Destroy Bdd Circuit for the process +*/ + VasyVexBddDestroyBddCircuit( VpnFigure, VpnProc ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyMultiWaitFsmVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyMultiWaitVpnProc | +| | +\------------------------------------------------------------*/ + +void VasyMultiWaitVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyMultiWaitVpnProc %s\n", VpnProc->NAME ); + VasyDebugSaveVpnFig( VpnFigure ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VasyMultiWaitCreateVpnTrans( VpnFigure, VpnProc, VpnTrans ); + } + } + + VasyMultiWaitFsmVpnProc( VpnFigure, VpnProc ); + + VasySynthesisMultiWaitVpnProc( VpnFigure, RtlFigure, VpnProc ); + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VasyMultiWaitDestroyVpnTrans( VpnFigure, VpnProc, VpnTrans ); + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + VasyPrintf( stdout, " <-- VasyMultiWaitVpnProc %s\n", VpnProc->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_mulwait.h b/alliance/src/vasy/src/vasy_mulwait.h new file mode 100644 index 00000000..3158a895 --- /dev/null +++ b/alliance/src/vasy/src/vasy_mulwait.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_mulwait.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_MULWAIT_H +# define VASY_MULWAIT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyMultiWaitVpnProc(); + +# endif diff --git a/alliance/src/vasy/src/vasy_onewait.c b/alliance/src/vasy/src/vasy_onewait.c new file mode 100644 index 00000000..0f3d3607 --- /dev/null +++ b/alliance/src/vasy/src/vasy_onewait.c @@ -0,0 +1,2062 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_onewait.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_shared.h" +# include "vasy_support.h" +# include "vasy_vexbdd.h" +# include "vasy_synth.h" +# include "vasy_onewait.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashSens = (authtable *)0; + static authtable *VasyHashBitVecDef = (authtable *)0; + static authtable *VasyHashDefine = (authtable *)0; + static authtable *VasyHashSupport = (authtable *)0; + + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyOneWaitCreateVexEvent | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyOneWaitCreateVexEvent( SensSymbol ) + + vpnsym *SensSymbol; +{ + vexexpr *VexEvent; + + if ( SensSymbol->INDEX == -1 ) + { + VexEvent = createvexatombit( SensSymbol->NAME ); + } + else + { + VexEvent = createvexatomvec( SensSymbol->NAME, SensSymbol->INDEX, SensSymbol->INDEX ); + } + + VexEvent = createvexunaryexpr( VEX_EVENT, 1, VexEvent ); + + return( VexEvent ); +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitAddVexEvent | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyOneWaitAddVexEvent( AsgAtom, AsgExpr, SensSymbol ) + + vexexpr *AsgAtom; + vexexpr *AsgExpr; + vpnsym *SensSymbol; +{ + vexexpr *VexEvent; + vexexpr *VexNEvent; + + VexEvent = VasyOneWaitCreateVexEvent( SensSymbol ); + VexNEvent = createvexunaryexpr( VEX_NOT , 1, dupvexexpr( VexEvent ) ); + + VexEvent = createvexbinexpr( VEX_IFT, AsgExpr->WIDTH, VexEvent , dupvexexpr( AsgExpr ) ); + VexNEvent = createvexbinexpr( VEX_IFT, AsgAtom->WIDTH, VexNEvent, dupvexexpr( AsgAtom ) ); + + AsgExpr = createvexbinexpr( VEX_OR, AsgExpr->WIDTH, VexEvent, VexNEvent ); + + return( AsgExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitSubstVexAtom | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyOneWaitSubstVexAtom( Expr ) + + vexexpr *Expr; +{ + authelem *Element; + vpndecl_list *DefDeclar; + vpnact_list *VarAsg; + vpnsym *VarSymbol; + vexexpr *VarAtom; + vpnsym *DefSymbol; + char *DefName; + vexexpr *SubstExpr; + int Scan; + int Index; + int Width; + int Step; + + SubstExpr = (vexexpr *)0; + DefName = GetVexAtomValue( Expr ); + Element = searchauthelem( VasyHashDefine, DefName ); +/* +** Check if define should be substituted +*/ + if ( Element != (authelem *)0 ) + { + DefDeclar = searchvpndeclall( VasyFigure, DefName ); + VarAsg = (vpnact_list *)Element->VALUE; + + if ( ! isvextypedivisible( DefDeclar->BASE ) ) + { + freevexexpr( Expr ); + Expr = dupvexexpr( VarAsg->VEX_ATOM ); + } + else + { + if ( Expr->LEFT > Expr->RIGHT ) Step = -1; + else Step = 1; + + Index = Expr->LEFT; + Width = Expr->WIDTH; + + for ( Scan = 0; Scan < Width; Scan++ ) + { + DefSymbol = getvpnsymdecl( DefDeclar, Index ); + Element = searchauthelem( VasyHashBitVecDef, (char*)DefSymbol ); + + if ( Element != (authelem *)0 ) break; + } + + if ( Scan < Width ) + { + if ( Width > 1 ) SubstExpr = createvexoper( VEX_CONCAT, Width ); + + for ( Scan = 0; Scan < Width; Scan++ ) + { + DefSymbol = getvpnsymdecl( DefDeclar, Index ); + Element = searchauthelem( VasyHashBitVecDef, (char*)DefSymbol ); + + if ( Element != (authelem *)0 ) VarSymbol = (vpnsym *)Element->VALUE; + else VarSymbol = DefSymbol; + + VarAtom = createvexatomvec( VarSymbol->NAME, VarSymbol->INDEX, VarSymbol->INDEX ); + + if ( Width == 1 ) SubstExpr = VarAtom; + else addvexqexpr( SubstExpr, VarAtom ); + + Index += Step; + } + + freevexexpr( Expr ); + Expr = simpvexexpr( SubstExpr ); + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyOneWaitSubstVexAtom\n" ); + VasyPrintf( stdout, " +++ Replace %s by ", DefName ); + viewvexexprboundln( Expr ); + VasyPrintf( stdout, " <-- VasyOneWaitSubstVexAtom\n" ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitSubstVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyOneWaitSubstVex( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + vexexpr *SubstExpr; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( ! IsVexAtomLiteral( Expr ) ) + { + Expr = VasyOneWaitSubstVexAtom( Expr, 0 ); + } + + return( Expr ); + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + SubstExpr = VasyOneWaitSubstVex( GetVexOperand( ScanOper ) ); + SetVexOperand( ScanOper, SubstExpr ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitSubstVpnAct | +| | +\------------------------------------------------------------*/ + +static void VasyOneWaitSubstVpnAct( VpnFigure, VpnProc, VpnTrans, VpnAct ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vpnact_list *VpnAct; +{ + VasyFigure = VpnFigure; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyOneWaitSubstVpnAct\n" ); + VasyPrintf( stdout, " +++ " ); + viewvexexprboundln( VpnAct->VEX_EXPR ); + } + + VpnAct->VEX_EXPR = VasyOneWaitSubstVex( VpnAct->VEX_EXPR ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ " ); + viewvexexprboundln( VpnAct->VEX_EXPR ); + VasyPrintf( stdout, " <-- VasyOneWaitSubstVpnAct\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitAssignVpnSymbol | +| | +\------------------------------------------------------------*/ + +static void VasyOneWaitAssignVpnSymbol( VpnFigure, VpnProc , VpnTrans, + AsgAction, AsgSymbol, SensSymbol ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vpnact_list *AsgAction; + vpnsym *AsgSymbol; + vpnsym *SensSymbol; +{ + vasyprocinfo *ProcInfo; + vasytransinfo *TransInfo; + vasyactinfo *ActInfo; + vasysyminfo *SymInfo; + vpnact_list *DefAction; + vpnact_list *DefAction2; + vpnact_list *VpnAction2; + vpnsym *EventSymbol; + vpnsym *DefSymbol; + vpnsym *DefSymbol2; + vpnsym *AsgSymbol2; + vpndecl_list *DefDeclar; + vpndecl_list *DefDeclar2; + vpndecl_list *AsgDeclar; + vpndecl_list *AsgDeclar2; + vexexpr *AsgExpr; + vexexpr *DefAtom; + vexexpr *DefAtom2; + vexexpr *AsgAtom; + vexexpr *AsgAtom2; + authelem *Element; + auth2elem *Element2; + chain_list **Support; + chain_list **Literal; + chain_list **Event; + chain_list **Support2; + chain_list **Literal2; + chain_list **DefSupport; + chain_list **DefSupport2; + unsigned char *DefFlags; + unsigned char *DefFlags2; + unsigned char *Flags; + unsigned char *Flags2; + chain_list *ListOutput; + chain_list *SupportBdd; + chain_list *ScanChain; + chain_list *ScanChain2; + int DefPos; + int DefPos2; + int AsgPos; + int AsgPos2; + int DefIndex; + int DefIndex2; + int AsgIndex2; + short AddInput; + short Subst; + short InFollow; + short FreeAsgExpr; + bddcircuit *BddCircuit; + bddsystem *BddSystem; + bddnode **BddLiteral; + bddassoc *BddAssoc; + bddnode *BddAssign; + bddnode *BddAux; + bddnode *BddAux0; + bddnode *BddAux1; + bddnode *BddNotAux0; + bddnode *BddNotAux1; + bddnode *BddFollow; + bddnode *BddOscill; + bddnode *BddData; + bddnode *BddNode; + bddnode *BddStable; + bddnode *BddClock; + bddnode *BddFAsync; + bddnode *BddCAsync; + bddnode *BddCSetAsync; + bddnode *BddCResetAsync; + bddnode *BddCWriteAsync; + bddnode *BddDataAsync; + bddnode *BddCEdgeSync; + bddnode *BddFEdgeSync; + bddnode *BddFSync; + bddnode *BddCSync; + bddnode *BddCEdge; + bddnode *BddRising; + bddnode *BddFalling; + bddnode *BddCSetSync; + bddnode *BddCResetSync; + bddnode *BddCWriteSync; + bddnode *BddDataSync; + bddvar BddVar; + vexexpr *VexExpr; + vexexpr *VexData; + authtable *HashAssign; + authtable *HashBitVec; + auth2table *HashLiteral; + auth2table *HashSupport; + long Size; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyOneWaitAssignVpnSymbol\n" ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + BddSystem = ProcInfo->BDD_SYSTEM; + BddLiteral = ProcInfo->BDD_LITERAL; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + HashAssign = TransInfo->HASH_ASSIGN; + HashBitVec = TransInfo->HASH_BITVEC; + HashLiteral = TransInfo->HASH_LITERAL; + HashSupport = TransInfo->HASH_SUPPORT; + + ActInfo = GetVasyVpnActInfo( AsgAction ); + Literal = ActInfo->LITERAL; + Support = ActInfo->SUPPORT; + Flags = ActInfo->FLAGS; + Event = ActInfo->EVENT; + + ActInfo->SPLIT = 1; + + AsgDeclar = AsgSymbol->DECL; + AsgAtom = AsgAction->VEX_ATOM; + AsgExpr = AsgAction->VEX_EXPR; + AsgPos = getvexvectorpos( AsgAtom, AsgSymbol->INDEX ); + + SymInfo = &ActInfo->SYM_INFO[ AsgPos ]; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + if ( AsgDeclar->TYPE == VPN_DECLAR_VARIABLE ) + { + DefSymbol = (vpnsym *)Support[ AsgPos ]->DATA; + + addauthelem( VasyHashBitVecDef, (char*)DefSymbol, (long)AsgSymbol ); + addauthelem( VasyHashDefine , DefSymbol->NAME , (long)AsgAction ); + } + + FreeAsgExpr = 0; + + if ( Event[ AsgPos ] != (chain_list *)0 ) + { + EventSymbol = (vpnsym *)Event[ AsgPos ]->DATA; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Event Symbol %s\n", EventSymbol->NAME ); + } + } + else + { + EventSymbol = SensSymbol; + + if ( IsVasyDebugLevel1() ) + { + if ( EventSymbol != (vpnsym *)0 ) + { + VasyPrintf( stdout, "Event Symbol %s\n", EventSymbol->NAME ); + } + } + } +/* +** Special case for register with one wait sens list symbol => Add Event +*/ + if ( ( SensSymbol != (vpnsym *)0 ) && + ( SymInfo->TYPE == VASY_SYM_REGISTER ) ) + { + if ( SensSymbol != EventSymbol ) + { + VasyPrintf( stdout, "ERROR bad event %s %d\n", EventSymbol->NAME, EventSymbol->INDEX ); + } + + AsgExpr = VasyOneWaitAddVexEvent( AsgAtom, AsgExpr, SensSymbol ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> Add Event %s %d\n", SensSymbol->NAME, SensSymbol->INDEX ); + } + + if ( IsVasyDebugLevel1() ) + { + viewvexexprboundln( AsgExpr ); + } + + FreeAsgExpr = 1; + } + + ListOutput = (chain_list *)0; + + for ( ScanChain = Support[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + AsgSymbol2 = (vpnsym *)ScanChain->DATA; + AsgDeclar2 = AsgSymbol2->DECL; + + AddInput = 1; + + if ( AsgDeclar2->TYPE == VPN_DECLAR_DEFINE ) + { + if ( isvextypedivisible( AsgDeclar2->BASE ) ) + { + Element = searchauthelem( HashBitVec, (char*)AsgSymbol2 ); + } + else + { + Element = searchauthelem( HashAssign, AsgSymbol2->NAME ); + } + + VpnAction2 = (vpnact_list *)Element->VALUE; + Literal2 = GetVasyVpnActInfoLiteral( VpnAction2 ); + Support2 = GetVasyVpnActInfoSupport( VpnAction2 ); + Flags2 = GetVasyVpnActInfoFlags( VpnAction2 ); + AsgAtom2 = VpnAction2->VEX_ATOM; + + if ( AsgSymbol2->INDEX == -1 ) AsgIndex2 = 0; + else AsgIndex2 = AsgSymbol2->INDEX; + + AsgPos2 = getvexvectorpos( AsgAtom2, AsgIndex2 ); +/* +** For all defines assignation where AsgSymbol appears (cycle) => Substitute defines +*/ + Element2 = searchauth2elem( HashSupport, + (char*)&Support2[ AsgPos2 ], (char*)AsgSymbol ); + + if ( ( SymInfo->TYPE == VASY_SYM_TRISTATE ) && + ( Element2 == (auth2elem *)0 ) ) + { +/* +** For all defines assignation where 'z' appears => Substitute defines +*/ + Element2 = searchauth2elem( HashLiteral, + (char*)&Literal2[ AsgPos2 ], + (char*)VEX_ATOM_BY_ID[ SymInfo->TRS_TYPE ] ); + } + + if ( ( Element2 == (auth2elem *)0 ) && + ( EventSymbol != (vpnsym *)0 ) ) + { + Element2 = searchauth2elem( HashSupport, + (char*)&Support2[ AsgPos2 ], (char*)EventSymbol ); + } + + if ( Element2 != (auth2elem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Should subst %s %d\n", AsgSymbol2->NAME, AsgSymbol2->INDEX ); + } + + if ( ! IsVasyVpnActInfoArith( Flags2[ AsgPos2 ] ) ) + { + AddInput = 0; + } + else + { +/* +** Substitution is impossible when there's an arithmetic expression ! +*/ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "WARNING: Arithmetic !! unable to substitute\n" ); + } + } + } + else + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Don't substitute %s %d\n", AsgSymbol2->NAME, AsgSymbol2->INDEX ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " >> " ); + viewvexexprboundln( VpnAction2->VEX_ATOM ); + VasyPrintf( stdout, " #= " ); + viewvexexprboundln( VpnAction2->VEX_EXPR ); + } + } + else + if ( AsgDeclar2->TYPE == VPN_DECLAR_CONSTANT ) + { + AddInput = 0; + } + + if ( AddInput ) + { + BddNode = VasyVexBddAddBddCircuitInput( VpnFigure, VpnProc, AsgSymbol2 ); + } + else + { + ListOutput = addchain( ListOutput, AsgSymbol2 ); + } + } + + if ( ( SymInfo->TYPE == VASY_SYM_TRISTATE ) && + ( SymInfo->VEX_DATA != (vexexpr *)0 ) ) + { + AsgPos = 0; + AsgExpr = SymInfo->VEX_DATA; + SymInfo->VEX_DATA = (vexexpr *)0; + + FreeAsgExpr = 1; + } + + do + { + Subst = 0; +/* +** Create The Bdd of the register/tristate assignment +*/ + Size = VasyVexBddConvertVex2BddSize( VpnFigure, VpnProc, VpnTrans, AsgExpr, AsgPos ); + + if ( Size > 400 ) + { + VasyPrintf( stdout, "ERROR too complex assignment %s %d -> %ld\n", + AsgSymbol->NAME, AsgSymbol->INDEX, Size ); + break; + } + + BddAssign = VasyVexBddConvertVex2Bdd( VpnFigure, VpnProc, VpnTrans, AsgExpr, AsgPos ); + + if ( SymInfo->TYPE == VASY_SYM_TRISTATE ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "*** Check tristate !\n" ); + } + + BddNode = BddLiteral[ SymInfo->TRS_TYPE ]; + BddVar = getbddvarbyindex( BddSystem, BddNode->INDEX ); + + BddAux0 = restrictbddnode( BddSystem, BddAssign, BddVar, BddSystem->ZERO ); + BddAux1 = restrictbddnode( BddSystem, BddAssign, BddVar, BddSystem->ONE ); + + BddNotAux0 = applybddnodenot( BddSystem, BddAux0 ); + BddNotAux1 = applybddnodenot( BddSystem, BddAux1 ); + + BddFollow = applybddnode( BddSystem, ABL_OR, BddAux0, BddNotAux1 ); + BddData = incbddrefext( BddAux0 ); + + if ( BddFollow == BddSystem->ZERO ) + { + SymInfo->TYPE = VASY_SYM_COMBINATORIAL; + } + + if ( IsVasyDebugLevel1() ) + { + addbddcircuitout( BddCircuit, "follow", BddFollow ); + addbddcircuitout( BddCircuit, "z0" , BddAux0 ); + addbddcircuitout( BddCircuit, "z1" , BddAux1 ); + addbddcircuitout( BddCircuit, "data" , BddData ); + addbddcircuitout( BddCircuit, "assign", BddAssign ); + + testbddcircuit( BddCircuit ); + + delbddcircuitout( BddCircuit, "follow" ); + delbddcircuitout( BddCircuit, "z0" ); + delbddcircuitout( BddCircuit, "z1" ); + delbddcircuitout( BddCircuit, "data" ); + delbddcircuitout( BddCircuit, "assign" ); + } + + decbddrefext( BddAux0 ); + decbddrefext( BddAux1 ); + decbddrefext( BddNotAux0 ); + decbddrefext( BddNotAux1 ); + } + else + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "*** Check register !\n" ); + } + + BddAux = VasyVexBddSearchBddCircuitInput( VpnFigure, VpnProc, AsgSymbol ); + BddVar = getbddvarbyindex( BddSystem, BddAux->INDEX ); + + BddAux0 = restrictbddnode( BddSystem, BddAssign, BddVar, BddSystem->ZERO ); + BddAux1 = restrictbddnode( BddSystem, BddAssign, BddVar, BddSystem->ONE ); + + BddNotAux0 = applybddnodenot( BddSystem, BddAux0 ); + BddNotAux1 = applybddnodenot( BddSystem, BddAux1 ); +/* +** Check the possibility of an oscillation !!! +*/ + BddOscill = applybddnode( BddSystem, ABL_AND, BddAux0, BddNotAux1 ); + + if ( BddOscill != BddLocalSystem->ZERO ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "WARNING Possibility of an oscillation !!\n" ); + + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddOscill ); + VasyPrintf( stdout, " Oscill : " ); + viewvexexprboundln( VexExpr ); + + freevexexpr( VexExpr ); + } + } + + BddFollow = applybddnode( BddSystem, ABL_OR, BddAux0, BddNotAux1 ); + + if ( BddFollow == BddSystem->ONE ) + { +/* +** The symbol assignment is not of type register => just dataflow +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "It's not a register, symbol always assigned !\n" ); + } + + BddData = incbddrefext( BddAssign ); + + SymInfo->TYPE = VASY_SYM_COMBINATORIAL; + } + else + if ( BddFollow == BddSystem->ZERO ) + { +/* +** The symbol assignment is not of type register => just delete it +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "It's not a register, symbol never assigned !\n" ); + } + + BddData = BddSystem->ZERO; + + SymInfo->TYPE = VASY_SYM_CONSTANT; + } + else + { +/* +** The symbol assignment is of type register => analysis +*/ + /* ICI BIG BUG !! Corrected ... + BddData = incbddrefext( BddAux0 ); + */ + BddData = applybddnode( BddSystem, ABL_AND, BddAssign, BddFollow ); + SymInfo->TYPE = VASY_SYM_REGISTER; + } + + if ( IsVasyDebugLevel1() ) + { + addbddcircuitout( BddCircuit, "follow", BddFollow ); + addbddcircuitout( BddCircuit, "aux_0" , BddAux0 ); + addbddcircuitout( BddCircuit, "aux_1" , BddAux1 ); + addbddcircuitout( BddCircuit, "oscill", BddOscill ); + addbddcircuitout( BddCircuit, "data" , BddData ); + addbddcircuitout( BddCircuit, "assign", BddAssign ); + + testbddcircuit( BddCircuit ); + + delbddcircuitout( BddCircuit, "follow" ); + delbddcircuitout( BddCircuit, "aux_0" ); + delbddcircuitout( BddCircuit, "aux_1" ); + delbddcircuitout( BddCircuit, "oscill" ); + delbddcircuitout( BddCircuit, "data" ); + delbddcircuitout( BddCircuit, "assign" ); + } + + decbddrefext( BddAux0 ); + decbddrefext( BddAux1 ); + decbddrefext( BddNotAux0 ); + decbddrefext( BddNotAux1 ); + decbddrefext( BddOscill ); + + } +/* +** For Follow condition, verify there's no define ! +*/ + if ( BddFollow != BddSystem->ZERO ) + { + resetauthtable( VasyHashSupport ); + + SupportBdd = VasyVexBddSupportVpnSymbol( VpnFigure, VpnProc, BddFollow ); + + for ( ScanChain = SupportBdd; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + DefSymbol = (vpnsym *)ScanChain->DATA; + addauthelem( VasyHashSupport, (char *)DefSymbol, 0 ); + } + + freechain( SupportBdd ); + + SupportBdd = VasyVexBddSupportVpnSymbol( VpnFigure, VpnProc, BddAssign ); + + for ( ScanChain = SupportBdd; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + DefSymbol = (vpnsym *)ScanChain->DATA; + DefDeclar = DefSymbol->DECL; + + if ( DefDeclar->TYPE == VPN_DECLAR_DEFINE ) + { + Element = searchauthelem( VasyHashSupport, (char *)DefSymbol ); + + if ( Element != (authelem *)0 ) InFollow = 1; + else InFollow = 0; + + if ( isvextypedivisible( DefDeclar->BASE ) ) + { + Element = searchauthelem( HashBitVec, (char*)DefSymbol ); + } + else + { + Element = searchauthelem( HashAssign, DefSymbol->NAME ); + } + + DefAction = (vpnact_list *)Element->VALUE; + DefFlags = GetVasyVpnActInfoFlags( DefAction ); + DefSupport = GetVasyVpnActInfoSupport( DefAction ); + DefAtom = DefAction->VEX_ATOM; + + if ( DefSymbol->INDEX == -1 ) DefIndex = 0; + else DefIndex = DefSymbol->INDEX; + + DefPos = getvexvectorpos( DefAtom, DefIndex ); + + if ( ! IsVasyVpnActInfoArith( DefFlags[ DefPos ] ) ) + { + if ( ! InFollow ) + { + for ( ScanChain2 = DefSupport[ DefPos ]; + ScanChain2 != (chain_list *)0; + ScanChain2 = ScanChain2->NEXT ) + { + DefSymbol2 = (vpnsym *)ScanChain2->DATA; + Element = searchauthelem( VasyHashSupport, (char *)DefSymbol2 ); + + if ( Element != (authelem *)0 ) + { + InFollow = 1; break; + } + } + } + + if ( InFollow ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Should subst %s %d\n", DefSymbol->NAME, DefSymbol->INDEX ); + } + + for ( ScanChain2 = DefSupport[ DefPos ]; + ScanChain2 != (chain_list *)0; + ScanChain2 = ScanChain2->NEXT ) + { + DefSymbol2 = (vpnsym *)ScanChain2->DATA; + DefDeclar2 = DefSymbol2->DECL; + + if ( DefDeclar2->TYPE == VPN_DECLAR_DEFINE ) + { + if ( isvextypedivisible( DefDeclar2->BASE ) ) + { + Element = searchauthelem( HashBitVec, (char*)DefSymbol2 ); + } + else + { + Element = searchauthelem( HashAssign, DefSymbol2->NAME ); + } + + DefAction2 = (vpnact_list *)Element->VALUE; + DefSupport2 = GetVasyVpnActInfoSupport( DefAction2 ); + DefFlags2 = GetVasyVpnActInfoFlags( DefAction2 ); + DefAtom2 = DefAction2->VEX_ATOM; + + if ( DefSymbol2->INDEX == -1 ) DefIndex2 = 0; + else DefIndex2 = DefSymbol2->INDEX; + + DefPos2 = getvexvectorpos( DefAtom2, DefIndex2 ); + + if ( ! IsVasyVpnActInfoArith( DefFlags2[ DefPos2 ] ) ) + { + VasyVexBddDelBddCircuitInput( VpnFigure, VpnProc, DefSymbol2 ); + VasyVexBddDelBddCircuitOutput( VpnFigure, VpnProc, DefSymbol2 ); + } + else + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "WARNING: Arithmetic !! unable to substitute\n" ); + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " >> " ); + viewvexexprboundln( DefAction2->VEX_ATOM ); + VasyPrintf( stdout, " #= " ); + viewvexexprboundln( DefAction2->VEX_EXPR ); + } + } + } + + VasyVexBddDelBddCircuitInput( VpnFigure, VpnProc, DefSymbol ); + + Subst = 1; + } + } + else + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " >> " ); + viewvexexprboundln( DefAction->VEX_ATOM ); + VasyPrintf( stdout, " #= " ); + viewvexexprboundln( DefAction->VEX_EXPR ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "WARNING: Arithmetic !! unable to substitute\n" ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " >> " ); + viewvexexprboundln( DefAction->VEX_ATOM ); + VasyPrintf( stdout, " #= " ); + viewvexexprboundln( DefAction->VEX_EXPR ); + } + } + } + + freechain( SupportBdd ); + } +/* +** No more define to substitute, convert bdd to vex and perform analysis +*/ + if ( ! Subst ) + { + reorderbddsystemsimple( BddSystem ); + + if ( SymInfo->TYPE == VASY_SYM_COMBINATORIAL ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddData ); + SymInfo->VEX_DATA = VexExpr; + } + else +/* +** Register analysis, extract sync/async set and reset, write enable and edge ... +*/ + if ( ( SymInfo->TYPE == VASY_SYM_REGISTER ) || + ( SymInfo->TYPE == VASY_SYM_TRISTATE ) ) + { + BddFAsync = BddSystem->ZERO; + BddCAsync = BddSystem->ZERO; + BddCSetAsync = BddSystem->ZERO; + BddCResetAsync = BddSystem->ZERO; + BddCWriteAsync = BddSystem->ZERO; + BddDataAsync = BddSystem->ZERO; + + if ( EventSymbol != (vpnsym *)0 ) + { + BddStable = VasyVexBddSearchBddCircuitStable( VpnFigure, VpnProc, EventSymbol ); + BddVar = getbddvarbyindex( BddSystem, BddStable->INDEX ); + + BddCAsync = restrictbddnode( BddSystem, BddFollow, BddVar, BddSystem->ONE ); + BddFAsync = restrictbddnode( BddSystem, BddData , BddVar, BddSystem->ONE ); + } + else + { + BddCAsync = incbddrefext( BddFollow ); + BddFAsync = incbddrefext( BddData ); + } +/* +** Build a Bdd association with all symbols of the BddCAsync +*/ + BddAssoc = addbddassoc( BddSystem ); + SupportBdd = getbddnodesupportchain( BddSystem, BddCAsync ); + + for ( ScanChain = SupportBdd; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + BddNode = (bddnode *)ScanChain->DATA; + BddVar = getbddvarbyindex( BddSystem, BddNode->INDEX ); + addbddnodeassoc( BddSystem, BddAssoc, BddVar, BddNode ); + } + + freechain( SupportBdd ); +/* +** Search all asynchronous informations +*/ + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCAsync, BddFAsync ); + decbddrefext( BddNode ); + BddNode = forallbddnodemissassoc( (bddsystem *)0, BddNode, BddAssoc ); + + BddCSetAsync = BddNode; + + BddNode = applybddnodenot( (bddsystem *)0, BddFAsync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCAsync, BddNode ); + decbddrefext( BddNode ); + BddNode = forallbddnodemissassoc( (bddsystem *)0, BddNode, BddAssoc ); + + BddCResetAsync = BddNode; + + BddNode = applybddnode( (bddsystem *)0, ABL_NOR, BddCSetAsync, BddCResetAsync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCAsync, BddNode ); + + BddCWriteAsync = BddNode; + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteAsync, BddFAsync ); + decbddrefext( BddNode ); + BddNode = existbddnodeassoc( (bddsystem *)0, BddNode, BddAssoc ); + + BddDataAsync = BddNode; +/* +** Verify the correctness of asynchronous informations +*/ + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteAsync, BddDataAsync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_OR , BddCSetAsync, BddNode ); + decbddrefext( BddNode ); + + if ( ( BddNode != BddFAsync ) && + ( BddCWriteAsync != BddSystem->ZERO ) ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "Cofactor for asynchronous conditions %s\n", AsgSymbol->NAME ); + } + + decbddrefext( BddDataAsync ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteAsync, BddFAsync ); + decbddrefext( BddNode ); + BddDataAsync = cofactorbddnode( (bddsystem *)0, BddNode, BddCWriteAsync ); + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteAsync, BddDataAsync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_OR , BddCSetAsync, BddNode ); + decbddrefext( BddNode ); + } + + if ( BddNode != BddFAsync ) + { + VasyPrintf( stdout, "Illegal asynchronous conditions %s\n", AsgSymbol->NAME ); + + /* TO BE DONE ! A VERIFIER */ + + decbddrefext( BddCSetAsync ); + decbddrefext( BddCResetAsync ); + decbddrefext( BddCWriteAsync ); + decbddrefext( BddDataAsync ); + + BddCWriteAsync = incbddrefext( BddFollow ); + BddDataAsync = incbddrefext( BddData ); + } +/* +** Add asynchronous informations to symbol +*/ + { + if ( BddCSetAsync != BddSystem->ZERO ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddCSetAsync ); + VasyAddVpnSymBiVex( SymInfo, VexExpr, (vexexpr *)0, VASY_BIVEX_ASYNC_SET ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " SetAsync : " ); + viewvexexprboundln( VexExpr ); + } + } + + if ( BddCResetAsync != BddSystem->ZERO ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddCResetAsync ); + VasyAddVpnSymBiVex( SymInfo, VexExpr, (vexexpr *)0, VASY_BIVEX_ASYNC_RESET ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " ResetAsync : " ); + viewvexexprboundln( VexExpr ); + } + } + + if ( BddCWriteAsync != BddSystem->ZERO ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddCWriteAsync ); + VexData = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddDataAsync ); + VasyAddVpnSymBiVex( SymInfo, VexExpr, VexData, VASY_BIVEX_ASYNC_WEN ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " WriteAsync : " ); + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, " DataAsync : " ); + viewvexexprboundln( VexData ); + } + } + + if ( ( BddCSetAsync != BddSystem->ZERO ) || + ( BddCResetAsync != BddSystem->ZERO ) || + ( BddCWriteAsync != BddSystem->ZERO ) ) + { + SymInfo->REG_TYPE = VASY_SYM_REGISTER_ASYNC; + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Asynchronous analysis results\n" ); + + addbddcircuitout( BddCircuit, "follow", BddFollow ); + addbddcircuitout( BddCircuit, "data" , BddData ); + addbddcircuitout( BddCircuit, "casync", BddCAsync ); + addbddcircuitout( BddCircuit, "fasync", BddFAsync ); + addbddcircuitout( BddCircuit, "csa" , BddCSetAsync ); + addbddcircuitout( BddCircuit, "cra" , BddCResetAsync ); + addbddcircuitout( BddCircuit, "cwa" , BddCWriteAsync ); + addbddcircuitout( BddCircuit, "dwa" , BddDataAsync ); + + testbddcircuit( BddCircuit ); + + delbddcircuitout( BddCircuit, "follow" ); + delbddcircuitout( BddCircuit, "data" ); + delbddcircuitout( BddCircuit, "casync" ); + delbddcircuitout( BddCircuit, "fasync" ); + delbddcircuitout( BddCircuit, "csa" ); + delbddcircuitout( BddCircuit, "cra" ); + delbddcircuitout( BddCircuit, "cwa" ); + delbddcircuitout( BddCircuit, "dwa" ); + } + + decbddrefext( BddCSetAsync ); + decbddrefext( BddCResetAsync ); + decbddrefext( BddCWriteAsync ); + decbddrefext( BddDataAsync ); +/* +** Search all synchronous informations +*/ + if ( EventSymbol != (vpnsym *)0 ) + { + BddFSync = BddSystem->ZERO; + BddCSync = BddSystem->ZERO; + BddCEdge = BddSystem->ZERO; + BddRising = BddSystem->ZERO; + BddFalling = BddSystem->ZERO; + BddCSetSync = BddSystem->ZERO; + BddCResetSync = BddSystem->ZERO; + BddCWriteSync = BddSystem->ZERO; + BddDataSync = BddSystem->ZERO; + + BddAux0 = applybddnodenot( (bddsystem *)0, BddCAsync ); + BddFEdgeSync = applybddnode( (bddsystem *)0, ABL_AND, BddData , BddAux0 ); + BddCEdgeSync = applybddnode( (bddsystem *)0, ABL_AND, BddFollow, BddAux0 ); +/* +** Verify there is no intersection between CAsync and CEdge +*/ + BddAux1 = existbddnodeassoc( (bddsystem *)0, BddCEdgeSync, BddAssoc ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddAux1, BddAux0 ); + + decbddrefext( BddAux0 ); + decbddrefext( BddAux1 ); + decbddrefext( BddNode ); + + if ( BddNode == BddCEdgeSync ) + { + decbddrefext( BddCEdgeSync ); + BddCEdgeSync = incbddrefext( BddAux1 ); + + decbddrefext( BddFEdgeSync ); + BddFEdgeSync = existbddnodeassoc( (bddsystem *)0, BddFEdgeSync, BddAssoc ); + } + else + { + VasyPrintf( stdout, "Conflict between asynchronous and synchronous condition !\n" ); + } + + delbddassoc( BddSystem, BddAssoc ); + BddAssoc = addbddassoc( BddSystem ); + + BddStable = VasyVexBddSearchBddCircuitStable( VpnFigure, VpnProc, EventSymbol ); + BddVar = getbddvarbyindex( BddSystem, BddStable->INDEX ); + addbddnodeassoc( BddSystem, BddAssoc, BddVar, BddStable ); + + BddClock = VasyVexBddSearchBddCircuitInput( VpnFigure, VpnProc, EventSymbol ); + BddVar = getbddvarbyindex( BddSystem, BddClock->INDEX ); + addbddnodeassoc( BddSystem, BddAssoc, BddVar, BddClock ); + + BddCEdge = existbddnodemissassoc( (bddsystem *)0, BddCEdgeSync, BddAssoc ); + + BddFalling = applybddnode( (bddsystem *)0, ABL_NOR, BddClock, BddStable ); + BddNode = applybddnodenot( (bddsystem *)0, BddStable ); + decbddrefext( BddNode ); + BddRising = applybddnode( (bddsystem *)0, ABL_AND, BddClock, BddNode ); + + if ( ( BddCEdge != BddFalling ) && + ( BddCEdge != BddRising ) ) + { + if ( BddCEdge != BddLocalSystem->ZERO ) + { + VasyPrintf( stdout, "Illegal edge condition on %s!\n", AsgSymbol->NAME ); + } + + BddCSync = incbddrefext( BddCEdgeSync ); + BddFSync = incbddrefext( BddFEdgeSync ); + + decbddrefext( BddCEdge ); + BddCEdge = BddSystem->ZERO; + } + else + { + BddCSync = existbddnodeassoc( (bddsystem *)0, BddCEdgeSync, BddAssoc ); + BddFSync = existbddnodeassoc( (bddsystem *)0, BddFEdgeSync, BddAssoc ); + } + + delbddassoc( BddSystem, BddAssoc ); + + if ( BddCSync != BddSystem->ONE ) + { + BddAssoc = addbddassoc( BddSystem ); + + SupportBdd = getbddnodesupportchain( BddSystem, BddCSync ); + + for ( ScanChain = SupportBdd; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + BddNode = (bddnode *)ScanChain->DATA; + BddVar = getbddvarbyindex( BddSystem, BddNode->INDEX ); + addbddnodeassoc( BddSystem, BddAssoc, BddVar, BddNode ); + } + + freechain( SupportBdd ); +/* +** Search all synchronous informations +*/ + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCSync, BddFSync ); + decbddrefext( BddNode ); + BddNode = forallbddnodemissassoc( (bddsystem *)0, BddNode, BddAssoc ); + + BddCSetSync = BddNode; + + BddNode = applybddnodenot( (bddsystem *)0, BddFSync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCSync, BddNode ); + decbddrefext( BddNode ); + BddNode = forallbddnodemissassoc( (bddsystem *)0, BddNode, BddAssoc ); + + BddCResetSync = BddNode; + + BddNode = applybddnode( (bddsystem *)0, ABL_NOR, BddCSetSync, BddCResetSync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCSync, BddNode ); + + BddCWriteSync = BddNode; + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteSync, BddFSync ); + decbddrefext( BddNode ); + + BddNode = existbddnodeassoc( (bddsystem *)0, BddNode, BddAssoc ); + BddDataSync = BddNode; + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteSync, BddDataSync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_OR , BddCSetSync, BddNode ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCEdge, BddNode ); + decbddrefext( BddNode ); + + if ( ( BddNode != BddFEdgeSync ) && + ( BddCWriteSync != BddSystem->ZERO ) ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "Cofactor for synchronous conditions %s\n", + AsgSymbol->NAME ); + } + + decbddrefext( BddDataSync ); + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteSync, BddFSync ); + decbddrefext( BddNode ); + + BddNode = cofactorbddnode( (bddsystem *)0, BddNode, BddCWriteSync ); + BddDataSync = BddNode; + } + } + else + { + BddCWriteSync = BddSystem->ONE; + BddDataSync = incbddrefext( BddFSync ); + } +/* +** Verify the correctness of synchronous informations +*/ + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCWriteSync, BddDataSync ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_OR , BddCSetSync, BddNode ); + decbddrefext( BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, BddCEdge, BddNode ); + decbddrefext( BddNode ); + + if ( BddNode != BddFEdgeSync ) + { + VasyPrintf( stdout, "Illegal synchronous conditions %s\n", AsgSymbol->NAME ); + } +/* +** Add synchronous informations to symbol +*/ + if ( BddCEdge != BddSystem->ZERO ) + { + if ( SymInfo->REG_TYPE == VASY_SYM_REGISTER_ASYNC ) + { + SymInfo->REG_TYPE = VASY_SYM_REGISTER_MIXED; + } + else + { + SymInfo->REG_TYPE = VASY_SYM_REGISTER_SYNC; + } + + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddClock ); + + if ( BddCEdge == BddFalling ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " FallingEdge : " ); + viewvexexprboundln( VexExpr ); + } + VasyAddVpnSymBiVex( SymInfo, VexExpr, (vexexpr *)0, VASY_BIVEX_FALLING_EDGE ); + } + else + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " RisingEdge : " ); + viewvexexprboundln( VexExpr ); + } + VasyAddVpnSymBiVex( SymInfo, VexExpr, (vexexpr *)0, VASY_BIVEX_RISING_EDGE ); + } + + if ( BddCSetSync != BddSystem->ZERO ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddCSetSync ); + VasyAddVpnSymBiVex( SymInfo, VexExpr, (vexexpr *)0, VASY_BIVEX_SYNC_SET ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " SetSync : " ); + viewvexexprboundln( VexExpr ); + } + } + + if ( BddCResetSync != BddSystem->ZERO ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddCResetSync ); + VasyAddVpnSymBiVex( SymInfo, VexExpr, (vexexpr *)0, VASY_BIVEX_SYNC_RESET ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " ResetSync : " ); + viewvexexprboundln( VexExpr ); + } + } + + if ( BddCWriteSync != BddSystem->ZERO ) + { + VexExpr = (vexexpr *)0; + + if ( BddCWriteSync != BddSystem->ONE ) + { + VexExpr = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddCWriteSync ); + } + + VexData = VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddDataSync ); + VasyAddVpnSymBiVex( SymInfo, VexExpr, VexData, VASY_BIVEX_SYNC_WEN ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " WriteSync : " ); + viewvexexprboundln( VexExpr ); + VasyPrintf( stdout, " DataSync : " ); + viewvexexprboundln( VexData ); + } + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Synchronous analysis results\n" ); + + addbddcircuitout( BddCircuit, "follow" , BddFollow ); + addbddcircuitout( BddCircuit, "data" , BddData ); + addbddcircuitout( BddCircuit, "cedge" , BddCEdge ); + addbddcircuitout( BddCircuit, "fedges" , BddFEdgeSync ); + addbddcircuitout( BddCircuit, "falling", BddFalling ); + addbddcircuitout( BddCircuit, "rising" , BddRising ); + addbddcircuitout( BddCircuit, "fsync" , BddFSync ); + addbddcircuitout( BddCircuit, "csync" , BddCSync ); + addbddcircuitout( BddCircuit, "css" , BddCSetSync ); + addbddcircuitout( BddCircuit, "crs" , BddCResetSync ); + addbddcircuitout( BddCircuit, "cws" , BddCWriteSync ); + addbddcircuitout( BddCircuit, "dws" , BddDataSync ); + + testbddcircuit( BddCircuit ); + + delbddcircuitout( BddCircuit, "follow" ); + delbddcircuitout( BddCircuit, "data" ); + delbddcircuitout( BddCircuit, "cedge" ); + delbddcircuitout( BddCircuit, "fedges" ); + delbddcircuitout( BddCircuit, "falling" ); + delbddcircuitout( BddCircuit, "rising" ); + delbddcircuitout( BddCircuit, "fsync" ); + delbddcircuitout( BddCircuit, "csync" ); + delbddcircuitout( BddCircuit, "css" ); + delbddcircuitout( BddCircuit, "crs" ); + delbddcircuitout( BddCircuit, "cws" ); + delbddcircuitout( BddCircuit, "dws" ); + } + + decbddrefext( BddFSync ); + decbddrefext( BddCSync ); + decbddrefext( BddCEdge ); + decbddrefext( BddRising ); + decbddrefext( BddFalling ); + decbddrefext( BddCSetSync ); + decbddrefext( BddCResetSync ); + decbddrefext( BddCWriteSync ); + decbddrefext( BddDataSync ); + } + + decbddrefext( BddFAsync ); + decbddrefext( BddCAsync ); + + delbddassoc( BddSystem, BddAssoc ); + } + } + + decbddrefext( BddFollow ); + decbddrefext( BddData ); + decbddrefext( BddAssign ); + + for ( ScanChain = ListOutput; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + DefSymbol = (vpnsym *)ScanChain->DATA; + VasyVexBddDelBddCircuitOutput( VpnFigure, VpnProc, DefSymbol ); + } + } + while ( Subst ); + + freechain( ListOutput ); + + if ( FreeAsgExpr ) + { + freevexexpr( AsgExpr ); + } + + if ( SymInfo->BIVEX != (vasybivex_list *)0 ) + { + SymInfo->BIVEX = (vasybivex_list *)reverse( (chain_list *)SymInfo->BIVEX ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyOneWaitAssignVpnSymbol %d\n", SymInfo->TYPE ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasyOneWaitVpnTrans( VpnFigure, VpnProc, WaitTrans, VpnTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *WaitTrans; + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + vasyactinfo *ActInfo; + vasysyminfo *SymInfo; + vpnact_list *VpnAction; + vpnsym *AsgSymbol; + vpnsym *VpnSymbol; + vpnsym *SensSymbol; + vpndecl_list *AsgDeclar; + vpndecl_list *VpnDeclar; + vexexpr *AsgAtom; + vexexpr *VexBit; + char *AtomName; + authelem *Element; + auth2elem *Element2; + chain_list **Support; + chain_list **Literal; + chain_list **Event; + chain_list *ScanChain; + chain_list *SupportBit; + unsigned char *Flags; + int NumberEvent; + int NumberSens; + int NumberInSens; + int NumberNotInSens; + int NumberSupport; + int TristateLoop; + int AsgIndex; + int AsgMin; + int AsgMax; + int AsgPos; + auth2table *HashSupport; + authtable *HashAssign; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyOneWaitVpnTrans %s\n", VpnTrans->NAME ); + } +/* +** Create Bdd Circuit +*/ + VasyVexBddCreateBddCircuit( VpnFigure, VpnProc ); +/* +** Hash All symbol that appears in the sensitivity list +*/ + if ( VasyHashSens == (authtable *)0 ) + { + VasyHashSens = createauthtable( 100 ); + VasyHashDefine = createauthtable( 100 ); + VasyHashBitVecDef = createauthtable( 100 ); + VasyHashSupport = createauthtable( 100 ); + } + + NumberSens = 0; + SensSymbol = (vpnsym *)0; + + for ( ScanChain = WaitTrans->WAIT_SYM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + SensSymbol = GetVpnSymbol( ScanChain ); + addauthelem( VasyHashSens, (char*)SensSymbol, (long)SensSymbol ); + + NumberSens++; + } + + if ( NumberSens != 1 ) SensSymbol = (vpnsym *)0; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + HashSupport = TransInfo->HASH_SUPPORT; + HashAssign = TransInfo->HASH_ASSIGN; +/* +** Never assigned variable should be replaced by define +*/ + for ( ScanChain = VpnProc->VAR_DECL; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnDeclar = (vpndecl_list *)ScanChain->DATA; + AsgAtom = VpnDeclar->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + + Element = searchauthelem( HashAssign, AtomName ); + + if ( Element == (authelem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Variable %s never assigned !\n", AtomName ); + } + + VpnDeclar->TYPE = VPN_DECLAR_CONSTANT; + } + } + + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + VasyOneWaitSubstVpnAct( VpnFigure, VpnProc, VpnTrans, VpnAction ); + + if ( VpnAction->TYPE == VPN_ACT_ASG_DEFINE ) continue; + + ActInfo = GetVasyVpnActInfo( VpnAction ); + Support = ActInfo->SUPPORT; + Literal = ActInfo->LITERAL; + Event = ActInfo->EVENT; + Flags = ActInfo->FLAGS; + + AsgAtom = VpnAction->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + SymInfo = &ActInfo->SYM_INFO[ AsgPos ]; + SymInfo->TYPE = VASY_SYM_UNKNOWN; +/* +** Symbol is not used just skip it ! +*/ + if ( ! IsVasyVpnActInfoUsed( Flags[ AsgPos ] ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Skip Symbol %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + SymInfo->TYPE = VASY_SYM_UNUSED; continue; + } + else + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Treat Symbol %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + } +/* +** Count the number of event that appear in the assignation +*/ + NumberEvent = 0; + + for ( ScanChain = Event[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + + Element = searchauthelem( VasyHashSens, (char*)VpnSymbol ); + + if ( Element == (authelem *)0 ) + { + VasyPrintf( stdout, "ERROR Event symbol %s %d but not in sens list\n", + AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + NumberEvent++; + } + + if ( NumberEvent > 1 ) + { + VasyPrintf( stdout, "ERROR more than one event %d\n", NumberEvent ); + } + + NumberInSens = 0; + NumberNotInSens = 0; + NumberSupport = 0; +/* +** Count the number of signals that appear in the sensitivity list +*/ + for ( ScanChain = Support[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VpnDeclar = VpnSymbol->DECL; + + if ( ( VpnDeclar->TYPE != VPN_DECLAR_DEFINE ) && + ( VpnDeclar->TYPE != VPN_DECLAR_VARIABLE ) ) + { + Element = searchauthelem( VasyHashSens, (char*)VpnSymbol ); + + if ( Element != (authelem *)0 ) NumberInSens++; + else NumberNotInSens++; + } + + if ( VpnDeclar->TYPE != VPN_DECLAR_DEFINE ) + { + NumberSupport++; + } + } +/* +** Check if there is a Tristate literal in the assignation +*/ + for ( ScanChain = Literal[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + if ( ScanChain->DATA == VEX_ATOM_TRISTATE ) + { + SymInfo->TYPE = VASY_SYM_TRISTATE; + SymInfo->TRS_TYPE = VEX_TRISTATE_ID; + + break; + } + else + if ( ScanChain->DATA == VEX_ATOM_WEAK_ZERO ) + { + SymInfo->TYPE = VASY_SYM_TRISTATE; + SymInfo->TRS_TYPE = VEX_WEAK_ZERO_ID; + + break; + } + else + if ( ScanChain->DATA == VEX_ATOM_WEAK_ONE ) + { + SymInfo->TYPE = VASY_SYM_TRISTATE; + SymInfo->TRS_TYPE = VEX_WEAK_ONE_ID; + + break; + } + } +/* +** Check if there is a Cycle in the assignation +*/ + Element2 = searchauth2elem( HashSupport, + (char*)&Support[ AsgPos ], (char*)AsgSymbol ); + + if ( ( Element2 != (auth2elem *)0 ) && + ( IsVasyVpnActInfoArith( Flags[ AsgPos ] ) ) ) + { + VasyPrintf( stdout, "ERROR arithmetic loop !\n" ); continue; + } + + if ( ( Element2 != (auth2elem *)0 ) && + ( SymInfo->TYPE == VASY_SYM_TRISTATE ) ) + { + TristateLoop = 1; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "WARNING tristate loop !\n" ); + } + } + else + { + TristateLoop = 0; + } + + if ( NumberInSens == 0 ) + { +/* +** None support's signal appear in the sensitivity list +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "None support's signal appear in the sensitivity list\n" ); + } + + if ( Element2 != (auth2elem *)0 ) + { +/* +** None support's signal in the sens list and there is a cyle => ERROR ! +*/ + VasyPrintf( stdout, "ERROR none support'signal in the sens list and a cycle\n" ); + continue; + } + else + if ( ( NumberSupport == 0 ) || + ( NumberNotInSens == 0 ) ) + { + if ( NumberSupport == 0 ) + { +/* +** Support is empty and there is no cycle => Assign constant value +*/ + if ( SymInfo->TYPE != VASY_SYM_TRISTATE ) + { + SymInfo->TYPE = VASY_SYM_CONSTANT; + } + } + else + { +/* +** Support is not empty and there is no cycle => Assign variable only +*/ + if ( SymInfo->TYPE != VASY_SYM_TRISTATE ) + { + SymInfo->TYPE = VASY_SYM_COMBINATORIAL; + } + } + } + else + { +/* +** None support's signal in the sensitivity list => ERROR ! +*/ + VasyPrintf( stdout, "ERROR none support'signal in the sensitivity list\n" ); + continue; + } + } + else + if ( NumberNotInSens == 0 ) + { +/* +** All signals appear in the sensitivity list +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "All signals appear in the sensitivity list\n" ); + } + + if ( Element2 == (auth2elem *)0 ) + { +/* +** There is no cycle => Assign dataflow +*/ + if ( SymInfo->TYPE != VASY_SYM_TRISTATE ) + { + SymInfo->TYPE = VASY_SYM_COMBINATORIAL; + } + } + else + { +/* +** There is a cycle, should be a register (May be a Latch) +*/ + if ( SymInfo->TYPE != VASY_SYM_TRISTATE ) + { + SymInfo->TYPE = VASY_SYM_REGISTER; + } + } + } + else + { +/* +** Some signals appear in the sensitivity list => registers ! +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Some signals appear in the sensitivity list !\n" ); + } + + if ( Element2 == (auth2elem *)0 ) + { +/* +** Some signals in the sens list and there is no cyle => ERROR ! +*/ + VasyPrintf( stdout, "ERROR Some signals are missing in the sens list" ); + VasyDisplayLines( VpnProc->LINE ); + fprintf( stdout, "\n" ); + + continue; + } + else + { +/* +** There is a cycle, assign register (May be a D-register) +*/ + if ( SymInfo->TYPE != VASY_SYM_TRISTATE ) + { + SymInfo->TYPE = VASY_SYM_REGISTER; + } + } + } + + if ( ( SymInfo->TYPE == VASY_SYM_TRISTATE ) || + ( SymInfo->TYPE == VASY_SYM_REGISTER ) ) + { + if ( TristateLoop ) + { + SymInfo->TYPE = VASY_SYM_REGISTER; + SensSymbol = (vpnsym *)0; + + VasyOneWaitAssignVpnSymbol( VpnFigure, VpnProc , VpnTrans, + VpnAction, AsgSymbol, SensSymbol ); + + if ( SymInfo->TYPE != VASY_SYM_COMBINATORIAL ) + { + VasyPrintf( stdout, "ERROR Tristate loop\n" ); continue; + } + + SymInfo->TYPE = VASY_SYM_TRISTATE; + } + + VasyOneWaitAssignVpnSymbol( VpnFigure, VpnProc , VpnTrans, + VpnAction, AsgSymbol, SensSymbol ); + } + + if ( SymInfo->TYPE == VASY_SYM_REGISTER ) + { +/* +** Verify that the follow, set and reset condition's support are included in the sens list +*/ + /* TO BE DONE + if ( SymInfo->VEX_COND != (vexexpr *)0 ) + { + VexBit = SymInfo->VEX_COND; + SupportBit = VasySupportVpnTransBitVex( VpnFigure, VpnProc, VpnTrans, VexBit ); + + for ( ScanChain = SupportBit; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasyPrintf( stdout, " + Sup Cond %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); + } + + freechain( SupportBit ); + } + */ + + if ( SymInfo->VEX_DATA != (vexexpr *)0 ) + { +/* +** Verify that there is no variable in the data support +*/ + VexBit = SymInfo->VEX_DATA; + SupportBit = VasySupportVpnTransBitVex( VpnFigure, VpnProc, VpnTrans, VexBit ); + + for ( ScanChain = SupportBit; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasyPrintf( stdout, " + Sup Data %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); + } + + freechain( SupportBit ); + } + } + else + if ( ( SymInfo->TYPE == VASY_SYM_COMBINATORIAL ) || + ( SymInfo->TYPE == VASY_SYM_TRISTATE ) ) + { +/* +** Should verify again the sensitivity list !! +*/ + if ( NumberNotInSens != 0 ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "ERROR Some signals are missing in the sens list\n" ); + } + } + } + } + } +/* +** Destroy Bdd Circuit +*/ + VasyVexBddDestroyBddCircuit( VpnFigure, VpnProc ); + + resetauthtable( VasyHashSens ); + resetauthtable( VasyHashDefine ); + resetauthtable( VasyHashBitVecDef ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyOneWaitVpnTrans %s\n", VpnTrans->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyOneWaitVpnProc | +| | +\------------------------------------------------------------*/ + +void VasyOneWaitVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *WaitTrans; + vpntrans_list *ActionTrans; + vpnplace_list *SkipPlace; + vpnarc *VpnArc; + vasyprocinfo *ProcInfo; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyOneWaitVpnProc %s\n", VpnProc->NAME ); + } + + WaitTrans = VpnProc->ELABO; +/* +** Sensitivity list is empty never waked up, could be a constant initialisation +*/ + if ( WaitTrans->WAIT_SYM == (chain_list *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Sensitivity list is empty never waked up !\n" ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + ProcInfo->TYPE = VASY_PROC_UNUSED; + + return; + } + + VpnArc = GetVpnArc( WaitTrans->PLACE_OUT ); + SkipPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( SkipPlace->TRANS_OUT ); + ActionTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Wait Trans %s\n" , WaitTrans->NAME ); + VasyPrintf( stdout, " +++ Action Trans %s\n", ActionTrans->NAME ); + } +/* +** Initialize all action's for support computation +*/ + VasySupportCreateVpnTrans( VpnFigure, VpnProc, ActionTrans ); +/* +** Hash and compute the support and cycle of all actions +*/ + VasySupportVpnTrans( VpnFigure, VpnProc, ActionTrans, 1 ); +/* +** Compute all the used symbols for all actions +*/ + VasySupportUsedVpnTrans( VpnFigure, VpnProc, ActionTrans ); +/* +** Compute register symbol for all actions +*/ + VasyOneWaitVpnTrans( VpnFigure, VpnProc, WaitTrans, ActionTrans ); + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + ProcInfo->TYPE = VASY_PROC_DATA_FLOW; +/* +** Reset all support information for all actions +*/ + VasySupportResetVpnTrans( VpnFigure, VpnProc, ActionTrans ); +/* +** Hash and compute the support and cycle of all actions +*/ + VasySupportVpnTrans( VpnFigure, VpnProc, ActionTrans, 0 ); +/* +** Compute all the used symbols for all actions +*/ + VasySupportUsedVpnTrans( VpnFigure, VpnProc, ActionTrans ); +/* +** Synthesis of all actions +*/ + VasySynthesisOneWaitVpnProc( VpnFigure, RtlFigure, VpnProc ); +/* +** Destroy all action's information +*/ + VasySupportDestroyVpnTrans( VpnFigure, VpnProc, ActionTrans ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasyOneWaitVpnProc %s\n", VpnProc->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_onewait.h b/alliance/src/vasy/src/vasy_onewait.h new file mode 100644 index 00000000..a6b11d6d --- /dev/null +++ b/alliance/src/vasy/src/vasy_onewait.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_onewait.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_ONEWAIT_H +# define VASY_ONEWAIT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyOneWaitVpnProc(); + +# endif diff --git a/alliance/src/vasy/src/vasy_parse.c b/alliance/src/vasy/src/vasy_parse.c new file mode 100644 index 00000000..ead8033d --- /dev/null +++ b/alliance/src/vasy/src/vasy_parse.c @@ -0,0 +1,971 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_parse.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vbh.h" +# include "vbl.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_shared.h" +# include "vasy_parse.h" +# include "vasy_debug.h" +# include "vasy_generic.h" +# include "vasy_generate.h" +# include "vasy_loop.h" +# include "vasy_array.h" +# include "vasy_error.h" +# include "vasy_main.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static char VasyBuffer[ 512 ]; + static authtable *VasyHashTreatedModel = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyParseVerifyVexWidth | +| | +\------------------------------------------------------------*/ + +static void VasyParseVerifyVexWidth( VexExpr ) + + vexexpr *VexExpr; +{ + chain_list *ScanOper; + char *FuncName; + vexexpr *VexOperand; + int FuncId; + short Width; + long Oper; + + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( IsVexNodeVarWidth( VexExpr ) ) + { + VasyPrintf( stdout, "ERROR size of atom %s should be static\n", + GetVexAtomValue( VexExpr ) ); + autexit( 1 ); + } + } + else + if ( IsVexNodeFunc( VexExpr ) ) + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasyParseVerifyVexWidth( GetVexOperand( ScanOper ) ); + } + + FuncName = GetVexFuncValue( VexExpr ); + FuncId = getvexstdfuncid( FuncName ); + + if ( FuncId != -1 ) + { + switch ( FuncId ) + { + case VEX_STD_TO_BIT : + case VEX_STD_TO_BITVECTOR : + case VEX_STD_TO_STDULOGIC : + case VEX_STD_TO_STDLOGICVECTOR : + case VEX_STD_TO_STDULOGICVECTOR : + case VEX_STD_TO_X01 : + case VEX_STD_TO_X01Z : + case VEX_STD_TO_UX01 : + case VEX_STD_CONV_INTEGER : + case VEX_STD_RISING_EDGE : + case VEX_STD_FALLING_EDGE : + case VEX_STD_STD_LOGIC_VECTOR : + case VEX_STD_STD_ULOGIC_VECTOR : + case VEX_STD_SIGNED : + case VEX_STD_UNSIGNED : + case VEX_STD_TO_INTEGER : + + VexOperand = GetVexOperand( VexExpr->OPERAND ); + VexExpr->WIDTH = VexOperand->WIDTH; + + break; + } + } + } + else + { + Oper = GetVexOperValue( VexExpr ); + VexOperand = GetVexOperand( VexExpr->OPERAND ); + VasyParseVerifyVexWidth( VexOperand ); + + if ( ( Oper == VEX_EVENT ) || + ( Oper == VEX_NOT ) || + ( Oper == VEX_NEG ) || + ( Oper == VEX_ABS ) ) + { + VexExpr->WIDTH = VexOperand->WIDTH; + ClearVexNodeVarWidth( VexExpr ); + } + else + if ( ( Oper == VEX_OR ) || + ( Oper == VEX_AND ) || + ( Oper == VEX_XOR ) || + ( Oper == VEX_NOR ) || + ( Oper == VEX_NAND ) || + ( Oper == VEX_NXOR ) ) + { + Width = VexOperand->WIDTH; + + VexExpr->WIDTH = VexOperand->WIDTH; + ClearVexNodeVarWidth( VexExpr ); + + for ( ScanOper = VexExpr->OPERAND->NEXT; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + VasyParseVerifyVexWidth( VexOperand ); + + if ( VexOperand->WIDTH != Width ) + { + viewvexexprln( VexExpr ); + VasyPrintf( stdout, "ERROR illegal use of %s, different size width operands\n", + getvexopername( Oper ) ); + + } + } + } + else + if ( ( Oper == VEX_CONCAT ) || + ( Oper == VEX_MUL ) ) + { + Width = VexOperand->WIDTH; + + for ( ScanOper = VexExpr->OPERAND->NEXT; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + VasyParseVerifyVexWidth( VexOperand ); + + Width += VexOperand->WIDTH; + } + + ClearVexNodeVarWidth( VexExpr ); + VexExpr->WIDTH = Width; + } + else + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) || + ( Oper == VEX_LT ) || + ( Oper == VEX_LE ) || + ( Oper == VEX_GT ) || + ( Oper == VEX_GE ) ) + { + for ( ScanOper = VexExpr->OPERAND->NEXT; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + VasyParseVerifyVexWidth( VexOperand ); + } + + ClearVexNodeVarWidth( VexExpr ); + VexExpr->WIDTH = 1; + } + else + if ( ( Oper == VEX_ADD ) || + ( Oper == VEX_SUB ) ) + { + Width = VexOperand->WIDTH; + + for ( ScanOper = VexExpr->OPERAND->NEXT; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + VasyParseVerifyVexWidth( VexOperand ); + + if ( VexOperand->WIDTH > Width ) Width = VexOperand->WIDTH; + } + + ClearVexNodeVarWidth( VexExpr ); + VexExpr->WIDTH = Width; + } + else + if ( Oper == VEX_DIV ) + { + Width = VexOperand->WIDTH; + + for ( ScanOper = VexExpr->OPERAND->NEXT; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VexOperand = GetVexOperand( ScanOper ); + VasyParseVerifyVexWidth( VexOperand ); + } + + ClearVexNodeVarWidth( VexExpr ); + VexExpr->WIDTH = Width; + } + else + if ( Oper != VEX_MOD ) + { + viewvexexprln( VexExpr ); + VasyPrintf( stdout, "ERROR operator %s not supported !\n", + getvexopername( Oper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyParseVerifyVex | +| | +\------------------------------------------------------------*/ + +vexexpr *VasyParseVerifyVex( VexExpr ) + + vexexpr *VexExpr; +{ + VasyParseVerifyVexWidth( VexExpr ); + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyParseVerifyVbhFig | +| | +\------------------------------------------------------------*/ + +static void VasyParseVerifyVbhFig( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbpor_list *VbhPort; + vbaux_list *VbhAux; + vbcst_list *VbhCst; + vbmod_list *VbhMod; + vbins_list *VbhIns; + vbmap_list *VbhMap; + vexexpr *VexTarget; + vexexpr *VexExpr; + int Error; + + Error = 0; + + for ( VbhPort = VbhFigure->BEPOR; + VbhPort != (vbpor_list *)0; + VbhPort = VbhPort->NEXT ) + { + VexTarget = VbhPort->TARGET; + VexExpr = VbhPort->VEX; + + if ( ( ! IsVexNodeAtom( VexTarget ) ) || + ( ( VexExpr != (vexexpr *)0 ) && + ( ( ! IsVexNodeAtom( VexExpr ) ) || + ( ! IsVexAtomLiteral( VexExpr ) ) ) ) ) + { + fprintf( stdout, "ERROR size of port %s should be static\n", + getvexatomname( VexTarget ) ); + Error = 1; + } + } + + for ( VbhCst = VbhFigure->BECST; + VbhCst != (vbcst_list *)0; + VbhCst = VbhCst->NEXT ) + { + VexTarget = VbhCst->TARGET; + VexExpr = VbhCst->VEX; + + if ( ( ! IsVexNodeAtom( VexTarget ) ) || + ( ( VexExpr != (vexexpr *)0 ) && + ( ( ! IsVexNodeAtom( VexExpr ) ) || + ( ! IsVexAtomLiteral( VexExpr ) ) ) ) ) + { + fprintf( stdout, "ERROR size of constant %s should be static\n", + getvexatomname( VexTarget ) ); + Error = 1; + } + } + + for ( VbhAux = VbhFigure->BEAUX; + VbhAux != (vbaux_list *)0; + VbhAux = VbhAux->NEXT ) + { + VexTarget = VbhAux->TARGET; + VexExpr = VbhAux->VEX; + + if ( ( ! IsVexNodeAtom( VexTarget ) ) || + ( ( VexExpr != (vexexpr *)0 ) && + ( ( ! IsVexNodeAtom( VexExpr ) ) || + ( ! IsVexAtomLiteral( VexExpr ) ) ) ) ) + { + fprintf( stdout, "ERROR size of signal %s should be static\n", + getvexatomname( VexTarget ) ); + Error = 1; + } + } + + for ( VbhMod = VbhFigure->BEMOD; + VbhMod != (vbmod_list *)0; + VbhMod = VbhMod->NEXT ) + { + for ( VbhPort = VbhMod->BEPOR; + VbhPort != (vbpor_list *)0; + VbhPort = VbhPort->NEXT ) + { + VexTarget = VbhPort->TARGET; + VexExpr = VbhPort->VEX; + + if ( ( ! IsVexNodeAtom( VexTarget ) ) || + ( ( VexExpr != (vexexpr *)0 ) && + ( ! IsVexNodeAtom( VexExpr ) ) ) ) + { + fprintf( stdout, "ERROR size of port %s in model %s should be static\n", + getvexatomname( VexTarget ), VbhMod->NAME ); + Error = 1; + } + } + } + + for ( VbhIns = VbhFigure->BEINS; + VbhIns != (vbins_list *)0; + VbhIns = VbhIns->NEXT ) + { + for ( VbhMap = VbhIns->PORT_MAP; + VbhMap != (vbmap_list *)0; + VbhMap = VbhMap->NEXT ) + { + VexTarget = VbhMap->FORMAL; + VexExpr = VbhMap->ACTUAL; + + if ( ! IsVexNodeAtom( VexTarget ) ) + { + fprintf( stdout, "ERROR size of port map %s in instance %s should be static\n", + getvexatomname( VexTarget ), VbhIns->NAME ); + Error = 1; + } + } + } + + if ( Error ) autexit( 1 ); + + vbh_forallvexvbfig( VbhFigure, simpvexexpr, VasyParseVerifyVex ); + + if ( IsVasyDebugLevel1() ) + { + vbh_viewvbfig( VbhFigure ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyParseVbhInstanceAddPower | +| | +\------------------------------------------------------------*/ + +static void VasyParseVbhInstanceAddPower( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbins_list *VbhInstance; + vbmap_list *VbhMap; + vbtyp_list *VbhType; + vexexpr *VexFormal; + vexexpr *VexActual; + char *Name; + int AddVdd; + int AddVss; + + VbhType = vbh_getvbtyp( VbhFigure, "bit" ); + + for ( VbhInstance = VbhFigure->BEINS; + VbhInstance != (vbins_list *)0; + VbhInstance = VbhInstance->NEXT ) + { + AddVdd = 1; + AddVss = 1; + + for ( VbhMap = VbhInstance->PORT_MAP; + VbhMap != (vbmap_list *)0; + VbhMap = VbhMap->NEXT ) + { + Name = getvexarrayname( VbhMap->FORMAL ); + + if ( Name == VasyPowerVdd ) AddVdd = 0; + else + if ( Name == VasyPowerVss ) AddVss = 0; + } + + if ( AddVdd ) + { + VexFormal = createvexatombit( VasyPowerVdd ); + VexActual = dupvexexpr( VexFormal ); + + VbhInstance->PORT_MAP = vbh_addvbmap( VbhInstance->PORT_MAP, VexFormal, VexActual, 0 ); + } + + if ( AddVss ) + { + VexFormal = createvexatombit( VasyPowerVss ); + VexActual = dupvexexpr( VexFormal ); + + VbhInstance->PORT_MAP = vbh_addvbmap( VbhInstance->PORT_MAP, VexFormal, VexActual, 0 ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyParseVbhPortAddPower | +| | +\------------------------------------------------------------*/ + +static vbpor_list *VasyParseVbhPortAddPower( VbhFigure, HeadPort, ModelName ) + + vbfig_list *VbhFigure; + vbpor_list *HeadPort; + char *ModelName; +{ + vbpor_list *VbhPort; + vbtyp_list *VbhType; + vexexpr *VexAtom; + char *Name; + int CreateVdd; + int CreateVss; + + CreateVdd = 1; + CreateVss = 1; + + VbhType = vbh_getvbtyp( VbhFigure, "bit" ); + + for ( VbhPort = HeadPort; + VbhPort != (vbpor_list *)0; + VbhPort = VbhPort->NEXT ) + { + Name = getvexarrayname( VbhPort->TARGET ); + + if ( Name == VasyPowerVdd ) + { + CreateVdd = 0; + VasyPrintf( stdout, "WARNING connector vdd already exists in model %s\n", ModelName ); + } + else + if ( Name == VasyPowerVss ) + { + CreateVss = 0; + + VasyPrintf( stdout, "WARNING connector vss already exists in model %s\n", ModelName ); + } + } + + if ( CreateVdd ) + { + VexAtom = createvexatombit( VasyPowerVdd ); + HeadPort = vbh_addvbpor( HeadPort, VexAtom, (vexexpr *)0, 'I', 0, VbhType, 0 ); + } + + if ( CreateVss ) + { + VexAtom = createvexatombit( VasyPowerVss ); + HeadPort = vbh_addvbpor( HeadPort, VexAtom, (vexexpr *)0, 'I', 0, VbhType, 0 ); + } + + return( HeadPort ); +} + +/*------------------------------------------------------------\ +| | +| VasyParseAddPower | +| | +\------------------------------------------------------------*/ + +static void VasyParseAddPower( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vbmod_list *VbhModel; + + if ( VasyPowerVdd == (char *)0 ) + { + VasyPowerVdd = namealloc( "vdd" ); + VasyPowerVss = namealloc( "vss" ); + } + + VbhFigure->BEPOR = VasyParseVbhPortAddPower( VbhFigure, VbhFigure->BEPOR, VbhFigure->NAME ); + + for ( VbhModel = VbhFigure->BEMOD; + VbhModel != (vbmod_list *)0; + VbhModel = VbhModel->NEXT ) + { + VbhModel->BEPOR = VasyParseVbhPortAddPower( VbhFigure, VbhModel->BEPOR, VbhModel->NAME ); + } + + VasyParseVbhInstanceAddPower( VbhFigure ); +} + +/*------------------------------------------------------------\ +| | +| VasyParseVbhFig | +| | +\------------------------------------------------------------*/ + +vbfig_list *VasyParseVbhFig( FileName, GenMap, Deep ) + + char *FileName; + vbmap_list *GenMap; + int Deep; +{ + authtable *HashModel; + authelem *Element; + vbfig_list *VbhFigure; + vbfig_list *VbhNewFigure; + vbmod_list **PrevModel; + vbmod_list *VbhModel; + vbgen_list *VbhGen; + vbmod_list *DelModel; + vbmod_list *VbhNewModel; + vbins_list *VbhInstance; + vbmap_list *VbhGenMap; + vbtyp_list *VbhType; + vbpor_list *VbhPort; + char *InstanceName; + char *ModelName; + char *NewModelName; + char *Name; + char *GenName; + int Generic; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyParseVbhFig %s\n", FileName ); + } + + if ( IsVasyDebugStatistics() ) + { + VasyDebugStartChrono(1); + } + + VbhFigure = getvbfiggenmap( FileName, VPN_IN, GenMap ); + + if ( VasyHashTreatedModel == (authtable *)0 ) + { + VasyHashTreatedModel = createauthtable( 100 ); + } + + HashModel = createauthtable( 100 ); + + for ( VbhModel = VbhFigure->BEMOD; + VbhModel != (vbmod_list *)0; + VbhModel = VbhModel->NEXT ) + { + addauthelem( HashModel, VbhModel->NAME, (long)VbhModel ); + } + + for ( VbhInstance = VbhFigure->BEINS; + VbhInstance != (vbins_list *)0; + VbhInstance = VbhInstance->NEXT ) + { + ModelName = VbhInstance->MODEL; + Element = searchauthelem( HashModel, ModelName ); + + if ( Element == (authelem *)0 ) + { + VasyPrintf( stdout, "ERROR unknown model %s for instance %s\n", + ModelName, VbhInstance->NAME ); + autexit( 1 ); + } + } + + for ( VbhInstance = VbhFigure->BEINS; + VbhInstance != (vbins_list *)0; + VbhInstance = VbhInstance->NEXT ) + { + Element = searchauthelem( HashModel, VbhInstance->MODEL ); + VbhModel = (vbmod_list *)Element->VALUE; + + if ( ( VbhInstance->GEN_MAP != (vbmap_list *)0 ) || + ( VbhModel->BEGEN != (vbgen_list *)0 ) ) Generic = 1; + else Generic = 0; + + if ( ( Generic ) || + ( ( VasyFlagHier ) && + ( ! incatalog( VbhInstance->MODEL ) ) ) ) + { + InstanceName = VbhInstance->NAME; + ModelName = VbhInstance->MODEL; + + if ( Generic ) + { + sprintf( VasyBuffer, "%s_%s", ModelName, InstanceName ); + NewModelName = namealloc( VasyBuffer ); + + VbhInstance->MODEL = NewModelName; + } + else + { + NewModelName = ModelName; + } + + Element = searchauthelem( VasyHashTreatedModel, NewModelName ); + + if ( ( Generic ) || + ( Element == (authelem *)0 ) ) + { + for ( VbhGen = VbhModel->BEGEN; + VbhGen != (vbgen_list *)0; + VbhGen = VbhGen->NEXT ) + { + if ( ( IsVexNodeAtom( VbhGen->TARGET ) ) && + ( VbhGen->VEX != (vexexpr *)0 ) ) + { + GenName = GetVexAtomValue( VbhGen->TARGET ); + + for ( VbhGenMap = VbhInstance->GEN_MAP; + VbhGenMap != (vbmap_list *)0; + VbhGenMap = VbhGenMap->NEXT ) + { + if ( IsVexNodeAtom( VbhGenMap->FORMAL ) ) + { + Name = GetVexAtomValue( VbhGenMap->FORMAL ); + + if ( Name == GenName ) break; + } + } + + if ( VbhGenMap == (vbmap_list *)0 ) + { + VbhInstance->GEN_MAP = vbh_addvbmap( VbhInstance->GEN_MAP, + dupvexexpr( VbhGen->TARGET ), dupvexexpr( VbhGen->VEX ), VbhGen->LINE ); + } + } + } + + VbhNewFigure = VasyMainTreatModel( ModelName, NewModelName, + VbhInstance->GEN_MAP, Deep + 1 ); + + addauthelem( VasyHashTreatedModel, NewModelName, (long)VbhNewFigure ); + + if ( Generic ) + { + VbhFigure->BEMOD = vbh_addvbmod( VbhFigure->BEMOD, NewModelName, 0 ); + VbhNewModel = VbhFigure->BEMOD; + + for ( VbhPort = VbhNewFigure->BEPOR; + VbhPort != (vbpor_list *)0; + VbhPort = VbhPort->NEXT ) + { + VbhType = vbh_getvbtyp( VbhFigure, VbhPort->TYPE->NAME ); + + VbhNewModel->BEPOR = vbh_addvbpor( VbhNewModel->BEPOR, + dupvexexpr( VbhPort->TARGET ), + dupvexexpr( VbhPort->VEX ), + VbhPort->DIR, VbhPort->KIND, VbhType, 0 ); + } + } + } + } + } + + resetauthtable( HashModel ); + + VasyGenerateVbhFig( VbhFigure ); + VasyGenericVbhFig( VbhFigure ); +/* +** Hash used model ! +*/ + for ( VbhInstance = VbhFigure->BEINS; + VbhInstance != (vbins_list *)0; + VbhInstance = VbhInstance->NEXT ) + { + ModelName = VbhInstance->MODEL; + addauthelem( HashModel, ModelName, 0 ); + } + + VbhModel = VbhFigure->BEMOD; + PrevModel = &VbhFigure->BEMOD; +/* +** Delete all unused model ! +*/ + while ( VbhModel != (vbmod_list *)0 ) + { + Element = searchauthelem( HashModel, VbhModel->NAME ); + + if ( Element == (authelem *)0 ) + { + *PrevModel = VbhModel->NEXT; + DelModel = VbhModel; + VbhModel = VbhModel->NEXT; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "Delete model %s\n", DelModel->NAME ); + } + + DelModel->NEXT = (vbmod_list *)0; + + vbh_frevbmod( DelModel ); + } + else + { + PrevModel = &VbhModel->NEXT; + VbhModel = VbhModel->NEXT; + } + } + + destroyauthtable( HashModel ); + + if ( VasyFlagPower ) + { + VasyParseAddPower( VbhFigure ); + } + + VasyUnrollLoopVbhFig( VbhFigure ); + VasyExpandArrayVbhFig( VbhFigure ); + + VasyParseVerifyVbhFig( VbhFigure ); + + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Compilation : %ld sec\n", VasyDebugReadChrono(1) ); + VasyDebugStartChrono(1); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyParseVbhFig %s\n\n", FileName ); + } + + return( VbhFigure ); +} + +/*------------------------------------------------------------\ +| | +| VasyParseVbh2VpnFig | +| | +\------------------------------------------------------------*/ + +vpnfig_list *VasyParseVbh2VpnFig( VbhFigure ) + + vbfig_list *VbhFigure; +{ + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vpntrans_list *AsgTrans; + vpnplace_list *VpnPlace; + vpnplace_list *AsgPlace; + vpnarc *VpnArc; + vpnact_list *VpnAction; + vpndecl_list *VpnDeclar; + vexexpr *VexAtom; + vexexpr *VexExpr; + char *Value; + long NumberBus; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyParseVbh2VpnFig %s\n", VbhFigure->NAME ); + } + + if ( IsVasyDebugStatistics() ) + { + VasyDebugStartChrono(1); + } + + VpnFigure = addvpnfig( VbhFigure->NAME ); + + VvhVbh2Vpn( VbhFigure, VpnFigure, 1 ); + + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Translation : %ld sec\n", VasyDebugReadChrono(1) ); + } + + if ( VpnFigure->FUNCTION != (vpnfunc_list *)0 ) + { + VasyErrorLine( VASY_NOT_YET_IMPLEMENTED_ERROR, VpnFigure->FUNCTION->LINE, "Function" ); + } + + NumberBus = 0; +/* +** Modify all guarded bus process +*/ + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + if ( IsVpnProcGuarded( VpnProc ) ) + { +/* +** Check if it's guarded bus assignment +*/ + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + VexAtom = VpnAction->VEX_ATOM; + + if ( VexAtom != (vexexpr *)0 ) + { + Value = getvexatomname( VexAtom ); + VpnDeclar = searchvpndeclall( VpnFigure, Value ); + + if ( VpnDeclar->KIND == VPN_KIND_BUS ) break; + } + } + + if ( VpnAction != (vpnact_list *)0 ) break; + } + + if ( VpnAction == (vpnact_list *)0 ) continue; +/* +** Add a new assignment : VexAtom <= (others => 'Z'); +*/ + VpnTrans = VpnProc->FIRST; + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + delvpnarc( VpnFigure, VpnArc ); + + sprintf( VasyBuffer, "asg_bus_%ld", NumberBus++ ); + AsgPlace = addvpnprocplace( VpnFigure, VpnProc, VasyBuffer ); + AsgPlace->TYPE = VPN_PLACE_ASSIGN; + AsgTrans = addvpnproctrans( VpnFigure, VpnProc, VasyBuffer ); + AsgTrans->TYPE = VPN_TRANS_ACT_EXEC; + + VexAtom = dupvexexpr( VexAtom ); + VexExpr = createvexatomveclit( VEX_TRISTATE, VexAtom->WIDTH ); + VpnAction = addvpnactasg( VpnFigure, AsgTrans, VexAtom, VexExpr ); + + addvpnarctrans( VpnFigure, VpnTrans, AsgPlace ); + addvpnarcplace( VpnFigure, AsgPlace, AsgTrans ); + addvpnarctrans( VpnFigure, AsgTrans, VpnPlace ); + } + } + + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "+++ VasyAddProcInfo %s\n", VpnProc->NAME ); + } + + VasyAddVpnProcInfo( VpnProc ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyParseVbh2VpnFig %s\n\n", VbhFigure->NAME ); + } + + return( VpnFigure ); +} + +/*------------------------------------------------------------\ +| | +| VasyParsePackage | +| | +\------------------------------------------------------------*/ + +void VasyParsePackage( FileName ) + + char *FileName; +{ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyParsePackage %s\n\n", FileName ); + } + + if ( FileName == (char *)0 ) return; + + getvbpkg( FileName, VPN_IN ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyParsePackage %s\n\n", FileName ); + } +} diff --git a/alliance/src/vasy/src/vasy_parse.h b/alliance/src/vasy/src/vasy_parse.h new file mode 100644 index 00000000..f6f683d8 --- /dev/null +++ b/alliance/src/vasy/src/vasy_parse.h @@ -0,0 +1,76 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_parse.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_PARSE_H +# define VASY_PARSE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyParsePackage(); + extern vbfig_list *VasyParseVbhFig(); + extern vpnfig_list *VasyParseVbh2VpnFig(); + + extern vpnfig_list *VvhVbh2Vpn(); + +# endif diff --git a/alliance/src/vasy/src/vasy_preanal.c b/alliance/src/vasy/src/vasy_preanal.c new file mode 100644 index 00000000..b4d4f1b0 --- /dev/null +++ b/alliance/src/vasy/src/vasy_preanal.c @@ -0,0 +1,281 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_preanal.c | +| | +| Authors : Jacomme Ludovic | +| Seb Leon | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vbh.h" +# include "vbl.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_shared.h" +# include "vasy_preanal.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashName = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyPreAnalysisVexExpr | +| | +\------------------------------------------------------------*/ + +static int VasyPreAnalysisVexExpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + authelem *Element; + char *Name; + int FuncId; + int Index; + char Literal; + + if ( IsVexNodeAtom( Expr ) ) + { + Name = GetVexAtomValue( Expr ); + + if ( ! IsVexAtomLiteral( Expr ) ) + { + Element = searchauthelem( VasyHashName, Name ); + + if ( Element != (authelem *)0 ) return( 1 ); + } + else + { + for ( Index = 0; Index < Expr->WIDTH; Index++ ) + { + Literal = Name[ Index + 1 ]; + + if ( ( Literal == VEX_TRISTATE ) || + ( Literal == VEX_WEAK_ZERO ) || + ( Literal == VEX_WEAK_ONE ) ) return( 1 ); + } + } + } + else + { + if ( IsVexNodeFunc( Expr ) ) + { + Name = GetVexFuncValue( Expr ); + FuncId = getvexstdfuncid( Name ); + + if ( FuncId == -1 ) return( 1 ); + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + if ( VasyPreAnalysisVexExpr( GetVexOperand( ScanOper ) ) ) + { + return( 1 ); + } + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyPreAnalysisVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyPreAnalysisVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpnact_list *VpnAct; + vexexpr *VexAtom; + char *Name; + int ToAnalyse; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyPreAnalysisVpnProc %s\n", VpnProc->NAME ); + } + + if ( ( IsVpnProcSequential( VpnProc ) ) || + ( IsVpnProcGuarded( VpnProc ) ) ) + { + SetVasyVpnProcToAnalyse( VpnProc ); + } + else + { + if ( VasyHashName == (authtable *)0 ) + { + VasyHashName = createauthtable( 50 ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + if ( ( VpnAct->TYPE == VPN_ACT_ASG_PORT ) || + ( VpnAct->TYPE == VPN_ACT_ASG_SIGNAL ) ) + { + VexAtom = VpnAct->VEX_ATOM; + Name = GetVexAtomValue( VexAtom ); + addauthelem( VasyHashName, Name, 0 ); + } + } + } + + ToAnalyse = 0; + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) || + ( VpnTrans->TYPE == VPN_TRANS_SUP_WAIT ) ) continue; + + if ( ( VpnTrans->VEX_GUARD != (vexexpr *)0 ) && + ( VasyPreAnalysisVexExpr( VpnTrans->VEX_GUARD ) ) ) + { + ToAnalyse = 1; + } + else + { + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + if ( VasyPreAnalysisVexExpr( VpnAct->VEX_EXPR ) ) + { + ToAnalyse = 1; break; + } + } + } + + if ( ToAnalyse ) + { + SetVasyVpnProcToAnalyse( VpnProc ); break; + } + } + + resetauthtable( VasyHashName ); + } + + if ( IsVasyDebugLevel0() ) + { + if ( IsVasyVpnProcToAnalyse( VpnProc ) ) + { + VasyPrintf( stdout, " +++ Should Analyse Process %s\n", VpnProc->NAME ); + } + + VasyPrintf( stdout, " <-- VasyPreAnalysisVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyPreAnalysisVpnFig | +| | +\------------------------------------------------------------*/ + +void VasyPreAnalysisVpnFig( VpnFigure ) + + vpnfig_list *VpnFigure; +{ + vpnproc_list *VpnProc; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyPreAnalysisVpnFig %s\n", VpnFigure->NAME ); + } + + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + VasyPreAnalysisVpnProc( VpnFigure, VpnProc ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasyPreAnalysisVpnFig %s\n\n", VpnFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_preanal.h b/alliance/src/vasy/src/vasy_preanal.h new file mode 100644 index 00000000..e73b7e21 --- /dev/null +++ b/alliance/src/vasy/src/vasy_preanal.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_preanal.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + + +# ifndef VASY_PREANAL_H +# define VASY_PREANAL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyPreAnalysisVpnFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_redact.c b/alliance/src/vasy/src/vasy_redact.c new file mode 100644 index 00000000..cab52e23 --- /dev/null +++ b/alliance/src/vasy/src/vasy_redact.c @@ -0,0 +1,837 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_redact.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_redact.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + static vpnproc_list *VasyProcess = (vpnproc_list *)0; + + static authtable *VasyHashAssign = (authtable *)0; + static authtable *VasyHashBitVecAsg = (authtable *)0; + + static authtable *VasyHashVariable = (authtable *)0; + static authtable *VasyHashBitVecVar = (authtable *)0; + + static authtable *VasyHashDriver = (authtable *)0; + static authtable *VasyHashBitVecDrv = (authtable *)0; + + static vpntrans_list *VasySubstTrans = (vpntrans_list *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyRedActAddVpnDefine | +| | +\------------------------------------------------------------*/ + +vpndecl_list *VasyRedActAddVpnDefine( VpnFigure, VpnProc, Width, DefBase ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + unsigned short Width; + unsigned char DefBase; +{ + vpndecl_list *DefDeclar; + vexexpr *DefAtom; + char *FatherName; + char Buffer[ 128 ]; + unsigned char NewBase; + long Number; + + FatherName = VpnProc->NAME; + Number = GetVpnNumDeclDef( VpnFigure ); + + sprintf( Buffer, "%s_reddef_%ld", FatherName, Number ); + + if ( ( DefBase == VEX_TYPE_REG_BIT ) || + ( DefBase == VEX_TYPE_MUX_BIT ) || + ( DefBase == VEX_TYPE_WOR_BIT ) ) + { + DefBase = VEX_TYPE_BIT; + } + else + if ( ( DefBase == VEX_TYPE_REG_VECTOR ) || + ( DefBase == VEX_TYPE_MUX_VECTOR ) || + ( DefBase == VEX_TYPE_WOR_VECTOR ) ) + { + DefBase = VEX_TYPE_BIT_VECTOR; + } + + NewBase = getvextypescalar( DefBase ); + + if ( ( isvextypevector( DefBase ) ) && + ( ( Width > 1 ) || + ( NewBase == DefBase ) ) ) + { + DefAtom = createvexatomvec( Buffer, Width - 1, 0 ); + } + else + { + DefAtom = createvexatombit( Buffer ); + DefBase = NewBase; + } + + DefDeclar = addvpndeclprocdef( VpnFigure, VpnProc, DefAtom, DefBase ); + + return( DefDeclar ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedActSubstVexAtom | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyRedActSubstVexAtom( Expr, SubstDriver ) + + vexexpr *Expr; + short SubstDriver; +{ + authtable *HashBitVec; + char *AtomValue; + char *DefName; + authelem *Element; + vexexpr *SubstExpr; + vexexpr *DefAtom; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + vpnact_list *ScanAsg; + vpnact_list *NewAct; + vpndecl_list *ScanDeclar; + vpndecl_list *DefDeclar; + vpnsym *ScanSym; + int DefIndex; + int DefPos; + int Scan; + int Index; + int Width; + int Step; + + SubstExpr = (vexexpr *)0; + AtomValue = GetVexAtomValue( Expr ); + + if ( SubstDriver ) + { + Element = searchauthelem( VasyHashDriver, AtomValue ); + HashBitVec = VasyHashBitVecDrv; + } + else + { + Element = searchauthelem( VasyHashVariable, AtomValue ); + HashBitVec = VasyHashBitVecVar; + } + + ScanDeclar = searchvpndeclall( VasyFigure, AtomValue ); +/* +** Check if symbol should be substituted +*/ + if ( Element != (authelem *)0 ) + { + if ( ! isvextypedivisible( ScanDeclar->BASE ) ) + { +/* +** Symbol is not a bit_vector, just replace vex +*/ + ScanAsg = (vpnact_list *)Element->VALUE; + + freevexexpr( Expr ); + Expr = dupvexexpr( ScanAsg->VEX_EXPR ); + } + else + { +/* +** Symbol is a bit_vector, make a concatenation +*/ + if ( Expr->LEFT > Expr->RIGHT ) Step = -1; + else Step = 1; + + Index = Expr->LEFT; + Width = Expr->WIDTH; + + if ( Width > 1 ) SubstExpr = createvexoper( VEX_CONCAT, Width ); + + for ( Scan = 0; Scan < Width; Scan++ ) + { + ScanSym = getvpnsymdecl( ScanDeclar, Index ); + Element = searchauthelem( HashBitVec, (char *)ScanSym ); + + if ( Element != (authelem *)0 ) + { + ScanAsg = (vpnact_list *)Element->VALUE; + AsgExpr = ScanAsg->VEX_EXPR; + AsgAtom = ScanAsg->VEX_ATOM; + + if ( ( ! IsVexNodeAtom( AsgExpr ) ) || + ( IsVexAtomLiteral( AsgExpr ) ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Substitute assign is not atomic, create define !\n" ); + } + + DefDeclar = VasyRedActAddVpnDefine( VasyFigure, VasyProcess, + AsgAtom->WIDTH, ScanDeclar->BASE ); + + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + ScanAsg->VEX_EXPR = dupvexnode( DefAtom ); + + NewAct = addvpnactasgbefore( VasyFigure, VasySubstTrans, ScanAsg, DefAtom, AsgExpr ); + unionvpnline( VasyFigure, &NewAct->LINE, ScanAsg->LINE ); + + AsgExpr = ScanAsg->VEX_EXPR; + } + + DefName = GetVexAtomValue( AsgExpr ); + DefPos = getvexvectorpos( AsgAtom, Index ); + DefIndex = getvexvectorindex( AsgExpr, DefPos ); + + DefAtom = createvexatomvec( DefName, DefIndex, DefIndex ); + } + else + { + DefAtom = createvexatomvec( AtomValue, Index, Index ); + } + + if ( Width == 1 ) SubstExpr = DefAtom; + else addvexqexpr( SubstExpr, DefAtom ); + + Index += Step; + } + + freevexexpr( Expr ); + Expr = simpvexexpr( SubstExpr ); + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedActSubstVexAtom\n" ); + VasyPrintf( stdout, " +++ Replace %s by ", AtomValue ); + viewvexexprboundln( Expr ); + VasyPrintf( stdout, " <-- VasyRedActSubstVexAtom\n" ); + } + } + else + { + Expr = (vexexpr *)0; + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedActSubstVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyRedActSubstVex( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + vexexpr *SubstExpr; + long Oper; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( ! IsVexAtomLiteral( Expr ) ) + { + SubstExpr = VasyRedActSubstVexAtom( Expr, 0 ); + + if ( SubstExpr != (vexexpr *)0 ) Expr = SubstExpr; + } + + return( Expr ); + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_DRIVER ) + { + SubstExpr = GetVexOperand( Expr->OPERAND ); + SubstExpr = VasyRedActSubstVexAtom( SubstExpr, 1 ); + + if ( SubstExpr != (vexexpr *)0 ) + { + Expr->OPERAND->DATA = (void *)0; + freevexexpr( Expr ); + + Expr = SubstExpr; + } + + return( Expr ); + } + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + SubstExpr = VasyRedActSubstVex( GetVexOperand( ScanOper ) ); + SetVexOperand( ScanOper, SubstExpr ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedActSubstVpnAct | +| | +\------------------------------------------------------------*/ + +static void VasyRedActSubstVpnAct( VpnFigure, VpnProc, VpnTrans, VpnAct ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vpnact_list *VpnAct; +{ + VasyFigure = VpnFigure; + VasyProcess = VpnProc; + VasySubstTrans = VpnTrans; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedActSubstVpnAct\n" ); + VasyPrintf( stdout, " +++ " ); + viewvexexprboundln( VpnAct->VEX_EXPR ); + } + + VpnAct->VEX_EXPR = VasyRedActSubstVex( VpnAct->VEX_EXPR ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ " ); + viewvexexprboundln( VpnAct->VEX_EXPR ); + VasyPrintf( stdout, " <-- VasyRedActSubstVpnAct\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedActVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasyRedActVpnTrans( VpnFigure, VpnProc, VpnTrans, SubstDriver ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + short SubstDriver; +{ + vpnact_list *VpnAct; + vpnact_list *DelAct; + vpnact_list *NewAct; + unsigned char AsgVar; + unsigned char AsgDriver; + vpndecl_list *AsgDeclar; + vpnsym *AsgSymbol; + vpnsym *DelSymbol; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + vpndecl_list *DefDeclar; + vexexpr *DefAtom; + vexexpr *DelAtom; + vexexpr *DelExpr; + vexexpr *DelAtom2; + vexexpr *DelExpr2; + authelem *Element; + char *AtomValue; + int AsgIndex; + int AsgMin; + int AsgMax; + int DelMin; + int DelMax; + int DelPos; + int DelIndex; +/* +** Reduction for all assign's action in a transition +*/ + if ( VpnTrans->ACT == (vpnact_list *)0 ) return; + + if ( VasyHashAssign == (authtable *)0 ) + { + VasyHashAssign = createauthtable( 100 ); + VasyHashBitVecAsg = createauthtable( 100 ); + + VasyHashVariable = createauthtable( 100 ); + VasyHashBitVecVar = createauthtable( 100 ); + + VasyHashDriver = createauthtable( 100 ); + VasyHashBitVecDrv = createauthtable( 100 ); + } + + VpnAct = VpnTrans->ACT; + + while ( VpnAct != (vpnact_list *)0 ) + { + VasyRedActSubstVpnAct( VpnFigure, VpnProc, VpnTrans, VpnAct ); +/* +** Assign statement +*/ + if ( VpnAct->TYPE == VPN_ACT_ASG_VARIABLE ) + { + AsgVar = 1; + AsgDriver = 0; + } + else + { + AsgVar = 0; + + if ( ( SubstDriver ) && + ( ( VpnAct->TYPE == VPN_ACT_ASG_PORT ) || + ( VpnAct->TYPE == VPN_ACT_ASG_SIGNAL ) ) ) AsgDriver = 1; + else AsgDriver = 0; + } + + AsgAtom = VpnAct->VEX_ATOM; + AsgExpr = VpnAct->VEX_EXPR; + + if ( ! IsVexNodeAtom( AsgAtom ) ) + { + VasyErrorLine( VASY_ILLEGAL_ASSIGN_ERROR, VpnAct->LINE, getvexatomname( AsgAtom ) ); + } + + AtomValue = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomValue ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); +/* +** Delete action if S <= S --> there is nothing more to do ! +*/ + if ( isvexequalexpr( AsgAtom, AsgExpr ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ %s <= %s just delete and continue !\n", AtomValue, AtomValue ); + } + + DelAct = VpnAct; + VpnAct = VpnAct->NEXT; + + delvpnact( VpnFigure, VpnTrans, DelAct ); + + continue; + } +/* +** Variable Assign statement +*/ + if ( ( AsgVar ) && ( ! SubstDriver ) ) + { +/* +** Modify assign V := f --> Define #= f, V := Define +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ First Variable assignment %s := define !\n", AtomValue ); + } + + DefDeclar = VasyRedActAddVpnDefine( VpnFigure, VpnProc, + AsgAtom->WIDTH, AsgDeclar->BASE ); + + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + VpnAct->VEX_EXPR = dupvexnode( DefAtom ); + + NewAct = addvpnactasgbefore( VpnFigure, VpnTrans, VpnAct, DefAtom, AsgExpr ); + unionvpnline( VpnFigure, &NewAct->LINE, VpnAct->LINE ); + } +/* +** Variable or Signal Assign statement +*/ + Element = searchauthelem( VasyHashAssign, AtomValue ); + + if ( Element != (authelem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ previous assignment to %s !\n", AtomValue ); + } + + if ( ! isvextypedivisible( AsgDeclar->BASE ) ) + { +/* +** Delete previous assign to symbol V +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ just delete previous assignment to %s !\n", AtomValue ); + } + + DelAct = (vpnact_list *)Element->VALUE; + delvpnact( VpnFigure, VpnTrans, DelAct ); + } + else + { +/* +** Delete previous assign to bit_vector symbol V +*/ + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + Element = searchauthelem( VasyHashBitVecAsg, (char *)AsgSymbol ); +/* +** Check if there is a previous assign to symbol V +*/ + if ( Element != (authelem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Previous bit_vector assign to %s %d\n", + AsgSymbol->NAME, AsgIndex ); + } + + DelAct = (vpnact_list *)Element->VALUE; + DelAtom = DelAct->VEX_ATOM; + + DelMin = getvexvectormin( DelAtom ); + DelMax = getvexvectormax( DelAtom ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Check instersection [%d %d] -> [%d %d]\n", + AsgMin, AsgMax, DelMin, DelMax ); + } +/* +** Check the kind of range's intersection +*/ + if ( ( DelMin >= AsgMin ) && + ( DelMax <= AsgMax ) ) + { +/* +** [ ] Asg Completely included +** [<-[ ]->] Del +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Intersection completely included just delete\n" ); + } + + AsgIndex = DelMax; + delvpnact( VpnFigure, VpnTrans, DelAct ); + } + else + { + DelAtom = DelAct->VEX_ATOM; + DelExpr = DelAct->VEX_EXPR; +/* +** Previous assign to symbol V must be an atomic expression ! +*/ + if ( ( ! IsVexNodeAtom( DelExpr ) ) || + ( IsVexAtomLiteral( DelExpr ) ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Previous assign is not atomic, create define !\n" ); + } + + DefDeclar = VasyRedActAddVpnDefine( VpnFigure, VpnProc, + DelAtom->WIDTH, AsgDeclar->BASE ); + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + DelAct->VEX_EXPR = dupvexnode( DefAtom ); + + NewAct = addvpnactasgbefore( VpnFigure, VpnTrans, DelAct, DefAtom, DelExpr ); + unionvpnline( VpnFigure, &NewAct->LINE, DelAct->LINE ); + + DelExpr = DelAct->VEX_EXPR; + } + + if ( ( DelMin < AsgMin ) && + ( DelMax <= AsgMax ) ) + { +/* +** [ ] Asg Partialy included on left +** [<-[]------->] Del +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Intersection partialy on left\n" ); + } + + if ( IsVexAtomDown( DelAtom ) ) + { + DelPos = getvexvectorpos( DelAtom, AsgMin - 1 ); + DelIndex = getvexvectorindex( DelExpr, DelPos ); + + slicevexatomvec( DelExpr, DelIndex , DelExpr->RIGHT ); + slicevexatomvec( DelAtom, AsgMin - 1, DelAtom->RIGHT ); + } + else + { + DelPos = getvexvectorpos( DelAtom, AsgMin - 1 ); + DelIndex = getvexvectorindex( DelExpr, DelPos ); + + slicevexatomvec( DelExpr, DelExpr->LEFT, DelIndex ); + slicevexatomvec( DelAtom, DelAtom->LEFT, AsgMin - 1 ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ New previous assign \n" ); + viewvexexprbound( DelAtom ); + fprintf( stdout, " <= " ); + viewvexexprboundln( DelExpr ); + } + } + else + if ( ( DelMax > AsgMax ) && + ( DelMin >= AsgMin ) ) + { +/* +** [ ] Asg Partialy included on right +** [<-------[]->] Del +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Intersection partialy on right\n" ); + } + + if ( IsVexAtomDown( DelAtom ) ) + { + DelPos = getvexvectorpos( DelAtom, AsgMax + 1 ); + DelIndex = getvexvectorindex( DelExpr, DelPos ); + + slicevexatomvec( DelExpr, DelExpr->LEFT, DelIndex ); + slicevexatomvec( DelAtom, DelAtom->LEFT, AsgMax + 1 ); + } + else + { + DelPos = getvexvectorpos( DelAtom, AsgMax + 1 ); + DelIndex = getvexvectorindex( DelExpr, DelPos ); + + slicevexatomvec( DelExpr, DelIndex , DelExpr->RIGHT ); + slicevexatomvec( DelAtom, AsgMax + 1, DelAtom->RIGHT ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ New previous assign \n" ); + viewvexexprbound( DelAtom ); + fprintf( stdout, " <= " ); + viewvexexprboundln( DelExpr ); + } + } + else + { +/* +** [ ] Asg Partialy included on the two sides +** [<-[]----[]->] Del +*/ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Intersection partialy on two sides\n" ); + } + + DelAtom2 = dupvexnode( DelAtom ); + DelExpr2 = dupvexnode( DelExpr ); + + if ( IsVexAtomDown( DelAtom ) ) + { + DelPos = getvexvectorpos( DelAtom, AsgMin - 1 ); + DelIndex = getvexvectorindex( DelExpr, DelPos ); + + slicevexatomvec( DelExpr, DelIndex , DelExpr->RIGHT ); + slicevexatomvec( DelAtom, AsgMin - 1, DelAtom->RIGHT ); + } + else + { + DelPos = getvexvectorpos( DelAtom, AsgMin - 1 ); + DelIndex = getvexvectorindex( DelExpr, DelPos ); + + slicevexatomvec( DelExpr, DelExpr->LEFT, DelIndex ); + slicevexatomvec( DelAtom, DelAtom->LEFT, AsgMin - 1 ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ New previous assign \n" ); + viewvexexprbound( DelAtom ); + fprintf( stdout, " <= " ); + viewvexexprboundln( DelExpr ); + } + + if ( IsVexAtomDown( DelAtom ) ) + { + DelPos = getvexvectorpos( DelAtom2, AsgMax + 1 ); + DelIndex = getvexvectorindex( DelExpr2, DelPos ); + + slicevexatomvec( DelExpr2, DelExpr2->LEFT, DelIndex ); + slicevexatomvec( DelAtom2, DelAtom2->LEFT, AsgMax + 1 ); + } + else + { + DelPos = getvexvectorpos( DelAtom2, AsgMax + 1 ); + DelIndex = getvexvectorindex( DelExpr2, DelPos ); + + slicevexatomvec( DelExpr2, DelIndex , DelExpr2->RIGHT ); + slicevexatomvec( DelAtom2, AsgMax + 1, DelAtom2->RIGHT ); + } + + NewAct = addvpnactasgbefore( VpnFigure, VpnTrans, + DelAct, DelAtom2, DelExpr2 ); + unionvpnline( VpnFigure, &NewAct->LINE, DelAct->LINE ); + DelAct = NewAct; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ New added previous assign \n" ); + viewvexexprbound( DelAtom2 ); + fprintf( stdout, " <= " ); + viewvexexprboundln( DelExpr2 ); + } + + DelMin = getvexvectormin( DelAtom2 ); + DelMax = getvexvectormax( DelAtom2 ); +/* +** Add modified assign to bit_vector symbol V in hash table +*/ + for ( DelIndex = DelMin; DelIndex <= DelMax; DelIndex++ ) + { + DelSymbol = getvpnsymdecl( AsgDeclar, DelIndex ); + addauthelem( VasyHashBitVecAsg, (char *)DelSymbol, (long)DelAct ); + + if ( AsgVar ) + { + addauthelem( VasyHashBitVecVar, (char *)DelSymbol, (long)DelAct ); + } + else + if ( AsgDriver ) + { + addauthelem( VasyHashBitVecDrv, (char *)DelSymbol, (long)DelAct ); + } + } + } + + AsgIndex = AsgMax; + } + } + } + } + } +/* +** Add assign to bit_vector symbol V in hash table +*/ + if ( isvextypedivisible( AsgDeclar->BASE ) ) + { + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + addauthelem( VasyHashBitVecAsg, (char *)AsgSymbol, (long)VpnAct ); + + if ( AsgVar ) + { + addauthelem( VasyHashBitVecVar, (char *)AsgSymbol, (long)VpnAct ); + } + else + if ( AsgDriver ) + { + addauthelem( VasyHashBitVecDrv, (char *)AsgSymbol, (long)VpnAct ); + } + } + } +/* +** Add assign to symbol V in hash table +*/ + addauthelem( VasyHashAssign, AtomValue, (long)VpnAct ); +/* +** Add assign to variable V in hash table +*/ + if ( AsgVar ) + { + addauthelem( VasyHashVariable, AtomValue, (long)VpnAct ); + } + else + if ( AsgDriver ) + { + addauthelem( VasyHashDriver, AtomValue, (long)VpnAct ); + } + + VpnAct = VpnAct->NEXT; + } + + resetauthtable( VasyHashAssign ); + resetauthtable( VasyHashBitVecAsg ); + + resetauthtable( VasyHashVariable ); + resetauthtable( VasyHashBitVecVar ); + + resetauthtable( VasyHashDriver ); + resetauthtable( VasyHashBitVecDrv ); +} diff --git a/alliance/src/vasy/src/vasy_redact.h b/alliance/src/vasy/src/vasy_redact.h new file mode 100644 index 00000000..9e26564f --- /dev/null +++ b/alliance/src/vasy/src/vasy_redact.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_redact.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_REDACT_H +# define VASY_REDACT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern vpndecl_list *VasyRedActAddVpnDefine(); + extern void VasyRedActVpnTrans(); + +# endif diff --git a/alliance/src/vasy/src/vasy_redinst.c b/alliance/src/vasy/src/vasy_redinst.c new file mode 100644 index 00000000..b005d62b --- /dev/null +++ b/alliance/src/vasy/src/vasy_redinst.c @@ -0,0 +1,1955 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_redinst.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_redact.h" +# include "vasy_redinst.h" +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + static vpnproc_list *VasyProcess = (vpnproc_list *)0; + static vpntrans_list *VasyPrevTrans = (vpntrans_list *)0; + + static auth2table *VasyHash2Assign = (auth2table *)0; + static auth2table *VasyHash2BitVecAsg = (auth2table *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstVpnPlace(); + +static void VasyRedInstViewAuth2Elem( Element ) + + auth2elem *Element; +{ + vpntrans_list *VpnTrans; + vpnsym *VpnSymbol; + vpnact_list *VpnAct; + + VpnTrans = (vpntrans_list *)Element->KEY1; + VpnSymbol = (vpnsym *)Element->KEY2; + VpnAct = (vpnact_list *)Element->VALUE; + + VasyPrintf( stdout, "%s, %s %d, ", + VpnTrans->NAME, VpnSymbol->NAME, VpnSymbol->INDEX ); + viewvexexprbound( VpnAct->VEX_ATOM ); + fprintf( stdout, " <= " ); + viewvexexprboundln( VpnAct->VEX_EXPR ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstHashVpnAct | +| | +\------------------------------------------------------------*/ + +static int VasyRedInstHashVpnAct( VpnTrans, VpnAct ) + + vpntrans_list *VpnTrans; + vpnact_list *VpnAct; +{ + vpnact_list *NewAct; + vpndecl_list *AsgDeclar; + vpndecl_list *DefDeclar; + vexexpr *AsgAtom; + vexexpr *DefAtom; + vexexpr *AsgExpr; + vpnsym *AsgSymbol; + char *AtomValue; + int AsgMin; + int AsgMax; + int AsgIndex; + + AsgAtom = VpnAct->VEX_ATOM; + AsgExpr = VpnAct->VEX_EXPR; + + if ( ! IsVexNodeAtom( AsgAtom ) ) + { + VasyErrorLine( VASY_ILLEGAL_ASSIGN_ERROR, VpnAct->LINE, getvexatomname( AsgAtom ) ); + } + + AtomValue = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VasyFigure, AtomValue ); + + if ( ! IsVexNodeAtom( AsgExpr ) ) + { + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Hash assign is not atomic, create define !\n" ); + } + + DefDeclar = VasyRedActAddVpnDefine( VasyFigure, VasyProcess, + AsgAtom->WIDTH, AsgDeclar->BASE ); + + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + VpnAct->VEX_EXPR = dupvexnode( DefAtom ); + + NewAct = addvpnactasgbefore( VasyFigure, VpnTrans, VpnAct, DefAtom, AsgExpr ); + unionvpnline( VasyFigure, &NewAct->LINE, VpnAct->LINE ); + + AsgExpr = VpnAct->VEX_EXPR; + } + + addauth2elem( VasyHash2Assign, (char*)VpnTrans, (char*)AtomValue, (long)VpnAct ); + + if ( isvextypedivisible( AsgDeclar->BASE ) ) + { + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + addauth2elem( VasyHash2BitVecAsg, (char*)VpnTrans, (char*)AsgSymbol, (long)VpnAct ); + } + + return( 1 ); + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstVertical | +| | +\------------------------------------------------------------*/ + +static vpntrans_list *VasyRedInstVertical( BeginPlace, EndTrans ) + + vpnplace_list *BeginPlace; + vpntrans_list *EndTrans; +{ + vpntrans_list *VpnTrans; + vpnplace_list *VpnPlace; + vpnplace_list *EndPlace; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstVertical %s %s\n", + BeginPlace->NAME, EndTrans->NAME ); + } + + if ( ( EndTrans->TYPE != VPN_TRANS_ACT_GUARDED ) && + ( EndTrans->TYPE != VPN_TRANS_ACT_EXEC ) && + ( EndTrans->TYPE != VPN_TRANS_IMMEDIATE ) ) + { + return( EndTrans ); + } + + while ( EndTrans->NUMBER_IN == 1 ) + { + VpnArc = GetVpnArc( EndTrans->PLACE_OUT ); + EndPlace = GetVpnArcTargetPlace( VpnArc ); + + VpnArc = GetVpnArc( EndTrans->PLACE_IN ); + VpnPlace = GetVpnArcSourcePlace( VpnArc ); + + if ( ( VpnPlace == BeginPlace ) || + ( VpnPlace->NUMBER_IN != 1 ) || + ( VpnPlace->NUMBER_OUT != 1 ) ) + { + break; + } + + VpnArc = GetVpnArc( VpnPlace->TRANS_IN ); + VpnTrans = GetVpnArcSourceTrans( VpnArc ); + + if ( EndTrans->TYPE != VPN_TRANS_IMMEDIATE ) + { + if ( ( VpnTrans->TYPE != VPN_TRANS_GUARDED ) && + ( VpnTrans->TYPE != VPN_TRANS_ACT_GUARDED ) && + ( VpnTrans->TYPE != VPN_TRANS_ACT_EXEC ) && + ( VpnTrans->TYPE != VPN_TRANS_IMMEDIATE ) ) + { + break; + } + + if ( VpnTrans->TYPE == VPN_TRANS_IMMEDIATE ) + { + VpnTrans->TYPE = EndTrans->TYPE; + + if ( EndTrans->ACT != (vpnact_list *)0 ) + { + VpnTrans->ACT = EndTrans->ACT; + VpnTrans->LAST_ACT = EndTrans->LAST_ACT; + } + + VpnTrans->VEX_GUARD = EndTrans->VEX_GUARD; + + EndTrans->ACT = (vpnact_list *)0; + EndTrans->LAST_ACT = &EndTrans->ACT; + EndTrans->VEX_GUARD = (vexexpr *)0; + } + else + { + if ( ( VpnTrans->TYPE == VPN_TRANS_GUARDED ) && + ( EndTrans->TYPE == VPN_TRANS_ACT_GUARDED ) ) + { + VpnTrans->TYPE = VPN_TRANS_ACT_GUARDED; + + if ( EndTrans->ACT != (vpnact_list *)0 ) + { + VpnTrans->ACT = EndTrans->ACT; + VpnTrans->LAST_ACT = EndTrans->LAST_ACT; + } + + VpnTrans->VEX_GUARD = optimvexbinexpr( VEX_AND, 1, + EndTrans->VEX_GUARD, + VpnTrans->VEX_GUARD ); + + EndTrans->ACT = (vpnact_list *)0; + EndTrans->LAST_ACT = &EndTrans->ACT; + EndTrans->VEX_GUARD = (vexexpr *)0; + } + else + { + if ( EndTrans->ACT != (vpnact_list *)0 ) + { + *VpnTrans->LAST_ACT = EndTrans->ACT; + EndTrans->ACT->PREV = VpnTrans->LAST_ACT; + VpnTrans->LAST_ACT = EndTrans->LAST_ACT; + EndTrans->ACT = (vpnact_list *)0; + EndTrans->LAST_ACT = &EndTrans->ACT; + + VasyRedActVpnTrans( VasyFigure, VasyProcess, VpnTrans, 1 ); + } + + if ( VpnTrans->TYPE == VPN_TRANS_GUARDED ) + { + VpnTrans->TYPE = VPN_TRANS_ACT_GUARDED; + } + } + } + } + + if ( ( EndTrans->TYPE == VPN_TRANS_ACT_GUARDED ) || + ( EndTrans->TYPE == VPN_TRANS_ACT_EXEC ) || + ( EndTrans->TYPE == VPN_TRANS_IMMEDIATE ) ) + { + delvpnplace( VasyFigure, VpnPlace ); + delvpntrans( VasyFigure, EndTrans ); + + addvpnarctrans( VasyFigure, VpnTrans, EndPlace ); + } + + EndTrans = VpnTrans; + } + + if ( IsVasyDebugLevel2() ) + { + VasyDebugSaveVpnFig( VasyFigure ); + + VasyPrintf( stdout, " <-- VasyRedInstVertical %s %s\n", + BeginPlace->NAME, EndTrans->NAME ); + } + + return( EndTrans ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstGuarded | +| | +\------------------------------------------------------------*/ + +static int VasyRedInstGuarded( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + chain_list *ScanTrans; + chain_list *ScanTrans2; + vpntrans_list *VpnTrans; + vpntrans_list *VpnTrans2; + vpnplace_list *VpnPlace; + vpnarc *VpnArc; + vexexpr *Guard; + int Reduce; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstGuarded %s\n", BeginPlace->NAME ); + } + + ScanTrans = BeginPlace->TRANS_OUT; + Reduce = 0; + + while ( ScanTrans != (chain_list *)0 ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + ScanTrans = ScanTrans->NEXT; + + if ( VpnTrans->TYPE == VPN_TRANS_GUARDED ) + { + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( ( VpnPlace->NUMBER_IN == 1 ) && + ( ! IsVasyRedInstTag( VpnPlace ) ) ) + { + for ( ScanTrans2 = VpnPlace->TRANS_OUT; + ScanTrans2 != (chain_list *)0; + ScanTrans2 = ScanTrans2->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans2 ); + VpnTrans2 = GetVpnArcTargetTrans( VpnArc ); + + if ( ( VpnTrans2->TYPE != VPN_TRANS_ACT_EXEC ) && + ( VpnTrans2->TYPE != VPN_TRANS_ACT_GUARDED ) && + ( VpnTrans2->TYPE != VPN_TRANS_GUARDED ) && + ( VpnTrans2->TYPE != VPN_TRANS_IMMEDIATE ) ) break; + } + + if ( ScanTrans2 != (chain_list *)0 ) continue; + + ScanTrans2 = VpnPlace->TRANS_OUT; + + while ( ScanTrans2 != (chain_list *)0 ) + { + VpnArc = GetVpnArc( ScanTrans2 ); + VpnTrans2 = GetVpnArcTargetTrans( VpnArc ); + + Guard = dupvexexpr( VpnTrans->VEX_GUARD ); + + if ( VpnTrans2->TYPE == VPN_TRANS_IMMEDIATE ) + { + VpnTrans2->TYPE = VPN_TRANS_GUARDED; + VpnTrans2->VEX_GUARD = Guard; + } + else + if ( VpnTrans2->TYPE == VPN_TRANS_ACT_EXEC ) + { + VpnTrans2->TYPE = VPN_TRANS_ACT_GUARDED; + VpnTrans2->VEX_GUARD = Guard; + } + else + { + VpnTrans2->VEX_GUARD = optimvexbinexpr( VEX_AND, 1, + Guard, VpnTrans2->VEX_GUARD ); + } + + addvpnarcplace( VasyFigure, BeginPlace, VpnTrans2 ); + + ScanTrans2 = ScanTrans2->NEXT; + } + + delvpnplace( VasyFigure, VpnPlace ); + delvpntrans( VasyFigure, VpnTrans ); + + Reduce = 1; + } + } + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstGuarded\n" ); + + if ( Reduce ) VasyDebugSaveVpnFig( VasyFigure ); + } + + return( Reduce ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstLateralVpnAct | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstLateralVpnAct( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + chain_list *ScanTrans; + chain_list *ScanTrans2; + vpntrans_list *VpnTrans; + vpntrans_list *VpnTrans2; + vpnarc *VpnArc; + vpnarc *VpnArc2; + vpnact_list *VpnAct; + vpnact_list *VpnAct2; + vpnact_list *VpnAct3; + vpndecl_list *AsgDeclar; + vpnsym *AsgSymbol; + vexexpr *AsgAtom; + vexexpr *AsgAtom2; + vexexpr *AsgAtom3; + vexexpr *AsgExpr; + vexexpr *AsgExpr2; + vexexpr *AsgExpr3; + char *AtomValue; + char *AtomValue2; + auth2elem *Element; + int AsgIndex; + int AsgMin; + int AsgMax; + int AsgMin2; + int AsgMax2; + int AsgPos2; + int AsgPos3; + int AsgIndex2; + int AsgIndex3; + int FoundBitVec; +/* +** For all transitions Ti, put all ASGi in hash table +*/ + FoundBitVec = 0; + + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + if ( VpnAct->TYPE == VPN_ACT_ASG_DEFINE ) continue; + + FoundBitVec |= VasyRedInstHashVpnAct( VpnTrans, VpnAct ); + } + } + + if ( ! FoundBitVec ) return; +/* +** For All Bit vector assign, built disjoint assignement +*/ + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + if ( VpnAct->TYPE == VPN_ACT_ASG_DEFINE ) continue; +/* +** Assign statement +*/ + AsgAtom = VpnAct->VEX_ATOM; + AsgExpr = VpnAct->VEX_EXPR; + + AtomValue = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VasyFigure, AtomValue ); + + if ( ! isvextypedivisible( AsgDeclar->BASE ) ) continue; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Check Assign in others transition !\n" ); + viewvexexprbound( AsgAtom ); + viewvexexprboundln( AsgExpr ); + } + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); +/* +** Check all assign to bit_vector symbol V in others transitions +*/ + for ( ScanTrans2 = BeginPlace->TRANS_OUT; + ScanTrans2 != (chain_list *)0; + ScanTrans2 = ScanTrans2->NEXT ) + { + VpnArc2 = GetVpnArc( ScanTrans2 ); + VpnTrans2 = GetVpnArcTargetTrans( VpnArc2 ); + + if ( VpnTrans2 == VpnTrans ) continue; + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + Element = searchauth2elem( VasyHash2BitVecAsg, (char*)VpnTrans2, (char*)AsgSymbol ); +/* +** Assign to symbol V appears in transistion VpnTrans2 ! +*/ + if ( Element != (auth2elem *)0 ) + { + VpnAct2 = (vpnact_list *)Element->VALUE; + + AsgAtom2 = VpnAct2->VEX_ATOM; + AsgExpr2 = VpnAct2->VEX_EXPR; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Prev asg %s %d trans %s\n", + AsgSymbol->NAME, AsgIndex, VpnTrans2->NAME ); + viewvexexprbound( AsgAtom2 ); + viewvexexprboundln( AsgExpr2 ); + } + + AtomValue2 = GetVexAtomValue( AsgAtom2 ); + + AsgMin2 = getvexvectormin( AsgAtom2 ); + AsgMax2 = getvexvectormax( AsgAtom2 ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Check instersection [%d %d] -> [%d %d]\n", + AsgMin, AsgMax, AsgMin2, AsgMax2 ); + } +/* +** Check the kind of range's intersection +*/ + if ( ( AsgMin2 < AsgMin ) && + ( AsgMax2 >= AsgMin ) ) + { +/* +** [ ] Asg Partialy included on left +** [<-[]------->] Asg2 +*/ + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Intersection partialy on left\n" ); + } + + AsgAtom3 = dupvexexpr( AsgAtom2 ); + AsgExpr3 = dupvexexpr( AsgExpr2 ); + + if ( IsVexAtomDown( AsgAtom2 ) ) + { + AsgPos2 = getvexvectorpos( AsgAtom2, AsgMin ); + AsgIndex2 = getvexvectorindex( AsgExpr2, AsgPos2 ); + + slicevexatomvec( AsgExpr2, AsgExpr2->LEFT, AsgIndex2 ); + slicevexatomvec( AsgAtom2, AsgAtom2->LEFT, AsgMin ); + + AsgPos3 = getvexvectorpos( AsgAtom3, AsgMin - 1 ); + AsgIndex3 = getvexvectorindex( AsgExpr3, AsgPos3 ); + + slicevexatomvec( AsgExpr3, AsgIndex3 , AsgExpr3->RIGHT ); + slicevexatomvec( AsgAtom3, AsgMin - 1, AsgAtom3->RIGHT ); + } + else + { + AsgPos2 = getvexvectorpos( AsgAtom2, AsgMin ); + AsgIndex2 = getvexvectorindex( AsgExpr2, AsgPos2 ); + + slicevexatomvec( AsgExpr2, AsgIndex2, AsgExpr2->RIGHT ); + slicevexatomvec( AsgAtom2, AsgMin , AsgAtom2->RIGHT ); + + AsgPos3 = getvexvectorpos( AsgAtom3, AsgMin - 1 ); + AsgIndex3 = getvexvectorindex( AsgExpr3, AsgPos3 ); + + slicevexatomvec( AsgExpr3, AsgExpr3->LEFT, AsgIndex3 ); + slicevexatomvec( AsgAtom3, AsgAtom3->LEFT, AsgMin - 1 ); + } + + VpnAct3 = addvpnactasgbefore( VasyFigure, VpnTrans2, + VpnAct2, AsgAtom3, AsgExpr3 ); + unionvpnline( VasyFigure, &VpnAct3->LINE, VpnAct2->LINE ); + + VasyRedInstHashVpnAct( VpnTrans2, VpnAct3 ); + + AsgMin2 = getvexvectormin( AsgAtom2 ); + AsgMax2 = getvexvectormax( AsgAtom2 ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ New assign \n" ); + viewvexexprbound( AsgAtom2 ); + fprintf( stdout, " <= " ); + viewvexexprboundln( AsgExpr2 ); + viewvexexprbound( AsgAtom3 ); + fprintf( stdout, " <= " ); + viewvexexprboundln( AsgExpr3 ); + } + } + + if ( ( AsgMax2 > AsgMax ) && + ( AsgMin2 <= AsgMax ) ) + { +/* +** [ ] Asg Partialy included on right +** [<-------[]->] Asg2 +*/ + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Intersection partialy on right\n" ); + } + + AsgAtom3 = dupvexexpr( AsgAtom2 ); + AsgExpr3 = dupvexexpr( AsgExpr2 ); + + if ( IsVexAtomDown( AsgAtom2 ) ) + { + AsgPos3 = getvexvectorpos( AsgAtom3, AsgMax + 1 ); + AsgIndex3 = getvexvectorindex( AsgExpr3, AsgPos3 ); + + slicevexatomvec( AsgExpr3, AsgExpr3->LEFT, AsgIndex3 ); + slicevexatomvec( AsgAtom3, AsgAtom3->LEFT, AsgMax + 1 ); + + AsgPos2 = getvexvectorpos( AsgAtom2, AsgMax ); + AsgIndex2 = getvexvectorindex( AsgExpr2, AsgPos2 ); + + slicevexatomvec( AsgExpr2, AsgIndex2, AsgExpr2->RIGHT ); + slicevexatomvec( AsgAtom2, AsgMax , AsgAtom2->RIGHT ); + } + else + { + AsgPos3 = getvexvectorpos( AsgAtom3, AsgMax + 1 ); + AsgIndex3 = getvexvectorindex( AsgExpr3, AsgPos3 ); + + slicevexatomvec( AsgExpr3, AsgIndex3 , AsgExpr3->RIGHT ); + slicevexatomvec( AsgAtom3, AsgMax + 1, AsgAtom3->RIGHT ); + + AsgPos2 = getvexvectorpos( AsgAtom2, AsgMax ); + AsgIndex2 = getvexvectorindex( AsgExpr2, AsgPos2 ); + + slicevexatomvec( AsgExpr2, AsgExpr2->LEFT, AsgIndex2 ); + slicevexatomvec( AsgAtom2, AsgAtom2->LEFT, AsgMax ); + } + + VpnAct3 = addvpnactasgbefore( VasyFigure, VpnTrans2, + VpnAct2, AsgAtom3, AsgExpr3 ); + unionvpnline( VasyFigure, &VpnAct3->LINE, VpnAct2->LINE ); + + VasyRedInstHashVpnAct( VpnTrans2, VpnAct3 ); + + AsgMin2 = getvexvectormin( AsgAtom2 ); + AsgMax2 = getvexvectormax( AsgAtom2 ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ New assign \n" ); + viewvexexprbound( AsgAtom2 ); + fprintf( stdout, " <= " ); + viewvexexprboundln( AsgExpr2 ); + viewvexexprbound( AsgAtom3 ); + fprintf( stdout, " <= " ); + viewvexexprboundln( AsgExpr3 ); + VasyDebugSaveVpnFig( VasyFigure ); + } + } + + if ( ( AsgMin2 == AsgMin ) && + ( AsgMax2 == AsgMax ) ) + { +/* +** [ ] Asg Completetly Equal +** [<-[ ]->] Asg2 +*/ + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Intersection Completely equal !!\n" ); + } + + AsgIndex = AsgMax; + } + else + if ( ( AsgMin2 >= AsgMin ) && + ( AsgMax2 <= AsgMax ) ) + { +/* +** [ ] Asg Completely included +** [<-[ ]->] Asg2 +*/ + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Intersection completely included !!\n" ); + } + + AsgIndex = AsgMax2; + } + else + { + AsgIndex = AsgMax; + } + } + } + } + } + } + + if ( IsVasyDebugLevel2() ) + { + viewauth2table( VasyHash2BitVecAsg, VasyRedInstViewAuth2Elem ); + } +} + +/*------------------------------------------------------------\ +| | +| IsVasyRedInstGuardAtomic | +| | +\------------------------------------------------------------*/ + +int IsVasyRedInstGuardAtomic( VexGuard ) + + vexexpr *VexGuard; +{ + long Oper; + + if ( IsVexNodeAtom( VexGuard ) ) + { + return( 1 ); + } + + if ( IsVexNodeOper( VexGuard ) ) + { + Oper = GetVexOperValue( VexGuard ); + + if ( Oper == VEX_NOT ) + { + VexGuard = GetVexOperand( VexGuard->OPERAND ); + + return( IsVasyRedInstGuardAtomic( VexGuard ) ); + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstLateral | +| | +\------------------------------------------------------------*/ + +static int VasyRedInstLateral( BeginPlace, EndPlace, KeepGuard ) + + vpnplace_list *BeginPlace; + vpnplace_list *EndPlace; + short KeepGuard; +{ + chain_list *ScanTrans; + chain_list *ScanTrans2; + vpntrans_list *FirstTrans; + vpntrans_list *VpnTrans; + vpntrans_list *VpnTrans2; + vpnplace_list *VpnPlace; + vpnarc *VpnArc; + vpnarc *VpnArc2; + vpnact_list *VpnAct; + vpnact_list *DelAct; + vpnact_list *PrevAct; + vpnact_list *VpnAct2; + vpnact_list *NewAct; + vpnact_list *NewAct2; + vpndecl_list *AsgDeclar; + vpndecl_list *DefDeclar; + vpnsym *AsgSymbol; + vexexpr *AsgAtom; + vexexpr *VexGuard; + vexexpr *VexDriver; + vexexpr *VexExpr; + vexexpr *DefAtom; + char *AtomValue; + auth2elem *Element; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstLateral %s %s\n", BeginPlace->NAME, EndPlace->NAME ); + } + + if ( BeginPlace->NUMBER_OUT <= 1 ) return( 0 ); +/* +** For all transitions Ti, Tj, verify Ti->OUT == Tj->OUT, and Ti & Tj Guarded. +*/ + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( ( VpnTrans->TYPE != VPN_TRANS_GUARDED ) && + ( VpnTrans->TYPE != VPN_TRANS_ACT_GUARDED ) ) return( 0 ); + + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( EndPlace != VpnPlace ) return( 0 ); + } + + if ( VasyHash2Assign == (auth2table *)0 ) + { + VasyHash2Assign = createauth2table( 100 ); + VasyHash2BitVecAsg = createauth2table( 100 ); + } +/* +** Make only disjunct assigment for all ASGi in Ti +*/ + VasyRedInstLateralVpnAct( BeginPlace ); +/* +** Make all guard's expression atomic, and move define on first trans +*/ + FirstTrans = (vpntrans_list *)0; + + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + VexGuard = VpnTrans->VEX_GUARD; + + if ( FirstTrans == (vpntrans_list *)0 ) + { + FirstTrans = VpnTrans; + } + else + { +/* +** Move all define assignment on the first transition +*/ + VpnAct = VpnTrans->ACT; + PrevAct = (vpnact_list *)0; + + while ( VpnAct != (vpnact_list *)0 ) + { + DelAct = VpnAct; + VpnAct = VpnAct->NEXT; + + if ( DelAct->TYPE == VPN_ACT_ASG_DEFINE ) + { + DefAtom = DelAct->VEX_ATOM; + VexExpr = DelAct->VEX_EXPR; + + NewAct = addvpnactasgafter( VasyFigure, FirstTrans, PrevAct, DefAtom, VexExpr ); + PrevAct = NewAct; + + NewAct->LINE = DelAct->LINE; + + DelAct->VEX_ATOM = (vexexpr *)0; + DelAct->VEX_EXPR = (vexexpr *)0; + DelAct->LINE = (vpnline_list *)0; + + delvpnact( VasyFigure, VpnTrans, DelAct ); + } + } + } + + if ( ! IsVasyRedInstGuardAtomic( VexGuard ) ) + { + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Lateral Guard is not atomic, create define !\n" ); + viewvexexprboundln( VexGuard ); + } + + DefDeclar = VasyRedActAddVpnDefine( VasyFigure, VasyProcess, 1, VEX_TYPE_BOOLEAN ); + + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + VpnTrans->VEX_GUARD = dupvexnode( DefAtom ); + + NewAct = addvpnactasgfirst( VasyFigure, FirstTrans, DefAtom, VexGuard ); + unionvpnline( VasyFigure, &NewAct->LINE, BeginPlace->LINE ); + + if ( IsVasyDebugLevel2() ) + { + viewvexexprboundln( VpnTrans->VEX_GUARD ); + } + } + } + + if ( IsVasyDebugLevel2() ) + { + VasyDebugSaveVpnFig( VasyFigure ); + } + + FirstTrans = (vpntrans_list *)0; + + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + VpnAct = VpnTrans->ACT; + + if ( FirstTrans == (vpntrans_list *)0 ) + { + FirstTrans = VpnTrans; + + FirstTrans->ACT = (vpnact_list *)0; + FirstTrans->LAST_ACT = &FirstTrans->ACT; + } + + while ( VpnAct != (vpnact_list *)0 ) + { + NewAct = VpnAct; + VpnAct = VpnAct->NEXT; + + *FirstTrans->LAST_ACT = NewAct; + NewAct->PREV = FirstTrans->LAST_ACT; + NewAct->NEXT = (vpnact_list *)0; + FirstTrans->LAST_ACT = &NewAct->NEXT; + + if ( NewAct->TYPE != VPN_ACT_ASG_DEFINE ) + { + AsgAtom = NewAct->VEX_ATOM; + VexDriver = (vexexpr *)0; + + AtomValue = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VasyFigure, AtomValue ); + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgAtom->LEFT ); + VexGuard = dupvexexpr( VpnTrans->VEX_GUARD ); + + NewAct->VEX_EXPR = optimvexbinexpr( VEX_IFT, AsgAtom->WIDTH, + VexGuard, NewAct->VEX_EXPR ); + + for ( ScanTrans2 = BeginPlace->TRANS_OUT; + ScanTrans2 != (chain_list *)0; + ScanTrans2 = ScanTrans2->NEXT ) + { + VpnArc2 = GetVpnArc( ScanTrans2 ); + VpnTrans2 = GetVpnArcTargetTrans( VpnArc2 ); + + if ( VpnTrans2 == VpnTrans ) continue; + + if ( isvextypedivisible( AsgDeclar->BASE ) ) + { + Element = searchauth2elem( VasyHash2BitVecAsg, (char*)VpnTrans2, (char*)AsgSymbol ); + } + else + { + Element = searchauth2elem( VasyHash2Assign, (char*)VpnTrans2, AtomValue ); + } + + VexGuard = dupvexexpr( VpnTrans2->VEX_GUARD ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Guard of %s is ", VpnTrans2->NAME ); + viewvexexprboundln( VexGuard ); + } + + if ( Element == (auth2elem *)0 ) + { + if ( VexDriver == (vexexpr *)0 ) + { + VexDriver = VexGuard; + } + else + { + VexDriver = optimvexbinexpr( VEX_OR, 1, VexDriver, VexGuard ); + } + } + else + { + VpnAct2 = (vpnact_list *)Element->VALUE; + VexExpr = dupvexexpr( VpnAct2->VEX_EXPR ); + VexExpr = optimvexbinexpr( VEX_IFT, AsgAtom->WIDTH, VexGuard, VexExpr ); + + NewAct->VEX_EXPR = optimvexbinexpr( VEX_OR, AsgAtom->WIDTH, + NewAct->VEX_EXPR, VexExpr ); + unionvpnline( VasyFigure, &NewAct->LINE, VpnAct2->LINE ); + + delvpnact( VasyFigure, VpnTrans2, VpnAct2 ); + } + } + + if ( VexDriver != (vexexpr *)0 ) + { + VexExpr = dupvexexpr( AsgAtom ); + + if ( ( NewAct->TYPE == VPN_ACT_ASG_PORT ) || + ( NewAct->TYPE == VPN_ACT_ASG_SIGNAL ) ) + { + VexExpr = createvexunaryexpr( VEX_DRIVER, VexExpr->WIDTH, VexExpr ); + VexExpr->TYPE = AsgAtom->TYPE; + + SetVexNodeOper( VexExpr ); + } + + VexExpr = optimvexbinexpr( VEX_IFT, AsgAtom->WIDTH, VexDriver, VexExpr ); + + NewAct->VEX_EXPR = optimvexbinexpr( VEX_OR, AsgAtom->WIDTH, + NewAct->VEX_EXPR, VexExpr ); + } + + if ( NewAct->TYPE == VPN_ACT_ASG_VARIABLE ) + { + VexExpr = NewAct->VEX_EXPR; + DefDeclar = VasyRedActAddVpnDefine( VasyFigure, VasyProcess, + AsgAtom->WIDTH, AsgDeclar->BASE ); + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + NewAct->VEX_EXPR = dupvexnode( DefAtom ); + + NewAct2 = addvpnactasgbefore( VasyFigure, FirstTrans, NewAct, DefAtom, VexExpr ); + unionvpnline( VasyFigure, &NewAct2->LINE, NewAct->LINE ); + } + } + } + + if ( VpnTrans != FirstTrans ) + { + VpnTrans->ACT = (vpnact_list *)0; + VpnTrans->LAST_ACT = &VpnTrans->ACT; + } + } + + if ( ! KeepGuard ) + { + freevexexpr( FirstTrans->VEX_GUARD ); + FirstTrans->VEX_GUARD = (vexexpr *)0; + } + + while ( BeginPlace->TRANS_OUT->NEXT != (chain_list *)0 ) + { + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT->NEXT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( KeepGuard ) + { + FirstTrans->VEX_GUARD = optimvexbinexpr( VEX_OR, 1, + FirstTrans->VEX_GUARD, + VpnTrans->VEX_GUARD ); + VpnTrans->VEX_GUARD = (vexexpr *)0; + } + + delvpntrans( VasyFigure, VpnTrans ); + } + + if ( KeepGuard ) + { + if ( FirstTrans->ACT != (vpnact_list *)0 ) FirstTrans->TYPE = VPN_TRANS_ACT_GUARDED; + else FirstTrans->TYPE = VPN_TRANS_GUARDED; + } + else + { + if ( FirstTrans->ACT != (vpnact_list *)0 ) FirstTrans->TYPE = VPN_TRANS_ACT_EXEC; + else FirstTrans->TYPE = VPN_TRANS_IMMEDIATE; + } + + resetauth2table( VasyHash2Assign ); + resetauth2table( VasyHash2BitVecAsg ); + + if ( IsVasyDebugLevel2() ) + { + VasyDebugSaveVpnFig( VasyFigure ); + VasyPrintf( stdout, " <-- VasyRedInstLateral\n" ); + } + + return( 1 ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstLateralWait | +| | +\------------------------------------------------------------*/ + +int VasyRedInstLateralWait( VpnFigure, VpnProc, BeginPlace, EndPlace ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnplace_list *BeginPlace; + vpnplace_list *EndPlace; +{ + VasyFigure = VpnFigure; + VasyProcess = VpnProc; + + return( VasyRedInstLateral( BeginPlace, EndPlace, 1 ) ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstCase | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstCase( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *EndPlace; + vpnplace_list *CasePlace; + vpntrans_list *CaseTrans; + vpntrans_list *EndTrans; + vpnarc *VpnArc; + chain_list *ScanChain; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstCase %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + SetVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + EndTrans = GetVpnArcTargetTrans( VpnArc ); + + for ( ScanChain = BeginPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + CaseTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( CaseTrans->PLACE_OUT ); + CasePlace = GetVpnArcTargetPlace( VpnArc ); + + VasyPrevTrans = CaseTrans; + + VasyRedInstVpnPlace( CasePlace ); + + VasyPrevTrans = VasyRedInstVertical( BeginPlace, VasyPrevTrans ); + } + + VasyPrevTrans = EndTrans; + + VasyRedInstGuarded( BeginPlace ); + VasyRedInstLateral( BeginPlace, EndPlace, 0 ); + + ClearVasyRedInstTag( EndPlace ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstCase\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstAsg | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstAsg( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstAsg %s\n", BeginPlace->NAME ); + } + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstAsg\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstProc | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstProc( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstProc %s\n", BeginPlace->NAME ); + } + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstProc\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstWait | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstWait( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *EndPlace; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstWait %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + if ( EndPlace == (vpnplace_list *)0 ) + { + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + else + { + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstWait\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstExit | +| | +\------------------------------------------------------------*/ + +static int VasyRedInstExit( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *EndPlace; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstExit %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + if ( EndPlace == (vpnplace_list *)0 ) + { + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + else + { + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstExit\n" ); + } + + return( EndPlace == (vpnplace_list *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstNext | +| | +\------------------------------------------------------------*/ + +static int VasyRedInstNext( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *EndPlace; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstNext %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + if ( EndPlace == (vpnplace_list *)0 ) + { + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + else + { + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstNext\n" ); + } + + return( EndPlace == (vpnplace_list *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstLoop | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstLoop( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpntrans_list *LoopTrans; + vpnplace_list *LoopPlace; + vpnplace_list *EndPlace; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstLoop %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + if ( EndPlace != (vpnplace_list *)0 ) + { + SetVasyRedInstTag( BeginPlace ); + SetVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + LoopTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( LoopTrans->PLACE_OUT ); + LoopPlace = GetVpnArcTargetPlace( VpnArc ); + + VasyPrevTrans = LoopTrans; + + VasyRedInstVpnPlace( LoopPlace ); + + VasyPrevTrans = VasyRedInstVertical( LoopPlace, VasyPrevTrans ); + ClearVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + } + else + { + SetVasyRedInstTag( BeginPlace ); + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + EndPlace = BeginPlace; + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstLoop %s\n", EndPlace->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstWhile | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstWhile( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *TestPlace; + vpnplace_list *EndPlace; + vpnplace_list *CasePlace; + vpntrans_list *CaseTrans; + vpntrans_list *TestTrans; + vpnarc *VpnArc; + chain_list *ScanChain; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstWhile %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + SetVasyRedInstTag( BeginPlace ); + SetVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + TestTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( TestTrans->PLACE_OUT ); + TestPlace = GetVpnArcTargetPlace( VpnArc ); + + for ( ScanChain = TestPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + CaseTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( CaseTrans->PLACE_OUT ); + CasePlace = GetVpnArcTargetPlace( VpnArc ); + + VasyPrevTrans = CaseTrans; + + VasyRedInstVpnPlace( CasePlace ); + + VasyPrevTrans = VasyRedInstVertical( TestPlace, VasyPrevTrans ); + } + + ClearVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstWhile %s\n", EndPlace->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstFor | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstFor( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *TestPlace; + vpnplace_list *LoopPlace; + vpnplace_list *EndPlace; + vpnplace_list *IncPlace; + vpnplace_list *CasePlace; + vpntrans_list *CaseTrans; + vpntrans_list *SkipTrans; + vpnarc *VpnArc; + chain_list *ScanChain; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasyRedInstFor %s\n", BeginPlace->NAME ); + } + + EndPlace = BeginPlace->LINK; + BeginPlace->LINK = (vpnplace_list *)0; + + SetVasyRedInstTag( BeginPlace ); + SetVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + SkipTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( SkipTrans->PLACE_OUT ); + LoopPlace = GetVpnArcTargetPlace( VpnArc ); + + SetVasyRedInstTag( LoopPlace ); + IncPlace = LoopPlace->LINK; + IncPlace->LINK = (vpnplace_list *)0; + + if ( IncPlace != (vpnplace_list *)0 ) + { + SetVasyRedInstTag( IncPlace ); + } + + VpnArc = GetVpnArc( LoopPlace->TRANS_OUT ); + SkipTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( SkipTrans->PLACE_OUT ); + TestPlace = GetVpnArcTargetPlace( VpnArc ); + + for ( ScanChain = TestPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + CaseTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( CaseTrans->PLACE_OUT ); + CasePlace = GetVpnArcTargetPlace( VpnArc ); + + VasyPrevTrans = CaseTrans; + + VasyRedInstVpnPlace( CasePlace ); + + VasyPrevTrans = VasyRedInstVertical( TestPlace, VasyPrevTrans ); + } + + if ( IncPlace != (vpnplace_list *)0 ) + { + ClearVasyRedInstTag( IncPlace ); + } + + ClearVasyRedInstTag( LoopPlace ); + ClearVasyRedInstTag( EndPlace ); + + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + VasyPrevTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasyRedInstFor %s\n", EndPlace->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstVpnPlace | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstVpnPlace( BeginPlace ) + + vpnplace_list *BeginPlace; +{ + vpnplace_list *ScanPlace; + vpnplace_list *NextPlace; + vpnarc *VpnArc; + vpntrans_list *VpnTrans; + short Stop; + + ScanPlace = BeginPlace; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, "--> VasyRedInstVpnPlace %s\n", BeginPlace->NAME ); + } + + Stop = 0; + + while ( ! IsVasyRedInstTag( ScanPlace ) ) + { + if ( ScanPlace->LINK != (vpnplace_list *)0 ) NextPlace = ScanPlace->LINK; + else NextPlace = ScanPlace; + + VpnArc = GetVpnArc( NextPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); +/* + if ( VpnTrans->PLACE_OUT == (chain_list *)0 ) break; +*/ + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + NextPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( ScanPlace->TYPE == VPN_PLACE_ASSIGN ) + { + VasyRedInstAsg( ScanPlace ); + } + else + if ( ( ScanPlace->TYPE == VPN_PLACE_IF ) || + ( ScanPlace->TYPE == VPN_PLACE_CASE ) ) + { + VasyRedInstCase( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_WHILE ) + { + VasyRedInstWhile( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_FOR ) + { + VasyRedInstFor( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_LOOP ) + { + VasyRedInstLoop( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_WAIT ) + { + VasyRedInstWait( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_EXIT ) + { + Stop = VasyRedInstExit( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_NEXT ) + { + Stop = VasyRedInstNext( ScanPlace ); + } + else + if ( ScanPlace->TYPE == VPN_PLACE_PROCESS ) + { + VasyRedInstProc( ScanPlace ); + } + else +/*\ + if ( ( ScanPlace->TYPE == VPN_PLACE_END_IF ) || + ( ScanPlace->TYPE == VPN_PLACE_END_CASE ) || + ( ScanPlace->TYPE == VPN_PLACE_END_FOR ) || + ( ScanPlace->TYPE == VPN_PLACE_END_LOOP ) || + ( ScanPlace->TYPE == VPN_PLACE_END_WHILE ) ) +\*/ + { + VasyPrintf( stdout, " +++ Should not happen %s!!!\n", + VPN_PLACE_TYPE[ ScanPlace->TYPE ] ); + autexit( 1 ); + } +/*\ + else + { + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ Skip %s %s !!!\n", + ScanPlace->NAME, VPN_PLACE_TYPE[ ScanPlace->TYPE ] ); + } + } +\*/ + + VasyPrevTrans = VasyRedInstVertical( BeginPlace, VasyPrevTrans ); + + if ( Stop ) break; + + ScanPlace = NextPlace; + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, "<-- VasyRedInstVpnPlace %s %d\n", BeginPlace->NAME, Stop ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstStartVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstStartVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *BeginTrans; + vpnplace_list *ScanPlace; + vpnplace_list *BeginPlace; + vpnarc *VpnArc; + + BeginTrans = VpnProc->FIRST; + VpnArc = GetVpnArc( BeginTrans->PLACE_IN ); + BeginPlace = GetVpnArcSourcePlace( VpnArc ); + + VpnProc->FIRST = VpnProc->ELABO; + VpnArc = GetVpnArc( BeginTrans->PLACE_OUT ); + ScanPlace = GetVpnArcTargetPlace( VpnArc ); + + VasyFigure = VpnFigure; + VasyProcess = VpnProc; + VasyPrevTrans = BeginTrans; + + SetVasyRedInstTag( BeginPlace ); + VasyRedInstVpnPlace( ScanPlace ); + + VasyPrevTrans = VasyRedInstVertical( BeginPlace, VasyPrevTrans ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstImmediateVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstImmediateVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpnplace_list *PrevPlace; + vpnplace_list *NextPlace; + vpntrans_list *PrevTrans; + vpntrans_list *DelTrans; + chain_list *ScanTrans; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyRedInstImmediateVpnProc\n" ); + } + + VpnTrans = VpnProc->TRANS; + + while ( VpnTrans != (vpntrans_list *)0 ) + { + if ( ( VpnTrans->TYPE == VPN_TRANS_IMMEDIATE ) && + ( VpnTrans->NUMBER_IN == 1 ) && + ( VpnTrans->NUMBER_OUT == 1 ) ) + { + VpnArc = GetVpnArc( VpnTrans->PLACE_IN ); + PrevPlace = GetVpnArcSourcePlace( VpnArc ); + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + NextPlace = GetVpnArcTargetPlace( VpnArc ); + + DelTrans = VpnTrans; + VpnTrans = VpnTrans->NEXT; + + if ( PrevPlace->NUMBER_OUT == 1 ) + { + delvpntrans( VpnFigure, DelTrans ); + + for ( ScanTrans = PrevPlace->TRANS_IN; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + PrevTrans = GetVpnArcSourceTrans( VpnArc ); + + addvpnarctrans( VpnFigure, PrevTrans, NextPlace ); + } + + delvpnplace( VpnFigure, PrevPlace ); + } + } + else + { + VpnTrans = VpnTrans->NEXT; + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + + VasyPrintf( stdout, " <-- VasyRedInstImmediateVpnProc\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstLocalVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyRedInstLocalVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpnplace_list *ScanPlace; + vpnplace_list *NextPlace; + vpnplace_list *PrevPlace; + vpnplace_list *EndPlace; + vpntrans_list *ScanTrans; + vpntrans_list *PrevTrans; + vpntrans_list *NewTrans; + vpnarc *VpnArc; + chain_list *ScanChain; + int Modified; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "--> VasyRedInstLocalVpnProc %s\n", VpnProc->NAME ); + VasyDebugSaveVpnFig( VasyFigure ); + } + + VasyFigure = VpnFigure; + VasyProcess = VpnProc; + + Modified = 1; + + while ( Modified ) + { + Modified = 0; + + ScanPlace = VpnProc->PLACE; + + while ( ScanPlace != (vpnplace_list *)0 ) + { + NextPlace = ScanPlace->NEXT; + + if ( ScanPlace->NUMBER_OUT > 1 ) + { + VpnArc = GetVpnArc( ScanPlace->TRANS_OUT ); + ScanTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( ScanTrans->PLACE_OUT ); + EndPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( VasyRedInstLateral( ScanPlace, EndPlace, 0 ) ) + { + Modified = 1; + } + } + + if ( ( ScanPlace->NUMBER_IN == 1 ) && + ( ScanPlace->NUMBER_OUT == 1 ) ) + { + VpnArc = GetVpnArc( ScanPlace->TRANS_OUT ); + ScanTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( ScanPlace->TRANS_IN ); + PrevTrans = GetVpnArcSourceTrans( VpnArc ); + + VpnArc = GetVpnArc( PrevTrans->PLACE_IN ); + PrevPlace = GetVpnArcSourcePlace( VpnArc ); + NewTrans = VasyRedInstVertical( PrevPlace, ScanTrans ); + + if ( NewTrans != ScanTrans ) + { + Modified = 1; + } + } + else + if ( ScanPlace->NUMBER_IN == 0 ) + { + ScanChain = ScanPlace->TRANS_OUT; + + while ( ScanChain != (chain_list *)0 ) + { + VpnArc = GetVpnArc( ScanChain ); + ScanChain = ScanChain->NEXT; + ScanTrans = GetVpnArcTargetTrans( VpnArc ); + + delvpntrans( VpnFigure, ScanTrans ); + } + + delvpnplace( VpnFigure, ScanPlace ); + + Modified = 1; + } + + ScanPlace = NextPlace; + } + + if ( Modified && IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VasyFigure ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "<-- VasyRedInstLocalVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedInstVpnProc | +| | +\------------------------------------------------------------*/ + +void VasyRedInstVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *ScanTrans; + vpnplace_list *ScanPlace; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyRedInstVpnProc %s\n", VpnProc->NAME ); + VasyDebugSaveVpnFig( VpnFigure ); + } + +/* +** Only one assigment to each symbols for all actions +*/ + for ( ScanTrans = VpnProc->TRANS; + ScanTrans != (vpntrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VasyRedActVpnTrans( VpnFigure, VpnProc, ScanTrans, 0 ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } +/* +** Reduction on all instruction +*/ + if ( ! IsVasyDebugNoRedInst() ) + { + VasyRedInstStartVpnProc( VpnFigure, VpnProc ); + } +/* +** Sets all place's type to unknown ! +*/ + for ( ScanPlace = VpnProc->PLACE; + ScanPlace != (vpnplace_list *)0; + ScanPlace = ScanPlace->NEXT ) + { + ScanPlace->TYPE = VPN_PLACE_UNKNOWN; + ScanPlace->LINK = (vpnplace_list *)0; + ClearVasyRedInstTag( ScanPlace ); + } + + VasyRedInstImmediateVpnProc( VpnFigure, VpnProc ); +/* +** Apply a local reduction, this is the last chance ! +*/ + if ( ! IsVasyDebugNoRedInst() ) + { + VasyRedInstLocalVpnProc( VpnFigure, VpnProc ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + VasyPrintf( stdout, " <-- VasyRedInstVpnProc %s\n", VpnProc->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_redinst.h b/alliance/src/vasy/src/vasy_redinst.h new file mode 100644 index 00000000..7cdfa8c6 --- /dev/null +++ b/alliance/src/vasy/src/vasy_redinst.h @@ -0,0 +1,81 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_reduce.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_REDINST_H +# define VASY_REDINST_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_REDINST_TAG_MASK (long)0x01 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define SetVasyRedInstTag( O ) ((O)->FLAGS |= VASY_REDINST_TAG_MASK) +# define ClearVasyRedInstTag( O ) ((O)->FLAGS &= ~VASY_REDINST_TAG_MASK) +# define IsVasyRedInstTag( O ) ((O)->FLAGS & VASY_REDINST_TAG_MASK) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern int IsVasyRedInstGuardAtomic(); + extern int VasyRedInstLateralWait(); + extern void VasyRedInstVpnProc(); + +# endif diff --git a/alliance/src/vasy/src/vasy_reduce.c b/alliance/src/vasy/src/vasy_reduce.c new file mode 100644 index 00000000..e2205450 --- /dev/null +++ b/alliance/src/vasy/src/vasy_reduce.c @@ -0,0 +1,170 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_reduce.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_shared.h" +# include "vasy_redact.h" +# include "vasy_redinst.h" +# include "vasy_redwait.h" +# include "vasy_reduce.h" + +# include "vasy_debug.h" +# include "vasy_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyReduceVpnFig | +| | +\------------------------------------------------------------*/ + +void VasyReduceVpnFig( VpnFigure ) + + vpnfig_list *VpnFigure; +{ + vpnproc_list *VpnProc; + int Reduced; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasyReduceVpnFig %s\n", VpnFigure->NAME ); + VasyDebugSaveVpnFig( VpnFigure ); + } +/* +** Partial reduction instruction by instruction +*/ + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Process : %ld\n", GetVpnNumProc( VpnFigure ) ); + VasyPrintf( stdout, "--> Transition : %ld\n", GetVpnNumTrans( VpnFigure ) ); + VasyPrintf( stdout, "--> Place : %ld\n", GetVpnNumPlace( VpnFigure ) ); + VasyDebugStartChrono(1); + } + + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + if ( IsVasyVpnProcToAnalyse( VpnProc ) ) + { + VasyRedInstVpnProc( VpnFigure, VpnProc ); + } + } + + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Local reduction : %ld sec\n", VasyDebugReadChrono(1) ); + VasyPrintf( stdout, "--> Process : %ld\n", GetVpnNumProc( VpnFigure ) ); + VasyPrintf( stdout, "--> Transition : %ld\n", GetVpnNumTrans( VpnFigure ) ); + VasyPrintf( stdout, "--> Place : %ld\n", GetVpnNumPlace( VpnFigure ) ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } +/* +** Global reduction wait to wait +*/ + if ( IsVasyDebugStatistics() ) VasyDebugStartChrono(1); + + Reduced = 0; + + for ( VpnProc = VpnFigure->PROCESS; + VpnProc != (vpnproc_list *)0; + VpnProc = VpnProc->NEXT ) + { + if ( IsVasyVpnProcToAnalyse( VpnProc ) ) + { + Reduced += VasyRedWaitVpnProc( VpnFigure, VpnProc ); + } + } + + if ( IsVasyDebugStatistics() ) + { + VasyPrintf( stdout, "--> Process minimal : %d\n", Reduced ); + + VasyPrintf( stdout, "--> Global reduction : %ld sec\n", VasyDebugReadChrono(1) ); + VasyPrintf( stdout, "--> Process : %ld\n", GetVpnNumProc( VpnFigure ) ); + VasyPrintf( stdout, "--> Transition : %ld\n", GetVpnNumTrans( VpnFigure ) ); + VasyPrintf( stdout, "--> Place : %ld\n", GetVpnNumPlace( VpnFigure ) ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + VasyPrintf( stdout, "<-- VasyReduceVpnFig %s\n", VpnFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_reduce.h b/alliance/src/vasy/src/vasy_reduce.h new file mode 100644 index 00000000..fc0aa21f --- /dev/null +++ b/alliance/src/vasy/src/vasy_reduce.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_reduce.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_REDUCE_H +# define VASY_REDUCE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasyReduceVpnFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_redwait.c b/alliance/src/vasy/src/vasy_redwait.c new file mode 100644 index 00000000..a0c3c754 --- /dev/null +++ b/alliance/src/vasy/src/vasy_redwait.c @@ -0,0 +1,1109 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_redwait.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_debug.h" +# include "vasy_error.h" +# include "vasy_shared.h" +# include "vasy_redact.h" +# include "vasy_redinst.h" +# include "vasy_redwait.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + static vpnproc_list *VasyProcess = (vpnproc_list *)0; + + static vasystack_list *VasyStackHead = (vasystack_list *)0; + static vasystack_list *VasyStackQueue = (vasystack_list *)0; + static authtable *VasyHashStackTrans = (authtable *)0; + static long VasyStackSize = 0; + static long VasyNumberTrans = 0; + + static authtable *VasyHashAssign = (authtable *)0; + static authtable *VasyHashRenDef = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyRedWaitAddVpnTrans | +| | +\------------------------------------------------------------*/ + +static vpntrans_list *VasyRedWaitAddVpnTrans() +{ + vpntrans_list *VpnTrans; + char Buffer[ 128 ]; + + sprintf( Buffer, "%s.redwait.%ld", VasyProcess->NAME, VasyNumberTrans++ ); + VpnTrans = addvpnproctrans( VasyFigure, VasyProcess, Buffer ); + + return( VpnTrans ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitAddVpnPlace | +| | +\------------------------------------------------------------*/ + +static vpnplace_list *VasyRedWaitAddVpnPlace() +{ + vpnplace_list *VpnPlace; + char Buffer[ 128 ]; + + sprintf( Buffer, "%s.redwait.%ld", VasyProcess->NAME, VasyNumberTrans++ ); + VpnPlace = addvpnprocplace( VasyFigure, VasyProcess, Buffer ); + + return( VpnPlace ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitDelDriverVexExpr | +| | +\------------------------------------------------------------*/ + +static void VasyRedWaitDelDriverVexExpr( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + vexexpr *Atom; + long Oper; + + if ( IsVexNodeAtom( Expr ) ) + { + return; + } + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_DRIVER ) + { + Atom = GetVexOperand( Expr->OPERAND ); + freechain( Expr->OPERAND ); + copyvexnode( Expr, Atom ); + freevexexpr( Atom ); + + return; + } + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasyRedWaitDelDriverVexExpr( GetVexOperand( ScanOper ) ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitDelDriverVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasyRedWaitDelDriverVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpnact_list *VpnAct; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyRedWaitDelDriverVpnProc\n" ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + /* + VpnAct->VEX_EXPR = simpvexexpreq( VpnAct->VEX_EXPR ); + */ + VpnAct->VEX_EXPR = simpvexexpr( VpnAct->VEX_EXPR ); + VasyRedWaitDelDriverVexExpr( VpnAct->VEX_EXPR ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + + VasyPrintf( stdout, " <-- VasyRedWaitDelDriverVpnProc\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitPushVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasyRedWaitPushVpnTrans( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + vasystack_list *NewStack; + authelem *Element; + + Element = searchauthelem( VasyHashStackTrans, VpnTrans->NAME ); + + if ( Element != (authelem *)0 ) + { + VasyError( VASY_LOOP_IN_REDUCTION, VpnTrans->NAME ); + } + + if ( VpnTrans->TYPE != VPN_TRANS_INF_WAIT ) + { + addauthelem( VasyHashStackTrans, VpnTrans->NAME, 0 ); + } + + NewStack = (vasystack_list *)autallocheap( sizeof( vasystack_list ) ); + NewStack->TRANS = VpnTrans; + + if ( VasyStackQueue == (vasystack_list *)0 ) + { + VasyStackHead = NewStack; + } + else + { + VasyStackQueue->NEXT = NewStack; + NewStack->PREV = VasyStackQueue; + } + + VasyStackQueue = NewStack; + VasyStackSize++; +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitPopVpnTrans | +| | +\------------------------------------------------------------*/ + +static vpntrans_list *VasyRedWaitPopVpnTrans() + +{ + vasystack_list *DelStack; + vpntrans_list *VpnTrans; + + DelStack = VasyStackQueue; + VasyStackQueue = DelStack->PREV; + + if ( VasyStackQueue == (vasystack_list *)0 ) + { + VasyStackHead = (vasystack_list *)0; + } + else + { + VasyStackQueue->NEXT = (vasystack_list *)0; + } + + VpnTrans = DelStack->TRANS; + + autfreeheap( DelStack, sizeof( vasystack_list ) ); + VasyStackSize--; + + if ( VpnTrans->TYPE != VPN_TRANS_INF_WAIT ) + { + delauthelem( VasyHashStackTrans, VpnTrans->NAME ); + } + + return( VpnTrans ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitStackVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasyRedWaitStackVpnTrans() +{ + vasystack_list *ScanStack; + vpntrans_list *VpnTrans; + vpntrans_list *BeginWait; + vpntrans_list *EndWait; + vpntrans_list *StackTrans; + vpnplace_list *EndPlace; + vpnplace_list *BeginPlace; + vpnact_list *VpnAct; + vpnline_list *VpnLine; + vpnarc *VpnArc; + vexexpr *VexGuard; + short RedAction; + + BeginWait = VasyStackHead->TRANS; + EndWait = VasyStackQueue->TRANS; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyRedWaitStackVpnTrans %s -> %s Size %ld\n", + BeginWait->NAME, EndWait->NAME, VasyStackSize ); + } + + VpnTrans = VasyRedWaitAddVpnTrans(); + BeginPlace = GetVasyRedWaitPlace( BeginWait ); + + VpnArc = GetVpnArc( EndWait->PLACE_IN ); + EndPlace = GetVpnArcSourcePlace( VpnArc ); + + VpnArc = addvpnarcplace( VasyFigure, BeginPlace, VpnTrans ); + VpnArc = addvpnarctrans( VasyFigure, VpnTrans , EndPlace ); + + RedAction = 0; + + for ( ScanStack = VasyStackHead->NEXT; + ScanStack != VasyStackQueue; + ScanStack = ScanStack->NEXT ) + { + StackTrans = ScanStack->TRANS; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ %s\n", StackTrans->NAME ); + } + + VexGuard = StackTrans->VEX_GUARD; + + if ( VexGuard != (vexexpr *)0 ) + { + VexGuard = dupvexexpr( VexGuard ); + + if ( VpnTrans->VEX_GUARD != (vexexpr *)0 ) + { + VexGuard = optimvexbinexpr( VEX_AND, 1, VpnTrans->VEX_GUARD, VexGuard ); + } + + VpnTrans->VEX_GUARD = VexGuard; + } + + for ( VpnAct = StackTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + addvpnact( VasyFigure, VpnTrans, + dupvexexpr( VpnAct->VEX_ATOM ), + dupvexexpr( VpnAct->VEX_EXPR ), VpnAct->TYPE ); + + for ( VpnLine = VpnAct->LINE; + VpnLine != (vpnline_list *)0; + VpnLine = VpnLine->NEXT ) + { + addvpnline( VasyFigure, &VpnAct->LINE, VpnLine->LINE ); + } + } + + if ( StackTrans->ACT != (vpnact_list *)0 ) RedAction = 1; + } + + if ( VpnTrans->VEX_GUARD != (vexexpr *)0 ) + { + if ( VpnTrans->ACT == (vpnact_list *)0 ) VpnTrans->TYPE = VPN_TRANS_GUARDED; + else VpnTrans->TYPE = VPN_TRANS_ACT_GUARDED; + } + else + { + if ( VpnTrans->ACT == (vpnact_list *)0 ) VpnTrans->TYPE = VPN_TRANS_IMMEDIATE; + else VpnTrans->TYPE = VPN_TRANS_ACT_EXEC; + } + + if ( RedAction ) + { + VasyRedActVpnTrans( VasyFigure, VasyProcess, VpnTrans, 1 ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VasyFigure ); + VasyPrintf( stdout, " <-- VasyRedWaitStackVpnTrans\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedWait2WaitVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasyRedWait2WaitVpnTrans( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + chain_list *ScanPlace; + chain_list *ScanTrans; + vpnplace_list *VpnPlace; + vpntrans_list *NewTrans; + vpnarc *VpnArc; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyRedWait2WaitVpnTrans %s\n", VpnTrans->NAME ); + } + + VasyRedWaitPushVpnTrans( VpnTrans ); + + for ( ScanPlace = VpnTrans->PLACE_OUT; + ScanPlace != (chain_list *)0; + ScanPlace = ScanPlace->NEXT ) + { + VpnArc = GetVpnArc( ScanPlace ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + for ( ScanTrans = VpnPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + NewTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( NewTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VasyRedWaitPushVpnTrans( NewTrans ); + VasyRedWaitStackVpnTrans( NewTrans ); + VasyRedWaitPopVpnTrans(); + } + else + { + VasyRedWait2WaitVpnTrans( NewTrans ); + } + } + } + + VasyRedWaitPopVpnTrans(); +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitRenameVex | +| | +\------------------------------------------------------------*/ + +static void VasyRedWaitRenameVex( Expr ) + + vexexpr *Expr; +{ + chain_list *ScanOper; + authelem *Element; + + if ( Expr != (vexexpr *)0 ) + { + if ( IsVexNodeAtom( Expr ) ) + { + if ( ! IsVexAtomLiteral( Expr ) ) + { + Element = searchauthelem( VasyHashRenDef, GetVexAtomValue( Expr ) ); + + if ( Element != (authelem *)0 ) + { + SetVexAtomValue( Expr, Element->VALUE ); + } + } + } + + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasyRedWaitRenameVex( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitRenameDefine | +| | +\------------------------------------------------------------*/ + + +static void VasyRedWaitRenameDefine( VpnFigure, VpnProc, VpnAct ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnact_list *VpnAct; +{ + vpndecl_list *DefDeclar; + authelem *Element; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + vexexpr *DefAtom; + char *AtomValue; + char *DefValue; + int DefBase; + int DefWidth; + + AsgAtom = VpnAct->VEX_ATOM; + AsgExpr = VpnAct->VEX_EXPR; + + if ( VpnAct->TYPE == VPN_ACT_ASG_DEFINE ) + { + AtomValue = GetVexAtomValue( AsgAtom ); + Element = searchauthelem( VasyHashRenDef, AtomValue ); + + if ( Element == (authelem *)0 ) + { + DefDeclar = searchvpndecldef( VpnFigure, AtomValue ); + DefAtom = DefDeclar->VEX_ATOM; + DefBase = DefDeclar->BASE; + DefWidth = DefAtom->WIDTH; + DefDeclar = VasyRedActAddVpnDefine( VpnFigure, VpnProc, DefWidth, DefBase ); + + DefAtom = DefDeclar->VEX_ATOM; + DefValue = GetVexAtomValue( DefAtom ); + + addauthelem( VasyHashRenDef, AtomValue, (long)DefValue ); + } + else + { + DefValue = (char *)Element->VALUE; + } + + SetVexAtomValue( AsgAtom, DefValue ); + } + + VasyRedWaitRenameVex( AsgExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitLateralWait | +| | +\------------------------------------------------------------*/ + +static void VasyRedWaitLateralWait( VpnFigure, VpnProc, WaitTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *WaitTrans; +{ + vasyprocinfo *ProcInfo; + vpndecl_list *DefDeclar; + vpntrans_list *DefTrans; + vpntrans_list *VpnTrans; + vpnplace_list *WaitPlace; + vpnplace_list *BeginPlace; + vpnplace_list *DefPlace; + vpnplace_list *VpnPlace; + vpnplace_list *EndPlace; + vpnact_list *VpnAct; + vpnact_list *VpnNextAct; + vpnarc *VpnArc; + vexexpr *DefAtom; + vexexpr *VexGuard; + chain_list *ScanTrans; + chain_list **PrevTrans; + chain_list *NewTrans; + chain_list *OldTransList; + chain_list *NewTransList; + chain_list **PrevTransList; + char *AtomValue; + authelem *Element; + int NumberTrans; + short CheckLoop; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyRedWaitLateralWait %s\n", WaitTrans->NAME ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + VpnArc = GetVpnArc( WaitTrans->PLACE_IN ); + WaitPlace = GetVpnArcSourcePlace( VpnArc ); + VpnArc = GetVpnArc( WaitTrans->PLACE_OUT ); + BeginPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( BeginPlace->NUMBER_OUT <= 1 ) return; + + if ( VasyHashAssign == (authtable *)0 ) + { + VasyHashAssign = createauthtable( 100 ); + VasyHashRenDef = createauthtable( 100 ); + } +/* +** Rename all defines for all transition +*/ + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + VasyRedWaitRenameDefine( VpnFigure, VpnProc, VpnAct ); + + } + + VasyRedWaitRenameVex( VpnTrans->VEX_GUARD ); + + resetauthtable( VasyHashRenDef ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } +/* +** Move all defines assignment on the define transition +*/ + DefTrans = VasyRedWaitAddVpnTrans(); + DefPlace = VasyRedWaitAddVpnPlace(); + + addvpnarcplace( VpnFigure, DefPlace, DefTrans ); + + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + VpnAct = VpnTrans->ACT; + + while ( VpnAct != (vpnact_list *)0 ) + { + VpnNextAct = VpnAct->NEXT; + + if ( VpnAct->TYPE == VPN_ACT_ASG_DEFINE ) + { + DefAtom = VpnAct->VEX_ATOM; + AtomValue = GetVexAtomValue( DefAtom ); + + Element = searchauthelem( VasyHashAssign, AtomValue ); + + if ( Element == (authelem *)0 ) + { + *VpnAct->PREV = VpnNextAct; + + if ( VpnNextAct != (vpnact_list *)0 ) + { + VpnNextAct->PREV = VpnAct->PREV; + } + else + { + VpnTrans->LAST_ACT = VpnAct->PREV; + } + + *DefTrans->LAST_ACT = VpnAct; + VpnAct->PREV = DefTrans->LAST_ACT; + VpnAct->NEXT = (vpnact_list *)0; + DefTrans->LAST_ACT = &VpnAct->NEXT; + + addauthelem( VasyHashAssign, AtomValue, (long)VpnAct ); + } + else + { + delvpnact( VpnFigure, VpnTrans, VpnAct ); + } + } + + VpnAct = VpnNextAct; + } + } + + resetauthtable( VasyHashAssign ); + + NewTransList = (chain_list *)0; + PrevTransList = &NewTransList; + OldTransList = BeginPlace->TRANS_OUT; + + BeginPlace->TRANS_OUT = (chain_list *)0; + BeginPlace->NUMBER_OUT = 0; + + NumberTrans = 0; + + if ( ProcInfo->NUMBER_WAIT > 1 ) CheckLoop = 1; + else CheckLoop = 0; + + while ( OldTransList != (chain_list *)0 ) + { + PrevTrans = &OldTransList; + ScanTrans = OldTransList; + EndPlace = (vpnplace_list *)0; + + while ( ScanTrans != (chain_list *)0 ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( ( VpnTrans->TYPE != VPN_TRANS_GUARDED ) && + ( VpnTrans->TYPE != VPN_TRANS_ACT_GUARDED ) ) + { + VasyPrintf( stdout, "ERROR Should not happen %s!!!\n", + VPN_TRANS_TYPE[ VpnTrans->TYPE ] ); + autexit( 1 ); + } + + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( ( ( EndPlace == (vpnplace_list *)0 ) || + ( VpnPlace == EndPlace ) ) && + ( ( ! CheckLoop ) || + ( VpnPlace != WaitPlace ) || + ( VpnTrans->ACT == (vpnact_list *)0 ) ) ) + { + EndPlace = VpnPlace; + NewTrans = ScanTrans; + + *PrevTrans = ScanTrans->NEXT; + ScanTrans = ScanTrans->NEXT; + + NewTrans->NEXT = BeginPlace->TRANS_OUT; + BeginPlace->TRANS_OUT = NewTrans; + BeginPlace->NUMBER_OUT++; + } + else + { + PrevTrans = &ScanTrans->NEXT; + ScanTrans = ScanTrans->NEXT; + } + } + + if ( EndPlace == (vpnplace_list *)0 ) + { + CheckLoop = 0; continue; + } + + if ( EndPlace == WaitPlace ) + { + CheckLoop = 0; + } + + VasyRedInstLateralWait( VpnFigure, VpnProc, BeginPlace, EndPlace ); + + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + VpnAct = VpnTrans->ACT; + + while ( VpnAct != (vpnact_list *)0 ) + { + VpnNextAct = VpnAct->NEXT; + + if ( VpnAct->TYPE == VPN_ACT_ASG_DEFINE ) + { + DefAtom = VpnAct->VEX_ATOM; + AtomValue = GetVexAtomValue( DefAtom ); + + *VpnAct->PREV = VpnNextAct; + + if ( VpnNextAct != (vpnact_list *)0 ) + { + VpnNextAct->PREV = VpnAct->PREV; + } + else + { + VpnTrans->LAST_ACT = VpnAct->PREV; + } + + *DefTrans->LAST_ACT = VpnAct; + VpnAct->PREV = DefTrans->LAST_ACT; + VpnAct->NEXT = (vpnact_list *)0; + DefTrans->LAST_ACT = &VpnAct->NEXT; + } + + VpnAct = VpnNextAct; + } + + NewTrans = BeginPlace->TRANS_OUT; + *PrevTransList = NewTrans; + PrevTransList = &NewTrans->NEXT; + + BeginPlace->TRANS_OUT = (chain_list *)0; + BeginPlace->NUMBER_OUT = 0; + + NumberTrans++; + } + + BeginPlace->TRANS_OUT = NewTransList; + BeginPlace->NUMBER_OUT = NumberTrans; + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + if ( BeginPlace->NUMBER_OUT == 1 ) + { + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + freevexexpr( VpnTrans->VEX_GUARD ); + VpnTrans->VEX_GUARD = (vexexpr *)0; + + if ( ( VpnTrans->ACT != (vpnact_list *)0 ) || + ( DefTrans->ACT != (vpnact_list *)0 ) ) VpnTrans->TYPE = VPN_TRANS_ACT_EXEC; + else VpnTrans->TYPE = VPN_TRANS_IMMEDIATE; + } + else + { + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + VexGuard = VpnTrans->VEX_GUARD; + + if ( ! IsVasyRedInstGuardAtomic( VexGuard ) ) + { + DefDeclar = VasyRedActAddVpnDefine( VpnFigure, VpnProc, 1, VEX_TYPE_BOOLEAN ); + + DefAtom = dupvexnode( DefDeclar->VEX_ATOM ); + VpnTrans->VEX_GUARD = dupvexnode( DefAtom ); + + VpnAct = addvpnactasg( VpnFigure, DefTrans, DefAtom, VexGuard ); + } + } + } + + if ( DefTrans->ACT != (vpnact_list *)0 ) + { + if ( BeginPlace->NUMBER_OUT > 1 ) + { + VpnArc = GetVpnArc( WaitTrans->PLACE_OUT ); + delvpnarc( VpnFigure, VpnArc ); + + addvpnarctrans( VpnFigure, WaitTrans, DefPlace ); + addvpnarctrans( VpnFigure, DefTrans , BeginPlace ); + + DefTrans->TYPE = VPN_TRANS_ACT_EXEC; + } + else + { + VpnArc = GetVpnArc( BeginPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( VpnTrans->ACT != (vpnact_list *)0 ) + { + *DefTrans->LAST_ACT = VpnTrans->ACT; + VpnTrans->ACT->PREV = DefTrans->LAST_ACT; + } + else + { + VpnTrans->LAST_ACT = DefTrans->LAST_ACT; + } + + VpnTrans->ACT = DefTrans->ACT; + VpnTrans->ACT->PREV = &VpnTrans->ACT; + + DefTrans->ACT = (vpnact_list *)0; + DefTrans->LAST_ACT = &DefTrans->ACT; + } + } + + if ( DefTrans->ACT == (vpnact_list *)0 ) + { + delvpntrans( VpnFigure, DefTrans ); + delvpnplace( VpnFigure, DefPlace ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VasyFigure ); + VasyPrintf( stdout, " <-- VasyRedWaitLateralWait %s\n", WaitTrans->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasyRedWait2WaitVpnProc | +| | +\------------------------------------------------------------*/ + +static int VasyRedWait2WaitVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vasyprocinfo *ProcInfo; + vpntrans_list *VpnTrans; + vpntrans_list *DelTrans; + vpnplace_list *VpnPlace; + vpnplace_list *DelPlace; + vpnarc *VpnArc; + long NumberTrans; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyRedWait2WaitVpnProc %s\n", VpnProc->NAME ); + } + + VasyFigure = VpnFigure; + VasyProcess = VpnProc; + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + NumberTrans = 0; + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) ProcInfo->NUMBER_WAIT++; + else NumberTrans++; + } +/* +** Is a reduction is needed ? +*/ + if ( ( ProcInfo->NUMBER_WAIT == 1 ) && + ( NumberTrans <= 1 ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " No reduction is needed for %s\n", VpnProc->NAME ); + } + + if ( VpnProc->TRANS == (vpntrans_list *)0 ) + { + VasyErrorLine( VASY_NO_WAIT_IN_PROCESS_ERROR, VpnProc->LINE, VpnProc->NAME ); + } + + return( 1 ); + } + + for ( VpnPlace = VpnProc->PLACE; + VpnPlace != (vpnplace_list *)0; + VpnPlace = VpnPlace->NEXT ) + { + SetVasyRedWaitDelete( VpnPlace ); + } +/* +** Initialization of all the wait transition +*/ + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VpnArc = GetVpnArc( VpnTrans->PLACE_IN ); + VpnPlace = GetVpnArcSourcePlace( VpnArc ); + ClearVasyRedWaitDelete( VpnPlace ); + + VpnPlace = VasyRedWaitAddVpnPlace(); + SetVasyRedWaitPlace( VpnTrans, VpnPlace ); + } + else + { + SetVasyRedWaitDelete( VpnTrans ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + if ( VasyHashStackTrans == (authtable *)0 ) + { + VasyHashStackTrans = createauthtable( 100 ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VasyRedWait2WaitVpnTrans( VpnTrans ); + } + } + + resetauthtable( VasyHashStackTrans ); + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VpnPlace = GetVasyRedWaitPlace( VpnTrans ); + ClearVasyRedWaitPlace( VpnTrans ); + + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + delvpnarc( VpnFigure, VpnArc ); + + addvpnarctrans( VpnFigure, VpnTrans, VpnPlace ); + } + } + + VpnTrans = VpnProc->TRANS; + + while ( VpnTrans != (vpntrans_list *)0 ) + { + DelTrans = VpnTrans; + VpnTrans = VpnTrans->NEXT; + + if ( IsVasyRedWaitDelete( DelTrans ) ) + { + delvpntrans( VpnFigure, DelTrans ); + } + } + + VpnPlace = VpnProc->PLACE; + + while ( VpnPlace != (vpnplace_list *)0 ) + { + DelPlace = VpnPlace; + VpnPlace = VpnPlace->NEXT; + + if ( IsVasyRedWaitDelete( DelPlace ) ) + { + delvpnplace( VpnFigure, DelPlace ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VasyRedWaitLateralWait( VpnFigure, VpnProc, VpnTrans ); + } + } + + if ( VpnProc->TRANS == (vpntrans_list *)0 ) + { + VasyErrorLine( VASY_NO_WAIT_IN_PROCESS_ERROR, VpnProc->LINE, VpnProc->NAME ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " <-- VasyRedWait2WaitVpnProc %s\n", VpnProc->NAME ); + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyRedWaitVpnProc | +| | +\------------------------------------------------------------*/ + +int VasyRedWaitVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + int Reduced; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasyRedWaitVpnProc\n" ); + VasyDebugSaveVpnFig( VpnFigure ); + } +/* +** Reduce Wait to Wait +*/ + Reduced = VasyRedWait2WaitVpnProc( VpnFigure, VpnProc ); +/* +** Delete All Driver attributes on all assignment statement +*/ + VasyRedWaitDelDriverVpnProc( VpnFigure, VpnProc ); + + if ( IsVasyDebugLevel0() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + VasyPrintf( stdout, " <-- VasyRedWaitVpnProc\n" ); + } + + return( Reduced ); +} diff --git a/alliance/src/vasy/src/vasy_redwait.h b/alliance/src/vasy/src/vasy_redwait.h new file mode 100644 index 00000000..ce54fd1c --- /dev/null +++ b/alliance/src/vasy/src/vasy_redwait.h @@ -0,0 +1,114 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_redwait.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_REDWAIT_H +# define VASY_REDWAIT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_REDWAIT_DEL_MASK (long)0x01 +# define VASY_REDWAIT_TAG_MASK (long)0x02 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Delete | +| | +\------------------------------------------------------------*/ + +# define SetVasyRedWaitDelete( O ) ((O)->FLAGS |= VASY_REDWAIT_DEL_MASK) +# define ClearVasyRedWaitDelete( O ) ((O)->FLAGS &= ~VASY_REDWAIT_DEL_MASK) +# define IsVasyRedWaitDelete( O ) ((O)->FLAGS & VASY_REDWAIT_DEL_MASK) + +/*------------------------------------------------------------\ +| | +| Tag | +| | +\------------------------------------------------------------*/ + +# define SetVasyRedWaitTag( O ) ((O)->FLAGS |= VASY_REDWAIT_TAG_MASK) +# define ClearVasyRedWaitTag( O ) ((O)->FLAGS &= ~VASY_REDWAIT_TAG_MASK) +# define IsVasyRedWaitTag( O ) ((O)->FLAGS & VASY_REDWAIT_TAG_MASK) + +/*------------------------------------------------------------\ +| | +| Place | +| | +\------------------------------------------------------------*/ + +# define SetVasyRedWaitPlace( T, P ) ((T)->USER = (void *)P ) +# define GetVasyRedWaitPlace( T ) ((vpnplace_list *)(T)->USER) +# define ClearVasyRedWaitPlace( T ) ((T)->USER = (void *)0 ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ + + typedef struct vasystack_list + { + struct vasystack_list *NEXT; + struct vasystack_list *PREV; + vpntrans_list *TRANS; + + } vasystack_list; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern int VasyRedWaitVpnProc(); + +# endif diff --git a/alliance/src/vasy/src/vasy_shared.c b/alliance/src/vasy/src/vasy_shared.c new file mode 100644 index 00000000..6705cd39 --- /dev/null +++ b/alliance/src/vasy/src/vasy_shared.c @@ -0,0 +1,402 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_shared.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_error.h" +# include "vasy_shared.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + char *VASY_SYM_TYPE[ VASY_MAX_SYM_TYPE ] = + { + "UNKNOWN", + "UNUSED", + "CONSTANT", + "COMBINATORIAL", + "TRISTATE", + "REGISTER" + }; + + char *VasyPowerVdd = (char *)0; + char *VasyPowerVss = (char *)0; + + int VasyFlagDebug = 0; + int VasyFlagOption = 0; + int VasyFlagDrive = 2; + int VasyFlagVerbose = 0; + int VasyFlagHier = 0; + int VasyFlagOver = 0; + int VasyFlagStdLogic = 0; + int VasyFlagInitial = 0; + int VasyFlagPower = 0; + int VasyFlagCLA = 0; + int VasyFlagEqual = 0; + int VasyFlagLax = 0; + int VasyFlagBoom = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyAddVpnProcInfo | +| | +\------------------------------------------------------------*/ + +vasyprocinfo *VasyAddVpnProcInfo( VpnProc ) + + vpnproc_list *VpnProc; +{ + vasyprocinfo *ProcInfo; + + ProcInfo = (vasyprocinfo *)autallocheap( sizeof( vasyprocinfo ) ); + + SetVasyVpnProcInfo( VpnProc, ProcInfo ); + + return( ProcInfo ); +} + +/*------------------------------------------------------------\ +| | +| VasyDelVpnProcInfo | +| | +\------------------------------------------------------------*/ + +void VasyDelVpnProcInfo( VpnProc ) + + vpnproc_list *VpnProc; +{ + vasyprocinfo *ProcInfo; + vasybivex_list *ProcBiVex; + vasybivex_list *DelProcBiVex; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + ProcBiVex = ProcInfo->BIVEX; + + while ( ProcBiVex != (vasybivex_list *)0 ) + { + freevexexpr( ProcBiVex->VEX_COND ); + freevexexpr( ProcBiVex->VEX_DATA ); + + DelProcBiVex = ProcBiVex; + ProcBiVex = ProcBiVex->NEXT; + + autfreeheap( DelProcBiVex, sizeof( vasybivex_list ) ); + } + + autfreeheap( ProcInfo, sizeof( vasyprocinfo ) ); + + SetVasyVpnProcInfo( VpnProc, (vasyprocinfo *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyAddVpnActInfo | +| | +\------------------------------------------------------------*/ + +vasyactinfo *VasyAddVpnActInfo( VpnAction ) + + vpnact_list *VpnAction; +{ + vasyactinfo *ActInfo; + vexexpr *AsgAtom; + chain_list **Support; + chain_list **Literal; + chain_list **Event; + vasysyminfo *SymInfo; + unsigned char *Flags; + short Width; + + AsgAtom = VpnAction->VEX_ATOM; + Width = AsgAtom->WIDTH; + + ActInfo = (vasyactinfo *)autallocheap( sizeof( vasyactinfo ) ); + + Support = (chain_list **)autallocblock( sizeof( chain_list *) * Width ); + Literal = (chain_list **)autallocblock( sizeof( chain_list *) * Width ); + Event = (chain_list **)autallocblock( sizeof( chain_list *) * Width ); + Flags = (unsigned char *)autallocblock( sizeof( char ) * Width ); + SymInfo = (vasysyminfo *)autallocblock( sizeof( vasysyminfo ) * Width ); + + ActInfo->SUPPORT = Support; + ActInfo->LITERAL = Literal; + ActInfo->EVENT = Event; + ActInfo->FLAGS = Flags; + ActInfo->SYM_INFO = SymInfo; + + SetVasyVpnActInfo( VpnAction, ActInfo ); + + return( ActInfo ); +} + +/*------------------------------------------------------------\ +| | +| VasyDelVpnActInfo | +| | +\------------------------------------------------------------*/ + +void VasyDelVpnActInfo( VpnAction ) + + vpnact_list *VpnAction; +{ + vasyactinfo *ActInfo; + vexexpr *AsgAtom; + chain_list **Support; + chain_list **Literal; + chain_list **Event; + unsigned char *Flags; + vasysyminfo *SymInfo; + vasybivex_list *SymBiVex; + vasybivex_list *DelSymBiVex; + int Index; + + ActInfo = GetVasyVpnActInfo( VpnAction ); + + AsgAtom = VpnAction->VEX_ATOM; + Support = ActInfo->SUPPORT; + Literal = ActInfo->LITERAL; + Event = ActInfo->EVENT; + Flags = ActInfo->FLAGS; + SymInfo = ActInfo->SYM_INFO; + + for ( Index = 0; Index < AsgAtom->WIDTH; Index++ ) + { + freechain( Support[ Index ] ); + freechain( Literal[ Index ] ); + + SymBiVex = SymInfo[ Index ].BIVEX; + + while ( SymBiVex != (vasybivex_list *)0 ) + { + freevexexpr( SymBiVex->VEX_COND ); + freevexexpr( SymBiVex->VEX_DATA ); + + DelSymBiVex = SymBiVex; + SymBiVex = SymBiVex->NEXT; + + autfreeheap( DelSymBiVex, sizeof( vasybivex_list ) ); + } + + freevexexpr( SymInfo[ Index ].VEX_DATA ); + } + + autfreeblock( Support ); + autfreeblock( Literal ); + autfreeblock( Event ); + autfreeblock( Flags ); + autfreeblock( SymInfo ); + + autfreeheap( ActInfo, sizeof( vasyactinfo ) ); + + SetVasyVpnActInfo( VpnAction, (vasyactinfo *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyAddVpnWaitInfo | +| | +\------------------------------------------------------------*/ + +vasywaitinfo *VasyAddVpnWaitInfo( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + vasywaitinfo *WaitInfo; + + WaitInfo = (vasywaitinfo *)autallocheap( sizeof( vasywaitinfo ) ); + SetVasyVpnWaitInfo( VpnTrans, WaitInfo ); + + return( WaitInfo ); +} + +/*------------------------------------------------------------\ +| | +| VasyDelVpnWaitInfo | +| | +\------------------------------------------------------------*/ + +void VasyDelVpnWaitInfo( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + vasywaitinfo *WaitInfo; + + WaitInfo = GetVasyVpnWaitInfo( VpnTrans ); + autfreeheap( WaitInfo, sizeof( vasywaitinfo ) ); + + SetVasyVpnWaitInfo( VpnTrans, (vasywaitinfo *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyAddVpnTransInfo | +| | +\------------------------------------------------------------*/ + +vasytransinfo *VasyAddVpnTransInfo( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + + TransInfo = (vasytransinfo *)autallocheap( sizeof( vasytransinfo ) ); + + TransInfo->HASH_ASSIGN = createauthtable( 100 ); + TransInfo->HASH_BITVEC = createauthtable( 100 ); + TransInfo->HASH_SUPPORT = createauth2table( 100 ); + TransInfo->HASH_LITERAL = createauth2table( 100 ); + TransInfo->HASH_EVENT = createauth2table( 100 ); + + SetVasyVpnTransInfo( VpnTrans, TransInfo ); + + return( TransInfo ); +} + +/*------------------------------------------------------------\ +| | +| VasyDelVpnTransInfo | +| | +\------------------------------------------------------------*/ + +void VasyDelVpnTransInfo( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + + destroyauthtable( TransInfo->HASH_ASSIGN ); + destroyauthtable( TransInfo->HASH_BITVEC ); + destroyauth2table( TransInfo->HASH_SUPPORT ); + destroyauth2table( TransInfo->HASH_LITERAL ); + destroyauth2table( TransInfo->HASH_EVENT ); + + autfreeheap( TransInfo, sizeof( vasytransinfo ) ); + + SetVasyVpnTransInfo( VpnTrans, (vasytransinfo *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyAddVpnSymBiVex | +| | +\------------------------------------------------------------*/ + +vasybivex_list *VasyAddVpnSymBiVex( SymInfo, VexCond, VexData, Type ) + + vasysyminfo *SymInfo; + vexexpr *VexCond; + vexexpr *VexData; + int Type; +{ + vasybivex_list *SymBiVex; + + SymBiVex = (vasybivex_list *)autallocheap( sizeof( vasybivex_list ) ); + + SymBiVex->VEX_COND = VexCond; + SymBiVex->VEX_DATA = VexData; + SymBiVex->TYPE = Type; + + SymBiVex->NEXT = SymInfo->BIVEX; + SymInfo->BIVEX = SymBiVex; + + return( SymBiVex ); +} + +/*------------------------------------------------------------\ +| | +| VasyAddVpnProcBiVex | +| | +\------------------------------------------------------------*/ + +vasybivex_list *VasyAddVpnProcBiVex( ProcInfo, VexCond, VexData, Type ) + + vasyprocinfo *ProcInfo; + vexexpr *VexCond; + vexexpr *VexData; + int Type; +{ + vasybivex_list *SymBiVex; + + SymBiVex = (vasybivex_list *)autallocheap( sizeof( vasybivex_list ) ); + + SymBiVex->VEX_COND = VexCond; + SymBiVex->VEX_DATA = VexData; + SymBiVex->TYPE = Type; + + SymBiVex->NEXT = ProcInfo->BIVEX; + ProcInfo->BIVEX = SymBiVex; + + return( SymBiVex ); +} diff --git a/alliance/src/vasy/src/vasy_shared.h b/alliance/src/vasy/src/vasy_shared.h new file mode 100644 index 00000000..d0b1e115 --- /dev/null +++ b/alliance/src/vasy/src/vasy_shared.h @@ -0,0 +1,335 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_shared.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_SHARED_H +# define VASY_SHARED_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Process Flags | +| | +\------------------------------------------------------------*/ + +# define VASY_PROC_TO_ANALYSE_MASK 0x1 + +/*------------------------------------------------------------\ +| | +| Process Type | +| | +\------------------------------------------------------------*/ + +# define VASY_PROC_UNKNOWN 0 +# define VASY_PROC_UNUSED 1 +# define VASY_PROC_DATA_FLOW 2 +# define VASY_PROC_FSM 3 +# define VASY_PROC_FSM_OUTREG 4 +# define VASY_MAX_VPN_PROC_TYPE 5 + +/*------------------------------------------------------------\ +| | +| Rtl Declar Type Mask | +| | +\------------------------------------------------------------*/ + +# define VASY_RTL_DECL_COMBINATORIAL 0x0100 +# define VASY_RTL_DECL_TRISTATE 0x0200 +# define VASY_RTL_DECL_PULL_UP 0x0400 +# define VASY_RTL_DECL_PULL_DOWN 0x0800 +# define VASY_RTL_DECL_REGISTER 0x1000 + +# define VASY_RTL_VERILOG_REG_MASK 0x2000 + +/*------------------------------------------------------------\ +| | +| Symbol Type | +| | +\------------------------------------------------------------*/ + +# define VASY_SYM_UNKNOWN 0 +# define VASY_SYM_UNUSED 1 +# define VASY_SYM_CONSTANT 2 +# define VASY_SYM_COMBINATORIAL 3 +# define VASY_SYM_TRISTATE 4 +# define VASY_SYM_PULL_UP 5 +# define VASY_SYM_PULL_DOWN 6 +# define VASY_SYM_REGISTER 7 + +# define VASY_MAX_SYM_TYPE 8 + +/*------------------------------------------------------------\ +| | +| Symbol Register Type | +| | +\------------------------------------------------------------*/ + +# define VASY_SYM_REGISTER_NONE 0 +# define VASY_SYM_REGISTER_SYNC 1 +# define VASY_SYM_REGISTER_ASYNC 2 +# define VASY_SYM_REGISTER_MIXED 3 + +# define VASY_MAX_SYM_REGISTER TYPE 4 + +/*------------------------------------------------------------\ +| | +| Bi Vex Type | +| | +\------------------------------------------------------------*/ + +# define VASY_BIVEX_FALLING_EDGE RTL_BIVEX_FALLING_EDGE +# define VASY_BIVEX_RISING_EDGE RTL_BIVEX_RISING_EDGE +# define VASY_BIVEX_ASYNC_RESET RTL_BIVEX_ASYNC_RESET +# define VASY_BIVEX_ASYNC_SET RTL_BIVEX_ASYNC_SET +# define VASY_BIVEX_ASYNC_WEN RTL_BIVEX_ASYNC_WEN +# define VASY_BIVEX_SYNC_RESET RTL_BIVEX_SYNC_RESET +# define VASY_BIVEX_SYNC_SET RTL_BIVEX_SYNC_SET +# define VASY_BIVEX_SYNC_WEN RTL_BIVEX_SYNC_WEN +# define VASY_MAX_BIVEX_TYPE RTL_MAX_BIVEX_TYPE + +# define VASY_BIVEX_TYPE RTL_BIVEX_TYPE + +/*------------------------------------------------------------\ +| | +| Action Flags | +| | +\------------------------------------------------------------*/ + +# define VASY_ACT_USED_MASK 0x1 +# define VASY_ACT_ARITH_MASK 0x2 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Process Analysis | +| | +\------------------------------------------------------------*/ + +# define IsVasyVpnProcToAnalyse( P ) ( (P)->FLAGS & VASY_PROC_TO_ANALYSE_MASK ) +# define SetVasyVpnProcToAnalyse( P ) ( (P)->FLAGS |= VASY_PROC_TO_ANALYSE_MASK ) +# define ClearVasyVpnProcToAnalyse( P ) ( (P)->FLAGS &= ~VASY_PROC_TO_ANALYSE_MASK) + +/*------------------------------------------------------------\ +| | +| Rtl Declar Type | +| | +\------------------------------------------------------------*/ + +# define SetVasyRtlDeclType( D, T ) ((D)->FLAGS |= (long)(T)) +# define IsVasyRtlDeclType( D, T ) ((D)->FLAGS & (long)(T)) + +# define SetVasyRtlDeclVerilogReg( D ) ((D)->FLAGS |= VASY_RTL_VERILOG_REG_MASK) +# define IsVasyRtlDeclVerilogReg( D ) ((D)->FLAGS & VASY_RTL_VERILOG_REG_MASK) + +/*------------------------------------------------------------\ +| | +| Proc Info | +| | +\------------------------------------------------------------*/ + +# define SetVasyVpnProcInfo( P, I ) ((P)->USER = (void *)(I)) +# define GetVasyVpnProcInfo( P ) ((vasyprocinfo *)(P)->USER) + +/*------------------------------------------------------------\ +| | +| Act Info | +| | +\------------------------------------------------------------*/ + +# define SetVasyVpnActInfo( A, I ) ((A)->USER = (void *)(I)) +# define GetVasyVpnActInfo( A ) ((vasyactinfo *)(A)->USER) + +# define GetVasyVpnActInfoSupport( A ) (((vasyactinfo *)(A)->USER)->SUPPORT) +# define GetVasyVpnActInfoFlags( A ) (((vasyactinfo *)(A)->USER)->FLAGS) +# define GetVasyVpnActInfoLiteral( A ) (((vasyactinfo *)(A)->USER)->LITERAL) +# define GetVasyVpnActInfoEvent( A ) (((vasyactinfo *)(A)->USER)->EVENT) + +# define SetVasyVpnActInfoUsed( F ) ( (F) |= VASY_ACT_USED_MASK ) +# define SetVasyVpnActInfoArith( F ) ( (F) |= VASY_ACT_ARITH_MASK ) + +# define ClearVasyVpnActInfoUsed( F ) ( (F) &= ~VASY_ACT_USED_MASK ) +# define ClearVasyVpnActInfoArith( F ) ( (F) &= ~VASY_ACT_ARITH_MASK ) + +# define IsVasyVpnActInfoUsed( F ) ( (F) & VASY_ACT_USED_MASK ) +# define IsVasyVpnActInfoArith( F ) ( (F) & VASY_ACT_ARITH_MASK ) + +/*------------------------------------------------------------\ +| | +| Trans Info | +| | +\------------------------------------------------------------*/ + +# define SetVasyVpnTransInfo( T, I ) ((T)->USER = (void *)(I)) +# define GetVasyVpnTransInfo( T ) ((vasytransinfo *)(T)->USER) + +# define SetVasyVpnWaitInfo( T, I ) ((T)->USER = (void *)(I)) +# define GetVasyVpnWaitInfo( T ) ((vasywaitinfo *)(T)->USER) + +/*------------------------------------------------------------\ +| | +| Sym Info | +| | +\------------------------------------------------------------*/ + +# define SetVasyVpnSymInfo( S, I ) ((S)->USER = (void *)(I)) +# define GetVasyVpnSymInfo( S ) ((vasysyminfo *)(S)->USER) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ + + typedef struct vasybivex_list + { + struct vasybivex_list *NEXT; + vexexpr *VEX_COND; + vexexpr *VEX_DATA; + unsigned char TYPE; + + } vasybivex_list; + + typedef struct vasyprocinfo + { + long NUMBER_WAIT; + long NUMBER_ACTION; + bddcircuit *BDD_CIRCUIT; + bddsystem *BDD_SYSTEM; + bddnode **BDD_LITERAL; + authtable *HASH_ABL2SYM; + authtable *HASH_SYM2ABL; + vasybivex_list *BIVEX; + unsigned char TYPE; + + } vasyprocinfo; + + typedef struct vasywaitinfo + { + vpntrans_list *DEF_TRANS; + vpntrans_list *LOOP_TRANS; + vpnplace_list *WAIT_PLACE; + + } vasywaitinfo; + + typedef struct vasytransinfo + { + authtable *HASH_ASSIGN; + authtable *HASH_BITVEC; + auth2table *HASH_SUPPORT; + auth2table *HASH_LITERAL; + auth2table *HASH_EVENT; + + } vasytransinfo; + + + typedef struct vasysyminfo + { + vexexpr *VEX_DATA; + vasybivex_list *BIVEX; + unsigned char TYPE; + unsigned char TRS_TYPE; + unsigned char REG_TYPE; + + } vasysyminfo; + + typedef struct vasyactinfo + { + chain_list **SUPPORT; + chain_list **LITERAL; + chain_list **EVENT; + vasysyminfo *SYM_INFO; + unsigned char *FLAGS; + unsigned char SPLIT; + + } vasyactinfo; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern char *VASY_SYM_TYPE[ VASY_MAX_SYM_TYPE ]; + + extern char *VasyPowerVdd; + extern char *VasyPowerVss; + + extern int VasyFlagDebug; + extern int VasyFlagOption; + extern int VasyFlagDrive; + extern int VasyFlagVerbose; + extern int VasyFlagHier; + extern int VasyFlagOver; + extern int VasyFlagStdLogic; + extern int VasyFlagInitial; + extern int VasyFlagPower; + extern int VasyFlagCLA; + extern int VasyFlagEqual; + extern int VasyFlagLax; + extern int VasyFlagBoom; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern vasyprocinfo *VasyAddVpnProcInfo(); + extern void VasyDelVpnProcInfo(); + + extern vasytransinfo *VasyAddVpnTransInfo(); + extern void VasyDelVpnTransInfo(); + + extern vasywaitinfo *VasyAddVpnWaitInfo(); + extern void VasyDelVpnWaitInfo(); + + extern vasyactinfo *VasyAddVpnActInfo(); + extern void VasyDelVpnActInfo(); + + extern vasybivex_list *VasyAddVpnSymBiVex(); + extern vasybivex_list *VasyAddVpnProcBiVex(); + +# endif diff --git a/alliance/src/vasy/src/vasy_simprtl.c b/alliance/src/vasy/src/vasy_simprtl.c new file mode 100644 index 00000000..16736b04 --- /dev/null +++ b/alliance/src/vasy/src/vasy_simprtl.c @@ -0,0 +1,1789 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_synth.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_support.h" +# include "vasy_shared.h" +# include "vasy_synth.h" +# include "vasy_simprtl.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static rtlfig_list *VasyFigure = (rtlfig_list *)0; + static rtlasg_list *VasyAsg = (rtlasg_list *)0; + static authtable *VasyHashRtlAsg = (authtable *)0; + static authtable *VasyHashOutAsg = (authtable *)0; + static long VasyNumberDef = 0; + + static short VasyOperatorSupported[ VEX_MAX_OPERATOR ] = + { + 1, /* VEX_CONCAT */ + 1, /* VEX_NOT */ + 1, /* VEX_NEG */ + 1, /* VEX_EVENT */ + 1, /* VEX_OR */ + 1, /* VEX_AND */ + 1, /* VEX_XOR */ + 1, /* VEX_NOR */ + 1, /* VEX_NAND */ + 1, /* 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 */ + 0, /* VEX_MUL */ + 0, /* VEX_DIV */ + 0, /* VEX_EXP */ + 1, /* 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 */ + 1, /* VEX_IFT */ + 0, /* VEX_ARRAY */ + 0, /* VEX_INDEX_N */ + 0, /* VEX_OTHERS */ + 0, /* VEX_NUM_BIT */ + 1 /* VEX_ABS */ + }; + + static char VasyBuffer[ 512 ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + static void VasySimplifySubstAsg(); + +/*------------------------------------------------------------\ +| | +| VasySimplifyHashRegisterAsg | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyHashRegisterAsg( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + vexexpr *VexAtom; + char *AtomName; + int VexMin; + int VexMax; + int VexIndex; + + if ( VasyHashRtlAsg == (authtable *)0 ) + { + VasyHashRtlAsg = createauthtable( 1000 ); + } + else + { + resetauthtable( VasyHashRtlAsg ); + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VexAtom = RtlAsg->VEX_ATOM; + AtomName = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + VexMin = getvexvectormin( VexAtom ); + VexMax = getvexvectormax( VexAtom ); + + if ( RtlAsg->TYPE == RTL_ASG_REGISTER ) + { + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + addauthelem( VasyHashRtlAsg, (char *)RtlSymbol, (long)RtlAsg ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyCompactRegister | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyCompactRegister( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg1; + rtlasg_list *RtlAsg2; + rtlbivex_list *ScanBiVex1; + rtlbivex_list *ScanBiVex2; + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + vexexpr *AsgAtom1; + vexexpr *AsgAtom2; + vexexpr *VexData1; + vexexpr *VexData2; + vexexpr *DeclAtom; + char *AtomName; + authelem *Element; + int AsgMax; + int DeclMax; + int VexMin; + int VexMax; + int VexWidth; + int VexIndex; + int Concat; + + RtlAsg1 = RtlFigure->ASSIGN; + + while ( RtlAsg1 != (rtlasg_list *)0 ) + { + if ( RtlAsg1->TYPE != RTL_ASG_REGISTER ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + AsgAtom1 = RtlAsg1->VEX_ATOM; + AsgMax = getvexvectormax( AsgAtom1 ); + + AtomName = GetVexAtomValue( AsgAtom1 ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + DeclAtom = RtlDeclar->VEX_ATOM; + DeclMax = getvexvectormax( DeclAtom ); + + if ( AsgMax >= DeclMax ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + RtlSymbol = getrtlsymdecl( RtlDeclar, AsgMax + 1 ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element == (authelem *)0 ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + RtlAsg2 = (rtlasg_list *)Element->VALUE; + + if ( RtlAsg1->REG_TYPE != RtlAsg2->REG_TYPE ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + Concat = 1; + + for ( ScanBiVex1 = RtlAsg1->BIVEX, + ScanBiVex2 = RtlAsg2->BIVEX; + ( ( ScanBiVex1 != (rtlbivex_list *)0 ) && + ( ScanBiVex2 != (rtlbivex_list *)0 ) ); + ScanBiVex1 = ScanBiVex1->NEXT, + ScanBiVex2 = ScanBiVex2->NEXT ) + { + if ( ScanBiVex1->TYPE != ScanBiVex2->TYPE ) + { + Concat = 0; break; + } + else + if ( ( ScanBiVex1->VEX_COND != (vexexpr *)0 ) && + ( ScanBiVex2->VEX_COND != (vexexpr *)0 ) ) + { + if ( ! isvexequalexpr( ScanBiVex1->VEX_COND, ScanBiVex2->VEX_COND ) ) + { + Concat = 0; break; + } + } + else + if ( ScanBiVex1->VEX_COND != ScanBiVex2->VEX_COND ) + { + Concat = 0; break; + } + } + + if ( ! Concat ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "Concat " ); + viewvexexpr( RtlAsg1->VEX_ATOM ); + fprintf( stdout, " & " ); + viewvexexprln( RtlAsg2->VEX_ATOM ); + } + + AsgAtom2 = RtlAsg2->VEX_ATOM; + + if ( IsVexAtomUp( DeclAtom ) ) + { + AsgAtom1 = createvexatomvec( AtomName, AsgAtom1->LEFT, AsgAtom2->RIGHT ); + } + else + { + AsgAtom1 = createvexatomvec( AtomName, AsgAtom2->LEFT, AsgAtom1->RIGHT ); + } + + freevexexpr( RtlAsg1->VEX_ATOM ); + RtlAsg1->VEX_ATOM = AsgAtom1; + + for ( ScanBiVex1 = RtlAsg1->BIVEX, + ScanBiVex2 = RtlAsg2->BIVEX; + ( ( ScanBiVex1 != (rtlbivex_list *)0 ) && + ( ScanBiVex2 != (rtlbivex_list *)0 ) ); + ScanBiVex1 = ScanBiVex1->NEXT, + ScanBiVex2 = ScanBiVex2->NEXT ) + { + VexData1 = ScanBiVex1->VEX_DATA; + + if ( VexData1 != (vexexpr *)0 ) + { + VexData2 = dupvexexpr( ScanBiVex2->VEX_DATA ); + VexWidth = VexData1->WIDTH + VexData2->WIDTH; + + if ( IsVexAtomUp( DeclAtom ) ) + { + VexData1 = optimvexbinexpr( VEX_CONCAT, VexWidth, VexData1, VexData2 ); + } + else + { + VexData1 = optimvexbinexpr( VEX_CONCAT, VexWidth, VexData2, VexData1 ); + } + + ScanBiVex1->VEX_DATA = simpvexexpr( VexData1 ); + } + } + + VexMin = getvexvectormin( AsgAtom1 ); + VexMax = getvexvectormax( AsgAtom1 ); + + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + addauthelem( VasyHashRtlAsg, (char *)RtlSymbol, (long)RtlAsg1 ); + } + + delrtlasg( RtlFigure, RtlAsg2 ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyViewHashTristateAsg | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyViewHashTristateAsg( Element ) + + authelem *Element; +{ + rtlasg_list *RtlAsg; + chain_list *ScanChain; + rtlsym *RtlSymbol; + + RtlSymbol = (rtlsym *)Element->KEY; + ScanChain = (chain_list *)Element->VALUE; + + fprintf( stdout, "RtlSymbol %s[%d]\n", RtlSymbol->NAME, RtlSymbol->INDEX ); + + while ( ScanChain != (chain_list *)0 ) + { + RtlAsg = (rtlasg_list *)ScanChain->DATA; + fprintf( stdout, "RtlAsg %lx\n", (long)RtlAsg ); + ScanChain = ScanChain->NEXT; + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyHashTristateAsg | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyHashTristateAsg( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + authelem *Element; + chain_list *HeadChain; + vexexpr *VexAtom; + char *AtomName; + int VexMin; + int VexMax; + int VexIndex; + + if ( VasyHashRtlAsg == (authtable *)0 ) + { + VasyHashRtlAsg = createauthtable( 1000 ); + } + else + { + resetauthtable( VasyHashRtlAsg ); + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VexAtom = RtlAsg->VEX_ATOM; + AtomName = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + VexMin = getvexvectormin( VexAtom ); + VexMax = getvexvectormax( VexAtom ); + + if ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) + { + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element == (authelem *)0 ) HeadChain = (chain_list *)0; + else HeadChain = (chain_list *)Element->VALUE; + + HeadChain = addchain( HeadChain, (void *)RtlAsg ); + addauthelem( VasyHashRtlAsg, (char *)RtlSymbol, (long)HeadChain ); + } + } + } + + if ( IsVasyDebugLevel1() ) + { + viewauthtable( VasyHashRtlAsg, VasySimplifyViewHashTristateAsg ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyFreeHashTristateAsg | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyFreeHashTristateAsg( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + vexexpr *VexAtom; + char *AtomName; + authelem *Element; + chain_list *HeadChain; + int VexMin; + int VexMax; + int VexIndex; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VexAtom = RtlAsg->VEX_ATOM; + AtomName = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + VexMin = getvexvectormin( VexAtom ); + VexMax = getvexvectormax( VexAtom ); + + if ( RtlAsg->TYPE == RTL_ASG_TRISTATE ) + { + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element != (authelem *)0 ) + { + HeadChain = (chain_list *)Element->VALUE; + + if ( HeadChain != (chain_list *)0 ) + { + Element->VALUE = 0; + freechain( HeadChain ); + } + } + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyCompactTristate | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyCompactTristate( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg1; + rtlasg_list *RtlAsg2; + rtlbivex_list *ScanBiVex1; + rtlbivex_list *ScanBiVex2; + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + vexexpr *AsgAtom1; + vexexpr *AsgAtom2; + vexexpr *VexData1; + vexexpr *VexData2; + vexexpr *DeclAtom; + char *AtomName; + chain_list *ScanChain; + chain_list *ReplChain; + authelem *Element; + int AsgMax; + int DeclMax; + int VexMin; + int VexMax; + int VexWidth; + int VexIndex; + int Concat; + + RtlAsg1 = RtlFigure->ASSIGN; + + while ( RtlAsg1 != (rtlasg_list *)0 ) + { + if ( RtlAsg1->TYPE != RTL_ASG_TRISTATE ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + AsgAtom1 = RtlAsg1->VEX_ATOM; + AsgMax = getvexvectormax( AsgAtom1 ); + + AtomName = GetVexAtomValue( AsgAtom1 ); + RtlDeclar = searchrtldecl( VasyFigure, AtomName ); + + DeclAtom = RtlDeclar->VEX_ATOM; + DeclMax = getvexvectormax( DeclAtom ); + + if ( AsgMax >= DeclMax ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + RtlSymbol = getrtlsymdecl( RtlDeclar, AsgMax + 1 ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element == (authelem *)0 ) + { + RtlAsg1 = RtlAsg1->NEXT; continue; + } + + Concat = 0; + + for ( ScanChain = (chain_list *)Element->VALUE; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + RtlAsg2 = (rtlasg_list *)ScanChain->DATA; + Concat = 1; + + for ( ScanBiVex1 = RtlAsg1->BIVEX, + ScanBiVex2 = RtlAsg2->BIVEX; + ( ( ScanBiVex1 != (rtlbivex_list *)0 ) && + ( ScanBiVex2 != (rtlbivex_list *)0 ) ); + ScanBiVex1 = ScanBiVex1->NEXT, + ScanBiVex2 = ScanBiVex2->NEXT ) + { + if ( ScanBiVex1->TYPE != ScanBiVex2->TYPE ) + { + Concat = 0; break; + } + else + if ( ( ScanBiVex1->VEX_COND != (vexexpr *)0 ) && + ( ScanBiVex2->VEX_COND != (vexexpr *)0 ) ) + { + if ( ! isvexequalexpr( ScanBiVex1->VEX_COND, ScanBiVex2->VEX_COND ) ) + { + Concat = 0; break; + } + } + else + if ( ScanBiVex1->VEX_COND != ScanBiVex2->VEX_COND ) + { + Concat = 0; break; + } + } + + if ( ! Concat ) continue; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "Concat " ); + viewvexexpr( RtlAsg1->VEX_ATOM ); + fprintf( stdout, " & " ); + viewvexexprln( RtlAsg2->VEX_ATOM ); + } + + AsgAtom2 = RtlAsg2->VEX_ATOM; + + if ( IsVexAtomUp( DeclAtom ) ) + { + AsgAtom1 = createvexatomvec( AtomName, AsgAtom1->LEFT, AsgAtom2->RIGHT ); + } + else + { + AsgAtom1 = createvexatomvec( AtomName, AsgAtom2->LEFT, AsgAtom1->RIGHT ); + } + + freevexexpr( RtlAsg1->VEX_ATOM ); + RtlAsg1->VEX_ATOM = AsgAtom1; + + for ( ScanBiVex1 = RtlAsg1->BIVEX, + ScanBiVex2 = RtlAsg2->BIVEX; + ( ( ScanBiVex1 != (rtlbivex_list *)0 ) && + ( ScanBiVex2 != (rtlbivex_list *)0 ) ); + ScanBiVex1 = ScanBiVex1->NEXT, + ScanBiVex2 = ScanBiVex2->NEXT ) + { + VexData1 = ScanBiVex1->VEX_DATA; + + if ( VexData1 != (vexexpr *)0 ) + { + VexData2 = dupvexexpr( ScanBiVex2->VEX_DATA ); + VexWidth = VexData1->WIDTH + VexData2->WIDTH; + + if ( IsVexAtomUp( DeclAtom ) ) + { + VexData1 = optimvexbinexpr( VEX_CONCAT, VexWidth, VexData1, VexData2 ); + } + else + { + VexData1 = optimvexbinexpr( VEX_CONCAT, VexWidth, VexData2, VexData1 ); + } + + ScanBiVex1->VEX_DATA = simpvexexpr( VexData1 ); + } + } + + VexMin = getvexvectormin( AsgAtom1 ); + VexMax = getvexvectormax( AsgAtom1 ); + + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + for ( ReplChain = (chain_list *)Element->VALUE; + ReplChain != (chain_list *)0; + ReplChain = ReplChain->NEXT ) + { + if ( ReplChain->DATA == (void *)RtlAsg2 ) + { + ReplChain->DATA = RtlAsg1; break; + } + } + } + + delrtlasg( RtlFigure, RtlAsg2 ); + + break; + } + + if ( ! Concat ) + { + RtlAsg1 = RtlAsg1->NEXT; + } + } + + VasySimplifyFreeHashTristateAsg( RtlFigure ); +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyDisplayRead | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyDisplayRead( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + vexexpr *VexAtom; + int VexIndex; + int Type; + + for ( Type = 0; Type < RTL_MAX_DECLAR_TYPE; Type++ ) + { + for ( RtlDeclar = RtlFigure->DECLAR[ Type ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + VasyPrintf( stdout, " %s --> Asg: %ld, Read: %ld\n", + RtlDeclar->DECL_SYM->NAME, + IsVasyRtlDeclarAsg( RtlDeclar ), + IsVasyRtlDeclarRead( RtlDeclar ) ); + + VexAtom = RtlDeclar->VEX_ATOM; + + for ( VexIndex = 0; VexIndex < VexAtom->WIDTH; VexIndex++ ) + { + RtlSymbol = &RtlDeclar->DECL_SYM[ VexIndex ]; + + VasyPrintf( stdout, " > %s[%d]\n +++ Asg: %ld, Read: %ld\n", + RtlSymbol->NAME, RtlSymbol->INDEX, + IsVasyRtlDeclarAsg( RtlSymbol ), + IsVasyRtlDeclarRead( RtlSymbol ) ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyDisplaySubst | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyDisplaySubst( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VasyPrintf( stdout, "NRead %ld ", GetVasyRtlAssignNumberRead( RtlAsg ) ); + viewvexexprln( RtlAsg->VEX_ATOM ); + + if ( IsVasyRtlAssignSubst( RtlAsg ) ) + { + VasyPrintf( stdout, " +++ Should substitute\n" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyMarkReadVex | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyMarkReadVex( Expr ) + + vexexpr *Expr; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + chain_list *ScanOper; + char *AtomName; + int VexMin; + int VexMax; + int VexIndex; + + if ( Expr == (vexexpr *)0 ) return; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( IsVexAtomLiteral( Expr ) ) return; + + AtomName = GetVexAtomValue( Expr ); + VexMin = getvexvectormin( Expr ); + VexMax = getvexvectormax( Expr ); + + RtlDeclar = searchrtldecl( VasyFigure, AtomName ); + SetVasyRtlDeclarRead( RtlDeclar ); + + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + SetVasyRtlDeclarRead( RtlSymbol ); + } + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasySimplifyMarkReadVex( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyMarkWriteVex | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyMarkWriteVex( Expr ) + + vexexpr *Expr; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + chain_list *ScanOper; + char *AtomName; + int VexMin; + int VexMax; + int VexIndex; + + if ( Expr == (vexexpr *)0 ) return; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( IsVexAtomLiteral( Expr ) ) return; + + AtomName = GetVexAtomValue( Expr ); + VexMin = getvexvectormin( Expr ); + VexMax = getvexvectormax( Expr ); + + RtlDeclar = searchrtldecl( VasyFigure, AtomName ); + SetVasyRtlDeclarAsg( RtlDeclar ); + + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + SetVasyRtlDeclarAsg( RtlSymbol ); + } + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasySimplifyMarkWriteVex( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyMarkAsgVex | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyMarkAsgVex( Expr ) + + vexexpr *Expr; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + vexexpr *AsgAtom; + vexexpr *AsgData; + chain_list *ScanOper; + char *AtomName; + authelem *Element; + int VexMin; + int VexMax; + int VexIndex; + + if ( Expr == (vexexpr *)0 ) return; + + if ( IsVexNodeAtom( Expr ) ) + { + if ( IsVexAtomLiteral( Expr ) ) return; + + AtomName = GetVexAtomValue( Expr ); + RtlDeclar = searchrtldecl( VasyFigure, AtomName ); + + VexMin = getvexvectormin( Expr ); + VexMax = getvexvectormax( Expr ); + + RtlSymbol = getrtlsymdecl( RtlDeclar, VexMin ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element != (authelem *)0 ) + { + RtlAsg = (rtlasg_list *)Element->VALUE; + AsgAtom = RtlAsg->VEX_ATOM; + AsgData = RtlAsg->VEX_DATA; + + IncVasyRtlAssignNumberRead( RtlAsg ); + + if ( ( AsgAtom->LEFT == Expr->LEFT ) && + ( AsgAtom->RIGHT == Expr->RIGHT ) ) + { + if ( GetVasyRtlAssignNumberRead( RtlAsg ) > 1 ) + { + if ( ! IsVexNodeAtom( AsgData ) ) + { + ClearVasyRtlAssignSubst( RtlAsg ); + } + } + } + else + { + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element != (authelem *)0 ) + { + RtlAsg = (rtlasg_list *)Element->VALUE; + ClearVasyRtlAssignSubst( RtlAsg ); + } + } + } + } + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + VasySimplifyMarkAsgVex( GetVexOperand( ScanOper ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifySubstVex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySimplifySubstVex( Expr ) + + vexexpr *Expr; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + vexexpr *Operand; + authelem *Element; + chain_list *ScanOper; + char *AtomName; + + if ( Expr != (vexexpr *)0 ) + { + if ( IsVexNodeAtom( Expr ) ) + { + if ( ! IsVexAtomLiteral( Expr ) ) + { + AtomName = GetVexAtomValue( Expr ); + RtlDeclar = searchrtldecl( VasyFigure, AtomName ); + + RtlSymbol = getrtlsymdecl( RtlDeclar, Expr->LEFT ); + Element = searchauthelem( VasyHashRtlAsg, (char *)RtlSymbol ); + + if ( Element != (authelem *)0 ) + { + RtlAsg = (rtlasg_list *)Element->VALUE; + + if ( IsVasyRtlAssignSubst( RtlAsg ) ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " Substitute %s[%d %d]\n", + AtomName, Expr->LEFT, Expr->RIGHT ); + } + + if ( ! IsVasyRtlAssignSubstDone( RtlAsg ) ) + { + VasySimplifySubstAsg( RtlAsg ); + } + + freevexexpr( Expr ); + Expr = dupvexexpr( RtlAsg->VEX_DATA ); + } + } + } + } + else + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = VasySimplifySubstVex( GetVexOperand( ScanOper ) ); + SetVexOperand( ScanOper, Operand ); + } + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimplifySubstAsg | +| | +\------------------------------------------------------------*/ + +static void VasySimplifySubstAsg( RtlAsg ) + + rtlasg_list *RtlAsg; +{ + rtlbivex_list *ScanBiVex; + + if ( ! IsVasyRtlAssignSubstDone( RtlAsg ) ) + { + SetVasyRtlAssignSubstDone( RtlAsg ); + + RtlAsg->VEX_DATA = VasySimplifySubstVex( RtlAsg->VEX_DATA ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + ScanBiVex->VEX_COND = VasySimplifySubstVex( ScanBiVex->VEX_COND ); + ScanBiVex->VEX_DATA = VasySimplifySubstVex( ScanBiVex->VEX_DATA ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyHashAsg | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyHashDefineAsg( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + vexexpr *VexAtom; + char *AtomName; + int VexMin; + int VexMax; + int VexIndex; + + if ( VasyHashRtlAsg == (authtable *)0 ) + { + VasyHashRtlAsg = createauthtable( 1000 ); + } + else + { + resetauthtable( VasyHashRtlAsg ); + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VexAtom = RtlAsg->VEX_ATOM; + AtomName = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + VexMin = getvexvectormin( VexAtom ); + VexMax = getvexvectormax( VexAtom ); + + if ( ( RtlAsg->TYPE == RTL_ASG_COMBINATORIAL ) && + ( RtlDeclar->TYPE == RTL_DECLAR_SIGNAL ) && + ( IsVasyRtlDeclarDefine( RtlDeclar ) ) ) + { + SetVasyRtlAssignSubst( RtlAsg ); + + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + + addauthelem( VasyHashRtlAsg, (char *)RtlSymbol, (long)RtlAsg ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifySubstDefine | +| | +\------------------------------------------------------------*/ + +static void VasySimplifySubstDefine( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlasg_list *RtlAsg; + rtlasg_list *DelAsg; + rtlbivex_list *ScanBiVex; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VasySimplifyMarkAsgVex( RtlAsg->VEX_DATA ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasySimplifyMarkAsgVex( ScanBiVex->VEX_COND ); + VasySimplifyMarkAsgVex( ScanBiVex->VEX_DATA ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasySimplifyDisplaySubst( RtlFigure ); + } + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VasySimplifySubstAsg( RtlAsg ); + } +/* +** Delete unused assignments +*/ + RtlAsg = RtlFigure->ASSIGN; + + while ( RtlAsg != (rtlasg_list *)0 ) + { + DelAsg = RtlAsg; + RtlAsg = RtlAsg->NEXT; + + if ( IsVasyRtlAssignSubst( DelAsg ) ) + { + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " Delete " ); + viewvexexprln( DelAsg->VEX_ATOM ); + } + + delrtlasg( RtlFigure, DelAsg ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyMarkRead | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyMarkRead( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtlport_list *RtlPort; + rtlsym *RtlSymbol; + rtlasg_list *RtlAsg; + rtlbivex_list *ScanBiVex; + rtlins_list *RtlInst; + rtlmap_list *RtlMap; + vexexpr *VexAtom; + char *AtomName; + int VexMin; + int VexMax; + int VexIndex; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VexAtom = RtlAsg->VEX_ATOM; + AtomName = GetVexAtomValue( VexAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + SetVasyRtlDeclarAsg( RtlDeclar ); + + VexMin = getvexvectormin( VexAtom ); + VexMax = getvexvectormax( VexAtom ); + + for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ ) + { + RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex ); + SetVasyRtlDeclarAsg( RtlSymbol ); + } + + VasySimplifyMarkReadVex( RtlAsg->VEX_DATA ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasySimplifyMarkReadVex( ScanBiVex->VEX_COND ); + VasySimplifyMarkReadVex( ScanBiVex->VEX_DATA ); + } + } + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + for ( RtlMap = RtlInst->MAP; + RtlMap != (rtlmap_list *)0; + RtlMap = RtlMap->NEXT ) + { + VexAtom = RtlMap->VEX_FORMAL; + + if ( IsVexNodeAtom( VexAtom ) ) + { + AtomName = GetVexAtomValue( VexAtom ); + RtlPort = searchrtlmodport( RtlFigure, RtlInst->MODEL, AtomName ); + + if ( RtlPort->DIR != RTL_DIR_OUT ) + { + VasySimplifyMarkReadVex( RtlMap->VEX_ACTUAL ); + } + + if ( RtlPort->DIR != RTL_DIR_IN ) + { + VasySimplifyMarkWriteVex( RtlMap->VEX_ACTUAL ); + } + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifySubstReadOutVex | +| | +\------------------------------------------------------------*/ + +static void VasySimplifySubstReadOutVex( VexExpr ) + + vexexpr *VexExpr; +{ + vexexpr *Operand; + char *AtomValue; + authelem *Element; + chain_list *ScanChain; + + if ( VexExpr != (vexexpr *)0 ) + { + if ( IsVexNodeAtom( VexExpr ) ) + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + Element = searchauthelem( VasyHashOutAsg, AtomValue ); + + if ( Element != (authelem *)0 ) + { + AtomValue = (char *)Element->VALUE; + SetVexAtomValue( VexExpr, AtomValue ); + } + } + } + else + { + for ( ScanChain = VexExpr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + VasySimplifySubstReadOutVex( Operand ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifySubstReadOut | +| | +\------------------------------------------------------------*/ + +static void VasySimplifySubstReadOut( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtldecl_list *RtlDeclar; + rtldecl_list *NewDeclar; + rtlasg_list *RtlAsg; + rtlasg_list *NewAsg; + rtlbivex_list *ScanBiVex; + vexexpr *VexAtom; + vexexpr *NewAtom; + char *AtomName; + char *NewName; + int Found; + + Found = 0; + + if ( VasyHashOutAsg == (authtable *)0 ) + { + VasyHashOutAsg = createauthtable( 1000 ); + } + else + { + resetauthtable( VasyHashOutAsg ); + } + + RtlAsg = RtlFigure->ASSIGN; + + for ( RtlDeclar = RtlFigure->DECLAR[ RTL_DECLAR_PORT ]; + RtlDeclar != (rtldecl_list *)0; + RtlDeclar = RtlDeclar->NEXT ) + { + if ( ( RtlDeclar->DIR == RTL_DIR_OUT ) && + ( IsVasyRtlDeclarRead( RtlDeclar ) ) ) + { + Found = 1; +/* +** Add an internal signal +*/ + VexAtom = RtlDeclar->VEX_ATOM; + AtomName = GetVexAtomValue( VexAtom ); + + sprintf( VasyBuffer, "rtl_internal_%s", AtomName ); + NewName = namealloc( VasyBuffer ); + NewAtom = dupvexexpr( VexAtom ); + SetVexAtomValue( NewAtom, NewName ); + + NewDeclar = addrtldecl( VasyFigure, NewAtom, RTL_DECLAR_SIGNAL ); + NewDeclar->VEX_INIT = dupvexexpr( RtlDeclar->VEX_INIT ); + NewDeclar->BASE = RtlDeclar->BASE; + NewDeclar->KIND = RtlDeclar->KIND; + NewDeclar->DIR = RTL_DIR_INOUT; + + SetVasyRtlDeclarAsg( NewDeclar ); + SetVasyRtlDeclarRead( NewDeclar ); + + addauthelem( VasyHashOutAsg, AtomName, (long)NewName ); +/* +** Add an assignation to this signal out <= internal_out +*/ + NewAsg = addrtlasg( RtlFigure, dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + NewAsg->VEX_DATA = dupvexexpr( NewAtom ); + } + } + + if ( Found ) + { + while ( RtlAsg != (rtlasg_list *)0 ) + { + VasySimplifySubstReadOutVex( RtlAsg->VEX_ATOM ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasySimplifySubstReadOutVex( ScanBiVex->VEX_COND ); + VasySimplifySubstReadOutVex( ScanBiVex->VEX_DATA ); + } + + RtlAsg = RtlAsg->NEXT; + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyExtendSignVex | +| | +\------------------------------------------------------------*/ + +vexexpr *VasySimplifyExtendSignVex( VexExpr, Width ) + + vexexpr *VexExpr; + int Width; +{ + vexexpr *VexAtom; + vexexpr *VexConcat; + vexexpr *VexBit; + rtldecl_list *RtlDeclar; + rtlasg_list *RtlAssign; + char *AtomValue; + int Left; + int Index; + + if ( VexExpr->WIDTH != Width ) + { + VexAtom = (vexexpr *)0; + + if ( ! IsVexNodeAtom( VexExpr ) ) + { + sprintf( VasyBuffer, "rtlexts_%ld", VasyNumberDef++ ); + VexAtom = createvexatomvec( VasyBuffer, VexExpr->WIDTH - 1, 0 ); + + RtlDeclar = addrtldecl( VasyFigure, VexAtom, RTL_DECLAR_SIGNAL ); + + if ( IsVexNodeSigned( VexExpr ) ) RtlDeclar->BASE = VEX_TYPE_SIGNED; + else RtlDeclar->BASE = VEX_TYPE_UNSIGNED; + + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + + RtlAssign = addrtlasgafter( VasyFigure, VasyAsg, + dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexExpr; + + VexExpr = dupvexexpr( VexAtom ); + } + + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + sprintf( VasyBuffer, "rtlexts_%ld", VasyNumberDef++ ); + VexAtom = createvexatomvec( VasyBuffer, Width - 1, 0 ); + + RtlDeclar = addrtldecl( VasyFigure, VexAtom, RTL_DECLAR_SIGNAL ); + if ( IsVexNodeSigned( VexExpr ) ) RtlDeclar->BASE = VEX_TYPE_SIGNED; + else RtlDeclar->BASE = VEX_TYPE_UNSIGNED; + + RtlDeclar->KIND = RTL_KIND_NONE; + RtlDeclar->DIR = RTL_DIR_INOUT; + } + + if ( VexExpr->WIDTH < Width ) + { + VexConcat = createvexoper( VEX_CONCAT, Width ); + addvexhexpr( VexConcat, dupvexexpr( VexExpr ) ); + + if ( IsVexNodeSigned( VexExpr ) ) + { + AtomValue = GetVexAtomValue( VexExpr ); + + if ( IsVexAtomLiteral( VexExpr ) ) + { + VexBit = createvexatomveclit( AtomValue[ 1 ], Width - VexExpr->WIDTH ); + addvexhexpr( VexConcat, dupvexexpr( VexBit ) ); + } + else + { + VexBit = createvexatomvec( AtomValue, VexExpr->LEFT, VexExpr->LEFT ); + + for ( Index = VexExpr->WIDTH; Index < Width; Index++ ) + { + addvexhexpr( VexConcat, dupvexexpr( VexBit ) ); + } + + freevexexpr( VexBit ); + } + + SetVexNodeSigned( VexConcat ); + } + else + { + VexBit = createvexatomveclit( VEX_ZERO, Width - VexExpr->WIDTH ); + addvexhexpr( VexConcat, VexBit ); + } + + VexConcat = simpvexexpr( VexConcat ); + } + else + { + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + if ( IsVexNodeDown( VexExpr ) ) + { + Left = Width + VexExpr->RIGHT - 1; + } + else + { + Left = VexExpr->RIGHT - Width + 1; + } + + VexConcat = createvexatomvec( GetVexAtomValue( VexExpr ), Left, VexExpr->RIGHT ); + } + else + { + strcpy( VasyBuffer, GetVexAtomValue( VexExpr ) ); + + Left = VexExpr->WIDTH - Width; +/* +** Should Verify the correctness of the sign ... TO BE DONE +*/ + if ( Width > 1 ) VasyBuffer[ Left ] = '"'; + else VasyBuffer[ Left ] = '\''; + + VexConcat = createvexatomlit( &VasyBuffer[ Left ] ); + } + } + + if ( ! IsVexAtomLiteral( VexExpr ) ) + { + RtlAssign = addrtlasgafter( VasyFigure, VasyAsg, + dupvexexpr( VexAtom ), RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexConcat; + + freevexexpr( VexExpr ); + VexExpr = dupvexexpr( VexAtom ); + } + else + { + freevexexpr( VexExpr ); + VexExpr = VexConcat; + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyResizeWidthVex | +| | +\------------------------------------------------------------*/ + +static int VasySimplifyGetLog2n( VexExpr ) + + vexexpr *VexExpr; +{ + long Value; + long Mask; + int Log2n; + int Index; + + if ( evalvexatomlong( VexExpr, &Value ) ) + { + return( -1 ); + } + + Mask = 1; + Log2n = -1; + + for ( Index = 0; Index < 32; Index++ ) + { + if ( Value & Mask ) + { + if ( Log2n == -1 ) Log2n = Index; + else return( -1 ); + } + + Mask = Mask << 1L; + } + + return( Log2n ); +} + +static vexexpr *VasySimplifyResizeWidthVex( VexExpr, Width ) + + vexexpr *VexExpr; + int Width; +{ + vexexpr *Operand; + chain_list *ScanOper; + int MaxWidth; + long IntValue; + long Oper; + + if ( VexExpr != (vexexpr *)0 ) + { + if ( IsVexNodeAtom( VexExpr ) ) + { + VexExpr = VasySimplifyExtendSignVex( VexExpr, Width ); + } + else + if ( IsVexNodeOper( VexExpr ) ) + { + Oper = GetVexOperValue( VexExpr ); + + if ( ! VasyOperatorSupported[ Oper ] ) + { + VasyError( VASY_ERROR_OPERATOR_NOT_SUPPORTED, getvexoperuppername( Oper ) ); + } + + if ( Oper == VEX_CONCAT ) + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasySimplifyResizeWidthVex( Operand, Operand->WIDTH ); + SetVexOperand( ScanOper, Operand ); + } + + VexExpr = VasySimplifyExtendSignVex( VexExpr, Width ); + } + else + if ( Oper == VEX_IFT ) + { + Operand = GetVexOperand( VexExpr->OPERAND ); + Operand = VasySimplifyResizeWidthVex( Operand, 1 ); + SetVexOperand( VexExpr->OPERAND, Operand ); + + Operand = GetVexOperand( VexExpr->OPERAND->NEXT ); + Operand = VasySimplifyResizeWidthVex( Operand, Width ); + SetVexOperand( VexExpr->OPERAND->NEXT, Operand ); + } + else + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) || + ( Oper == VEX_LT ) || + ( Oper == VEX_LE ) || + ( Oper == VEX_GT ) || + ( Oper == VEX_GE ) ) + { + MaxWidth = 0; + + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + + if ( ScanOper == VexExpr->OPERAND ) MaxWidth = Operand->WIDTH; + else + if ( Operand->WIDTH > MaxWidth ) MaxWidth = Operand->WIDTH; + + SetVexOperand( ScanOper, Operand ); + } + + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasySimplifyResizeWidthVex( Operand, MaxWidth ); + SetVexOperand( ScanOper, Operand ); + } + } + else + if ( Oper == VEX_MOD ) + { + Operand = GetVexOperand( VexExpr->OPERAND->NEXT ); + IntValue = VasySimplifyGetLog2n( Operand ); + + if ( IntValue == -1 ) + { + VasyError( VASY_ERROR_OPERATOR_NOT_SUPPORTED, getvexoperuppername( Oper ) ); + } + + Operand = GetVexOperand( VexExpr->OPERAND ); + Operand = VasySimplifyResizeWidthVex( Operand, IntValue ); + ClearVexNodeSigned( Operand ); + Operand = VasySimplifyExtendSignVex( Operand, Width ); + + SetVexOperand( VexExpr->OPERAND, (vexexpr *)0 ); + freevexexpr( VexExpr ); + + VexExpr = Operand; + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasySimplifyResizeWidthVex( Operand, Width ); + SetVexOperand( ScanOper, Operand ); + } + } + + VexExpr->WIDTH = Width; + } + else + { + for ( ScanOper = VexExpr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasySimplifyResizeWidthVex( Operand, Operand->WIDTH ); + SetVexOperand( ScanOper, Operand ); + } + + VexExpr->WIDTH = Width; + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyResizeWidth | +| | +\------------------------------------------------------------*/ + +static void VasySimplifyResizeWidth( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + rtlins_list *RtlInst; + rtlmap_list *RtlMap; + rtlasg_list *RtlAsg; + rtlbivex_list *ScanBiVex; + vexexpr *VexAtom; + int Width; + + for ( RtlAsg = RtlFigure->ASSIGN; + RtlAsg != (rtlasg_list *)0; + RtlAsg = RtlAsg->NEXT ) + { + VexAtom = RtlAsg->VEX_ATOM; + Width = VexAtom->WIDTH; + + RtlAsg->VEX_DATA = VasySimplifyResizeWidthVex( RtlAsg->VEX_DATA, Width ); + + for ( ScanBiVex = RtlAsg->BIVEX; + ScanBiVex != (rtlbivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + ScanBiVex->VEX_COND = VasySimplifyResizeWidthVex( ScanBiVex->VEX_COND, 1 ); + ScanBiVex->VEX_DATA = VasySimplifyResizeWidthVex( ScanBiVex->VEX_DATA, Width ); + } + } + + for ( RtlInst = RtlFigure->INSTANCE; + RtlInst != (rtlins_list *)0; + RtlInst = RtlInst->NEXT ) + { + for ( RtlMap = RtlInst->MAP; + RtlMap != (rtlmap_list *)0; + RtlMap = RtlMap->NEXT ) + { + VexAtom = RtlMap->VEX_FORMAL; + Width = VexAtom->WIDTH; + + RtlMap->VEX_ACTUAL = VasySimplifyResizeWidthVex( RtlMap->VEX_ACTUAL, Width ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySimplifyRtlFig | +| | +\------------------------------------------------------------*/ + +void VasySimplifyRtlFig( RtlFigure ) + + rtlfig_list *RtlFigure; +{ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> VasySimplifyRtlFig %s\n", RtlFigure->NAME ); + } + + VasyFigure = RtlFigure; +/* +** All operands in all expressions should have the 'right' width +*/ + VasySimplifyResizeWidth( RtlFigure ); +/* +** Hash all register assignments +*/ + VasySimplifyHashRegisterAsg( RtlFigure ); +/* +** Compact all register assignments +*/ + VasySimplifyCompactRegister( RtlFigure ); +/* +** Hash all tristates assignments +*/ + VasySimplifyHashTristateAsg( RtlFigure ); +/* +** Compact all tristates assignments +*/ + VasySimplifyCompactTristate( RtlFigure ); +/* +** Hash all define assignments +*/ + VasySimplifyHashDefineAsg( RtlFigure ); +/* +** Find all define assignment to substitute and delete +*/ + VasySimplifySubstDefine( RtlFigure ); +/* +** Find all symbol read and assigned +*/ + VasySimplifyMarkRead( RtlFigure ); +/* +** Rename all read out ports +*/ + VasySimplifySubstReadOut( RtlFigure ); + + if ( IsVasyDebugLevel2() ) + { + VasySimplifyDisplayRead( RtlFigure ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "<-- VasySimplifyRtlFig %s\n", RtlFigure->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_simprtl.h b/alliance/src/vasy/src/vasy_simprtl.h new file mode 100644 index 00000000..9473ca78 --- /dev/null +++ b/alliance/src/vasy/src/vasy_simprtl.h @@ -0,0 +1,134 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_simprtl.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_SIMP_RTL_H +# define VASY_SIMP_RTL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Declar Mask | +| | +\------------------------------------------------------------*/ + +# define VASY_DECLAR_ASG_MASK 0x01 +# define VASY_DECLAR_READ_MASK 0x02 +# define VASY_DECLAR_USED_MASK 0x03 +# define VASY_DECLAR_DEFINE_MASK 0x04 + +/*------------------------------------------------------------\ +| | +| Macros Declar | +| | +\------------------------------------------------------------*/ + +# define SetVasyRtlDeclarAsg( D ) ((D)->FLAGS |= VASY_DECLAR_ASG_MASK) +# define ClearVasyRtlDeclarAsg( D ) ((D)->FLAGS &= ~VASY_DECLAR_ASG_MASK) +# define IsVasyRtlDeclarAsg( D ) ((D)->FLAGS & VASY_DECLAR_ASG_MASK) + +# define SetVasyRtlDeclarRead( D ) ((D)->FLAGS |= VASY_DECLAR_READ_MASK) +# define ClearVasyRtlDeclarRead( D ) ((D)->FLAGS &= ~VASY_DECLAR_READ_MASK) +# define IsVasyRtlDeclarRead( D ) ((D)->FLAGS & VASY_DECLAR_READ_MASK) + +# define IsVasyRtlDeclarUsed( D ) ((D)->FLAGS & VASY_DECLAR_USED_MASK) +# define ClearVasyRtlDeclarUsed( D ) ((D)->FLAGS &= ~VASY_DECLAR_USED_MASK) + +# define SetVasyRtlDeclarDefine( D ) ((D)->FLAGS |= VASY_DECLAR_DEFINE_MASK) +# define ClearVasyRtlDeclarDefine( D ) ((D)->FLAGS &= ~VASY_DECLAR_DEFINE_MASK) +# define IsVasyRtlDeclarDefine( D ) ((D)->FLAGS & VASY_DECLAR_DEFINE_MASK) + +/*------------------------------------------------------------\ +| | +| Assign Mask | +| | +\------------------------------------------------------------*/ + +# define VASY_ASSIGN_SUBST_MASK 0x01 +# define VASY_ASSIGN_SUBST_DONE_MASK 0x02 + +# define VASY_ASSIGN_NUMBER_READ_MASK 0xF0 +# define VASY_ASSIGN_NUMBER_READ_SHIFT 4 + +/*------------------------------------------------------------\ +| | +| Macros Assign | +| | +\------------------------------------------------------------*/ + +# define SetVasyRtlAssignSubst( D ) ((D)->FLAGS |= VASY_ASSIGN_SUBST_MASK) +# define ClearVasyRtlAssignSubst( D ) ((D)->FLAGS &= ~VASY_ASSIGN_SUBST_MASK) +# define IsVasyRtlAssignSubst( D ) ((D)->FLAGS & VASY_ASSIGN_SUBST_MASK) + +# define GetVasyRtlAssignNumberRead( D ) \ + (((D)->FLAGS & VASY_ASSIGN_NUMBER_READ_MASK) >> VASY_ASSIGN_NUMBER_READ_SHIFT) + +# define SetVasyRtlAssignNumberRead( D, V ) \ + ((D)->FLAGS = ((D)->FLAGS & ~VASY_ASSIGN_NUMBER_READ_MASK) | \ + (((V) << VASY_ASSIGN_NUMBER_READ_SHIFT) & VASY_ASSIGN_NUMBER_READ_MASK)) + +# define IncVasyRtlAssignNumberRead( D ) \ + (SetVasyRtlAssignNumberRead( D, GetVasyRtlAssignNumberRead( D ) + 1 )) + +# define SetVasyRtlAssignSubstDone( D ) ((D)->FLAGS |= VASY_ASSIGN_SUBST_DONE_MASK) +# define ClearVasyRtlAssignSubstDone( D ) ((D)->FLAGS &= ~VASY_ASSIGN_SUBST_DONE_MASK) +# define IsVasyRtlAssignSubstDone( D ) ((D)->FLAGS & VASY_ASSIGN_SUBST_DONE_MASK) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasySimplifyRtlFig(); + +# endif diff --git a/alliance/src/vasy/src/vasy_simul.c b/alliance/src/vasy/src/vasy_simul.c new file mode 100644 index 00000000..ba1e9361 --- /dev/null +++ b/alliance/src/vasy/src/vasy_simul.c @@ -0,0 +1,1769 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_simul.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 28.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_simul.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + static vpnline_list *VasyVpnLine = (vpnline_list *)0; + + static vasysimul *VasySimulateVex(); + + static vasysimul *VasySimulateVexConcat(); + static vasysimul *VasySimulateVexLogic(); + static vasysimul *VasySimulateVexEvent(); + static vasysimul *VasySimulateVexNeg(); + static vasysimul *VasySimulateVexAbs(); + static vasysimul *VasySimulateVexSum(); + static vasysimul *VasySimulateVexEqual(); + static vasysimul *VasySimulateVexCompare(); + static vasysimul *VasySimulateVexSlice(); + static vasysimul *VasySimulateVexDriver(); + + static vasysimul *(*VasySimulOperFunc[ VEX_MAX_OPERATOR ])() = + { + VasySimulateVexConcat, /* VEX_CONCAT */ + VasySimulateVexLogic, /* VEX_NOT */ + VasySimulateVexNeg, /* VEX_NEG */ + VasySimulateVexEvent, /* VEX_EVENT */ + VasySimulateVexLogic, /* VEX_OR */ + VasySimulateVexLogic, /* VEX_AND */ + VasySimulateVexLogic, /* VEX_XOR */ + VasySimulateVexLogic, /* VEX_NOR */ + VasySimulateVexLogic, /* VEX_NAND */ + VasySimulateVexLogic, /* VEX_NXOR */ + VasySimulateVexEqual, /* VEX_EQ */ + VasySimulateVexEqual, /* VEX_NE */ + VasySimulateVexCompare, /* VEX_LT */ + VasySimulateVexCompare, /* VEX_LE */ + VasySimulateVexCompare, /* VEX_GT */ + VasySimulateVexCompare, /* VEX_GE */ + VasySimulateVexSum, /* VEX_ADD */ + VasySimulateVexSum, /* VEX_SUB */ + NULL, /* VEX_MUL */ + NULL, /* VEX_DIV */ + NULL, /* VEX_EXP */ + NULL, /* VEX_MOD */ + NULL, /* VEX_REM */ + VasySimulateVexSlice, /* VEX_TO */ + VasySimulateVexSlice, /* VEX_DOWNTO */ + VasySimulateVexSlice, /* VEX_INDEX */ + NULL, /* VEX_LEFT */ + NULL, /* VEX_RIGHT */ + NULL, /* VEX_LOW */ + NULL, /* VEX_HIGH */ + NULL, /* VEX_LENGTH */ + NULL, /* VEX_RANGE */ + NULL, /* VEX_REV_RANGE */ + VasySimulateVexDriver, /* VEX_DRIVER */ + VasySimulateVexLogic, /* VEX_IFT */ + NULL, /* VEX_ARRAY */ + NULL, /* VEX_INDEX_N */ + NULL, /* VEX_OTHERS */ + NULL, /* VEX_NUM_BIT */ + VasySimulateVexAbs /* VEX_ABS */ + }; + + static char VasyTruthTableAnd[ VEX_MAX_ID ][ VEX_MAX_ID ] = + { + /* -------------------------------------------------- + ** | U X 0 1 Z W L H - + ** -------------------------------------------------- + */ + { 0 , 0 , 2 , 0 , 0 , 0 , 2 , 0 , 0 }, /* u */ + { 0 , 1 , 2 , 1 , 1 , 1 , 2 , 1 , 1 }, /* x */ + { 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 }, /* 0 */ + { 0 , 1 , 2 , 3 , 1 , 1 , 2 , 3 , 1 }, /* 1 */ + { 0 , 1 , 2 , 1 , 1 , 1 , 2 , 1 , 1 }, /* z */ + { 0 , 1 , 2 , 1 , 1 , 1 , 2 , 1 , 1 }, /* w */ + { 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 }, /* l */ + { 0 , 1 , 2 , 3 , 1 , 1 , 2 , 3 , 1 }, /* h */ + { 0 , 1 , 2 , 1 , 1 , 1 , 2 , 1 , 1 } /* - */ + }; + + static char VasyTruthTableOr[ VEX_MAX_ID ][ VEX_MAX_ID ] = + { + /* ---------------------------------------------------- + ** | u x 0 1 z w l h - + ** ---------------------------------------------------- + */ + { 0 , 0 , 0 , 3 , 0 , 0 , 0 , 3 , 0 }, /* u */ + { 0 , 1 , 1 , 3 , 1 , 1 , 1 , 3 , 1 }, /* x */ + { 0 , 1 , 2 , 3 , 1 , 1 , 2 , 3 , 1 }, /* 0 */ + { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 }, /* 1 */ + { 0 , 1 , 1 , 3 , 1 , 1 , 1 , 3 , 1 }, /* z */ + { 0 , 1 , 1 , 3 , 1 , 1 , 1 , 3 , 1 }, /* w */ + { 0 , 1 , 2 , 3 , 1 , 1 , 2 , 3 , 1 }, /* l */ + { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 }, /* h */ + { 0 , 1 , 1 , 3 , 1 , 1 , 1 , 3 , 1 } /* - */ + }; + + static char VasyTruthTableXor[ VEX_MAX_ID ][ VEX_MAX_ID ] = + { + /* ---------------------------------------------------- + ** | u x 0 1 z w l h - + ** ---------------------------------------------------- + */ + { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, /* u */ + { 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }, /* x */ + { 0 , 1 , 2 , 3 , 1 , 1 , 2 , 3 , 1 }, /* 0 */ + { 0 , 1 , 3 , 2 , 1 , 1 , 3 , 2 , 1 }, /* 1 */ + { 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }, /* z */ + { 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }, /* w */ + { 0 , 1 , 2 , 3 , 1 , 1 , 2 , 3 , 1 }, /* l */ + { 0 , 1 , 3 , 2 , 1 , 1 , 3 , 2 , 1 }, /* h */ + { 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } /* - */ + }; + + static char VasyTruthTableNot[ VEX_MAX_ID ] = + { + /* ---------------------------------------------------- + ** | u x 0 1 z w l h - + ** ---------------------------------------------------- + */ + 0 , 1 , 3 , 2 , 1 , 1 , 3 , 2 , 1 + }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasySimulateViewSimul | +| | +\------------------------------------------------------------*/ + +static void VasySimulateViewSimul( ScanSimul ) + + vasysimul *ScanSimul; +{ + char *Value; + int Position; + int Width; + + VasyPrintf( stdout, " --> VasySimulateViewSimul %d %d\n", + ScanSimul->WIDTH, ScanSimul->SIGNED ); + + Value = ScanSimul->VALUE; + Width = ScanSimul->WIDTH; + + for ( Position = 0; Position < Width; Position++ ) + { + VasyPrintf( stdout, " +++ Simul[ %d ] > %c\n", + Position, VEX_LITERAL_BY_ID[ (int)Value[ Position ] ] ); + } + + VasyPrintf( stdout, " <-- VasySimulateViewSimul\n" ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateAddSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateAddSimul( Width, Signed ) + + short Width; + short Signed; +{ + vasysimul *NewSimul; + + NewSimul = (vasysimul *)autallocheap( sizeof( vasysimul ) ); + + NewSimul->VALUE = autallocheap( Width ); + NewSimul->WIDTH = Width; + NewSimul->SIGNED = Signed; + + return( NewSimul ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateDelSimul | +| | +\------------------------------------------------------------*/ + +void VasySimulateDelSimul( DelSimul ) + + vasysimul *DelSimul; +{ + autfreeheap( DelSimul->VALUE, DelSimul->WIDTH ); + autfreeheap( DelSimul, sizeof( vasysimul ) ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateSignSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateSignSimul( Simul ) + + vasysimul *Simul; +{ + vasysimul *NewSimul; + char *NewValue; + char *Value; + int Position; + + Value = Simul->VALUE; + + if ( ! Simul->SIGNED ) + { + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasySimulateSignSimul\n" ); + VasySimulateViewSimul( Simul ); + } + + if ( Value[ 0 ] == VEX_ONE_ID ) + { + NewSimul = VasySimulateAddSimul( Simul->WIDTH + 1, 1 ); + NewValue = NewSimul->VALUE; + + NewValue[ 0 ] = VEX_ZERO_ID; + + for ( Position = 0; Position < Simul->WIDTH; Position++ ) + { + NewValue[ Position + 1 ] = Value[ Position ]; + } + + VasySimulateDelSimul( Simul ); + Simul = NewSimul; + } + + Simul->SIGNED = 1; + + if ( IsVasyDebugLevel2() ) + { + VasySimulateViewSimul( Simul ); + VasyPrintf( stdout, " <-- VasySimulateSignSimul\n" ); + } + } + + return( Simul ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateIncWidthSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateCarryOutSimul( Simul, CarryOut ) + + vasysimul *Simul; + char CarryOut; +{ + vasysimul *NewSimul; + char *NewValue; + char *Value; + int Position; + + NewSimul = VasySimulateAddSimul( Simul->WIDTH + 1, Simul->SIGNED ); + + NewValue = NewSimul->VALUE; + Value = Simul->VALUE; + + for ( Position = 0; Position < Simul->WIDTH; Position++ ) + { + NewValue[ Position + 1 ] = Value[ Position ]; + } + + NewValue[ 0 ] = CarryOut; + VasySimulateDelSimul( Simul ); + + return( NewSimul ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateExtendSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateExtendSimul( Simul, Width ) + + vasysimul *Simul; + short Width; +{ + vasysimul *NewSimul; + char *NewValue; + char *Value; + int Position; + int Delta; + char BitSign; + + Simul = VasySimulateSignSimul( Simul ); + Delta = Width - Simul->WIDTH; + + if ( Delta > 0 ) + { + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasySimulateExtendSimul (%d %d)\n", + Simul->WIDTH, Width ); + VasySimulateViewSimul( Simul ); + } + + Value = Simul->VALUE; + BitSign = Value[ 0 ]; + + NewSimul = VasySimulateAddSimul( Width, 1 ); + NewValue = NewSimul->VALUE; + + for ( Position = 0; Position < Delta; Position++ ) + { + NewValue[ Position ] = BitSign; + } + + for ( Position = 0; Position < Simul->WIDTH; Position++ ) + { + NewValue[ Position + Delta ] = Value[ Position ]; + } + + VasySimulateDelSimul( Simul ); + Simul = NewSimul; + + if ( IsVasyDebugLevel2() ) + { + VasySimulateViewSimul( Simul ); + VasyPrintf( stdout, " <-- VasySimulateExtendSimul\n" ); + } + } + + return( Simul ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateResizeSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateResizeSimul( Simul, Width, Signed ) + + vasysimul *Simul; + short Width; + short Signed; +{ + vasysimul *NewSimul; + char *NewValue; + char *Value; + int Position; + int Delta; + char BitSign; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasySimulateResizeSimul > (%d %d)\n", Width, Signed ); + VasySimulateViewSimul( Simul ); + } + + Value = Simul->VALUE; + Delta = Width - Simul->WIDTH; + + if ( Delta == 0 ) + { +/* +** Target Width is equal => must be convertible +*/ + if ( ( Simul->SIGNED != Signed ) && + ( Value[ 0 ] == VEX_ONE_ID ) ) + { + VasyWarningLine( VASY_WARNING_IN_SIMULATION, VasyVpnLine, "unconvertible value" ); + } + } + else + if ( Delta > 0 ) + { +/* +** Target Width is greater => must extend the sign +*/ + if ( ( Simul->SIGNED ) && + ( ! Signed ) && + ( Value[ 0 ] == VEX_ONE_ID ) ) + { + VasyErrorLine( VASY_WARNING_IN_SIMULATION, VasyVpnLine, "unconvertible value" ); + } + + if ( ( Signed ) && + ( Simul->SIGNED ) ) BitSign = Value[ 0 ]; + else BitSign = VEX_ZERO_ID; + + NewSimul = VasySimulateAddSimul( Width, Signed ); + NewValue = NewSimul->VALUE; + + for ( Position = 0; Position < Delta; Position++ ) + { + NewValue[ Position ] = BitSign; + } + + for ( Position = 0; Position < Simul->WIDTH; Position++ ) + { + NewValue[ Position + Delta ] = Value[ Position ]; + } + + VasySimulateDelSimul( Simul ); + Simul = NewSimul; + } + else + { +/* +** Target Width is lower => must verify the sign +*/ + Delta = - Delta; + + if ( ( Signed ) && + ( Simul->SIGNED ) ) BitSign = Value[ 0 ]; + else BitSign = VEX_ZERO_ID; + + for ( Position = 0; Position < Delta; Position++ ) + { + if ( Value[ Position ] != BitSign ) + { + VasyWarningLine( VASY_WARNING_IN_SIMULATION, VasyVpnLine, "unconvertible value" ); + } + } + + NewSimul = VasySimulateAddSimul( Width, Signed ); + NewValue = NewSimul->VALUE; + + for ( Position = 0; Position < Width; Position++ ) + { + NewValue[ Position ] = Value[ Position + Delta ]; + } + + VasySimulateDelSimul( Simul ); + Simul = NewSimul; + } + + if ( IsVasyDebugLevel2() ) + { + VasySimulateViewSimul( Simul ); + VasyPrintf( stdout, " <-- VasySimulateResizeSimul\n" ); + } + + return( Simul ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateIntegerSimul | +| | +\------------------------------------------------------------*/ + +static long VasySimulateIntegerSimul( SimulExpr ) + + vasysimul *SimulExpr; +{ + char *SimulValue; + int Width; + int Position; + long Value; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasySimulateIntegerSimul\n" ); + VasySimulateViewSimul( SimulExpr ); + } + + SimulValue = SimulExpr->VALUE; + Width = SimulExpr->WIDTH; + Position = 0; + Value = 0; + + if ( ( SimulExpr->SIGNED ) && + ( SimulValue[ 0 ] == VEX_ONE_ID ) ) + { + Value = -1; + } + + for ( Position = 0; Position < Width; Position++ ) + { + Value = Value << 1; + + if ( SimulValue[ Position ] == VEX_ONE_ID ) + { + Value |= 1; + } + else + if ( SimulValue[ Position ] != VEX_ZERO_ID ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VasyVpnLine, "not integer value" ); + } + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " <-- VasySimulateNegSimul %ld\n", Value ); + } + + return( Value ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateNegSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateNegSimul( SimulExpr ) + + vasysimul *SimulExpr; +{ + char *SimulValue; + int Position; + char Value1; + char Value; + char Carry; + char Sign; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasySimulateNegSimul\n" ); + VasySimulateViewSimul( SimulExpr ); + } + + SimulExpr = VasySimulateSignSimul( SimulExpr ); + SimulValue = SimulExpr->VALUE; + + Sign = SimulValue[ 0 ]; + Carry = 1; + + for ( Position = SimulExpr->WIDTH - 1; Position >= 0; Position-- ) + { + if ( SimulValue[ Position ] == VEX_ONE_ID ) Value1 = 0; + else Value1 = 1; + + Value = Value1 ^ Carry; + Carry = Value1 & Carry; + + if ( Value ) Value = VEX_ONE_ID; + else Value = VEX_ZERO_ID; + + SimulValue[ Position ] = Value; + } + + if ( ( Sign == VEX_ONE_ID ) && + ( SimulValue[ 0 ] != VEX_ZERO_ID ) ) + { + SimulExpr = VasySimulateCarryOutSimul( SimulExpr, VEX_ZERO_ID ); + } + + if ( IsVasyDebugLevel2() ) + { + VasySimulateViewSimul( SimulExpr ); + VasyPrintf( stdout, " <-- VasySimulateNegSimul\n" ); + } + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateSumSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateSumSimul( SimulExpr1, SimulExpr2 ) + + vasysimul *SimulExpr1; + vasysimul *SimulExpr2; +{ + char *SimulValue1; + char *SimulValue2; + char Negative1; + char Negative2; + char Value1; + char Value2; + char Value; + char Carry; + int Position; + + SimulExpr1 = VasySimulateSignSimul( SimulExpr1 ); + SimulExpr2 = VasySimulateSignSimul( SimulExpr2 ); + + if ( SimulExpr1->WIDTH > SimulExpr2->WIDTH ) + { + SimulExpr2 = VasySimulateExtendSimul( SimulExpr2, SimulExpr1->WIDTH ); + } + else + if ( SimulExpr2->WIDTH > SimulExpr1->WIDTH ) + { + SimulExpr1 = VasySimulateExtendSimul( SimulExpr1, SimulExpr2->WIDTH ); + } + + Carry = 0; + SimulValue1 = SimulExpr1->VALUE; + SimulValue2 = SimulExpr2->VALUE; + + Negative1 = ( SimulValue1[ 0 ] == VEX_ONE_ID ); + Negative2 = ( SimulValue2[ 0 ] == VEX_ONE_ID ); + + for ( Position = SimulExpr1->WIDTH - 1; Position >= 0; Position-- ) + { + Value1 = SimulValue1[ Position ]; + Value2 = SimulValue2[ Position ]; + + if ( Value1 == VEX_ONE_ID ) Value1 = 1; + else Value1 = 0; + + if ( Value2 == VEX_ONE_ID ) Value2 = 1; + else Value2 = 0; + + Value = Value1 ^ Value2 ^ Carry; + Carry = ( Value1 & Value2 ) | + ( Value1 & Carry ) | + ( Value2 & Carry ) ; + + if ( Value ) Value = VEX_ONE_ID; + else Value = VEX_ZERO_ID; + + SimulValue1[ Position ] = Value; + } + + if ( ( Negative1 ) && + ( Negative2 ) ) + { + if ( SimulValue1[ 0 ] == VEX_ZERO_ID ) + { + SimulExpr1 = VasySimulateCarryOutSimul( SimulExpr1, VEX_ONE_ID ); + } + } + else + if ( ( ! Negative1 ) && + ( ! Negative2 ) ) + { + if ( SimulValue1[ 0 ] == VEX_ONE_ID ) + { + SimulExpr1 = VasySimulateCarryOutSimul( SimulExpr1, VEX_ZERO_ID ); + } + } + + VasySimulateDelSimul( SimulExpr2 ); + + return( SimulExpr1 ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateAbsSimul | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateAbsSimul( SimulExpr ) + + vasysimul *SimulExpr; +{ + char *SimulValue; + int Position; + char Value1; + char Value; + char Carry; + char Sign; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " --> VasySimulateAbsSimul\n" ); + VasySimulateViewSimul( SimulExpr ); + } + + SimulValue = SimulExpr->VALUE; + + Sign = SimulValue[ 0 ]; + + if ( ( Sign == VEX_ONE_ID ) && + ( SimulExpr->SIGNED ) ) + { + Carry = 1; + + for ( Position = SimulExpr->WIDTH - 1; Position >= 0; Position-- ) + { + if ( SimulValue[ Position ] == VEX_ONE_ID ) Value1 = 0; + else Value1 = 1; + + Value = Value1 ^ Carry; + Carry = Value1 & Carry; + + if ( Value ) Value = VEX_ONE_ID; + else Value = VEX_ZERO_ID; + + SimulValue[ Position ] = Value; + } + + if ( ( Sign == VEX_ONE_ID ) && + ( SimulValue[ 0 ] != VEX_ZERO_ID ) ) + { + SimulExpr = VasySimulateCarryOutSimul( SimulExpr, VEX_ZERO_ID ); + } + } + + if ( IsVasyDebugLevel2() ) + { + VasySimulateViewSimul( SimulExpr ); + VasyPrintf( stdout, " <-- VasySimulateAbsSimul\n" ); + } + + return( SimulExpr ); +} + + +/*------------------------------------------------------------\ +| | +| VasySimulateVexAbs | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexAbs( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr; + vexexpr *Operand; + + Operand = GetVexOperand( Expr->OPERAND ); + SimulExpr = VasySimulateVex( Operand ); + SimulExpr = VasySimulateAbsSimul( SimulExpr ); + + return( SimulExpr ); +} + + +/*------------------------------------------------------------\ +| | +| VasySimulateVexNeg | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexNeg( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr; + vexexpr *Operand; + + Operand = GetVexOperand( Expr->OPERAND ); + SimulExpr = VasySimulateVex( Operand ); + SimulExpr = VasySimulateNegSimul( SimulExpr ); + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexSum | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexSum( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr1; + vasysimul *SimulExpr2; + chain_list *ScanChain; + vexexpr *Operand; + long Oper; + + Oper = GetVexOperValue( Expr ); + + ScanChain = Expr->OPERAND; + Operand = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( Operand ); + ScanChain = ScanChain->NEXT; + + while ( ScanChain != (chain_list *)0 ) + { + Operand = GetVexOperand( ScanChain ); + SimulExpr2 = VasySimulateVex( Operand ); + + if ( Oper == VEX_SUB ) + { + SimulExpr2 = VasySimulateNegSimul( SimulExpr2 ); + } + + SimulExpr1 = VasySimulateSumSimul( SimulExpr1, SimulExpr2 ); + + ScanChain = ScanChain->NEXT; + } + + return( SimulExpr1 ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexEqual | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexEqual( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr1; + vasysimul *SimulExpr2; + char *SimulValue1; + char *SimulValue2; + chain_list *ScanChain; + vexexpr *Operand; + char Equal; + long Oper; + int Position; + + Oper = GetVexOperValue( Expr ); + + ScanChain = Expr->OPERAND; + Operand = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( Operand ); + + ScanChain = ScanChain->NEXT; + Operand = GetVexOperand( ScanChain ); + SimulExpr2 = VasySimulateVex( Operand ); + + if ( SimulExpr1->WIDTH > SimulExpr2->WIDTH ) + { + SimulExpr2 = VasySimulateExtendSimul( SimulExpr2, SimulExpr1->WIDTH ); + } + else + if ( SimulExpr2->WIDTH > SimulExpr1->WIDTH ) + { + SimulExpr1 = VasySimulateExtendSimul( SimulExpr1, SimulExpr2->WIDTH ); + } + + SimulValue1 = SimulExpr1->VALUE; + SimulValue2 = SimulExpr2->VALUE; + + if ( Oper == VEX_EQ ) Equal = 1; + else Equal = 0; + + for ( Position = 0; Position < SimulExpr2->WIDTH; Position++ ) + { + if ( SimulValue1[ Position ] != SimulValue2[ Position ] ) + { + Equal = ! Equal; break; + } + } + + VasySimulateDelSimul( SimulExpr1 ); + VasySimulateDelSimul( SimulExpr2 ); + + SimulExpr1 = VasySimulateAddSimul( 1, 0 ); + + if ( Equal ) SimulExpr1->VALUE[ 0 ] = VEX_ONE_ID; + else SimulExpr1->VALUE[ 0 ] = VEX_ZERO_ID; + + return( SimulExpr1 ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexCompare | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexCompare( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr1; + vasysimul *SimulExpr2; + char *SimulValue1; + chain_list *ScanChain; + vexexpr *Operand; + long Oper; + short Compare; + short Negative; + short Zero; + int Position; + + Oper = GetVexOperValue( Expr ); + + ScanChain = Expr->OPERAND; + Operand = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( Operand ); + + ScanChain = ScanChain->NEXT; + Operand = GetVexOperand( ScanChain ); + SimulExpr2 = VasySimulateVex( Operand ); + + SimulExpr2 = VasySimulateNegSimul( SimulExpr2 ); + SimulExpr1 = VasySimulateSumSimul( SimulExpr1, SimulExpr2 ); + + SimulValue1 = SimulExpr1->VALUE; + + Negative = ( SimulValue1[ 0 ] == VEX_ONE_ID ); + Zero = 1; + + for ( Position = SimulExpr1->WIDTH - 1; Position >= 0; Position-- ) + { + if ( SimulValue1[ Position ] != VEX_ZERO_ID ) + { + Zero = 0; break; + } + } + + if ( Oper == VEX_LT ) Compare = ( Negative ) && ( ! Zero ); + else + if ( Oper == VEX_GT ) Compare = ( ! Negative ) && ( ! Zero ); + else + if ( Oper == VEX_LE ) Compare = ( Negative ) || ( Zero ); + else + Compare = ( ! Negative ) || ( Zero ); + + VasySimulateDelSimul( SimulExpr1 ); + + SimulExpr1 = VasySimulateAddSimul( 1, 0 ); + + if ( Compare ) SimulExpr1->VALUE[ 0 ] = VEX_ONE_ID; + else SimulExpr1->VALUE[ 0 ] = VEX_ZERO_ID; + + return( SimulExpr1 ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexAtom | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexAtom( Atom, Effec ) + + vexexpr *Atom; + short Effec; +{ + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + vasysimul *SimulAtom; + char *SimulValue; + char *AtomValue; + int Position; + int Delta; + short Signed; + + AtomValue = GetVexAtomValue( Atom ); + + if ( IsVexAtomSigned( Atom ) ) Signed = 1; + else Signed = 0; + + SimulAtom = VasySimulateAddSimul( Atom->WIDTH, Signed ); + SimulValue = SimulAtom->VALUE; + + if ( IsVexAtomLiteral( Atom ) ) + { + for ( Position = 0; Position < Atom->WIDTH; Position++ ) + { + SimulValue[ Position ] = getvexliteralid( AtomValue[ Position + 1 ] ); + } + } + else + { + VpnDeclar = searchvpndeclall( VasyFigure, AtomValue ); + Delta = getvexvectorpos( VpnDeclar->VEX_ATOM, Atom->LEFT ); + + for ( Position = 0; Position < Atom->WIDTH; Position++ ) + { + VpnSymbol = &VpnDeclar->DECL_SYM[ Position + Delta ]; + + if ( Effec ) SimulValue[ Position ] = VpnSymbol->EFFEC; + else SimulValue[ Position ] = VpnSymbol->DRIVE; + } + } + + return( SimulAtom ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexSlice | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexSlice( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr1; + vasysimul *SimulExpr2; + char *SimulValue1; + char *SimulValue2; + chain_list *ScanChain; + vexexpr *VexAtom; + vexexpr *Operand; + long Oper; + int IndexFrom; + int IndexTo; + int IndexMin; + int IndexMax; + int Index; + int Width; + int Position; + int ScanPos; + short Signed; + + Oper = GetVexOperValue( Expr ); + + ScanChain = Expr->OPERAND; + VexAtom = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( VexAtom ); + SimulValue1 = SimulExpr1->VALUE; + + ScanChain = ScanChain->NEXT; + Operand = GetVexOperand( ScanChain ); + SimulExpr2 = VasySimulateVex( Operand ); + + IndexFrom = VasySimulateIntegerSimul( SimulExpr2 ); + VasySimulateDelSimul( SimulExpr2 ); + + if ( Oper != VEX_INDEX ) + { + ScanChain = ScanChain->NEXT; + Operand = GetVexOperand( ScanChain ); + SimulExpr2 = VasySimulateVex( Operand ); + + IndexTo = VasySimulateIntegerSimul( SimulExpr2 ); + VasySimulateDelSimul( SimulExpr2 ); + } + else + { + IndexTo = IndexFrom; + } + + if ( IsVexAtomSigned( VexAtom ) ) Signed = 1; + else Signed = 0; + + if ( Oper == VEX_DOWNTO ) + { + IndexMin = IndexTo; + IndexMax = IndexFrom; + } + else + { + IndexMin = IndexFrom; + IndexMax = IndexTo; + } + + Width = ( IndexMax - IndexMin ) + 1; + + if ( Width <= 0 ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VasyVpnLine, "negative width" ); + } + + SimulExpr2 = VasySimulateAddSimul( Width, Signed ); + SimulValue2 = SimulExpr2->VALUE; + + Position = 0; + + for ( Index = IndexMin; Index <= IndexMax; Index++ ) + { + ScanPos = getvexvectorpos( VexAtom, Index ); + + if ( ScanPos == -1 ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VasyVpnLine, "index out of bound" ); + } + + SimulValue2[ Position ] = SimulValue1[ ScanPos ]; + } + + VasySimulateDelSimul( SimulExpr1 ); + + return( SimulExpr2 ); +} + + +/*------------------------------------------------------------\ +| | +| VasySimulateVexConcat | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexConcat( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr; + vasysimul *SimulOper; + char *SimulValue; + chain_list *ScanChain; + vexexpr *Operand; + int Position; + int ScanPos; + int Width; + + SimulExpr = VasySimulateAddSimul( Expr->WIDTH, 0 ); + SimulValue = SimulExpr->VALUE; + Position = 0; + + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Width = Operand->WIDTH; + SimulOper = VasySimulateVex( Operand ); + + for ( ScanPos = 0; ScanPos < Width; ScanPos++ ) + { + SimulValue[ Position++ ] = SimulOper->VALUE[ ScanPos ]; + } + + VasySimulateDelSimul( SimulOper ); + } + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexDriver | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexDriver( Expr ) + + vexexpr *Expr; +{ + vexexpr *Atom; + vasysimul *SimulExpr; + + Atom = GetVexOperand( Expr->OPERAND ); + SimulExpr = VasySimulateVexAtom( Atom, 0 ); + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexEvent | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexEvent( Expr ) + + vexexpr *Expr; +{ + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + vexexpr *Atom; + vasysimul *SimulExpr; + char *SimulValue; + char *AtomValue; + int Delta; + + SimulExpr = VasySimulateAddSimul( 1, 0 ); + SimulValue = SimulExpr->VALUE; + + Atom = GetVexOperand( Expr->OPERAND ); + AtomValue = GetVexAtomValue( Atom ); + + VpnDeclar = searchvpndeclall( VasyFigure, AtomValue ); + Delta = getvexvectorpos( VpnDeclar->VEX_ATOM, Atom->LEFT ); + VpnSymbol = &VpnDeclar->DECL_SYM[ Delta ]; + + if ( VpnSymbol->EVENT ) SimulValue[ 0 ] = VEX_ONE_ID; + else SimulValue[ 0 ] = VEX_ZERO_ID; + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexLogic | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVexLogic( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr1; + vasysimul *SimulExpr2; + char *SimulValue1; + char *SimulValue2; + chain_list *ScanChain; + vexexpr *Operand; + int Value1; + int Value2; + long Oper; + short Width; + int Position; + int Negative; + + Oper = GetVexOperValue( Expr ); + Width = Expr->WIDTH; + + Negative = isvexnegativeoper( Oper ); + + if ( Negative ) Oper = getvexnotoper( Oper ); + + if ( Oper == VEX_IFT ) Oper = VEX_AND; + + ScanChain = Expr->OPERAND; + Operand = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( Operand ); + SimulValue1 = SimulExpr1->VALUE; + + ScanChain = ScanChain->NEXT; + + while ( ScanChain != (chain_list *)0 ) + { + Operand = GetVexOperand( ScanChain ); + SimulExpr2 = VasySimulateVex( Operand ); + SimulValue2 = SimulExpr2->VALUE; + + for ( Position = 0; Position < Width; Position++ ) + { + Value1 = SimulValue1[ Position ]; + Value2 = SimulValue2[ Position ]; + + if ( Oper == VEX_AND ) + { + Value1 = VasyTruthTableAnd[ Value1 ][ Value2 ]; + } + else + if ( Oper == VEX_OR ) + { + Value1 = VasyTruthTableOr[ Value1 ][ Value2 ]; + } + else + { + Value1 = VasyTruthTableXor[ Value1 ][ Value2 ]; + } + + SimulValue1[ Position ] = Value1; + } + + VasySimulateDelSimul( SimulExpr2 ); + ScanChain = ScanChain->NEXT; + } + + if ( Negative ) + { + for ( Position = 0; Position < Width; Position++ ) + { + Value1 = SimulValue1[ Position ]; + + SimulValue1[ Position ] = VasyTruthTableNot[ Value1 ]; + } + } + + return( SimulExpr1 ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVex | +| | +\------------------------------------------------------------*/ + +static vasysimul *VasySimulateVex( Expr ) + + vexexpr *Expr; +{ + vasysimul *SimulExpr; + long Oper; + + SimulExpr = (vasysimul *)0; + + if ( IsVexNodeAtom( Expr ) ) + { + SimulExpr = VasySimulateVexAtom( Expr, 1 ); + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( VasySimulOperFunc[ Oper ] == NULL ) + { + VasyErrorLine( VASY_NOT_YET_IMPLEMENTED_ERROR, VasyVpnLine, "Operator" ); + } + + SimulExpr = (*VasySimulOperFunc[ Oper ])( Expr ); + } + else + { + VasyErrorLine( VASY_NOT_YET_IMPLEMENTED_ERROR, VasyVpnLine, "Function" ); + } + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, " +++ VasySimulateVex " ); + viewvexexprboundln( Expr ); + } + + if ( IsVasyDebugLevel2() ) + { + VasySimulateViewSimul( SimulExpr ); + } + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexGuard | +| | +\------------------------------------------------------------*/ + +static int VasySimulateVexGuard( VpnFigure, VexGuard ) + + vpnfig_list *VpnFigure; + vexexpr *VexGuard; +{ + vasysimul *GuardSimul; + char *GuardValue; + int Guard; + + VasyFigure = VpnFigure; + GuardSimul = VasySimulateVex( VexGuard ); + GuardValue = GuardSimul->VALUE; + + if ( GuardValue[ 0 ] == VEX_ONE_ID ) Guard = 1; + else Guard = 0; + + VasySimulateDelSimul( GuardSimul ); + + return( Guard ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVexExpr | +| | +\------------------------------------------------------------*/ + +vasysimul *VasySimulateVexExpr( VpnFigure, VexAtom, VexExpr ) + + vpnfig_list *VpnFigure; + vexexpr *VexAtom; + vexexpr *VexExpr; +{ + vasysimul *SimulExpr; + short Signed; + + VasyFigure = VpnFigure; + SimulExpr = VasySimulateVex( VexExpr ); + + if ( IsVexAtomSigned( VexAtom ) ) Signed = 1; + else Signed = 0; + + SimulExpr = VasySimulateResizeSimul( SimulExpr, VexAtom->WIDTH, Signed ); + + return( SimulExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateGetVpnActAtom | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasySimulateGetVpnActAtom( VpnFigure, VpnAction ) + + vpnfig_list *VpnFigure; + vpnact_list *VpnAction; +{ + vasysimul *SimulExpr1; + chain_list *ScanChain; + vexexpr *VexExpr; + vexexpr *VexAtom; + vexexpr *Operand; + long Oper; + int IndexFrom; + int IndexTo; + int IndexMin; + int IndexMax; + int Width; + int PosMin; + int PosMax; + + VexExpr = VpnAction->VEX_ATOM; + + if ( IsVexNodeAtom( VexExpr ) ) return( VexExpr ); + + if ( ! IsVexNodeOper( VexExpr ) ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VpnAction->LINE, "bad assigment" ); + } + + Oper = GetVexOperValue( VexExpr ); + + if ( ( Oper != VEX_INDEX ) && + ( Oper != VEX_DOWNTO ) && + ( Oper != VEX_TO ) ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VpnAction->LINE, "bad assigment" ); + } + + VasyFigure = VpnFigure; + VasyVpnLine = VpnAction->LINE; + + ScanChain = VexExpr->OPERAND; + VexAtom = GetVexOperand( ScanChain ); + + ScanChain = ScanChain->NEXT; + Operand = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( Operand ); + + IndexFrom = VasySimulateIntegerSimul( SimulExpr1 ); + VasySimulateDelSimul( SimulExpr1 ); + + if ( Oper != VEX_INDEX ) + { + ScanChain = ScanChain->NEXT; + Operand = GetVexOperand( ScanChain ); + SimulExpr1 = VasySimulateVex( Operand ); + + IndexTo = VasySimulateIntegerSimul( SimulExpr1 ); + VasySimulateDelSimul( SimulExpr1 ); + } + else + { + IndexTo = IndexFrom; + } + + VexExpr = dupvexnode( VexAtom ); + + if ( Oper == VEX_DOWNTO ) + { + IndexMin = IndexTo; + IndexMax = IndexFrom; + + SetVexAtomDown( VexExpr ); + } + else + { + IndexMin = IndexFrom; + IndexMax = IndexTo; + + SetVexAtomUp( VexExpr ); + } + + Width = ( IndexMax - IndexMin ) + 1; + + if ( Width <= 0 ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VpnAction->LINE, "negative width" ); + } + + PosMin = getvexvectorpos( VexAtom, IndexMin ); + PosMax = getvexvectorpos( VexAtom, IndexMax ); + + if ( ( PosMin == -1 ) || + ( PosMax == -1 ) ) + { + VasyErrorLine( VASY_ERROR_IN_SIMULATION, VpnAction->LINE, "index out of bound" ); + } + + VexExpr->LEFT = IndexFrom; + VexExpr->RIGHT = IndexTo; + VexExpr->WIDTH = Width; + + SetVexAtomStaWidth( VexExpr ); + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVpnAct | +| | +\------------------------------------------------------------*/ + +static void VasySimulateVpnAct( VpnFigure, VpnProc, VpnAction ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnact_list *VpnAction; +{ + vpndecl_list *AsgDeclar; + vpnsym *AsgSymbol; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + vasysimul *AsgSimul; + char *AsgValue; + char *AtomValue; + int AsgWidth; + int AsgIndex; + int Position; + + VasyVpnLine = VpnAction->LINE; + + AsgAtom = VasySimulateGetVpnActAtom( VpnFigure, VpnAction ); + AsgExpr = VpnAction->VEX_EXPR; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, ">> Simulation Of " ); + viewvexexprbound( AsgAtom ); + fprintf( stdout, " : " ); + viewvexexprboundln( AsgExpr ); + } + + AsgSimul = VasySimulateVexExpr( VpnFigure, AsgAtom, AsgExpr ); + AsgValue = AsgSimul->VALUE; + + AtomValue = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomValue ); + AsgWidth = AsgAtom->WIDTH; + + for ( Position = 0; Position < AsgWidth; Position++ ) + { + AsgIndex = getvexvectorindex( AsgAtom, Position ); + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + + if ( ( AsgDeclar->TYPE == VPN_DECLAR_DEFINE ) || + ( AsgDeclar->TYPE == VPN_DECLAR_VARIABLE ) ) + { + AsgSymbol->EFFEC = AsgValue[ Position ]; + } + else + { + AsgSymbol->DRIVE = AsgValue[ Position ]; + } + } + + if ( IsVasyDebugLevel1() ) + { + VasySimulateViewSimul( AsgSimul ); + } + + VasySimulateDelSimul( AsgSimul ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "<<\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVpnPlace | +| | +\------------------------------------------------------------*/ + +static int VasySimulateVpnPlace( VpnFigure, VpnProc, BeginPlace ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnplace_list *BeginPlace; +{ + chain_list *ScanTrans; + vpnarc *VpnArc; + vpntrans_list *VpnTrans; + vpnplace_list *VpnPlace; + vpnact_list *VpnAct; + + VpnPlace = (vpnplace_list *)0; + + do + { + if ( IsVasySimulateLoop( BeginPlace ) ) + { + VasyErrorLine( VASY_LOOP_IN_SIMULATION, BeginPlace->LINE, BeginPlace->NAME ); + } + + IncVasySimulateLoop( BeginPlace ); + + VpnTrans = (vpntrans_list *)0; + + for ( ScanTrans = BeginPlace->TRANS_OUT; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( VpnTrans->VEX_GUARD != (vexexpr *)0 ) + { + VasyVpnLine = VpnPlace->LINE; + + if ( VasySimulateVexGuard( VpnFigure, VpnTrans->VEX_GUARD ) ) + { + break; + } + } + } + + if ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) + { + VpnProc->ELABO = VpnTrans; + + BeginPlace->TOKEN = 1; + + break; + } + + for ( VpnAct = VpnTrans->ACT; + VpnAct != (vpnact_list *)0; + VpnAct = VpnAct->NEXT ) + { + VasySimulateVpnAct( VpnFigure, VpnProc, VpnAct ); + } + + BeginPlace = VpnPlace; + } + while ( 1 ); + + for ( VpnPlace = VpnProc->PLACE; + VpnPlace != (vpnplace_list *)0; + VpnPlace = VpnPlace->NEXT ) + { + ClearVasySimulateLoop( VpnPlace ); + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| VasySimulateVpnProc | +| | +\------------------------------------------------------------*/ + +void VasySimulateVpnProc( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vpnplace_list *VpnPlace; + vpnplace_list *ElaboPlace; + vpntrans_list *ElaboTrans; +/*\ + vpntrans_list *VpnTrans; + chain_list *ScanTrans; +\*/ + vpnarc *VpnArc; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySimulateVpnProc %s\n", VpnProc->NAME ); + } + + ElaboTrans = VpnProc->ELABO; + VpnArc = GetVpnArc( ElaboTrans->PLACE_IN ); + ElaboPlace = GetVpnArcSourcePlace( VpnArc ); + + VpnArc = GetVpnArc( ElaboTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); +/* +** Change the first Sup_Wait transition +*/ + ElaboPlace->TOKEN = 0; + + VpnProc->ELABO = (vpntrans_list *)0; + + if ( ElaboTrans->TYPE == VPN_TRANS_SUP_WAIT ) + { + ElaboTrans->TYPE = VPN_TRANS_IMMEDIATE; + } +/*\ + for ( ScanTrans = DelPlace->TRANS_IN; + ScanTrans != (chain_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + VpnArc = GetVpnArc( ScanTrans ); + VpnTrans = GetVpnArcSourceTrans( VpnArc ); + + addvpnarctrans( VpnFigure, VpnTrans, VpnPlace ); + } + + delvpntrans( VpnFigure, ElaboTrans ); + delvpnplace( VpnFigure, ElaboPlace ); + + if ( IsVasyDebugLevel1() ) + { + VasyDebugSaveVpnFig( VpnFigure ); + } +\*/ +/* +** Start elaboration from the first process place +*/ + VasySimulateVpnPlace( VpnFigure, VpnProc, VpnPlace ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySimulateVpnProc %s\n", VpnProc->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_simul.h b/alliance/src/vasy/src/vasy_simul.h new file mode 100644 index 00000000..d1dc47d5 --- /dev/null +++ b/alliance/src/vasy/src/vasy_simul.h @@ -0,0 +1,101 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_simul.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 28.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_SIMUL_H +# define VASY_SIMUL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Loop | +| | +\------------------------------------------------------------*/ + +# define VASY_MAX_SIMULATE_LOOP 1000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define SetVasySymbolInOut( S, IO ) ((S)->FLAGS = IO ) +# define GetVasySymbolInOut( S ) ((S)->FLAGS ) + +# define SetVasySymbolEvent( S, E ) ((S)->USER = (void *)E ) +# define GetVasySymbolEvent( S ) ((paevt_list *)(S)->USER ) + +# define IncVasySimulateLoop( O ) ((O)->FLAGS++ ) +# define ClearVasySimulateLoop( O ) ((O)->FLAGS = 0) +# define IsVasySimulateLoop( O ) ((O)->FLAGS == VASY_MAX_SIMULATE_LOOP) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ + + typedef struct vasysimul + { + char *VALUE; + short WIDTH; + short SIGNED; + + } vasysimul; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasySimulateDelSimul(); + extern vasysimul *VasySimulateVexExpr(); + extern void VasySimulateVpnProc(); + +# endif diff --git a/alliance/src/vasy/src/vasy_support.c b/alliance/src/vasy/src/vasy_support.c new file mode 100644 index 00000000..aacede0b --- /dev/null +++ b/alliance/src/vasy/src/vasy_support.c @@ -0,0 +1,1812 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_support.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_shared.h" +# include "vasy_support.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashBitVec = (authtable *)0; + static authtable *VasyHashAssign = (authtable *)0; + static authtable *VasyHashReadError = (authtable *)0; + static auth2table *VasyHash2Support = (auth2table *)0; + static auth2table *VasyHash2Literal = (auth2table *)0; + static auth2table *VasyHash2Event = (auth2table *)0; + + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + static vpnsym *VasySymbolError = (vpnsym *)0; + static int VasyArithmetic = 0; + + static chain_list **VasySupport = (chain_list **)0; + static chain_list **VasyLiteral = (chain_list **)0; + static chain_list **VasyEvent = (chain_list **)0; + + static short VasyMaxPosition = 0; + + static authtable *VasyHashSupportBit = (authtable *)0; + static chain_list *VasySupportBit = (chain_list *)0; + static authtable *VasyHashEventBit = (authtable *)0; + static chain_list *VasyEventBit = (chain_list *)0; + + static vpnline_list *VasyVpnLine = (vpnline_list *)0; + + static char VasyOperSupportMode[ VEX_MAX_OPERATOR ] = + { + VASY_SUPPORT_ERROR, /* VEX_CONCAT */ + VASY_SUPPORT_LOGIC, /* VEX_NOT */ + VASY_SUPPORT_ARITH, /* VEX_NEG */ + VASY_SUPPORT_LOGIC, /* VEX_EVENT */ + VASY_SUPPORT_LOGIC, /* VEX_OR */ + VASY_SUPPORT_LOGIC, /* VEX_AND */ + VASY_SUPPORT_LOGIC, /* VEX_XOR */ + VASY_SUPPORT_LOGIC, /* VEX_NOR */ + VASY_SUPPORT_LOGIC, /* VEX_NAND */ + VASY_SUPPORT_LOGIC, /* VEX_NXOR */ + VASY_SUPPORT_ARITH, /* VEX_EQ */ + VASY_SUPPORT_ARITH, /* VEX_NE */ + VASY_SUPPORT_ARITH, /* VEX_LT */ + VASY_SUPPORT_ARITH, /* VEX_LE */ + VASY_SUPPORT_ARITH, /* VEX_GT */ + VASY_SUPPORT_ARITH, /* VEX_GE */ + VASY_SUPPORT_ARITH, /* VEX_ADD */ + VASY_SUPPORT_ARITH, /* VEX_SUB */ + VASY_SUPPORT_ARITH, /* VEX_MUL */ + VASY_SUPPORT_ARITH, /* VEX_DIV */ + VASY_SUPPORT_ARITH, /* VEX_EXP */ + VASY_SUPPORT_ARITH, /* VEX_MOD */ + VASY_SUPPORT_ARITH, /* VEX_REM */ + VASY_SUPPORT_ERROR, /* VEX_TO */ + VASY_SUPPORT_ERROR, /* VEX_DOWNTO */ + VASY_SUPPORT_ERROR, /* VEX_INDEX */ + VASY_SUPPORT_ERROR, /* VEX_LEFT */ + VASY_SUPPORT_ERROR, /* VEX_RIGHT */ + VASY_SUPPORT_ERROR, /* VEX_LOW */ + VASY_SUPPORT_ERROR, /* VEX_HIGH */ + VASY_SUPPORT_ERROR, /* VEX_LENGTH */ + VASY_SUPPORT_ERROR, /* VEX_RANGE */ + VASY_SUPPORT_ERROR, /* VEX_REV_RANGE */ + VASY_SUPPORT_ERROR, /* VEX_DRIVER */ + VASY_SUPPORT_LOGIC, /* VEX_IFT */ + VASY_SUPPORT_ERROR, /* VEX_ARRAY */ + VASY_SUPPORT_ERROR, /* VEX_INDEX_N */ + VASY_SUPPORT_ERROR, /* VEX_OTHERS */ + VASY_SUPPORT_ERROR, /* VEX_NUM_BIT */ + VASY_SUPPORT_ARITH /* VEX_ABS */ + }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasySupportViewHashSymbol | +| | +\------------------------------------------------------------*/ + +/* +static void VasySupportViewHashSymbol( Element ) + + authelem *Element; +{ + vpnsym *VpnSymbol; + + VpnSymbol = (vpnsym *)Element->KEY; + fprintf( stdout, "Sym %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); +} +*/ + +/*------------------------------------------------------------\ +| | +| VasySupportViewHashName | +| | +\------------------------------------------------------------*/ + +/* +static void VasySupportViewHashName( Element ) + + authelem *Element; +{ + fprintf( stdout, "%s\n", (char *)Element->KEY ); +} +*/ + +/*------------------------------------------------------------\ +| | +| VasySupportViewVpnAct | +| | +\------------------------------------------------------------*/ + +static void VasySupportViewVpnAct( VpnTrans ) + + vpntrans_list *VpnTrans; +{ + chain_list **Support; + chain_list **Literal; + chain_list **Event; + unsigned char *Flags; + chain_list *ScanChain; + vpnact_list *VpnAction; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + vpnsym *AsgSymbol; + char *VexLiteral; + char *AtomName; + int AsgIndex; + int AsgPos; + int AsgWidth; + int AsgStep; + + VasyPrintf( stdout, "--> VasySupportViewVpnAct\n" ); + + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + AsgAtom = VpnAction->VEX_ATOM; + AsgExpr = VpnAction->VEX_EXPR; + AtomName = GetVexAtomValue( AsgAtom ); + Support = GetVasyVpnActInfoSupport( VpnAction ); + Literal = GetVasyVpnActInfoLiteral( VpnAction ); + Event = GetVasyVpnActInfoEvent( VpnAction ); + Flags = GetVasyVpnActInfoFlags( VpnAction ); + + viewvexexprbound( AsgAtom ); + fprintf( stdout, " <<< " ); + viewvexexprboundln( AsgExpr ); + + if ( IsVexAtomDown( AsgAtom ) ) AsgStep = -1; + else AsgStep = 1; + + AsgIndex = AsgAtom->LEFT; + AsgWidth = AsgAtom->WIDTH; + + while ( AsgWidth != 0 ) + { + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + VasyPrintf( stdout, "%s[%d] %x > ", AtomName, AsgIndex, (int)Flags[ AsgPos ] ); + + for ( ScanChain = Support[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + AsgSymbol = (vpnsym *)ScanChain->DATA; + fprintf( stdout, "%s[%d] ", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + fprintf( stdout, "\n" ); + VasyPrintf( stdout, "%s[%d] ! ", AtomName, AsgIndex ); + + for ( ScanChain = Literal[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VexLiteral = (char *)ScanChain->DATA; + fprintf( stdout, "%s ", VexLiteral ); + } + + fprintf( stdout, "\n" ); + VasyPrintf( stdout, "%s[%d] * ", AtomName, AsgIndex ); + + for ( ScanChain = Event[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + AsgSymbol = (vpnsym *)ScanChain->DATA; + fprintf( stdout, "%s[%d] ", AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + fprintf( stdout, "\n" ); + + AsgIndex += AsgStep; + AsgWidth--; + } + } + + VasyPrintf( stdout, "<-- VasySupportViewVpnAct\n" ); +} + +/*------------------------------------------------------------\ +| | +| VasySupportUsedVpnSymbol | +| | +\------------------------------------------------------------*/ + +static void VasySupportUsedVpnSymbol( AsgSymbol ) + + vpnsym *AsgSymbol; +{ + vpnact_list *VpnAction; + vpndecl_list *AsgDeclar; + vpnsym *VpnSymbol; + vexexpr *AsgAtom; + authelem *Element; + vasyactinfo *ActInfo; + chain_list **Support; + unsigned char *Flags; + chain_list *ScanChain; + int AsgPos; + + AsgDeclar = AsgSymbol->DECL; + + if ( ! isvextypedivisible( AsgDeclar->BASE ) ) + { + Element = searchauthelem( VasyHashAssign, AsgSymbol->NAME ); + } + else + { + Element = searchauthelem( VasyHashBitVec, (char*)AsgSymbol ); + } + + if ( Element == (authelem *)0 ) return; + + VpnAction = (vpnact_list *)Element->VALUE; + ActInfo = GetVasyVpnActInfo( VpnAction ); + + Support = ActInfo->SUPPORT; + Flags = ActInfo->FLAGS; + + AsgAtom = VpnAction->VEX_ATOM; + AsgPos = getvexvectorpos( AsgAtom, AsgSymbol->INDEX ); + + if ( ! IsVasyVpnActInfoUsed( Flags[ AsgPos ] ) ) + { + SetVasyVpnActInfoUsed( Flags[ AsgPos ] ); + + for ( ScanChain = Support[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + + if ( VpnSymbol != AsgSymbol ) + { + VasySupportUsedVpnSymbol( VpnSymbol ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportUsedVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasySupportUsedVpnTrans( VpnFigure, VpnProc, VpnTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + vpnact_list *VpnAction; + vasyactinfo *VasyAction; + vpndecl_list *AsgDeclar; + vpnsym *VpnSymbol; + vpnsym *AsgSymbol; + vexexpr *AsgAtom; + vexexpr *VexGuard; + chain_list *SupportGuard; + chain_list **Support; + chain_list *ScanChain; + char *AtomName; + unsigned char *Flags; + int AsgIndex; + int AsgMin; + int AsgMax; + int AsgPos; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + + VasyHashAssign = TransInfo->HASH_ASSIGN; + VasyHashBitVec = TransInfo->HASH_BITVEC; + + VexGuard = VpnTrans->VEX_GUARD; + + if ( VexGuard != (vexexpr *)0 ) + { + SupportGuard = VasySupportVpnTransBitVex( VpnFigure, VpnProc, VpnTrans, VexGuard ); + + for ( ScanChain = SupportGuard; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasySupportUsedVpnSymbol( VpnSymbol ); + } + + freechain( SupportGuard ); + } + + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + if ( ( VpnAction->TYPE == VPN_ACT_ASG_SIGNAL ) || + ( VpnAction->TYPE == VPN_ACT_ASG_PORT ) ) + { + VasyAction = GetVasyVpnActInfo( VpnAction ); + Support = VasyAction->SUPPORT; + Flags = VasyAction->FLAGS; + + AsgAtom = VpnAction->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + SetVasyVpnActInfoUsed( Flags[ AsgPos ] ); + + for ( ScanChain = Support[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + + if ( VpnSymbol != AsgSymbol ) + { + VasySupportUsedVpnSymbol( VpnSymbol ); + } + } + } + } + } + + if ( IsVasyDebugLevel0() ) + { + VasySupportViewVpnAct( VpnTrans ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportEventVpnSymbol | +| | +\------------------------------------------------------------*/ + +static void VasySupportEventVpnSymbol( PosSupp, Position, VpnSymbol ) + + int PosSupp; + int Position; + vpnsym *VpnSymbol; +{ + auth2elem *Element2; + + Position += PosSupp; + Element2 = searchauth2elem( VasyHash2Event, (char*)&VasyEvent[ Position ], (char*)VpnSymbol ); + + if ( Element2 == (auth2elem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "+ " ); + } + + VasyEvent[ Position ] = addchain( VasyEvent[ Position ], VpnSymbol ); + addauth2elem( VasyHash2Event, (char*)&VasyEvent[ Position ], (char*)VpnSymbol, 0 ); + } + else + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "* " ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Event[ %d ] <= %s %d\n", + Position, VpnSymbol->NAME, VpnSymbol->INDEX ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportVpnSymbol | +| | +\------------------------------------------------------------*/ + +static void VasySupportVpnSymbol( PosSupp, Position, VpnSymbol ) + + int PosSupp; + int Position; + vpnsym *VpnSymbol; +{ + auth2elem *Element2; + + Position += PosSupp; + Element2 = searchauth2elem( VasyHash2Support, + (char*)&VasySupport[ Position ], (char*)VpnSymbol ); + + if ( Element2 == (auth2elem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "+ " ); + } + + VasySupport[ Position ] = addchain( VasySupport[ Position ], VpnSymbol ); + addauth2elem( VasyHash2Support, (char*)&VasySupport[ Position ], (char*)VpnSymbol, 0 ); + } + else + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "* " ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Support[ %d ] <= %s %d\n", + Position, VpnSymbol->NAME, VpnSymbol->INDEX ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportVexLiteral | +| | +\------------------------------------------------------------*/ + +static void VasySupportVexLiteral( PosSupp, Position, Literal ) + + int PosSupp; + int Position; + char *Literal; +{ + auth2elem *Element2; + + Position += PosSupp; + Element2 = searchauth2elem( VasyHash2Literal, + (char*)&VasyLiteral[ Position ], (char*)Literal ); + + if ( Element2 == (auth2elem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "+ " ); + } + + VasyLiteral[ Position ] = addchain( VasyLiteral[ Position ], Literal ); + addauth2elem( VasyHash2Literal, (char*)&VasyLiteral[ Position ], (char*)Literal, 0 ); + } + else + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "* " ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Literal[ %d ] <= %s\n", Position, Literal ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportVex | +| | +\------------------------------------------------------------*/ + +static void VasySupportVex( PosSupp, PosFrom, PosTo, Expr, Mode ) + + unsigned short PosSupp; + unsigned short PosFrom; + unsigned short PosTo; + vexexpr *Expr; + unsigned char Mode; +{ + vpnact_list *VpnAction; + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + char *VexLiteral; + char *AtomName; + chain_list **DupSupport; + chain_list **DupLiteral; + chain_list **DupEvent; + chain_list *ScanChain; + authelem *Element; + vexexpr *Operand; + vexexpr *Operand2; + unsigned char NewMode; + long Oper; + int LiteralId; + int Position; + int DupPosition; + int Index; + + if ( Expr == (vexexpr *)0 ) return; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "VasySupportVex %d %d %d Mode %d-> \n", + PosSupp, PosFrom, PosTo, Mode ); + viewvexexprboundln( Expr ); + } + + Oper = -1; + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_CONCAT ) + { + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + + if ( Mode != VASY_SUPPORT_ARITH ) + { + PosFrom = 0; + PosTo = Operand->WIDTH - 1; + } + + VasySupportVex( PosSupp, PosFrom, PosTo, Operand, Mode ); + + if ( Mode != VASY_SUPPORT_ARITH ) PosSupp += Operand->WIDTH; + } + } + else + if ( Oper == VEX_EVENT ) + { + Expr = GetVexOperand( Expr->OPERAND ); + } + else + { + NewMode = VasyOperSupportMode[ Oper ]; + + if ( NewMode == VASY_SUPPORT_ERROR ) + { + VasyErrorLine( VASY_ERROR_IN_SUPPORT, VasyVpnLine, VEX_OPER_NAME[ Oper ] ); + } + else + if ( NewMode == VASY_SUPPORT_ARITH ) + { + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) ) + { + Operand = GetVexOperand( Expr->OPERAND ); + Operand2 = GetVexOperand( Expr->OPERAND->NEXT ); + + if ( ( Operand->WIDTH == 1 ) && + ( Operand2->WIDTH == 1 ) ) + { + NewMode = VASY_SUPPORT_LOGIC; + } + else + if ( Operand->WIDTH != Operand2->WIDTH ) + { + VasyArithmetic = 1; + } + } + else + { + VasyArithmetic = 1; + } + } + + if ( Mode != VASY_SUPPORT_ARITH ) Mode = NewMode; + + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + VasySupportVex( PosSupp, PosFrom, PosTo, Operand, Mode ); + } + } + } + + if ( IsVexNodeAtom( Expr ) ) + { + AtomName = GetVexAtomValue( Expr ); + + if ( IsVexAtomLiteral( Expr ) ) + { + if ( Mode == VASY_SUPPORT_LOGIC ) + { + for ( Position = PosFrom; Position <= PosTo; Position++ ) + { + if ( Position >= Expr->WIDTH ) DupPosition = Expr->WIDTH - 1; + else DupPosition = Position; + + LiteralId = getvexliteralid( AtomName[ DupPosition + 1 ] ); + + if ( LiteralId != -1 ) + { + VexLiteral = VEX_ATOM_BY_ID[ LiteralId ]; + VasySupportVexLiteral( PosSupp, Position, VexLiteral ); + } + } + } + else + { + for ( Position = PosFrom; Position <= PosTo; Position++ ) + { + for ( DupPosition = 0; DupPosition < Expr->WIDTH; DupPosition++ ) + { + LiteralId = getvexliteralid( AtomName[ DupPosition + 1 ] ); + + if ( LiteralId != -1 ) + { + VexLiteral = VEX_ATOM_BY_ID[ LiteralId ]; + VasySupportVexLiteral( PosSupp, Position, VexLiteral ); + } + } + } + } + + return; + } + + VpnDeclar = searchvpndeclall( VasyFigure, AtomName ); +/* +** Checks the Atom's type +*/ + if ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) + { +/* +** Atom is a define, verify if it is read only (variable register) ! +*/ + for ( Position = PosFrom; Position <= PosTo; Position++ ) + { + if ( Position >= Expr->WIDTH ) DupPosition = Expr->WIDTH - 1; + else DupPosition = Position; + + Index = getvexvectorindex( Expr, DupPosition ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + Element = searchauthelem( VasyHashReadError, (char*)VpnSymbol ); + + if ( Element != (authelem *)0 ) + { + VasyPrintf( stdout, "Error !!! %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); + VasySymbolError = (vpnsym *)Element->VALUE; + } + } +/* +** Atom is a define, duplicate its support list +*/ + VpnAction = (vpnact_list *)0; + DupSupport = (chain_list **)0; + DupLiteral = (chain_list **)0; + DupEvent = (chain_list **)0; + + if ( ! isvextypedivisible( VpnDeclar->BASE ) ) + { +/* +** Atom is a define and its base is not bit_vector +*/ + Element = searchauthelem( VasyHashAssign, AtomName ); + VpnAction = (vpnact_list *)Element->VALUE; + + DupSupport = GetVasyVpnActInfoSupport( VpnAction ); + DupLiteral = GetVasyVpnActInfoLiteral( VpnAction ); + DupEvent = GetVasyVpnActInfoEvent( VpnAction ); + } + + for ( Position = PosFrom; Position <= PosTo; Position++ ) + { + if ( Position >= Expr->WIDTH ) DupPosition = Expr->WIDTH - 1; + else DupPosition = Position; + + Index = getvexvectorindex( Expr, DupPosition ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + if ( isvextypedivisible( VpnDeclar->BASE ) ) + { +/* +** Atom is a define and its base is bit_vector +*/ + Element = searchauthelem( VasyHashBitVec, (char*)VpnSymbol ); + VpnAction = (vpnact_list *)Element->VALUE; + + DupSupport = GetVasyVpnActInfoSupport( VpnAction ); + DupLiteral = GetVasyVpnActInfoLiteral( VpnAction ); + DupEvent = GetVasyVpnActInfoEvent( VpnAction ); + } +/* +** Duplicate support of Atom in support list +*/ + if ( Mode == VASY_SUPPORT_LOGIC ) + { + DupPosition = getvexvectorpos( VpnAction->VEX_ATOM, Index ); + + for ( ScanChain = DupSupport[ DupPosition ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasySupportVpnSymbol( PosSupp, Position, VpnSymbol ); + } + + for ( ScanChain = DupLiteral[ DupPosition ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VexLiteral = (char *)ScanChain->DATA; + VasySupportVexLiteral( PosSupp, Position, VexLiteral ); + } + + for ( ScanChain = DupEvent[ DupPosition ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasySupportEventVpnSymbol( PosSupp, Position, VpnSymbol ); + } + } + else + { + for ( DupPosition = 0; DupPosition < Expr->WIDTH; DupPosition++ ) + { + for ( ScanChain = DupSupport[ DupPosition ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasySupportVpnSymbol( PosSupp, Position, VpnSymbol ); + } + + for ( ScanChain = DupLiteral[ DupPosition ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VexLiteral = (char *)ScanChain->DATA; + VasySupportVexLiteral( PosSupp, Position, VexLiteral ); + } + + for ( ScanChain = DupEvent[ DupPosition ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasySupportEventVpnSymbol( PosSupp, Position, VpnSymbol ); + } + } + } + } + } + + if ( ( VpnDeclar->TYPE == VPN_DECLAR_PORT ) || + ( VpnDeclar->TYPE == VPN_DECLAR_SIGNAL ) || + ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) || + ( VpnDeclar->TYPE == VPN_DECLAR_VARIABLE ) ) + { +/* +** Atom is a port, a signal a define or a variable, add it in the support list +*/ + if ( Mode == VASY_SUPPORT_LOGIC ) + { + for ( Position = PosFrom; Position <= PosTo; Position++ ) + { + if ( Position >= Expr->WIDTH ) DupPosition = Expr->WIDTH - 1; + else DupPosition = Position; + + Index = getvexvectorindex( Expr, DupPosition ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + VasySupportVpnSymbol( PosSupp, Position, VpnSymbol ); + + if ( Oper == VEX_EVENT ) + { + VasySupportEventVpnSymbol( PosSupp, Position, VpnSymbol ); + } + } + } + else + { + for ( Position = PosFrom; Position <= PosTo; Position++ ) + { + for ( DupPosition = 0; DupPosition < Expr->WIDTH; DupPosition++ ) + { + Index = getvexvectorindex( Expr, DupPosition ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + VasySupportVpnSymbol( PosSupp, Position, VpnSymbol ); + + if ( Oper == VEX_EVENT ) + { + VasySupportEventVpnSymbol( PosSupp, Position, VpnSymbol ); + } + } + } + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportVpnAct | +| | +\------------------------------------------------------------*/ + +static chain_list **VasySupportVpnAct( VpnFigure, VpnProc, VpnAction ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnact_list *VpnAction; +{ + vasybivex_list *ScanBiVex; + vasyactinfo *ActInfo; + vasysyminfo *SymInfo; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + int PosFrom; + int PosTo; + int AsgPos; + int Position; + unsigned char *Flags; + + ActInfo = GetVasyVpnActInfo( VpnAction ); + + VasyVpnLine = VpnAction->LINE; + + AsgAtom = VpnAction->VEX_ATOM; + AsgExpr = VpnAction->VEX_EXPR; + + VasyFigure = VpnFigure; + VasySymbolError = (vpnsym *)0; + VasySupport = GetVasyVpnActInfoSupport( VpnAction ); + VasyLiteral = GetVasyVpnActInfoLiteral( VpnAction ); + VasyEvent = GetVasyVpnActInfoEvent( VpnAction ); + VasyArithmetic = 0; + + VasyMaxPosition = AsgAtom->WIDTH; + + PosFrom = 0; + PosTo = 0; + + if ( ActInfo->SPLIT ) + { + for ( AsgPos = 0; AsgPos < AsgAtom->WIDTH; AsgPos++ ) + { + SymInfo = &ActInfo->SYM_INFO[ AsgPos ]; + + if ( SymInfo->TYPE != VASY_SYM_UNKNOWN ) + { + if ( PosFrom < PosTo ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, ">> Support Of [%d-%d] ", PosFrom, PosTo ); + viewvexexprbound( AsgAtom ); + fprintf( stdout, " : " ); + viewvexexprboundln( AsgExpr ); + } + + VasySupportVex( PosFrom, PosFrom, PosTo - 1, AsgExpr, VASY_SUPPORT_LOGIC ); + } + + if ( SymInfo->TYPE != VASY_SYM_UNUSED ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, ">> Support Of [%d-%d] %d ", AsgPos, AsgPos, SymInfo->TYPE); + viewvexexprbound( AsgAtom ); + fprintf( stdout, " : " ); + + viewvexexprboundln( SymInfo->VEX_DATA ); + + for ( ScanBiVex = SymInfo->BIVEX; + ScanBiVex != (vasybivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + viewvexexprboundln( ScanBiVex->VEX_COND ); + viewvexexprboundln( ScanBiVex->VEX_DATA ); + } + } + + VasySupportVex( AsgPos, 0, 0, SymInfo->VEX_DATA, VASY_SUPPORT_LOGIC ); + + for ( ScanBiVex = SymInfo->BIVEX; + ScanBiVex != (vasybivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VasySupportVex( AsgPos, 0, 0, ScanBiVex->VEX_COND, VASY_SUPPORT_LOGIC ); + VasySupportVex( AsgPos, 0, 0, ScanBiVex->VEX_DATA, VASY_SUPPORT_LOGIC ); + } + } + + PosFrom = AsgPos + 1; + PosTo = PosFrom; + } + else + { + PosTo++; + } + } + } + else + { + PosTo = AsgAtom->WIDTH; + } + + if ( PosFrom < PosTo ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, ">> Support Of [%d-%d] ", PosFrom, PosTo ); + viewvexexprbound( AsgAtom ); + fprintf( stdout, " : " ); + viewvexexprboundln( AsgExpr ); + } + + VasySupportVex( PosFrom, PosFrom, PosTo - 1, AsgExpr, VASY_SUPPORT_LOGIC ); + } + + if ( VasySymbolError != (vpnsym *)0 ) + { + VasyPrintf( stdout, "Error !! READ VARIABLE %s %d\n", + VasySymbolError->NAME, VasySymbolError->INDEX ); + } + + if ( VasyArithmetic ) + { + Flags = GetVasyVpnActInfoFlags( VpnAction ); + + for ( Position = PosFrom; Position < PosTo; Position++ ) + { + SetVasyVpnActInfoArith( Flags[ Position ] ); + } + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "<<\n" ); + } + + return( VasySupport ); +} + +/*------------------------------------------------------------\ +| | +| VasySupportMergeVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasySupportMergeVpnTrans( VpnFigure, VpnProc, DefTrans, VpnTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *DefTrans; + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + vpnact_list *VpnAction; + vpnsym *AsgSymbol; + vpndecl_list *AsgDeclar; + vexexpr *AsgAtom; + char *AtomName; + int AsgIndex; + int AsgMin; + int AsgMax; + authtable *HashAssign; + authtable *HashBitVec; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + + HashAssign = TransInfo->HASH_ASSIGN; + HashBitVec = TransInfo->HASH_BITVEC; +/* +** Initialize all actions and put them in assign hash table +*/ + for ( VpnAction = DefTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + AsgAtom = VpnAction->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); +/* +** Add assign to bit_vector symbol V in hash table +*/ + if ( isvextypedivisible( AsgDeclar->BASE ) ) + { + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + addauthelem( HashBitVec, (char*)AsgSymbol, (long)VpnAction ); + } + } +/* +** Add assign to symbol V in hash table +*/ + addauthelem( HashAssign, AtomName, (long)VpnAction ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportCreateVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasySupportCreateVpnTrans( VpnFigure, VpnProc, VpnTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + vpnact_list *VpnAction; + vpnsym *AsgSymbol; + vpndecl_list *AsgDeclar; + vexexpr *AsgAtom; + char *AtomName; + int AsgIndex; + int AsgMin; + int AsgMax; + authtable *HashAssign; + authtable *HashBitVec; + + TransInfo = VasyAddVpnTransInfo( VpnTrans ); + + HashAssign = TransInfo->HASH_ASSIGN; + HashBitVec = TransInfo->HASH_BITVEC; +/* +** Initialize all actions and put them in assign hash table +*/ + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + AsgAtom = VpnAction->VEX_ATOM; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); +/* +** Add Vasy Action to each Vpn Action +*/ + VasyAddVpnActInfo( VpnAction ); +/* +** Add assign to bit_vector symbol V in hash table +*/ + if ( isvextypedivisible( AsgDeclar->BASE ) ) + { + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + addauthelem( HashBitVec, (char*)AsgSymbol, (long)VpnAction ); + } + } +/* +** Add assign to symbol V in hash table +*/ + addauthelem( HashAssign, AtomName, (long)VpnAction ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportResetVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasySupportResetVpnTrans( VpnFigure, VpnProc, VpnTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; +{ + vasytransinfo *TransInfo; + vpnact_list *VpnAction; + vexexpr *AsgAtom; + int AsgIndex; + chain_list **Support; + chain_list **Event; + chain_list **Literal; + unsigned char *Flags; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + + resetauth2table( TransInfo->HASH_SUPPORT ); + resetauth2table( TransInfo->HASH_LITERAL ); + resetauth2table( TransInfo->HASH_EVENT ); +/* +** Initialize all actions and put them in assign hash table +*/ + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + AsgAtom = VpnAction->VEX_ATOM; + + Support = GetVasyVpnActInfoSupport( VpnAction ); + Literal = GetVasyVpnActInfoLiteral( VpnAction ); + Event = GetVasyVpnActInfoEvent( VpnAction ); + Flags = GetVasyVpnActInfoFlags( VpnAction ); + + for ( AsgIndex = 0; AsgIndex < AsgAtom->WIDTH; AsgIndex++ ) + { + freechain( Support[ AsgIndex ] ); + freechain( Event[ AsgIndex ] ); + freechain( Literal[ AsgIndex ] ); + + Support[ AsgIndex ] = (chain_list *)0; + Literal[ AsgIndex ] = (chain_list *)0; + Event [ AsgIndex ] = (chain_list *)0; + Flags [ AsgIndex ] = 0; + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportDestroyVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasySupportDestroyVpnTrans( VpnFigure, VpnProc, VpnTrans ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; +{ + vpnact_list *VpnAction; + + VasyDelVpnTransInfo( VpnTrans ); +/* +** Del Vasy Action to each Vpn Action +*/ + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + VasyDelVpnActInfo( VpnAction ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportEventBitVpnSymbol | +| | +\------------------------------------------------------------*/ + +static void VasySupportEventBitVpnSymbol( VpnSymbol ) + + vpnsym *VpnSymbol; +{ + authelem *Element; + + Element = searchauthelem( VasyHashEventBit, (char*)VpnSymbol ); + + if ( Element == (authelem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "+ " ); + } + + VasyEventBit = addchain( VasyEventBit, VpnSymbol ); + addauthelem( VasyHashEventBit, (char*)VpnSymbol, 0 ); + } + else + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "* " ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "EventBit <= %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportEventBitVex | +| | +\------------------------------------------------------------*/ + +static void VasySupportEventBitVex( Expr ) + + vexexpr *Expr; +{ + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + char *AtomName; + chain_list *ScanChain; + vexexpr *Operand; + long Oper; + int Index; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "VasySupportEventBitVex -> \n" ); + viewvexexprboundln( Expr ); + } + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_EVENT ) + { + Expr = GetVexOperand( Expr->OPERAND ); + + AtomName = GetVexAtomValue( Expr ); + VpnDeclar = searchvpndeclall( VasyFigure, AtomName ); + + Index = getvexvectorindex( Expr, 0 ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + VasySupportEventBitVpnSymbol( VpnSymbol ); + } + else + { + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + VasySupportEventBitVex( Operand ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportVpnTransEventBitVex | +| | +\------------------------------------------------------------*/ + +chain_list *VasySupportVpnTransEventBitVex( VpnFigure, VpnProc, VexBit ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vexexpr *VexBit; +{ + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasySupportVpnTransEventBitVex\n" ); + } + + VasyFigure = VpnFigure; + + if ( VasyHashEventBit == (authtable *)0 ) + { + VasyHashEventBit = createauthtable( 50 ); + } + + VasyEventBit = (chain_list *)0; + VasySupportEventBitVex( VexBit ); + + resetauthtable( VasyHashEventBit ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " <-- VasySupportVpnTransEventBitVex\n" ); + } + + return( VasyEventBit ); +} + +/*------------------------------------------------------------\ +| | +| VasySupportBitVpnSymbol | +| | +\------------------------------------------------------------*/ + +static void VasySupportBitVpnSymbol( VpnSymbol ) + + vpnsym *VpnSymbol; +{ + authelem *Element; + + Element = searchauthelem( VasyHashSupportBit, (char*)VpnSymbol ); + + if ( Element == (authelem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "+ " ); + } + + VasySupportBit = addchain( VasySupportBit, VpnSymbol ); + addauthelem( VasyHashSupportBit, (char*)VpnSymbol, 0 ); + } + else + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "* " ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "SupportBit <= %s %d\n", VpnSymbol->NAME, VpnSymbol->INDEX ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySupportBitVex | +| | +\------------------------------------------------------------*/ + +static void VasySupportBitVex( Expr ) + + vexexpr *Expr; +{ + vpnact_list *VpnAction; + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + char *AtomName; + chain_list **Support; + chain_list *ScanChain; + authelem *Element; + vexexpr *Operand; + long Oper; + int Position; + int Index; + unsigned char Mode; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "VasySupportBitVex -> \n" ); + viewvexexprboundln( Expr ); + } + + if ( IsVexNodeAtom( Expr ) ) + { + AtomName = GetVexAtomValue( Expr ); + + if ( IsVexAtomLiteral( Expr ) ) return; + + VpnDeclar = searchvpndeclall( VasyFigure, AtomName ); +/* +** Checks the Atom's type +*/ + if ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) + { +/* +** Atom is a define (and width = 1), duplicate its support list +*/ + Index = getvexvectorindex( Expr, 0 ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + if ( ! isvextypedivisible( VpnDeclar->BASE ) ) + { +/* +** Atom is a define and its base is not bit_vector +*/ + Element = searchauthelem( VasyHashAssign, AtomName ); + VpnAction = (vpnact_list *)Element->VALUE; + } + else + { +/* +** Atom is a define and its base is bit_vector +*/ + Element = searchauthelem( VasyHashBitVec, (char*)VpnSymbol ); + VpnAction = (vpnact_list *)Element->VALUE; + } + + Support = GetVasyVpnActInfoSupport( VpnAction ); + Position = getvexvectorpos( VpnAction->VEX_ATOM, Index ); +/* +** Duplicate support of Atom in support list +*/ + for ( ScanChain = Support[ Position ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnSymbol = (vpnsym *)ScanChain->DATA; + VasySupportBitVpnSymbol( VpnSymbol ); + } + } + + if ( ( VpnDeclar->TYPE == VPN_DECLAR_PORT ) || + ( VpnDeclar->TYPE == VPN_DECLAR_SIGNAL ) || + ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) || + ( VpnDeclar->TYPE == VPN_DECLAR_VARIABLE ) ) + { +/* +** Atom is a port, a signal a define or a variable, add it in the support list +*/ + Index = getvexvectorindex( Expr, 0 ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + VasySupportBitVpnSymbol( VpnSymbol ); + } + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + Mode = VasyOperSupportMode[ Oper ]; + + if ( ( Oper == VEX_EQ ) && + ( Expr->WIDTH == 1 ) ) + { + Mode = VASY_SUPPORT_LOGIC; + } + + if ( ( Mode == VASY_SUPPORT_ERROR ) || + ( Mode == VASY_SUPPORT_ARITH ) ) + { + VasyErrorLine( VASY_ERROR_IN_SUPPORT, VasyVpnLine, VEX_OPER_NAME[ Oper ] ); + } + + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + VasySupportBitVex( Operand ); + } + } +} + + +/*------------------------------------------------------------\ +| | +| VasySupportVpnTransBitVex | +| | +\------------------------------------------------------------*/ + +chain_list *VasySupportVpnTransBitVex( VpnFigure, VpnProc, VpnTrans, VexBit ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vexexpr *VexBit; +{ + vasytransinfo *TransInfo; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasySupportVpnTransBitVex\n" ); + } + + VasyFigure = VpnFigure; + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + + VasyHashAssign = TransInfo->HASH_ASSIGN; + VasyHashBitVec = TransInfo->HASH_BITVEC; + + if ( VasyHashSupportBit == (authtable *)0 ) + { + VasyHashSupportBit = createauthtable( 100 ); + } + + VasySupportBit = (chain_list *)0; + VasySupportBitVex( VexBit ); + + resetauthtable( VasyHashSupportBit ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " <-- VasySupportVpnTransBitVex\n" ); + } + + return( VasySupportBit ); +} + +/*------------------------------------------------------------\ +| | +| VasySupportVpnTrans | +| | +\------------------------------------------------------------*/ + +void VasySupportVpnTrans( VpnFigure, VpnProc, VpnTrans, CheckVar ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + int CheckVar; +{ + vasytransinfo *TransInfo; + vpnact_list *VpnAction; + vpnact_list *VpnAction2; + vpnact_list *DefAction; + vpnsym *AsgSymbol; + vpnsym *DefSymbol; + vpnsym *AsgSymbol2; + vpndecl_list *AsgDeclar; + vpndecl_list *DefDeclar; + vpndecl_list *AsgDeclar2; + vexexpr *AsgAtom; + vexexpr *DefAtom; + vexexpr *AsgAtom2; + char *AtomName; + char *AtomName2; + authelem *Element; + auth2elem *Element2; + chain_list **Support; + chain_list **Support2; + chain_list **DefSupport; + chain_list **DefLiteral; + chain_list *ScanChain; + int AsgIndex; + int AsgIndex2; + int DefIndex; + int AsgMin; + int AsgMin2; + int AsgMax; + int AsgMax2; + int AsgPos; + int AsgPos2; + int DefPos; + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasySupportVpnTrans %s\n", VpnTrans->NAME ); + } + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + + VasyHashAssign = TransInfo->HASH_ASSIGN; + VasyHashBitVec = TransInfo->HASH_BITVEC; + VasyHash2Support = TransInfo->HASH_SUPPORT; + VasyHash2Literal = TransInfo->HASH_LITERAL; + VasyHash2Event = TransInfo->HASH_EVENT; + + if ( VasyHashReadError == (authtable *)0 ) + { + VasyHashReadError = createauthtable( 100 ); + } +/* +** For all assignment compute support +*/ + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + VasySupportVpnAct( VpnFigure, VpnProc, VpnAction ); + + if ( ( CheckVar ) && + ( VpnAction->TYPE == VPN_ACT_ASG_VARIABLE ) ) + { +/* +** Check if a variable depends on itself +*/ + Support = GetVasyVpnActInfoSupport( VpnAction ); + AsgAtom = VpnAction->VEX_ATOM; + DefAtom = VpnAction->VEX_EXPR; + + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AtomName = GetVexAtomValue( DefAtom ); + DefDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + Element2 = searchauth2elem( VasyHash2Support, + (char*)&Support[ AsgPos ], (char*)AsgSymbol ); + + if ( Element2 != (auth2elem *)0 ) + { +/* +** The variable depends on itself, hash all define of its support (unreadable) +*/ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "!!! variable %s %d depends on itself !\n", + AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + DefIndex = getvexvectorindex( DefAtom, AsgPos ); + DefSymbol = getvpnsymdecl( DefDeclar, DefIndex ); + DefPos = getvexvectorpos( DefAtom, DefIndex ); + + if ( isvextypedivisible( DefDeclar->BASE ) ) + { + Element = searchauthelem( VasyHashBitVec, (char*)DefSymbol ); + } + else + { + Element = searchauthelem( VasyHashAssign, DefSymbol->NAME ); + } + + DefAction = (vpnact_list *)Element->VALUE; + DefSupport = GetVasyVpnActInfoSupport( DefAction ); + DefLiteral = GetVasyVpnActInfoLiteral( DefAction ); + + for ( ScanChain = DefSupport[ DefPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + delauth2elem( VasyHash2Support, + (char*)&DefSupport[ DefPos ], (char*)ScanChain->DATA ); + } + + for ( ScanChain = DefLiteral[ DefPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + delauth2elem( VasyHash2Literal, + (char*)&DefLiteral[ DefPos ], (char*)ScanChain->DATA ); + } + + freechain( DefSupport[ DefPos ] ); + DefSupport[ DefPos ] = (chain_list *)0; + + freechain( DefLiteral[ DefPos ] ); + DefLiteral[ DefPos ] = (chain_list *)0; + + addauth2elem( VasyHash2Support, (char*)&DefSupport[ DefPos ], (char*)AsgSymbol, 0 ); + DefSupport[ DefPos ] = addchain( DefSupport[ DefPos ], AsgSymbol ); + + for ( ScanChain = Support[ AsgPos ]; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + AsgSymbol2 = (vpnsym *)ScanChain->DATA; + + if ( AsgSymbol2 == DefSymbol ) continue; + + AsgDeclar2 = AsgSymbol2->DECL; + + if ( AsgDeclar2->TYPE == VPN_DECLAR_DEFINE ) + { + if ( isvextypedivisible( AsgDeclar2->BASE ) ) + { + Element = searchauthelem( VasyHashBitVec, (char*)AsgSymbol2 ); + } + else + { + Element = searchauthelem( VasyHashAssign, AsgSymbol2->NAME ); + } + + VpnAction2 = (vpnact_list *)Element->VALUE; + Support2 = GetVasyVpnActInfoSupport( VpnAction2 ); + AsgAtom2 = VpnAction2->VEX_ATOM; + + if ( AsgSymbol2->INDEX == -1 ) AsgIndex2 = 0; + else AsgIndex2 = AsgSymbol2->INDEX; + + AsgPos2 = getvexvectorpos( AsgAtom2, AsgIndex2 ); + Element2 = searchauth2elem( VasyHash2Support, + (char*)&Support2[ AsgPos2 ], (char*)AsgSymbol ); + + if ( Element2 != (auth2elem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, ">>> define %s %d depends on %s %d !\n", + AsgSymbol2->NAME, AsgSymbol2->INDEX, AsgSymbol->NAME, AsgSymbol->INDEX ); + } + + addauthelem( VasyHashReadError, (char*)AsgSymbol2, (long)AsgSymbol ); + } + } + } +/* +** Verify that no previous signal or variable assigment use this variable ! +*/ + for ( VpnAction2 = VpnTrans->ACT; + VpnAction2 != (vpnact_list *)0; + VpnAction2 = VpnAction2->NEXT ) + { + if ( VpnAction2 == VpnAction ) break; + + if ( VpnAction2->TYPE == VPN_ACT_ASG_DEFINE ) continue; + + Support2 = GetVasyVpnActInfoSupport( VpnAction2 ); + AsgAtom2 = VpnAction2->VEX_ATOM; + AtomName2 = GetVexAtomValue( AsgAtom2 ); + AsgDeclar2 = searchvpndeclall( VpnFigure, AtomName2 ); + + AsgMin2 = getvexvectormin( AsgAtom2 ); + AsgMax2 = getvexvectormax( AsgAtom2 ); + + for ( AsgIndex2 = AsgMin2; AsgIndex2 <= AsgMax2; AsgIndex2++ ) + { + AsgSymbol2 = getvpnsymdecl( AsgDeclar2, AsgIndex2 ); + AsgPos2 = getvexvectorpos( AsgAtom2, AsgIndex2 ); + Element2 = searchauth2elem( VasyHash2Support, + (char*)&Support2[ AsgPos2 ], (char*)AsgSymbol ); + + if ( Element2 != (auth2elem *)0 ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "### Error symbol %s %d !!!\n", + AsgSymbol2->NAME, AsgSymbol2->INDEX ); + } + } + } + } + } + } + } + } + + resetauthtable( VasyHashReadError ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " <-- VasySupportVpnTrans %s\n", VpnTrans->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_support.h b/alliance/src/vasy/src/vasy_support.h new file mode 100644 index 00000000..575acf22 --- /dev/null +++ b/alliance/src/vasy/src/vasy_support.h @@ -0,0 +1,86 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_support.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_SUPPORT_H +# define VASY_SUPPORT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Support | +| | +\------------------------------------------------------------*/ + +# define VASY_SUPPORT_ERROR 0 +# define VASY_SUPPORT_LOGIC 1 +# define VASY_SUPPORT_BOOLEAN 2 +# define VASY_SUPPORT_ARITH 3 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasySupportCreateVpnTrans(); + extern void VasySupportMergeVpnTrans(); + extern void VasySupportResetVpnTrans(); + extern void VasySupportDestroyVpnTrans(); + + extern void VasySupportVpnTrans(); + extern void VasySupportUsedVpnTrans(); + + extern chain_list *VasySupportVpnTransBitVex(); + extern chain_list *VasySupportVpnTransEventBitVex(); + +# endif diff --git a/alliance/src/vasy/src/vasy_synth.c b/alliance/src/vasy/src/vasy_synth.c new file mode 100644 index 00000000..e5b161db --- /dev/null +++ b/alliance/src/vasy/src/vasy_synth.c @@ -0,0 +1,1247 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_synth.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vpn.h" +# include "vtl.h" +# include "rtn.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_support.h" +# include "vasy_shared.h" +# include "vasy_synth.h" +# include "vasy_simprtl.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashWait = (authtable *)0; + static rtlfig_list *VasyFigure = (rtlfig_list *)0; + static rtlasg_list *VasyAssign = (rtlasg_list *)0; + static long VasyNumberCond = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyGetFsmStateName | +| | +\------------------------------------------------------------*/ + +static char *VasyGetFsmStateName( VpnProc, WaitTrans ) + + vpnproc_list *VpnProc; + vpntrans_list *WaitTrans; +{ + authelem *Element; + char Buffer[ 128 ]; + int Index; + + Element = searchauthelem( VasyHashWait, (char *)WaitTrans ); + + if ( Element == (authelem *)0 ) + { + strcpy( Buffer, WaitTrans->NAME ); + + for ( Index = 0; Buffer[ Index ] != '\0'; Index++ ) + { + if ( Buffer[ Index ] == '.' ) Buffer[ Index ] = '_'; + } + + Element = addauthelem( VasyHashWait, (char *)WaitTrans, (long)namealloc( Buffer ) ); + } + + return( (char *)Element->VALUE ); +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisVpnDecl | +| | +\------------------------------------------------------------*/ + +void VasySynthesisVpnDecl( VpnFigure, RtlFigure ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; +{ + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + rtldecl_list *RtlDeclar; + rtlsym *RtlSymbol; + vexexpr *VexAtom; + vexexpr *VexInit; + int ScanPos; + int RtlType; + int RtlKind; + int RtlBase; + int RtlDir; + int Type; +/* +** Convert Vpn Declaration to Rtl Declaration +*/ + for ( Type = 0; Type < VPN_MAX_DECLAR_TYPE; Type++ ) + { + for ( VpnDeclar = VpnFigure->DECLAR[ Type ]; + VpnDeclar != (vpndecl_list *)0; + VpnDeclar = VpnDeclar->NEXT ) + { + RtlKind = VpnDeclar->KIND; + RtlBase = VpnDeclar->BASE; + RtlDir = VpnDeclar->DIR; + + VexAtom = dupvexexpr( VpnDeclar->VEX_ATOM ); + + if ( Type != VPN_DECLAR_DEFINE ) VexInit = dupvexexpr( VpnDeclar->VEX_INIT ); + else VexInit = (vexexpr *)0; + + if ( RtlKind == VPN_KIND_BUS ) RtlKind = RTL_KIND_BUS; + else + if ( RtlKind == VPN_KIND_REGISTER ) RtlKind = RTL_KIND_REGISTER; + else RtlKind = RTL_KIND_NONE; + + if ( RtlDir == VPN_DIR_IN ) RtlDir = RTL_DIR_IN; + else + if ( RtlDir == VPN_DIR_OUT ) RtlDir = RTL_DIR_OUT; + else + RtlDir = RTL_DIR_INOUT; + + if ( Type == VPN_DECLAR_PORT ) RtlType = RTL_DECLAR_PORT; + else + if ( Type == VPN_DECLAR_CONSTANT ) RtlType = RTL_DECLAR_CONSTANT; + else + RtlType = RTL_DECLAR_SIGNAL; + + RtlDeclar = addrtldecl( RtlFigure, VexAtom, RtlType ); + + if ( Type == VPN_DECLAR_DEFINE ) + { + SetVasyRtlDeclarDefine( RtlDeclar ); + } + + RtlDeclar->BASE = RtlBase; + RtlDeclar->KIND = RtlKind; + RtlDeclar->DIR = RtlDir; + + RtlDeclar->VEX_INIT = VexInit; + + for ( ScanPos = 0; ScanPos < VexAtom->WIDTH; ScanPos++ ) + { + RtlSymbol = &RtlDeclar->DECL_SYM[ ScanPos ]; + VpnSymbol = &VpnDeclar->DECL_SYM[ ScanPos ]; + + RtlSymbol->INIT = VpnSymbol->INIT; + RtlSymbol->DRIVE = VpnSymbol->DRIVE; + RtlSymbol->EFFEC = VpnSymbol->EFFEC; + RtlSymbol->EVENT = VpnSymbol->EVENT; + } + } + } + + for ( Type = 0; Type < RTL_MAX_DECLAR_TYPE; Type++ ) + { + RtlDeclar = RtlFigure->DECLAR[ Type ]; + + if ( RtlDeclar != (rtldecl_list *)0 ) + { + RtlFigure->DECLAR[ Type ] = (rtldecl_list *)reverse( (chain_list *)RtlDeclar ); + } + } + + VasyNumberCond = 0; +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisVpnModel | +| | +\------------------------------------------------------------*/ + +void VasySynthesisVpnModel( VpnFigure, RtlFigure ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; +{ + vpnmod_list *VpnModel; + rtlmod_list *RtlModel; + vpnport_list *VpnPort; + vpngen_list *VpnGen; + rtlport_list *RtlPort; + rtlgen_list *RtlGen; + vexexpr *Atom; + vexexpr *Expr; + unsigned char Dir; + unsigned char Base; + + for ( VpnModel = VpnFigure->MODEL; + VpnModel != (vpnmod_list *)0; + VpnModel = VpnModel->NEXT ) + { + RtlModel = addrtlmod( RtlFigure, VpnModel->NAME ); + + for ( VpnPort = VpnModel->PORT; + VpnPort != (vpnport_list *)0; + VpnPort = VpnPort->NEXT ) + { + Atom = dupvexexpr( VpnPort->VEX_ATOM ); + Base = VpnPort->BASE; + Dir = VpnPort->DIR; + + if ( Dir == VPN_DIR_IN ) Dir = RTL_DIR_IN; + else + if ( Dir == VPN_DIR_OUT ) Dir = RTL_DIR_OUT; + else + Dir = RTL_DIR_INOUT; + + RtlPort = addrtlmodport( RtlFigure, RtlModel, Atom, Base, Dir ); + } + + for ( VpnGen = VpnModel->GENERIC; + VpnGen != (vpngen_list *)0; + VpnGen = VpnGen->NEXT ) + { + Atom = dupvexexpr( VpnGen->VEX_ATOM ); + Expr = dupvexexpr( VpnGen->VEX_EXPR ); + Base = VpnGen->BASE; + + RtlGen = addrtlmodgen( RtlFigure, RtlModel, Atom, Expr, Base ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisVpnInstance | +| | +\------------------------------------------------------------*/ + +void VasySynthesisVpnInstance( VpnFigure, RtlFigure ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; +{ + vpnins_list *VpnInst; + rtlins_list *RtlInst; + rtlmod_list *RtlModel; + vpnmap_list *VpnMap; + rtlmap_list *RtlMap; + vpngen_list *VpnGen; + rtlgen_list *RtlGen; + vexexpr *Formal; + vexexpr *Actual; + vexexpr *Atom; + vexexpr *Expr; + + for ( VpnInst = VpnFigure->INSTANCE; + VpnInst != (vpnins_list *)0; + VpnInst = VpnInst->NEXT ) + { + RtlModel = searchrtlmod( RtlFigure, VpnInst->MODEL->NAME ); + RtlInst = addrtlins( RtlFigure, VpnInst->NAME, RtlModel ); + + for ( VpnMap = VpnInst->MAP; + VpnMap != (vpnmap_list *)0; + VpnMap = VpnMap->NEXT ) + { + Formal = dupvexexpr( VpnMap->VEX_FORMAL ); + Actual = dupvexexpr( VpnMap->VEX_ACTUAL ); + + RtlMap = addrtlinsmap( RtlFigure, RtlInst, Formal, Actual ); + } + + for ( VpnGen = VpnInst->GENERIC; + VpnGen != (vpngen_list *)0; + VpnGen = VpnGen->NEXT ) + { + Atom = dupvexexpr( VpnGen->VEX_ATOM ); + Expr = dupvexexpr( VpnGen->VEX_EXPR ); + + RtlGen = addrtlinsgen( RtlFigure, RtlInst, Atom, Expr ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisAddRtlDefine | +| | +\------------------------------------------------------------*/ + +vexexpr *VasySynthesisAddRtlDefine( RtlFigure, RtlDeclar, VexCond ) + + rtlfig_list *RtlFigure; + rtldecl_list *RtlDeclar; + vexexpr *VexCond; +{ + rtldecl_list *DefDeclar; + rtlasg_list *DefAssign; + vexexpr *VexAtom; + vexexpr *VexAtomZero; + vexexpr *VexAtomOne; + char Buffer[ 32 ]; + + sprintf( Buffer, "rtldef_%ld", VasyNumberCond++ ); + VexAtom = createvexatombit( Buffer ); + + DefDeclar = addrtldecl( RtlFigure, VexAtom, RTL_DECLAR_SIGNAL ); + + DefDeclar->BASE = getvextypescalar( RtlDeclar->BASE ); + DefDeclar->KIND = RTL_KIND_NONE; + DefDeclar->DIR = RTL_DIR_INOUT; + + VexAtomOne = createvexatomlit( VEX_ATOM_ONE ); + VexAtomZero = createvexatomlit( VEX_ATOM_ZERO ); + + DefAssign = addrtlasg( RtlFigure, dupvexexpr( VexAtom ), RTL_ASG_CONDITIONAL ); + + addrtlasgbivex( RtlFigure, DefAssign, VexCond , VexAtomOne , RTL_BIVEX_CONDITIONAL ); + addrtlasgbivex( RtlFigure, DefAssign, (vexexpr *)0, VexAtomZero, RTL_BIVEX_CONDITIONAL ); + + return( dupvexexpr( VexAtom ) ); +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisSubstIftVexExpr | +| | +\------------------------------------------------------------*/ + +vexexpr *VasySynthesisSubstIftVexExpr( RtlFigure, RtlDeclar, Expr ) + + rtlfig_list *RtlFigure; + rtldecl_list *RtlDeclar; + vexexpr *Expr; +{ + chain_list *ScanOper; + vexexpr *Operand; + vexexpr *VexCond; + vexexpr *VexData; + long Oper; + int ScanPos; + int Width; + + if ( ! IsVexNodeAtom( Expr ) ) + { + for ( ScanOper = Expr->OPERAND; + ScanOper != (chain_list *)0; + ScanOper = ScanOper->NEXT ) + { + Operand = GetVexOperand( ScanOper ); + Operand = VasySynthesisSubstIftVexExpr( RtlFigure, RtlDeclar, Operand ); + SetVexOperand( ScanOper, Operand ); + } + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_IFT ) + { + ScanOper = Expr->OPERAND; + VexCond = GetVexOperand( ScanOper ); + SetVexOperand( ScanOper, (vexexpr *)0 ); + + ScanOper = ScanOper->NEXT; + VexData = GetVexOperand( ScanOper ); + SetVexOperand( ScanOper, (vexexpr *)0 ); + + Width = Expr->WIDTH; + + freevexexpr( Expr ); + + VexCond = VasySynthesisAddRtlDefine( RtlFigure, RtlDeclar, VexCond ); + + if ( Width > 1 ) + { + Expr = createvexoper( VEX_CONCAT, Width ); + + for ( ScanPos = 0; ScanPos < Width; ScanPos++ ) + { + addvexhexpr( Expr, dupvexexpr( VexCond ) ); + } + } + else + { + Expr = dupvexexpr( VexCond ); + } + + Expr = createvexbinexpr( VEX_AND, Expr->WIDTH, Expr, VexData ); + } + + return( Expr ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisDupVexExpr | +| | +\------------------------------------------------------------*/ + +vexexpr *VasySynthesisDupVexExpr( RtlFigure, RtlDeclar, Expr ) + + rtlfig_list *RtlFigure; + rtldecl_list *RtlDeclar; + vexexpr *Expr; +{ + Expr = dupvexexpr( Expr ); + + if ( RtlDeclar != (rtldecl_list *)0 ) + { + Expr = VasySynthesisSubstIftVexExpr( RtlFigure, RtlDeclar, Expr ); + } + + Expr = simpvexexpr( Expr ); + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisOneWaitVpnTrans | +| | +\------------------------------------------------------------*/ + +static void VasySynthesisOneWaitVpnTrans( VpnFigure, RtlFigure, VpnTrans ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpntrans_list *VpnTrans; +{ + vpnact_list *VpnAction; + vasyactinfo *ActInfo; + vasysyminfo *SymInfo; + vasybivex_list *SymBiVex; + rtldecl_list *RtlDeclar; + char *Flags; + vpndecl_list *AsgDeclar; + vpnsym *AsgSymbol; + vexexpr *AsgAtom; + vexexpr *RtlAtom; + vexexpr *AsgExpr; + vexexpr *VexCond; + vexexpr *VexData; + char *AtomName; + int AsgMin; + int AsgMax; + int AsgWidth; + int AsgIndex; + int AsgPos; + rtlasg_list *RtlAssign; + int RtlType; + int Used; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySynthesisOneWaitVpnTrans %s\n", VpnTrans->NAME ); + } + + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + ActInfo = GetVasyVpnActInfo( VpnAction ); + Flags = GetVasyVpnActInfoFlags( VpnAction ); + + AsgAtom = VpnAction->VEX_ATOM; + AsgExpr = VpnAction->VEX_EXPR; + AtomName = GetVexAtomValue( AsgAtom ); + AsgDeclar = searchvpndeclall( VpnFigure, AtomName ); + + AsgMin = getvexvectormin( AsgAtom ); + AsgMax = getvexvectormax( AsgAtom ); + AsgWidth = AsgAtom->WIDTH; + + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + Used = 0; + + if ( ! ActInfo->SPLIT ) + { + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + if ( IsVasyVpnActInfoUsed( Flags[ AsgPos ] ) ) + { + Used = 1; break; + } + } + + if ( ! Used ) continue; + + RtlAtom = dupvexexpr( AsgAtom ); + + RtlAssign = addrtlasg( RtlFigure, RtlAtom, RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VasySynthesisDupVexExpr( RtlFigure, RtlDeclar, AsgExpr ); + + SetVasyRtlDeclType( RtlDeclar, VASY_RTL_DECL_COMBINATORIAL ); + } + else + { + for ( AsgIndex = AsgMin; AsgIndex <= AsgMax; AsgIndex++ ) + { + AsgSymbol = getvpnsymdecl( AsgDeclar, AsgIndex ); + AsgPos = getvexvectorpos( AsgAtom, AsgIndex ); + + SymInfo = &ActInfo->SYM_INFO[ AsgPos ]; + + if ( ! IsVasyVpnActInfoUsed( Flags[ AsgPos ] ) ) continue; + + Used = 1; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "--> Symbol %s %d\n", AsgSymbol->NAME, AsgSymbol->INDEX ); + VasyPrintf( stdout, "+++ Type %s\n", VASY_SYM_TYPE[ SymInfo->TYPE ] ); + VasyPrintf( stdout, "+++ Data " ); + viewvexexprboundln( SymInfo->VEX_DATA ); + + for ( SymBiVex = SymInfo->BIVEX; + SymBiVex != (vasybivex_list *)0; + SymBiVex = SymBiVex->NEXT ) + { + VasyPrintf( stdout, "+++ %s ", VASY_BIVEX_TYPE[ SymBiVex->TYPE ] ); + VasyPrintf( stdout, "+++ Cond " ); + viewvexexprboundln( SymBiVex->VEX_COND ); + VasyPrintf( stdout, "+++ Data " ); + viewvexexprboundln( SymBiVex->VEX_DATA ); + } + } + + if ( AsgSymbol->INDEX == -1 ) + { + RtlAtom = createvexatombit( AsgSymbol->NAME ); + } + else + { + RtlAtom = createvexatomvec( AsgSymbol->NAME, AsgSymbol->INDEX, AsgSymbol->INDEX ); + } + + if ( ( SymInfo->TYPE == VASY_SYM_REGISTER ) || + ( SymInfo->TYPE == VASY_SYM_TRISTATE ) ) + { + RtlType = RTL_ASG_REGISTER; + + if ( SymInfo->TYPE == VASY_SYM_TRISTATE ) + { + if ( SymInfo->TRS_TYPE == VEX_TRISTATE_ID ) + { + RtlType = RTL_ASG_TRISTATE; + SetVasyRtlDeclType( RtlDeclar, VASY_RTL_DECL_TRISTATE ); + } + else + if ( SymInfo->TRS_TYPE == VEX_WEAK_ONE_ID ) + { + RtlType = RTL_ASG_PULL_UP; + SetVasyRtlDeclType( RtlDeclar, VASY_RTL_DECL_PULL_UP ); + } + else + if ( SymInfo->TRS_TYPE == VEX_WEAK_ZERO_ID ) + { + RtlType = RTL_ASG_PULL_DOWN; + SetVasyRtlDeclType( RtlDeclar, VASY_RTL_DECL_PULL_DOWN ); + } + } + else + { + SetVasyRtlDeclType( RtlDeclar, VASY_RTL_DECL_REGISTER ); + } + + RtlAssign = addrtlasg( RtlFigure, RtlAtom, RtlType ); + + RtlType = RTL_ASG_REGISTER_NONE; + + if ( SymInfo->REG_TYPE == VASY_SYM_REGISTER_SYNC ) RtlType = RTL_ASG_REGISTER_SYNC; + else + if ( SymInfo->REG_TYPE == VASY_SYM_REGISTER_ASYNC ) RtlType = RTL_ASG_REGISTER_ASYNC; + else + if ( SymInfo->REG_TYPE == VASY_SYM_REGISTER_MIXED ) RtlType = RTL_ASG_REGISTER_MIXED; + + RtlAssign->REG_TYPE = RtlType; + + for ( SymBiVex = SymInfo->BIVEX; + SymBiVex != (vasybivex_list *)0; + SymBiVex = SymBiVex->NEXT ) + { + VexCond = SymBiVex->VEX_COND; + VexData = SymBiVex->VEX_DATA; + + VexCond = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexCond ); + VexData = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexData ); + + addrtlasgbivex( RtlFigure, RtlAssign, VexCond, VexData, SymBiVex->TYPE ); + } + } + else + if ( SymInfo->TYPE == VASY_SYM_COMBINATORIAL ) + { + VexData = SymInfo->VEX_DATA; + VexData = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexData ); + + RtlAssign = addrtlasg( RtlFigure, RtlAtom, RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VexData; + } + } + } + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySynthesisOneWaitVpnTrans %s\n", VpnTrans->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisOneWaitVpnProc | +| | +\------------------------------------------------------------*/ + +void VasySynthesisOneWaitVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *WaitTrans; + vpntrans_list *VpnTrans; + vpnplace_list *SkipPlace; + vpnarc *VpnArc; + vasyprocinfo *ProcInfo; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySynthesisOneWaitVpnProc %s\n", VpnProc->NAME ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + WaitTrans = VpnProc->ELABO; + + VpnArc = GetVpnArc( WaitTrans->PLACE_OUT ); + SkipPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( SkipPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + VasySynthesisOneWaitVpnTrans( VpnFigure, RtlFigure, VpnTrans ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySynthesisOneWaitVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisMultiWaitVpnProc | +| | +\------------------------------------------------------------*/ + +void VasySynthesisMultiWaitVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *WaitTrans; + vpntrans_list *DefTrans; + vpntrans_list *AsgTrans; + vpntrans_list *EndTrans; + vpnplace_list *WaitPlace; + vpnplace_list *EndPlace; + vpnact_list *VpnAction; + vpnarc *VpnArc; + chain_list *ScanChain; + vasywaitinfo *WaitInfo; + rtlfsm_list *RtlFsm; + rtlfsmstate_list *RtlState; + rtlfsmstate_list *RtlStateFrom; + rtlfsmstate_list *RtlStateTo; + rtlfsmtrans_list *RtlTrans; + vasyprocinfo *ProcInfo; + vasybivex_list *ScanBiVex; + vexexpr *VexCond; + vexexpr *VexData; + vexexpr *AsgAtom; + vexexpr *AsgExpr; + char *StateName; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySynthesisMultiWaitVpnProc %s\n", VpnProc->NAME ); + } + + if ( VasyHashWait == (authtable *)0 ) + { + VasyHashWait = createauthtable( 50 ); + } + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + RtlFsm = addrtlfsm( RtlFigure, VpnProc->NAME ); + + for ( ScanBiVex = ProcInfo->BIVEX; + ScanBiVex != (vasybivex_list *)0; + ScanBiVex = ScanBiVex->NEXT ) + { + VexCond = ScanBiVex->VEX_COND; + VexData = ScanBiVex->VEX_DATA; + + VexCond = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexCond ); + VexData = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexData ); + + addrtlfsmbivex( RtlFigure, RtlFsm, VexCond, VexData, ScanBiVex->TYPE ); + } +/* +** Create a state in the FSM for all wait transitions +*/ + for ( WaitTrans = VpnProc->TRANS; + WaitTrans != (vpntrans_list *)0; + WaitTrans = WaitTrans->NEXT ) + { + if ( WaitTrans->TYPE != VPN_TRANS_INF_WAIT ) continue; + + StateName = VasyGetFsmStateName( VpnProc, WaitTrans ); + RtlState = addrtlfsmstate( RtlFigure, RtlFsm, StateName ); + + WaitInfo = GetVasyVpnWaitInfo( WaitTrans ); + DefTrans = WaitInfo->DEF_TRANS; + + if ( DefTrans != (vpntrans_list *)0 ) + { + VasySynthesisOneWaitVpnTrans( VpnFigure, RtlFigure, DefTrans ); + } + } +/* +** Create all transition for each state of the FSM +*/ + for ( WaitTrans = VpnProc->TRANS; + WaitTrans != (vpntrans_list *)0; + WaitTrans = WaitTrans->NEXT ) + { + if ( WaitTrans->TYPE != VPN_TRANS_INF_WAIT ) continue; + + StateName = VasyGetFsmStateName( VpnProc, WaitTrans ); + RtlStateFrom = searchrtlfsmstate( RtlFigure, RtlFsm, StateName ); + + WaitInfo = GetVasyVpnWaitInfo( WaitTrans ); + WaitPlace = WaitInfo->WAIT_PLACE; + + for ( ScanChain = WaitPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( AsgTrans->PLACE_OUT ); + EndPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( EndPlace->TRANS_OUT ); + EndTrans = GetVpnArcTargetTrans( VpnArc ); + + StateName = VasyGetFsmStateName( VpnProc, EndTrans ); + RtlStateTo = searchrtlfsmstate( RtlFigure, RtlFsm, StateName ); + + VexCond = AsgTrans->VEX_GUARD; + VexCond = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexCond ); + + RtlTrans = addrtlfsmtrans( RtlFigure, RtlFsm, RtlStateFrom, RtlStateTo, VexCond ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, "Arc %s -> %s\nCond ", RtlStateFrom->NAME, RtlStateTo->NAME ); + viewvexexprboundln( VexCond ); + } + + for ( VpnAction = AsgTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + AsgAtom = dupvexexpr( VpnAction->VEX_ATOM ); + + AsgExpr = VpnAction->VEX_EXPR; + AsgExpr = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, AsgExpr ); + + addrtlfsmtransasg( RtlFigure, RtlFsm, RtlTrans, AsgAtom, AsgExpr ); + } + } + } + + resetauthtable( VasyHashWait ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySynthesisMultiWaitVpnProc %s\n", VpnProc->NAME ); + } +} +/*------------------------------------------------------------\ +| | +| VasySynthesisSimpleAssignVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasySynthesisSimpleAssignVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpnact_list *VpnAction; + rtldecl_list *RtlDeclar; + vexexpr *AsgAtom; + vexexpr *RtlAtom; + vexexpr *AsgExpr; + char *AtomName; + rtlasg_list *RtlAssign; + int SimpleAsg; +/* +** Treat all simple assign +*/ + if ( ( ! IsVpnProcWithSelect( VpnProc ) ) && + ( ! IsVpnProcConditionnal( VpnProc ) ) ) + { + SimpleAsg = 1; + } + else + { + SimpleAsg = 0; + } + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( ( VpnTrans->TYPE == VPN_TRANS_SUP_WAIT ) || + ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) ) continue; + + for ( VpnAction = VpnTrans->ACT; + VpnAction != (vpnact_list *)0; + VpnAction = VpnAction->NEXT ) + { + if ( ( SimpleAsg ) || + ( VpnAction->TYPE == VPN_ACT_ASG_DEFINE ) ) + { + SetVasyVpnTransAsgDefine( VpnTrans ); + + AsgAtom = VpnAction->VEX_ATOM; + AsgExpr = VpnAction->VEX_EXPR; + AtomName = GetVexAtomValue( AsgAtom ); + RtlDeclar = searchrtldecl( RtlFigure, AtomName ); + + RtlAtom = dupvexexpr( AsgAtom ); + RtlAssign = addrtlasg( RtlFigure, RtlAtom, RTL_ASG_COMBINATORIAL ); + RtlAssign->VEX_DATA = VasySynthesisDupVexExpr( RtlFigure, RtlDeclar, AsgExpr ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisConditionnalScanPlace | +| | +\------------------------------------------------------------*/ + +static void VasySynthesisConditionnalScanPlace( CondPlace ) + + vpnplace_list *CondPlace; +{ + vpnplace_list *AsgPlace; + vpnplace_list *IfPlace; + vpntrans_list *SwapTrans; + vpntrans_list *AsgTrans; + vpntrans_list *TrueTrans; + vpntrans_list *FalseTrans; + vpnarc *VpnArc; + vexexpr *VexCond; + vexexpr *VexData; + + if ( CondPlace->TYPE == VPN_PLACE_IF ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "CondPlace %s\n", CondPlace->NAME ); + } + + VpnArc = GetVpnArc( CondPlace->TRANS_OUT ); + FalseTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( CondPlace->TRANS_OUT->NEXT ); + TrueTrans = GetVpnArcTargetTrans( VpnArc ); + + VpnArc = GetVpnArc( TrueTrans->PLACE_OUT ); + AsgPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( AsgPlace->TRANS_OUT ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( ( AsgPlace->TYPE != VPN_PLACE_ASSIGN ) || + ( IsVasyVpnTransAsgDefine( AsgTrans ) ) ) + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " +++ Swap True/False\n" ); + } + + SwapTrans = TrueTrans; + TrueTrans = FalseTrans; + FalseTrans = SwapTrans; + + VpnArc = GetVpnArc( TrueTrans->PLACE_OUT ); + AsgPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( AsgPlace->TRANS_OUT ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + } + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "True : %s, False : %s, Asg : %s\n", + TrueTrans->NAME, FalseTrans->NAME, AsgTrans->NAME ); + } + + VexCond = TrueTrans->VEX_GUARD; + VexData = AsgTrans->ACT->VEX_EXPR; + + VexCond = VasySynthesisDupVexExpr( VasyFigure, (rtldecl_list *)0, VexCond ); + VexData = VasySynthesisDupVexExpr( VasyFigure, (rtldecl_list *)0, VexData ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " > Cond : " ); + viewvexexprboundln( VexCond ); + VasyPrintf( stdout, " > Data : " ); + viewvexexprboundln( VexData ); + } + + addrtlasgbivex( VasyFigure, VasyAssign, VexCond, VexData, RTL_BIVEX_CONDITIONAL ); + + VpnArc = GetVpnArc( FalseTrans->PLACE_OUT ); + IfPlace = GetVpnArcTargetPlace( VpnArc ); + + if ( IfPlace->TYPE == VPN_PLACE_ASSIGN ) + { + VpnArc = GetVpnArc( IfPlace->TRANS_OUT ); + AsgTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( IsVasyVpnTransAsgDefine( AsgTrans ) ) + { + VpnArc = GetVpnArc( AsgTrans->PLACE_OUT ); + IfPlace = GetVpnArcTargetPlace( VpnArc ); + } + else + { + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, "Final ELSE %s\n", IfPlace->NAME ); + } + + VexData = AsgTrans->ACT->VEX_EXPR; + VexData = VasySynthesisDupVexExpr( VasyFigure, (rtldecl_list *)0, VexData ); + + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " > Data : " ); + viewvexexprboundln( VexData ); + } + + addrtlasgbivex( VasyFigure, VasyAssign, (vexexpr *)0, VexData, RTL_BIVEX_CONDITIONAL ); + + return; + } + } + + VasySynthesisConditionnalScanPlace( IfPlace ); + } + else + { + VasyPrintf( stdout, "ERROR : Should not happen !!!\n" ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisConditionnalVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasySynthesisConditionnalVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpnplace_list *VpnPlace; + vpntrans_list *VpnTrans; + vpnact_list *VpnAction; + vpnarc *VpnArc; + vexexpr *RtlAtom; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySynthesisConditionnalVpnProc %s\n", VpnProc->NAME ); + } + + VasyFigure = RtlFigure; +/* +** Look for the target assignment +*/ + RtlAtom = (vexexpr *)0; + + for ( VpnTrans = VpnProc->TRANS; + VpnTrans != (vpntrans_list *)0; + VpnTrans = VpnTrans->NEXT ) + { + if ( ( VpnTrans->TYPE == VPN_TRANS_INF_WAIT ) || + ( VpnTrans->TYPE == VPN_TRANS_SUP_WAIT ) ) continue; + + VpnAction = VpnTrans->ACT; + + if ( ( VpnAction != (vpnact_list *)0 ) && + ( ( VpnAction->TYPE == VPN_ACT_ASG_PORT ) || + ( VpnAction->TYPE == VPN_ACT_ASG_SIGNAL ) ) ) + { + RtlAtom = dupvexexpr( VpnAction->VEX_ATOM ); break; + } + } +/* +** Look for the first place IF +*/ + for ( VpnPlace = VpnProc->PLACE; + VpnPlace != (vpnplace_list *)0; + VpnPlace = VpnPlace->NEXT ) + { + if ( VpnPlace->TYPE == VPN_PLACE_PROCESS ) break; + } + + do + { + VpnArc = GetVpnArc( VpnPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + } + while ( VpnPlace->TYPE != VPN_PLACE_IF ); + + VasyAssign = addrtlasg( RtlFigure, RtlAtom, RTL_ASG_CONDITIONAL ); + + VasySynthesisConditionnalScanPlace( VpnPlace ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySynthesisConditionnalVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisWithSelectVpnProc | +| | +\------------------------------------------------------------*/ + +static void VasySynthesisWithSelectVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + vpntrans_list *VpnTrans; + vpntrans_list *ElseTrans; + vpnplace_list *VpnPlace; + vpnplace_list *BeginPlace; + vpnarc *VpnArc; + chain_list *ScanChain; + vpnact_list *VpnAction; + vexexpr *AsgAtom; + vexexpr *RtlAtom; + vexexpr *AsgExpr; + vexexpr *ElseData; + vexexpr *VexData; + vexexpr *VexCond; + char *AtomName; + rtlasg_list *RtlAssign; + long MaxNode; + long NumberNode; + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySynthesisWithSelectVpnProc %s\n", VpnProc->NAME ); + } +/* +** Look for the place BEGIN_CASE +*/ + for ( BeginPlace = VpnProc->PLACE; + BeginPlace != (vpnplace_list *)0; + BeginPlace = BeginPlace->NEXT ) + { + if ( BeginPlace->TYPE == VPN_PLACE_CASE ) break; + } +/* +** Look for the transition OTHERS/ELSE +*/ + MaxNode = 0; + NumberNode = 0; + ElseTrans = (vpntrans_list *)0; + + for ( ScanChain = BeginPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + NumberNode = getvexexprnumnode( VpnTrans->VEX_GUARD ); + + if ( NumberNode > MaxNode ) + { + MaxNode = NumberNode; + ElseTrans = VpnTrans; + } + } +/* +** Create a conditionnal RTL assign +*/ + VpnArc = GetVpnArc( ElseTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( VpnPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + VpnAction = VpnTrans->ACT; + + AsgAtom = VpnAction->VEX_ATOM; + AsgExpr = VpnAction->VEX_EXPR; + ElseData = AsgExpr; + AtomName = GetVexAtomValue( AsgAtom ); + + RtlAtom = dupvexexpr( AsgAtom ); + RtlAssign = addrtlasg( RtlFigure, RtlAtom, RTL_ASG_CONDITIONAL ); + + for ( ScanChain = BeginPlace->TRANS_OUT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + VpnArc = GetVpnArc( ScanChain ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + + if ( VpnTrans == ElseTrans ) continue; + + VexCond = VpnTrans->VEX_GUARD; + VpnArc = GetVpnArc( VpnTrans->PLACE_OUT ); + VpnPlace = GetVpnArcTargetPlace( VpnArc ); + VpnArc = GetVpnArc( VpnPlace->TRANS_OUT ); + VpnTrans = GetVpnArcTargetTrans( VpnArc ); + VexData = VpnTrans->ACT->VEX_EXPR; + + VexCond = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexCond ); + VexData = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, VexData ); + + addrtlasgbivex( RtlFigure, RtlAssign, VexCond, VexData, RTL_BIVEX_CONDITIONAL ); + } + + ElseData = VasySynthesisDupVexExpr( RtlFigure, (rtldecl_list *)0, ElseData ); + addrtlasgbivex( RtlFigure, RtlAssign, (vexexpr *)0, ElseData, RTL_BIVEX_CONDITIONAL ); + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySynthesisWithSelectVpnProc %s\n", VpnProc->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| VasySynthesisCombinatorialVpnProc | +| | +\------------------------------------------------------------*/ + +void VasySynthesisCombinatorialVpnProc( VpnFigure, RtlFigure, VpnProc ) + + vpnfig_list *VpnFigure; + rtlfig_list *RtlFigure; + vpnproc_list *VpnProc; +{ + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " --> VasySynthesisCombinatorialVpnProc %s\n", VpnProc->NAME ); + } + + VasySynthesisSimpleAssignVpnProc( VpnFigure, RtlFigure, VpnProc ); + + if ( IsVpnProcWithSelect( VpnProc ) ) + { + VasySynthesisWithSelectVpnProc( VpnFigure, RtlFigure, VpnProc ); + } + else + if ( IsVpnProcConditionnal( VpnProc ) ) + { + VasySynthesisConditionnalVpnProc( VpnFigure, RtlFigure, VpnProc ); + } + + if ( IsVasyDebugLevel0() ) + { + VasyPrintf( stdout, " <-- VasySynthesisCombinatorialVpnProc %s\n", VpnProc->NAME ); + } +} diff --git a/alliance/src/vasy/src/vasy_synth.h b/alliance/src/vasy/src/vasy_synth.h new file mode 100644 index 00000000..e363ecf1 --- /dev/null +++ b/alliance/src/vasy/src/vasy_synth.h @@ -0,0 +1,84 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_synth.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_SYNTH_H +# define VASY_SYNTH_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define VASY_TRANS_ASG_DEFINE_MASK 0x01 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define SetVasyVpnTransAsgDefine( T ) ((T)->FLAGS |= VASY_TRANS_ASG_DEFINE_MASK) +# define ClearVasyVpnTransAsgDefine( T ) ((T)->FLAGS &= ~VASY_TRANS_ASG_DEFINE_MASK) +# define IsVasyVpnTransAsgDefine( T ) ((T)->FLAGS & VASY_TRANS_ASG_DEFINE_MASK) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void VasySynthesisOneWaitVpnProc(); + extern void VasySynthesisMultiWaitVpnProc(); + extern void VasySynthesisCombinatorialVpnProc(); + extern void VasySynthesisVpnDecl(); + extern void VasySynthesisVpnInstance(); + extern void VasySynthesisVpnModel(); + +# endif diff --git a/alliance/src/vasy/src/vasy_vexbdd.c b/alliance/src/vasy/src/vasy_vexbdd.c new file mode 100644 index 00000000..3741132c --- /dev/null +++ b/alliance/src/vasy/src/vasy_vexbdd.c @@ -0,0 +1,1179 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : VASY | +| | +| File : vasy_vexbdd.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "vex.h" +# include "bdd.h" +# include "vpn.h" +# include "vtl.h" + +# include "vasy_error.h" +# include "vasy_debug.h" +# include "vasy_shared.h" +# include "vasy_vexbdd.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *VasyHashSym2Abl = (authtable *)0; + static authtable *VasyHashAbl2Sym = (authtable *)0; + static authtable *VasyHashAbl2Del = (authtable *)0; + static authtable *VasyHashAssign = (authtable *)0; + static authtable *VasyHashBitVec = (authtable *)0; + static bddsystem *VasyBddSystem = (bddsystem *)0; + static bddcircuit *VasyBddCircuit = (bddcircuit *)0; + static vpnfig_list *VasyFigure = (vpnfig_list *)0; + + static vpnline_list *VasyVpnLine = (vpnline_list *)0; + + static char VasyOperVex2Abl[ VEX_MAX_OPERATOR ] = + { + -1 , /* VEX_CONCAT */ + ABL_NOT , /* VEX_NOT */ + -1 , /* VEX_NEG */ + -1 , /* VEX_EVENT */ + ABL_OR , /* VEX_OR */ + ABL_AND , /* VEX_AND */ + ABL_XOR , /* VEX_XOR */ + ABL_NOR , /* VEX_NOR */ + ABL_NAND, /* VEX_NAND */ + ABL_NXOR, /* VEX_NXOR */ + ABL_NXOR, /* VEX_EQ */ + ABL_XOR , /* 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 */ + -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 */ + ABL_AND , /* VEX_IFT */ + -1 , /* VEX_ARRAY */ + -1 , /* VEX_INDEX_N */ + -1 , /* VEX_OTHERS */ + -1 , /* VEX_NUM_BIT */ + -1 /* VEX_ABS */ + }; + + static char VasyOperAbl2Vex[ ABL_MAX_OPERATOR ] = + { + VEX_OR , /* ABL_OR */ + VEX_AND , /* ABL_AND */ + VEX_XOR , /* ABL_XOR */ + VEX_NOT , /* ABL_NOT */ + VEX_NOR , /* ABL_NOR */ + VEX_NAND, /* ABL_NAND */ + VEX_NXOR, /* ABL_NXOR */ + -1 , /* ABL_STABLE */ + -1 , /* ABL_AF */ + -1 , /* ABL_AG */ + -1 , /* ABL_AX */ + -1 , /* ABL_AU */ + -1 , /* ABL_EF */ + -1 , /* ABL_EG */ + -1 , /* ABL_EX */ + -1 /* ABL_EU */ + }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VasyVexBddGetAblName | +| | +\------------------------------------------------------------*/ + +static char *VasyVexBddGetAblName( AsgSymbol ) + + vpnsym *AsgSymbol; +{ + authelem *Element; + char *AblName; + char Buffer[ 128 ]; + + Element = searchauthelem( VasyHashSym2Abl, (char*)AsgSymbol ); + + if ( Element == (authelem *)0 ) + { + if ( AsgSymbol->INDEX == -1 ) + { + AblName = AsgSymbol->NAME; + } + else + { + sprintf( Buffer, "%s %d", AsgSymbol->NAME, AsgSymbol->INDEX ); + AblName = namealloc( Buffer ); + } + + addauthelem( VasyHashSym2Abl, (char*)AsgSymbol, (long)AblName ); + addauthelem( VasyHashAbl2Sym, (char*)AblName , (long)AsgSymbol ); + } + else + { + AblName = (char *)Element->VALUE; + } + + return( AblName ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddGetAblDelName | +| | +\------------------------------------------------------------*/ + +static char *VasyVexBddGetAblDelName( AblName ) + + char *AblName; +{ + authelem *Element; + char *DelName; + char Buffer[ 128 ]; + + if ( VasyHashAbl2Del == (authtable *)0 ) + { + VasyHashAbl2Del = createauthtable( 100 ); + } + + Element = searchauthelem( VasyHashAbl2Del, AblName ); + + if ( Element == (authelem *)0 ) + { + strcpy( Buffer , "del." ); + strcpy( Buffer + 4, AblName ); + + DelName = namealloc( Buffer ); + + addauthelem( VasyHashAbl2Del, AblName, (long)DelName ); + } + else + { + DelName = (char *)Element->VALUE; + } + + return( DelName ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddGetVpnSymbol | +| | +\------------------------------------------------------------*/ + +static vpnsym *VasyVexBddGetVpnSymbol( AblName ) + + char *AblName; +{ + authelem *Element; + + if ( VasyHashAbl2Sym == (authtable *)0 ) + { + return( (vpnsym *)0 ); + } + + Element = searchauthelem( VasyHashAbl2Sym, AblName ); + + if ( Element != (authelem *)0 ) + { + return( (vpnsym *)Element->VALUE ); + } + + return( (vpnsym *)0 ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddVex2BddSize | +| | +\------------------------------------------------------------*/ + +static long VasyVexBddVex2BddSize( Expr, Position ) + + vexexpr *Expr; + short Position; +{ + vpnact_list *VpnAction; + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + char *AtomName; + chain_list *ScanChain; + authelem *Element; + vexexpr *VexAtom; + vexexpr *VexExpr; + vexexpr *Operand; + char *NodeName; + bddnode *BddNode; + long Oper; + int ScanPos; + int PosFrom; + int Index; + int PosTo; + long Size; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, "VasyVexBddVex2BddSize %d->\n", Position ); + viewvexexprboundln( Expr ); + } + + Size = 1; + + if ( IsVexNodeAtom( Expr ) ) + { + AtomName = GetVexAtomValue( Expr ); + + if ( Position >= Expr->WIDTH ) ScanPos = Expr->WIDTH - 1; + else ScanPos = Position; + + if ( ! IsVexAtomLiteral( Expr ) ) + { +/* +** Expression is an atom => check if this atom should be substituted ! +*/ + VpnDeclar = searchvpndeclall( VasyFigure, AtomName ); + Index = getvexvectorindex( Expr, ScanPos ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + NodeName = VasyVexBddGetAblName( VpnSymbol ); + BddNode = searchbddcircuitin( VasyBddCircuit, NodeName ); + + if ( BddNode == (bddnode *)0 ) + { +/* +** Should substitute this atom by its bdd node +*/ + VexExpr = (vexexpr *)0; + VexAtom = (vexexpr *)0; + + if ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) + { + if ( ! isvextypedivisible( VpnDeclar->BASE ) ) + { + Element = searchauthelem( VasyHashAssign, AtomName ); + } + else + { + Element = searchauthelem( VasyHashBitVec, (char*)VpnSymbol ); + } + + if ( Element != (authelem *)0 ) + { + VpnAction = (vpnact_list *)Element->VALUE; + + VexAtom = VpnAction->VEX_ATOM; + VexExpr = VpnAction->VEX_EXPR; + } + } + else + if ( VpnDeclar->TYPE == VPN_DECLAR_CONSTANT ) + { + VexAtom = VpnDeclar->VEX_ATOM; + VexExpr = VpnDeclar->VEX_INIT; + } + + if ( VexAtom != (vexexpr *)0 ) + { + ScanPos = getvexvectorpos( VexAtom, Index ); + Size = VasyVexBddVex2BddSize( VexExpr, ScanPos ); + } + } + } + else + { + Size = 0; + } + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_CONCAT ) + { +/* +** Special case for concatenation +*/ + PosFrom = 0; + Operand = (vexexpr *)0; + + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + PosTo = PosFrom + Operand->WIDTH - 1; + + if ( ( Position >= PosFrom ) && + ( Position <= PosTo ) ) break; + + PosFrom = PosTo + 1; + PosTo = PosFrom; + } + + ScanPos = Position - PosFrom; + Size = VasyVexBddVex2BddSize( Operand, ScanPos ); + } + else + if ( Oper != VEX_EVENT ) + { +/* +** Apply VasyVexBddVex2BddSize for all operands +*/ + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + Size += VasyVexBddVex2BddSize( Operand, Position ); + } + } + } + + return( Size ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddVex2Bdd | +| | +\------------------------------------------------------------*/ + +static bddnode *VasyVexBddVex2Bdd( Expr, Position ) + + vexexpr *Expr; + short Position; +{ + vpnact_list *VpnAction; + vpndecl_list *VpnDeclar; + vpnsym *VpnSymbol; + char *AtomName; + chain_list *ScanChain; + authelem *Element; + vexexpr *VexAtom; + vexexpr *VexExpr; + vexexpr *Operand; + char *NodeName; + bddnode *BddNode; + bddnode *BddLast; + long Oper; + long AblOper; + int ScanPos; + int PosFrom; + int Index; + int PosTo; + int Negative; + int FoundEq; + + if ( IsVasyDebugLevel2() ) + { + VasyPrintf( stdout, "VasyVexBddVex2Bdd %d->\n", Position ); + viewvexexprboundln( Expr ); + } + + BddNode = (bddnode *)0; + FoundEq = 0; + + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( ( Oper == VEX_EQ ) || + ( Oper == VEX_NE ) ) + { +/* +** Special case for equal / not equal +*/ + Expr = simpvexexpreq( dupvexexpr( Expr ) ); + Oper = GetVexOperValue( Expr ); + FoundEq = 1; + } + } + + if ( IsVexNodeAtom( Expr ) ) + { + AtomName = GetVexAtomValue( Expr ); + + if ( Position >= Expr->WIDTH ) ScanPos = Expr->WIDTH - 1; + else ScanPos = Position; + + if ( IsVexAtomLiteral( Expr ) ) + { +/* +** Expression is a literal => return a terminal bdd node +*/ + Index = getvexliteralid( AtomName[ ScanPos + 1 ] ); + + if ( Index == VEX_ZERO_ID ) BddNode = VasyBddSystem->ZERO; + else + if ( Index == VEX_ONE_ID ) BddNode = VasyBddSystem->ONE; + else + if ( Index == VEX_DC_ID ) BddNode = VasyBddSystem->ZERO; + else + { + NodeName = VEX_ATOM_BY_ID[ Index ]; + BddNode = searchbddcircuitin( VasyBddCircuit, NodeName ); + } + } + else + { +/* +** Expression is an atom => check if this atom should be substituted ! +*/ + VpnDeclar = searchvpndeclall( VasyFigure, AtomName ); + Index = getvexvectorindex( Expr, ScanPos ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + + NodeName = VasyVexBddGetAblName( VpnSymbol ); + BddNode = searchbddcircuitin( VasyBddCircuit, NodeName ); + + if ( BddNode == (bddnode *)0 ) + { +/* +** Should substitute this atom by its bdd node +*/ + BddNode = searchbddcircuitout( VasyBddCircuit, NodeName ); + + if ( BddNode == (bddnode *)0 ) + { + VexExpr = (vexexpr *)0; + VexAtom = (vexexpr *)0; + + if ( VpnDeclar->TYPE == VPN_DECLAR_DEFINE ) + { + if ( ! isvextypedivisible( VpnDeclar->BASE ) ) + { + Element = searchauthelem( VasyHashAssign, AtomName ); + } + else + { + Element = searchauthelem( VasyHashBitVec, (char*)VpnSymbol ); + } + + if ( Element != (authelem *)0 ) + { + VpnAction = (vpnact_list *)Element->VALUE; + + VexAtom = VpnAction->VEX_ATOM; + VexExpr = VpnAction->VEX_EXPR; + } + } + else + if ( VpnDeclar->TYPE == VPN_DECLAR_CONSTANT ) + { + VexAtom = VpnDeclar->VEX_ATOM; + VexExpr = VpnDeclar->VEX_INIT; + } + + if ( ( VexAtom != (vexexpr *)0 ) && + ( ! isvexarithoperinexpr( VexExpr ) ) ) + { + ScanPos = getvexvectorpos( VexAtom, Index ); + BddNode = VasyVexBddVex2Bdd( VexExpr, ScanPos ); + + addbddcircuitout( VasyBddCircuit, NodeName, BddNode ); + } + else + { + BddNode = addbddcircuitin( VasyBddCircuit, NodeName, 0, BDD_IN_MODE_LAST ); + } + } + else + { + incbddrefext( BddNode ); + } + } + } + } + else + if ( IsVexNodeOper( Expr ) ) + { + Oper = GetVexOperValue( Expr ); + + if ( Oper == VEX_CONCAT ) + { +/* +** Special case for concatenation +*/ + PosFrom = 0; + Operand = (vexexpr *)0; + + for ( ScanChain = Expr->OPERAND; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + PosTo = PosFrom + Operand->WIDTH - 1; + + if ( ( Position >= PosFrom ) && + ( Position <= PosTo ) ) break; + + PosFrom = PosTo + 1; + PosTo = PosFrom; + } + + ScanPos = Position - PosFrom; + BddNode = VasyVexBddVex2Bdd( Operand, ScanPos ); + } + else + if ( Oper == VEX_EVENT ) + { +/* +** Special case for event attribute => Add an input S'stable +*/ + Operand = GetVexOperand( Expr->OPERAND ); + + if ( ! IsVexNodeAtom( Operand ) ) + { + VasyErrorLine( VASY_ERROR_IN_VEX2BDD, VasyVpnLine, VEX_OPER_NAME[ Oper ] ); + } + + AtomName = GetVexAtomValue( Operand ); + VpnDeclar = searchvpndeclall( VasyFigure, AtomName ); + Index = getvexvectorindex( Expr, Position ); + VpnSymbol = getvpnsymdecl( VpnDeclar, Index ); + NodeName = VasyVexBddGetAblName( VpnSymbol ); + + NodeName = getbddstablename( NodeName ); + BddNode = addbddcircuitin( VasyBddCircuit, NodeName, 0, BDD_IN_MODE_LAST ); + BddNode = applybddnodenot( VasyBddSystem, BddNode ); + } + else + { +/* +** Apply VasyVexBddVex2Bdd for all operands +*/ + if ( isvexnegativeoper( Oper ) ) + { + Negative = 1; + Oper = getvexnotoper( Oper ); + } + else + { + Negative = 0; + } + + AblOper = VasyOperVex2Abl[ Oper ]; + + if ( AblOper == -1 ) + { + VasyErrorLine( VASY_ERROR_IN_VEX2BDD, VasyVpnLine, VEX_OPER_NAME[ Oper ] ); + } + + Operand = GetVexOperand( Expr->OPERAND ); + BddNode = VasyVexBddVex2Bdd( Operand, Position ); + + for ( ScanChain = Expr->OPERAND->NEXT; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + Operand = GetVexOperand( ScanChain ); + BddLast = VasyVexBddVex2Bdd( Operand, Position ); + + BddNode = applybddnode( VasyBddSystem, AblOper, + decbddrefext( BddLast ), + decbddrefext( BddNode ) ); + } + + if ( Negative ) + { + BddNode = applybddnodenot( VasyBddSystem, + decbddrefext( BddNode ) ); + } + } + } + + if ( FoundEq ) freevexexpr( Expr ); + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddSupportVpnSymbol | +| | +\------------------------------------------------------------*/ + +chain_list *VasyVexBddSupportVpnSymbol( VpnFigure, VpnProc, BddNode ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + bddnode *BddNode; +{ + vasyprocinfo *ProcInfo; + chain_list *Support; + chain_list **PrevChain; + chain_list *ScanChain; + chain_list *DelChain; + char **NameIn; + bddindex *IndexIn; + char *AblName; + char *Name; + vpnsym *VpnSymbol; + bddindex Index; + + VasyFigure = VpnFigure; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + VasyBddCircuit = ProcInfo->BDD_CIRCUIT; + VasyBddSystem = ProcInfo->BDD_SYSTEM; + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + Support = getbddnodesupportchain( VasyBddSystem, BddNode ); + IndexIn = VasyBddCircuit->INDEX_IN; + NameIn = VasyBddCircuit->NAME_IN; + + ScanChain = Support; + PrevChain = &Support; + + while ( ScanChain != (chain_list *)0 ) + { + BddNode = (bddnode *)ScanChain->DATA; + + Index = BddNode->INDEX - BDD_INDEX_MIN; + Index = IndexIn[ Index ]; + AblName = NameIn[ Index ]; + + Name = isbddstablename( AblName ); + if ( Name != (char *)0 ) AblName = Name; + + VpnSymbol = VasyVexBddGetVpnSymbol( AblName ); + + if ( VpnSymbol != (vpnsym *)0 ) + { + ScanChain->DATA = (void *)VpnSymbol; + + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + } + else + { + *PrevChain = ScanChain->NEXT; + DelChain = ScanChain; + ScanChain = ScanChain->NEXT; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + } + + return( Support ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddConvertVex2BddSize | +| | +\------------------------------------------------------------*/ + +long VasyVexBddConvertVex2BddSize( VpnFigure, VpnProc, VpnTrans, Expr, Position ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vexexpr *Expr; + short Position; +{ + vasyprocinfo *ProcInfo; + vasytransinfo *TransInfo; + long Size; + + VasyFigure = VpnFigure; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + VasyBddCircuit = ProcInfo->BDD_CIRCUIT; + VasyBddSystem = ProcInfo->BDD_SYSTEM; + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + VasyHashAssign = TransInfo->HASH_ASSIGN; + VasyHashBitVec = TransInfo->HASH_BITVEC; + + Size = VasyVexBddVex2BddSize( Expr, Position ); + + return( Size ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddConvertVex2Bdd | +| | +\------------------------------------------------------------*/ + +bddnode *VasyVexBddConvertVex2Bdd( VpnFigure, VpnProc, VpnTrans, Expr, Position ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpntrans_list *VpnTrans; + vexexpr *Expr; + short Position; +{ + vasyprocinfo *ProcInfo; + vasytransinfo *TransInfo; + bddnode *BddNode; + + VasyFigure = VpnFigure; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + VasyBddCircuit = ProcInfo->BDD_CIRCUIT; + VasyBddSystem = ProcInfo->BDD_SYSTEM; + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + TransInfo = GetVasyVpnTransInfo( VpnTrans ); + VasyHashAssign = TransInfo->HASH_ASSIGN; + VasyHashBitVec = TransInfo->HASH_BITVEC; + + VasyVpnLine = VpnProc->LINE; + BddNode = VasyVexBddVex2Bdd( Expr, Position ); + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddAbl2Vex | +| | +\------------------------------------------------------------*/ + +static vexexpr *VasyVexBddAbl2Vex( AblExpr ) + + ablexpr *AblExpr; +{ + vexexpr *VexExpr; + vexexpr *VexOperand; + vpnsym *VpnSymbol; + char *AtomValue; + long AblOper; + long VexOper; + int Index; + + if ( ABL_ATOM( AblExpr ) ) + { + AtomValue = ABL_ATOM_VALUE( AblExpr ); + + if ( AtomValue[ 0 ] == '\'' ) + { + Index = getvexliteralid( AtomValue[ 1 ] ); + VexExpr = createvexatombit( VEX_ATOM_BY_ID[ Index ] ); + } + else + { + VpnSymbol = VasyVexBddGetVpnSymbol( AtomValue ); + + if ( VpnSymbol->INDEX == -1 ) + { + VexExpr = createvexatombit( VpnSymbol->NAME ); + } + else + { + VexExpr = createvexatomvec( VpnSymbol->NAME, VpnSymbol->INDEX, VpnSymbol->INDEX ); + } + } + } + else + { + AblOper = ABL_OPER( AblExpr ); + + if ( AblOper == ABL_STABLE ) + { + VexOperand = VasyVexBddAbl2Vex( ABL_CADR( AblExpr ) ); + VexExpr = createvexunaryexpr( VEX_EVENT, 1, VexOperand ); + VexExpr = createvexunaryexpr( VEX_NOT , 1, VexExpr ); + } + else + if ( AblOper == ABL_NOT ) + { + VexOperand = VasyVexBddAbl2Vex( ABL_CADR( AblExpr ) ); + VexExpr = optimvexnotexpr( VexOperand ); + } + else + { + VexOper = VasyOperAbl2Vex[ AblOper ]; + + if ( VexOper == -1 ) + { + VasyError( VASY_ERROR_IN_ABL2VEX, ABL_OPERATOR_NAME[ AblOper ] ); + } + + VexExpr = createvexoper( VexOper, 1 ); + + while ( ( AblExpr = ABL_CDR( AblExpr ) ) != (ablexpr *)0 ) + { + VexOperand = VasyVexBddAbl2Vex( ABL_CAR( AblExpr ) ); + addvexhexpr( VexExpr, VexOperand ); + } + } + } + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddConvertBdd2Vex | +| | +\------------------------------------------------------------*/ + +vexexpr *VasyVexBddConvertBdd2Vex( VpnFigure, VpnProc, BddNode ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + bddnode *BddNode; +{ + vasyprocinfo *ProcInfo; + bddcircuit *BddCircuit; + ablexpr *AblExpr; + vexexpr *VexExpr; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + BddCircuit = ProcInfo->BDD_CIRCUIT; + AblExpr = convertbddcircuitabl( BddCircuit, BddNode ); + + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + VexExpr = VasyVexBddAbl2Vex( AblExpr ); + freeablexpr( AblExpr ); + + return( VexExpr ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddSearchBddCircuitInput | +| | +\------------------------------------------------------------*/ + +bddnode *VasyVexBddSearchBddCircuitInput( VpnFigure, VpnProc, VpnSymbol ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnsym *VpnSymbol; +{ + vasyprocinfo *ProcInfo; + bddcircuit *BddCircuit; + bddnode *BddNode; + char *AblName; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + AblName = VasyVexBddGetAblName( VpnSymbol ); + BddNode = searchbddcircuitin( BddCircuit, AblName ); + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddSearchBddCircuitStable | +| | +\------------------------------------------------------------*/ + +bddnode *VasyVexBddSearchBddCircuitStable( VpnFigure, VpnProc, VpnSymbol ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnsym *VpnSymbol; +{ + vasyprocinfo *ProcInfo; + bddcircuit *BddCircuit; + bddnode *BddNode; + char *AblName; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + AblName = VasyVexBddGetAblName( VpnSymbol ); + AblName = getbddstablename( AblName ); + + BddNode = searchbddcircuitin( BddCircuit, AblName ); + + if ( BddNode == (bddnode *)0 ) + { + BddNode = addbddcircuitin( BddCircuit, AblName, 0, BDD_IN_MODE_LAST ); + } + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddAddBddCircuitInput | +| | +\------------------------------------------------------------*/ + +bddnode *VasyVexBddAddBddCircuitInput( VpnFigure, VpnProc, VpnSymbol ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnsym *VpnSymbol; +{ + vasyprocinfo *ProcInfo; + bddcircuit *BddCircuit; + bddnode *BddNode; + char *AblName; + char *DelName; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + AblName = VasyVexBddGetAblName( VpnSymbol ); + DelName = VasyVexBddGetAblDelName( AblName ); + + BddNode = searchbddcircuitin( BddCircuit, DelName ); + + if ( BddNode == (bddnode *)0 ) + { + BddNode = addbddcircuitin( BddCircuit, AblName, 0, BDD_IN_MODE_LAST ); + } + else + { + BddNode = renamebddcircuitin( BddCircuit, DelName, AblName ); + } + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddDelBddCircuitInput | +| | +\------------------------------------------------------------*/ + +bddnode *VasyVexBddDelBddCircuitInput( VpnFigure, VpnProc, VpnSymbol ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnsym *VpnSymbol; +{ + vasyprocinfo *ProcInfo; + bddcircuit *BddCircuit; + bddnode *BddNode; + char *AblName; + char *DelName; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + AblName = VasyVexBddGetAblName( VpnSymbol ); + DelName = VasyVexBddGetAblDelName( AblName ); + + BddNode = renamebddcircuitin( BddCircuit, AblName, DelName ); + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddDelBddCircuitOutput | +| | +\------------------------------------------------------------*/ + +int VasyVexBddDelBddCircuitOutput( VpnFigure, VpnProc, VpnSymbol ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; + vpnsym *VpnSymbol; +{ + vasyprocinfo *ProcInfo; + bddcircuit *BddCircuit; + char *AblName; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + BddCircuit = ProcInfo->BDD_CIRCUIT; + + VasyHashSym2Abl = ProcInfo->HASH_SYM2ABL; + VasyHashAbl2Sym = ProcInfo->HASH_ABL2SYM; + + AblName = VasyVexBddGetAblName( VpnSymbol ); + return( delbddcircuitout( BddCircuit, AblName ) ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddCreateBddCircuit | +| | +\------------------------------------------------------------*/ + +bddcircuit *VasyVexBddCreateBddCircuit( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vasyprocinfo *ProcInfo; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + bddnode **BddLiteral; + bddnode *BddNode; + char *Name; + int Literal; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + + BddSystem = createbddsystem( 100, 1000, 100, 500000 ); + BddCircuit = createbddcircuit( VpnProc->NAME, 100, 100, BddSystem ); + BddLiteral = (bddnode **)autallocblock( sizeof( bddnode *) * VEX_MAX_ID ); + + reorderbddsystemdynamic( BddSystem, reorderbddsystemsimple, 100000, 100 ); + + for ( Literal = 0; Literal < VEX_MAX_ID; Literal++ ) + { + if ( Literal == VEX_ONE_ID ) + { + BddNode = BddSystem->ONE; + } + else + if ( Literal == VEX_ZERO_ID ) + { + BddNode = BddSystem->ZERO; + } + if ( Literal == VEX_DC_ID ) + { + BddNode = BddSystem->ZERO; + } + else + { + Name = VEX_ATOM_BY_ID[ Literal ]; + BddNode = addbddcircuitin( BddCircuit, Name, 0, BDD_IN_MODE_LAST ); + } + + BddLiteral[ Literal ] = BddNode; + } + + ProcInfo->BDD_SYSTEM = BddSystem; + ProcInfo->BDD_CIRCUIT = BddCircuit; + ProcInfo->BDD_LITERAL = BddLiteral; + ProcInfo->HASH_ABL2SYM = createauthtable( 100 ); + ProcInfo->HASH_SYM2ABL = createauthtable( 100 ); + + return( BddCircuit ); +} + +/*------------------------------------------------------------\ +| | +| VasyVexBddDestroyBddCircuit | +| | +\------------------------------------------------------------*/ + +void VasyVexBddDestroyBddCircuit( VpnFigure, VpnProc ) + + vpnfig_list *VpnFigure; + vpnproc_list *VpnProc; +{ + vasyprocinfo *ProcInfo; + + ProcInfo = GetVasyVpnProcInfo( VpnProc ); + +# if 0 + if ( IsVasyDebugLevel1() ) + { + VasyPrintf( stdout, " --> VasyVexBddDestroyBddCircuit\n" ); + testbddcircuit( ProcInfo->BDD_CIRCUIT ); + } +# endif + + destroybddsystem( ProcInfo->BDD_SYSTEM ); + destroybddcircuit( ProcInfo->BDD_CIRCUIT ); + + destroyauthtable( ProcInfo->HASH_ABL2SYM ); + destroyauthtable( ProcInfo->HASH_SYM2ABL ); + + ProcInfo->BDD_SYSTEM = (bddsystem *)0; + ProcInfo->BDD_CIRCUIT = (bddcircuit *)0; + ProcInfo->HASH_ABL2SYM = (authtable *)0; + ProcInfo->HASH_SYM2ABL = (authtable *)0; +} diff --git a/alliance/src/vasy/src/vasy_vexbdd.h b/alliance/src/vasy/src/vasy_vexbdd.h new file mode 100644 index 00000000..22c12fea --- /dev/null +++ b/alliance/src/vasy/src/vasy_vexbdd.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 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 : VASY | +| | +| File : vasy_vexbdd.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 25.08.97 | +| | +\------------------------------------------------------------*/ + +# ifndef VASY_VEXBDD_H +# define VASY_VEXBDD_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern bddnode *VasyVexBddAddBddCircuitInput(); + extern bddnode *VasyVexBddDelBddCircuitInput(); + extern int VasyVexBddDelBddCircuitOutput(); + + extern bddnode *VasyVexBddSearchBddCircuitInput(); + extern bddnode *VasyVexBddSearchBddCircuitStable(); + extern bddcircuit *VasyVexBddCreateBddCircuit(); + extern void VasyVexBddDestroyBddCircuit(); + + extern bddnode *VasyVexBddConvertVex2Bdd(); + extern long VasyVexBddConvertVex2BddSize(); + extern vexexpr *VasyVexBddConvertBdd2Vex(); + + extern chain_list *VasyVexBddSupportVpnSymbol(); + + +# endif