From 33e30974b3fa7bfa2f3902c6ff8becbf2c1af72c Mon Sep 17 00:00:00 2001 From: Ludovic Jacomme Date: Tue, 26 Mar 2002 12:41:55 +0000 Subject: [PATCH] Hello --- alliance/src/boom/Makefile.am | 1 + alliance/src/boom/man1/Makefile.am | 2 + alliance/src/boom/man1/boom.1 | 108 ++ alliance/src/boom/src/Makefile.am | 23 + alliance/src/boom/src/boom_abl.c | 1571 +++++++++++++++++++++ alliance/src/boom/src/boom_abl.h | 80 ++ alliance/src/boom/src/boom_anneal.c | 317 +++++ alliance/src/boom/src/boom_anneal.h | 74 + alliance/src/boom/src/boom_aux.c | 682 +++++++++ alliance/src/boom/src/boom_aux.h | 78 ++ alliance/src/boom/src/boom_auxinit.c | 352 +++++ alliance/src/boom/src/boom_auxinit.h | 74 + alliance/src/boom/src/boom_bdd.c | 1841 +++++++++++++++++++++++++ alliance/src/boom/src/boom_bdd.h | 109 ++ alliance/src/boom/src/boom_burgun.c | 442 ++++++ alliance/src/boom/src/boom_burgun.h | 75 + alliance/src/boom/src/boom_check.c | 132 ++ alliance/src/boom/src/boom_check.h | 71 + alliance/src/boom/src/boom_cost.c | 848 ++++++++++++ alliance/src/boom/src/boom_cost.h | 83 ++ alliance/src/boom/src/boom_dc.c | 235 ++++ alliance/src/boom/src/boom_dc.h | 70 + alliance/src/boom/src/boom_debug.c | 396 ++++++ alliance/src/boom/src/boom_debug.h | 167 +++ alliance/src/boom/src/boom_drive.c | 98 ++ alliance/src/boom/src/boom_drive.h | 71 + alliance/src/boom/src/boom_error.c | 164 +++ alliance/src/boom/src/boom_error.h | 99 ++ alliance/src/boom/src/boom_gradient.c | 415 ++++++ alliance/src/boom/src/boom_gradient.h | 74 + alliance/src/boom/src/boom_hash.c | 313 +++++ alliance/src/boom/src/boom_hash.h | 107 ++ alliance/src/boom/src/boom_logic.c | 1070 ++++++++++++++ alliance/src/boom/src/boom_logic.h | 79 ++ alliance/src/boom/src/boom_main.c | 383 +++++ alliance/src/boom/src/boom_main.h | 70 + alliance/src/boom/src/boom_one.c | 113 ++ alliance/src/boom/src/boom_one.h | 70 + alliance/src/boom/src/boom_optim.c | 226 +++ alliance/src/boom/src/boom_optim.h | 79 ++ alliance/src/boom/src/boom_order.c | 155 +++ alliance/src/boom/src/boom_order.h | 71 + alliance/src/boom/src/boom_param.c | 592 ++++++++ alliance/src/boom/src/boom_param.h | 76 + alliance/src/boom/src/boom_parse.c | 150 ++ alliance/src/boom/src/boom_parse.h | 71 + alliance/src/boom/src/boom_post.c | 160 +++ alliance/src/boom/src/boom_post.h | 71 + alliance/src/boom/src/boom_procrast.c | 258 ++++ alliance/src/boom/src/boom_procrast.h | 71 + alliance/src/boom/src/boom_random.c | 249 ++++ alliance/src/boom/src/boom_random.h | 70 + alliance/src/boom/src/boom_shared.c | 509 +++++++ alliance/src/boom/src/boom_shared.h | 293 ++++ alliance/src/boom/src/boom_simple.c | 156 +++ alliance/src/boom/src/boom_simple.h | 70 + alliance/src/boom/src/boom_simul.c | 224 +++ alliance/src/boom/src/boom_simul.h | 74 + alliance/src/boom/src/boom_top.c | 226 +++ alliance/src/boom/src/boom_top.h | 70 + alliance/src/boom/src/boom_window.c | 385 ++++++ alliance/src/boom/src/boom_window.h | 81 ++ alliance/src/fmi/Makefile.am | 1 + alliance/src/fmi/man1/Makefile.am | 2 + alliance/src/fmi/man1/fmi.1 | 49 + alliance/src/fmi/src/Makefile.am | 12 + alliance/src/fmi/src/fmi_bdd.c | 190 +++ alliance/src/fmi/src/fmi_bdd.h | 46 + alliance/src/fmi/src/fmi_main.c | 187 +++ alliance/src/fmi/src/fmi_main.h | 70 + alliance/src/fmi/src/fmi_optim.c | 608 ++++++++ alliance/src/fmi/src/fmi_optim.h | 90 ++ alliance/src/fmi/src/fmi_parse.c | 94 ++ alliance/src/fmi/src/fmi_parse.h | 44 + alliance/src/fmi/src/fsa_bdd.c | 128 ++ 75 files changed, 16865 insertions(+) create mode 100644 alliance/src/boom/Makefile.am create mode 100644 alliance/src/boom/man1/Makefile.am create mode 100644 alliance/src/boom/man1/boom.1 create mode 100644 alliance/src/boom/src/Makefile.am create mode 100644 alliance/src/boom/src/boom_abl.c create mode 100644 alliance/src/boom/src/boom_abl.h create mode 100644 alliance/src/boom/src/boom_anneal.c create mode 100644 alliance/src/boom/src/boom_anneal.h create mode 100644 alliance/src/boom/src/boom_aux.c create mode 100644 alliance/src/boom/src/boom_aux.h create mode 100644 alliance/src/boom/src/boom_auxinit.c create mode 100644 alliance/src/boom/src/boom_auxinit.h create mode 100644 alliance/src/boom/src/boom_bdd.c create mode 100644 alliance/src/boom/src/boom_bdd.h create mode 100644 alliance/src/boom/src/boom_burgun.c create mode 100644 alliance/src/boom/src/boom_burgun.h create mode 100644 alliance/src/boom/src/boom_check.c create mode 100644 alliance/src/boom/src/boom_check.h create mode 100644 alliance/src/boom/src/boom_cost.c create mode 100644 alliance/src/boom/src/boom_cost.h create mode 100644 alliance/src/boom/src/boom_dc.c create mode 100644 alliance/src/boom/src/boom_dc.h create mode 100644 alliance/src/boom/src/boom_debug.c create mode 100644 alliance/src/boom/src/boom_debug.h create mode 100644 alliance/src/boom/src/boom_drive.c create mode 100644 alliance/src/boom/src/boom_drive.h create mode 100644 alliance/src/boom/src/boom_error.c create mode 100644 alliance/src/boom/src/boom_error.h create mode 100644 alliance/src/boom/src/boom_gradient.c create mode 100644 alliance/src/boom/src/boom_gradient.h create mode 100644 alliance/src/boom/src/boom_hash.c create mode 100644 alliance/src/boom/src/boom_hash.h create mode 100644 alliance/src/boom/src/boom_logic.c create mode 100644 alliance/src/boom/src/boom_logic.h create mode 100644 alliance/src/boom/src/boom_main.c create mode 100644 alliance/src/boom/src/boom_main.h create mode 100644 alliance/src/boom/src/boom_one.c create mode 100644 alliance/src/boom/src/boom_one.h create mode 100644 alliance/src/boom/src/boom_optim.c create mode 100644 alliance/src/boom/src/boom_optim.h create mode 100644 alliance/src/boom/src/boom_order.c create mode 100644 alliance/src/boom/src/boom_order.h create mode 100644 alliance/src/boom/src/boom_param.c create mode 100644 alliance/src/boom/src/boom_param.h create mode 100644 alliance/src/boom/src/boom_parse.c create mode 100644 alliance/src/boom/src/boom_parse.h create mode 100644 alliance/src/boom/src/boom_post.c create mode 100644 alliance/src/boom/src/boom_post.h create mode 100644 alliance/src/boom/src/boom_procrast.c create mode 100644 alliance/src/boom/src/boom_procrast.h create mode 100644 alliance/src/boom/src/boom_random.c create mode 100644 alliance/src/boom/src/boom_random.h create mode 100644 alliance/src/boom/src/boom_shared.c create mode 100644 alliance/src/boom/src/boom_shared.h create mode 100644 alliance/src/boom/src/boom_simple.c create mode 100644 alliance/src/boom/src/boom_simple.h create mode 100644 alliance/src/boom/src/boom_simul.c create mode 100644 alliance/src/boom/src/boom_simul.h create mode 100644 alliance/src/boom/src/boom_top.c create mode 100644 alliance/src/boom/src/boom_top.h create mode 100644 alliance/src/boom/src/boom_window.c create mode 100644 alliance/src/boom/src/boom_window.h create mode 100644 alliance/src/fmi/Makefile.am create mode 100644 alliance/src/fmi/man1/Makefile.am create mode 100644 alliance/src/fmi/man1/fmi.1 create mode 100644 alliance/src/fmi/src/Makefile.am create mode 100644 alliance/src/fmi/src/fmi_bdd.c create mode 100644 alliance/src/fmi/src/fmi_bdd.h create mode 100644 alliance/src/fmi/src/fmi_main.c create mode 100644 alliance/src/fmi/src/fmi_main.h create mode 100644 alliance/src/fmi/src/fmi_optim.c create mode 100644 alliance/src/fmi/src/fmi_optim.h create mode 100644 alliance/src/fmi/src/fmi_parse.c create mode 100644 alliance/src/fmi/src/fmi_parse.h create mode 100644 alliance/src/fmi/src/fsa_bdd.c diff --git a/alliance/src/boom/Makefile.am b/alliance/src/boom/Makefile.am new file mode 100644 index 00000000..5fcaa0d3 --- /dev/null +++ b/alliance/src/boom/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src man1 diff --git a/alliance/src/boom/man1/Makefile.am b/alliance/src/boom/man1/Makefile.am new file mode 100644 index 00000000..68de3e75 --- /dev/null +++ b/alliance/src/boom/man1/Makefile.am @@ -0,0 +1,2 @@ +man_MANS = boom.1 +EXTRA_DIST = $(man_MANS) diff --git a/alliance/src/boom/man1/boom.1 b/alliance/src/boom/man1/boom.1 new file mode 100644 index 00000000..87e2963c --- /dev/null +++ b/alliance/src/boom/man1/boom.1 @@ -0,0 +1,108 @@ +.\" $Id: boom.1,v 1.1 2002/03/26 12:37:22 ludo Exp $ +.\" @(#)Labo.l 2.2 95/09/24 UPMC; Author: Jacomme L. +.pl -.4 +.TH BOOM 1 "August 25, 2000" "ASIM/LIP6" "CAO\-VLSI Reference Manual" +.SH NAME +.TP +BOOM \- BOOlean Minimization +.so man1/alc_origin.1 +.SH SYNOPSIS +.TP +\f4boom [\-VTOAP] [\-l num] [\-d num] [\-i num] [\-a num] [\-sjbgpwtmorn] + filename [outname] +.br +.SH DESCRIPTION +.br +\fBBOOM\fP is used for the first step of the synthesis process. +It optimizes a behavioural description using a Reduced Ordered Binary +Decision Diagram representation of logic functions. +The file \fBfilename\fP is the input behavioural description and must +be written in vbe(5) format. +The resulting behavioural optimized description is saved with the name +\fBoutname\fP or \fBinput_name\fP_o in vbe(5) format. + +.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 optimization is displayed on the standard output. +.TP 10 +\f4\-T\fP +Trace mode on. +Some debug informations are displayed on the standard output. +.TP 10 +\f4\-O\fP +Reverses initial Bdd variables order. +.TP 10 +\f4\-A\fP +\fBBOOM\fP performs a local optimization and keeps the architecture of the initial description by saving most of the intermediate signals. +This mode is well-suited for big or regular circuits such as multipliers, adders. +By default \fBBOOM\fP performs a global optimization and removes most of the intermediate +signals so that the outputs are expressed in terms of the inputs or the internal registers. +This mode is well-suited for random circuits such as FSMs. +.TP 10 +\f4\-P\fP +Uses a parameter file \fBinput_name\fP.boom describing +optimization directives and constraints. +(see below for the exact syntax) + +.nf +# Example of .boom file + +# +# The list of auxiliary signals that have to be kept +# during optimization. +# Generally carry signals, ram address signals etc ... +# +BEGIN_KEEP + +carry[3:0] +ram_address[3:0] + +END + +# +# The list of auxiliary signals which assigned +# expression won't be modified. +# Generally it's ram output signals. +# +BEGIN_DONT_TOUCH +ram_out[7:0] +END +.fi + +.TP 10 +\f4\-l num\fP +Specifies the optimization level [0\-3] +(default is 0, low level). +.TP 10 +\f4\-d num\fP +Specifies the delay optimization percent +(default is 0% delay, 100% surface). +.TP 10 +\f4\-i num\fP +Specifies the number of iterations for the choosen optimization algorithm +(for experts only). +.TP 10 +\f4\-a num\fP +Specifies the amplitude during bdd reordering (for experts only). +.TP 10 +\f4\-sjbgpwtmorn\fP +Specifies which algorithm has to be used for the boolean optimization. + +.SH SEE ALSO +.BR boom (5), +.BR vbe (5), +.BR asimut (1), +.BR boog (1), +.BR MBK_WORK_LIB (1). + +.so man1/alc_bug_report.1 + diff --git a/alliance/src/boom/src/Makefile.am b/alliance/src/boom/src/Makefile.am new file mode 100644 index 00000000..c06d89de --- /dev/null +++ b/alliance/src/boom/src/Makefile.am @@ -0,0 +1,23 @@ +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = boom + +boom_LDADD = @LIBS@ \ + -lAbv -lAbe -lAbt -lBdd -lAbl -lAut -lMut + +boom_SOURCES = \ +boom_abl.c boom_cost.h boom_main.c boom_procrast.h \ +boom_abl.h boom_dc.c boom_main.h boom_random.c \ +boom_anneal.c boom_dc.h boom_one.c boom_random.h \ +boom_anneal.h boom_debug.c boom_one.h boom_shared.c \ +boom_aux.c boom_debug.h boom_optim.c boom_shared.h \ +boom_aux.h boom_drive.c boom_optim.h boom_simple.c \ +boom_auxinit.c boom_drive.h boom_order.c boom_simple.h \ +boom_auxinit.h boom_error.c boom_order.h boom_simul.c \ +boom_bdd.c boom_error.h boom_param.c boom_simul.h \ +boom_bdd.h boom_gradient.c boom_param.h boom_top.c \ +boom_burgun.c boom_gradient.h boom_parse.c boom_top.h \ +boom_burgun.h boom_hash.c boom_parse.h boom_window.c \ +boom_check.c boom_hash.h boom_post.c boom_window.h \ +boom_check.h boom_logic.c boom_post.h \ +boom_cost.c boom_logic.h boom_procrast.c diff --git a/alliance/src/boom/src/boom_abl.c b/alliance/src/boom/src/boom_abl.c new file mode 100644 index 00000000..77ed99e4 --- /dev/null +++ b/alliance/src/boom/src/boom_abl.c @@ -0,0 +1,1571 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_abl.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_shared.h" +# include "boom_error.h" +# include "boom_abl.h" +# include "boom_hash.h" +# include "boom_debug.h" +# include "boom_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static boomhabltable *BoomHashAblTable = (boomhabltable *)0; + static char **BoomAblNameArray = (char **)0; + static bddindex *BoomAblIndexArray = (bddindex *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern bddnode *loc_applybdd(); + extern bddnode *loc_simpbdddcon(); + extern bddnode *loc_simpbdddcoff(); + extern bddnode *loc_applybddnot(); + +/*------------------------------------------------------------\ +| | +| BoomGiveBestExpr | +| | +\------------------------------------------------------------*/ + +static chain_list *BoomGiveBestExpr( Expr1, Expr2 ) + + chain_list *Expr1; + chain_list *Expr2; +{ + if ( getablexprnumatom( Expr1 ) > + getablexprnumatom( Expr2 ) ) + { + freeablexpr( Expr1 ); + + return( Expr2 ); + } + + freeablexpr( Expr2 ); + + return( Expr1 ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Index 2 Abl | +| | +\------------------------------------------------------------*/ + +static chain_list *BoomBddIndex2Abl( Index ) + + bddindex Index; +{ + ablexpr *Atom; + char *Name; + + if ( Index < BDD_INDEX_MIN ) + { + if ( Index == BDD_INDEX_ZERO ) + { + return( createablatom( "'0'" ) ); + } + + return( createablatom( "'1'" ) ); + } + + Index = Index - BDD_INDEX_MIN; + + if ( BoomAblIndexArray != (bddindex *)0 ) + { + Index = BoomAblIndexArray[ Index ]; + } + + Name = BoomAblNameArray[ Index ]; + Atom = createablatom( Name ); + + Name = isbddstablename( Name ); + + if ( Name != (char *)0 ) + { + ABL_CAR( Atom ) = addchain( (chain_list *)0, (void *)ABL_STABLE ); + addablhexpr( Atom, createablatom( Name ) ); + } + + return( Atom ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Node 2 Mux | +| | +\------------------------------------------------------------*/ + +static chain_list *BoomBddNode2Mux( Equation, BddHigh, BddLow ) + + chain_list *Equation; + bddnode *BddHigh; + bddnode *BddLow; +{ + bddnode *NodeAnd; + bddnode *NodeAux1; + bddnode *NodeAux2; + chain_list *Equation1; + chain_list *Equation2; + chain_list *Equation3; + short IndexHigh; + short IndexLow; + + IndexHigh = BddHigh->INDEX; + IndexLow = BddLow->INDEX; + +/* +** Terminal multiplexor +*/ + if ( ( IndexLow < BDD_INDEX_MIN ) || + ( IndexHigh < BDD_INDEX_MIN ) ) + { + if ( ( IndexLow < BDD_INDEX_MIN ) && + ( IndexHigh < BDD_INDEX_MIN ) ) + { +/* +** F = a' +*/ + if ( IndexLow == BDD_INDEX_ONE ) + { + Equation = createablnotexpr( Equation ); + } +/* +** F = a +*/ + return( Equation ); + } +/* +** F = a' + H +*/ + if ( IndexLow == BDD_INDEX_ONE ) + { + Equation = createablbinexpr( ABL_OR, + createablnotexpr( Equation ), + BoomBddNode2Abl( BddHigh ) ); + } + else +/* +** F = a.H +*/ + if ( IndexLow == BDD_INDEX_ZERO ) + { + Equation = createablbinexpr( ABL_AND, + Equation, + BoomBddNode2Abl( BddHigh ) ); + } + else +/* +** F = a + L +*/ + if ( IndexHigh == BDD_INDEX_ONE ) + { + Equation = createablbinexpr( ABL_OR, + Equation, + BoomBddNode2Abl( BddLow ) ); + } + else +/* +** F = a'.L +*/ + { + Equation = createablbinexpr( ABL_AND, + createablnotexpr( Equation ), + BoomBddNode2Abl( BddLow ) ); + } + + return( Equation ); + } + + NodeAnd = decbddrefext( loc_applybdd( ABL_AND, BddHigh, BddLow ) ); + + if ( NodeAnd->INDEX == BDD_INDEX_ZERO ) + { + NodeAux1 = decbddrefext( loc_applybdd( ABL_OR, BddHigh, BddLow ) ); +/* +** F = a ^ L +*/ + if ( NodeAux1->INDEX == BDD_INDEX_ONE ) + { + Equation = createablbinexpr( ABL_XOR, + Equation, + BoomBddNode2Abl( BddLow ) ); + return( Equation ); + } + } +/* +** F = H + a'.L(H=*) +*/ + if ( NodeAnd == BddHigh ) + { + NodeAux1 = decbddrefext( loc_simpbdddcon( BddLow, BddHigh ) ); + + Equation1 = BoomBddNode2Abl( BddHigh ); + Equation2 = createablbinexpr( ABL_AND, + createablnotexpr( dupablexpr( Equation ) ), + BoomBddNode2Abl( NodeAux1 ) ); + + Equation3 = createablbinexpr( ABL_OR, Equation1, Equation2 ); + + NodeAux2 = decbddrefext( loc_applybddnot( BddLow ) ); + NodeAux2 = decbddrefext( loc_simpbdddcoff( BddHigh, NodeAux2 ) ); + + Equation1 = BoomBddNode2Abl( BddLow ); + Equation2 = createablbinexpr( ABL_OR, + createablnotexpr( Equation ), + BoomBddNode2Abl( NodeAux2 ) ); + + Equation = createablbinexpr( ABL_AND, Equation1, Equation2 ); + + Equation = BoomGiveBestExpr( Equation, Equation3 ); + + return( Equation ); + } +/* +** F = L + a.H(L=*) +*/ + if ( NodeAnd == BddLow ) + { + NodeAux1 = decbddrefext( loc_simpbdddcon( BddHigh, BddLow ) ); + + Equation1 = BoomBddNode2Abl( BddLow ); + Equation2 = createablbinexpr( ABL_AND, + dupablexpr( Equation ), + BoomBddNode2Abl( NodeAux1 ) ); + + Equation3 = createablbinexpr( ABL_OR, Equation1, Equation2 ); + + NodeAux2 = decbddrefext( loc_applybddnot( BddHigh ) ); + NodeAux2 = decbddrefext( loc_simpbdddcoff( BddLow, NodeAux2 ) ); + + Equation1 = BoomBddNode2Abl( BddHigh ); + Equation2 = createablbinexpr( ABL_OR, + Equation, + BoomBddNode2Abl( NodeAux2 ) ); + + Equation = createablbinexpr( ABL_AND, Equation1, Equation2 ); + + Equation = BoomGiveBestExpr( Equation, Equation3 ); + + return( Equation ); + } +/* +** F = a'.L(H.L=*) + a.H(H.L=*) + H.L(PHL=*), PHL = L(H.L=*).H(H.L=*) +*/ + NodeAux1 = decbddrefext( loc_simpbdddcon( BddLow , NodeAnd ) ); + NodeAux2 = decbddrefext( loc_simpbdddcon( BddHigh, NodeAnd ) ); + + if ( ( NodeAux1 != BddLow ) && + ( NodeAux2 != BddHigh ) ) + { + Equation1 = createablbinexpr( ABL_AND, + createablnotexpr( dupablexpr( Equation ) ), + BoomBddNode2Abl( NodeAux1 ) ); + + Equation2 = createablbinexpr( ABL_AND, + dupablexpr( Equation ), + BoomBddNode2Abl( NodeAux2 ) ); + + NodeAux1 = decbddrefext( loc_applybdd( ABL_AND, NodeAux1, NodeAux2 ) ); + NodeAux1 = decbddrefext( loc_simpbdddcon( NodeAnd, NodeAux1 ) ); + + Equation1 = createablbinexpr( ABL_OR, Equation1, Equation2 ); + + Equation3 = createablbinexpr( ABL_OR, + Equation1, + BoomBddNode2Abl( NodeAux1 ) ); + + Equation1 = createablbinexpr( ABL_AND, + createablnotexpr( dupablexpr( Equation ) ), + BoomBddNode2Abl( BddLow ) ); + + Equation2 = createablbinexpr( ABL_AND, + Equation, + BoomBddNode2Abl( BddHigh ) ); + + Equation = createablbinexpr( ABL_OR, Equation1, Equation2 ); + + Equation = BoomGiveBestExpr( Equation, Equation3 ); + } + else + { + Equation1 = createablbinexpr( ABL_AND, + createablnotexpr( dupablexpr( Equation ) ), + BoomBddNode2Abl( BddLow ) ); + + Equation2 = createablbinexpr( ABL_AND, + Equation, + BoomBddNode2Abl( BddHigh ) ); + + Equation = createablbinexpr( ABL_OR, Equation1, Equation2 ); + } + + return( Equation ); +} + +/*------------------------------------------------------------\ +| | +| BoomBddNode2Abl | +| | +\------------------------------------------------------------*/ + +chain_list *BoomBddNode2Abl( BddNode ) + + bddnode *BddNode; +{ + boomhabl *HashAbl; + chain_list *Equation; + chain_list *Atom; + chain_list *Cumul; + bddnode *ScanNode; + bddnode *BddHigh; + bddnode *BddLow; +/* +** F = '1' +*/ + if ( BddNode->INDEX == BDD_INDEX_ONE ) + { + return( createablatom( "'1'" ) ); + } +/* +** F = '0' +*/ + if ( BddNode->INDEX == BDD_INDEX_ZERO ) + { + return( createablatom( "'0'" ) ); + } + + BddHigh = BddNode->HIGH; + BddLow = BddNode->LOW; + +/* +** Terminal Variable +*/ + if ( ( BddLow->INDEX < BDD_INDEX_MIN ) || + ( BddHigh->INDEX < BDD_INDEX_MIN ) ) + { + Atom = BoomBddIndex2Abl( BddNode->INDEX ); + + if ( ( BddLow->INDEX < BDD_INDEX_MIN ) && + ( BddHigh->INDEX < BDD_INDEX_MIN ) ) + { + if ( BddLow->INDEX == BDD_INDEX_ONE ) + { +/* +** F = a +*/ + Atom = createablnotexpr( Atom ); + } +/* +** F = a' +*/ + return( Atom ); + } +/* +** F = a' + H +*/ + if ( BddLow->INDEX == BDD_INDEX_ONE ) + { + Equation = createablbinexpr( ABL_OR, + createablnotexpr( Atom ), + BoomBddNode2Abl( BddHigh ) ); + } + else +/* +** F = a.H +*/ + if ( BddLow->INDEX == BDD_INDEX_ZERO ) + { + Equation = createablbinexpr( ABL_AND, + Atom, + BoomBddNode2Abl( BddHigh ) ); + } + else +/* +** F = a + L +*/ + if ( BddHigh->INDEX == BDD_INDEX_ONE ) + { + Equation = createablbinexpr( ABL_OR, + Atom, + BoomBddNode2Abl( BddLow ) ); + } +/* +** F = a'.L +*/ + else + { + Equation = createablbinexpr( ABL_AND, + createablnotexpr( Atom ), + BoomBddNode2Abl( BddLow ) ); + } + + BoomAddHashAbl( BoomHashAblTable, BddNode, Equation ); + + return( Equation ); + } + + HashAbl = BoomSearchHashAbl( BoomHashAblTable, BddNode ); + + if ( HashAbl != (boomhabl *)0 ) + { + return( dupablexpr( HashAbl->ABL ) ); + } +/* +** Simplify First Level +*/ + Equation = BoomBddIndex2Abl( BddNode->INDEX ); + ScanNode = (bddnode *)0; + + do + { + Cumul = (chain_list *)0; +/* +** Kernel OR +*/ + if ( ( BddHigh == BddLow->HIGH ) || + ( BddHigh == BddLow->LOW ) ) + { + Cumul = createabloper( ABL_OR ); + addablhexpr( Cumul, Equation ); + + ScanNode = BddLow; + + do + { + Atom = BoomBddIndex2Abl( ScanNode->INDEX ); + + if ( ScanNode->HIGH == BddHigh ) + { + ScanNode = ScanNode->LOW; + } + else + { + ScanNode = ScanNode->HIGH; + Atom = createablnotexpr( Atom ); + } + + addablqexpr( Cumul, Atom ); + } + while ( ( ScanNode->HIGH == BddHigh ) || + ( ScanNode->LOW == BddHigh ) ); + + BddLow = ScanNode; + Equation = Cumul; + } +/* +** Kernel AND +*/ + if ( ( BddLow == BddHigh->HIGH ) || + ( BddLow == BddHigh->LOW ) ) + { + Cumul = createabloper( ABL_AND ); + addablhexpr( Cumul, Equation ); + + ScanNode = BddHigh; + + do + { + Atom = BoomBddIndex2Abl( ScanNode->INDEX ); + + if ( ScanNode->LOW == BddLow ) + { + ScanNode = ScanNode->HIGH; + } + else + { + ScanNode = ScanNode->LOW; + Atom = createablnotexpr( Atom ); + } + + addablqexpr( Cumul, Atom ); + } + while ( ( ScanNode->HIGH == BddLow ) || + ( ScanNode->LOW == BddLow ) ); + + BddHigh = ScanNode; + Equation = Cumul; + } +/* +** Kernel XOR +*/ + if ( ( BddLow->INDEX == BddHigh->INDEX ) && + ( BddHigh->HIGH == BddLow->LOW ) && + ( BddHigh->LOW == BddLow->HIGH ) ) + { + Cumul = createabloper( ABL_XOR ); + addablhexpr( Cumul, Equation ); + + ScanNode = BddLow; + + Atom = BoomBddIndex2Abl( ScanNode->INDEX ); + addablqexpr( Cumul, Atom ); + + BddHigh = BddHigh->LOW; + BddLow = BddLow->LOW; + + Equation = Cumul; + } + + if ( Cumul == (chain_list *)0 ) break; + } + while ( ( BddHigh->INDEX >= BDD_INDEX_MIN ) && + ( BddLow->INDEX >= BDD_INDEX_MIN ) ); + +/* +** Simplify Second Level +*/ + if ( BddHigh->INDEX == BddLow->INDEX ) + { + if ( ( BddHigh->LOW == BddLow->HIGH ) && + ( BddHigh->LOW->INDEX >= BDD_INDEX_MIN ) ) + { +/* +** Carry +*/ + if ( ( BddHigh->HIGH->INDEX == BDD_INDEX_ONE ) && + ( BddLow->LOW->INDEX == BDD_INDEX_ZERO ) ) + { + Atom = BoomBddIndex2Abl( BddHigh->INDEX ); + Cumul = createablbinexpr( ABL_AND, + dupablexpr( Atom ), + dupablexpr( Equation ) ); + + Atom = createablbinexpr( ABL_OR, Atom, Equation ); + + Equation = BoomBddNode2Abl( BddHigh->LOW ); +/* +** ( A.B + HL ).( A + B ) +*/ + if ( ( ! ABL_ATOM( Equation ) ) && + ( ABL_OPER( Equation ) == ABL_OR ) ) + { + Cumul = createablbinexpr( ABL_OR , Cumul, Equation ); + Equation = createablbinexpr( ABL_AND, Cumul, Atom ); + } +/* +** A.B + HL.( A + B ) +*/ + else + { + Atom = createablbinexpr( ABL_AND, Atom , Equation ); + Equation = createablbinexpr( ABL_OR , Cumul, Atom ); + } + + BoomAddHashAbl( BoomHashAblTable, BddNode, Equation ); + + return( Equation ); + } + + if ( ( BddHigh->HIGH->INDEX == BDD_INDEX_ZERO ) && + ( BddLow->LOW->INDEX == BDD_INDEX_ONE ) ) + { + Equation = createablnotexpr( Equation ); + Atom = createablnotexpr( BoomBddIndex2Abl( BddHigh->INDEX ) ); + + Cumul = createablbinexpr( ABL_AND, + dupablexpr( Atom ), + dupablexpr( Equation ) ); + + Atom = createablbinexpr( ABL_OR, Atom, Equation ); + + Equation = BoomBddNode2Abl( BddHigh->LOW ); +/* +** ( A'.B' + HL ).( A' + B' ) +*/ + if ( ( ! ABL_ATOM( Equation ) ) && + ( ABL_OPER( Equation ) == ABL_OR ) ) + { + Cumul = createablbinexpr( ABL_OR , Cumul, Equation ); + Equation = createablbinexpr( ABL_AND, Cumul, Atom ); + } +/* +** A'.B' + HL.( A' + B' ) +*/ + else + { + Atom = createablbinexpr( ABL_AND, Atom , Equation ); + Equation = createablbinexpr( ABL_OR , Cumul, Atom ); + } + + BoomAddHashAbl( BoomHashAblTable, BddNode, Equation ); + + return( Equation ); + } + } + + if ( ( BddHigh->HIGH == BddLow->LOW ) && + ( BddHigh->HIGH->INDEX >= BDD_INDEX_MIN ) ) + { +/* +** Carry +*/ + if ( ( BddHigh->LOW->INDEX == BDD_INDEX_ONE ) && + ( BddLow->HIGH->INDEX == BDD_INDEX_ZERO ) ) + { + Atom = createablnotexpr( BoomBddIndex2Abl( BddHigh->INDEX ) ); + Cumul = createablbinexpr( ABL_AND, + dupablexpr( Atom ), + dupablexpr( Equation ) ); + + Atom = createablbinexpr( ABL_OR, Atom, Equation ); + + Equation = BoomBddNode2Abl( BddHigh->HIGH ); +/* +** ( A.B' + HH ).( A + B' ) +*/ + if ( ( ! ABL_ATOM( Equation ) ) && + ( ABL_OPER( Equation ) == ABL_OR ) ) + { + Cumul = createablbinexpr( ABL_OR , Cumul, Equation ); + Equation = createablbinexpr( ABL_AND, Cumul, Atom ); + } +/* +** A.B' + HH.( A + B' ) +*/ + else + { + Atom = createablbinexpr( ABL_AND, Atom , Equation ); + Equation = createablbinexpr( ABL_OR , Cumul, Atom ); + } + + BoomAddHashAbl( BoomHashAblTable, BddNode, Equation ); + + return( Equation ); + } + + if ( ( BddHigh->LOW->INDEX == BDD_INDEX_ZERO ) && + ( BddLow->HIGH->INDEX == BDD_INDEX_ONE ) ) + { + Equation = createablnotexpr( Equation ); + Atom = BoomBddIndex2Abl( BddHigh->INDEX ); + + Cumul = createablbinexpr( ABL_AND, + dupablexpr( Atom ), + dupablexpr( Equation ) ); + + Atom = createablbinexpr( ABL_OR, Atom, Equation ); + + Equation = BoomBddNode2Abl( BddHigh->HIGH ); +/* +** ( A'.B + HL ).( A' + B ) +*/ + if ( ( ! ABL_ATOM( Equation ) ) && + ( ABL_OPER( Equation ) == ABL_OR ) ) + { + Cumul = createablbinexpr( ABL_OR , Cumul, Equation ); + Equation = createablbinexpr( ABL_AND, Cumul, Atom ); + } +/* +** A'.B + HL.( A' + B ) +*/ + else + { + Atom = createablbinexpr( ABL_AND, Atom , Equation ); + Equation = createablbinexpr( ABL_OR , Cumul, Atom ); + } + + BoomAddHashAbl( BoomHashAblTable, BddNode, Equation ); + + return( Equation ); + } + } + } + + Equation = BoomBddNode2Mux( Equation, BddHigh, BddLow ); + + BoomAddHashAbl( BoomHashAblTable, BddNode, Equation ); + + return( Equation ); +} + + + +/*------------------------------------------------------------\ +| | +| BoomBehBddNode2Abl | +| | +\------------------------------------------------------------*/ + +void BoomBehBddNode2Abl( BehFigure ) + + befig_list *BehFigure; +{ + bddcircuit *BddCircuit; + bddsystem *BddSystem; + beout_list *BehOut; + beaux_list *BehAux; + bebux_list *BehBux; + bebus_list *BehBus; + bereg_list *BehReg; + bddnode *BddNode; + binode_list *BiNode; + biabl_list *BiAbl; + chain_list *Equation; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "--> BoomBehBddNode2Abl !\n" ); + } + + BddCircuit = BehFigure->CIRCUI; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + + BoomAblNameArray = BddCircuit->NAME_IN; + BoomAblIndexArray = BddCircuit->INDEX_IN; + + if ( BoomHashAblTable == (boomhabltable *)0 ) + { + BoomHashAblTable = BoomCreateHashAblTable( 10000 ); + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehAux %s !\n", BehAux->NAME ); + } + + if ( IsBoomBehAuxDontTouch( BehAux ) ) continue; + + BddNode = BehAux->NODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BehAux->ABL ); + BehAux->ABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( BehAux->ABL, ABL_VIEW_VHDL ); + } + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehOut %s !\n", BehOut->NAME ); + } + if ( IsBoomBehAuxDontTouch( BehOut ) ) continue; + + BddNode = BehOut->NODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BehOut->ABL ); + BehOut->ABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBus %s !\n", BehBus->NAME ); + } + + if ( IsBoomBehAuxDontTouch( BehBus ) ) continue; + + BiAbl = BehBus->BIABL; + + for ( BiNode = BehBus->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != (bddnode *)0 ) + { + BddNode = BiNode->VALNODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BiAbl->VALABL ); + BiAbl->VALABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + if ( BiNode->CNDNODE != (bddnode *)0 ) + { + BddNode = BiNode->CNDNODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BiAbl->CNDABL ); + BiAbl->CNDABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + BiAbl = BiAbl->NEXT; + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBux %s !\n", BehBux->NAME ); + } + + if ( IsBoomBehAuxDontTouch( BehBux ) ) continue; + + BiAbl = BehBux->BIABL; + + for ( BiNode = BehBux->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != (bddnode *)0 ) + { + BddNode = BiNode->VALNODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BiAbl->VALABL ); + BiAbl->VALABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + if ( BiNode->CNDNODE != (bddnode *)0 ) + { + BddNode = BiNode->CNDNODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BiAbl->CNDABL ); + BiAbl->CNDABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + BiAbl = BiAbl->NEXT; + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehReg %s !\n", BehReg->NAME ); + } + + if ( IsBoomBehAuxDontTouch( BehReg ) ) continue; + + BiAbl = BehReg->BIABL; + + for ( BiNode = BehReg->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != (bddnode *)0 ) + { + BddNode = BiNode->VALNODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BiAbl->VALABL ); + BiAbl->VALABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + if ( BiNode->CNDNODE != (bddnode *)0 ) + { + BddNode = BiNode->CNDNODE; + Equation = polarablexpr( BoomBddNode2Abl( BddNode ), 1 ); + + freeablexpr( BiAbl->CNDABL ); + BiAbl->CNDABL = Equation; + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Equation, ABL_VIEW_VHDL ); + } + } + + BiAbl = BiAbl->NEXT; + } + } + + BoomResetHashAblTable( BoomHashAblTable ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "<-- BoomBehBddNode2Abl !\n" ); + } + +} + +/*------------------------------------------------------------\ +| | +| BoomBehMapAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehMapAbl( BehFigure, Function, All ) + + befig_list *BehFigure; + chain_list *(*Function)(); + int All; +{ + beout_list *BehOut; + beaux_list *BehAux; + bebux_list *BehBux; + bebus_list *BehBus; + bereg_list *BehReg; + biabl_list *BiAbl; + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehOut ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehOut %s\n", BehOut->NAME ); + } + + BehOut->ABL = Function( BehOut->ABL ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehBus ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBus %s\n", BehBus->NAME ); + } + + BiAbl = BehBus->BIABL; + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BiAbl->VALABL = Function( BiAbl->VALABL ); + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BiAbl->CNDABL = Function( BiAbl->CNDABL ); + } + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehBux ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBux %s\n", BehBux->NAME ); + } + + BiAbl = BehBux->BIABL; + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BiAbl->VALABL = Function( BiAbl->VALABL ); + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BiAbl->CNDABL = Function( BiAbl->CNDABL ); + } + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehReg ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehReg %s\n", BehReg->NAME ); + } + + BiAbl = BehReg->BIABL; + + for ( BiAbl = BehReg->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BiAbl->VALABL = Function( BiAbl->VALABL ); + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BiAbl->CNDABL = Function( BiAbl->CNDABL ); + } + } + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehAux ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehAux %s\n", BehAux->NAME ); + } + + BehAux->ABL = Function( BehAux->ABL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehScanAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehScanAbl( BehFigure, Function, All ) + + befig_list *BehFigure; + void (*Function)(); + int All; +{ + beout_list *BehOut; + beaux_list *BehAux; + bebux_list *BehBux; + bebus_list *BehBus; + bereg_list *BehReg; + biabl_list *BiAbl; + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehOut ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehOut %s\n", BehOut->NAME ); + } + + Function( BehOut->ABL ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehBus ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBus %s\n", BehBus->NAME ); + } + + BiAbl = BehBus->BIABL; + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + Function( BiAbl->VALABL ); + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + Function( BiAbl->CNDABL ); + } + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehBux ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBux %s\n", BehBux->NAME ); + } + + BiAbl = BehBux->BIABL; + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + Function( BiAbl->VALABL ); + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + Function( BiAbl->CNDABL ); + } + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehReg ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehReg %s\n", BehReg->NAME ); + } + + BiAbl = BehReg->BIABL; + + for ( BiAbl = BehReg->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + Function( BiAbl->VALABL ); + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + Function( BiAbl->CNDABL ); + } + } + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( ( ! All ) && ( IsBoomBehAuxDontTouch( BehAux ) ) ) continue; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehAux %s\n", BehAux->NAME ); + } + + Function( BehAux->ABL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehMapAblWithName | +| | +\------------------------------------------------------------*/ + +void BoomBehMapAblWithName( BehFigure, Function ) + + befig_list *BehFigure; + chain_list *(*Function)(); +{ + beout_list *BehOut; + beaux_list *BehAux; + bebux_list *BehBux; + bebus_list *BehBus; + bereg_list *BehReg; + biabl_list *BiAbl; + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehOut %s\n", BehOut->NAME ); + } + + BehOut->ABL = Function( BehOut->NAME, BehOut->ABL ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBus %s\n", BehBus->NAME ); + } + + BiAbl = BehBus->BIABL; + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BiAbl->VALABL = Function( BehBus->NAME, BiAbl->VALABL ); + } + + /* + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BiAbl->CNDABL = Function( BiAbl->CNDABL ); + } + */ + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehBux %s\n", BehBux->NAME ); + } + + BiAbl = BehBux->BIABL; + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BiAbl->VALABL = Function( BehBux->NAME, BiAbl->VALABL ); + } + + /* + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BiAbl->CNDABL = Function( BiAbl->CNDABL ); + } + */ + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehReg %s\n", BehReg->NAME ); + } + + BiAbl = BehReg->BIABL; + + for ( BiAbl = BehReg->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BiAbl->VALABL = Function( BehReg->NAME, BiAbl->VALABL ); + } + + /* + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BiAbl->CNDABL = Function( BiAbl->CNDABL ); + } + */ + } + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BehAux %s\n", BehAux->NAME ); + } + + BehAux->ABL = Function( BehAux->NAME, BehAux->ABL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomNormalizeAbl | +| | +\------------------------------------------------------------*/ + +# if 0 +static void BoomSortAbl( expr, func, direction) + + chain_list *expr; + long (*func) (); + int direction; +{ + chain_list *expr1; + int okPermu = 1; + + if (!ABL_ATOM (expr)) /* ce n'est pas un atome */ + { + while (okPermu) + { + expr1 = ABL_CDR (expr); + okPermu = 0; + while (ABL_CDR (expr1)) + { + if ((direction == 1 && + ((*func) ABL_CAR (expr1) > (*func) ABL_CADR (expr1))) || + (direction == 0 && + ((*func) ABL_CAR (expr1) < (*func) ABL_CADR (expr1)))) + { + chain_list *permu; + + permu = ABL_CAR (expr1); + expr1->DATA = (void *) ABL_CADR (expr1); + (expr1->NEXT)->DATA = (void *) permu; + okPermu = 1; + } + expr1 = ABL_CDR (expr1); + } + } + } +} + +static int LocalBoomNormalizeAbl( Expr ) + + ablexpr *Expr; +{ + if ( ABL_ATOM( Expr ) ) + { + return ( (int)ABL_ATOM_VALUE( Expr ) ); + } + + if ( ABL_OPER (Expr) == ABL_NOT) + { + if (ABL_ATOM(ABL_CADR(Expr))) + { + return ( ABL_NOT * 100 + 10); + } + else + { + return (ABL_NOT * 100 + ABL_OPER(ABL_CADR (Expr))); + } + } + + return ABL_OPER(Expr) * 100 + getablexprlength(Expr); +} + +static void BoomNormalizeAbl( Expr ) + + ablexpr *Expr; +{ + if ( ! ABL_ATOM( Expr ) ) + { + BoomSortAbl( Expr, LocalBoomNormalizeAbl, 1 ); + + while ( ( Expr = ABL_CDR( Expr ) ) != (chain_list *)0 ) + { + BoomNormalizeAbl( ABL_CAR( Expr ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehNormalizeAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehNormalizeAbl( BehFigure ) + + befig_list *BehFigure; +{ + BoomBehMapAbl( BehFigure, BoomNormalizeAbl, 0 ); +} +# endif + +/*------------------------------------------------------------\ +| | +| BoomBehUnflatAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehUnflatAbl( BehFigure ) + + befig_list *BehFigure; +{ + BoomBehMapAbl( BehFigure, unflatablexpr, 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehFlatAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehFlatAbl( BehFigure ) + + befig_list *BehFigure; +{ + BoomBehScanAbl( BehFigure, flatablexpr, 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehSimplifyAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehSimplifyAbl( BehFigure ) + + befig_list *BehFigure; +{ + BoomBehMapAbl( BehFigure, simpablexpr, 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomReverseAbl | +| | +\------------------------------------------------------------*/ + +static chain_list *BoomReverseAbl( Expr ) + + chain_list *Expr; +{ + chain_list *ScanExpr; + + if ( ! ABL_ATOM( Expr ) ) + { + if ( ABL_CDDR( Expr ) != (chain_list *)0 ) + { + ABL_CDR( Expr ) = reverse( ABL_CDR( Expr ) ); + } + + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (chain_list *)0 ) + { + ABL_CAR( ScanExpr ) = BoomReverseAbl( ABL_CAR( ScanExpr ) ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehReverseAbl | +| | +\------------------------------------------------------------*/ + +void BoomBehReverseAbl( BehFigure ) + + befig_list *BehFigure; +{ + BoomBehMapAbl( BehFigure, BoomReverseAbl, 0 ); +} diff --git a/alliance/src/boom/src/boom_abl.h b/alliance/src/boom/src/boom_abl.h new file mode 100644 index 00000000..630337e8 --- /dev/null +++ b/alliance/src/boom/src/boom_abl.h @@ -0,0 +1,80 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_abl.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_ABL_H +# define BOOM_ABL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehBddNode2Abl(); + extern chain_list *BoomBddNode2Abl(); + extern void BoomBehMapAbl(); + extern void BoomBehScanAbl(); + extern void BoomBehMapAblWithName(); + + extern void BoomBehReverseAbl(); + extern void BoomBehFlatAbl(); + extern void BoomBehSimplifyAbl(); + extern void BoomBehUnflatAbl(); + +# endif diff --git a/alliance/src/boom/src/boom_anneal.c b/alliance/src/boom/src/boom_anneal.c new file mode 100644 index 00000000..1aed671e --- /dev/null +++ b/alliance/src/boom/src/boom_anneal.c @@ -0,0 +1,317 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_anneal.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 08.08.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_gradient.h" +# include "boom_anneal.h" + + +#ifndef AUTO_HAS_DRAND48 +/* The drand48() function return non-negative double-precision + * floating-point values uniformly distributed between [0.0, 1.0). + */ +#ifndef RAND_MAX +# define RAND_MAX (unsigned long)( (1L<<31) - 1) +# endif +#define drand48() ((double) rand() / (double) (RAND_MAX + 1.0)) +#endif + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomDupBddOrder | +| | +\------------------------------------------------------------*/ + +static chain_list *BoomDupBddOrder( BddOrder ) + + chain_list *BddOrder; +{ + chain_list *DupBddOrder; + chain_list *ScanChain; + chain_list *DupChain; + chain_list **PrevBddOrder; + + DupBddOrder = (chain_list *)0; + PrevBddOrder = &DupBddOrder; + + for ( ScanChain = BddOrder; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + DupChain = addchain( (chain_list *)0, ScanChain->DATA ); + *PrevBddOrder = DupChain; + PrevBddOrder = &DupChain->NEXT; + } + + return( DupBddOrder ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeAnneal | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeAnneal( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + long Cost; + double Proba; + double MaxProba; + long NewCost; + long BestCost; + long Iteration; + long Amplitude; + long MaxIteration; + long MaxAmplitude; + chain_list *AnnealOrder; + chain_list *NewOrder; + chain_list *BestOrder; + int Level; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + MaxAmplitude = FigInfo->AMPLITUDE; + Level = FigInfo->OPTIM_LEVEL; + + if ( MaxIteration <= 0 ) MaxIteration = 100; + /* + if ( MaxAmplitude <= 0 ) MaxAmplitude = 1 + (BddLocalSystem->NUMBER_VAR / 8); + */ + /* + if ( MaxAmplitude <= 0 ) MaxAmplitude = 1 + (BddLocalSystem->NUMBER_VAR / 2); + */ + if ( MaxAmplitude <= 0 ) MaxAmplitude = 5; + + MaxIteration = MaxIteration * (Level + 1); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Compute initial cost !\n" ); + } + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + /* + AnnealOrder = BoomBehGetBddOrder( BehFigure ); + */ + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Compute initial order\n" ); + } + + if ( Level >= 1 ) + { + AnnealOrder = BoomBehGradientBddOrder( BehFigure ); + } + else + { + AnnealOrder = BoomBehGetBddOrder( BehFigure ); + } + + BestCost = Cost; + BestOrder = (chain_list *)0; + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "done\n" ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + Amplitude = MaxAmplitude; + /* + Amplitude = 1 + (long)( (double)MaxAmplitude * + exp( - ( (double)Iteration * 8.0 ) / (double)MaxIteration ) ); + */ + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Iteration %ld, Amplitude %ld\n", Iteration, Amplitude ); + } + + BoomBehRandomBddOrder( BehFigure, Amplitude ); + + NewOrder = BoomBehGetBddOrder( BehFigure ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + MaxProba = exp( - (double)Iteration / 5.0 ); + Proba = drand48(); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Proba : %g %g\n", Proba, MaxProba ); + } + + if ( NewCost < BestCost ) + { + BestCost = NewCost; + + freechain( BestOrder ); + BestOrder = BoomDupBddOrder( AnnealOrder ); + } + + if ( ( Proba < MaxProba ) || + ( NewCost < Cost ) ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Accept new solution %ld (gain %ld)\n", NewCost, Cost - NewCost ); + } + + Cost = NewCost; + + freechain( AnnealOrder ); + AnnealOrder = NewOrder; + } + else + { + BoomBehRebuildBddNode( BehFigure, AnnealOrder ); + freechain( NewOrder ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3ld\b\b\b", ( ( Iteration + 1 ) * 100 ) / MaxIteration ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Anneal cost : %ld\n", Cost ); + } + + if ( ( BestCost < Cost ) && + ( BestOrder != (chain_list *)0 ) ) + { + freechain( AnnealOrder ); + AnnealOrder = BestOrder; + BestOrder = (chain_list *)0; + } + else + { + freechain( BestOrder ); + BestOrder = (chain_list *)0; + } + + BoomBehRebuildBddNode( BehFigure, AnnealOrder ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} diff --git a/alliance/src/boom/src/boom_anneal.h b/alliance/src/boom/src/boom_anneal.h new file mode 100644 index 00000000..cdc694ec --- /dev/null +++ b/alliance/src/boom/src/boom_anneal.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_anneal.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_ANNEAL_H +# define BOOM_ANNEAL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_ANNEAL_EXPLOSION_LIMIT 10000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeAnneal(); + +# endif diff --git a/alliance/src/boom/src/boom_aux.c b/alliance/src/boom/src/boom_aux.c new file mode 100644 index 00000000..3c8809eb --- /dev/null +++ b/alliance/src/boom/src/boom_aux.c @@ -0,0 +1,682 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_aux.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_bdd.h" +# include "boom_abl.h" +# include "boom_cost.h" +# include "boom_aux.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static befig_list *BoomBehFigure = (befig_list *)0; + static char *BoomCurrentName = (char *)0; + static long BoomAuxNumber = 0; + + static char BoomAuxName[ 128 ]; + static authtable *BoomAuxHashTable = (authtable *)0; + static authtable *BoomNotAuxHashTable = (authtable *)0; + static authtable *BoomAuxNameHashTable = (authtable *)0; + + static authtable *BoomUselessAuxHashTable = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern bddnode *loc_applybddnot(); + +/*------------------------------------------------------------\ +| | +| BoomGetAblDepth | +| | +\------------------------------------------------------------*/ + +static long BoomGetAblDepth( Expr ) + + ablexpr *Expr; +{ + long NumberOper; + long MaxDepth; + long CarDepth; + + if ( ABL_ATOM( Expr ) ) + { + return( 0 ); + } + + /* + if ( ( ABL_ATOM( Expr ) ) || + ( ( ABL_OPER( Expr ) == ABL_NOT ) && + ( ABL_ATOM( ABL_CADR( Expr ) ) ) ) ) + { + return( 0 ); + } + */ + + MaxDepth = 0; + NumberOper = 0; + + while ( ( Expr = ABL_CDR( Expr ) ) != (chain_list *)0 ) + { + CarDepth = BoomGetAblDepth( ABL_CAR( Expr ) ); + + if ( CarDepth > MaxDepth ) MaxDepth = CarDepth; + + /* NumberOper++; */ + } + + NumberOper++; + + if ( NumberOper > 1 ) NumberOper--; + + return( MaxDepth + NumberOper ); +} + +/*------------------------------------------------------------\ +| | +| BoomCheckIfGoodAuxAbl | +| | +\------------------------------------------------------------*/ + +static int BoomCheckIfGoodAuxAbl( Expr ) + + ablexpr *Expr; +{ + if ( ( ABL_ATOM( Expr ) ) || + ( ( ABL_OPER( Expr ) == ABL_NOT ) && + ( ABL_ATOM( ABL_CADR( Expr ) ) ) ) ) + { + return( 0 ); + } + + return( 1 ); + /* + long MaxDepth; + + MaxDepth = BoomGetAblDepth( Expr ); + + return ( MaxDepth >= BOOM_AUX_MIN_DEPTH ); + */ +} + +/*------------------------------------------------------------\ +| | +| BoomCreateAuxAbl | +| | +\------------------------------------------------------------*/ + +static ablexpr *BoomCreateAuxAbl( Expr ) + + ablexpr *Expr; +{ + bddnode *BddNode; + bddnode *BddNot; + chain_list *ScanExpr; + authelem *Element; + char *Name; + long Polar; + + if ( ! ABL_ATOM( Expr ) ) + { + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (chain_list *)0 ) + { + ABL_CAR( ScanExpr ) = BoomCreateAuxAbl( ABL_CAR( ScanExpr ) ); + } + + BddNode = BoomGetBddMarkAbl( Expr ); + + if ( BddNode == NULL ) + { + return( Expr ); + } + + BddNot = decbddrefext( loc_applybddnot( BddNode ) ); + + if ( IsBoomDebugLevel2() ) + { + viewablexprln( ScanExpr, ABL_VIEW_VHDL ); + + fprintf( stdout, "BddNode->MARK %d\n", BddNode->MARK ); + fprintf( stdout, "BddNot->MARK %d\n", BddNot->MARK ); + } + + Polar = 1; + Element = searchauthelem( BoomAuxHashTable, (char *)BddNode ); + + if ( Element == (authelem *)0 ) + { + Element = searchauthelem( BoomNotAuxHashTable, (char *)BddNode ); + Polar = 0; + } + + if ( Element == (authelem *)0 ) + { + if ( ( (BddNode->MARK + BddNot->MARK ) < 2 ) || + ( ! BoomCheckIfGoodAuxAbl( Expr ) ) ) + { + return( Expr ); + } + + sprintf( BoomAuxName, "aux%ld", BoomAuxNumber++ ); + + Name = namealloc( BoomAuxName ); + + if ( BddNot->MARK < BddNode->MARK ) + { + addauthelem( BoomAuxHashTable , (char *)BddNode, (long)Name ); + addauthelem( BoomNotAuxHashTable, (char *)BddNot , (long)Name ); + } + else + { + addauthelem( BoomAuxHashTable , (char *)BddNot , (long)Name ); + addauthelem( BoomNotAuxHashTable, (char *)BddNode, (long)Name ); + + BoomUnmarkBddNode( Expr ); + Expr = createablnotexpr( Expr ); + } + + BoomBehFigure->BEAUX = beh_addbeaux( BoomBehFigure->BEAUX, Name, Expr, (void *)0 ); + BoomAddBehAuxInfo( BoomBehFigure->BEAUX ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Add auxiliary signal %s P %d N %d\n", + Name, BddNode->MARK, BddNot->MARK ); + viewablexprln( Expr, ABL_VIEW_VHDL ); + } + + if ( BddNot->MARK < BddNode->MARK ) + { + Expr = createablatom( Name ); + } + else + { + Expr = createablnotexpr( createablatom( Name ) ); + } + } + else + { + Name = (char *)Element->VALUE; + + if ( Name != BoomCurrentName ) + { + /* BIG BUG !! */ + Element = searchauthelem( BoomAuxNameHashTable, Name ); + + if ( Element == (authelem *)0 ) + { + BoomUnmarkBddNode( Expr ); + freeablexpr( Expr ); + + Expr = createablatom( Name ); + + if ( ! Polar ) Expr = createablnotexpr( Expr ); + } + } + + return( Expr ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomCreateAuxAblWithName | +| | +\------------------------------------------------------------*/ + +static ablexpr *BoomCreateAuxAblWithName( Name, Expr ) + + char *Name; + ablexpr *Expr; +{ + BoomCurrentName = Name; + + Expr = BoomCreateAuxAbl( Expr ); + + return ( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehInitializeAux | +| | +\------------------------------------------------------------*/ + +void BoomBehInitializeAux( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + bddnode *BddNode; + bddnode *BddNot; + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( IsBoomBehAuxDontTouch( BehAux ) ) continue; + + BddNode = BehAux->NODE; + BddNot = decbddrefext( loc_applybddnot( BddNode ) ); + + addauthelem( BoomAuxHashTable , (char *)BddNode, (long)BehAux->NAME ); + addauthelem( BoomNotAuxHashTable , (char *)BddNot , (long)BehAux->NAME ); + addauthelem( BoomAuxNameHashTable, BehAux->NAME , 0 ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomCountAuxOccurAbl | +| | +\------------------------------------------------------------*/ + +static void BoomCountAuxOccurAbl( Expr ) + + ablexpr *Expr; +{ + ablexpr *ScanExpr; + authelem *Element; + char *Value; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + Element = searchauthelem( BoomUselessAuxHashTable, Value ); + + if ( Element != (authelem *)0 ) + { + Element->VALUE++; + } + } + else + { + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (chain_list *)0 ) + { + BoomCountAuxOccurAbl( ABL_CAR( ScanExpr ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomReplaceUselessAuxAbl | +| | +\------------------------------------------------------------*/ + +static ablexpr *BoomReplaceUselessAuxAbl( Expr ) + + ablexpr *Expr; +{ + ablexpr *ScanExpr; + authelem *Element; + char *Value; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + Element = searchauthelem( BoomUselessAuxHashTable, Value ); + + if ( Element != (authelem *)0 ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Replace %s by ", Value ); + viewablexprln( (ablexpr *)Element->VALUE, ABL_VIEW_VHDL ); + } + + freeablexpr( Expr ); + Expr = BoomReplaceUselessAuxAbl( dupablexpr( (ablexpr *)Element->VALUE ) ); + + if ( IsBoomDebugLevel1() ) + { + viewablexprln( Expr, ABL_VIEW_VHDL ); + } + } + } + else + { + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (chain_list *)0 ) + { + ABL_CAR( ScanExpr ) = BoomReplaceUselessAuxAbl( ABL_CAR( ScanExpr ) ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehDeleteUselessAux | +| | +\------------------------------------------------------------*/ + +void BoomBehDeleteUselessAux( BehFigure, InitialAux, RemoveBerin ) + + befig_list *BehFigure; + beaux_list *InitialAux; +{ + boombeauxinfo *AuxInfo; + beaux_list *BehAux; + beaux_list *DelBehAux; + beaux_list *HeadBehAux; + beaux_list **PrevBehAux; + authelem *Element; + + if ( BoomUselessAuxHashTable == (authtable *)0 ) + { + BoomUselessAuxHashTable = createauthtable( 10000 ); + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( BehAux == InitialAux ) break; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Add '%s'\n", BehAux->NAME ); + } + + addauthelem( BoomUselessAuxHashTable, BehAux->NAME, 0 ); + } + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Count Occurences\n" ); + } + + BoomBehScanAbl( BehFigure, BoomCountAuxOccurAbl, 0 ); + + BoomBehGiveCost( BehFigure ); + + HeadBehAux = (beaux_list *)0; + PrevBehAux = &BehFigure->BEAUX; + BehAux = BehFigure->BEAUX; + + while ( BehAux != (beaux_list *)0 ) + { + if ( BehAux == InitialAux ) break; + + AuxInfo = GetBoomBehAuxInfo( BehAux ); + Element = searchauthelem( BoomUselessAuxHashTable, BehAux->NAME ); + + if ( ( ! IsBoomBehAuxKeep( BehAux ) ) && + ( ( Element->VALUE <= 1 ) || + ( AuxInfo->LITERAL_COST <= 1 ) || + ( ( AuxInfo->LITERAL_COST < BOOM_AUX_MIN_LITERAL_COST ) && + ( Element->VALUE < BOOM_AUX_MIN_OCCUR ) ) ) ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Should delete %s %ld %ld\n", + BehAux->NAME, Element->VALUE, AuxInfo->LITERAL_COST ); + } + + Element->VALUE = (long)BehAux->ABL; + + DelBehAux = BehAux; + BehAux = BehAux->NEXT; + *PrevBehAux = BehAux; + + DelBehAux->NEXT = HeadBehAux; + HeadBehAux = DelBehAux; + + if ( RemoveBerin ) + { + BehFigure->BERIN = beh_rmvberin( BehFigure->BERIN, DelBehAux->NAME ); + } + } + else + { + delauthelem( BoomUselessAuxHashTable, BehAux->NAME ); + + PrevBehAux = &BehAux->NEXT; + BehAux = BehAux->NEXT; + } + } + + BoomBehMapAbl( BehFigure, BoomReplaceUselessAuxAbl, 1 ); + + BoomBehFreeBehAux( HeadBehAux ); + + resetauthtable( BoomUselessAuxHashTable ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehCreateAux | +| | +\------------------------------------------------------------*/ + +void BoomBehCreateAux( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *InitialAux; + bddcircuit *BddCircuit; + bddsystem *BddSystem; + long Reverse; + + BddCircuit = BehFigure->CIRCUI; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + + BoomBehFigure = BehFigure; + +# ifdef DEBUG +fprintf( stdout, "Before BoomBehMakeBddNode\n" ); +testbddcircuit( (bddcircuit *)0 ); +# endif + + InitialAux = BehFigure->BEAUX; + BoomAuxNumber = 0; + + if ( BoomAuxHashTable == (authtable *)0 ) + { + BoomAuxHashTable = createauthtable( 1000 ); + BoomNotAuxHashTable = createauthtable( 1000 ); + BoomAuxNameHashTable = createauthtable( 1000 ); + } + + for ( Reverse = 0; Reverse < 4; Reverse++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BoomBehCreateAux Reverse %ld\n", Reverse ); + } + + if ( Reverse != 0 ) + { + BoomBehReverseAbl( BehFigure ); + } + + /* + garbagebddsystem( (bddsystem *)0 ); + fprintf( stdout, "Before %ld ", BddLocalSystem->NUMBER_NODE ); + */ + + BoomBehUnflatAbl( BehFigure ); + BoomBehMakeBddNode( BehFigure, 1 ); + + BoomBehInitializeAux( BehFigure ); + BoomBehMapAblWithName( BehFigure, BoomCreateAuxAblWithName ); + BoomBehUnmarkBddNode( BehFigure ); + + /* + garbagebddsystem( (bddsystem *)0 ); + fprintf( stdout, "After %ld\n", BddLocalSystem->NUMBER_NODE ); + */ + + resetauthtable( BoomAuxHashTable ); + resetauthtable( BoomNotAuxHashTable ); + resetauthtable( BoomAuxNameHashTable ); + + BoomBehFlatAbl( BehFigure ); + BoomBehSimplifyAbl( BehFigure ); + + /* + BoomBehDeleteUselessAux( BehFigure, InitialAux, 0 ); + */ + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Reverse %ld Aux %ld\n", Reverse, BoomAuxNumber ); + } + } + + /* + for ( BoomAuxMinDepth = 15; BoomAuxMinDepth >= 2; BoomAuxMinDepth-- ) + BoomAuxMinDepth = 2; + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Check Depth %ld\n", BoomAuxMinDepth ); + } + } + */ + +# ifdef DEBUG +fprintf( stdout, "After BoomCreateAuxAbl\n" ); +testbddcircuit( (bddcircuit *)0 ); +# endif + +# ifdef DEBUG +fprintf( stdout, "After UnmarkAbl\n" ); +testbddcircuit( (bddcircuit *)0 ); + + BoomBehResetBddNode( BehFigure ); +# endif +} + +/*------------------------------------------------------------\ +| | +| BoomBehComputeAux | +| | +\------------------------------------------------------------*/ + +beaux_list *BoomBehComputeAux( BehFigure, BehAux ) + + befig_list *BehFigure; + beaux_list *BehAux; +{ + beaux_list *ScanAux; + beaux_list **PrevAux; + + PrevAux = &BehFigure->BEAUX; + + for ( ScanAux = BehFigure->BEAUX; + ScanAux != (beaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + if ( ScanAux == BehAux ) + { + *PrevAux = (beaux_list *)0; break; + } + + PrevAux = &ScanAux->NEXT; + } + + BoomBehFreeBehAux( BehFigure->BEAUX ); + + BehFigure->BEAUX = ScanAux; + BehAux = ScanAux; + + BoomBehBddNode2Abl( BehFigure ); + + if ( IsBoomDebugLevel2() ) + { + BoomDebugSaveBehFigure( BehFigure, NULL ); + } + + BoomBehCreateAux( BehFigure ); + + if ( IsBoomDebugLevel2() ) + { + BoomDebugSaveBehFigure( BehFigure, NULL ); + } + + return( BehAux ); +} diff --git a/alliance/src/boom/src/boom_aux.h b/alliance/src/boom/src/boom_aux.h new file mode 100644 index 00000000..6c8861f0 --- /dev/null +++ b/alliance/src/boom/src/boom_aux.h @@ -0,0 +1,78 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_aux.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_AUX_H +# define BOOM_AUX_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_AUX_MIN_DEPTH 2 +# define BOOM_AUX_MIN_OCCUR 2 +# define BOOM_AUX_MIN_LITERAL_COST 2 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehCreateAux(); + extern beaux_list *BoomBehComputeAux(); + extern void BoomBehDeleteUselessAux(); + +# endif diff --git a/alliance/src/boom/src/boom_auxinit.c b/alliance/src/boom/src/boom_auxinit.c new file mode 100644 index 00000000..c5999a41 --- /dev/null +++ b/alliance/src/boom/src/boom_auxinit.c @@ -0,0 +1,352 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_auxinit.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_abl.h" +# include "boom_cost.h" +# include "boom_aux.h" +# include "boom_auxinit.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static befig_list *BoomBehFigure = (befig_list *)0; + static boombefiginfo *BoomFigInfo = (boombefiginfo *)0; + static authtable *BoomHashAux = (authtable *)0; + static long BoomAuxNumber = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomGetNumberAtomicXorAbl | +| | +\------------------------------------------------------------*/ + +static long BoomGetNumberAtomicXorAbl( Expr ) + + ablexpr *Expr; +{ + ablexpr *ScanExpr; + long Oper; + long Count; + + if ( ABL_ATOM( Expr ) ) + { + return( 0 ); + } + else + { + Oper = ABL_OPER( Expr ); + Count = 0; + + if ( ( Oper == ABL_XOR ) || + ( Oper == ABL_NXOR ) ) + { + Count = 1; + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (ablexpr *)0 ) + { + if ( ! ABL_ATOM( ABL_CAR( ScanExpr ) ) ) + { + Count = 0; break; + } + } + } + + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + Count += BoomGetNumberAtomicXorAbl( ABL_CAR( Expr ) ); + } + } + + return( Count ); +} + +/*------------------------------------------------------------\ +| | +| BoomGetNewAuxInitName | +| | +\------------------------------------------------------------*/ + +static char *BoomGetNewAuxInitName() +{ + authelem *Element; + char *Name; + char Buffer[ 32 ]; + + do + { + sprintf( Buffer, "boom_init_%ld", BoomAuxNumber++ ); + Name = namealloc( Buffer ); + Element = searchauthelem( BoomHashAux, Name ); + } + while ( Element != (authelem *)0 ); + + return( Name ); +} + +/*------------------------------------------------------------\ +| | +| BoomCreateAuxInitComparatorAbl | +| | +\------------------------------------------------------------*/ + +static ablexpr *BoomCreateAuxInitComparatorAbl( Expr ) + + ablexpr *Expr; +{ + ablexpr *ScanExpr; + long Oper; + ablexpr *Operand1; + ablexpr *Operand2; + ablexpr *AuxExpr; + char *AuxName; + + if ( ! ABL_ATOM( Expr ) ) + { + Oper = ABL_OPER( Expr ); + + if ( ( Oper == ABL_XOR ) || + ( Oper == ABL_NXOR ) ) + { + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (ablexpr *)0 ) + { + if ( ! ABL_ATOM( ABL_CAR( ScanExpr ) ) ) break; + } + + if ( ScanExpr == (ablexpr *)0 ) + { +/* +** Create auxiliary variables for each xor couple +*/ + ScanExpr = Expr; + Operand1 = (ablexpr *)0; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (ablexpr *)0 ) + { + if ( Operand1 == (ablexpr *)0 ) + { + Operand1 = ABL_CAR( ScanExpr ); + ABL_CAR( ScanExpr ) = (ablexpr *)0; + + continue; + } + + Operand2 = ABL_CAR( ScanExpr ); + ABL_CAR( ScanExpr ) = (ablexpr *)0; + + AuxExpr = createablbinexpr( ABL_XOR, Operand1, Operand2 ); + AuxName = BoomGetNewAuxInitName(); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Found a comparator, add aux init %s\n", AuxName ); + } + + BoomBehFigure->BEAUX = beh_addbeaux( BoomBehFigure->BEAUX, AuxName, AuxExpr, (void *)0 ); + BoomBehFigure->BERIN = beh_addberin( BoomBehFigure->BERIN, AuxName ); + BoomAddBehAuxInfo( BoomBehFigure->BEAUX ); + SetBoomBehAuxKeep( BoomBehFigure->BEAUX ); + + Operand1 = createablatom( AuxName ); + } + + freeablexpr( Expr ); + + Expr = Operand1; + + if ( Oper == ABL_NXOR ) Expr = optimablnotexpr( Expr ); + + return( Expr ); + } + } + + ScanExpr = Expr; + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (ablexpr *)0 ) + { + ABL_CAR( ScanExpr ) = BoomCreateAuxInitComparatorAbl( ABL_CAR( ScanExpr ) ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomIdentifiyComparatorAbl | +| | +\------------------------------------------------------------*/ + +static ablexpr *BoomIdentifiyComparatorAbl( Expr ) + + ablexpr *Expr; +{ + long Number; + + Number = BoomGetNumberAtomicXorAbl( Expr ); + + if ( Number > BOOM_AUX_INIT_MAX_XOR ) + { + Expr = BoomCreateAuxInitComparatorAbl( Expr ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomKeepStableAuxAbl | +| | +\------------------------------------------------------------*/ + +static void BoomKeepStableAuxAbl( Expr ) + + ablexpr *Expr; +{ + authelem *Element; + char *Value; + beaux_list *BehAux; + long Oper; + + if ( ABL_ATOM( Expr ) ) return; + + Oper = ABL_OPER( Expr ); + + if ( Oper == ABL_STABLE ) + { + Expr = ABL_CADR( Expr ); + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + Element = searchauthelem( BoomHashAux, Value ); + + if ( Element != (authelem *)0 ) + { + BehAux = (beaux_list *)Element->VALUE; + SetBoomBehAuxKeep( BehAux ); + } + } + } + else + { + while ( ( Expr = ABL_CDR( Expr ) ) != (chain_list *)0 ) + { + BoomKeepStableAuxAbl( ABL_CAR( Expr ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehCreateAuxInit | +| | +\------------------------------------------------------------*/ + +void BoomBehCreateAuxInit( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + + BoomBehFigure = BehFigure; + BoomFigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomHashAux = createauthtable( 100 ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + addauthelem( BoomHashAux, BehAux->NAME, (long)BehAux ); + + if ( BoomFigInfo->KEEP_AUX ) + { + SetBoomBehAuxKeep( BehAux ); + } + } + + BoomBehScanAbl( BehFigure, BoomKeepStableAuxAbl, 1 ); + + BoomBehDeleteUselessAux( BehFigure, (beaux_list *)0, 1 ); + + BoomBehMapAbl( BehFigure, simpablexpr, 1 ); + + BoomBehMapAbl( BehFigure, BoomIdentifiyComparatorAbl, 0 ); + + destroyauthtable( BoomHashAux ); +} diff --git a/alliance/src/boom/src/boom_auxinit.h b/alliance/src/boom/src/boom_auxinit.h new file mode 100644 index 00000000..02390c7b --- /dev/null +++ b/alliance/src/boom/src/boom_auxinit.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_auxinit.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_AUX_INIT_H +# define BOOM_AUX_INIT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_AUX_INIT_MAX_XOR 5 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehCreateAuxInit(); + +# endif diff --git a/alliance/src/boom/src/boom_bdd.c b/alliance/src/boom/src/boom_bdd.c new file mode 100644 index 00000000..0c1ef09c --- /dev/null +++ b/alliance/src/boom/src/boom_bdd.c @@ -0,0 +1,1841 @@ +/*------------------------------------------------------------\ +| | +| 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 : Boom | +| | +| File : boom_bdd.c | +| | +| Date : 06.06.00 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H + +# include +# include + +# include "boom_bdd.h" +# include "boom_abl.h" +# include "boom_order.h" +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static chain_list *BoomBddHeadName = (chain_list *)0; + static befig_list *BoomBddBehFigure = (befig_list *)0; + static char BoomBddMarkAbl = 0; + + static long BoomBddNumberNode = 0; + + static authtable *BoomBddHashAux = (authtable *)0; + static authtable *BoomBddHashKeepAux = (authtable *)0; + static authtable *BoomBddHashRenameAux = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Abl 2 Bdd | +| | +\------------------------------------------------------------*/ + +static bddnode *BoomExpr2BddNode( Expr ) + + chain_list *Expr; +{ + bddnode *BddNode; + bddnode *BddFirst; + char *AtomValue; + beaux_list *ScanAux; + chain_list *ScanChain; + chain_list *ScanExpr; + long Oper; + int Negative; + + if ( Expr == (chain_list *)0 ) + { + BoomError( BOOM_EXPR_NULL_ERROR, (char *)0 ); + } + + if ( ABL_ATOM( Expr ) ) + { + AtomValue = ABL_ATOM_VALUE( Expr ); + + if ( AtomValue == ABL_ATOM_NAME_ONE ) + { + return( BddLocalSystem->ONE ); + } + + if ( AtomValue == ABL_ATOM_NAME_ZERO ) + { + return( BddLocalSystem->ZERO ); + } + + BddNode = searchbddcircuitin( (bddcircuit *)0, AtomValue ); + + if ( BddNode != (bddnode *)0 ) + { + return( incbddrefext( BddNode ) ); + } + + for ( ScanAux = BoomBddBehFigure->BEAUX; + ScanAux != (beaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + if ( ScanAux->NAME == AtomValue ) break; + } + + if ( ScanAux == (beaux_list *)0 ) + { + BoomError( BOOM_UNKNOWN_ATOM_ERROR, AtomValue ); + } + + for ( ScanChain = BoomBddHeadName; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + if ( ScanChain->DATA == AtomValue ) + { + BoomError( BOOM_EXPR_LOOP_ERROR, AtomValue ); + } + } + + if ( ScanAux->NODE == (void *)0 ) + { + BoomBddHeadName = addchain( BoomBddHeadName, AtomValue ); + ScanAux->NODE = (void *)BoomExpr2BddNode( ScanAux->ABL ); + BoomBddHeadName = delchain( BoomBddHeadName, BoomBddHeadName ); + } + + BddNode = ScanAux->NODE; + + return( incbddrefext( BddNode ) ); + } + + Oper = ABL_OPER( Expr ); + ScanExpr = ABL_CDR( Expr ); + + if ( Oper == ABL_NOT ) + { + if ( ABL_CDR( ScanExpr ) != (chain_list *)0 ) + { + BoomError( BOOM_OPERATOR_ERROR, Oper ); + } + + BddFirst = BoomExpr2BddNode( ABL_CAR( ScanExpr ) ); + + BddNode = applybddnodenot( (bddsystem *)0, + decbddrefext( BddFirst ) ); + + if ( BoomBddMarkAbl ) BoomSetBddMarkAbl( Expr, BddNode ); + + return( BddNode ); + } + + if ( Oper == ABL_STABLE ) + { + ScanExpr = ABL_CAR( ScanExpr ); + + if ( ! ABL_ATOM( ScanExpr ) ) + { + BoomError( BOOM_ILLEGAL_STABLE_ERROR, (char *)0 ); + } + + AtomValue = ABL_ATOM_VALUE( ScanExpr ); + BddFirst = searchbddcircuitin( (bddcircuit *)0, AtomValue ); + + if ( BddFirst == (bddnode *)0 ) + { + BoomError( BOOM_UNKNOWN_ATOM_ERROR, AtomValue ); + } + + AtomValue = getbddstablename( AtomValue ); + BddNode = searchbddcircuitin( (bddcircuit *)0, AtomValue ); + + if ( BddNode == (bddnode *)0 ) + { + BddNode = addbddcircuitin( (bddcircuit *)0, AtomValue, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + if ( BoomBddMarkAbl ) BoomSetBddMarkAbl( Expr, BddNode ); + + return( BddNode ); + } + + if ( ( isablunaryoper( Oper ) ) || + ( ABL_CDR( ScanExpr ) == (chain_list *)0 ) ) + { + BoomError( BOOM_OPERATOR_ERROR, Oper ); + } + + if ( ( getabloperpolar( Oper ) == ABL_POLAR_POSITIVE ) || + ( ABL_CDDR( ScanExpr ) == (chain_list *)0 ) ) + { + Negative = 0; + } + else + { + Negative = 1; + Oper = getablopernot( Oper ); + } + + BddFirst = BoomExpr2BddNode( ABL_CAR( ScanExpr ) ); + + while ( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (chain_list *)0 ) + { + BddNode = BoomExpr2BddNode( ABL_CAR( ScanExpr ) ); + + BddFirst = applybddnode( (bddsystem *)0, Oper, + decbddrefext( BddFirst ), + decbddrefext( BddNode ) ); + } + + if ( Negative ) + { + BddFirst = applybddnodenot( (bddsystem *)0, + decbddrefext( BddFirst ) ); + } + + if ( BoomBddMarkAbl ) BoomSetBddMarkAbl( Expr, BddFirst ); + + return( BddFirst ); +} + +/*------------------------------------------------------------\ +| | +| Beh Abl 2 Bdd | +| | +\------------------------------------------------------------*/ + +static bddnode *BoomAbl2BddNode( Name, Expr ) + + char *Name; + chain_list *Expr; +{ + bddnode *BddNode; + + if ( Name != (char *)0 ) + { + BoomBddHeadName = addchain( BoomBddHeadName, Name ); + } + + BddNode = BoomExpr2BddNode( Expr ); + + if ( Name != (char *)0 ) + { + BoomBddHeadName = delchain( BoomBddHeadName, BoomBddHeadName ); + } + + if ( IsBddSystemExplosion( BddLocalSystem ) ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion !!! %ld\n", BddLocalSystem->NUMBER_NODE ); + } + + garbagebddsystem( BddLocalSystem ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion !!! %ld\n", BddLocalSystem->NUMBER_NODE ); + } + + explosionbddsystemrestart( BddLocalSystem ); + + explosionbddsystemdynamic( BddLocalSystem, NULL, BOOM_BDD_EXPLOSION_LIMIT ); + + BddNode = (bddnode *)0; + } + else + if ( Name != (char *)0 ) + { + BddNode = addbddcircuitout( (bddcircuit *)0, Name, BddNode ); + } + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| Beh Make Bdd | +| | +\------------------------------------------------------------*/ + +void BoomBehMakeBddNode( BehFigure, MarkAbl ) + + befig_list *BehFigure; + int MarkAbl; +{ + beaux_list *BehAux; + beout_list *BehOut; + bebus_list *BehBus; + bebux_list *BehBux; + bereg_list *BehReg; + biabl_list *BiAbl; + binode_list *BiNode; + + BoomBddBehFigure = BehFigure; + BoomBddHeadName = (chain_list *)0; + BoomBddMarkAbl = MarkAbl; + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( BehAux->NODE != (void *)0 ) decbddrefext( BehAux->NODE ); + + if ( ! IsBoomBehAuxDontTouch( BehAux ) ) + { + BehAux->NODE = (void *)BoomAbl2BddNode( BehAux->NAME, BehAux->ABL ); + } + else + { + BehAux->NODE = (void *)0; + } + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + BiNode = BehBus->BINODE; + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) decbddrefext( BiNode->VALNODE ); + if ( BiNode->CNDNODE != (void *)0 ) decbddrefext( BiNode->CNDNODE ); + + if ( ! IsBoomBehAuxDontTouch( BehBus ) ) + { + BiNode->VALNODE = (void *)BoomAbl2BddNode( BehBus->NAME, BiAbl->VALABL ); + BiNode->CNDNODE = (void *)BoomAbl2BddNode( (char *)0, BiAbl->CNDABL ); + } + else + { + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + } + + BiNode = BiNode->NEXT; + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + BiNode = BehBux->BINODE; + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) decbddrefext( BiNode->VALNODE ); + if ( BiNode->CNDNODE != (void *)0 ) decbddrefext( BiNode->CNDNODE ); + + if ( ! IsBoomBehAuxDontTouch( BehBux ) ) + { + BiNode->VALNODE = (void *)BoomAbl2BddNode( BehBux->NAME, BiAbl->VALABL ); + BiNode->CNDNODE = (void *)BoomAbl2BddNode( (char *)0, BiAbl->CNDABL ); + } + else + { + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + } + + BiNode = BiNode->NEXT; + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + BiNode = BehReg->BINODE; + + for ( BiAbl = BehReg->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) decbddrefext( BiNode->VALNODE ); + if ( BiNode->CNDNODE != (void *)0 ) decbddrefext( BiNode->CNDNODE ); + + if ( ! IsBoomBehAuxDontTouch( BehReg ) ) + { + BiNode->VALNODE = (void *)BoomAbl2BddNode( BehReg->NAME, BiAbl->VALABL ); + BiNode->CNDNODE = (void *)BoomAbl2BddNode( (char *)0, BiAbl->CNDABL ); + } + else + { + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + } + + BiNode = BiNode->NEXT; + } + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( BehOut->NODE != (void *)0 ) decbddrefext( BehOut->NODE ); + + if ( ! IsBoomBehAuxDontTouch( BehOut ) ) + { + BehOut->NODE = (void *)BoomAbl2BddNode( BehOut->NAME, BehOut->ABL ); + } + else + { + BehOut->NODE = (void *)0; + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomBddSetExprKeepAux | +| | +\------------------------------------------------------------*/ + +static long BoomBddSetExprKeepAux( Expr ) + + ablexpr *Expr; +{ + char *Value; + char *Name; + char *Vector; + beaux_list *BehAux; + bddnode *BddNode; + authelem *Element; + long Index; + long Number; + + Number = 0; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + + if ( ( Value != ABL_ATOM_NAME_ONE ) && + ( Value != ABL_ATOM_NAME_ZERO ) && + ( Value != ABL_ATOM_NAME_DC ) && + ( Value != ABL_ATOM_NAME_TRISTATE ) ) + { + Element = searchauthelem( BoomBddHashAux, Value ); + + if ( Element != (authelem *)0 ) + { + BehAux = (beaux_list *)Element->VALUE; + Element = searchauthelem( BoomBddHashKeepAux, Value ); + + if ( Element == (authelem *)0 ) + { + boombefiginfo *FigInfo; + + FigInfo = GetBoomBehFigInfo( BoomBddBehFigure ); + + Name = vhdlablvector( BehAux->NAME, &Index ); + + if ( Name != (char *)0 ) + { + for ( BehAux = BoomBddBehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + Vector = vhdlablvector( BehAux->NAME, &Index ); + + if ( Vector == Name ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Keep %s\n", BehAux->NAME ); + } + + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep signal %s\n", BehAux->NAME ); + } + + addauthelem( BoomBddHashKeepAux, BehAux->NAME, 0 ); + SetBoomBehAuxKeep( BehAux ); + BddNode = addbddcircuitin( (bddcircuit *)0, BehAux->NAME, + 0, BDD_IN_MODE_LAST ); + + Number++; + } + } + } + else + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Keep %s\n", BehAux->NAME ); + } + + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep signal %s\n", BehAux->NAME ); + } + + addauthelem( BoomBddHashKeepAux, BehAux->NAME, 0 ); + SetBoomBehAuxKeep( BehAux ); + BddNode = addbddcircuitin( (bddcircuit *)0, BehAux->NAME, 0, BDD_IN_MODE_LAST ); + + Number++; + } + } + else + { + Number++; + } + } + } + } + else + { + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + Number += BoomBddSetExprKeepAux( ABL_CAR( Expr ) ); + } + } + + return( Number ); +} + +/*------------------------------------------------------------\ +| | +| Beh Make Bdd No Explosion | +| | +\------------------------------------------------------------*/ + +void BoomBehMakeBddNodeNoExplosion( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + beout_list *BehOut; + bebus_list *BehBus; + bebux_list *BehBux; + bereg_list *BehReg; + biabl_list *BiAbl; + binode_list *BiNode; + bddnode *BddNode; + char *Name; + char *Vector; + long Index; + int Retry; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomBddBehFigure = BehFigure; + BoomBddHeadName = (chain_list *)0; + BoomBddMarkAbl = 0; + + explosionbddsystemdynamic( (bddsystem *)0, NULL, BOOM_BDD_EXPLOSION_LIMIT ); + + if ( BoomBddHashAux == (authtable *)0 ) + { + BoomBddHashAux = createauthtable( 100 ); + BoomBddHashKeepAux = createauthtable( 100 ); + BoomBddHashRenameAux = createauthtable( 100 ); + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + addauthelem( BoomBddHashAux, BehAux->NAME, (long)BehAux ); + } + + Retry = 1; + + while ( Retry ) + { + Retry = 0; + + for ( BehAux = BehFigure->BEAUX; + ( BehAux != (beaux_list *)0 ) && ( ! Retry ); + BehAux = BehAux->NEXT ) + { + if ( BehAux->NODE != (void *)0 ) decbddrefext( BehAux->NODE ); + + if ( ! IsBoomBehAuxDontTouch( BehAux ) ) + { + BehAux->NODE = (void *)BoomAbl2BddNode( BehAux->NAME, BehAux->ABL ); +/* +** Explosion ! +*/ + if ( BehAux->NODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehAux->NAME ); + } + + Retry = 1; + + Name = vhdlablvector( BehAux->NAME, &Index ); + + if ( Name != (char *)0 ) + { + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + Vector = vhdlablvector( BehAux->NAME, &Index ); + + if ( Vector == Name ) + { + BddNode = addbddcircuitin( (bddcircuit *)0, BehAux->NAME, + 0, BDD_IN_MODE_LAST ); + + if ( IsBoomBehAuxKeep( BehAux ) ) + { + SetBoomBehAuxDontTouch( BehAux ); + + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch signal %s\n", BehAux->NAME ); + } + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep signal %s\n", BehAux->NAME ); + } + + SetBoomBehAuxKeep( BehAux ); + + if ( BoomBddSetExprKeepAux( BehAux->ABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehAux ); + } + } + } + } + else + { + BddNode = addbddcircuitin( (bddcircuit *)0, BehAux->NAME, 0, BDD_IN_MODE_LAST ); + + if ( IsBoomBehAuxKeep( BehAux ) ) + { + SetBoomBehAuxDontTouch( BehAux ); + } + + SetBoomBehAuxKeep( BehAux ); + BoomBddSetExprKeepAux( BehAux->ABL ); + } + + break; + } + } + else + { + BehAux->NODE = (void *)0; + } + } + + for ( BehBus = BehFigure->BEBUS; + ( BehBus != (bebus_list *)0 ) && ( ! Retry ); + BehBus = BehBus->NEXT ) + { + BiNode = BehBus->BINODE; + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) decbddrefext( BiNode->VALNODE ); + if ( BiNode->CNDNODE != (void *)0 ) decbddrefext( BiNode->CNDNODE ); + + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + + if ( ! IsBoomBehAuxDontTouch( BehBus ) ) + { + BiNode->VALNODE = (void *)BoomAbl2BddNode( BehBus->NAME, BiAbl->VALABL ); + + if ( BiNode->VALNODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehBus->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehBus ) ) + { + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch bus signal %s\n", BehBus->NAME ); + } + + SetBoomBehAuxDontTouch( BehBus ); + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep bus signal %s\n", BehBus->NAME ); + } + + SetBoomBehAuxKeep( BehBus ); + + if ( BoomBddSetExprKeepAux( BiAbl->VALABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehBus ); + } + + break; + } + + BiNode->CNDNODE = (void *)BoomAbl2BddNode( (char *)0, BiAbl->CNDABL ); + + if ( BiNode->CNDNODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehBus->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehBus ) ) + { + SetBoomBehAuxDontTouch( BehBus ); + + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch bus signal %s\n", BehBus->NAME ); + } + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep bus signal %s\n", BehBus->NAME ); + } + + SetBoomBehAuxKeep( BehBus ); + + if ( BoomBddSetExprKeepAux( BiAbl->CNDABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehBus ); + } + + break; + } + } + else + { + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + } + + BiNode = BiNode->NEXT; + } + } + + for ( BehBux = BehFigure->BEBUX; + ( BehBux != (bebux_list *)0 ) && ( ! Retry ); + BehBux = BehBux->NEXT ) + { + BiNode = BehBux->BINODE; + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) decbddrefext( BiNode->VALNODE ); + if ( BiNode->CNDNODE != (void *)0 ) decbddrefext( BiNode->CNDNODE ); + + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + + if ( ! IsBoomBehAuxDontTouch( BehBux ) ) + { + BiNode->VALNODE = (void *)BoomAbl2BddNode( BehBux->NAME, BiAbl->VALABL ); + + if ( BiNode->VALNODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehBux->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehBux ) ) + { + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch bus signal %s\n", BehBux->NAME ); + } + + SetBoomBehAuxDontTouch( BehBux ); + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep bux signal %s\n", BehBux->NAME ); + } + + SetBoomBehAuxKeep( BehBux ); + + if ( BoomBddSetExprKeepAux( BiAbl->VALABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehBux ); + } + + break; + } + + BiNode->CNDNODE = (void *)BoomAbl2BddNode( (char *)0, BiAbl->CNDABL ); + + if ( BiNode->CNDNODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehBux->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehBux ) ) + { + SetBoomBehAuxDontTouch( BehBux ); + + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch bus signal %s\n", BehBux->NAME ); + } + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep bus signal %s\n", BehBux->NAME ); + } + + SetBoomBehAuxKeep( BehBux ); + + if ( BoomBddSetExprKeepAux( BiAbl->CNDABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehBux ); + } + + break; + } + } + else + { + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + } + + BiNode = BiNode->NEXT; + } + } + + for ( BehReg = BehFigure->BEREG; + ( BehReg != (bereg_list *)0 ) && ( ! Retry ); + BehReg = BehReg->NEXT ) + { + BiNode = BehReg->BINODE; + + for ( BiAbl = BehReg->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) decbddrefext( BiNode->VALNODE ); + if ( BiNode->CNDNODE != (void *)0 ) decbddrefext( BiNode->CNDNODE ); + + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + + if ( ! IsBoomBehAuxDontTouch( BehReg ) ) + { + BiNode->VALNODE = (void *)BoomAbl2BddNode( BehReg->NAME, BiAbl->VALABL ); + + if ( BiNode->VALNODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehReg->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehReg ) ) + { + SetBoomBehAuxDontTouch( BehReg ); + + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch register signal %s\n", BehReg->NAME ); + } + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep register signal %s\n", BehReg->NAME ); + } + + SetBoomBehAuxKeep( BehReg ); + + if ( BoomBddSetExprKeepAux( BiAbl->VALABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehReg ); + } + + break; + } + + BiNode->CNDNODE = (void *)BoomAbl2BddNode( (char *)0, BiAbl->CNDABL ); + + if ( BiNode->CNDNODE == (void *)0 ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehReg->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehReg ) ) + { + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch register signal %s\n", BehReg->NAME ); + } + + SetBoomBehAuxDontTouch( BehReg ); + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep register signal %s\n", BehReg->NAME ); + } + + SetBoomBehAuxKeep( BehReg ); + + if ( BoomBddSetExprKeepAux( BiAbl->CNDABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehReg ); + } + + break; + } + } + else + { + BiNode->VALNODE = (void *)0; + BiNode->CNDNODE = (void *)0; + } + + BiNode = BiNode->NEXT; + } + } + + for ( BehOut = BehFigure->BEOUT; + ( BehOut != (beout_list *)0 ) && ( ! Retry ); + BehOut = BehOut->NEXT ) + { + if ( BehOut->NODE != (void *)0 ) decbddrefext( BehOut->NODE ); + + if ( ! IsBoomBehAuxDontTouch( BehOut ) ) + { + BehOut->NODE = (void *)BoomAbl2BddNode( BehOut->NAME, BehOut->ABL ); + + if ( BehOut->NODE == (void *)0 ) + { +/* +** Explosion ! +*/ + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Explosion while building %s\n", BehOut->NAME ); + } + + Retry = 1; + + if ( IsBoomBehAuxKeep( BehOut ) ) + { + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Don't touch output signal %s\n", BehOut->NAME ); + } + + SetBoomBehAuxDontTouch( BehOut ); + } + else + if ( FigInfo->TRACE ) + { + fprintf( stdout, "\t Keep output signal %s\n", BehOut->NAME ); + } + + SetBoomBehAuxKeep( BehOut ); + + if ( BoomBddSetExprKeepAux( BehOut->ABL ) == 0 ) + { + SetBoomBehAuxDontTouch( BehOut ); + } + } + } + else + { + BehOut->NODE = (void *)0; + } + } + } + + resetauthtable( BoomBddHashAux ); + resetauthtable( BoomBddHashKeepAux ); + + reorderbddsystemwindow( (bddsystem *)0 ); + + explosionbddsystemdynamic( (bddsystem *)0, NULL, 0 ); +} + +/*------------------------------------------------------------\ +| | +| Beh Delete Useless Aux | +| | +\------------------------------------------------------------*/ + +static void BoomBddReplaceKeepAuxAbl( Expr ) + + ablexpr *Expr; +{ + authelem *Element; + char *Value; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + + if ( ( Value != ABL_ATOM_NAME_ONE ) && + ( Value != ABL_ATOM_NAME_ZERO ) && + ( Value != ABL_ATOM_NAME_DC ) && + ( Value != ABL_ATOM_NAME_TRISTATE ) ) + { + Element = searchauthelem( BoomBddHashRenameAux, Value ); + + if ( Element != (authelem *)0 ) + { + ABL_ATOM_VALUE( Expr ) = (char *)Element->VALUE; + } + } + } + else + { + while ( ( Expr = ABL_CDR( Expr ) ) != (chain_list *)0 ) + { + BoomBddReplaceKeepAuxAbl( ABL_CAR( Expr ) ); + } + } +} + +/*------------------------------------------------------------\ +| | +| Beh Delete Useless Keep Aux | +| | +\------------------------------------------------------------*/ + +static void BoomBehDeleteDuplicateKeepAux( BehFigure, OrderFlag, DontCareFlag ) + + befig_list *BehFigure; + int OrderFlag; + int DontCareFlag; +{ + beaux_list *BehAux; + beaux_list *BehAuxDup; + beaux_list **PrevAux; + beaux_list *BehAuxDel; + authelem *Element; + int Found; + + if ( BoomBddHashAux == (authtable *)0 ) + { + BoomBddHashAux = createauthtable( 100 ); + BoomBddHashKeepAux = createauthtable( 100 ); + BoomBddHashRenameAux = createauthtable( 100 ); + } +/* +** Should identify duplicate/useless auxiliar variables +*/ + Found = 0; + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( ( BehAux->NODE == NULL ) || + ( ! IsBoomBehAuxKeep( BehAux ) ) ) continue; + + Element = searchauthelem( BoomBddHashAux, (char *)BehAux->NODE ); + + if ( Element == (authelem *)0 ) + { + addauthelem( BoomBddHashAux, (char *)BehAux->NODE, (long)BehAux ); + } + else + { + BehAuxDup = (beaux_list *)Element->VALUE; + addauthelem( BoomBddHashRenameAux, BehAux->NAME, (long)BehAuxDup->NAME ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Should replace %s by %s\n", BehAux->NAME, BehAuxDup->NAME ); + } + + SetBoomBehAuxTag( BehAux ); + + Found = 1; + } + } + + if ( Found ) + { + BoomBehScanAbl( BehFigure, BoomBddReplaceKeepAuxAbl, 1 ); + + PrevAux = &BehFigure->BEAUX; + BehAux = BehFigure->BEAUX; + + while ( BehAux != (beaux_list *)0 ) + { + if ( IsBoomBehAuxTag( BehAux ) ) + { + *PrevAux = BehAux->NEXT; + BehAuxDel = BehAux; + BehAux = BehAux->NEXT; + + BehFigure->BERIN = beh_rmvberin( BehFigure->BERIN, BehAuxDel->NAME ); + + BehAuxDel->NEXT = (beaux_list *)0; + BoomBehFreeBehAux( BehAuxDel ); + } + else + { + PrevAux = &BehAux->NEXT; + BehAux = BehAux->NEXT; + } + } + + BoomBehResetBddNode( BehFigure ); + + resetbddcircuit( (bddcircuit *)0 ); + resetbddsystem( (bddsystem *)0 ); + + if ( ! BoomDebugFlag ) + { + SetBddSystemNoWarning( BddLocalSystem ); + } + + BoomBehMakeBddOrder( BehFigure, OrderFlag, DontCareFlag ); + + BoomBehMakeBddNode( BehFigure, 0 ); + } + + resetauthtable( BoomBddHashAux ); + resetauthtable( BoomBddHashRenameAux ); +} + +/*------------------------------------------------------------\ +| | +| Beh Make Bdd | +| | +\------------------------------------------------------------*/ + +void BoomBehAbl2BddNode( BehFigure, OrderFlag, DontCareFlag ) + + befig_list *BehFigure; + int OrderFlag; + int DontCareFlag; +{ + berin_list *BehRin; + beaux_list *BehAux; + beaux_list *DelAux; + beaux_list **PrevAux; + beout_list *BehOut; + bebus_list *BehBus; + + long NumberIn = 1; + long NumberOut = 1; + + if ( BehFigure->BEDLY == (beaux_list *)0 ) + { + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( ! IsBoomBehAuxKeep( BehAux ) ) + { + BehFigure->BERIN = beh_rmvberin( BehFigure->BERIN, BehAux->NAME ); + NumberOut++; + } + else + { + NumberIn++; + } + } + } + else + { + BoomError( BOOM_SIMPLIFY_ERROR, (char *)0 ); + } + + for ( BehRin = BehFigure->BERIN; + BehRin != (berin_list *)0; + BehRin = BehRin->NEXT ) + { + NumberIn++; + } + + if ( DontCareFlag ) NumberIn++; + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + NumberOut++; + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + NumberOut++; + } + + BehFigure->CIRCUI = + + (void *)createbddcircuit( BehFigure->NAME, NumberIn, NumberOut, (bddsystem *)0 ); + + BoomBehMakeBddOrder( BehFigure, OrderFlag, DontCareFlag ); + + BoomBehMakeBddNodeNoExplosion( BehFigure, 0 ); + + BoomBehDeleteDuplicateKeepAux( BehFigure, OrderFlag, DontCareFlag ); + + PrevAux = &BehFigure->BEAUX; + BehAux = BehFigure->BEAUX; + + while ( BehAux != (beaux_list *)0 ) + { + if ( ! IsBoomBehAuxKeep( BehAux ) ) + { + decbddrefext( BehAux->NODE ); + delbddcircuitout( (bddcircuit *)0, BehAux->NAME ); + + *PrevAux = BehAux->NEXT; + DelAux = BehAux; + BehAux = BehAux->NEXT; + + DelAux->NEXT = (beaux_list *)0; + BoomBehFreeBehAux( DelAux ); + } + else + { + PrevAux = &BehAux->NEXT; + BehAux = BehAux->NEXT; + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomUnmarkBddNode | +| | +\------------------------------------------------------------*/ + +chain_list *BoomUnmarkBddNode( Expr ) + + chain_list *Expr; +{ + chain_list *ScanExpr; + bddnode *BddNode; + + if ( ! ABL_ATOM( Expr ) ) + { + BddNode = (bddnode *)ABL_CDR( ABL_CAR( Expr ) ); + + if ( BddNode != (bddnode *)0 ) + { + if ( BddNode->MARK > 0 ) + { + BddNode->MARK = 0; decbddrefext( BddNode ); + } + + ABL_CDR( ABL_CAR( Expr ) ) = (chain_list *)0; + } + + ScanExpr = Expr; + + while( ( ScanExpr = ABL_CDR( ScanExpr ) ) != (chain_list *)0 ) + { + BoomUnmarkBddNode( ABL_CAR( ScanExpr ) ); + } + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehUnmarkBddNode | +| | +\------------------------------------------------------------*/ + +void BoomBehUnmarkBddNode( BehFigure ) + + befig_list *BehFigure; +{ + BoomBehMapAbl( BehFigure, BoomUnmarkBddNode, 0 ); +} + +/*------------------------------------------------------------\ +| | +| Boom Beh Reset Bdd Node | +| | +\------------------------------------------------------------*/ + +void BoomBehResetBddNode( BehFigure ) + + befig_list *BehFigure; +{ + bddcircuit *BddCircuit; + bddsystem *BddSystem; + beaux_list *BehAux; + beout_list *BehOut; + bebus_list *BehBus; + bebux_list *BehBux; + bereg_list *BehReg; + binode_list *BiNode; + + BddCircuit = BehFigure->CIRCUI; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( BehAux->NODE != (void *)0 ) + { + decbddrefext( BehAux->NODE ); + delbddcircuitout( (bddcircuit *)0, BehAux->NAME ); + } + + BehAux->NODE = (void *)0; + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( BehOut->NODE != (void *)0 ) + { + decbddrefext( BehOut->NODE ); + delbddcircuitout( (bddcircuit *)0, BehOut->NAME ); + } + + BehOut->NODE = (void *)0; + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + delbddcircuitout( (bddcircuit *)0, BehBus->NAME ); + + for ( BiNode = BehBus->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) + { + decbddrefext( BiNode->VALNODE ); + BiNode->VALNODE = (void *)0; + } + + if ( BiNode->CNDNODE != (void *)0 ) + { + decbddrefext( BiNode->CNDNODE ); + BiNode->CNDNODE = (void *)0; + } + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + delbddcircuitout( (bddcircuit *)0, BehBux->NAME ); + + for ( BiNode = BehBux->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) + { + decbddrefext( BiNode->VALNODE ); + BiNode->VALNODE = (void *)0; + } + + if ( BiNode->CNDNODE != (void *)0 ) + { + decbddrefext( BiNode->CNDNODE ); + BiNode->CNDNODE = (void *)0; + } + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + delbddcircuitout( (bddcircuit *)0, BehReg->NAME ); + + for ( BiNode = BehReg->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != (void *)0 ) + { + decbddrefext( BiNode->VALNODE ); + BiNode->VALNODE = (void *)0; + } + + if ( BiNode->CNDNODE != (void *)0 ) + { + decbddrefext( BiNode->CNDNODE ); + BiNode->CNDNODE = (void *)0; + } + } + } + + garbagebddsystem( (bddsystem *)0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehMapBdd | +| | +\------------------------------------------------------------*/ + +void BoomBehMapBdd( BehFigure, Function ) + + befig_list *BehFigure; + bddnode *(*Function)(); +{ + bddcircuit *BddCircuit; + bddsystem *BddSystem; + beaux_list *BehAux; + beout_list *BehOut; + bebus_list *BehBus; + bebux_list *BehBux; + bereg_list *BehReg; + binode_list *BiNode; + + BddCircuit = BehFigure->CIRCUI; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( BehAux->NODE != NULL ) + { + BehAux->NODE = Function( BehAux->NODE ); + addbddcircuitout( (bddcircuit *)0, BehAux->NAME, BehAux->NODE ); + } + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( BehOut->NODE != NULL ) + { + BehOut->NODE = Function( BehOut->NODE ); + addbddcircuitout( (bddcircuit *)0, BehOut->NAME, BehOut->NODE ); + } + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + for ( BiNode = BehBus->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != NULL ) + { + BiNode->VALNODE = Function( BiNode->VALNODE ); + addbddcircuitout( (bddcircuit *)0, BehBus->NAME, BiNode->VALNODE ); + } + + if ( BiNode->CNDNODE != NULL ) + { + BiNode->CNDNODE = Function( BiNode->CNDNODE ); + } + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + for ( BiNode = BehBux->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != NULL ) + { + BiNode->VALNODE = Function( BiNode->VALNODE ); + addbddcircuitout( (bddcircuit *)0, BehBux->NAME, BiNode->VALNODE ); + } + + if ( BiNode->CNDNODE != NULL ) + { + BiNode->CNDNODE = Function( BiNode->CNDNODE ); + } + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + for ( BiNode = BehReg->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != NULL ) + { + BiNode->VALNODE = Function( BiNode->VALNODE ); + addbddcircuitout( (bddcircuit *)0, BehReg->NAME, BiNode->VALNODE ); + } + + if ( BiNode->CNDNODE != NULL ) + { + BiNode->CNDNODE = Function( BiNode->CNDNODE ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehScanBdd | +| | +\------------------------------------------------------------*/ + +void BoomBehScanBdd( BehFigure, Function ) + + befig_list *BehFigure; + void (*Function)(); +{ + bddcircuit *BddCircuit; + bddsystem *BddSystem; + beaux_list *BehAux; + beout_list *BehOut; + bebus_list *BehBus; + bebux_list *BehBux; + bereg_list *BehReg; + binode_list *BiNode; + + BddCircuit = BehFigure->CIRCUI; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( BehAux->NODE != NULL ) Function( BehAux->NODE ); + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + if ( BehOut->NODE != NULL ) Function( BehOut->NODE ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + for ( BiNode = BehBus->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != NULL ) Function( BiNode->VALNODE ); + if ( BiNode->CNDNODE != NULL ) Function( BiNode->CNDNODE ); + } + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + for ( BiNode = BehBux->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != NULL ) Function( BiNode->VALNODE ); + if ( BiNode->CNDNODE != NULL ) Function( BiNode->CNDNODE ); + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + for ( BiNode = BehReg->BINODE; + BiNode != (binode_list *)0; + BiNode = BiNode->NEXT ) + { + if ( BiNode->VALNODE != NULL ) Function( BiNode->VALNODE ); + if ( BiNode->CNDNODE != NULL ) Function( BiNode->CNDNODE ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomGetNumberBddNode | +| | +\------------------------------------------------------------*/ + +static void BoomGetNumberBigBddNode( BddNode ) + + bddnode *BddNode; +{ + long Number; + + Number = getbddnodenum( (bddsystem *)0, BddNode ); + + if ( Number >= BOOM_BDD_NODE_BIG_SIZE ) BoomBddNumberNode += Number; +} + +/*------------------------------------------------------------\ +| | +| BoomBehGetNumberBddNode | +| | +\------------------------------------------------------------*/ + +long BoomBehGetNumberBigBddNode( BehFigure ) + + befig_list *BehFigure; +{ + BoomBddNumberNode = 0; + + BoomBehScanBdd( BehFigure, BoomGetNumberBigBddNode ); + + return( BoomBddNumberNode ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehGetBddOrder | +| | +\------------------------------------------------------------*/ + +chain_list *BoomBehGetBddOrder( BehFigure ) + + befig_list *BehFigure; +{ + chain_list *OrderList; + long BddVar; + long NumberVar; + long BddIndex; + char *Name; + + NumberVar = BddLocalSystem->NUMBER_VAR; + OrderList = (chain_list *)0; + + for ( BddVar = NumberVar - 1; BddVar >= 0; BddVar-- ) + { + BddIndex = getbddvarindex( (bddsystem *)0, BddVar ); + Name = getbddcircuitinname( (bddcircuit *)0, BddIndex ); + + OrderList = addchain( OrderList, (void *)Name ); + } + + return( OrderList ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehRebuildBddNode | +| | +\------------------------------------------------------------*/ + +void BoomBehRebuildBddNode( BehFigure, OrderList ) + + befig_list *BehFigure; + chain_list *OrderList; +{ + chain_list *ScanList; + + BoomBehResetBddNode( BehFigure ); + + resetbddcircuit( (bddcircuit *)0 ); + resetbddsystem( (bddsystem *)0 ); + + if ( ! BoomDebugFlag ) + { + SetBddSystemNoWarning( BddLocalSystem ); + } + + for ( ScanList = OrderList; + ScanList != (chain_list *)0; + ScanList = ScanList->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, (char *)ScanList->DATA, 0, BDD_IN_MODE_LAST ); + } + + BoomBehMakeBddNode( BehFigure, 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehRandomBddOrder | +| | +\------------------------------------------------------------*/ + +void BoomBehRandomBddOrder( BehFigure, Amplitude ) + + befig_list *BehFigure; + long Amplitude; +{ + boombefiginfo *FigInfo; + long NumberVar; + long MaxNode; + long BddVar; + long BddSwapVar; + unsigned long MoveTo; + unsigned long MoveIndex; + + static unsigned char InitRandom = 1; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + if ( InitRandom ) + { + srand( getpid() ); + InitRandom = 0; + } + + if ( Amplitude <= 0 ) return; + + NumberVar = BddLocalSystem->NUMBER_VAR; + + for ( BddVar = 0; BddVar < NumberVar; BddVar++ ) + { + MoveTo = (rand() >> 8) % Amplitude; + + if ( IsBoomDebugLevel2() ) + { + BoomPrintf( stdout, "Move %ld amplitude %ld\n", BddVar, MoveTo ); + } + + MaxNode = BddLocalSystem->NUMBER_NODE + BOOM_BDD_SWAP_LIMIT; + + for ( MoveIndex = 0; MoveIndex < MoveTo; MoveIndex++ ) + { + BddSwapVar = BddVar - MoveIndex; + + if ( ( BddSwapVar >= ( NumberVar - 1 ) ) || + ( BddSwapVar <= 0 ) ) break; + + if ( IsBoomDebugLevel2() ) + { + BoomPrintf( stdout, "> Swap %ld with %ld\n", BddSwapVar, BddSwapVar - 1 ); + } + + swapbddvar( (bddsystem *)0, BddSwapVar ); + + if ( BddLocalSystem->NUMBER_NODE > MaxNode ) + { + garbagebddsystem( (bddsystem *)0 ); + } + + if ( BddLocalSystem->NUMBER_NODE > MaxNode ) + { + break; + } + } + } +} diff --git a/alliance/src/boom/src/boom_bdd.h b/alliance/src/boom/src/boom_bdd.h new file mode 100644 index 00000000..94d26f6b --- /dev/null +++ b/alliance/src/boom/src/boom_bdd.h @@ -0,0 +1,109 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_bdd.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_BDD_H +# define BOOM_BDD_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_BDD_NODE_BIG_SIZE 8 +# define BOOM_BDD_EXPLOSION_LIMIT 200000 +# define BOOM_BDD_SWAP_LIMIT 10000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +/* +# define BoomSetBddMarkAbl( E, N ) \ + \ + do { ABL_CDR( ABL_CAR( E ) ) = (chain_list *)(N); \ + if ( (N)->MARK == 0 ) (N)->MARK = 1; \ + else (N)->MARK = 2; \ + incbddrefext( (N) ); \ + } while (0) +*/ + +# define BoomSetBddMarkAbl( E, N ) \ + \ + do { ABL_CDR( ABL_CAR( E ) ) = (chain_list *)(N); \ + if ( (N)->MARK == 0 ) incbddrefext( (N) ); \ + (N)->MARK++; \ + } while (0) + +# define BoomGetBddMarkAbl( E ) \ + \ + ( (bddnode *)( ABL_CDR( ABL_CAR( E ) ) ) ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Varibddes | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehAbl2BddNode(); + extern void BoomBehMakeBddNode(); + extern void BoomBehResetBddNode(); + extern void BoomBehUnmarkBddNode(); + extern void BoomBehScanBdd(); + extern void BoomBehMapBdd(); + extern long BoomBehGetNumberBigBddNode(); + + extern chain_list *BoomUnmarkBddNode(); + extern chain_list *BoomBehGetBddOrder(); + extern void BoomBehRandomBddOrder(); + extern void BoomBehRebuildBddNode(); + +# endif diff --git a/alliance/src/boom/src/boom_burgun.c b/alliance/src/boom/src/boom_burgun.c new file mode 100644 index 00000000..278584f1 --- /dev/null +++ b/alliance/src/boom/src/boom_burgun.c @@ -0,0 +1,442 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_burgun.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 08.08.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_burgun.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static bddnode *BoomBddTopVarNode = (bddnode *)0; + static long BoomCurrentVar = (long )0; + static long BoomBurgunVar = (long )0; + static long BoomCurrentCost = 0; + + static int BoomExplosionFlag = 0; + + static char *BoomIndexArray = (char *)0; + static long BoomIndexArraySize = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBurgunTopBurgunVar | +| | +\------------------------------------------------------------*/ + +static bddnode *BoomBurgunTopBurgunVar( BddNode ) + + bddnode *BddNode; +{ + bddnode *NewBddNode; + + NewBddNode = composebddnode( BddLocalSystem, BddNode, + BoomBurgunVar , BoomBddTopVarNode ); + + return( NewBddNode ); +} + +/*------------------------------------------------------------\ +| | +| BoomBurgunTopBddNode | +| | +\------------------------------------------------------------*/ + +static void BoomBurgunTopBddNode( BddNode ) + + bddnode *BddNode; +{ + bddnode *NewBddNode; + long Number; + + if ( ! BoomExplosionFlag ) + { + Number = getbddnodenum( (bddsystem *)0, BddNode ); + + if ( Number < BOOM_BDD_NODE_BIG_SIZE ) return; + + NewBddNode = composebddnode( BddLocalSystem, BddNode, + BoomCurrentVar, BoomBddTopVarNode ); + + if ( IsBddSystemExplosion( BddLocalSystem ) ) + { + BoomPrintf( stdout, "Explosion !!! %ld\n", BddLocalSystem->NUMBER_NODE ); + + garbagebddsystem( BddLocalSystem ); + explosionbddsystemrestart( BddLocalSystem ); + + BoomExplosionFlag = 1; + } + else + { + BoomCurrentCost += getbddnodenum( (bddsystem *)0, NewBddNode ); + /* + Number = getbddnodenum( (bddsystem *)0, NewBddNode ); + + if ( Number >= BOOM_BDD_NODE_BIG_SIZE ) BoomCurrentCost += Number; + */ + + decbddrefext( NewBddNode ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehBurgunBddOrder | +| | +\------------------------------------------------------------*/ + +chain_list *BoomBehBurgunBddOrder( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + chain_list *OrderList; + long NumberIndex; + long NumberVar; + long VarIndex; + long TopVar; + long FirstVar; + long LastVar; + long ExplosionLimit; + long MaxNode; + long BurgunCost; + char *Name; + char Buffer[ 32 ]; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + NumberIndex = BddLocalSystem->NUMBER_INDEX; + NumberVar = BddLocalSystem->NUMBER_VAR; + + if ( BoomIndexArray == (char *)0 ) + { + BoomIndexArray = (char *)autallocblock( sizeof( char ) * NumberIndex ); + BoomIndexArraySize = NumberIndex; + } + else + if ( NumberIndex > BoomIndexArraySize ) + { + BoomIndexArray = (char *)autresizeblock( (char *)BoomIndexArray, + sizeof( long ) * BoomIndexArraySize, + sizeof( long ) * NumberIndex ); + BoomIndexArraySize = NumberIndex; + } + + memset( BoomIndexArray, 0, BoomIndexArraySize ); + + OrderList = (chain_list *)0; + + for ( TopVar = 0; TopVar < NumberVar; TopVar++ ) + { + VarIndex = getbddvarindex( BddLocalSystem, TopVar ); + sprintf( Buffer, "_top_%ld", TopVar ); + BoomBddTopVarNode = addbddcircuitin( BddLocalCircuit, Buffer, + VarIndex, BDD_IN_MODE_BEFORE ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "TopVar %ld %s\n", TopVar, Buffer ); + } + + MaxNode = BddLocalSystem->NUMBER_NODE * 2; + FirstVar = TopVar + 1; + LastVar = TopVar + NumberVar; + + BoomBurgunVar = -1; + BurgunCost = 0; + + for ( BoomCurrentVar = FirstVar; BoomCurrentVar <= LastVar; BoomCurrentVar++ ) + { + VarIndex = getbddvarindex( (bddsystem *)0, BoomCurrentVar ); + + if ( BoomIndexArray[ VarIndex ] != 0 ) continue; + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Sweep !\n" ); + } + + sweepbddvar( BddLocalSystem, TopVar, 1 ); + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Garbage !\n" ); + } + + garbagebddsystem( BddLocalSystem ); + MaxNode = BddLocalSystem->NUMBER_NODE * 4; + } + } + + ExplosionLimit = BddLocalSystem->NUMBER_NODE * 2; + + if ( ExplosionLimit < BOOM_BURGUN_EXPLOSION_LIMIT ) + { + ExplosionLimit = BOOM_BURGUN_EXPLOSION_LIMIT; + } + + BoomExplosionFlag = 0; + + explosionbddsystemdynamic( (bddsystem *)0, NULL, ExplosionLimit ); + + BoomCurrentCost = 0; + + BoomBehScanBdd( BehFigure, BoomBurgunTopBddNode ); + + if ( ! BoomExplosionFlag ) + { + if ( ( BoomBurgunVar == -1 ) || + ( BoomCurrentCost < BurgunCost ) ) + { + BoomBurgunVar = BoomCurrentVar; + BurgunCost = BoomCurrentCost; + } + } + else + { + BoomExplosionFlag = 0; + } + + if ( IsBoomDebugLevel1() ) + { + Name = getbddcircuitinname( (bddcircuit *)0, VarIndex ); + BoomPrintf( stdout, "%ld %ld %s\n", BoomCurrentVar, BoomCurrentCost, Name ); + } + } + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "BurgunCost %ld BoomBurgunVar %ld\n", BurgunCost, BoomBurgunVar ); + } + + explosionbddsystemdynamic( (bddsystem *)0, NULL, 0 ); + + VarIndex = getbddvarindex( (bddsystem *)0, BoomBurgunVar ); + Name = getbddcircuitinname( (bddcircuit *)0, VarIndex ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Var %s\n", Name ); + } + + OrderList = addchain( OrderList, (void *)Name ); + + BoomIndexArray[ VarIndex ] = 1; + + BoomBehMapBdd( BehFigure, BoomBurgunTopBurgunVar ); + } + + OrderList = reverse( OrderList ); + + BoomBehRebuildBddNode( BehFigure, OrderList ); + + return( OrderList ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeBurgun | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeBurgun( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + long Cost; + long NewCost; + long Iteration; + long Amplitude; + long MaxIteration; + long MaxAmplitude; + chain_list *BurgunOrder; + chain_list *NewOrder; + int Level; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + MaxAmplitude = FigInfo->AMPLITUDE; + Level = FigInfo->OPTIM_LEVEL; + + if ( MaxIteration <= 0 ) MaxIteration = 2; + if ( MaxAmplitude <= 0 ) MaxAmplitude = 5; + + MaxIteration = MaxIteration * (Level + 1); + MaxAmplitude = MaxAmplitude + Level; + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + BurgunOrder = BoomBehGetBddOrder( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Iteration %ld\n", Iteration ); + } + + Amplitude = MaxAmplitude + 1; + + do + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Amplitude %ld\n", Amplitude ); + } + + if ( Amplitude <= MaxAmplitude ) + { + BoomBehRandomBddOrder( BehFigure, Amplitude ); + } + + NewOrder = BoomBehBurgunBddOrder( BehFigure ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + + freechain( BurgunOrder ); + BurgunOrder = NewOrder; + } + else + { + freechain( NewOrder ); + } + + Amplitude--; + } + while ( Amplitude >= 0 ); + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3ld\b\b\b", ( ( Iteration + 1 ) * 100 ) / MaxIteration ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Burgun cost : %ld\n", Cost ); + } + + BoomBehRebuildBddNode( BehFigure, BurgunOrder ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} diff --git a/alliance/src/boom/src/boom_burgun.h b/alliance/src/boom/src/boom_burgun.h new file mode 100644 index 00000000..214436ab --- /dev/null +++ b/alliance/src/boom/src/boom_burgun.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU 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 : BOOM | +| | +| File : boom_burgun.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_BURGUN_H +# define BOOM_BURGUN_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_BURGUN_EXPLOSION_LIMIT 10000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeBurgun(); + extern chain_list *BoomBehBurgunBddOrder(); + +# endif diff --git a/alliance/src/boom/src/boom_check.c b/alliance/src/boom/src/boom_check.c new file mode 100644 index 00000000..4e74eb38 --- /dev/null +++ b/alliance/src/boom/src/boom_check.c @@ -0,0 +1,132 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_check.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_check.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_abl.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + +static int BoomFoundDontCare = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomCheckBehAblDontCare | +| | +\------------------------------------------------------------*/ + +static void BoomCheckBehAblDontCare( Expr ) + + ablexpr *Expr; +{ + if ( Expr != (ablexpr *)0 ) + { + if ( ! BoomFoundDontCare ) + { + BoomFoundDontCare = isablnameinexpr( Expr, ABL_ATOM_NAME_DC ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomCheckBehFigure | +| | +\------------------------------------------------------------*/ + +void BoomCheckBehFigure( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomFoundDontCare = 0; + + BoomBehScanAbl( BehFigure, BoomCheckBehAblDontCare, 1 ) ; + + FigInfo->DONT_CARE = BoomFoundDontCare; + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Dont care %d\n", BoomFoundDontCare ); + } + + + /* Check combinatory loop etc ... */ + /* TO BE DONE */ +} diff --git a/alliance/src/boom/src/boom_check.h b/alliance/src/boom/src/boom_check.h new file mode 100644 index 00000000..423ed916 --- /dev/null +++ b/alliance/src/boom/src/boom_check.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 : BOOM | +| | +| File : boom_check.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_CHECK_H +# define BOOM_CHECK_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomCheckBehFigure(); + +# endif diff --git a/alliance/src/boom/src/boom_cost.c b/alliance/src/boom/src/boom_cost.c new file mode 100644 index 00000000..063b3f99 --- /dev/null +++ b/alliance/src/boom/src/boom_cost.c @@ -0,0 +1,848 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_cost.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_cost.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static long BoomOperSurfaceCost[ ABL_MAX_OPERATOR ][ 3 ] = + { + { 1250, 1500, 1750 }, /* ABL_OR */ + { 1250, 1500, 1750 }, /* ABL_AND */ + { 2250, 4500, 6750 }, /* ABL_XOR */ + { 750, 0, 0 }, /* ABL_NOT */ + { 1000, 1250, 1500 }, /* ABL_NOR */ + { 1000, 1250, 1500 }, /* ABL_NAND */ + { 2250, 4500, 6750 }, /* ABL_NXOR */ + { 0, 0, 0 } /* ABL_STABLE */ + }; + + static int BoomFlagDepth = 0; + static int BoomFlagSurface = 0; + + static authtable *BoomHashAux = (authtable *)0; + static authtable *BoomHashBux = (authtable *)0; + static authtable *BoomHashBus = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomGiveAblSurfaceCost | +| | +\------------------------------------------------------------*/ + +static long LocalBoomGiveAblSurfaceCost( Expr ) + + ablexpr *Expr; +{ + long Oper; + long Cost; + long NumOper; + long NextStep; + + if ( ABL_ATOM( Expr ) ) + { + return( 0 ); + } + + Oper = ABL_OPER( Expr ); + Cost = 0; + NumOper = 0; + + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + Cost += LocalBoomGiveAblSurfaceCost( ABL_CAR( Expr ) ); + + NumOper++; + } + + while ( NumOper ) + { + NextStep = NumOper / 4; + + if ( NextStep ) + { + Cost += NextStep * BoomOperSurfaceCost[ Oper ][ BOOM_OPER_ARITY_4 ]; + } + + NumOper %= 4; + + if ( NumOper == 3 ) + { + if ( NextStep >= 1 ) NextStep += 3; + else Cost += BoomOperSurfaceCost[ Oper ][ BOOM_OPER_ARITY_3 ]; + } + else + if ( NumOper == 2 ) + { + if ( ( NextStep <= 2 ) && + ( NextStep != 0 ) ) + { + NextStep += 2; + } + else + { + Cost += BoomOperSurfaceCost[ Oper ][ BOOM_OPER_ARITY_2 ]; + } + } + else + if ( NumOper == 1 ) + { + if ( Oper == ABL_NOT ) + { + Cost += BoomOperSurfaceCost[ Oper ][ BOOM_OPER_ARITY_1 ]; + } + else + if ( NextStep != 0 ) NextStep++; + } + + NumOper = NextStep; + NextStep = 0; + } + + return( Cost ); +} + +static long BoomGiveAblSurfaceCost( Expr ) + + ablexpr *Expr; +{ + long Cost; + + if ( ! BoomFlagSurface ) + { + return( 0 ); + } + + Cost = LocalBoomGiveAblSurfaceCost( Expr ); + + if ( IsBoomDebugLevel2() ) + { + fprintf( stdout, "BoomGiveAblSurfaceCost\n" ); + viewablexprln( Expr, ABL_VIEW_VHDL ); + fprintf( stdout, "%ld\n", Cost ); + } + + return( Cost ); +} + + +/*------------------------------------------------------------\ +| | +| BoomGiveAblLiteralCost | +| | +\------------------------------------------------------------*/ + +static long LocalBoomGiveAblLiteralCost( Expr ) + + ablexpr *Expr; +{ + long Oper; + long Cost; + + if ( ABL_ATOM( Expr ) ) + { + return( 1 ); + } + + Cost = 0; + Oper = ABL_OPER( Expr ); + + if ( Oper != ABL_STABLE ) + { + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + Cost += LocalBoomGiveAblLiteralCost( ABL_CAR( Expr ) ); + } + } + + return( Cost ); +} + +long BoomGiveAblLiteralCost( Expr ) + + ablexpr *Expr; +{ + long Cost; + + if ( ABL_ATOM( Expr ) ) + { + Cost = 0; + } + else + { + Cost = LocalBoomGiveAblLiteralCost( Expr ); + } + + if ( IsBoomDebugLevel2() ) + { + fprintf( stdout, "BoomGiveAblLiteralCost\n" ); + viewablexprln( Expr, ABL_VIEW_VHDL ); + fprintf( stdout, "%ld\n", Cost ); + } + + return( Cost ); +} + +/*------------------------------------------------------------\ +| | +| BoomGiveAblDepthCost | +| | +\------------------------------------------------------------*/ + +static long BoomGiveAblDepthCost(); + +static long LocalBoomGiveAblDepthCost( Expr ) + + ablexpr *Expr; +{ + boombeauxinfo *AuxInfo; + boombebuxinfo *BuxInfo; + boombebusinfo *BusInfo; + bebus_list *BehBus; + bebux_list *BehBux; + beaux_list *BehAux; + char *Value; + authelem *Element; + biabl_list *BiAbl; + long Oper; + long Cost; + long Arity; + long NewCost; + + Cost = 0; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + + if ( ( Value != ABL_ATOM_NAME_ONE ) && + ( Value != ABL_ATOM_NAME_ZERO ) && + ( Value != ABL_ATOM_NAME_DC ) && + ( Value != ABL_ATOM_NAME_TRISTATE ) ) + { + Element = searchauthelem( BoomHashAux, Value ); + + if ( Element != (authelem *)0 ) + { + BehAux = (beaux_list *)Element->VALUE; + AuxInfo = GetBoomBehAuxInfo( BehAux ); + + if ( ! IsBoomBehAuxTag( BehAux ) ) + { + SetBoomBehAuxTag( BehAux ); + AuxInfo->DEPTH_COST = BoomGiveAblDepthCost( BehAux->ABL ); + } + + return( AuxInfo->DEPTH_COST ); + } + + Element = searchauthelem( BoomHashBus, Value ); + + if ( Element != (authelem *)0 ) + { + BehBus = (bebus_list *)Element->VALUE; + BusInfo = GetBoomBehBusInfo( BehBus ); + + if ( ! IsBoomBehAuxTag( BehBus ) ) + { + SetBoomBehAuxTag( BehBus ); + + BusInfo->DEPTH_COST = 0; + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->VALABL ); + + if ( NewCost > BusInfo->DEPTH_COST ) + { + BusInfo->DEPTH_COST = NewCost; + } + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->CNDABL ); + + if ( NewCost > BusInfo->DEPTH_COST ) + { + BusInfo->DEPTH_COST = NewCost; + } + } + } + } + + return( BusInfo->DEPTH_COST ); + } + + Element = searchauthelem( BoomHashBux, Value ); + + if ( Element != (authelem *)0 ) + { + BehBux = (bebux_list *)Element->VALUE; + BuxInfo = GetBoomBehBuxInfo( BehBux ); + + if ( ! IsBoomBehAuxTag( BehBux ) ) + { + BuxInfo->DEPTH_COST = 0; + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->VALABL ); + + if ( NewCost > BuxInfo->DEPTH_COST ) + { + BuxInfo->DEPTH_COST = NewCost; + } + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->CNDABL ); + + if ( NewCost > BuxInfo->DEPTH_COST ) + { + BuxInfo->DEPTH_COST = NewCost; + } + } + } + + SetBoomBehAuxTag( BehBux ); + } + + return( BuxInfo->DEPTH_COST ); + } + } + } + else + { + Oper = ABL_OPER( Expr ); + + if ( Oper != ABL_STABLE ) + { + Arity = 0; + + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + Arity++; + + NewCost = LocalBoomGiveAblDepthCost( ABL_CAR( Expr ) ); + + if ( NewCost > Cost ) Cost = NewCost; + } + + if ( Oper != ABL_NOT ) + { + Cost += BoomComputeLog2( Arity ); + } + } + } + + return( Cost ); +} + +static long BoomGiveAblDepthCost( Expr ) + + ablexpr *Expr; +{ + long Cost; + + if ( ! BoomFlagDepth ) + { + return( 0 ); + } + + Cost = LocalBoomGiveAblDepthCost( Expr ); + + if ( IsBoomDebugLevel2() ) + { + fprintf( stdout, "BoomGiveAblDepthCost\n" ); + viewablexprln( Expr, ABL_VIEW_VHDL ); + fprintf( stdout, "%ld\n", Cost ); + } + + return( Cost ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehPrintCost | +| | +\------------------------------------------------------------*/ + +void BoomBehPrintCost( Text, BehFigure ) + + char *Text; + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + fprintf( stdout, "\t--> %s cost\n", Text ); + fprintf( stdout, "\t Surface : %ld\n" , FigInfo->SURFACE_COST ); + fprintf( stdout, "\t Depth : %ld\n" , FigInfo->DEPTH_COST ); + fprintf( stdout, "\t Literals : %ld\n" , FigInfo->LITERAL_COST ); + /* + fprintf( stdout, "\t Delay : %.3f ns\n", FigInfo->DEPTH_COST * 0.200 ); + */ +} + +/*------------------------------------------------------------\ +| | +| BoomBehGiveFullCost | +| | +\------------------------------------------------------------*/ + +long BoomBehGiveFullCost( BehFigure, Quick ) + + befig_list *BehFigure; + int Quick; +{ + boombefiginfo *FigInfo; + beout_list *BehOut; + beaux_list *BehAux; + bereg_list *BehReg; + bebus_list *BehBus; + bebux_list *BehBux; + biabl_list *BiAbl; + boombeauxinfo *AuxInfo; + boombeoutinfo *OutInfo; + boombereginfo *RegInfo; + boombebusinfo *BusInfo; + boombebuxinfo *BuxInfo; + long LiteralCost; + long SurfaceCost; + long DepthCost; + long GlobalCost; + long NewCost; + long PerCent; + char Buffer[ 32 ]; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + if ( BoomHashAux == (authtable *)0 ) + { + BoomHashAux = createauthtable( 100 ); + BoomHashBux = createauthtable( 100 ); + BoomHashBus = createauthtable( 100 ); + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + addauthelem( BoomHashAux, BehAux->NAME, (long)BehAux ); + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + addauthelem( BoomHashBux, BehBux->NAME, (long)BehBux ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + addauthelem( BoomHashBus, BehBus->NAME, (long)BehBus ); + } + + LiteralCost = 0; + SurfaceCost = 0; + DepthCost = 0; + + BoomFlagDepth = 1; + BoomFlagSurface = 1; + + if ( Quick ) + { + if ( FigInfo->OPTIM_DELAY_PERCENT == 0 ) BoomFlagDepth = 0; + if ( FigInfo->USE_LITERAL ) BoomFlagSurface = 0; + + if ( FigInfo->OPTIM_DELAY_PERCENT == 100 ) BoomFlagSurface = 0; + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + AuxInfo = GetBoomBehAuxInfo( BehAux ); + + AuxInfo->LITERAL_COST = BoomGiveAblLiteralCost( BehAux->ABL ); + LiteralCost += AuxInfo->LITERAL_COST; + + AuxInfo->SURFACE_COST = BoomGiveAblSurfaceCost( BehAux->ABL ); + SurfaceCost += AuxInfo->SURFACE_COST; + + if ( ! IsBoomBehAuxTag( BehAux ) ) + { + AuxInfo->DEPTH_COST = BoomGiveAblDepthCost( BehAux->ABL ); + SetBoomBehAuxTag( BehAux ); + } + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + OutInfo = GetBoomBehOutInfo( BehOut ); + + OutInfo->LITERAL_COST = BoomGiveAblLiteralCost( BehOut->ABL ); + LiteralCost += OutInfo->LITERAL_COST; + + OutInfo->SURFACE_COST = BoomGiveAblSurfaceCost( BehOut->ABL ); + SurfaceCost += OutInfo->SURFACE_COST; + + OutInfo->DEPTH_COST = BoomGiveAblDepthCost( BehOut->ABL ); + + if ( OutInfo->DEPTH_COST > DepthCost ) + { + DepthCost = OutInfo->DEPTH_COST; + } + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + BusInfo = GetBoomBehBusInfo( BehBus ); + BusInfo->LITERAL_COST = 0; + BusInfo->SURFACE_COST = 0; + + if ( ! IsBoomBehAuxTag( BehBus ) ) + { + BusInfo->DEPTH_COST = 0; + } + + for ( BiAbl = BehBus->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BusInfo->LITERAL_COST += BoomGiveAblLiteralCost( BiAbl->VALABL ); + BusInfo->SURFACE_COST += BoomGiveAblSurfaceCost( BiAbl->VALABL ); + + if ( ! IsBoomBehAuxTag( BehBus ) ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->VALABL ); + + if ( NewCost > BusInfo->DEPTH_COST ) + { + BusInfo->DEPTH_COST = NewCost; + } + } + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BusInfo->LITERAL_COST += BoomGiveAblLiteralCost( BiAbl->CNDABL ); + BusInfo->SURFACE_COST += BoomGiveAblSurfaceCost( BiAbl->CNDABL ); + + if ( ! IsBoomBehAuxTag( BehBus ) ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->CNDABL ); + + if ( NewCost > BusInfo->DEPTH_COST ) + { + BusInfo->DEPTH_COST = NewCost; + } + } + } + } + + SetBoomBehAuxTag( BehBus ); + + LiteralCost += BusInfo->LITERAL_COST; + SurfaceCost += BusInfo->SURFACE_COST; + + if ( BusInfo->DEPTH_COST > DepthCost ) + { + DepthCost = BusInfo->DEPTH_COST; + } + } + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + BuxInfo = GetBoomBehBuxInfo( BehBux ); + BuxInfo->LITERAL_COST = 0; + BuxInfo->SURFACE_COST = 0; + + if ( ! IsBoomBehAuxTag( BehBux ) ) + { + BuxInfo->DEPTH_COST = 0; + } + + for ( BiAbl = BehBux->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + BuxInfo->LITERAL_COST += BoomGiveAblLiteralCost( BiAbl->VALABL ); + BuxInfo->SURFACE_COST += BoomGiveAblSurfaceCost( BiAbl->VALABL ); + + if ( ! IsBoomBehAuxTag( BehBux ) ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->VALABL ); + + if ( NewCost > BuxInfo->DEPTH_COST ) + { + BuxInfo->DEPTH_COST = NewCost; + } + } + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + BuxInfo->LITERAL_COST += BoomGiveAblLiteralCost( BiAbl->CNDABL ); + BuxInfo->SURFACE_COST += BoomGiveAblSurfaceCost( BiAbl->CNDABL ); + + if ( ! IsBoomBehAuxTag( BehBux ) ) + { + NewCost = BoomGiveAblDepthCost( BiAbl->CNDABL ); + + if ( NewCost > BuxInfo->DEPTH_COST ) + { + BuxInfo->DEPTH_COST = NewCost; + } + } + } + } + + SetBoomBehAuxTag( BehBux ); + + LiteralCost += BuxInfo->LITERAL_COST; + SurfaceCost += BuxInfo->SURFACE_COST; + + if ( BuxInfo->DEPTH_COST > DepthCost ) + { + DepthCost = BuxInfo->DEPTH_COST; + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + RegInfo = GetBoomBehRegInfo( BehReg ); + RegInfo->LITERAL_COST = 0; + RegInfo->SURFACE_COST = 0; + RegInfo->DEPTH_COST = 0; + + for ( BiAbl = BehReg->BIABL; + BiAbl != (biabl_list *)0; + BiAbl = BiAbl->NEXT ) + { + if ( BiAbl->VALABL != (chain_list *)0 ) + { + RegInfo->LITERAL_COST += BoomGiveAblLiteralCost( BiAbl->VALABL ); + RegInfo->SURFACE_COST += BoomGiveAblSurfaceCost( BiAbl->VALABL ); + + NewCost = BoomGiveAblDepthCost( BiAbl->VALABL ); + + if ( NewCost > RegInfo->DEPTH_COST ) + { + RegInfo->DEPTH_COST = NewCost; + } + } + + if ( BiAbl->CNDABL != (chain_list *)0 ) + { + RegInfo->LITERAL_COST += BoomGiveAblLiteralCost( BiAbl->CNDABL ); + RegInfo->SURFACE_COST += BoomGiveAblSurfaceCost( BiAbl->CNDABL ); + + NewCost = BoomGiveAblDepthCost( BiAbl->CNDABL ); + + if ( NewCost > RegInfo->DEPTH_COST ) + { + RegInfo->DEPTH_COST = NewCost; + } + } + } + + LiteralCost += RegInfo->LITERAL_COST; + SurfaceCost += RegInfo->SURFACE_COST; + + if ( RegInfo->DEPTH_COST > DepthCost ) + { + DepthCost = RegInfo->DEPTH_COST; + } + } + + resetauthtable( BoomHashAux ); + resetauthtable( BoomHashBus ); + resetauthtable( BoomHashBux ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + ClearBoomBehAuxTag( BehAux ); + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + ClearBoomBehAuxTag( BehBux ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + ClearBoomBehAuxTag( BehBus ); + } + + if ( IsBoomDebugLevel1() ) + { + if ( FigInfo->USE_LITERAL ) + { + sprintf( Buffer, "%ld", LiteralCost ); + } + else + { + sprintf( Buffer, "%ld", SurfaceCost ); + } + + BoomDebugSaveBehFigure( BehFigure, Buffer ); + } + + FigInfo->LITERAL_COST = LiteralCost; + FigInfo->SURFACE_COST = SurfaceCost; + FigInfo->DEPTH_COST = DepthCost; + + + if ( FigInfo->INITIAL_DEPTH_COST == 0 ) + { + FigInfo->INITIAL_DEPTH_COST = DepthCost + 1; + } + + if ( FigInfo->INITIAL_LITERAL_COST == 0 ) + { + FigInfo->INITIAL_LITERAL_COST = LiteralCost + 1; + } + + if ( FigInfo->INITIAL_SURFACE_COST == 0 ) + { + FigInfo->INITIAL_SURFACE_COST = SurfaceCost + 1; + } + + SurfaceCost = ( (double) SurfaceCost * 1000.0 / (double) FigInfo->INITIAL_SURFACE_COST ); + LiteralCost = ( (double) LiteralCost * 1000.0 / (double) FigInfo->INITIAL_LITERAL_COST ); + DepthCost = ( (double) DepthCost * 1000.0 / (double) FigInfo->INITIAL_DEPTH_COST ); + + PerCent = FigInfo->OPTIM_DELAY_PERCENT; + + if ( FigInfo->USE_LITERAL ) + { + GlobalCost = ( ( LiteralCost * ( 100 - PerCent ) ) + + ( DepthCost * PerCent ) ) / 100; + } + else + { + GlobalCost = ( ( SurfaceCost * ( 100 - PerCent ) ) + + ( DepthCost * PerCent ) ) / 100; + } + + FigInfo->GLOBAL_COST = GlobalCost; + + return( GlobalCost ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehGiveCost | +| | +\------------------------------------------------------------*/ + +long BoomBehGiveCost( BehFigure ) + + befig_list *BehFigure; +{ + return ( BoomBehGiveFullCost( BehFigure, 1 ) ); +} diff --git a/alliance/src/boom/src/boom_cost.h b/alliance/src/boom/src/boom_cost.h new file mode 100644 index 00000000..270c6c8e --- /dev/null +++ b/alliance/src/boom/src/boom_cost.h @@ -0,0 +1,83 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_cost.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_COST_H +# define BOOM_COST_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_OPER_ARITY_1 0 +# define BOOM_OPER_ARITY_2 0 +# define BOOM_OPER_ARITY_3 1 +# define BOOM_OPER_ARITY_4 2 + +# define BOOM_OPER_MAX_ARITY 3 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern long BoomBehGiveCost(); + extern long BoomBehGiveFullCost(); + extern void BoomBehPrintCost(); + + extern long BoomGiveAblLiteralCost(); + +# endif diff --git a/alliance/src/boom/src/boom_dc.c b/alliance/src/boom/src/boom_dc.c new file mode 100644 index 00000000..577f6517 --- /dev/null +++ b/alliance/src/boom/src/boom_dc.c @@ -0,0 +1,235 @@ +/*-----------------------------------------------------------\ +| 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 : BOOM | +| | +| File : boom_dc.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 02.11.01 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +#include MUT_H +#include AUT_H +#include ABL_H +#include BDD_H +#include ABE_H +#include ABV_H +#include ABT_H + +#include +#include +#include + +#include "boom_error.h" +#include "boom_debug.h" +#include "boom_shared.h" +#include "boom_aux.h" +#include "boom_abl.h" +#include "boom_bdd.h" +#include "boom_cost.h" +#include "boom_optim.h" +#include "boom_auxinit.h" +#include "boom_dc.h" + + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static bddnode *BoomBddDontCare = (bddnode *)0; + static int BoomFoundAblDc = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomReplaceDontCareAbl | +| | +\------------------------------------------------------------*/ + +static void BoomReplaceDontCareAbl( Expr ) + + ablexpr *Expr; +{ + if ( ABL_ATOM( Expr ) ) + { + if ( ABL_ATOM_VALUE( Expr ) == ABL_ATOM_NAME_DC ) + { + BoomFoundAblDc = 1; + ABL_ATOM_VALUE( Expr ) = ABL_ATOM_NAME_ZERO; + } + } + + while ( ( Expr = ABL_CDR( Expr ) ) ) + { + BoomReplaceDontCareAbl( ABL_CAR( Expr ) ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomOptimDontCareAbl | +| | +\------------------------------------------------------------*/ + +static ablexpr *BoomOptimDontCareAbl( Expr ) + + ablexpr *Expr; +{ + BoomFoundAblDc = 0; + BoomReplaceDontCareAbl( Expr ); + + if ( BoomFoundAblDc ) + { + Expr = simpablexpr( Expr ); + } + + return( Expr ); +} + +/*------------------------------------------------------------\ +| | +| BoomOptimDontCareBdd | +| | +\------------------------------------------------------------*/ + +static bddnode *BoomOptimDontCareBdd( BddNode ) + + bddnode *BddNode; +{ + bddnode *BddOnSet; + bddnode *BddOffSet; + bddnode *BddDcSet; + bddnode *BddOptim; + bddnode *BddOptimOn; + bddnode *BddOptimOff; + bddvar VarDontCare; + int OnSize; + int OptimSize; + int OptimSizeOn; + int OptimSizeOff; + + VarDontCare = getbddvarbyindex( (bddsystem *)0, BoomBddDontCare->INDEX ); + + BddOnSet = restrictbddnode( (bddsystem *)0, BddNode, VarDontCare, + BddLocalSystem->ZERO ); + + if ( BddOnSet == BddNode ) + { + decbddrefext( BddOnSet ); + + return ( BddNode ); + } + + BddOffSet = applybddnodenot( (bddsystem *)0, BddOnSet ); + + BddDcSet = restrictbddnode( (bddsystem *)0, BddNode, VarDontCare, + BddLocalSystem->ONE ); + BddDcSet = applybddnode( (bddsystem *)0, ABL_AND, decbddrefext( BddDcSet ), BddOffSet ); + + BddOptimOn = simpbddnodedcon( (bddsystem *)0, BddOnSet, BddDcSet ); + BddOptimOff = simpbddnodedcoff( (bddsystem *)0, BddOnSet, BddDcSet ); + + decbddrefext( BddOnSet ); + decbddrefext( BddOffSet ); + decbddrefext( BddDcSet ); + decbddrefext( BddOptimOn ); + decbddrefext( BddOptimOff ); + decbddrefext( BddNode ); + + OnSize = getbddnodenum( (bddsystem *)0, BddOnSet ); + OptimSizeOn = getbddnodenum( (bddsystem *)0, BddOptimOn ); + OptimSizeOff = getbddnodenum( (bddsystem *)0, BddOptimOff ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "OnSize %d, OptimSizeOn %d, OptimSizeOff %d\n", + OnSize, OptimSizeOn, OptimSizeOff ); + } + + if ( OptimSizeOn > OptimSizeOff ) + { + BddOptim = BddOptimOff; + OptimSize = OptimSizeOff; + } + else + { + BddOptim = BddOptimOn; + OptimSize = OptimSizeOn; + } + + if ( OptimSize < OnSize ) BddNode = incbddrefext( BddOptim ); + else BddNode = incbddrefext( BddOnSet ); + + return( BddNode ); +} + +/*------------------------------------------------------------\ +| | +| BoomOptimDontCare | +| | +\------------------------------------------------------------*/ + +void BoomOptimDontCare( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomBddDontCare = FigInfo->BDD_DONT_CARE; + + BoomBehMapBdd( BehFigure, BoomOptimDontCareBdd ); + + garbagebddsystem( (bddsystem *)0 ); + + BoomBehMapAbl( BehFigure, BoomOptimDontCareAbl, 1 ); +} diff --git a/alliance/src/boom/src/boom_dc.h b/alliance/src/boom/src/boom_dc.h new file mode 100644 index 00000000..24b6a6cb --- /dev/null +++ b/alliance/src/boom/src/boom_dc.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_dc.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 02.11.01 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_DC_H +# define BOOM_DC_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomOptimDontCare(); + +# endif diff --git a/alliance/src/boom/src/boom_debug.c b/alliance/src/boom/src/boom_debug.c new file mode 100644 index 00000000..c9b71c55 --- /dev/null +++ b/alliance/src/boom/src/boom_debug.c @@ -0,0 +1,396 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_debug.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + int BoomDebugFlag = 0; + int BoomDebugOption = 0; + time_t BoomDebugChrono[ BOOM_DEBUG_MAX_CHRONO ]; + +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ + + static char *BoomDebugItemName[ ] = + { + "boom_abl.c", + "boom_anneal.c", + "boom_aux.c", + "boom_auxinit.c", + "boom_bdd.c", + "boom_burgun.c", + "boom_check.c", + "boom_cost.c", + "boom_dc.c", + "boom_debug.c", + "boom_drive.c", + "boom_error.c", + "boom_gradient.c", + "boom_hash.c", + "boom_main.c", + "boom_one.c", + "boom_optim.c", + "boom_order.c", + "boom_param.c", + "boom_parse.c", + "boom_procrast.c", + "boom_random.c", + "boom_shared.c", + "boom_simple.c", + "boom_simul.c", + "boom_top.c", + "boom_window.c", + (char *)0 + }; + + static char *BoomDebugItemFlag = (char *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomDebugSetOption | +| | +\------------------------------------------------------------*/ + +int BoomDebugSetOption( Name ) + + char *Name; +{ + /* + if ( ! strcmp( Name, "no_redinst" ) ) + { + SetBoomDebugNoRedInst(); return( 1 ); + } + else + if ( ! strcmp( Name, "stat" ) ) + { + SetBoomDebugStatistics(); return( 1 ); + } + else + if ( ! strcmp( Name, "stdout" ) ) + { + SetBoomDebugDriveStdout(); return( 1 ); + } + */ + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomDebugAddItem | +| | +\------------------------------------------------------------*/ + +int BoomDebugAddItem( Name, Mode ) + + char *Name; + int Mode; +{ + char Buffer[ 64 ]; + char *Item; + int Index; + + if ( BoomDebugItemFlag == (char *)0 ) + { + Index = 0; + + while ( BoomDebugItemName[ Index ] != (char *)0 ) + { + BoomDebugItemName[ Index ] = namealloc( BoomDebugItemName[ Index ] ); + + Index++; + } + + BoomDebugItemFlag = autallocblock( Index ); + } + + if ( ! strcmp( Name, "all" ) ) + { + BoomDebugFlag |= Mode; + + Index = 0; + + while ( BoomDebugItemName[ Index ] != (char *)0 ) + { + BoomDebugItemFlag[ Index ] |= Mode; + + Index++; + } + + return( 1 ); + } + else + { + sprintf( Buffer, "boom_%s.c", Name ); + Item = namealloc( Buffer ); + Index = 0; + + while ( BoomDebugItemName[ Index ] != (char *)0 ) + { + if ( Item == BoomDebugItemName[ Index ] ) + { + BoomDebugItemFlag[ Index ] |= Mode; + BoomDebugFlag |= Mode; + + return( 1 ); + } + + Index++; + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomDebugSearchItem | +| | +\------------------------------------------------------------*/ + +int BoomDebugSearchItem( Item, Mode ) + + char *Item; + int Mode; +{ + int Index; + + if ( ( Mode & BoomDebugFlag ) == Mode ) + { + Item = namealloc( Item ); + Index = 0; + + while ( BoomDebugItemName[ Index ] != (char *)0 ) + { + if ( Item == BoomDebugItemName[ Index ] ) + { + return( ( BoomDebugItemFlag[ Index ] & Mode ) == Mode ); + } + + Index++; + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| BoomDebugLocSaveBehCost | +| | +\------------------------------------------------------------*/ + +static void BoomDebugLocSaveBehCost( BehFigure, FileName ) + + befig_list *BehFigure; + char *FileName; +{ + FILE *XscFile; + beaux_list *BehAux; + beout_list *BehOut; + bereg_list *BehReg; + boombeauxinfo *AuxInfo; + boombeoutinfo *OutInfo; + boombereginfo *RegInfo; + long Layer; + + XscFile = mbkfopen( BehFigure->NAME, "xsc", "w" ); + + if ( XscFile != (FILE *)0 ) + { + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + AuxInfo = GetBoomBehAuxInfo( BehAux ); + + if ( AuxInfo != (boombeauxinfo *)0 ) + { + Layer = AuxInfo->LITERAL_COST; + if ( Layer > 31 ) Layer = 32; + + fprintf( XscFile, "B:beaux_%s:%ld:LITERAL %ld DELAY %ld\n", + BehAux->NAME, Layer, AuxInfo->LITERAL_COST, AuxInfo->DELAY_COST ); + } + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + OutInfo = GetBoomBehOutInfo( BehOut ); + + if ( OutInfo != (boombeoutinfo *)0 ) + { + Layer = OutInfo->LITERAL_COST; + if ( Layer > 31 ) Layer = 32; + + fprintf( XscFile, "B:beout_%s:%ld:LITERAL %ld DELAY %ld\n", + BehOut->NAME, Layer, OutInfo->LITERAL_COST, OutInfo->DELAY_COST ); + } + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + RegInfo = GetBoomBehRegInfo( BehReg ); + + if ( RegInfo != (boombereginfo *)0 ) + { + Layer = RegInfo->LITERAL_COST; + if ( Layer > 31 ) Layer = 32; + + fprintf( XscFile, "B:bereg_%s:%ld:LITERAL %ld DELAY %ld\n", + BehReg->NAME, Layer, RegInfo->LITERAL_COST, RegInfo->DELAY_COST ); + } + } + + fclose( XscFile ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomDebugLocSaveBehFigure | +| | +\------------------------------------------------------------*/ + +void BoomDebugLocSaveBehFigure( BehFigure, Text, FileName, Line ) + + befig_list *BehFigure; + char *Text; + char *FileName; + int Line; +{ + static char Buffer[ 128 ]; + static int Number = 0; + + char *Name; + int Length; + + Name = BehFigure->NAME; + + sprintf( Buffer, "beh%03d_%04d", Number++, Line ); + Length = strlen( Buffer ); + + FileName = FileName + 4; + strcpy( Buffer + Length, FileName ); + Length += strlen( FileName ); + + if ( Text != (char *)0 ) + { + strcpy( &Buffer[ Length - 2 ], Text ); + } + else + { + Buffer[ Length - 2 ] = '\0'; + } + + BehFigure->NAME = namealloc( Buffer ); + + fprintf( stdout, " +++ BoomDebugSaveBehFigure %s.vbe\n", BehFigure->NAME ); + vhdlsavebefig( BehFigure, 0 ); + + BoomDebugLocSaveBehCost( BehFigure, BehFigure->NAME ); + + BehFigure->NAME = Name; +} + +/*------------------------------------------------------------\ +| | +| BoomDebugPrint | +| | +\------------------------------------------------------------*/ + +void BoomDebugPrint( 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/boom/src/boom_debug.h b/alliance/src/boom/src/boom_debug.h new file mode 100644 index 00000000..55946490 --- /dev/null +++ b/alliance/src/boom/src/boom_debug.h @@ -0,0 +1,167 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_debug.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_DEBUG_H +# define BOOM_DEBUG_H + +# include + +/*------------------------------------------------------------\ +| | +| Debug Mode | +| | +\------------------------------------------------------------*/ + +# define BOOM_DEBUG_LEVEL0 0x01 +# define BOOM_DEBUG_LEVEL1 0x03 +# define BOOM_DEBUG_LEVEL2 0x07 + +/*------------------------------------------------------------\ +| | +| Debug Option | +| | +\------------------------------------------------------------*/ + +/* +# define BOOM_DEBUG_NO_RED_INST 0x01 +# define BOOM_DEBUG_STATISTICS 0x02 +# define BOOM_DEBUG_DRIVE_STDOUT 0x04 +*/ + +/*------------------------------------------------------------\ +| | +| Chrono | +| | +\------------------------------------------------------------*/ + +# define BOOM_DEBUG_MAX_CHRONO 10 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Save Macro | +| | +\------------------------------------------------------------*/ + +# define BoomDebugSaveBehFigure( F, T ) \ + \ + (BoomDebugLocSaveBehFigure( (F), (T), __FILE__, __LINE__ )) + +/*------------------------------------------------------------\ +| | +| Debug Macro | +| | +\------------------------------------------------------------*/ + +# define IsBoomDebugLevel0() (BoomDebugSearchItem( __FILE__, BOOM_DEBUG_LEVEL0)) +# define IsBoomDebugLevel1() (BoomDebugSearchItem( __FILE__, BOOM_DEBUG_LEVEL1)) +# define IsBoomDebugLevel2() (BoomDebugSearchItem( __FILE__, BOOM_DEBUG_LEVEL2)) + +/*------------------------------------------------------------\ +| | +| Print Macro | +| | +\------------------------------------------------------------*/ + +# define BoomPrintf BoomDebugPrint( __FILE__, __LINE__ ); fprintf + +/*------------------------------------------------------------\ +| | +| Debug Option Macro | +| | +\------------------------------------------------------------*/ + +/* +# define IsBoomDebugNoRedInst() (BoomDebugOption & BOOM_DEBUG_NO_RED_INST) +# define SetBoomDebugNoRedInst() (BoomDebugOption |= BOOM_DEBUG_NO_RED_INST) +# define IsBoomDebugStatistics() (BoomDebugOption & BOOM_DEBUG_STATISTICS) +# define SetBoomDebugStatistics() (BoomDebugOption |= BOOM_DEBUG_STATISTICS) +# define IsBoomDebugDriveStdout() (BoomDebugOption & BOOM_DEBUG_DRIVE_STDOUT) +# define SetBoomDebugDriveStdout() (BoomDebugOption |= BOOM_DEBUG_DRIVE_STDOUT) +*/ + +/*------------------------------------------------------------\ +| | +| Time Macro | +| | +\------------------------------------------------------------*/ + +# define BoomDebugStartChrono(N) (void)time(&BoomDebugChrono[(N)]) +# define BoomDebugReadChrono(N) (time((void *)0) - BoomDebugChrono[(N)]) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern int BoomDebugFlag; + extern int BoomDebugOption; + extern time_t BoomDebugChrono[ BOOM_DEBUG_MAX_CHRONO ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern int BoomDebugSearchItem(); + extern int BoomDebugAddItem(); + + extern int BoomDebugSetOption(); + + extern void BoomDebugLocSaveBehFigure(); + extern void BoomDebugPrint(); + +# endif diff --git a/alliance/src/boom/src/boom_drive.c b/alliance/src/boom/src/boom_drive.c new file mode 100644 index 00000000..499091f5 --- /dev/null +++ b/alliance/src/boom/src/boom_drive.c @@ -0,0 +1,98 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_parse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_abl.h" +# include "boom_parse.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomDriveBehFigure | +| | +\------------------------------------------------------------*/ + +void BoomDriveBehFigure( BehFigure, FileName ) + + befig_list *BehFigure; + char *FileName; +{ + char *SaveName; + + SaveName = BehFigure->NAME; + BehFigure->NAME = FileName; + + vhdlsavebefig( BehFigure, 0 ); + BehFigure->NAME = SaveName; +} diff --git a/alliance/src/boom/src/boom_drive.h b/alliance/src/boom/src/boom_drive.h new file mode 100644 index 00000000..0a31a3af --- /dev/null +++ b/alliance/src/boom/src/boom_drive.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 : BOOM | +| | +| File : boom_drive.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_DRIVE_H +# define BOOM_DRIVE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomDriveBehFigure(); + +# endif diff --git a/alliance/src/boom/src/boom_error.c b/alliance/src/boom/src/boom_error.c new file mode 100644 index 00000000..3fefffd7 --- /dev/null +++ b/alliance/src/boom/src/boom_error.c @@ -0,0 +1,164 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_error.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include MUT_H +# include AUT_H +# include "boom_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomDisplayError | +| | +\------------------------------------------------------------*/ + +void BoomDisplayError( File, Line, Error, Text ) + + char *File; + int Line; + int Error; + char *Text; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%d ", Name, Line ); + + switch( Error ) + { + case BOOM_EXPR_NULL_ERROR : + + fprintf( stderr, "null expression !\n" ); + + break; + + case BOOM_EXPR_LOOP_ERROR : + + fprintf( stderr, "combinatory loop on %s !\n", Text ); + + break; + + case BOOM_UNKNOWN_ATOM_ERROR : + + fprintf( stderr, "unknown atom %s !\n", Text ); + + break; + + case BOOM_SIMPLIFY_ERROR : + + fprintf( stderr, "cannot simplify internal signals\n" ); + + break; + + case BOOM_ILLEGAL_STABLE_ERROR : + + fprintf( stderr, "illegal use of STABLE operator\n" ); + + break; + + case BOOM_OPERATOR_ERROR : + + fprintf( stderr, "illegal use of operator %ld\n", (long)Text ); + + break; + + default : fprintf( stderr, "Internal error number %d\n", Error ); + } + + autexit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| BoomDisplayWarning | +| | +\------------------------------------------------------------*/ + +void BoomDisplayWarning( File, Line, Warning, Text ) + + char *File; + int Line; + int Warning; + char *Text; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%d ", Name, Line ); + + switch ( Warning ) + { + default : fprintf( stderr, "Internal warning number %d\n", Warning ); + } +} diff --git a/alliance/src/boom/src/boom_error.h b/alliance/src/boom/src/boom_error.h new file mode 100644 index 00000000..fee12614 --- /dev/null +++ b/alliance/src/boom/src/boom_error.h @@ -0,0 +1,99 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_error.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_ERROR_H +# define BOOM_ERROR_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_EXPR_NULL_ERROR 0 +# define BOOM_EXPR_LOOP_ERROR 1 +# define BOOM_UNKNOWN_ATOM_ERROR 2 +# define BOOM_SIMPLIFY_ERROR 3 +# define BOOM_ILLEGAL_STABLE_ERROR 4 +# define BOOM_OPERATOR_ERROR 5 + +/*------------------------------------------------------------\ +| | +| Errors | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Warnings | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define BoomError( ERROR, TEXT ) \ + \ + BoomDisplayError( __FILE__, __LINE__, (ERROR), (TEXT) ) + +# define BoomWarning( WARNING, TEXT ) \ + \ + BoomDisplayWarning( __FILE__, __LINE__, (WARNING), (TEXT) ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomDisplayError(); + extern void BoomDisplayWarning(); + +# endif diff --git a/alliance/src/boom/src/boom_gradient.c b/alliance/src/boom/src/boom_gradient.c new file mode 100644 index 00000000..2e3d194a --- /dev/null +++ b/alliance/src/boom/src/boom_gradient.c @@ -0,0 +1,415 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_gradient.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_gradient.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static bddnode *BoomBddTopVarNode = (bddnode *)0; + static long BoomCurrentVar = (long )0; + static long BoomCurrentCost = 0; + + static int BoomExplosionFlag = 0; + + + static long *BoomVarCostArray = (long *)0; + static long *BoomVarSortArray = (long *)0; + static long BoomVarArraySize = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomGradientTopBddNode | +| | +\------------------------------------------------------------*/ + +static void BoomGradientTopBddNode( BddNode ) + + bddnode *BddNode; +{ + bddnode *NewBddNode; + long Number; + + if ( ! BoomExplosionFlag ) + { + Number = getbddnodenum( (bddsystem *)0, BddNode ); + + if ( Number < BOOM_BDD_NODE_BIG_SIZE ) return; + + NewBddNode = composebddnode( BddLocalSystem, BddNode, + BoomCurrentVar, BoomBddTopVarNode ); + + if ( IsBddSystemExplosion( BddLocalSystem ) ) + { + BoomPrintf( stdout, "Explosion !!! %ld\n", BddLocalSystem->NUMBER_NODE ); + + garbagebddsystem( BddLocalSystem ); + explosionbddsystemrestart( BddLocalSystem ); + + BoomExplosionFlag = 1; + } + else + { + BoomCurrentCost += getbddnodenum( (bddsystem *)0, NewBddNode ); + /* + Number = getbddnodenum( (bddsystem *)0, NewBddNode ); + + if ( Number >= BOOM_BDD_NODE_BIG_SIZE ) BoomCurrentCost += Number; + */ + + decbddrefext( NewBddNode ); + } + } +} + +/*------------------------------------------------------------\ +| | +| BoomGradientCompareCost | +| | +\------------------------------------------------------------*/ + +static long BoomGradientCompareCost( CostArray, Index1, Index2 ) + + long *CostArray; + long Index1; + long Index2; +{ + return( CostArray[ Index2 ] - CostArray[ Index1 ] ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehGradientBddOrder | +| | +\------------------------------------------------------------*/ + +chain_list *BoomBehGradientBddOrder( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + chain_list *OrderList; + long NumberVar; + long VarIndex; + long Index; + long ExplosionLimit; + long MaxNode; + char *Name; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + VarIndex = getbddvarindex( BddLocalSystem, 0 ); + BoomBddTopVarNode = addbddcircuitin( BddLocalCircuit, "_top_", VarIndex, + BDD_IN_MODE_BEFORE ); + + NumberVar = BddLocalSystem->NUMBER_VAR; + + if ( BoomVarCostArray == (long *)0 ) + { + BoomVarCostArray = (long *)autallocblock( sizeof( long ) * NumberVar ); + BoomVarSortArray = (long *)autallocblock( sizeof( long ) * NumberVar ); + + BoomVarArraySize = NumberVar; + } + else + if ( NumberVar > BoomVarArraySize ) + { + BoomVarCostArray = (long *)autresizeblock( (char *)BoomVarCostArray, + sizeof( long ) * BoomVarArraySize, + sizeof( long ) * NumberVar ); + BoomVarSortArray = (long *)autresizeblock( (char *)BoomVarSortArray, + sizeof( long ) * BoomVarArraySize, + sizeof( long ) * NumberVar ); + BoomVarArraySize = NumberVar; + } + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Compute Cost for each variables\n" ); + } + + MaxNode = BddLocalSystem->NUMBER_NODE * 2; + + for ( BoomCurrentVar = 1; BoomCurrentVar < NumberVar; BoomCurrentVar++ ) + { + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Sweep !\n" ); + } + + sweepbddvar( BddLocalSystem, 0, 1 ); + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Garbage !\n" ); + } + + garbagebddsystem( BddLocalSystem ); + MaxNode = BddLocalSystem->NUMBER_NODE * 4; + } + } + + ExplosionLimit = BddLocalSystem->NUMBER_NODE * 2; + + if ( ExplosionLimit < BOOM_GRADIENT_EXPLOSION_LIMIT ) + { + ExplosionLimit = BOOM_GRADIENT_EXPLOSION_LIMIT; + } + + explosionbddsystemdynamic( (bddsystem *)0, NULL, ExplosionLimit ); + + BoomCurrentCost = 0; + + BoomBehScanBdd( BehFigure, BoomGradientTopBddNode ); + + if ( BoomExplosionFlag ) + { + BoomExplosionFlag = 0; + BoomVarCostArray[ BoomCurrentVar - 1 ] = - BoomCurrentVar; + } + else + { + BoomVarCostArray[ BoomCurrentVar - 1 ] = BoomCurrentCost; + } + + if ( IsBoomDebugLevel1() ) + { + VarIndex = getbddvarindex( (bddsystem *)0, BoomCurrentVar ); + Name = getbddcircuitinname( (bddcircuit *)0, VarIndex ); + + BoomPrintf( stdout, "%ld %ld %s\n", BoomCurrentVar, BoomCurrentCost, Name ); + } + } + + explosionbddsystemdynamic( (bddsystem *)0, NULL, 0 ); + + sortautarray( BoomVarCostArray, BoomVarSortArray, NumberVar - 1, BoomGradientCompareCost ); + + OrderList = (chain_list *)0; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "New variable order (reverse)\n" ); + } + + for ( Index = NumberVar - 2; Index >= 0; Index-- ) + { + VarIndex = getbddvarindex( (bddsystem *)0, BoomVarSortArray[ Index ] + 1 ); + Name = getbddcircuitinname( (bddcircuit *)0, VarIndex ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "%ld %ld %s\n", BoomVarSortArray[ Index ] + 1, VarIndex, Name ); + } + + OrderList = addchain( OrderList, (void *)Name ); + } + + BoomBehRebuildBddNode( BehFigure, OrderList ); + + return( OrderList ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeGradient | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeGradient( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + long Cost; + long NewCost; + long Iteration; + long Amplitude; + long MaxIteration; + long MaxAmplitude; + chain_list *BestOrder; + chain_list *NewOrder; + int Level; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + MaxAmplitude = FigInfo->AMPLITUDE; + Level = FigInfo->OPTIM_LEVEL; + + if ( MaxIteration <= 0 ) MaxIteration = 2; + if ( MaxAmplitude <= 0 ) MaxAmplitude = 5; + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + BestOrder = BoomBehGetBddOrder( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + MaxIteration = MaxIteration * (Level + 1); + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Iteration %ld\n", Iteration ); + } + + Amplitude = MaxAmplitude; + + do + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Amplitude %ld\n", Amplitude ); + } + + BoomBehRandomBddOrder( BehFigure, Amplitude ); + + NewOrder = BoomBehGradientBddOrder( BehFigure ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + + freechain( BestOrder ); + BestOrder = NewOrder; + } + else + { + freechain( NewOrder ); + } + + Amplitude--; + } + while ( Amplitude > 0 ); + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3ld\b\b\b", ( ( Iteration + 1 ) * 100 ) / MaxIteration ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Best cost : %ld\n", Cost ); + } + + BoomBehRebuildBddNode( BehFigure, BestOrder ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} diff --git a/alliance/src/boom/src/boom_gradient.h b/alliance/src/boom/src/boom_gradient.h new file mode 100644 index 00000000..208adaf6 --- /dev/null +++ b/alliance/src/boom/src/boom_gradient.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_gradient.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_GRADIENT_H +# define BOOM_GRADIENT_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_GRADIENT_EXPLOSION_LIMIT 10000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeGradient(); + extern chain_list *BoomBehGradientBddOrder(); + +# endif diff --git a/alliance/src/boom/src/boom_hash.c b/alliance/src/boom/src/boom_hash.c new file mode 100644 index 00000000..24edf1f6 --- /dev/null +++ b/alliance/src/boom/src/boom_hash.c @@ -0,0 +1,313 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_hash.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include +# include "boom_error.h" +# include "boom_hash.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Get Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Get Hash Size | +| | +\------------------------------------------------------------*/ + +static long BoomGetHashAblSize( Size ) + + long Size; +{ + int Index; + + for ( Index = 0; Index < AUT_MAX_PRIME_NUMBER; Index++ ) + { + if ( AUT_HASH_PRIME_NUMBER[ Index ] > Size ) + { + return( AUT_HASH_PRIME_NUMBER[ Index ] ); + } + } + + if ( ( Size & 1 ) == 0 ) Size++; + + return( Size ); +} + +/*------------------------------------------------------------\ +| | +| Boom Get Hash Key | +| | +\------------------------------------------------------------*/ + +static long BoomGetHashAblKey( Table, BddNode ) + + boomhabltable *Table; + bddnode *BddNode; +{ + return( ((unsigned long)BddNode >> 2 ) % Table->TABLE_SIZE ); +} + +/*------------------------------------------------------------\ +| | +| Create Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Create Hash Abl Table | +| | +\------------------------------------------------------------*/ + +boomhabltable *BoomCreateHashAblTable( Length ) + + long Length; +{ + boomhabltable *HashTable; + boomhabl *Table; + + Length = BoomGetHashAblSize( Length ); + + HashTable = (boomhabltable *)autallocblock( sizeof( boomhabltable ) ); + Table = (boomhabl *)autallocblock( sizeof( boomhabl ) * Length ); + + HashTable->TABLE = Table; + HashTable->TABLE_SIZE = Length; + + return( HashTable ); +} + +/*------------------------------------------------------------\ +| | +| Reset Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Reset Hash Abl Table | +| | +\------------------------------------------------------------*/ + +void BoomResetHashAblTable( HashTable ) + + boomhabltable *HashTable; +{ + boomhabl *HashAbl; + long HashIndex; + + if ( HashTable->NUMBER_ABL > 0 ) + { + for ( HashIndex = 0; HashIndex < HashTable->TABLE_SIZE; HashIndex++ ) + { + HashAbl = &HashTable->TABLE[ HashIndex ]; + + if ( HashAbl->NODE != (bddnode *)0 ) + { + freeablexpr( HashAbl->ABL ); + + HashAbl->ABL = (chain_list *)0; + HashAbl->NODE = (bddnode *)0; + } + } + + HashTable->NUMBER_ABL = 0; + HashTable->NUMBER_RESET++; + } + + HashTable->NUMBER_ADD = 0; + HashTable->NUMBER_HIT = 0; + HashTable->NUMBER_MISS = 0; +} + +/*------------------------------------------------------------\ +| | +| Destroy Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Destroy Hash Abl Table | +| | +\------------------------------------------------------------*/ + +void BoomDestroyHashAblTable( HashTable ) + + boomhabltable *HashTable; +{ + BoomResetHashAblTable( HashTable ); + + autfreeblock( HashTable->TABLE ); + autfreeblock( HashTable ); +} + +/*------------------------------------------------------------\ +| | +| Add Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Add Hash Element | +| | +\------------------------------------------------------------*/ + +boomhabl *BoomAddHashAbl( HashTable, BddNode, Equation ) + + boomhabltable *HashTable; + bddnode *BddNode; + chain_list *Equation; +{ + boomhabl *HashAbl; + long HashIndex; + + HashIndex = BoomGetHashAblKey( HashTable, BddNode, Equation ); + HashAbl = &HashTable->TABLE[ HashIndex ]; + + HashTable->NUMBER_ADD++; + + if ( HashAbl->NODE == (bddnode *)0 ) + { + HashTable->NUMBER_ABL++; + } + else + { + freeablexpr( HashAbl->ABL ); + } + + HashAbl->NODE = BddNode; + HashAbl->ABL = dupablexpr( Equation ); + + return( HashAbl ); +} + +/*------------------------------------------------------------\ +| | +| Search Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Search Hash Abl | +| | +\------------------------------------------------------------*/ + +boomhabl *BoomSearchHashAbl( HashTable, BddNode ) + + boomhabltable *HashTable; + bddnode *BddNode; +{ + boomhabl *HashAbl; + long HashIndex; + + HashIndex = BoomGetHashAblKey( HashTable, BddNode ); + HashAbl = &HashTable->TABLE[ HashIndex ]; + + if ( HashAbl->NODE == BddNode ) + { + HashTable->NUMBER_HIT++; + + return( HashAbl ); + } + + HashTable->NUMBER_MISS++; + + return( (boomhabl *)0 ); +} + +/*------------------------------------------------------------\ +| | +| Boom View Hash Abl Table | +| | +\------------------------------------------------------------*/ + +void BoomViewHashAblTable( HashTable ) + + boomhabltable *HashTable; +{ + fprintf( stdout, "--> HashAblTable\n" ); + fprintf( stdout, " SIZE : %ld\n", HashTable->TABLE_SIZE ); + fprintf( stdout, " ABL : %ld\n", HashTable->NUMBER_ABL ); + fprintf( stdout, " ADD : %ld\n", HashTable->NUMBER_ADD ); + fprintf( stdout, " HIT : %ld\n", HashTable->NUMBER_HIT ); + fprintf( stdout, " MISS : %ld\n", HashTable->NUMBER_MISS ); + fprintf( stdout, " RESET : %ld\n", HashTable->NUMBER_RESET ); + + fprintf( stdout, "<-- HashAblTable\n" ); +} diff --git a/alliance/src/boom/src/boom_hash.h b/alliance/src/boom/src/boom_hash.h new file mode 100644 index 00000000..b20210c0 --- /dev/null +++ b/alliance/src/boom/src/boom_hash.h @@ -0,0 +1,107 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_hash.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_HASH_H +# define BOOM_HASH_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Hash Abl | +| | +\------------------------------------------------------------*/ + + typedef struct boomhabl + { + bddnode *NODE; + chain_list *ABL; + + } boomhabl; + +/*-----------------------------------------------------------\ +| | +| Boom Hash Abl Table | +| | +\-----------------------------------------------------------*/ + + typedef struct boomhabltable + { + boomhabl *TABLE; + long TABLE_SIZE; + long NUMBER_ABL; + long NUMBER_ADD; + long NUMBER_HIT; + long NUMBER_MISS; + long NUMBER_RESET; + + } boomhabltable; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern boomhabltable *BoomCreateHashAblTable(); + extern void BoomDestroyHashAblTable(); + extern void BoomResetHashAblTable(); + + extern boomhabl *BoomAddHashAbl(); + extern boomhabl *BoomSearchHashAbl(); + +# endif diff --git a/alliance/src/boom/src/boom_logic.c b/alliance/src/boom/src/boom_logic.c new file mode 100644 index 00000000..040e0690 --- /dev/null +++ b/alliance/src/boom/src/boom_logic.c @@ -0,0 +1,1070 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_logic.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_logic.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomLogicComputeAux | +| | +\------------------------------------------------------------*/ + +beaux_list *BoomLogicComputeAux( BehFigure, BehAux ) + + befig_list *BehFigure; + beaux_list *BehAux; +{ + beaux_list *ScanAux; + beaux_list **PrevAux; + + PrevAux = &BehFigure->BEAUX; + + for ( ScanAux = BehFigure->BEAUX; + ScanAux != (beaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + if ( ScanAux == BehAux ) + { + *PrevAux = (beaux_list *)0; break; + } + + PrevAux = &ScanAux->NEXT; + } + + BoomBehFreeBehAux( BehFigure->BEAUX ); + + BehFigure->BEAUX = ScanAux; + BehAux = ScanAux; + + BoomBehBddNode2Abl( BehFigure ); + + if ( IsBoomDebugLevel2() ) + { + BoomDebugSaveBehFigure( BehFigure, NULL ); + } + + BoomBehCreateAux( BehFigure ); + + if ( IsBoomDebugLevel2() ) + { + BoomDebugSaveBehFigure( BehFigure, NULL ); + } + + return( BehAux ); +} + +/*------------------------------------------------------------\ +| | +| Boom Logic Reorder Window 2 | +| | +\------------------------------------------------------------*/ + +int BoomLogicReorderWindow2( BehFigure, BehAux, BddVar, PCost ) + + befig_list *BehFigure; + beaux_list *BehAux; + bddvar BddVar; + long *PCost; +{ + long NewCost; + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( NewCost < *PCost ) + { + *PCost = NewCost; + + return( 1 ); + } + else + if ( NewCost == *PCost ) + { + return( 0 ); + } + + swapbddvar( BddLocalSystem, BddVar ); + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Boom Logic Reorder Window 3 | +| | +\------------------------------------------------------------*/ + +int BoomLogicReorderWindow3( BehFigure, BehAux, BddVar, PCost ) + + befig_list *BehFigure; + beaux_list *BehAux; + bddvar BddVar; + long *PCost; +{ + long Cost; + long NewCost; + int BestOrder; + + BestOrder = BOOM_LOGIC_REORDER_123; + Cost = *PCost; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: Initial cost %ld\n", Cost ); + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_LOGIC_REORDER_213; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 213 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_LOGIC_REORDER_231; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 231 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_LOGIC_REORDER_321; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 321 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_LOGIC_REORDER_312; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 312 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_LOGIC_REORDER_132; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 132 new cost %ld\n", Cost ); + } + } + + switch ( BestOrder ) + { + case BOOM_LOGIC_REORDER_123 : swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_LOGIC_REORDER_213 : swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_LOGIC_REORDER_231 : swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_LOGIC_REORDER_321 : swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_LOGIC_REORDER_312 : swapbddvar( (bddsystem *)0, BddVar ); + break; + } + + *PCost = Cost; + + return( BestOrder != BOOM_LOGIC_REORDER_123 ); +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeWindow | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeWindow( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + short *ReorderLevel; + bddvar NumberChild; + bddvar BestChild; + bddvar ChildCount; + bddvar ChildTo; + bddvar ChildFrom; + int SwapReorder; + int AnySwap; + int Moved; + long Cost; + long NewCost; + + NumberChild = BddLocalSystem->NUMBER_VAR; + ReorderLevel = (short *)autallocblock( sizeof( short ) * NumberChild ); + + for ( ChildFrom = 0; ChildFrom < ( NumberChild - 1 ); ChildFrom++ ) + { + ReorderLevel[ ChildFrom ] = 1; + } + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + do + { + AnySwap = 0; + + for ( ChildCount = 0; ChildCount < NumberChild - 1; ChildCount++ ) + { + if ( ReorderLevel[ ChildCount ] ) + { + if ( ChildCount < NumberChild - 2 ) + { + Moved = BoomLogicReorderWindow3( BehFigure, BehAux, ChildCount, &Cost ); + } + else + { + Moved = BoomLogicReorderWindow2( BehFigure, BehAux, ChildCount, &Cost ); + } + + if ( Moved ) + { + AnySwap = 1; + + if ( ChildCount > 0 ) ReorderLevel[ ChildCount - 1 ] = 1; + if ( ChildCount > 1 ) ReorderLevel[ ChildCount - 2 ] = 1; + + ReorderLevel[ ChildCount + 1 ] = 1; + + if ( ChildCount < NumberChild - 2 ) ReorderLevel[ ChildCount + 2 ] = 1; + if ( ChildCount < NumberChild - 3 ) ReorderLevel[ ChildCount + 3 ] = 1; + if ( ChildCount < NumberChild - 4 ) ReorderLevel[ ChildCount + 4 ] = 1; + } + else + { + ReorderLevel[ ChildCount ] = 0; + } + } + } + } + while ( AnySwap ); + + autfreeblock( ReorderLevel ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeTop | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeTop( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + char *ReorderLevel; + bddvar NumberChild; + bddvar BestChild; + bddvar ChildCount; + bddvar ChildTo; + bddvar ChildFrom; + char SwapReorder; + long Cost; + long NewCost; + + NumberChild = BddLocalSystem->NUMBER_VAR; + ReorderLevel = (char *)autallocblock( sizeof( char ) * NumberChild ); + + for ( ChildFrom = 0; ChildFrom < ( NumberChild - 1 ); ChildFrom++ ) + { + ReorderLevel[ ChildFrom ] = 1; + } + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + ChildCount = ( NumberChild - 1 ); + ChildFrom = 0; + + while ( ChildCount > 0 ) + { + /* + fprintf( stdout, "%-4d\b\b\b\b", ChildCount ); + fflush( stdout ); + */ + + if ( IsBoomDebugLevel2() ) + { + BoomPrintf( stdout, "-> ChildFrom %d\n", ChildFrom ); + } + + ReorderLevel[ ChildFrom ] = 0; + + BestChild = ChildFrom; + + for ( ChildTo = ChildFrom; ChildTo < ( NumberChild - 1 ); ChildTo++ ) + { + if ( IsBoomDebugLevel2() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", ChildTo, ChildTo + 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo ); + + SwapReorder = ReorderLevel[ ChildTo ]; + ReorderLevel[ ChildTo ] = ReorderLevel[ ChildTo + 1 ]; + ReorderLevel[ ChildTo + 1 ] = SwapReorder; + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + BestChild = ChildTo + 1; Cost = NewCost; + } + } + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "--> Best child %d\n", BestChild ); + BoomPrintf( stdout, "--> Best cost %ld\n", Cost ); + } + + for ( ChildTo = ( NumberChild - 1 ); ChildTo > BestChild; ChildTo-- ) + { +# ifdef BDD_DEBUG + if ( IsBoomDebugLevel1() ) + { +fprintf( stdout, "-> UnSwap %d and %d\n", ChildTo - 1, ChildTo ); + } +# endif + + SwapReorder = ReorderLevel[ ChildTo - 1 ]; + ReorderLevel[ ChildTo - 1 ] = ReorderLevel[ ChildTo ]; + ReorderLevel[ ChildTo ] = SwapReorder; + + swapbddvar( (bddsystem *)0, ChildTo - 1 ); + } + + while ( ! ReorderLevel[ ChildFrom ] ) + { + ChildFrom = ChildFrom + 1; + } + + ChildCount = ChildCount - 1; + } + + autfreeblock( ReorderLevel ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeProcrast | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeProcrast( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + bddvar NumberChild; + bddvar ChildTo; + bddvar ChildFrom; + char SwapReorder; + long Cost; + long NumberNode; + long NewCost; + long Iteration; + int MaxIteration; + long MaxNode; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + + if ( MaxIteration <= 0 ) MaxIteration = 2; + + NumberChild = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + MaxNode = ( BddLocalSystem->NUMBER_NODE * 120 ) / 100; + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + ChildFrom = 0; + + for ( ChildFrom = 0; ChildFrom < (NumberChild - 1); ChildFrom++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> ChildFrom %d\n", ChildFrom ); + } + + for ( ChildTo = ChildFrom; ChildTo < ( NumberChild - 1 ); ChildTo++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", ChildTo, ChildTo + 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo ); + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + garbagebddsystem( BddLocalSystem ); + } + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + BoomPrintf( stdout, "@@@@ Max nodes %ld reached %ld\n", + MaxNode, BddLocalSystem->NUMBER_NODE ); + break; + } + } + + NumberNode = BoomBehGetNumberBddNode( BehFigure ); + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld %ld\n", NewCost, NumberNode ); + } + + if ( NewCost > Cost ) + { + while ( ChildTo > ChildFrom ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> UnSwap %d and %d\n", ChildTo, ChildTo - 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo - 1 ); + + ChildTo = ChildTo - 1; + } + } + else + { + Cost = NewCost; + } + } + } + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeBest | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeBest( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + bddvar NumberChild; + bddvar ChildTo; + bddvar ChildFrom; + char SwapReorder; + long Cost; + long NewCost; + long Iteration; + int MaxIteration; + long MaxNode; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + + if ( MaxIteration <= 0 ) MaxIteration = 2; + + NumberChild = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + MaxNode = BddLocalSystem->NUMBER_NODE << 1; + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + ChildFrom = 0; + + for ( ChildFrom = 0; ChildFrom < (NumberChild - 1); ChildFrom++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> ChildFrom %d\n", ChildFrom ); + } + + for ( ChildTo = ChildFrom; ChildTo < ( NumberChild - 1 ); ChildTo++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", ChildTo, ChildTo + 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo ); + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + BoomPrintf( stdout, "@@@@ Max nodes %ld reached %ld\n", + MaxNode, BddLocalSystem->NUMBER_NODE ); + break; + } + } + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost > Cost ) + { + while ( ChildTo > ChildFrom ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> UnSwap %d and %d\n", ChildTo, ChildTo - 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo - 1 ); + + ChildTo = ChildTo - 1; + } + } + else + { + Cost = NewCost; + } + } + } + + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeSimple | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeSimple( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + bddvar NumberVar; + bddvar BddVar; + long Cost; + + NumberVar = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + for ( BddVar = 0; BddVar < NumberVar - 1; BddVar++ ) + { + /* + fprintf( stdout, "%-4d\b\b\b\b", NumberVar - BddVar ); + fflush( stdout ); + */ + + if ( BddVar < NumberVar - 2 ) + { + BoomLogicReorderWindow3( BehFigure, BehAux, BddVar, &Cost ); + } + else + { + BoomLogicReorderWindow2( BehFigure, BehAux, BddVar, &Cost ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "New cost %ld\n", Cost ); + } + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeRandom | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeRandom( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + long MaxIteration; + bddvar NumberVar; + bddvar BddVar; + int Iteration; + long Cost; + + static unsigned char InitOptimizeRandom = 1; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + + if ( InitOptimizeRandom ) + { + srand( getpid() ); + InitOptimizeRandom = 0; + } + + NumberVar = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld, NumberVar %d\n", Cost, NumberVar ); + } + + if ( MaxIteration <= 0 ) MaxIteration = NumberVar; + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + BddVar = (rand() >> 8) % (NumberVar - 1); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Swap %d\n", BddVar ); + } + + BoomLogicReorderWindow2( BehFigure, BehAux, BddVar, &Cost ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "New cost %ld\n", Cost ); + } + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +# if 0 +void BoomLogicOptimizeRandom( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + long MaxIteration; + bddvar NumberVar; + bddvar BddVar; + int Iteration; + int Amplitude; + int Swap; + long Cost; + + static unsigned char InitOptimizeRandom = 1; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + + if ( InitOptimizeRandom ) + { + srand( getpid() ); + InitOptimizeRandom = 0; + } + + NumberVar = BddLocalSystem->NUMBER_VAR; + + /* + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + */ + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld, NumberVar %d\n", Cost, NumberVar ); + } + + /* + if ( MaxIteration <= 0 ) MaxIteration = NumberVar; + */ + MaxIteration = 1 + ( ( NumberVar + 2 ) / 2 ); + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + if ( Iteration != 0 ) + { + BoomBehMakeBddNode( BehFigure, 0 ); + } + + for ( BddVar = 0; BddVar < ( NumberVar - 1 ); BddVar++ ) + { + Amplitude = (rand() >> 8) % 8; + + for ( Swap = 0; Swap < Amplitude; Swap++ ) + { + if ( ( BddVar + Swap ) >= ( NumberVar - 1 ) ) break; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", BddVar + Swap, BddVar + Swap + 1 ); + } + + swapbddvar( (bddsystem *)0, BddVar + Swap ); + } + } + + BoomLogicOptimizeProcrast( BehFigure ); + } + + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} +# endif + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimizeOne | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimizeOne( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + bddvar NumberVar; + bddvar BddVar; + long Cost; + + reorderbddsystemwindow( BddLocalSystem ); + + NumberVar = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomLogicComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomLogicOptimization | +| | +\------------------------------------------------------------*/ + +void BoomLogicOptimization( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + beaux_list *BehAux; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomBehCreateAuxInit( BehFigure ); + + if ( FigInfo->LOGIC_METHOD == BOOM_LOGIC_METHOD_NOTHING ) + { + return; + } + + BddSystem = createbddsystem( 1000, 200000, 100, 3000000 ); + reorderbddsystemdynamic( BddSystem, reorderbddsystemwindow, 200000, 50 ); + /* + explosionbddsystemdynamic( BddSystem, NULL, 50 ); + */ + + BoomBehAbl2BddNode( BehFigure, FigInfo->KEEP_AUX, FigInfo->INIT_BDD_ORDER ); + reorderbddsystemdynamic( BddSystem, garbagebddsystem, 200000, 50 ); + + BehAux = BehFigure->BEAUX; + + if ( IsBoomDebugLevel1() ) + { + testbddcircuit( (bddcircuit *)0 ); + } +/*\ + while ( testbddcircuit( (bddcircuit *)0 ) ) + { + BehAux = BoomLogicComputeAux( BehFigure, BehAux ); + + Cost = BoomBehGiveCost( BehFigure ); + fprintf( stdout, "New cost %d\n", Cost ); + } +\*/ + + switch ( FigInfo->LOGIC_METHOD ) + { + case BOOM_LOGIC_METHOD_SIMPLE : BoomLogicOptimizeSimple( BehFigure ); + break; + + case BOOM_LOGIC_METHOD_WINDOW : BoomLogicOptimizeWindow( BehFigure ); + break; + + case BOOM_LOGIC_METHOD_TOP : BoomLogicOptimizeTop( BehFigure ); + break; + + case BOOM_LOGIC_METHOD_ONE : BoomLogicOptimizeOne( BehFigure ); + break; + + case BOOM_LOGIC_METHOD_PROCRAST : BoomLogicOptimizeProcrast( BehFigure ); + break; + + case BOOM_LOGIC_METHOD_BEST : BoomLogicOptimizeBest( BehFigure ); + break; + + case BOOM_LOGIC_METHOD_RANDOM : BoomLogicOptimizeRandom( BehFigure ); + break; + } +/*\ + BoomBehResetBddNode( BehFigure ); +\*/ + + BddCircuit = BehFigure->CIRCUI; + BehFigure->CIRCUI = (bddcircuit *)0; + + destroybddcircuit( BddCircuit ); + destroybddsystem( BddSystem ); + + /* + BoomBehDeleteUselessAux( BehFigure, (beaux_list *)0 ); + */ +} diff --git a/alliance/src/boom/src/boom_logic.h b/alliance/src/boom/src/boom_logic.h new file mode 100644 index 00000000..8f9c11d3 --- /dev/null +++ b/alliance/src/boom/src/boom_logic.h @@ -0,0 +1,79 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU 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 : BOOM | +| | +| File : boom_logic.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_LOGIC_H +# define BOOM_LOGIC_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_LOGIC_REORDER_123 0 +# define BOOM_LOGIC_REORDER_213 1 +# define BOOM_LOGIC_REORDER_231 2 +# define BOOM_LOGIC_REORDER_321 3 +# define BOOM_LOGIC_REORDER_312 4 +# define BOOM_LOGIC_REORDER_132 5 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomLogicOptimization(); + +# endif diff --git a/alliance/src/boom/src/boom_main.c b/alliance/src/boom/src/boom_main.c new file mode 100644 index 00000000..103df974 --- /dev/null +++ b/alliance/src/boom/src/boom_main.c @@ -0,0 +1,383 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_main.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_shared.h" +# include "boom_parse.h" +# include "boom_check.h" +# include "boom_optim.h" +# include "boom_cost.h" +# include "boom_drive.h" +# include "boom_post.h" +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_param.h" +# include "boom_main.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Usage | +| | +\------------------------------------------------------------*/ + +void BoomUsage() +{ + fprintf( stderr, " boom [Options] [Algorithm] Input_file_name [Output_file_name]\n\n" ); + + fprintf( stdout, " Options : -V Sets verbose mode on\n" ); + fprintf( stdout, " -T Sets trace and verbose modes on\n" ); + fprintf( stdout, " -O Reverses initial Bdd variables order\n" ); + fprintf( stdout, " -A Keeps all auxiliary variables\n" ); + fprintf( stdout, " -P Uses a parameter file (Input_file_name.boom)\n" ); + fprintf( stdout, " -L Uses literal's number for surface estimation\n" ); + fprintf( stdout, " -l num Optimization level [0-3] (default 0, low level)\n" ); + fprintf( stdout, " -d num Delay optimization percent (default 0 %%)\n" ); + fprintf( stdout, " -i num Iteration count\n" ); + fprintf( stdout, " -a num Amplitude\n" ); + fprintf( stdout, "\n" ); + fprintf( stdout, " Algorithms : -s Simulated annealing (default)\n" ); + fprintf( stdout, " -j Just do it algorithm\n" ); + fprintf( stdout, " -b Burgun algorithm\n" ); + fprintf( stdout, " -g Gradient algorithm\n" ); + fprintf( stdout, " -p Procrastination algorithm\n" ); + fprintf( stdout, " -w Window bdd reorder\n" ); + fprintf( stdout, " -t Top bdd reorder\n" ); + fprintf( stdout, " -m Simple bdd reorder\n" ); + fprintf( stdout, " -o One pass (faster algorithm)\n" ); + fprintf( stdout, " -r Random bdd reorder\n" ); + fprintf( stdout, " -n No optimization algorithm\n" ); + fprintf( stdout, "\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Main | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char *argv[]; +{ + befig_list *BehFigure; + boombefiginfo *FigInfo; + char *InputFileName; + char *OutputFileName; + int Number; + int Index; + char Option; + + int FlagParamFile = 0; + int FlagVerbose = 0; + int FlagTrace = 0; + int FlagInitBddOrder = 0; + int FlagKeepAux = 0; + int FlagUseLiteral = 0; + int OptimAlgorithm = BOOM_OPTIM_ALGORITHM_ANNEAL; + int OptimLevel = 0; + int OptimDelayPerCent = 0; + int Iteration = 0; + int Amplitude = 0; + + alliancebanner_with_authors( "BooM", BOOM_VERSION, "BOOlean Minimization", + "2000", ALLIANCE_VERSION, "Ludovic Jacomme" ); + mbkenv(); + autenv(); + ablenv(); + bddenv(); + + if ( argc < 2 ) BoomUsage(); + + InputFileName = (char *)0; + OutputFileName = (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 ( BoomFlagDebug ) + { + if ( BoomDebugAddItem( &argv[ Number ][ Index ], BoomFlagDebug ) ) break; + } + + if ( BoomFlagOption ) + { + if ( BoomDebugSetOption( &argv[ Number ][ Index ] ) ) break; + } + + if ( Option == 'i' ) + { + Number = Number + 1; + if ( Number >= argc ) BoomUsage(); + + Iteration = atoi( argv[ Number ] ); + + break; + } + else + if ( Option == 'a' ) + { + Number = Number + 1; + if ( Number >= argc ) BoomUsage(); + + Amplitude = atoi( argv[ Number ] ); + + break; + } + else + if ( Option == 'l' ) + { + Number = Number + 1; + if ( Number >= argc ) BoomUsage(); + + OptimLevel = atoi( argv[ Number ] ); + + if ( ( OptimLevel < 0 ) || + ( OptimLevel > 3 ) ) BoomUsage(); + + break; + } + else + if ( Option == 'd' ) + { + Number = Number + 1; + if ( Number >= argc ) BoomUsage(); + + OptimDelayPerCent = atoi( argv[ Number ] ); + + if ( ( OptimDelayPerCent < 0 ) || + ( OptimDelayPerCent > 100 ) ) BoomUsage(); + + break; + } + + switch ( Option ) + { + case 'V' : FlagVerbose = 1; + break; + case 'T' : FlagTrace = 1; + break; + case 'O' : FlagInitBddOrder = 1; + break; + case 'P' : FlagParamFile = 1; + break; + case 'L' : FlagUseLiteral = 1; + break; + case 'A' : FlagKeepAux = 1; + break; + case 'j' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_SIMUL; + break; + case 'm' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_SIMPLE; + break; + case 't' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_TOP; + break; + case 'w' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_WINDOW; + break; + case 'o' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_ONE; + break; + case 'r' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_RANDOM; + break; + case 'p' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_PROCRAST; + break; + case 'b' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_BURGUN; + break; + case 'g' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_GRADIENT; + break; + case 'n' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_NOTHING; + break; + case 's' : OptimAlgorithm = BOOM_OPTIM_ALGORITHM_ANNEAL; + break; + case 'D' : + + Index = Index + 1; + Option = argv[ Number ][ Index ]; + + if ( Option == '0' ) BoomFlagDebug = BOOM_DEBUG_LEVEL0; + else + if ( Option == '1' ) BoomFlagDebug = BOOM_DEBUG_LEVEL1; + else + if ( Option == '2' ) BoomFlagDebug = BOOM_DEBUG_LEVEL2; + else + BoomUsage(); + break; + default : BoomUsage(); + } + + if ( Option == 'r' ) break; + } + } + else + if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ]; + else + if ( OutputFileName == (char *)0 ) OutputFileName = argv[ Number ]; + else + BoomUsage(); + } + + if ( InputFileName == (char *)0 ) BoomUsage(); + + InputFileName = autbasename( InputFileName, "vbe" ); + + if ( OutputFileName == (char *)0 ) + { + OutputFileName = autallocblock( strlen( InputFileName ) + 5 ); + sprintf( OutputFileName, "%s_o", InputFileName ); + } + else + { + OutputFileName = autbasename( OutputFileName, "vbe" ); + } + + fprintf( stdout, "\t--> Parse BEH file %s.vbe\n", InputFileName ); + + BehFigure = BoomParseBehFigure( InputFileName ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\n\t--> Check figure %s\n", BehFigure->NAME ); + } + + BoomCheckBehFigure( BehFigure ); + + if ( FlagParamFile ) + { + fprintf( stdout, "\n\t--> Parse parameter file %s.boom\n", InputFileName ); + BoomParseParamFile( BehFigure, InputFileName ); + } + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + if ( FlagKeepAux ) FigInfo->KEEP_AUX = 1; + if ( FlagInitBddOrder ) FigInfo->INIT_BDD_ORDER = 1; + + if ( FlagTrace ) FlagVerbose = 1; + + FigInfo->OPTIM_ALGORITHM = OptimAlgorithm; + FigInfo->OPTIM_LEVEL = OptimLevel; + FigInfo->OPTIM_DELAY_PERCENT = OptimDelayPerCent; + FigInfo->ITERATION = Iteration; + FigInfo->AMPLITUDE = Amplitude; + FigInfo->VERBOSE = FlagVerbose; + FigInfo->TRACE = FlagTrace; + FigInfo->USE_LITERAL = FlagUseLiteral; + + if ( FlagVerbose ) + { + fprintf( stdout, "\n\t--> Optimization parameters\n" ); + fprintf( stdout, "\t Algorithm : %s\n", BoomOptimAlgorithmName[ OptimAlgorithm ] ); + fprintf( stdout, "\t Keep aux : %s\n", FlagKeepAux ? "yes" : "no" ); + fprintf( stdout, "\t Area : %3d %%\n", 100 - OptimDelayPerCent ); + fprintf( stdout, "\t Delay : %3d %%\n", OptimDelayPerCent ); + fprintf( stdout, "\t Level : %3d\n", OptimLevel ); + fprintf( stdout, "\n" ); + } + + if ( FlagVerbose ) + { + BoomBehGiveFullCost( BehFigure, 0 ); + BoomBehPrintCost( "Initial", BehFigure ); + fprintf( stdout, "\n" ); + } + + BoomBehOptimize( BehFigure ); + + if ( FlagVerbose ) + { + BoomBehGiveFullCost( BehFigure, 0 ); + BoomBehPrintCost( "Final", BehFigure ); + fprintf( stdout, "\n" ); + } + + if ( FlagVerbose ) + { + fprintf( stdout, "\t--> Post treat figure %s\n\n", BehFigure->NAME ); + + BoomPostTreatBehFigure( BehFigure, OutputFileName ); + } + + fprintf( stdout, "\t--> Drive BEH file %s\n\n", OutputFileName ); + + BoomDriveBehFigure( BehFigure, OutputFileName ); + + BoomBehFreeBehFig( BehFigure ); + + return( 0 ); +} diff --git a/alliance/src/boom/src/boom_main.h b/alliance/src/boom/src/boom_main.h new file mode 100644 index 00000000..f0310466 --- /dev/null +++ b/alliance/src/boom/src/boom_main.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : BFP | +| | +| File : bfp_main.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BFP_MAIN_H +# define BFP_MAIN_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/boom/src/boom_one.c b/alliance/src/boom/src/boom_one.c new file mode 100644 index 00000000..bc389592 --- /dev/null +++ b/alliance/src/boom/src/boom_one.c @@ -0,0 +1,113 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU 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 : BOOM | +| | +| File : boom_one.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_one.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeOne | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeOne( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + bddvar NumberVar; + long Cost; + + reorderbddsystemwindow( BddLocalSystem ); + + NumberVar = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + diff --git a/alliance/src/boom/src/boom_one.h b/alliance/src/boom/src/boom_one.h new file mode 100644 index 00000000..507dad18 --- /dev/null +++ b/alliance/src/boom/src/boom_one.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_one.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_ONE_H +# define BOOM_ONE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeOne(); + +# endif diff --git a/alliance/src/boom/src/boom_optim.c b/alliance/src/boom/src/boom_optim.c new file mode 100644 index 00000000..1e1e9f96 --- /dev/null +++ b/alliance/src/boom/src/boom_optim.c @@ -0,0 +1,226 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_optim.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" +# include "boom_dc.h" +# include "boom_auxinit.h" + +# include "boom_window.h" +# include "boom_top.h" +# include "boom_simple.h" +# include "boom_one.h" +# include "boom_random.h" +# include "boom_procrast.h" +# include "boom_burgun.h" +# include "boom_gradient.h" +# include "boom_simul.h" +# include "boom_anneal.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimize | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimize( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + beaux_list *BehAux; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomBehCreateAuxInit( BehFigure ); + + if ( FigInfo->OPTIM_ALGORITHM == BOOM_OPTIM_ALGORITHM_NOTHING ) + { + return; + } + + BddSystem = createbddsystem( 1000, 20000, 100, 10000000 ); + + if ( ! BoomDebugFlag ) + { + SetBddSystemNoWarning( BddSystem ); + } + + reorderbddsystemdynamic( BddSystem, reorderbddsystemwindow, 100000, 50 ); + /* + explosionbddsystemdynamic( BddSystem, NULL, 50 ); + */ + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\t--> Translate Abl to Bdd\n" ); + } + + BoomBehAbl2BddNode( BehFigure, FigInfo->INIT_BDD_ORDER, FigInfo->DONT_CARE ); + reorderbddsystemdynamic( BddSystem, garbagebddsystem, 100000, 50 ); + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\t Total Bdd nodes %ld\n\n", BddSystem->NUMBER_NODE ); + } + + if ( FigInfo->DONT_CARE ) + { + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\t Optimize don't care\n" ); + } + + BoomOptimDontCare( BehFigure ); + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\t Total Bdd nodes %ld\n\n", BddSystem->NUMBER_NODE ); + } + } + + BehAux = BehFigure->BEAUX; + +/*\ + while ( testbddcircuit( (bddcircuit *)0 ) ) + { + BehAux = BoomOptimComputeAux( BehFigure, BehAux ); + + Cost = BoomBehGiveCost( BehFigure ); + fprintf( stdout, "New cost %d\n", Cost ); + } +\*/ + + switch ( FigInfo->OPTIM_ALGORITHM ) + { + case BOOM_OPTIM_ALGORITHM_SIMPLE : BoomBehOptimizeSimple( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_WINDOW : BoomBehOptimizeWindow( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_TOP : BoomBehOptimizeTop( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_ONE : BoomBehOptimizeOne( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_PROCRAST : BoomBehOptimizeProcrast( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_BURGUN : BoomBehOptimizeBurgun( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_RANDOM : BoomBehOptimizeRandom( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_GRADIENT : BoomBehOptimizeGradient( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_SIMUL : BoomBehOptimizeSimul( BehFigure ); + break; + + case BOOM_OPTIM_ALGORITHM_ANNEAL : BoomBehOptimizeAnneal( BehFigure ); + break; + } + + BoomBehResetBddNode( BehFigure ); + + BddCircuit = BehFigure->CIRCUI; + BehFigure->CIRCUI = (bddcircuit *)0; + + destroybddcircuit( BddCircuit ); + destroybddsystem( BddSystem ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + ClearBoomBehAuxKeep( BehAux ); + ClearBoomBehAuxDontTouch( BehAux ); + } + + BoomBehDeleteUselessAux( BehFigure, (beaux_list *)0, 1 ); + + BoomBehMapAbl( BehFigure, simpablexpr, 1 ); +} diff --git a/alliance/src/boom/src/boom_optim.h b/alliance/src/boom/src/boom_optim.h new file mode 100644 index 00000000..e46d089f --- /dev/null +++ b/alliance/src/boom/src/boom_optim.h @@ -0,0 +1,79 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU 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 : BOOM | +| | +| File : boom_optim.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_OPTIM_H +# define BOOM_OPTIM_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_OPTIM_REORDER_123 0 +# define BOOM_OPTIM_REORDER_213 1 +# define BOOM_OPTIM_REORDER_231 2 +# define BOOM_OPTIM_REORDER_321 3 +# define BOOM_OPTIM_REORDER_312 4 +# define BOOM_OPTIM_REORDER_132 5 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimize(); + +# endif diff --git a/alliance/src/boom/src/boom_order.c b/alliance/src/boom/src/boom_order.c new file mode 100644 index 00000000..4579903c --- /dev/null +++ b/alliance/src/boom/src/boom_order.c @@ -0,0 +1,155 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU 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 : Boom | +| | +| File : boom_order.c | +| | +| Date : 06.06.00 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABT_H + +# include +# include "boom_error.h" +# include "boom_shared.h" +# include "boom_order.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Beh Make Bdd Order | +| | +\------------------------------------------------------------*/ + +void BoomBehMakeBddOrder( BehFigure, OrderFlag, DontCareFlag ) + + befig_list *BehFigure; + int OrderFlag; + int DontCareFlag; +{ + berin_list *BehRin; + boombefiginfo *FigInfo; + chain_list *ScanOrder; + bddindex BddIndex; + authtable *HahsRin; + authelem *Element; + /* + beaux_list *BehAux; + beout_list *BehOut; + bebus_list *BehBus; + bebux_list *BehBux; + bereg_list *BehReg; + biabl_list *BiAbl; + */ + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + HahsRin = createauthtable( 100 ); + + for ( BehRin = BehFigure->BERIN; + BehRin != (berin_list *)0; + BehRin = BehRin->NEXT ) + { + addauthelem( HahsRin, BehRin->NAME, (long)BehRin ); + } + + for ( ScanOrder = FigInfo->BDD_ORDER_LIST; + ScanOrder != (chain_list *)0; + ScanOrder = ScanOrder->NEXT ) + { + Element = searchauthelem( HahsRin, (char *)ScanOrder->DATA ); + + if ( Element != (authelem *)0 ) + { + BehRin = (berin_list *)Element->VALUE; + SetBoomBehRinOrder( BehRin ); + + BddIndex = BddLocalCircuit->NUMBER_NAME_IN + BDD_INDEX_MIN; + addbddcircuitin( (bddcircuit *)0, BehRin->NAME, BddIndex, + BDD_IN_MODE_IMPOSE | BDD_IN_MODE_LAST ); + } + } + + destroyauthtable( HahsRin ); + + if ( OrderFlag ) + { + BehFigure->BERIN = (berin_list *)reverse( (chain_list *)BehFigure->BERIN ); + } + + for ( BehRin = BehFigure->BERIN; + BehRin != (berin_list *)0; + BehRin = BehRin->NEXT ) + { + if ( IsBoomBehRinOrder( BehRin ) ) continue; + + BddIndex = BddLocalCircuit->NUMBER_NAME_IN + BDD_INDEX_MIN; + addbddcircuitin( (bddcircuit *)0, BehRin->NAME, BddIndex, + BDD_IN_MODE_IMPOSE | BDD_IN_MODE_LAST ); + } + + if ( OrderFlag ) + { + BehFigure->BERIN = (berin_list *)reverse( (chain_list *)BehFigure->BERIN ); + } + + if ( DontCareFlag ) + { + FigInfo->BDD_DONT_CARE = addbddcircuitin( (bddcircuit *)0, + ABL_ATOM_NAME_DC, 0, BDD_IN_MODE_LAST ); + } +} diff --git a/alliance/src/boom/src/boom_order.h b/alliance/src/boom/src/boom_order.h new file mode 100644 index 00000000..93df25ea --- /dev/null +++ b/alliance/src/boom/src/boom_order.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 : BOOM | +| | +| File : boom_order.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_ORDER_H +# define BOOM_ORDER_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehMakeBddOrder(); + +# endif diff --git a/alliance/src/boom/src/boom_param.c b/alliance/src/boom/src/boom_param.c new file mode 100644 index 00000000..7899f786 --- /dev/null +++ b/alliance/src/boom/src/boom_param.c @@ -0,0 +1,592 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_param.c | +| | +| Author : Ludovic Jacomme | +| | +| Date : 03/07/2000 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_shared.h" +# include "boom_debug.h" +# include "boom_param.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *BoomHashAux = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomParseSetExprKeepAux | +| | +\------------------------------------------------------------*/ + +static void BoomParseSetExprKeepAux( Expr ) + + ablexpr *Expr; +{ + char *Value; + beaux_list *BehAux; + authelem *Element; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + + if ( ( Value != ABL_ATOM_NAME_ONE ) && + ( Value != ABL_ATOM_NAME_ZERO ) && + ( Value != ABL_ATOM_NAME_DC ) && + ( Value != ABL_ATOM_NAME_TRISTATE ) ) + { + Element = searchauthelem( BoomHashAux, Value ); + + if ( Element != (authelem *)0 ) + { + BehAux = (beaux_list *)Element->VALUE; + SetBoomBehAuxKeep( BehAux ); + } + } + } + + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + BoomParseSetExprKeepAux( ABL_CAR( Expr ) ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomParseSetBiAblKeepAux | +| | +\------------------------------------------------------------*/ + +static void BoomParseSetBiAblKeepAux( BiAbl ) + + biabl_list *BiAbl; +{ + while ( BiAbl != (biabl_list *)0 ) + { + if ( BiAbl->CNDABL != (ablexpr *)0 ) + { + BoomParseSetExprKeepAux( BiAbl->CNDABL ); + } + + if ( BiAbl->VALABL != (ablexpr *)0 ) + { + BoomParseSetExprKeepAux( BiAbl->VALABL ); + } + + BiAbl = BiAbl->NEXT; + } +} + +/*------------------------------------------------------------\ +| | +| BoomParseCheckParam | +| | +\------------------------------------------------------------*/ + +void BoomParseCheckParam( BehFigure, FileName ) + + befig_list *BehFigure; + char *FileName; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + bereg_list *BehReg; + beout_list *BehOut; + bebux_list *BehBux; + bebus_list *BehBus; + berin_list *BehRin; + chain_list **PrevChain; + chain_list *ScanChain; + chain_list *DelChain; + authtable *HashOut; + authtable *HashReg; + authtable *HashBux; + authtable *HashBus; + authtable *HashRin; + authelem *Element; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + BoomHashAux = createauthtable( 100 ); + + HashOut = createauthtable( 100 ); + HashReg = createauthtable( 100 ); + HashBux = createauthtable( 100 ); + HashBus = createauthtable( 100 ); + HashRin = createauthtable( 100 ); + + for ( BehRin = BehFigure->BERIN; + BehRin != (berin_list *)0; + BehRin = BehRin->NEXT ) + { + addauthelem( HashRin, BehRin->NAME, (long)BehRin ); + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + addauthelem( BoomHashAux, BehAux->NAME, (long)BehAux ); + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + addauthelem( HashOut, BehOut->NAME, (long)BehOut ); + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + addauthelem( HashReg, BehReg->NAME, (long)BehReg ); + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + addauthelem( HashBux, BehBux->NAME, (long)BehBux ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + addauthelem( HashBus, BehBus->NAME, (long)BehBus ); + } + + PrevChain = &FigInfo->KEEP_LIST; + ScanChain = FigInfo->KEEP_LIST; + + while ( ScanChain != (chain_list *)0 ) + { + Element = searchauthelem( BoomHashAux, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehAux = (beaux_list *)Element->VALUE; + SetBoomBehAuxKeep( BehAux ); + + fprintf( stderr, "\t keep signal '%s'\n", BehAux->NAME ); + } + else + { + fprintf( stderr, "\t### unknown signal '%s' in parameter file %s.boom\n", + (char *)ScanChain->DATA, FileName ); + + *PrevChain = ScanChain->NEXT; + DelChain = ScanChain; + ScanChain = ScanChain->NEXT; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + } + + PrevChain = &FigInfo->DONT_TOUCH_LIST; + ScanChain = FigInfo->DONT_TOUCH_LIST; + + while ( ScanChain != (chain_list *)0 ) + { + Element = searchauthelem( BoomHashAux, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehAux = (beaux_list *)Element->VALUE; + SetBoomBehAuxDontTouch( BehAux ); + SetBoomBehAuxKeep( BehAux ); + + BoomParseSetExprKeepAux( BehAux->ABL ); + + continue; + } + + Element = searchauthelem( HashOut, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehOut = (beout_list *)Element->VALUE; + SetBoomBehAuxDontTouch( BehOut ); + + BoomParseSetExprKeepAux( BehOut->ABL ); + + continue; + } + + Element = searchauthelem( HashReg, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehReg = (bereg_list *)Element->VALUE; + SetBoomBehAuxDontTouch( BehReg ); + + BoomParseSetBiAblKeepAux( BehReg->BIABL ); + + continue; + } + + Element = searchauthelem( HashBus, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehBus = (bebus_list *)Element->VALUE; + SetBoomBehAuxDontTouch( BehBus ); + + BoomParseSetBiAblKeepAux( BehBus->BIABL ); + + continue; + } + + Element = searchauthelem( HashBux, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehBux = (bebux_list *)Element->VALUE; + SetBoomBehAuxDontTouch( BehBux ); + + BoomParseSetBiAblKeepAux( BehBux->BIABL ); + + continue; + } + + if ( Element == (authelem *)0 ) + { + fprintf( stderr, "\t### unknown signal '%s' in parameter file %s.boom\n", + (char *)ScanChain->DATA, FileName ); + + *PrevChain = ScanChain->NEXT; + DelChain = ScanChain; + ScanChain = ScanChain->NEXT; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + } + + FigInfo->BDD_ORDER_LIST = reverse( FigInfo->BDD_ORDER_LIST ); + + PrevChain = &FigInfo->BDD_ORDER_LIST; + ScanChain = FigInfo->BDD_ORDER_LIST; + + while ( ScanChain != (chain_list *)0 ) + { + Element = searchauthelem( HashRin, (char *)ScanChain->DATA ); + + if ( Element != (authelem *)0 ) + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + + BehRin = (berin_list *)Element->VALUE; + SetBoomBehRinOrder( BehRin ); + + fprintf( stderr, "\t order input/signal/register '%s'\n", BehRin->NAME ); + } + else + { + fprintf( stderr, "\t### unknown signal '%s' in parameter file %s.boom\n", + (char *)ScanChain->DATA, FileName ); + + *PrevChain = ScanChain->NEXT; + DelChain = ScanChain; + ScanChain = ScanChain->NEXT; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + } + + destroyauthtable( HashReg ); + destroyauthtable( HashOut ); + destroyauthtable( HashBus ); + destroyauthtable( HashBux ); + destroyauthtable( HashRin ); + + destroyauthtable( BoomHashAux ); + BoomHashAux = (authtable *)0; +} + +/*------------------------------------------------------------\ +| | +| BoomParseParamFile | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomParseGetWord | +| | +\------------------------------------------------------------*/ + +static char *BoomParseGetWord( Buffer ) + + char *Buffer; +{ + char *String; + + if ( ( String = (char *)strtok( Buffer, " =,\t\n" ) ) != (char *)0 ) + { + String = namealloc( String ); + } + + return( String ); +} + +/*------------------------------------------------------------\ +| | +| BoomParseParamFile | +| | +\------------------------------------------------------------*/ + +void BoomParseParamFile( BehFigure, FileName ) + + befig_list *BehFigure; + char *FileName; +{ + boombefiginfo *FigInfo; + chain_list **PrevChain; + char *FirstWord; + char *Scan; + char *Pointer; + char *RegisterName; + int Left; + int Right; + int Step; + int Index; + int CurrentDef; + long LineNumber; + FILE *ParamFile; + char ParamBuffer[ 512 ]; + char Buffer[ 128 ]; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + FileName = autbasename( FileName, "boom" ); + ParamFile = mbkfopen( FileName, "boom", "r" ); + + if ( ParamFile == (FILE *)0 ) + { + fprintf( stderr, "\t### Unable to parse parameter file %s.boom\n", FileName ); + autexit( 1 ); + } + + LineNumber = 0; + CurrentDef = BOOM_PARAM_NONE; + + while ( fgets( ParamBuffer, 512, ParamFile ) != (char *)0 ) + { + LineNumber++; + + if ( ParamBuffer[ 0 ] == '#' ) continue; + + FirstWord = BoomParseGetWord( ParamBuffer ); + + if ( FirstWord == (char *)0 ) continue; + + if ( ! strncmp( FirstWord, "end", 3 ) ) CurrentDef = BOOM_PARAM_NONE; + else + if ( CurrentDef != BOOM_PARAM_NONE ) + { + /* + if ( CurrentDef == BOOM_PARAM_CLOCK ) + { + SecondWord = BoomParseGetWord( (char *)0 ); + + if ( SecondWord == (char *)0 ) + { + fprintf( stderr, "Syntax error line %ld in parameter file %s.boom\n", + LineNumber, FileName ); + autexit( 1 ); + } + } + else + */ + if ( ( CurrentDef == BOOM_PARAM_KEEP_AUX ) || + ( CurrentDef == BOOM_PARAM_DONT_TOUCH_AUX ) || + ( CurrentDef == BOOM_PARAM_BDD_ORDER ) ) + { + if ( CurrentDef == BOOM_PARAM_KEEP_AUX ) PrevChain = &FigInfo->KEEP_LIST; + else + if ( CurrentDef == BOOM_PARAM_BDD_ORDER ) PrevChain = &FigInfo->BDD_ORDER_LIST; + else + PrevChain = &FigInfo->DONT_TOUCH_LIST; + do + { + Scan = strchr( FirstWord, '[' ); + if ( Scan == NULL ) Scan = strchr( FirstWord, '(' ); + + if ( Scan != NULL ) + { + strcpy( Buffer, FirstWord ); + Scan = Buffer; + + Pointer = strchr( Scan, '[' ); + if ( Pointer == NULL ) Pointer = strchr( Scan, '(' ); + *Pointer = '\0'; + + RegisterName = namealloc( Buffer ); + Scan = Pointer + 1; + + Pointer = strchr( Scan, ':' ); + + if ( Pointer != (char *)0 ) + { + *Pointer = '\0'; + Left = atoi( Scan ); + Scan = Pointer + 1; + + Pointer = strchr( Scan, ']' ); + if ( Pointer == (char *)0 ) Pointer = strchr( Scan, ')' ); + + if ( Pointer == (char *)0 ) + { + fprintf( stderr, "\t### Syntax error line %ld in parameter file %s.boom\n", + LineNumber, FileName ); + autexit(1); + } + + *Pointer = '\0'; + Right = atoi( Scan ); + } + else + { + Left = atoi( Scan ); + Right = Left; + } + + if ( Left < Right ) Step = -1; + else Step = 1; + + for ( Index = Right; Index != (Left + Step) ; Index += Step ) + { + sprintf( Buffer, "%s %d", RegisterName, Index ); + *PrevChain = addchain( *PrevChain, namealloc( Buffer ) ); + } + } + else + { + *PrevChain = addchain( *PrevChain, FirstWord ); + } + } while ( ( FirstWord = BoomParseGetWord( NULL ) ) != NULL ); + } + else + { + fprintf( stderr, "Syntax error line %ld in parameter file %s.boom\n", + LineNumber, FileName ); + autexit( 1 ); + } + } + else + if ( ! strcmp( FirstWord, "begin_keep" ) ) + { + CurrentDef = BOOM_PARAM_KEEP_AUX; + } + else + if ( ! strcmp( FirstWord, "begin_dont_touch" ) ) + { + CurrentDef = BOOM_PARAM_DONT_TOUCH_AUX; + } + else + if ( ! strcmp( FirstWord, "begin_bdd_order" ) ) + { + CurrentDef = BOOM_PARAM_BDD_ORDER; + } + else + { + fprintf( stderr, "Syntax error line %ld in parameter file %s.boom\n", + LineNumber, FileName ); + autexit( 1 ); + } + } + + fclose( ParamFile ); + + BoomParseCheckParam( BehFigure, FileName ); +} diff --git a/alliance/src/boom/src/boom_param.h b/alliance/src/boom/src/boom_param.h new file mode 100644 index 00000000..c6065f27 --- /dev/null +++ b/alliance/src/boom/src/boom_param.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 : BOOM | +| | +| File : boom_param.h | +| | +| Author : Ludovic Jacomme | +| | +| Date : 03/07/2000 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_PARAM_H +# define BOOM_PARAM_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_PARAM_NONE 0 +# define BOOM_PARAM_KEEP_AUX 1 +# define BOOM_PARAM_DONT_TOUCH_AUX 2 +# define BOOM_PARAM_BDD_ORDER 3 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomParseParamFile(); + +# endif diff --git a/alliance/src/boom/src/boom_parse.c b/alliance/src/boom/src/boom_parse.c new file mode 100644 index 00000000..d3c1f482 --- /dev/null +++ b/alliance/src/boom/src/boom_parse.c @@ -0,0 +1,150 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_parse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_parse.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_abl.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomParseBehFigure | +| | +\------------------------------------------------------------*/ + +befig_list *BoomParseBehFigure( FileName ) + + char *FileName; +{ + befig_list *BehFigure; + beaux_list *BehAux; + beout_list *BehOut; + bereg_list *BehReg; + bebux_list *BehBux; + bebus_list *BehBus; + + BehFigure = vhdlloadbefig( (befig_list *)0, FileName, 2 ); + + if ( BehFigure->ERRFLG ) + { + fprintf( stderr, "\t### Unable to compile file %s.vbe\n", FileName ); + autexit( 1 ); + } + + BoomAddBehFigInfo( BehFigure ); + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + BoomAddBehAuxInfo( BehAux ); + } + + for ( BehBux = BehFigure->BEBUX; + BehBux != (bebux_list *)0; + BehBux = BehBux->NEXT ) + { + BoomAddBehBuxInfo( BehBux ); + } + + for ( BehBus = BehFigure->BEBUS; + BehBus != (bebus_list *)0; + BehBus = BehBus->NEXT ) + { + BoomAddBehBusInfo( BehBus ); + } + + for ( BehOut = BehFigure->BEOUT; + BehOut != (beout_list *)0; + BehOut = BehOut->NEXT ) + { + BoomAddBehOutInfo( BehOut ); + } + + for ( BehReg = BehFigure->BEREG; + BehReg != (bereg_list *)0; + BehReg = BehReg->NEXT ) + { + BoomAddBehRegInfo( BehReg ); + } + + beh_frebeaux( BehFigure->BEDLY ); + BehFigure->BEDLY = (beaux_list *)0; + + BoomBehMapAbl( BehFigure, simpablexpr, 1 ); + + return( BehFigure ); +} diff --git a/alliance/src/boom/src/boom_parse.h b/alliance/src/boom/src/boom_parse.h new file mode 100644 index 00000000..ffbb29b6 --- /dev/null +++ b/alliance/src/boom/src/boom_parse.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 : BOOM | +| | +| File : boom_parse.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_PARSE_H +# define BOOM_PARSE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern befig_list *BoomParseBehFigure(); + +# endif diff --git a/alliance/src/boom/src/boom_post.c b/alliance/src/boom/src/boom_post.c new file mode 100644 index 00000000..14f82839 --- /dev/null +++ b/alliance/src/boom/src/boom_post.c @@ -0,0 +1,160 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_post.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_abl.h" +# include "boom_post.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static authtable *BoomHashRename = (authtable *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomRenameAuxVectorAbl | +| | +\------------------------------------------------------------*/ + +static void BoomRenameAuxVectorAbl( Expr ) + + ablexpr *Expr; +{ + authelem *Element; + char *Value; + + if ( ABL_ATOM( Expr ) ) + { + Value = ABL_ATOM_VALUE( Expr ); + + if ( ( Value != ABL_ATOM_NAME_ONE ) && + ( Value != ABL_ATOM_NAME_ZERO ) && + ( Value != ABL_ATOM_NAME_DC ) && + ( Value != ABL_ATOM_NAME_TRISTATE ) ) + { + Element = searchauthelem( BoomHashRename, Value ); + + if ( Element != (authelem *)0 ) + { + ABL_ATOM_VALUE( Expr ) = (char *)Element->VALUE; + } + } + + return; + } + + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + BoomRenameAuxVectorAbl( ABL_CAR( Expr ) ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomPostTreatBehFigure | +| | +\------------------------------------------------------------*/ + +void BoomPostTreatBehFigure( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + char Buffer[ 512 ]; + char *Scan; + + if ( BoomHashRename == (authtable *)0 ) + { + BoomHashRename = createauthtable( 100 ); + } + + for ( BehAux = BehFigure->BEAUX; + BehAux != (beaux_list *)0; + BehAux = BehAux->NEXT ) + { + if ( strchr( BehAux->NAME, ' ' ) != (char *)0 ) + { + strcpy( Buffer, BehAux->NAME ); + Scan = strchr( Buffer, ' ' ); + *Scan = '_'; + + Scan = namealloc( Buffer ); + addauthelem( BoomHashRename, BehAux->NAME, (long)Scan ); + BehAux->NAME = Scan; + } + } + + BoomBehScanAbl( BehFigure, BoomRenameAuxVectorAbl, 1 ); + + resetauthtable( BoomHashRename ); +} diff --git a/alliance/src/boom/src/boom_post.h b/alliance/src/boom/src/boom_post.h new file mode 100644 index 00000000..945e107e --- /dev/null +++ b/alliance/src/boom/src/boom_post.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 : BOOM | +| | +| File : boom_post.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_POST_H +# define BOOM_POST_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomPostTreatBehFigure(); + +# endif diff --git a/alliance/src/boom/src/boom_procrast.c b/alliance/src/boom/src/boom_procrast.c new file mode 100644 index 00000000..629e5730 --- /dev/null +++ b/alliance/src/boom/src/boom_procrast.c @@ -0,0 +1,258 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_procrast.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_window.h" +# include "boom_procrast.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeProcrast | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeProcrast( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + bddvar NumberChild; + bddvar ChildTo; + bddvar ChildFrom; + long Cost; + long NewCost; + long NumberNode; + long NewNumberNode; + long LastNewNumberNode; + long Iteration; + long MaxIteration; + int Level; + long MaxNode; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + Level = FigInfo->OPTIM_LEVEL; + + if ( MaxIteration <= 0 ) MaxIteration = 2; + + MaxIteration = MaxIteration * (Level + 1); + + NumberChild = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + NumberNode = BoomBehGetNumberBigBddNode( BehFigure ); + + MaxNode = ( BddLocalSystem->NUMBER_NODE * 120 ) / 100; + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld %ld\n", Cost, NumberNode ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Iteration %ld\n", Iteration ); + } + + ChildFrom = 0; + + for ( ChildFrom = 0; ChildFrom < (NumberChild - 1); ChildFrom++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> ChildFrom %d\n", ChildFrom ); + } + + for ( ChildTo = ChildFrom; ChildTo < ( NumberChild - 1 ); ChildTo++ ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", ChildTo, ChildTo + 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo ); + + /* + NewNumberNode = BoomBehGetNumberBigBddNode( BehFigure ); + + BoomPrintf( stdout, "NewNumberNode: %ld\n", NewNumberNode ); + */ + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + garbagebddsystem( BddLocalSystem ); + } + + if ( BddLocalSystem->NUMBER_NODE >= MaxNode ) + { + BoomPrintf( stdout, "@@@@ Max nodes %ld reached %ld\n", + MaxNode, BddLocalSystem->NUMBER_NODE ); + break; + } + } + + NewNumberNode = BoomBehGetNumberBigBddNode( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewNumberNode: %ld\n", NewNumberNode ); + } + + /* + if ( NewNumberNode <= NumberNode ) + */ + if ( ( NewNumberNode != NumberNode ) && + ( NewNumberNode != LastNewNumberNode ) && + ( NewNumberNode <= ( NumberNode * 105 ) / 100 ) ) + { + if ( NewNumberNode < NumberNode ) NumberNode = NewNumberNode; + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld %ld\n", NewCost, NumberNode ); + } + } + else + { + NewCost = Cost + 1; + } + + LastNewNumberNode = NewNumberNode; + + if ( NewCost > Cost ) + { + while ( ChildTo > ChildFrom ) + { + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> UnSwap %d and %d\n", ChildTo, ChildTo - 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo - 1 ); + + ChildTo = ChildTo - 1; + } + } + else + { + Cost = NewCost; + } + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3ld\b\b\b", ( ( Iteration + 1 ) * 100 ) / MaxIteration ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + diff --git a/alliance/src/boom/src/boom_procrast.h b/alliance/src/boom/src/boom_procrast.h new file mode 100644 index 00000000..03d9dbdd --- /dev/null +++ b/alliance/src/boom/src/boom_procrast.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 : BOOM | +| | +| File : boom_procrast.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_PROCRAST_H +# define BOOM_PROCRAST_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeProcrast(); + +# endif diff --git a/alliance/src/boom/src/boom_random.c b/alliance/src/boom/src/boom_random.c new file mode 100644 index 00000000..1ac8ddd8 --- /dev/null +++ b/alliance/src/boom/src/boom_random.c @@ -0,0 +1,249 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_random.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_window.h" +# include "boom_random.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeRandom | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeRandom( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + long MaxIteration; + bddvar NumberVar; + bddvar BddVar; + int Iteration; + long Cost; + + static unsigned char InitOptimizeRandom = 1; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + + if ( InitOptimizeRandom ) + { + srand( getpid() ); + InitOptimizeRandom = 0; + } + + NumberVar = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld, NumberVar %d\n", Cost, NumberVar ); + } + + if ( MaxIteration <= 0 ) MaxIteration = NumberVar; + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + BddVar = (rand() >> 8) % (NumberVar - 1); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Swap %d\n", BddVar ); + } + + BoomBehReorderWindow2( BehFigure, BehAux, BddVar, &Cost ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "New cost %ld\n", Cost ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3ld\b\b\b", ( ( Iteration + 1 ) * 100 ) / MaxIteration ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + +# if 0 +void BoomBehOptimizeRandom( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + long MaxIteration; + bddvar NumberVar; + bddvar BddVar; + int Iteration; + int Amplitude; + int Swap; + long Cost; + + static unsigned char InitOptimizeRandom = 1; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + + if ( InitOptimizeRandom ) + { + srand( getpid() ); + InitOptimizeRandom = 0; + } + + NumberVar = BddLocalSystem->NUMBER_VAR; + + /* + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + */ + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld, NumberVar %d\n", Cost, NumberVar ); + } + + /* + if ( MaxIteration <= 0 ) MaxIteration = NumberVar; + */ + MaxIteration = 1 + ( ( NumberVar + 2 ) / 2 ); + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + if ( Iteration != 0 ) + { + BoomBehMakeBddNode( BehFigure, 0 ); + } + + for ( BddVar = 0; BddVar < ( NumberVar - 1 ); BddVar++ ) + { + Amplitude = (rand() >> 8) % 8; + + for ( Swap = 0; Swap < Amplitude; Swap++ ) + { + if ( ( BddVar + Swap ) >= ( NumberVar - 1 ) ) break; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", BddVar + Swap, BddVar + Swap + 1 ); + } + + swapbddvar( (bddsystem *)0, BddVar + Swap ); + } + } + + BoomOptimizeProcrast( BehFigure ); + } + + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} +# endif + diff --git a/alliance/src/boom/src/boom_random.h b/alliance/src/boom/src/boom_random.h new file mode 100644 index 00000000..6db6ef85 --- /dev/null +++ b/alliance/src/boom/src/boom_random.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_random.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_RANDOM_H +# define BOOM_RANDOM_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeRandom(); + +# endif diff --git a/alliance/src/boom/src/boom_shared.c b/alliance/src/boom/src/boom_shared.c new file mode 100644 index 00000000..22fec700 --- /dev/null +++ b/alliance/src/boom/src/boom_shared.c @@ -0,0 +1,509 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_shared.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include "boom_error.h" +# include "boom_shared.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + int BoomFlagDebug = 0; + int BoomFlagOption = 0; + + char *BoomOptimAlgorithmName[ BOOM_MAX_OPTIM_ALGORITHM ] = + { + "top bdd reorder", + "window bdd reorder", + "simple bdd reorder", + "one pass", + "random bdd reorder", + "procrastination", + "Luc Burgun", + "no optimization algorithm", + "gradient", + "just do it", + "simulated annealing" + }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomAddBehAuxInfo | +| | +\------------------------------------------------------------*/ + +boombeauxinfo *BoomAddBehAuxInfo( BehAux ) + + beaux_list *BehAux; +{ + boombeauxinfo *AuxInfo; + + AuxInfo = (boombeauxinfo *)autallocheap( sizeof( boombeauxinfo ) ); + + SetBoomBehAuxInfo( BehAux, AuxInfo ); + + return( AuxInfo ); +} + +/*------------------------------------------------------------\ +| | +| BoomDelBehAuxInfo | +| | +\------------------------------------------------------------*/ + +void BoomDelBehAuxInfo( BehAux ) + + beaux_list *BehAux; +{ + boombeauxinfo *AuxInfo; + + AuxInfo = GetBoomBehAuxInfo( BehAux ); + + if ( AuxInfo != (boombeauxinfo *)0 ) + { + autfreeheap( AuxInfo, sizeof( boombeauxinfo ) ); + SetBoomBehAuxInfo( BehAux, NULL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehFreeBehAux | +| | +\------------------------------------------------------------*/ + +void BoomBehFreeBehAux( BehAux ) + + beaux_list *BehAux; +{ + beaux_list *ScanBehAux; + + for ( ScanBehAux = BehAux; + ScanBehAux != (beaux_list *)0; + ScanBehAux = ScanBehAux->NEXT ) + { + BoomDelBehAuxInfo( ScanBehAux ); + } + + beh_frebeaux( BehAux ); +} + +/*------------------------------------------------------------\ +| | +| BoomAddBehOutInfo | +| | +\------------------------------------------------------------*/ + +boombeoutinfo *BoomAddBehOutInfo( BehOut ) + + beout_list *BehOut; +{ + boombeoutinfo *OutInfo; + + OutInfo = (boombeoutinfo *)autallocheap( sizeof( boombeoutinfo ) ); + + SetBoomBehOutInfo( BehOut, OutInfo ); + + return( OutInfo ); +} + +/*------------------------------------------------------------\ +| | +| BoomDelBehOutInfo | +| | +\------------------------------------------------------------*/ + +void BoomDelBehOutInfo( BehOut ) + + beout_list *BehOut; +{ + boombeoutinfo *OutInfo; + + OutInfo = GetBoomBehOutInfo( BehOut ); + + if ( OutInfo != (boombeoutinfo *)0 ) + { + autfreeheap( OutInfo, sizeof( boombeoutinfo ) ); + SetBoomBehOutInfo( BehOut, NULL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehFreeBehOut | +| | +\------------------------------------------------------------*/ + +void BoomBehFreeBehOut( BehOut ) + + beout_list *BehOut; +{ + beout_list *ScanBehOut; + + for ( ScanBehOut = BehOut; + ScanBehOut != (beout_list *)0; + ScanBehOut = ScanBehOut->NEXT ) + { + BoomDelBehOutInfo( ScanBehOut ); + } + + beh_frebeout( BehOut ); +} + +/*------------------------------------------------------------\ +| | +| BoomAddBehRegInfo | +| | +\------------------------------------------------------------*/ + +boombereginfo *BoomAddBehRegInfo( BehReg ) + + bereg_list *BehReg; +{ + boombereginfo *RegInfo; + + RegInfo = (boombereginfo *)autallocheap( sizeof( boombereginfo ) ); + + SetBoomBehRegInfo( BehReg, RegInfo ); + + return( RegInfo ); +} + +/*------------------------------------------------------------\ +| | +| BoomDelBehRegInfo | +| | +\------------------------------------------------------------*/ + +void BoomDelBehRegInfo( BehReg ) + + bereg_list *BehReg; +{ + boombereginfo *RegInfo; + + RegInfo = GetBoomBehRegInfo( BehReg ); + + if ( RegInfo != (boombereginfo *)0 ) + { + autfreeheap( RegInfo, sizeof( boombereginfo ) ); + SetBoomBehRegInfo( BehReg, NULL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehFreeBehReg | +| | +\------------------------------------------------------------*/ + +void BoomBehFreeBehReg( BehReg ) + + bereg_list *BehReg; +{ + bereg_list *ScanBehReg; + + for ( ScanBehReg = BehReg; + ScanBehReg != (bereg_list *)0; + ScanBehReg = ScanBehReg->NEXT ) + { + BoomDelBehRegInfo( ScanBehReg ); + } + + beh_frebereg( BehReg ); +} + +/*------------------------------------------------------------\ +| | +| BoomAddBehBusInfo | +| | +\------------------------------------------------------------*/ + +boombebusinfo *BoomAddBehBusInfo( BehBus ) + + bebus_list *BehBus; +{ + boombebusinfo *BusInfo; + + BusInfo = (boombebusinfo *)autallocheap( sizeof( boombebusinfo ) ); + + SetBoomBehBusInfo( BehBus, BusInfo ); + + return( BusInfo ); +} + +/*------------------------------------------------------------\ +| | +| BoomDelBehBusInfo | +| | +\------------------------------------------------------------*/ + +void BoomDelBehBusInfo( BehBus ) + + bebus_list *BehBus; +{ + boombebusinfo *BusInfo; + + BusInfo = GetBoomBehBusInfo( BehBus ); + + if ( BusInfo != (boombebusinfo *)0 ) + { + autfreeheap( BusInfo, sizeof( boombebusinfo ) ); + SetBoomBehBusInfo( BehBus, NULL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehFreeBehBus | +| | +\------------------------------------------------------------*/ + +void BoomBehFreeBehBus( BehBus ) + + bebus_list *BehBus; +{ + bebus_list *ScanBehBus; + + for ( ScanBehBus = BehBus; + ScanBehBus != (bebus_list *)0; + ScanBehBus = ScanBehBus->NEXT ) + { + BoomDelBehBusInfo( ScanBehBus ); + } + + beh_frebebus( BehBus ); +} + + +/*------------------------------------------------------------\ +| | +| BoomAddBehBuxInfo | +| | +\------------------------------------------------------------*/ + +boombebuxinfo *BoomAddBehBuxInfo( BehBux ) + + bebux_list *BehBux; +{ + boombebuxinfo *BuxInfo; + + BuxInfo = (boombebuxinfo *)autallocheap( sizeof( boombebuxinfo ) ); + + SetBoomBehBuxInfo( BehBux, BuxInfo ); + + return( BuxInfo ); +} + +/*------------------------------------------------------------\ +| | +| BoomDelBehBuxInfo | +| | +\------------------------------------------------------------*/ + +void BoomDelBehBuxInfo( BehBux ) + + bebux_list *BehBux; +{ + boombebuxinfo *BuxInfo; + + BuxInfo = GetBoomBehBuxInfo( BehBux ); + + if ( BuxInfo != (boombebuxinfo *)0 ) + { + autfreeheap( BuxInfo, sizeof( boombebuxinfo ) ); + SetBoomBehBuxInfo( BehBux, NULL ); + } +} + +/*------------------------------------------------------------\ +| | +| BoomBehFreeBehBux | +| | +\------------------------------------------------------------*/ + +void BoomBehFreeBehBux( BehBux ) + + bebux_list *BehBux; +{ + bebux_list *ScanBehBux; + + for ( ScanBehBux = BehBux; + ScanBehBux != (bebux_list *)0; + ScanBehBux = ScanBehBux->NEXT ) + { + BoomDelBehBuxInfo( ScanBehBux ); + } + + beh_frebebux( BehBux ); +} + +/*------------------------------------------------------------\ +| | +| BoomAddBehFigInfo | +| | +\------------------------------------------------------------*/ + +boombefiginfo *BoomAddBehFigInfo( BehFig ) + + befig_list *BehFig; +{ + boombefiginfo *FigInfo; + + FigInfo = (boombefiginfo *)autallocheap( sizeof( boombefiginfo ) ); + + SetBoomBehFigInfo( BehFig, FigInfo ); + + return( FigInfo ); +} + +/*------------------------------------------------------------\ +| | +| BoomDelBehFigInfo | +| | +\------------------------------------------------------------*/ + +void BoomDelBehFigInfo( BehFig ) + + befig_list *BehFig; +{ + boombefiginfo *FigInfo; + + FigInfo = GetBoomBehFigInfo( BehFig ); + + if ( FigInfo != (boombefiginfo *)0 ) + { + freechain( FigInfo->KEEP_LIST ); + freechain( FigInfo->DONT_TOUCH_LIST ); + freechain( FigInfo->BDD_ORDER_LIST ); + + autfreeheap( FigInfo, sizeof( boombefiginfo ) ); + SetBoomBehFigInfo( BehFig, NULL ); + } +} + + +/*------------------------------------------------------------\ +| | +| BoomBehFreeBehFig | +| | +\------------------------------------------------------------*/ + +void BoomBehFreeBehFig( BehFig ) + + befig_list *BehFig; +{ + BoomBehFreeBehReg( BehFig->BEREG ); + BoomBehFreeBehOut( BehFig->BEOUT ); + BoomBehFreeBehAux( BehFig->BEAUX ); + BoomBehFreeBehBus( BehFig->BEBUS ); + BoomBehFreeBehBux( BehFig->BEBUX ); + + BehFig->BEOUT = (beout_list *)0; + BehFig->BEREG = (bereg_list *)0; + BehFig->BEAUX = (beaux_list *)0; + BehFig->BEBUS = (bebus_list *)0; + BehFig->BEBUX = (bebux_list *)0; + + BoomDelBehFigInfo( BehFig ); + + BehFig->NEXT = (befig_list *)0; + beh_frebefig( BehFig ); +} + +/*------------------------------------------------------------\ +| | +| BoomComputeLog2 | +| | +\------------------------------------------------------------*/ + +long BoomComputeLog2( Value ) + + unsigned long Value; +{ + unsigned long Mask; + unsigned long Log2; + + Mask = 1; + Log2 = 0; + + while ( Value != 0 ) + { + Value = Value >> 1; + + Log2++; + } + + if ( Log2 > 0 ) Log2--; + + return( Log2 ); +} diff --git a/alliance/src/boom/src/boom_shared.h b/alliance/src/boom/src/boom_shared.h new file mode 100644 index 00000000..466efb5d --- /dev/null +++ b/alliance/src/boom/src/boom_shared.h @@ -0,0 +1,293 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : vasy_shared.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_SHARED_H +# define BOOM_SHARED_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Aux Flags | +| | +\------------------------------------------------------------*/ + +# define BOOM_AUX_KEEP_MASK 0x01 +# define BOOM_AUX_DONT_TOUCH_MASK 0x02 +# define BOOM_AUX_TAG_MASK 0x04 + +/*------------------------------------------------------------\ +| | +| Rin Flags | +| | +\------------------------------------------------------------*/ + +# define BOOM_RIN_ORDER_MASK 0x01 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Aux Flags | +| | +\------------------------------------------------------------*/ + +# define IsBoomBehAuxTag( A ) ((A)->FLAGS & BOOM_AUX_TAG_MASK) +# define SetBoomBehAuxTag( A ) ((A)->FLAGS |= BOOM_AUX_TAG_MASK) +# define ClearBoomBehAuxTag( A ) ((A)->FLAGS &= ~BOOM_AUX_TAG_MASK) + +# define IsBoomBehAuxKeep( A ) ((A)->FLAGS & BOOM_AUX_KEEP_MASK) +# define SetBoomBehAuxKeep( A ) ((A)->FLAGS |= BOOM_AUX_KEEP_MASK) +# define ClearBoomBehAuxKeep( A ) ((A)->FLAGS &= ~BOOM_AUX_KEEP_MASK) + +# define IsBoomBehAuxDontTouch( A ) ((A)->FLAGS & BOOM_AUX_DONT_TOUCH_MASK) +# define SetBoomBehAuxDontTouch( A ) ((A)->FLAGS |= BOOM_AUX_DONT_TOUCH_MASK) +# define ClearBoomBehAuxDontTouch( A ) ((A)->FLAGS &= ~BOOM_AUX_DONT_TOUCH_MASK) + +/*------------------------------------------------------------\ +| | +| Rin Flags | +| | +\------------------------------------------------------------*/ + +# define IsBoomBehRinOrder( R ) ((R)->FLAGS & BOOM_RIN_ORDER_MASK) +# define SetBoomBehRinOrder( R ) ((R)->FLAGS |= BOOM_RIN_ORDER_MASK) +# define ClearBoomBehRinOrder( R ) ((R)->FLAGS &= ~BOOM_RIN_ORDER_MASK) + +/*------------------------------------------------------------\ +| | +| Optimization Algorithm | +| | +\------------------------------------------------------------*/ + +# define BOOM_OPTIM_ALGORITHM_TOP 0 +# define BOOM_OPTIM_ALGORITHM_WINDOW 1 +# define BOOM_OPTIM_ALGORITHM_SIMPLE 2 +# define BOOM_OPTIM_ALGORITHM_ONE 3 +# define BOOM_OPTIM_ALGORITHM_RANDOM 4 +# define BOOM_OPTIM_ALGORITHM_PROCRAST 5 +# define BOOM_OPTIM_ALGORITHM_BURGUN 6 +# define BOOM_OPTIM_ALGORITHM_NOTHING 7 +# define BOOM_OPTIM_ALGORITHM_GRADIENT 8 +# define BOOM_OPTIM_ALGORITHM_SIMUL 9 +# define BOOM_OPTIM_ALGORITHM_ANNEAL 10 + +# define BOOM_MAX_OPTIM_ALGORITHM 11 + +/*------------------------------------------------------------\ +| | +| Beh Fig Info | +| | +\------------------------------------------------------------*/ + +# define SetBoomBehFigInfo( F, I ) ((F)->USER = (void *)(I)) +# define GetBoomBehFigInfo( F ) ((boombefiginfo *)(F)->USER) + +/*------------------------------------------------------------\ +| | +| Beh Aux Info | +| | +\------------------------------------------------------------*/ + +# define SetBoomBehAuxInfo( A, I ) ((A)->USER = (void *)(I)) +# define GetBoomBehAuxInfo( A ) ((boombeauxinfo *)(A)->USER) + +/*------------------------------------------------------------\ +| | +| Beh Out Info | +| | +\------------------------------------------------------------*/ + +# define SetBoomBehOutInfo( A, I ) ((A)->USER = (void *)(I)) +# define GetBoomBehOutInfo( A ) ((boombeoutinfo *)(A)->USER) + +/*------------------------------------------------------------\ +| | +| Beh Reg Info | +| | +\------------------------------------------------------------*/ + +# define SetBoomBehRegInfo( A, I ) ((A)->USER = (void *)(I)) +# define GetBoomBehRegInfo( A ) ((boombereginfo *)(A)->USER) + +/*------------------------------------------------------------\ +| | +| Beh Bus Info | +| | +\------------------------------------------------------------*/ + +# define SetBoomBehBusInfo( A, I ) ((A)->USER = (void *)(I)) +# define GetBoomBehBusInfo( A ) ((boombebusinfo *)(A)->USER) + +/*------------------------------------------------------------\ +| | +| Beh Bux Info | +| | +\------------------------------------------------------------*/ + +# define SetBoomBehBuxInfo( A, I ) ((A)->USER = (void *)(I)) +# define GetBoomBehBuxInfo( A ) ((boombebuxinfo *)(A)->USER) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ + + typedef struct boombeauxinfo + { + long DELAY_COST; + long DEPTH_COST; + long SURFACE_COST; + long LITERAL_COST; + + } boombeauxinfo; + + typedef struct boombeoutinfo + { + long DELAY_COST; + long DEPTH_COST; + long SURFACE_COST; + long LITERAL_COST; + + } boombeoutinfo; + + typedef struct boombereginfo + { + long DELAY_COST; + long DEPTH_COST; + long SURFACE_COST; + long LITERAL_COST; + + } boombereginfo; + + typedef struct boombebusinfo + { + long DELAY_COST; + long DEPTH_COST; + long SURFACE_COST; + long LITERAL_COST; + + } boombebusinfo; + + typedef struct boombebuxinfo + { + long DELAY_COST; + long DEPTH_COST; + long SURFACE_COST; + long LITERAL_COST; + + } boombebuxinfo; + + typedef struct boombefiginfo + { + chain_list *KEEP_LIST; + chain_list *DONT_TOUCH_LIST; + chain_list *BDD_ORDER_LIST; + long SURFACE_COST; + long DEPTH_COST; + long LITERAL_COST; + long GLOBAL_COST; + long INITIAL_SURFACE_COST; + long INITIAL_LITERAL_COST; + long INITIAL_DEPTH_COST; + unsigned char OPTIM_ALGORITHM; + unsigned char OPTIM_LEVEL; + unsigned char OPTIM_DELAY_PERCENT; + unsigned char KEEP_AUX; + unsigned char INIT_BDD_ORDER; + unsigned char VERBOSE; + unsigned char TRACE; + unsigned char USE_LITERAL; + unsigned char DONT_CARE; + bddnode *BDD_DONT_CARE; + int ITERATION; + int AMPLITUDE; + + } boombefiginfo; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern int BoomFlagOption; + extern int BoomFlagDebug; + extern char *BoomOptimAlgorithmName[ BOOM_MAX_OPTIM_ALGORITHM ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern boombeauxinfo *BoomAddBehAuxInfo(); + extern void BoomDelBehAuxInfo(); + extern void BoomBehFreeBehAux(); + + extern boombebuxinfo *BoomAddBehBuxInfo(); + extern void BoomDelBehBuxInfo(); + extern void BoomBehFreeBehBux(); + + extern boombebusinfo *BoomAddBehBusInfo(); + extern void BoomDelBehBusInfo(); + extern void BoomBehFreeBehBus(); + + extern boombeoutinfo *BoomAddBehOutInfo(); + extern void BoomDelBehOutInfo(); + extern void BoomBehFreeBehOut(); + + extern boombereginfo *BoomAddBehRegInfo(); + extern void BoomDelBehRegInfo(); + extern void BoomBehFreeBehReg(); + + extern boombefiginfo *BoomAddBehFigInfo(); + extern void BoomDelBehFigInfo(); + extern void BoomBehFreeBehFig(); + + extern long BoomComputeLog2(); + +# endif diff --git a/alliance/src/boom/src/boom_simple.c b/alliance/src/boom/src/boom_simple.c new file mode 100644 index 00000000..dc1f2182 --- /dev/null +++ b/alliance/src/boom/src/boom_simple.c @@ -0,0 +1,156 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_simple.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_window.h" +# include "boom_simple.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeSimple | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeSimple( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + bddvar NumberVar; + bddvar BddVar; + long Cost; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + NumberVar = BddLocalSystem->NUMBER_VAR; + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( BddVar = 0; BddVar < NumberVar - 1; BddVar++ ) + { + if ( BddVar < NumberVar - 2 ) + { + BoomBehReorderWindow3( BehFigure, BehAux, BddVar, &Cost ); + } + else + { + BoomBehReorderWindow2( BehFigure, BehAux, BddVar, &Cost ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "New cost %ld\n", Cost ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3d\b\b\b", ( ( BddVar + 1 ) * 100 ) / ( NumberVar - 1 ) ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} diff --git a/alliance/src/boom/src/boom_simple.h b/alliance/src/boom/src/boom_simple.h new file mode 100644 index 00000000..bef36564 --- /dev/null +++ b/alliance/src/boom/src/boom_simple.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_simple.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_SIMPLE_H +# define BOOM_SIMPLE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeSimple(); + +# endif diff --git a/alliance/src/boom/src/boom_simul.c b/alliance/src/boom/src/boom_simul.c new file mode 100644 index 00000000..0334cd1a --- /dev/null +++ b/alliance/src/boom/src/boom_simul.c @@ -0,0 +1,224 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_simul.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 08.08.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_optim.h" + +# include "boom_gradient.h" +# include "boom_simul.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeSimul | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeSimul( BehFigure ) + + befig_list *BehFigure; +{ + beaux_list *BehAux; + boombefiginfo *FigInfo; + long Cost; + long NewCost; + long Iteration; + long Amplitude; + long MaxIteration; + long MaxAmplitude; + chain_list *SimulOrder; + chain_list *NewOrder; + int Level; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + MaxIteration = FigInfo->ITERATION; + MaxAmplitude = FigInfo->AMPLITUDE; + Level = FigInfo->OPTIM_LEVEL; + + if ( MaxIteration <= 0 ) MaxIteration = 50; + if ( MaxAmplitude <= 0 ) MaxAmplitude = 1 + (BddLocalSystem->NUMBER_VAR / 4); + + MaxIteration = MaxIteration * (Level + 1); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Compute initial cost !\n" ); + } + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + /* + SimulOrder = BoomBehGetBddOrder( BehFigure ); + */ + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Compute initial order\n" ); + } + + if ( Level >= 1 ) + { + SimulOrder = BoomBehGradientBddOrder( BehFigure ); + } + else + { + SimulOrder = BoomBehGetBddOrder( BehFigure ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "done\n" ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + for ( Iteration = 0; Iteration < MaxIteration; Iteration++ ) + { + Amplitude = 1 + (long)( (double)MaxAmplitude * exp( - (double)Iteration / 5.0 ) ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Iteration %ld, Amplitude %ld\n", Iteration, Amplitude ); + } + + BoomBehRandomBddOrder( BehFigure, Amplitude ); + + NewOrder = BoomBehGetBddOrder( BehFigure ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + + freechain( SimulOrder ); + SimulOrder = NewOrder; + } + else + { + BoomBehRebuildBddNode( BehFigure, SimulOrder ); + freechain( NewOrder ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3ld\b\b\b", ( ( Iteration + 1 ) * 100 ) / MaxIteration ); + fflush( stdout ); + } + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Simul cost : %ld\n", Cost ); + } + + BoomBehRebuildBddNode( BehFigure, SimulOrder ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} diff --git a/alliance/src/boom/src/boom_simul.h b/alliance/src/boom/src/boom_simul.h new file mode 100644 index 00000000..b945470b --- /dev/null +++ b/alliance/src/boom/src/boom_simul.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_simul.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_SIMUL_H +# define BOOM_SIMUL_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_SIMUL_EXPLOSION_LIMIT 10000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeSimul(); + +# endif diff --git a/alliance/src/boom/src/boom_top.c b/alliance/src/boom/src/boom_top.c new file mode 100644 index 00000000..2bd26c09 --- /dev/null +++ b/alliance/src/boom/src/boom_top.c @@ -0,0 +1,226 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_top.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_top.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeTop | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeTop( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + char *ReorderLevel; + bddvar NumberChild; + bddvar BestChild; + bddvar ChildCount; + bddvar ChildTo; + bddvar ChildFrom; + char SwapReorder; + long Cost; + long NewCost; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + NumberChild = BddLocalSystem->NUMBER_VAR; + ReorderLevel = (char *)autallocblock( sizeof( char ) * NumberChild ); + + for ( ChildFrom = 0; ChildFrom < ( NumberChild - 1 ); ChildFrom++ ) + { + ReorderLevel[ ChildFrom ] = 1; + } + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + ChildCount = ( NumberChild - 1 ); + ChildFrom = 0; + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + while ( ChildCount > 0 ) + { + if ( IsBoomDebugLevel2() ) + { + BoomPrintf( stdout, "-> ChildFrom %d\n", ChildFrom ); + } + + ReorderLevel[ ChildFrom ] = 0; + + BestChild = ChildFrom; + + for ( ChildTo = ChildFrom; ChildTo < ( NumberChild - 1 ); ChildTo++ ) + { + if ( IsBoomDebugLevel2() ) + { + BoomPrintf( stdout, "-> Swap %d and %d\n", ChildTo, ChildTo + 1 ); + } + + swapbddvar( (bddsystem *)0, ChildTo ); + + SwapReorder = ReorderLevel[ ChildTo ]; + ReorderLevel[ ChildTo ] = ReorderLevel[ ChildTo + 1 ]; + ReorderLevel[ ChildTo + 1 ] = SwapReorder; + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + BestChild = ChildTo + 1; Cost = NewCost; + } + } + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "--> Best child %d\n", BestChild ); + BoomPrintf( stdout, "--> Best cost %ld\n", Cost ); + } + + for ( ChildTo = ( NumberChild - 1 ); ChildTo > BestChild; ChildTo-- ) + { +# ifdef BDD_DEBUG + if ( IsBoomDebugLevel1() ) + { +fprintf( stdout, "-> UnSwap %d and %d\n", ChildTo - 1, ChildTo ); + } +# endif + + SwapReorder = ReorderLevel[ ChildTo - 1 ]; + ReorderLevel[ ChildTo - 1 ] = ReorderLevel[ ChildTo ]; + ReorderLevel[ ChildTo ] = SwapReorder; + + swapbddvar( (bddsystem *)0, ChildTo - 1 ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-4d\b\b\b\b", + ( ( NumberChild - ChildCount ) * 100 ) / ( NumberChild - 1 ) ); + fflush( stdout ); + } + + while ( ! ReorderLevel[ ChildFrom ] ) + { + ChildFrom = ChildFrom + 1; + } + + ChildCount = ChildCount - 1; + } + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + autfreeblock( ReorderLevel ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} + diff --git a/alliance/src/boom/src/boom_top.h b/alliance/src/boom/src/boom_top.h new file mode 100644 index 00000000..036abea6 --- /dev/null +++ b/alliance/src/boom/src/boom_top.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_top.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_TOP_H +# define BOOM_TOP_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeTop(); + +# endif diff --git a/alliance/src/boom/src/boom_window.c b/alliance/src/boom/src/boom_window.c new file mode 100644 index 00000000..568292f9 --- /dev/null +++ b/alliance/src/boom/src/boom_window.c @@ -0,0 +1,385 @@ +/*------------------------------------------------------------\ +| | +| 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 : BOOM | +| | +| File : boom_window.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include ABE_H +# include ABV_H +# include ABT_H + +# include +# include +# include + +# include "boom_error.h" +# include "boom_debug.h" +# include "boom_shared.h" +# include "boom_aux.h" +# include "boom_abl.h" +# include "boom_bdd.h" +# include "boom_cost.h" +# include "boom_window.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Boom Beh Reorder Window 2 | +| | +\------------------------------------------------------------*/ + +int BoomBehReorderWindow2( BehFigure, BehAux, BddVar, PCost ) + + befig_list *BehFigure; + beaux_list *BehAux; + bddvar BddVar; + long *PCost; +{ + long NewCost; + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( NewCost < *PCost ) + { + *PCost = NewCost; + + return( 1 ); + } + else + if ( NewCost == *PCost ) + { + return( 0 ); + } + + swapbddvar( BddLocalSystem, BddVar ); + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| Boom Beh Reorder Window 3 | +| | +\------------------------------------------------------------*/ + +int BoomBehReorderWindow3( BehFigure, BehAux, BddVar, PCost ) + + befig_list *BehFigure; + beaux_list *BehAux; + bddvar BddVar; + long *PCost; +{ + long Cost; + long NewCost; + int BestOrder; + + BestOrder = BOOM_WINDOW_REORDER_123; + Cost = *PCost; + NewCost = Cost; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: Initial cost %ld\n", Cost ); + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_WINDOW_REORDER_213; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 213 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_WINDOW_REORDER_231; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 231 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_WINDOW_REORDER_321; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 321 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_WINDOW_REORDER_312; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 312 new cost %ld\n", Cost ); + } + } + + swapbddvar( (bddsystem *)0, BddVar ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + NewCost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel0() ) + { + BoomPrintf( stdout, "NewCost: %ld\n", NewCost ); + } + + if ( NewCost < Cost ) + { + Cost = NewCost; + BestOrder = BOOM_WINDOW_REORDER_132; + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Window3: 132 new cost %ld\n", Cost ); + } + } + + switch ( BestOrder ) + { + case BOOM_WINDOW_REORDER_123 : swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_WINDOW_REORDER_213 : swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_WINDOW_REORDER_231 : swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_WINDOW_REORDER_321 : swapbddvar( (bddsystem *)0, BddVar ); + swapbddvar( (bddsystem *)0, BddVar ); + break; + + case BOOM_WINDOW_REORDER_312 : swapbddvar( (bddsystem *)0, BddVar ); + break; + } + + *PCost = Cost; + + return( BestOrder != BOOM_WINDOW_REORDER_123 ); +} + +/*------------------------------------------------------------\ +| | +| BoomBehOptimizeWindow | +| | +\------------------------------------------------------------*/ + +void BoomBehOptimizeWindow( BehFigure ) + + befig_list *BehFigure; +{ + boombefiginfo *FigInfo; + beaux_list *BehAux; + short *ReorderLevel; + bddvar NumberChild; + bddvar ChildCount; + bddvar ChildFrom; + int AnySwap; + int Moved; + long Cost; + + FigInfo = GetBoomBehFigInfo( BehFigure ); + + NumberChild = BddLocalSystem->NUMBER_VAR; + ReorderLevel = (short *)autallocblock( sizeof( short ) * NumberChild ); + + for ( ChildFrom = 0; ChildFrom < ( NumberChild - 1 ); ChildFrom++ ) + { + ReorderLevel[ ChildFrom ] = 1; + } + + BehAux = BoomBehComputeAux( BehFigure, BehFigure->BEAUX ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Initial cost %ld\n", Cost ); + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "\t--> Optimization %% 0\b" ); + fflush( stdout ); + } + + do + { + AnySwap = 0; + + for ( ChildCount = 0; ChildCount < NumberChild - 1; ChildCount++ ) + { + if ( ReorderLevel[ ChildCount ] ) + { + if ( ChildCount < NumberChild - 2 ) + { + Moved = BoomBehReorderWindow3( BehFigure, BehAux, ChildCount, &Cost ); + } + else + { + Moved = BoomBehReorderWindow2( BehFigure, BehAux, ChildCount, &Cost ); + } + + if ( Moved ) + { + AnySwap = 1; + + if ( ChildCount > 0 ) ReorderLevel[ ChildCount - 1 ] = 1; + if ( ChildCount > 1 ) ReorderLevel[ ChildCount - 2 ] = 1; + + ReorderLevel[ ChildCount + 1 ] = 1; + + if ( ChildCount < NumberChild - 2 ) ReorderLevel[ ChildCount + 2 ] = 1; + if ( ChildCount < NumberChild - 3 ) ReorderLevel[ ChildCount + 3 ] = 1; + if ( ChildCount < NumberChild - 4 ) ReorderLevel[ ChildCount + 4 ] = 1; + } + else + { + ReorderLevel[ ChildCount ] = 0; + } + } + + if ( ( FigInfo->VERBOSE ) && + ( ! BoomDebugFlag ) ) + { + fprintf( stdout, "%-3d\b\b\b", ( ( ChildCount + 1 ) * 100 ) / ( NumberChild - 1 ) ); + fflush( stdout ); + } + } + } + while ( AnySwap ); + + if ( FigInfo->VERBOSE ) + { + fprintf( stdout, "\n\n" ); + } + + autfreeblock( ReorderLevel ); + + BehAux = BoomBehComputeAux( BehFigure, BehAux ); + Cost = BoomBehGiveCost( BehFigure ); + + if ( IsBoomDebugLevel1() ) + { + BoomPrintf( stdout, "Final cost %ld\n", Cost ); + } +} diff --git a/alliance/src/boom/src/boom_window.h b/alliance/src/boom/src/boom_window.h new file mode 100644 index 00000000..2db13bc7 --- /dev/null +++ b/alliance/src/boom/src/boom_window.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 : BOOM | +| | +| File : boom_window.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.06.00 | +| | +\------------------------------------------------------------*/ + +# ifndef BOOM_WINDOW_H +# define BOOM_WINDOW_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BOOM_WINDOW_REORDER_123 0 +# define BOOM_WINDOW_REORDER_213 1 +# define BOOM_WINDOW_REORDER_231 2 +# define BOOM_WINDOW_REORDER_321 3 +# define BOOM_WINDOW_REORDER_312 4 +# define BOOM_WINDOW_REORDER_132 5 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void BoomBehOptimizeWindow(); + extern int BoomBehReorderWindow3(); + extern int BoomBehReorderWindow2(); + +# endif diff --git a/alliance/src/fmi/Makefile.am b/alliance/src/fmi/Makefile.am new file mode 100644 index 00000000..5fcaa0d3 --- /dev/null +++ b/alliance/src/fmi/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src man1 diff --git a/alliance/src/fmi/man1/Makefile.am b/alliance/src/fmi/man1/Makefile.am new file mode 100644 index 00000000..49676a99 --- /dev/null +++ b/alliance/src/fmi/man1/Makefile.am @@ -0,0 +1,2 @@ +man_MANS = fmi.1 +EXTRA_DIST = $(man_MANS) diff --git a/alliance/src/fmi/man1/fmi.1 b/alliance/src/fmi/man1/fmi.1 new file mode 100644 index 00000000..df7670fd --- /dev/null +++ b/alliance/src/fmi/man1/fmi.1 @@ -0,0 +1,49 @@ +.TH FSP 1 "October 1, 1997" "ASIM/LIP6" "CAO\-VLSI Reference Manual" +.SH NAME +.TP +fmi +\- FSM state miminization +.so man1/alc_origin.1 +.SH SYNOPSIS +.TP +\fBfmi\fP [\fI-V\fP] \fIinput_file\fP \fIoutput_file\fP +.br +.SH DESCRIPTION +.br +Made to run on FSM descriptions, \fBfmi\fP supports the same subset of VHDL as syf +(for further informations about this subset see SYF(1) and FSM(5)). +\fBfmi\fP uses a Reduced Ordered Binary Decision Diagrams representation and +identifies equivalent states. +After this step, it drives a new FSM where all equivalent states are replaced +by a single state. +.br +As a restriction \fBfmi\fP doesn't handle don't cares (as this much more +difficult). + +.SH ENVIRONMENT VARIABLES +.br +.HP +.ti 7 +\fIMBK_WORK_LIB\fP gives the path of the FSM description. +The default value is the current directory. +.br +.HP +.ti 7 +\fIMBK_CATA_LIB\fP gives some auxiliary pathes for the FSM descriptions. +The default value is the current directory. +.SH OPTIONS +.ti 7 +\-V +Sets verbose mode on. Each step of the minimization is displayed on the +standard output. +.br +.SH EXAMPLE +.br + fmi digi digi_min + +.SH SEE ALSO +.br + \fBsyf\fP (1), \fBfsp\fP (1), \fBfsm\fP (5), \fBxfsm\fP (1). + +.so man1/alc_bug_report.1 + diff --git a/alliance/src/fmi/src/Makefile.am b/alliance/src/fmi/src/Makefile.am new file mode 100644 index 00000000..42516182 --- /dev/null +++ b/alliance/src/fmi/src/Makefile.am @@ -0,0 +1,12 @@ +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = fmi + +fmi_LDADD = @LIBS@ \ + -lFtl -lFks -lFvh -lFsm \ + -lBdd -lAbl -lAut -lMut + + +fmi_SOURCES = \ +fmi_bdd.c fmi_main.c fmi_optim.c fmi_parse.c fsa_bdd.c \ +fmi_bdd.h fmi_main.h fmi_optim.h fmi_parse.h diff --git a/alliance/src/fmi/src/fmi_bdd.c b/alliance/src/fmi/src/fmi_bdd.c new file mode 100644 index 00000000..01e5a81a --- /dev/null +++ b/alliance/src/fmi/src/fmi_bdd.c @@ -0,0 +1,190 @@ +/*------------------------------------------------------------\ +| | +| Tool : FSA | +| | +| File : fmi_bdd.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H + +# include "fmi_bdd.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Fmi Fsm Make Bdd Node | +| | +\------------------------------------------------------------*/ + +void FmiMakeFsmBddNode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstate_list *ScanState; + fsmlocout_list *ScanLocout; + fsmtrans_list *ScanTrans; + bddnode *BddNode; + bddnode *BddNodeOut; + bddnode *BddNodeLocout; + + setbddlocalcircuit( FsmFigure->CIRCUIT ); + setbddlocalsystem( BddLocalCircuit->BDD_SYSTEM ); + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + ScanTrans->BDD = addbddcircuitabl( (bddcircuit *)0, ScanTrans->ABL ); + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + BddNode = BddLocalSystem->ONE; + + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + BddNodeOut = searchbddcircuitin( (bddcircuit *)0, ScanLocout->OUT->NAME ); + + if ( ScanLocout->ABL != (chain_list *)0 ) + { + BddNodeLocout = addbddcircuitabl( (bddcircuit *)0, ScanLocout->ABL ); + } + else + { + BddNodeLocout = BddLocalSystem->ZERO; + } + + BddNodeLocout = applybddnode( (bddsystem *)0, ABL_NXOR, + decbddrefext( BddNodeLocout ), + decbddrefext( BddNodeOut ) ); + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNode ), + decbddrefext( BddNodeLocout ) ); + } + + BddNode = addbddcircuitout( (bddcircuit *)0, ScanState->NAME, BddNode ); + ScanState->USER = (void *)BddNode; + } + +#if 0 + testbddcircuit( (bddcircuit *)0 ); +#endif +} + +/*------------------------------------------------------------\ +| | +| Fmi Fsm Make Bdd Circuit | +| | +\------------------------------------------------------------*/ + +bddcircuit *FmiMakeFsmBddCircuit( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmin_list *ScanIn; + fsmout_list *ScanOut; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + + BddSystem = createbddsystem( 50, 10000, 1000, 900000 ); + reorderbddsystemdynamic( BddSystem, reorderbddsystemsimple, 100000, 50 ); + SetBddSystemNoWarning( BddSystem ); + + BddCircuit = createbddcircuit( FsmFigure->NAME, + FsmFigure->NUMBER_IN + FsmFigure->NUMBER_OUT, + FsmFigure->NUMBER_STATE, BddSystem ); + + for ( ScanIn = FsmFigure->IN; + ScanIn != (fsmin_list *)0; + ScanIn = ScanIn->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanIn->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanOut->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + FsmFigure->CIRCUIT = BddCircuit; + + FmiMakeFsmBddNode( FsmFigure ); + + return( FsmFigure->CIRCUIT ); +} + +/*------------------------------------------------------------\ +| | +| Fmi Fsm Convert Bdd Circuit | +| | +\------------------------------------------------------------*/ + +void FmiConvertFsmBddCircuit( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + bddcircuit *BddCircuit; + bddsystem *BddSystem; + + BddCircuit = FsmFigure->CIRCUIT; + BddSystem = BddCircuit->BDD_SYSTEM; + + reorderbddsystemwindow( BddSystem ); + convertfsmbddnodeabl( FsmFigure ); + + destroybddcircuit( BddCircuit ); + destroybddsystem( BddSystem ); + + FsmFigure->CIRCUIT = (bddcircuit *)0; +} diff --git a/alliance/src/fmi/src/fmi_bdd.h b/alliance/src/fmi/src/fmi_bdd.h new file mode 100644 index 00000000..4dc3e8a7 --- /dev/null +++ b/alliance/src/fmi/src/fmi_bdd.h @@ -0,0 +1,46 @@ +/*------------------------------------------------------------\ +| | +| Tool : FMI | +| | +| File : fmi_bdd.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef FMI_BDD_H +# define FMI_BDD_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern bddcircuit *FmiMakeFsmBddCircuit(); + extern void FmiConvertFsmBddCircuit(); + +# endif diff --git a/alliance/src/fmi/src/fmi_main.c b/alliance/src/fmi/src/fmi_main.c new file mode 100644 index 00000000..683323b1 --- /dev/null +++ b/alliance/src/fmi/src/fmi_main.c @@ -0,0 +1,187 @@ +/*------------------------------------------------------------\ +| | +| 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 : FMI | +| | +| File : fmi_main.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H + +# include +# include +# include + +# include "fmi_parse.h" +# include "fmi_bdd.h" +# include "fmi_optim.h" +# include "fmi_main.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Fmi Usage | +| | +\------------------------------------------------------------*/ + +void FmiUsage() +{ + fprintf( stderr, "\t\tfmi [Options] filename1 filename2\n\n" ); + + fprintf( stdout, "\t\tOptions : -V Sets Verbose mode on\n" ); + fprintf( stdout, "\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Main | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char *argv[]; +{ + char *InputFileName; + char *OutputFileName; + int Number; + + fsmfig_list *FsmFigure; + + int FlagVerbose = 0; + + alliancebanner_with_contrib( "FMI", FMI_VERSION, "FSM Minimization", "2000", + ALLIANCE_VERSION, "Frédéric Pétrot, Ludovic Jacomme", "Jean-Marie Alexandre" ); + + mbkenv(); + autenv(); + ablenv(); + bddenv(); + fsmenv(); + + if ( argc < 1 ) FmiUsage(); + + InputFileName = (char *)0; + OutputFileName = (char *)0; + + for ( Number = 1; Number < argc; Number++ ) + { + if ( ! strcmp( argv[ Number ], "-V" ) ) FlagVerbose = 1; + else + if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ]; + else + if ( OutputFileName == (char *)0 ) OutputFileName = argv[ Number ]; + else + FmiUsage(); + } + + if ( InputFileName == (char *)0 ) FmiUsage(); + + InputFileName = autbasename( InputFileName, FSM_IN ); + + if ( OutputFileName == (char *)0 ) + { + OutputFileName = autallocblock( strlen( InputFileName ) + 3 ); + sprintf( OutputFileName, "%sfmi", InputFileName ); + } + else + { + OutputFileName = autbasename( OutputFileName, FSM_IN ); + } + + if ( FlagVerbose ) + { + fprintf( stdout, "\t--> Run FSM Compiler\n" ); + fprintf( stdout, "\t--> Compile file %s\n", InputFileName ); + } + + FsmFigure = FmiParseFsm( InputFileName ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\t--> Build Binay Decision Diagrams\n" ); + } + + FmiMakeFsmBddCircuit( FsmFigure ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\t--> Identify equivalent states\n" ); + } + + FsmFigure = FmiOptimizeFsm( FsmFigure ); + + FsmFigure->NAME = namealloc( OutputFileName ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\t--> Save file %s\n", OutputFileName ); + } + + savefsmfig( FsmFigure ); + + return( 0 ); +} diff --git a/alliance/src/fmi/src/fmi_main.h b/alliance/src/fmi/src/fmi_main.h new file mode 100644 index 00000000..ac6af21b --- /dev/null +++ b/alliance/src/fmi/src/fmi_main.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : FSP | +| | +| File : fsp_main.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef FSP_MAIN_H +# define FSP_MAIN_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/fmi/src/fmi_optim.c b/alliance/src/fmi/src/fmi_optim.c new file mode 100644 index 00000000..b2efa099 --- /dev/null +++ b/alliance/src/fmi/src/fmi_optim.c @@ -0,0 +1,608 @@ +/*------------------------------------------------------------\ +| | +| Tool : FMI | +| | +| File : fmi_optim.c | +| | +| Author : Jean Marie Alexandre | +| | +| Date : 20.09.00 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include + +# include MUT_H +# include LOG_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H + + +# include "fmi_optim.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Parse Fsm File | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Fmi Del Elm | +| | +\------------------------------------------------------------*/ + +void +delfmielm (elm) + fmicelm_list *elm; +{ + fmicelm_list *DelElem; + fmicelm_list *ScanElem; + + ScanElem = elm; + + while ( ScanElem != (fmicelm_list *) 0) + { + DelElem = ScanElem; + ScanElem = ScanElem->NEXT; + autfreeheap ((char *) DelElem, sizeof (fmicelm_list)); + } +} + +/*------------------------------------------------------------\ +| | +| Fmi Del Classe | +| | +\------------------------------------------------------------*/ + +void +delfmiclasse (classe) + fmiclass_list *classe; +{ + fmiclass_list *DelClass; + fmiclass_list *ScanClass; + + ScanClass = classe; + + while (ScanClass != (fmiclass_list *) 0) + { + DelClass = ScanClass; + ScanClass = ScanClass->NEXT; + + autfreeheap((char *)DelClass, sizeof(fmiclass_list)); + } +} + +/*------------------------------------------------------------\ +| | +| Fmi Alloc Elm | +| | +\------------------------------------------------------------*/ + +fmicelm_list * +allocfmielm () +{ + return (fmicelm_list *) (autallocheap(sizeof (fmicelm_list))); +} + + + +/*------------------------------------------------------------\ +| | +| Fmi Alloc Classe | +| | +\------------------------------------------------------------*/ + +fmiclass_list * +allocfmiclasse () +{ + return (fmiclass_list *) (autallocheap(sizeof (fmiclass_list))); +} + + + +/*------------------------------------------------------------\ +| | +| AddCLassElm | +| | +\------------------------------------------------------------*/ + +fmicelm_list * +AddClassElm (elm, state) + fmicelm_list *elm; + fsmstate_list *state; + +{ + fmicelm_list *new; + + new = allocfmielm (); + + new->STATE = state; + new->NEXT = elm; + + return new; + +} + + +/*------------------------------------------------------------\ +| | +| AddCLass | +| | +\------------------------------------------------------------*/ + +fmiclass_list * +AddClass (classe) + fmiclass_list *classe; + +{ + fmiclass_list *new; + + new = allocfmiclasse (); + new->NEXT = classe; + return new; + +} + +/*------------------------------------------------------------\ +| | +| FmiRazUser | +| | +\------------------------------------------------------------*/ + +fsmstate_list * +FmiRazUser (state) + fsmstate_list *state; + +{ + + fsmstate_list *ScanState; + fsmstate_list *head; + + head = state; + + for (ScanState = state; + ScanState != (fsmstate_list *) 0; ScanState = ScanState->NEXT) + { + ScanState->USER = NULL; + + } + return (head); +} + +/*------------------------------------------------------------\ +| | +| FmiRazFlag | +| | +\------------------------------------------------------------*/ + +void +FmiRazFlag (classe) + fmiclass_list *classe; + +{ + + fmiclass_list *ScanClasse; + fmicelm_list *Scanelm; + fmiclass_list *head; + + head = classe; + + for (ScanClasse = classe; + ScanClasse != (fmiclass_list *) 0; ScanClasse = ScanClasse->NEXT) + { + for (Scanelm = ScanClasse->ELM; + Scanelm != (fmicelm_list *) 0; Scanelm = Scanelm->NEXT) + { + ClearFmiClass (Scanelm->STATE); + } + } +} + + +/*------------------------------------------------------------\ +| | +| FmiClassedansUser | +| | +\------------------------------------------------------------*/ + +fmiclass_list * +FmiClassedansUser (classe) + fmiclass_list *classe; +{ + + fmicelm_list *Scanelm; + fmiclass_list *Scanclasse; + + for (Scanclasse = classe; + Scanclasse != (fmiclass_list *) 0; Scanclasse = Scanclasse->NEXT) + { + for (Scanelm = Scanclasse->ELM; + Scanelm != (fmicelm_list *) 0; Scanelm = Scanelm->NEXT) + { + Scanelm->STATE->USER = (void *) Scanclasse; + } + } + return (classe); +} + + +/*------------------------------------------------------------\ +| | +| Fmitestin | +| | +\------------------------------------------------------------*/ + + + +int +Fmitestin (State1, State2) + fsmstate_list *State1; + fsmstate_list *State2; +{ + chain_list *ScanChain1; + chain_list *ScanChain2; + fsmtrans_list *Trans1; + fsmtrans_list *Trans2; + fsmstate_list *SuccState1; + fsmstate_list *SuccState2; + bddnode *BddNode1; + bddnode *BddNode2; + bddnode *BddNode; + + for (ScanChain1 = State1->FROM; + ScanChain1 != (chain_list *) 0; ScanChain1 = ScanChain1->NEXT) + { + Trans1 = (fsmtrans_list *) ScanChain1->DATA; + SuccState1 = Trans1->TO; + + BddNode1 = Trans1->BDD; + + for (ScanChain2 = State2->FROM; + ScanChain2 != (chain_list *) 0; ScanChain2 = ScanChain2->NEXT) + { + Trans2 = (fsmtrans_list *) ScanChain2->DATA; + BddNode2 = Trans2->BDD; + + BddNode = + applybddnode ((bddsystem *) 0, ABL_AND, BddNode1, BddNode2); + decbddrefext (BddNode); + + if (BddNode != BddLocalSystem->ZERO) + { + SuccState2 = Trans2->TO; + + if (SuccState2->USER != SuccState1->USER) + { + return 0; + } + } + } + } + return 1; +} + + +/*------------------------------------------------------------\ +| | +| Fmisucc | +| | +\------------------------------------------------------------*/ + +int +Fmisucc (State1, State2) + fsmstate_list *State1; + fsmstate_list *State2; + +{ + return (State1->USER == State2->USER) && Fmitestin (State1, State2); +} + +/*------------------------------------------------------------\ +| | +| FmiRec | +| | +\------------------------------------------------------------*/ +fsmfig_list * +FmiRec (fsm, classe) + fsmfig_list *fsm; + fmiclass_list *classe; +{ + fmiclass_list *ScanClasse; + fsmtrans_list *ScanTrans; + chain_list *ScanChain1; + fsmstate_list *State, *FromState, *ToState; + fsmtrans_list *trans; + fsmfig_list *NewFsm; + + fsmin_list *ScanIn; + fsmout_list *ScanOut; + fsmport_list *ScanPort; + fsmlocout_list *ScanLocout; + + for (ScanTrans = fsm->TRANS; ScanTrans; ScanTrans = ScanTrans->NEXT) + { + ClearFmiClass (ScanTrans); + } + + /* Duplication of the old FSM entity */ + + NewFsm = addfsmfig ("$$"); + + NewFsm->CLOCK = fsm->CLOCK; + NewFsm->CLOCK_ABL = dupablexpr (fsm->CLOCK_ABL); + + for (ScanIn = fsm->IN; ScanIn; ScanIn = ScanIn->NEXT) + { + addfsmin (NewFsm, ScanIn->NAME); + } + + for (ScanOut = fsm->OUT; ScanOut; ScanOut = ScanOut->NEXT) + { + addfsmout (NewFsm, ScanOut->NAME); + } + + for (ScanPort = fsm->PORT; ScanPort; ScanPort = ScanPort->NEXT) + { + addfsmport (NewFsm, ScanPort->NAME, ScanPort->DIR, ScanPort->TYPE); + } + + for (ScanClasse = classe; + ScanClasse != (fmiclass_list *) 0; ScanClasse = ScanClasse->NEXT) + { + State = addfsmstate (NewFsm, ScanClasse->ELM->STATE->NAME); + for (ScanLocout = ScanClasse->ELM->STATE->LOCOUT; + ScanLocout; ScanLocout = ScanLocout->NEXT) + { + addfsmlocout (State, searchfsmout (NewFsm, ScanLocout->OUT->NAME), + dupablexpr (ScanLocout->ABL), NULL); + } + } + + if (fsm->FIRST_STATE) { + NewFsm->FIRST_STATE = + searchfsmstate (NewFsm, + ((fmiclass_list *) fsm->FIRST_STATE->USER)->ELM->STATE-> + NAME); + SetFsmFirstState (NewFsm->FIRST_STATE); + } else + { + NewFsm->FIRST_STATE = NULL; + } + + + for (ScanClasse = classe; + ScanClasse != (fmiclass_list *) 0; ScanClasse = ScanClasse->NEXT) + { + State = ScanClasse->ELM->STATE; + for (ScanChain1 = State->FROM; + ScanChain1 != (chain_list *) 0; ScanChain1 = ScanChain1->NEXT) + { + FromState = searchfsmstate (NewFsm, ScanClasse->ELM->STATE->NAME); + ToState = searchfsmstate (NewFsm, + ((fmiclass_list + *) ((fsmtrans_list *) + ScanChain1->DATA)->TO->USER)-> + ELM->STATE->NAME); + trans = + addfsmtrans (NewFsm, FromState, ToState, + dupablexpr (((fsmtrans_list *) ScanChain1->DATA)-> + ABL)); + } + } + + if ( IsFsmFigMixedRtl( fsm ) ) + { + NewFsm->FIGURE = fsm->FIGURE; + SetFsmFigMixedRtl( NewFsm ); + + ClearFsmFigMixedRtl( fsm ); + fsm->FIGURE = (void *)0; + } + + delfsmfig( fsm->NAME ); + + return NewFsm; +} + +/*------------------------------------------------------------\ +| | +| FmiOptimizeFsm | +| | +\------------------------------------------------------------*/ + +fsmfig_list * +FmiOptimizeFsm (FsmFigure) + fsmfig_list *FsmFigure; +{ + + fsmstate_list *ScanState1; + fsmstate_list *ScanState2; + fmiclass_list *ScanClasse; + fmiclass_list *classetete = NULL; + fmicelm_list *ScanElm, *Elm; + + fmiclass_list *new; + fmiclass_list *act; + int modif = 0; + long int nombre; + long int n; + + /***************** premier passage ******************/ + + for (ScanState1 = FsmFigure->STATE; + ScanState1 != (fsmstate_list *) 0; ScanState1 = ScanState1->NEXT) + { + if (ScanState1->USER != (bddnode *) 0 && (!IsFmiClass (ScanState1))) + { + classetete = AddClass (classetete); + classetete->ELM = AddClassElm (NULL, ScanState1); + SetFmiClass (ScanState1); + + /* on considère maintenant que ScanState1 est dans une classe */ + + for (ScanState2 = ScanState1->NEXT; + ScanState2 != (fsmstate_list *) 0; + ScanState2 = ScanState2->NEXT) + { + + if (ScanState2->USER != (bddnode *) 0 + && (!IsFmiClass (ScanState2))) + { + if ((bddnode *) ScanState2->USER == + (bddnode *) ScanState1->USER) + { + classetete->ELM = + AddClassElm (classetete->ELM, ScanState2); + SetFmiClass (ScanState2); + } + + } + } + } + } + + + + +# ifdef DEBUG + for (new = classetete; new; new = new->NEXT) + { + printf ("{"); + for (ScanElm = new->ELM; ScanElm; ScanElm = ScanElm->NEXT) + printf ("%s%s", ScanElm->STATE->NAME, ScanElm->NEXT ? "," : ""); + printf ("}\n"); + } + printf ("\n"); +# endif + + +/* remise a jour des champs USER et FLAG de STATE */ + + FmiRazUser (FsmFigure->STATE); + FmiRazFlag (classetete); + + +/* on met la classe dans le champ USER de des states pour + * que chaque état sache dans quelle classe il se trouve */ + + + FmiClassedansUser (classetete); + +/******************* deuxième passage ************/ + + act = classetete; + + do + { + modif = 0; + new = NULL; + + for (ScanClasse = act; + ScanClasse != (fmiclass_list *) 0; ScanClasse = ScanClasse->NEXT) + { + for (ScanElm = ScanClasse->ELM; + ScanElm != (fmicelm_list *) 0; ScanElm = ScanElm->NEXT) + { + if (!IsFmiClass (ScanElm->STATE)) + { + new = AddClass (new); + new->ELM = AddClassElm (NULL, ScanElm->STATE); + SetFmiClass (ScanElm->STATE); + + for (Elm = ScanElm->NEXT; + Elm != (fmicelm_list *) 0; Elm = Elm->NEXT) + { + if (!IsFmiClass (Elm->STATE)) + { + if (Fmisucc (ScanElm->STATE, Elm->STATE)) + { + new->ELM = AddClassElm (new->ELM, Elm->STATE); + SetFmiClass (Elm->STATE); + } + else + { + modif = 1; + } + } + } + } + } + } + FmiRazFlag (new); + + if (modif == 1) + { + FmiClassedansUser (new); + act = new; + } + } + while (modif != 0); + + classetete = act; + +# ifdef DEBUG + for (new = classetete; new; new = new->NEXT) + { + printf ("{"); + for (ScanElm = new->ELM; ScanElm; ScanElm = ScanElm->NEXT) + printf ("%s%s", ScanElm->STATE->NAME, ScanElm->NEXT ? "," : ""); + printf ("}\n"); + } +# endif + +/* à partir de la classe, on reconstruit la nouvelle classe */ + + nombre = FsmFigure->NUMBER_STATE; + + FsmFigure = FmiRec (FsmFigure, classetete); + +/*delfmielm(classetete->ELM); +delfmiclasse(classetete); +delfmielm(act->ELM); +delfmiclasse(act); +*/ + + n = nombre; + nombre = nombre - FsmFigure->NUMBER_STATE; + fprintf( stdout, "\t--> Initial number states : %ld\n", n); + fprintf( stdout, "\t--> Number of deleted states : %ld\n", nombre); + + return (FsmFigure); +} diff --git a/alliance/src/fmi/src/fmi_optim.h b/alliance/src/fmi/src/fmi_optim.h new file mode 100644 index 00000000..4bbbbebe --- /dev/null +++ b/alliance/src/fmi/src/fmi_optim.h @@ -0,0 +1,90 @@ +/*------------------------------------------------------------\ +| | +| Tool : FMI | +| | +| File : fmi_optim.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef FMI_OPTIM_H +# define FMI_OPTIM_H + +/*------------------------------------------------------\ +| | +| Fsm Flag | +| | +\------------------------------------------------------*/ + +# define FMI_CLASS (long)( 0x0004 ) + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define IsFmiClass( T ) ( (T)->FLAGS & FMI_CLASS ) +# define SetFmiClass( T ) ( (T)->FLAGS |= FMI_CLASS ) +# define ClearFmiClass( T ) ( (T)->FLAGS &= ~FMI_CLASS ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| fmiclass | +| | +\------------------------------------------------------------*/ + + + typedef struct fmicelm_list + { + struct fmicelm_list *NEXT; + struct fsmstate_list *STATE; + + } fmicelm_list; + +/*------------------------------------------------------------\ +| | +| fmiclass_list | +| | +\------------------------------------------------------------*/ + + typedef struct fmiclass_list + { + struct fmiclass_list *NEXT; + struct fmicelm_list *ELM; + + } fmiclass_list; + + + + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + +extern fmiclass_list *classetete; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list *FmiOptimizeFsm(); + +# endif diff --git a/alliance/src/fmi/src/fmi_parse.c b/alliance/src/fmi/src/fmi_parse.c new file mode 100644 index 00000000..ccf5c103 --- /dev/null +++ b/alliance/src/fmi/src/fmi_parse.c @@ -0,0 +1,94 @@ +/*------------------------------------------------------------\ +| | +| tool : fmi | +| | +| file : fmi_parse.c | +| | +| authors : jacomme ludovic | +| | +| date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| include files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H + +# include "fmi_parse.h" + +/*------------------------------------------------------------\ +| | +| constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| parse fsm file | +| | +\------------------------------------------------------------*/ + +fsmfig_list *FmiParseFsm( FsmFilename ) + + char *FsmFilename; +{ + fsmfig_list *FsmFigure; + fsmstate_list *ScanState; + + + FsmFigure = getfsmfig( FsmFilename ); + + /* on detache l'état star */ + + ScanState = FsmFigure->STAR_STATE; + + if ( ScanState != (fsmstate_list *)0 ) + { + *ScanState->PREV = ScanState->NEXT; + + if ( ScanState->NEXT != (fsmstate_list *)0 ) + { + ScanState->NEXT->PREV = ScanState->PREV; + } + + FsmFigure->NUMBER_STATE--; + } + + ScanState = FsmFigure->STATE; + + simpfsmablexpr( FsmFigure ); + + return( FsmFigure ); +} diff --git a/alliance/src/fmi/src/fmi_parse.h b/alliance/src/fmi/src/fmi_parse.h new file mode 100644 index 00000000..70178562 --- /dev/null +++ b/alliance/src/fmi/src/fmi_parse.h @@ -0,0 +1,44 @@ +/*------------------------------------------------------------\ +| | +| Tool : FMI | +| | +| File : fmi_parse.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef FMI_PARSE_H +# define FMI_PARSE_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list *FmiParseFsm(); + +# endif diff --git a/alliance/src/fmi/src/fsa_bdd.c b/alliance/src/fmi/src/fsa_bdd.c new file mode 100644 index 00000000..6c9644ae --- /dev/null +++ b/alliance/src/fmi/src/fsa_bdd.c @@ -0,0 +1,128 @@ +/*------------------------------------------------------------\ +| | +| Tool : FSA | +| | +| File : fsa_bdd.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H +# include PAT_H +# include PPT_H + +# include "fsa_error.h" +# include "fsa_bdd.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Fsa Fsm Make Bdd Circuit | +| | +\------------------------------------------------------------*/ + +bddcircuit *FsaFsmMakeBddCircuit( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmin_list *ScanIn; + fsmout_list *ScanOut; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + + BddSystem = createbddsystem( 50, 10000, 1000, 900000 ); + + reorderbddsystemdynamic( BddSystem, reorderbddsystemsimple, 100000, 50 ); + + BddCircuit = createbddcircuit( FsmFigure->NAME, + FsmFigure->NUMBER_IN + FsmFigure->NUMBER_OUT, + FsmFigure->NUMBER_STATE, BddSystem ); + + for ( ScanIn = FsmFigure->IN; + ScanIn != (fsmin_list *)0; + ScanIn = ScanIn->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanIn->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanOut->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + FsmFigure->CIRCUIT = BddCircuit; + + makefsmbddnode( FsmFigure ); + reorderbddsystemwindow( BddSystem ); + + return( BddCircuit ); +} + +/*------------------------------------------------------------\ +| | +| Fsa Fsm Convert Bdd Circuit | +| | +\------------------------------------------------------------*/ + +void FsaFsmConvertBddCircuit( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + bddcircuit *BddCircuit; + bddsystem *BddSystem; + + BddCircuit = FsmFigure->CIRCUIT; + BddSystem = BddCircuit->BDD_SYSTEM; + + reorderbddsystemwindow( BddSystem ); + convertfsmbddnodeabl( FsmFigure ); + + destroybddcircuit( BddCircuit ); + destroybddsystem( BddSystem ); + + FsmFigure->CIRCUIT = (bddcircuit *)0; +}