104 if ( nNegs == 0 )
return 1;
105 if ( nNegs == 1 )
return 2;
109 if ( nNegs <= 1 )
return 5;
110 if ( nNegs == 2 )
return 6;
114 if ( nNegs <= 1 )
return 14;
115 if ( nNegs == 2 )
return 16;
116 if ( nNegs == 3 )
return 18;
118 Extra = nNegs - nVars/2;
119 return 20 + 12 * (nVars - 4) + (Extra > 0 ? 2 * Extra : 0);
124 int i, k, Limit = 10;
125 for ( i = 0; i < Limit; i++ )
127 for ( k = 0; k <= i; k++ )
134 int i, Entry, nLitsN = 0;
136 nLitsN += Abc_LitIsCompl(Entry);
137 return GetQCost( Vec_IntSize(vCube), nLitsN );
142 int v, nLits = 0, nLitsN = 0;
169 return ( ( ( lines + 1 ) / 2 ) >= controls ) ? 8 : 10;
172 return ( ( ( lines + 1 ) / 2 ) >= controls ) ? 4 * ( controls - 2 ) : 8 * ( controls - 3 );
209 int nIterWithoutImprovement = 0;
218 printf(
"\nITERATION #%d\n\n", ++nIterCount );
241 if ( nIterWithoutImprovement > (
int)(
g_CoverInfo.Quality>0) )
263 nIterWithoutImprovement = 0;
265 nIterWithoutImprovement++;
270 while ( nIterWithoutImprovement < 1 +
g_CoverInfo.Quality );
275 for ( z = 0; z < 1; z++ )
278 printf(
"\nITERATION #%d\n\n", ++nIterCount );
708 int c, i, k, Lit, Out;
721 Out = -Vec_IntPop(vCube) - 1;
728 if ( Abc_LitIsCompl(Lit) )
729 s_LevelValues[Abc_Lit2Var(Lit)] =
VAR_NEG;
731 s_LevelValues[Abc_Lit2Var(Lit)] =
VAR_POS;
747 pNew->
a = Vec_IntSize(vCube);
784 int MemTemp, MemTotal;
794 RemainderBits = (nIns*2)%(
sizeof(
unsigned)*8);
795 TotalWords = (nIns*2)/(
sizeof(
unsigned)*8) + (RemainderBits > 0);
799 RemainderBits = (nOuts)%(
sizeof(
unsigned)*8);
800 TotalWords = (nOuts)/(
sizeof(
unsigned)*8) + (RemainderBits > 0);
813 printf(
"Starting cover generation time is %.2f sec\n", TICKS_TO_SECONDS(
g_CoverInfo.TimeStart) );
814 printf(
"The number of cubes in the starting cover is %d\n",
g_CoverInfo.nCubesBefore );
819 printf(
"\nThe size of the starting cover is more than %d cubes. Quitting...\n",
g_CoverInfo.nCubesMax );
833 printf(
"Unexpected memory allocation problem. Quitting...\n" );
843 printf(
"Unexpected memory allocation problem. Quitting...\n" );
853 printf(
"Unexpected memory allocation problem. Quitting...\n" );
860 printf(
"Dynamically allocated memory is %dK\n", MemTotal/1000 );
868 printf(
"Generating the starting cover...\n" );
876 printf(
"Performing minimization...\n" );
883 printf(
"\nMinimization time is %.2f sec\n", TICKS_TO_SECONDS(
g_CoverInfo.TimeMin) );
884 printf(
"\nThe number of cubes after minimization is %d\n",
g_CoverInfo.nCubesInUse );
898 sprintf( Buffer,
"%s", pFileNameOut ? pFileNameOut :
"temp.esop" );
901 printf(
"Minimized cover has been written into file <%s>\n", Buffer );
927int Abc_ExorcismMain(
Vec_Wec_t * vEsop,
int nIns,
int nOuts,
char * pFileNameOut,
int Quality,
int Verbosity,
int nCubesMax,
int fUseQCost )
938 printf(
"\nEXORCISM, Ver.4.7: Exclusive Sum-of-Product Minimizer\n" );
939 printf(
"by Alan Mishchenko, Portland State University, July-September 2000\n\n" );
940 printf(
"Incoming ESOP has %d inputs, %d outputs, and %d cubes.\n", nIns, nOuts, Vec_WecSize(vEsop) );
943 if (
Exorcism( vEsop, nIns, nOuts, pFileNameOut ) == 0 )
945 printf(
"Something went wrong when minimizing the cover\n" );
956 int nIns, nOuts, nProducts, nFanins, i, k;
958 nIns = Abc_NtkCiNum( pNtk );
959 nOuts = Abc_NtkCoNum( pNtk );
964 pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pNode) );
965 if ( !Abc_ObjIsNode(pDriver) )
982 vEsop = Vec_WecAlloc( nProducts+1 );
986 pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pNode) );
989 nFanins = Abc_ObjFaninNum(pDriver);
992 Vec_Int_t *vCubeIn = Vec_WecPushLevel( vEsop );
993 Vec_IntGrow( vCubeIn, nIns+2 );
997 pFanin = Abc_ObjFanin0Ntk(pFanin);
998 assert( (
int)(ABC_PTRUINT_T)pFanin->
pCopy < nIns );
999 if ( pCube[k] ==
'0' )
1001 Vec_IntPush( vCubeIn, 2*k + 1 );
1003 else if ( pCube[k] ==
'1' )
1005 Vec_IntPush( vCubeIn, 2*k );
1008 Vec_IntPush( vCubeIn, -( i + 1 ) );
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
#define Abc_SopForEachCube(pSop, nFanins, pCube)
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
varvalue GetVar(Cube *pC, int Var)
INLINE FUNCTION DEFINITIONS ///.
Vec_Wec_t * Abc_ExorcismNtk2Esop(Abc_Ntk_t *pNtk)
int Exorcism(Vec_Wec_t *vEsop, int nIns, int nOuts, char *pFileNameOut)
int Abc_ExorcismMain(Vec_Wec_t *vEsop, int nIns, int nOuts, char *pFileNameOut, int Quality, int Verbosity, int nCubesMax, int fUseQCost)
void AddCubesToStartingCover(Vec_Wec_t *vEsop)
int ComputeQCostTcountBits(Cube *p)
int ComputeQCostTcount(Vec_Int_t *vCube)
int ComputeQCostBits(Cube *p)
int ComputeQCost(Vec_Int_t *vCube)
int GetQCost(int nVars, int nNegs)
EXTERNAL FUNCTIONS ///.
ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
GLOBAL VARIABLES ///.
int ToffoliGateCount(int controls, int lines)
int AllocateCover(int nCubes, int nWordsIn, int nWordsOut)
CUBE COVER MEMORY MANAGEMENT //.
void PrepareBitSetModule()
FUNCTION DEFINITIONS ///.
int IterativelyApplyExorLink4(char fDistEnable)
int AllocateCubeSets(int nVarsIn, int nVarsOut)
CUBE SET MANIPULATION PROCEDURES ///.
int AllocateQueques(int nPlaces)
void InsertVarsWithoutClearing(Cube *pC, int *pVars, int nVarsIn, int *pVarValues, int Output)
int WriteResultIntoFile(char *pFileName)
int IterativelyApplyExorLink3(char fDistEnable)
int IterativelyApplyExorLink2(char fDistEnable)
FUNCTIONS OF THIS MODULE ///.
int CheckForCloseCubes(Cube *p, int fAddCube)
varvalue
VARVALUE and CUBEDIST enum typedefs ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.