-- Copyright (C) 2001 Bill Billowitch. -- Some of the work to develop this test suite was done with Air Force -- support. The Air Force and Bill Billowitch assume no -- responsibilities for this software. -- This file is part of VESTs (Vhdl tESTs). -- VESTs 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. -- VESTs 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 VESTs; if not, write to the Free Software Foundation, -- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- --------------------------------------------------------------------- -- -- $Id: tc1945.vhd,v 1.2 2001-10-26 16:29:44 paw Exp $ -- $Revision: 1.2 $ -- -- --------------------------------------------------------------------- package c07s02b01x00p01n02i01945pkg is -- -- Index types for array declarations -- SUBTYPE st_ind1 IS INTEGER RANGE 1 TO 4; -- index from 1 (POSITIVE) SUBTYPE st_ind2 IS INTEGER RANGE 0 TO 3; -- index from 0 (NATURAL) SUBTYPE st_ind3 IS CHARACTER RANGE 'a' TO 'd'; -- non-INTEGER index SUBTYPE st_ind4 IS INTEGER RANGE 0 DOWNTO -3; -- descending range -- -- Logic types for subelements -- SUBTYPE st_scl1 IS BIT; SUBTYPE st_scl2 IS BOOLEAN; -- ----------------------------------------------------------------------------------------- -- Composite type declarations -- ----------------------------------------------------------------------------------------- -- -- Unconstrained arrays -- TYPE t_usa1_1 IS ARRAY (st_ind1 RANGE <>) OF BIT; TYPE t_usa1_2 IS ARRAY (st_ind2 RANGE <>) OF BOOLEAN; TYPE t_usa1_3 IS ARRAY (st_ind3 RANGE <>) OF BIT; TYPE t_usa1_4 IS ARRAY (st_ind4 RANGE <>) OF BOOLEAN; -- -- Constrained arrays of scalars (make compatable with unconstrained types -- SUBTYPE t_csa1_1 IS t_usa1_1 (st_ind1); SUBTYPE t_csa1_2 IS t_usa1_2 (st_ind2); SUBTYPE t_csa1_3 IS t_usa1_3 (st_ind3); SUBTYPE t_csa1_4 IS t_usa1_4 (st_ind4); -- ---------------------------------------------------------------------------------------------- -- -- TYPE declarations for resolution function (Constrained types only) -- TYPE t_csa1_1_vct IS ARRAY (POSITIVE RANGE <>) OF t_csa1_1; TYPE t_csa1_2_vct IS ARRAY (POSITIVE RANGE <>) OF t_csa1_2; TYPE t_csa1_3_vct IS ARRAY (POSITIVE RANGE <>) OF t_csa1_3; TYPE t_csa1_4_vct IS ARRAY (POSITIVE RANGE <>) OF t_csa1_4; end; use work.c07s02b01x00p01n02i01945pkg.all; ENTITY c07s02b01x00p01n02i01945ent IS END c07s02b01x00p01n02i01945ent; ARCHITECTURE c07s02b01x00p01n02i01945arch OF c07s02b01x00p01n02i01945ent IS -- -- CONSTANT Declarations -- CONSTANT ARGA_C_csa1_1 : t_csa1_1 := ( '1', '1', '0', '0' ); CONSTANT ARGA_C_usa1_1 : t_usa1_1(st_ind1) := ( '1', '1', '0', '0' ); CONSTANT ARGB_C_csa1_1 : t_csa1_1 := ( '1', '0', '1', '0' ); CONSTANT ARGB_C_usa1_1 : t_usa1_1(st_ind1) := ( '1', '0', '1', '0' ); CONSTANT AND_C_csa1_1 : t_csa1_1 := ( '1', '0', '0', '0' ); CONSTANT AND_C_usa1_1 : t_usa1_1(st_ind1) := ( '1', '0', '0', '0' ); CONSTANT ARGA_C_csa1_2 : t_csa1_2 := ( TRUE, TRUE, FALSE, FALSE ); CONSTANT ARGA_C_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, TRUE, FALSE, FALSE ); CONSTANT ARGB_C_csa1_2 : t_csa1_2 := ( TRUE, FALSE, TRUE, FALSE ); CONSTANT ARGB_C_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, FALSE, TRUE, FALSE ); CONSTANT AND_C_csa1_2 : t_csa1_2 := ( TRUE, FALSE, FALSE, FALSE ); CONSTANT AND_C_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, FALSE, FALSE, FALSE ); CONSTANT ARGA_C_csa1_3 : t_csa1_3 := ( '1', '1', '0', '0' ); CONSTANT ARGA_C_usa1_3 : t_usa1_3(st_ind3) := ( '1', '1', '0', '0' ); CONSTANT ARGB_C_csa1_3 : t_csa1_3 := ( '1', '0', '1', '0' ); CONSTANT ARGB_C_usa1_3 : t_usa1_3(st_ind3) := ( '1', '0', '1', '0' ); CONSTANT AND_C_csa1_3 : t_csa1_3 := ( '1', '0', '0', '0' ); CONSTANT AND_C_usa1_3 : t_usa1_3(st_ind3) := ( '1', '0', '0', '0' ); CONSTANT ARGA_C_csa1_4 : t_csa1_4 := ( TRUE, TRUE, FALSE, FALSE ); CONSTANT ARGA_C_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, TRUE, FALSE, FALSE ); CONSTANT ARGB_C_csa1_4 : t_csa1_4 := ( TRUE, FALSE, TRUE, FALSE ); CONSTANT ARGB_C_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, FALSE, TRUE, FALSE ); CONSTANT AND_C_csa1_4 : t_csa1_4 := ( TRUE, FALSE, FALSE, FALSE ); CONSTANT AND_C_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, FALSE, FALSE, FALSE ); -- -- SIGNAL Declarations -- SIGNAL ARGA_S_csa1_1 : t_csa1_1 := ( '1', '1', '0', '0' ); SIGNAL ARGA_S_usa1_1 : t_usa1_1(st_ind1) := ( '1', '1', '0', '0' ); SIGNAL ARGB_S_csa1_1 : t_csa1_1 := ( '1', '0', '1', '0' ); SIGNAL ARGB_S_usa1_1 : t_usa1_1(st_ind1) := ( '1', '0', '1', '0' ); SIGNAL AND_S_csa1_1 : t_csa1_1 := ( '1', '0', '0', '0' ); SIGNAL AND_S_usa1_1 : t_usa1_1(st_ind1) := ( '1', '0', '0', '0' ); SIGNAL ARGA_S_csa1_2 : t_csa1_2 := ( TRUE, TRUE, FALSE, FALSE ); SIGNAL ARGA_S_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, TRUE, FALSE, FALSE ); SIGNAL ARGB_S_csa1_2 : t_csa1_2 := ( TRUE, FALSE, TRUE, FALSE ); SIGNAL ARGB_S_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, FALSE, TRUE, FALSE ); SIGNAL AND_S_csa1_2 : t_csa1_2 := ( TRUE, FALSE, FALSE, FALSE ); SIGNAL AND_S_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, FALSE, FALSE, FALSE ); SIGNAL ARGA_S_csa1_3 : t_csa1_3 := ( '1', '1', '0', '0' ); SIGNAL ARGA_S_usa1_3 : t_usa1_3(st_ind3) := ( '1', '1', '0', '0' ); SIGNAL ARGB_S_csa1_3 : t_csa1_3 := ( '1', '0', '1', '0' ); SIGNAL ARGB_S_usa1_3 : t_usa1_3(st_ind3) := ( '1', '0', '1', '0' ); SIGNAL AND_S_csa1_3 : t_csa1_3 := ( '1', '0', '0', '0' ); SIGNAL AND_S_usa1_3 : t_usa1_3(st_ind3) := ( '1', '0', '0', '0' ); SIGNAL ARGA_S_csa1_4 : t_csa1_4 := ( TRUE, TRUE, FALSE, FALSE ); SIGNAL ARGA_S_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, TRUE, FALSE, FALSE ); SIGNAL ARGB_S_csa1_4 : t_csa1_4 := ( TRUE, FALSE, TRUE, FALSE ); SIGNAL ARGB_S_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, FALSE, TRUE, FALSE ); SIGNAL AND_S_csa1_4 : t_csa1_4 := ( TRUE, FALSE, FALSE, FALSE ); SIGNAL AND_S_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, FALSE, FALSE, FALSE ); BEGIN TESTING: PROCESS -- -- VARIABLE Declarations -- VARIABLE ARGA_V_csa1_1 : t_csa1_1 := ( '1', '1', '0', '0' ); VARIABLE ARGA_V_usa1_1 : t_usa1_1(st_ind1) := ( '1', '1', '0', '0' ); VARIABLE ARGB_V_csa1_1 : t_csa1_1 := ( '1', '0', '1', '0' ); VARIABLE ARGB_V_usa1_1 : t_usa1_1(st_ind1) := ( '1', '0', '1', '0' ); VARIABLE AND_V_csa1_1 : t_csa1_1 := ( '1', '0', '0', '0' ); VARIABLE AND_V_usa1_1 : t_usa1_1(st_ind1) := ( '1', '0', '0', '0' ); VARIABLE ARGA_V_csa1_2 : t_csa1_2 := ( TRUE, TRUE, FALSE, FALSE ); VARIABLE ARGA_V_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, TRUE, FALSE, FALSE ); VARIABLE ARGB_V_csa1_2 : t_csa1_2 := ( TRUE, FALSE, TRUE, FALSE ); VARIABLE ARGB_V_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, FALSE, TRUE, FALSE ); VARIABLE AND_V_csa1_2 : t_csa1_2 := ( TRUE, FALSE, FALSE, FALSE ); VARIABLE AND_V_usa1_2 : t_usa1_2(st_ind2) := ( TRUE, FALSE, FALSE, FALSE ); VARIABLE ARGA_V_csa1_3 : t_csa1_3 := ( '1', '1', '0', '0' ); VARIABLE ARGA_V_usa1_3 : t_usa1_3(st_ind3) := ( '1', '1', '0', '0' ); VARIABLE ARGB_V_csa1_3 : t_csa1_3 := ( '1', '0', '1', '0' ); VARIABLE ARGB_V_usa1_3 : t_usa1_3(st_ind3) := ( '1', '0', '1', '0' ); VARIABLE AND_V_csa1_3 : t_csa1_3 := ( '1', '0', '0', '0' ); VARIABLE AND_V_usa1_3 : t_usa1_3(st_ind3) := ( '1', '0', '0', '0' ); VARIABLE ARGA_V_csa1_4 : t_csa1_4 := ( TRUE, TRUE, FALSE, FALSE ); VARIABLE ARGA_V_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, TRUE, FALSE, FALSE ); VARIABLE ARGB_V_csa1_4 : t_csa1_4 := ( TRUE, FALSE, TRUE, FALSE ); VARIABLE ARGB_V_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, FALSE, TRUE, FALSE ); VARIABLE AND_V_csa1_4 : t_csa1_4 := ( TRUE, FALSE, FALSE, FALSE ); VARIABLE AND_V_usa1_4 : t_usa1_4(st_ind4) := ( TRUE, FALSE, FALSE, FALSE ); BEGIN -- -- Test AND operator on: CONSTANTs -- ASSERT ( ARGA_C_csa1_1 AND ARGB_C_csa1_1 ) = AND_C_csa1_1 REPORT "ERROR: composite AND operator failed; CONSTANT; csa1_1" SEVERITY FAILURE; ASSERT ( ARGA_C_csa1_2 AND ARGB_C_csa1_2 ) = AND_C_csa1_2 REPORT "ERROR: composite AND operator failed; CONSTANT; csa1_2" SEVERITY FAILURE; ASSERT ( ARGA_C_csa1_3 AND ARGB_C_csa1_3 ) = AND_C_csa1_3 REPORT "ERROR: composite AND operator failed; CONSTANT; csa1_3" SEVERITY FAILURE; ASSERT ( ARGA_C_csa1_4 AND ARGB_C_csa1_4 ) = AND_C_csa1_4 REPORT "ERROR: composite AND operator failed; CONSTANT; csa1_4" SEVERITY FAILURE; ASSERT ( ARGA_C_usa1_1 AND ARGB_C_usa1_1 ) = AND_C_usa1_1 REPORT "ERROR: composite AND operator failed; CONSTANT; usa1_1" SEVERITY FAILURE; ASSERT ( ARGA_C_usa1_2 AND ARGB_C_usa1_2 ) = AND_C_usa1_2 REPORT "ERROR: composite AND operator failed; CONSTANT; usa1_2" SEVERITY FAILURE; ASSERT ( ARGA_C_usa1_3 AND ARGB_C_usa1_3 ) = AND_C_usa1_3 REPORT "ERROR: composite AND operator failed; CONSTANT; usa1_3" SEVERITY FAILURE; ASSERT ( ARGA_C_usa1_4 AND ARGB_C_usa1_4 ) = AND_C_usa1_4 REPORT "ERROR: composite AND operator failed; CONSTANT; usa1_4" SEVERITY FAILURE; -- -- Test AND operator on: SIGNALs -- ASSERT ( ARGA_S_csa1_1 AND ARGB_S_csa1_1 ) = AND_S_csa1_1 REPORT "ERROR: composite AND operator failed; SIGNAL; csa1_1" SEVERITY FAILURE; ASSERT ( ARGA_S_csa1_2 AND ARGB_S_csa1_2 ) = AND_S_csa1_2 REPORT "ERROR: composite AND operator failed; SIGNAL; csa1_2" SEVERITY FAILURE; ASSERT ( ARGA_S_csa1_3 AND ARGB_S_csa1_3 ) = AND_S_csa1_3 REPORT "ERROR: composite AND operator failed; SIGNAL; csa1_3" SEVERITY FAILURE; ASSERT ( ARGA_S_csa1_4 AND ARGB_S_csa1_4 ) = AND_S_csa1_4 REPORT "ERROR: composite AND operator failed; SIGNAL; csa1_4" SEVERITY FAILURE; ASSERT ( ARGA_S_usa1_1 AND ARGB_S_usa1_1 ) = AND_S_usa1_1 REPORT "ERROR: composite AND operator failed; SIGNAL; usa1_1" SEVERITY FAILURE; ASSERT ( ARGA_S_usa1_2 AND ARGB_S_usa1_2 ) = AND_S_usa1_2 REPORT "ERROR: composite AND operator failed; SIGNAL; usa1_2" SEVERITY FAILURE; ASSERT ( ARGA_S_usa1_3 AND ARGB_S_usa1_3 ) = AND_S_usa1_3 REPORT "ERROR: composite AND operator failed; SIGNAL; usa1_3" SEVERITY FAILURE; ASSERT ( ARGA_S_usa1_4 AND ARGB_S_usa1_4 ) = AND_S_usa1_4 REPORT "ERROR: composite AND operator failed; SIGNAL; usa1_4" SEVERITY FAILURE; -- -- Test AND operator on: VARIABLEs -- ASSERT ( ARGA_V_csa1_1 AND ARGB_V_csa1_1 ) = AND_V_csa1_1 REPORT "ERROR: composite AND operator failed; VARIABLE; csa1_1" SEVERITY FAILURE; ASSERT ( ARGA_V_csa1_2 AND ARGB_V_csa1_2 ) = AND_V_csa1_2 REPORT "ERROR: composite AND operator failed; VARIABLE; csa1_2" SEVERITY FAILURE; ASSERT ( ARGA_V_csa1_3 AND ARGB_V_csa1_3 ) = AND_V_csa1_3 REPORT "ERROR: composite AND operator failed; VARIABLE; csa1_3" SEVERITY FAILURE; ASSERT ( ARGA_V_csa1_4 AND ARGB_V_csa1_4 ) = AND_V_csa1_4 REPORT "ERROR: composite AND operator failed; VARIABLE; csa1_4" SEVERITY FAILURE; ASSERT ( ARGA_V_usa1_1 AND ARGB_V_usa1_1 ) = AND_V_usa1_1 REPORT "ERROR: composite AND operator failed; VARIABLE; usa1_1" SEVERITY FAILURE; ASSERT ( ARGA_V_usa1_2 AND ARGB_V_usa1_2 ) = AND_V_usa1_2 REPORT "ERROR: composite AND operator failed; VARIABLE; usa1_2" SEVERITY FAILURE; ASSERT ( ARGA_V_usa1_3 AND ARGB_V_usa1_3 ) = AND_V_usa1_3 REPORT "ERROR: composite AND operator failed; VARIABLE; usa1_3" SEVERITY FAILURE; ASSERT ( ARGA_V_usa1_4 AND ARGB_V_usa1_4 ) = AND_V_usa1_4 REPORT "ERROR: composite AND operator failed; VARIABLE; usa1_4" SEVERITY FAILURE; wait for 5 ns; assert NOT( ( ARGA_C_csa1_1 AND ARGB_C_csa1_1 ) = AND_C_csa1_1 and ( ARGA_C_csa1_2 AND ARGB_C_csa1_2 ) = AND_C_csa1_2 and ( ARGA_C_csa1_3 AND ARGB_C_csa1_3 ) = AND_C_csa1_3 and ( ARGA_C_csa1_4 AND ARGB_C_csa1_4 ) = AND_C_csa1_4 and ( ARGA_C_usa1_1 AND ARGB_C_usa1_1 ) = AND_C_usa1_1 and ( ARGA_C_usa1_2 AND ARGB_C_usa1_2 ) = AND_C_usa1_2 and ( ARGA_C_usa1_3 AND ARGB_C_usa1_3 ) = AND_C_usa1_3 and ( ARGA_C_usa1_4 AND ARGB_C_usa1_4 ) = AND_C_usa1_4 and ( ARGA_S_csa1_1 AND ARGB_S_csa1_1 ) = AND_S_csa1_1 and ( ARGA_S_csa1_2 AND ARGB_S_csa1_2 ) = AND_S_csa1_2 and ( ARGA_S_csa1_3 AND ARGB_S_csa1_3 ) = AND_S_csa1_3 and ( ARGA_S_csa1_4 AND ARGB_S_csa1_4 ) = AND_S_csa1_4 and ( ARGA_S_usa1_1 AND ARGB_S_usa1_1 ) = AND_S_usa1_1 and ( ARGA_S_usa1_2 AND ARGB_S_usa1_2 ) = AND_S_usa1_2 and ( ARGA_S_usa1_3 AND ARGB_S_usa1_3 ) = AND_S_usa1_3 and ( ARGA_S_usa1_4 AND ARGB_S_usa1_4 ) = AND_S_usa1_4 and ( ARGA_V_csa1_1 AND A
/**CFile***********************************************************************
FileName [cuddAddFind.c]
PackageName [cudd]
Synopsis [Functions to find maximum and minimum in an ADD and to
extract the i-th bit.]
Description [External procedures included in this module:
<ul>
<li> Cudd_addFindMax()
<li> Cudd_addFindMin()
<li> Cudd_addIthBit()
</ul>
Static functions included in this module:
<ul>
<li> addDoIthBit()
</ul>]
Author [Fabio Somenzi]
Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
******************************************************************************/
#include "misc/util/util_hack.h"
#include "cuddInt.h"
ABC_NAMESPACE_IMPL_START
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Stucture declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Type declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Variable declarations */
/*---------------------------------------------------------------------------*/
#ifndef lint
static char rcsid[] DD_UNUSED = "$Id: cuddAddFind.c,v 1.8 2004/08/13 18:04:45 fabio Exp $";
#endif
/*---------------------------------------------------------------------------*/
/* Macro declarations */
/*---------------------------------------------------------------------------*/
/**AutomaticStart*************************************************************/
/*---------------------------------------------------------------------------*/
/* Static function prototypes */
/*---------------------------------------------------------------------------*/
static DdNode * addDoIthBit (DdManager *dd, DdNode *f, DdNode *index);
/**AutomaticEnd***************************************************************/
/*---------------------------------------------------------------------------*/
/* Definition of exported functions */
/*---------------------------------------------------------------------------*/
/**Function********************************************************************
Synopsis [Finds the maximum discriminant of f.]
Description [Returns a pointer to a constant ADD.]
SideEffects [None]
******************************************************************************/
DdNode *
Cudd_addFindMax(
DdManager * dd,
DdNode * f)
{
DdNode *t, *e, *res;
statLine(dd);
if (cuddIsConstant(f)) {
return(f);
}
res = cuddCacheLookup1(dd,Cudd_addFindMax,f);
if (res != NULL) {
return(res);
}
t = Cudd_addFindMax(dd,cuddT(f));
if (t == DD_PLUS_INFINITY(dd)) return(t);
e = Cudd_addFindMax(dd,cuddE(f));
res = (cuddV(t) >= cuddV(e)) ? t : e;
cuddCacheInsert1(dd,Cudd_addFindMax,f,res);
return(res);
} /* end of Cudd_addFindMax */
/**Function********************************************************************
Synopsis [Finds the minimum discriminant of f.]
Description [Returns a pointer to a constant ADD.]
SideEffects [None]
******************************************************************************/
DdNode *
Cudd_addFindMin(
DdManager * dd,
DdNode * f)
{
DdNode *t, *e, *res;
statLine(dd);
if (cuddIsConstant(f)) {
return(f);
}
res = cuddCacheLookup1(dd,Cudd_addFindMin,f);
if (res != NULL) {
return(res);
}
t = Cudd_addFindMin(dd,cuddT(f));
if (t == DD_MINUS_INFINITY(dd)) return(t);
e = Cudd_addFindMin(dd,cuddE(f));
res = (cuddV(t) <= cuddV(e)) ? t : e;
cuddCacheInsert1(dd,Cudd_addFindMin,f,res);
return(res);
} /* end of Cudd_addFindMin */
/**Function********************************************************************
Synopsis [Extracts the i-th bit from an ADD.]
Description [Produces an ADD from another ADD by replacing all
discriminants whose i-th bit is equal to 1 with 1, and all other
discriminants with 0. The i-th bit refers to the integer
representation of the leaf value. If the value is has a fractional
part, it is ignored. Repeated calls to this procedure allow one to
transform an integer-valued ADD into an array of ADDs, one for each
bit of the leaf values. Returns a pointer to the resulting ADD if
successful; NULL otherwise.]
SideEffects [None]
SeeAlso [Cudd_addBddIthBit]
******************************************************************************/
DdNode *
Cudd_addIthBit(
DdManager * dd,
DdNode * f,
int bit)
{
DdNode *res;
DdNode *index;
/* Use a constant node to remember the bit, so that we can use the
** global cache.
*/
index = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) bit);
if (index == NULL) return(NULL);
cuddRef(index);
do {
dd->reordered = 0;
res = addDoIthBit(dd, f, index);
} while (dd->reordered == 1);
if (res == NULL) {
Cudd_RecursiveDeref(dd, index);
return(NULL);
}
cuddRef(res);
Cudd_RecursiveDeref(dd, index);
cuddDeref(res);
return(res);
} /* end of Cudd_addIthBit */
/*---------------------------------------------------------------------------*/
/* Definition of internal functions */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
/**Function********************************************************************
Synopsis [Performs the recursive step for Cudd_addIthBit.]
Description [Performs the recursive step for Cudd_addIthBit.
Returns a pointer to the BDD if successful; NULL otherwise.]
SideEffects [None]
SeeAlso []
******************************************************************************/
static DdNode *
addDoIthBit(
DdManager * dd,
DdNode * f,
DdNode * index)
{
DdNode *res, *T, *E;
DdNode *fv, *fvn;
int mask, value;
int v;
statLine(dd);
/* Check terminal case. */
if (cuddIsConstant(f)) {
mask = 1 << ((int) cuddV(index));
value = (int) cuddV(f);
return((value & mask) == 0 ? DD_ZERO(dd) : DD_ONE(dd));
}
/* Check cache. */
res = cuddCacheLookup2(dd,addDoIthBit,f,index);
if (res != NULL) return(res);
/* Recursive step. */
v = f->index;
fv = cuddT(f); fvn = cuddE(f);
T = addDoIthBit(dd,fv,index);
if (T == NULL) return(NULL);
cuddRef(T);
E = addDoIthBit(dd,fvn,index);
if (E == NULL) {
Cudd_RecursiveDeref(dd, T);
return(NULL);
}
cuddRef(E);
res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
if (res == NULL) {
Cudd_RecursiveDeref(dd, T);
Cudd_RecursiveDeref(dd, E);
return(NULL);
}
cuddDeref(T);
cuddDeref(E);
/* Store result. */
cuddCacheInsert2(dd,addDoIthBit,f,index,res);
return(res);
} /* end of addDoIthBit */
ABC_NAMESPACE_IMPL_END