ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
extra.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/st/st.h"
Include dependency graph for extra.h:

Go to the source code of this file.

Typedefs

typedef unsigned short uint16
 
typedef unsigned int uint32
 
typedef struct Extra_BitMat_t_ Extra_BitMat_t
 
typedef struct Extra_FileReader_t_ Extra_FileReader_t
 
typedef struct Extra_MmFixed_t_ Extra_MmFixed_t
 
typedef struct Extra_MmFlex_t_ Extra_MmFlex_t
 
typedef struct Extra_MmStep_t_ Extra_MmStep_t
 
typedef struct Sdm_Man_t_ Sdm_Man_t
 
typedef struct ProgressBarStruct ProgressBar
 

Functions

Extra_BitMat_tExtra_BitMatrixStart (int nSize)
 
void Extra_BitMatrixClean (Extra_BitMat_t *p)
 
void Extra_BitMatrixStop (Extra_BitMat_t *p)
 
void Extra_BitMatrixPrint (Extra_BitMat_t *p)
 
int Extra_BitMatrixReadSize (Extra_BitMat_t *p)
 
void Extra_BitMatrixInsert1 (Extra_BitMat_t *p, int i, int k)
 
int Extra_BitMatrixLookup1 (Extra_BitMat_t *p, int i, int k)
 
void Extra_BitMatrixDelete1 (Extra_BitMat_t *p, int i, int k)
 
void Extra_BitMatrixInsert2 (Extra_BitMat_t *p, int i, int k)
 
int Extra_BitMatrixLookup2 (Extra_BitMat_t *p, int i, int k)
 
void Extra_BitMatrixDelete2 (Extra_BitMat_t *p, int i, int k)
 
void Extra_BitMatrixOr (Extra_BitMat_t *p, int i, unsigned *pInfo)
 
void Extra_BitMatrixOrTwo (Extra_BitMat_t *p, int i, int j)
 
int Extra_BitMatrixCountOnesUpper (Extra_BitMat_t *p)
 
int Extra_BitMatrixIsDisjoint (Extra_BitMat_t *p1, Extra_BitMat_t *p2)
 
int Extra_BitMatrixIsClique (Extra_BitMat_t *p)
 
char * Extra_FileGetSimilarName (char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
 
char * Extra_FileNameExtension (char *FileName)
 
char * Extra_FileNameAppend (char *pBase, char *pSuffix)
 
char * Extra_FileNameGeneric (char *FileName)
 
char * Extra_FileNameGenericAppend (char *pBase, char *pSuffix)
 
void Extra_FileNameCorrectPath (char *FileName)
 
char * Extra_FileNameWithoutPath (char *FileName)
 
char * Extra_FilePathWithoutName (char *FileName)
 
char * Extra_FileInTheSameDir (char *pPathFile, char *pFileName)
 
char * Extra_FileDesignName (char *pFileName)
 
int Extra_FileCheck (char *pFileName)
 
int Extra_FileSize (char *pFileName)
 
char * Extra_FileRead (FILE *pFile)
 
char * Extra_FileRead2 (FILE *pFile, FILE *pFile2)
 
char * Extra_FileReadContents (char *pFileName)
 
char * Extra_FileReadContents2 (char *pFileName, char *pFileName2)
 
int Extra_FileIsType (char *pFileName, char *pS1, char *pS2, char *pS3)
 
char * Extra_TimeStamp ()
 
char * Extra_StringAppend (char *pStrGiven, char *pStrAdd)
 
void Extra_StringClean (char *pStrGiven, char *pCharKeep)
 
unsigned Extra_ReadBinary (char *Buffer)
 
void Extra_PrintBinary (FILE *pFile, unsigned Sign[], int nBits)
 
void Extra_PrintBinary2 (FILE *pFile, unsigned Sign[], int nBits)
 
int Extra_ReadHex (unsigned Sign[], char *pString, int nDigits)
 
int Extra_ReadHexadecimal (unsigned Sign[], char *pString, int nVars)
 
void Extra_PrintHexadecimal (FILE *pFile, unsigned Sign[], int nVars)
 
void Extra_PrintHexadecimalString (char *pString, unsigned Sign[], int nVars)
 
void Extra_PrintHex (FILE *pFile, unsigned *pTruth, int nVars)
 
void Extra_PrintHex2 (FILE *pFile, unsigned *pTruth, int nVars)
 
void Extra_PrintHexReverse (FILE *pFile, unsigned *pTruth, int nVars)
 
void Extra_PrintSymbols (FILE *pFile, char Char, int nTimes, int fPrintNewLine)
 
Extra_FileReader_tExtra_FileReaderAlloc (char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
 FUNCTION DEFINITIONS ///.
 
void Extra_FileReaderFree (Extra_FileReader_t *p)
 
char * Extra_FileReaderGetFileName (Extra_FileReader_t *p)
 
int Extra_FileReaderGetFileSize (Extra_FileReader_t *p)
 
int Extra_FileReaderGetCurPosition (Extra_FileReader_t *p)
 
void * Extra_FileReaderGetTokens (Extra_FileReader_t *p)
 
int Extra_FileReaderGetLineNumber (Extra_FileReader_t *p, int iToken)
 
Extra_MmFixed_tExtra_MmFixedStart (int nEntrySize)
 
void Extra_MmFixedStop (Extra_MmFixed_t *p)
 
char * Extra_MmFixedEntryFetch (Extra_MmFixed_t *p)
 
void Extra_MmFixedEntryRecycle (Extra_MmFixed_t *p, char *pEntry)
 
void Extra_MmFixedRestart (Extra_MmFixed_t *p)
 
int Extra_MmFixedReadMemUsage (Extra_MmFixed_t *p)
 
int Extra_MmFixedReadMaxEntriesUsed (Extra_MmFixed_t *p)
 
Extra_MmFlex_tExtra_MmFlexStart ()
 
void Extra_MmFlexStop (Extra_MmFlex_t *p)
 
void Extra_MmFlexPrint (Extra_MmFlex_t *p)
 
char * Extra_MmFlexEntryFetch (Extra_MmFlex_t *p, int nBytes)
 
int Extra_MmFlexReadMemUsage (Extra_MmFlex_t *p)
 
Extra_MmStep_tExtra_MmStepStart (int nSteps)
 
void Extra_MmStepStop (Extra_MmStep_t *p)
 
char * Extra_MmStepEntryFetch (Extra_MmStep_t *p, int nBytes)
 
void Extra_MmStepEntryRecycle (Extra_MmStep_t *p, char *pEntry, int nBytes)
 
int Extra_MmStepReadMemUsage (Extra_MmStep_t *p)
 
int Extra_Base2LogDouble (double Num)
 
double Extra_Power2 (int Num)
 
int Extra_Power3 (int Num)
 
int Extra_NumCombinations (int k, int n)
 
int * Extra_DeriveRadixCode (int Number, int Radix, int nDigits)
 
int Extra_CountOnes (unsigned char *pBytes, int nBytes)
 
int Extra_Factorial (int n)
 
char ** Extra_Permutations (int n)
 
unsigned Extra_TruthPermute (unsigned Truth, char *pPerms, int nVars, int fReverse)
 
unsigned Extra_TruthPolarize (unsigned uTruth, int Polarity, int nVars)
 
unsigned Extra_TruthCanonN (unsigned uTruth, int nVars)
 
unsigned Extra_TruthCanonNN (unsigned uTruth, int nVars)
 
unsigned Extra_TruthCanonP (unsigned uTruth, int nVars)
 
unsigned Extra_TruthCanonNP (unsigned uTruth, int nVars)
 
unsigned Extra_TruthCanonNPN (unsigned uTruth, int nVars)
 
void Extra_Truth4VarNPN (unsigned short **puCanons, char **puPhases, char **puPerms, unsigned char **puMap)
 
void Extra_Truth4VarN (unsigned short **puCanons, char ***puPhases, char **ppCounters, int nPhasesMax)
 
unsigned short Extra_TruthPerm4One (unsigned uTruth, int Phase)
 
unsigned Extra_TruthPerm5One (unsigned uTruth, int Phase)
 
void Extra_TruthPerm6One (unsigned *uTruth, int Phase, unsigned *uTruthRes)
 
void Extra_TruthExpand (int nVars, int nWords, unsigned *puTruth, unsigned uPhase, unsigned *puTruthR)
 
void ** Extra_ArrayAlloc (int nCols, int nRows, int Size)
 
unsigned short ** Extra_TruthPerm43 ()
 
unsigned ** Extra_TruthPerm53 ()
 
unsigned ** Extra_TruthPerm54 ()
 
void Extra_BubbleSort (int Order[], int Costs[], int nSize, int fIncreasing)
 
int * Extra_GreyCodeSchedule (int n)
 
int * Extra_PermSchedule (int n)
 
word Extra_Truth6MinimumExact (word t, int *pComp, int *pPerm)
 
word Extra_Truth6MinimumHeuristic (word t)
 
int Extra_TruthCanonFastN (int nVarsMax, int nVarsReal, unsigned *pt, unsigned **pptRes, char **ppfRes)
 
int Sdm_ManCanRead ()
 
Sdm_Man_tSdm_ManRead ()
 
void Sdm_ManQuit ()
 
int Sdm_ManComputeFunc (Sdm_Man_t *p, int iDsdLit0, int iDsdLit1, int *pCut, int uMask, int fXor)
 
void Sdm_ManPrintDsdStats (Sdm_Man_t *p, int fVerbose)
 FUNCTION DEFINITIONS ///.
 
int Sdm_ManReadDsdVarNum (Sdm_Man_t *p, int iDsd)
 
int Sdm_ManReadDsdAndNum (Sdm_Man_t *p, int iDsd)
 
int Sdm_ManReadDsdClauseNum (Sdm_Man_t *p, int iDsd)
 
word Sdm_ManReadDsdTruth (Sdm_Man_t *p, int iDsd)
 
char * Sdm_ManReadDsdStr (Sdm_Man_t *p, int iDsd)
 
void Sdm_ManReadCnfCosts (Sdm_Man_t *p, int *pCosts, int nCosts)
 
ProgressBarExtra_ProgressBarStart (FILE *pFile, int nItemsTotal)
 FUNCTION DEFINITIONS ///.
 
void Extra_ProgressBarStop (ProgressBar *p)
 
void Extra_ProgressBarUpdate_int (ProgressBar *p, int nItemsCur, char *pString)
 
unsigned ** Extra_TruthElementary (int nVars)
 
void Extra_TruthSwapAdjacentVars (unsigned *pOut, unsigned *pIn, int nVars, int Start)
 
void Extra_TruthStretch (unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase)
 
void Extra_TruthShrink (unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase)
 
int Extra_TruthVarInSupport (unsigned *pTruth, int nVars, int iVar)
 
int Extra_TruthSupportSize (unsigned *pTruth, int nVars)
 
int Extra_TruthSupport (unsigned *pTruth, int nVars)
 
void Extra_TruthCofactor0 (unsigned *pTruth, int nVars, int iVar)
 
void Extra_TruthCofactor1 (unsigned *pTruth, int nVars, int iVar)
 
void Extra_TruthExist (unsigned *pTruth, int nVars, int iVar)
 
void Extra_TruthForall (unsigned *pTruth, int nVars, int iVar)
 
void Extra_TruthMux (unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
 
void Extra_TruthChangePhase (unsigned *pTruth, int nVars, int iVar)
 
int Extra_TruthMinCofSuppOverlap (unsigned *pTruth, int nVars, int *pVarMin)
 
void Extra_TruthCountOnesInCofs (unsigned *pTruth, int nVars, short *pStore)
 
unsigned Extra_TruthHash (unsigned *pIn, int nWords)
 
unsigned Extra_TruthSemiCanonicize (unsigned *pInOut, unsigned *pAux, int nVars, char *pCanonPerm, short *pStore)
 
abctime Extra_CpuTime ()
 
double Extra_CpuTimeDouble ()
 
int Extra_GetSoftDataLimit ()
 FUNCTION DEFINITIONS ///.
 
ABC_DLL void Extra_UtilGetoptReset ()
 
int Extra_UtilGetopt (int argc, char *argv[], const char *optstring)
 
char * Extra_UtilPrintTime (long t)
 
char * Extra_UtilStrsav (const char *s)
 
char * Extra_UtilTildeExpand (char *fname)
 
char * Extra_UtilFileSearch (char *file, char *path, char *mode)
 

Variables

ABC_NAMESPACE_HEADER_START typedef unsigned char uint8
 
void(* Extra_UtilMMoutOfMemory )(long size)
 
const char * globalUtilOptarg
 
int globalUtilOptind
 

Typedef Documentation

◆ Extra_BitMat_t

Definition at line 81 of file extra.h.

◆ Extra_FileReader_t

Definition at line 135 of file extra.h.

◆ Extra_MmFixed_t

Definition at line 147 of file extra.h.

◆ Extra_MmFlex_t

Definition at line 148 of file extra.h.

◆ Extra_MmStep_t

Definition at line 149 of file extra.h.

◆ ProgressBar

Definition at line 240 of file extra.h.

◆ Sdm_Man_t

typedef struct Sdm_Man_t_ Sdm_Man_t

Definition at line 225 of file extra.h.

◆ uint16

typedef unsigned short uint16

Definition at line 72 of file extra.h.

◆ uint32

typedef unsigned int uint32

Definition at line 73 of file extra.h.

Function Documentation

◆ Extra_ArrayAlloc()

void ** Extra_ArrayAlloc ( int nCols,
int nRows,
int Size )
extern

Function*************************************************************

Synopsis [Allocated one-memory-chunk array.]

Description []

SideEffects []

SeeAlso []

Definition at line 881 of file extraUtilMisc.c.

882{
883 void ** pRes;
884 char * pBuffer;
885 int i;
886 assert( nCols > 0 && nRows > 0 && Size > 0 );
887 pBuffer = ABC_ALLOC( char, nCols * (sizeof(void *) + nRows * Size) );
888 pRes = (void **)pBuffer;
889 pRes[0] = pBuffer + nCols * sizeof(void *);
890 for ( i = 1; i < nCols; i++ )
891 pRes[i] = (void *)((char *)pRes[0] + i * nRows * Size);
892 return pRes;
893}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Extra_Base2LogDouble()

int Extra_Base2LogDouble ( double Num)
extern

Function********************************************************************

Synopsis [Finds the smallest integer larger of equal than the logarithm.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file extraUtilMisc.c.

76{
77 double Res;
78 int ResInt;
79
80 Res = log(Num)/log(2.0);
81 ResInt = (int)Res;
82 if ( ResInt == Res )
83 return ResInt;
84 else
85 return ResInt+1;
86}

◆ Extra_BitMatrixClean()

void Extra_BitMatrixClean ( Extra_BitMat_t * p)
extern

Function*************************************************************

Synopsis [Stops the bit matrix.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file extraUtilBitMatrix.c.

111{
112 memset( p->ppData[0], 0, sizeof(unsigned) * p->nSize * p->nWords );
113}
Cube * p
Definition exorList.c:222
char * memset()
Here is the call graph for this function:

◆ Extra_BitMatrixCountOnesUpper()

int Extra_BitMatrixCountOnesUpper ( Extra_BitMat_t * p)
extern

Function*************************************************************

Synopsis [Counts the number of 1's in the upper rectangle.]

Description []

SideEffects []

SeeAlso []

Definition at line 349 of file extraUtilBitMatrix.c.

350{
351 int i, k, nTotal = 0;
352 for ( i = 0; i < p->nSize; i++ )
353 for ( k = i + 1; k < p->nSize; k++ )
354 nTotal += ( (p->ppData[i][k>>5] & (1 << (k&31))) > 0 );
355 return nTotal;
356}
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37

◆ Extra_BitMatrixDelete1()

void Extra_BitMatrixDelete1 ( Extra_BitMat_t * p,
int i,
int k )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 230 of file extraUtilBitMatrix.c.

231{
232 p->nDeletes++;
233 if ( i < k )
234 p->ppData[i][k>>p->nBitShift] &= ~(1<<(k & p->uMask));
235 else
236 p->ppData[k][i>>p->nBitShift] &= ~(1<<(i & p->uMask));
237}

◆ Extra_BitMatrixDelete2()

void Extra_BitMatrixDelete2 ( Extra_BitMat_t * p,
int i,
int k )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 292 of file extraUtilBitMatrix.c.

293{
294 p->nDeletes++;
295 if ( i > k )
296 p->ppData[i][k>>p->nBitShift] &= ~(1<<(k & p->uMask));
297 else
298 p->ppData[k][i>>p->nBitShift] &= ~(1<<(i & p->uMask));
299}

◆ Extra_BitMatrixInsert1()

void Extra_BitMatrixInsert1 ( Extra_BitMat_t * p,
int i,
int k )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file extraUtilBitMatrix.c.

191{
192 p->nInserts++;
193 if ( i < k )
194 p->ppData[i][k>>p->nBitShift] |= (1<<(k & p->uMask));
195 else
196 p->ppData[k][i>>p->nBitShift] |= (1<<(i & p->uMask));
197}
Here is the caller graph for this function:

◆ Extra_BitMatrixInsert2()

void Extra_BitMatrixInsert2 ( Extra_BitMat_t * p,
int i,
int k )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file extraUtilBitMatrix.c.

253{
254 p->nInserts++;
255 if ( i > k )
256 p->ppData[i][k>>p->nBitShift] |= (1<<(k & p->uMask));
257 else
258 p->ppData[k][i>>p->nBitShift] |= (1<<(i & p->uMask));
259}
Here is the caller graph for this function:

◆ Extra_BitMatrixIsClique()

int Extra_BitMatrixIsClique ( Extra_BitMat_t * pMat)
extern

Function*************************************************************

Synopsis [Returns 1 if the matrix is a set of cliques.]

Description [For example pairwise symmetry info should satisfy this property.]

SideEffects []

SeeAlso []

Definition at line 391 of file extraUtilBitMatrix.c.

392{
393 int v, u, i;
394 for ( v = 0; v < pMat->nSize; v++ )
395 for ( u = v+1; u < pMat->nSize; u++ )
396 {
397 if ( !Extra_BitMatrixLookup1( pMat, v, u ) )
398 continue;
399 // v and u are symmetric
400 for ( i = 0; i < pMat->nSize; i++ )
401 {
402 if ( i == v || i == u )
403 continue;
404 // i is neither v nor u
405 // the symmetry status of i is the same w.r.t. to v and u
406 if ( Extra_BitMatrixLookup1( pMat, i, v ) != Extra_BitMatrixLookup1( pMat, i, u ) )
407 return 0;
408 }
409 }
410 return 1;
411}
int Extra_BitMatrixLookup1(Extra_BitMat_t *p, int i, int k)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_BitMatrixIsDisjoint()

int Extra_BitMatrixIsDisjoint ( Extra_BitMat_t * p1,
Extra_BitMat_t * p2 )
extern

Function*************************************************************

Synopsis [Returns 1 if the matrices have no entries in common.]

Description []

SideEffects []

SeeAlso []

Definition at line 369 of file extraUtilBitMatrix.c.

370{
371 int i, w;
372 assert( p1->nSize == p2->nSize );
373 for ( i = 0; i < p1->nSize; i++ )
374 for ( w = 0; w < p1->nWords; w++ )
375 if ( p1->ppData[i][w] & p2->ppData[i][w] )
376 return 0;
377 return 1;
378}
Here is the caller graph for this function:

◆ Extra_BitMatrixLookup1()

int Extra_BitMatrixLookup1 ( Extra_BitMat_t * p,
int i,
int k )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 210 of file extraUtilBitMatrix.c.

211{
212 p->nLookups++;
213 if ( i < k )
214 return ((p->ppData[i][k>>p->nBitShift] & (1<<(k & p->uMask))) > 0);
215 else
216 return ((p->ppData[k][i>>p->nBitShift] & (1<<(i & p->uMask))) > 0);
217}
Here is the caller graph for this function:

◆ Extra_BitMatrixLookup2()

int Extra_BitMatrixLookup2 ( Extra_BitMat_t * p,
int i,
int k )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file extraUtilBitMatrix.c.

273{
274 p->nLookups++;
275 if ( i > k )
276 return ((p->ppData[i][k>>p->nBitShift] & (1<<(k & p->uMask))) > 0);
277 else
278 return ((p->ppData[k][i>>p->nBitShift] & (1<<(i & p->uMask))) > 0);
279}

◆ Extra_BitMatrixOr()

void Extra_BitMatrixOr ( Extra_BitMat_t * p,
int i,
unsigned * pInfo )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 313 of file extraUtilBitMatrix.c.

314{
315 int w;
316 for ( w = 0; w < p->nWords; w++ )
317 p->ppData[i][w] |= pInfo[w];
318}

◆ Extra_BitMatrixOrTwo()

void Extra_BitMatrixOrTwo ( Extra_BitMat_t * p,
int i,
int j )
extern

Function*************************************************************

Synopsis [Inserts the element into the upper part.]

Description []

SideEffects []

SeeAlso []

Definition at line 331 of file extraUtilBitMatrix.c.

332{
333 int w;
334 for ( w = 0; w < p->nWords; w++ )
335 p->ppData[i][w] = p->ppData[j][w] = (p->ppData[i][w] | p->ppData[j][w]);
336}
Here is the caller graph for this function:

◆ Extra_BitMatrixPrint()

void Extra_BitMatrixPrint ( Extra_BitMat_t * pMat)
extern

Function*************************************************************

Synopsis [Prints the bit-matrix.]

Description []

SideEffects []

SeeAlso []

Definition at line 144 of file extraUtilBitMatrix.c.

145{
146 int i, k, nVars;
147 printf( "\n" );
148 nVars = Extra_BitMatrixReadSize( pMat );
149 for ( i = 0; i < nVars; i++ )
150 {
151 for ( k = 0; k <= i; k++ )
152 printf( " " );
153 for ( k = i+1; k < nVars; k++ )
154 if ( Extra_BitMatrixLookup1( pMat, i, k ) )
155 printf( "1" );
156 else
157 printf( "." );
158 printf( "\n" );
159 }
160}
int Extra_BitMatrixReadSize(Extra_BitMat_t *p)
Here is the call graph for this function:

◆ Extra_BitMatrixReadSize()

int Extra_BitMatrixReadSize ( Extra_BitMat_t * p)
extern

Function*************************************************************

Synopsis [Reads the matrix size.]

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file extraUtilBitMatrix.c.

175{
176 return p->nSize;
177}
Here is the caller graph for this function:

◆ Extra_BitMatrixStart()

Extra_BitMat_t * Extra_BitMatrixStart ( int nSize)
extern

AutomaticStart AutomaticEnd Function*************************************************************

Synopsis [Starts the bit matrix.]

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file extraUtilBitMatrix.c.

82{
84 int i;
86 memset( p, 0, sizeof(Extra_BitMat_t) );
87 p->nSize = nSize;
88 p->nBitShift = (sizeof(unsigned) == 4) ? 5: 6;
89 p->uMask = (sizeof(unsigned) == 4) ? 31: 63;
90 p->nWords = nSize / (8 * sizeof(unsigned)) + ((nSize % (8 * sizeof(unsigned))) > 0);
91 p->ppData = ABC_ALLOC( unsigned *, nSize );
92 p->ppData[0] = ABC_ALLOC( unsigned, nSize * p->nWords );
93 memset( p->ppData[0], 0, sizeof(unsigned) * nSize * p->nWords );
94 for ( i = 1; i < nSize; i++ )
95 p->ppData[i] = p->ppData[i-1] + p->nWords;
96 return p;
97}
struct Extra_BitMat_t_ Extra_BitMat_t
Definition extra.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_BitMatrixStop()

void Extra_BitMatrixStop ( Extra_BitMat_t * p)
extern

Function*************************************************************

Synopsis [Stops the bit matrix.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file extraUtilBitMatrix.c.

127{
128 ABC_FREE( p->ppData[0] );
129 ABC_FREE( p->ppData );
130 ABC_FREE( p );
131}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Extra_BubbleSort()

void Extra_BubbleSort ( int Order[],
int Costs[],
int nSize,
int fIncreasing )
extern

Function*************************************************************

Synopsis [Bubble-sorts components by scores in increasing order.]

Description []

SideEffects []

SeeAlso []

Definition at line 2045 of file extraUtilMisc.c.

2046{
2047 int i, Temp, fChanges;
2048 assert( nSize < 1000 );
2049 for ( i = 0; i < nSize; i++ )
2050 Order[i] = i;
2051 if ( fIncreasing )
2052 {
2053 do {
2054 fChanges = 0;
2055 for ( i = 0; i < nSize - 1; i++ )
2056 {
2057 if ( Costs[Order[i]] <= Costs[Order[i+1]] )
2058 continue;
2059 Temp = Order[i];
2060 Order[i] = Order[i+1];
2061 Order[i+1] = Temp;
2062 fChanges = 1;
2063 }
2064 } while ( fChanges );
2065 }
2066 else
2067 {
2068 do {
2069 fChanges = 0;
2070 for ( i = 0; i < nSize - 1; i++ )
2071 {
2072 if ( Costs[Order[i]] >= Costs[Order[i+1]] )
2073 continue;
2074 Temp = Order[i];
2075 Order[i] = Order[i+1];
2076 Order[i+1] = Temp;
2077 fChanges = 1;
2078 }
2079 } while ( fChanges );
2080 }
2081}
Here is the caller graph for this function:

◆ Extra_CountOnes()

int Extra_CountOnes ( unsigned char * pBytes,
int nBytes )
extern

Function*************************************************************

Synopsis [Counts the number of ones in the bitstring.]

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file extraUtilMisc.c.

187{
188 static int bit_count[256] = {
189 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
190 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
191 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
192 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
193 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
194 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
195 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
196 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
197 };
198
199 int i, Counter;
200 Counter = 0;
201 for ( i = 0; i < nBytes; i++ )
202 Counter += bit_count[ *(pBytes+i) ];
203 return Counter;
204}

◆ Extra_CpuTime()

abctime Extra_CpuTime ( )
extern

Function*************************************************************

Synopsis [util_cpu_time()]

Description []

SideEffects []

SeeAlso []

Definition at line 364 of file extraUtilUtil.c.

365{
366 return Abc_Clock();
367}

◆ Extra_CpuTimeDouble()

double Extra_CpuTimeDouble ( )
extern

Function*************************************************************

Synopsis [util_cpu_time()]

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file extraUtilUtil.c.

396{
397/*
398 struct rusage ru;
399 getrusage(RUSAGE_SELF, &ru);
400 return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000;
401*/
402 struct timespec ts;
403 if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 )
404 return (double)-1;
405 double res = ((double) ts.tv_sec);
406 res += ((double) ts.tv_nsec) / 1000000000;
407 return res;
408}
Here is the caller graph for this function:

◆ Extra_DeriveRadixCode()

int * Extra_DeriveRadixCode ( int Number,
int Radix,
int nDigits )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file extraUtilMisc.c.

162{
163 static int Code[100];
164 int i;
165 assert( nDigits < 100 );
166 for ( i = 0; i < nDigits; i++ )
167 {
168 Code[i] = Number % Radix;
169 Number = Number / Radix;
170 }
171 assert( Number == 0 );
172 return Code;
173}
#define Code
Definition deflate.h:76

◆ Extra_Factorial()

int Extra_Factorial ( int n)
extern

Function********************************************************************

Synopsis [Computes the factorial.]

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file extraUtilMisc.c.

218{
219 int i, Res = 1;
220 for ( i = 1; i <= n; i++ )
221 Res *= i;
222 return Res;
223}
Here is the caller graph for this function:

◆ Extra_FileCheck()

int Extra_FileCheck ( char * pFileName)
extern

Function*************************************************************

Synopsis [Returns the file size.]

Description [The file should be closed.]

SideEffects []

SeeAlso []

Definition at line 300 of file extraUtilFile.c.

301{
302 FILE * pFile;
303 pFile = fopen( pFileName, "rb" );
304 if ( pFile == NULL )
305 {
306 printf( "Extra_FileCheck(): File \"%s\" does not exist.\n", pFileName );
307 return 0;
308 }
309 fseek( pFile, 0, SEEK_END );
310 if ( ftell( pFile ) == 0 )
311 printf( "Extra_FileCheck(): File \"%s\" is empty.\n", pFileName );
312 fclose( pFile );
313 return 1;
314}
#define SEEK_END
Definition zconf.h:392
Here is the caller graph for this function:

◆ Extra_FileDesignName()

char * Extra_FileDesignName ( char * pFileName)
extern

Definition at line 269 of file extraUtilFile.c.

270{
271 char * pBeg, * pEnd, * pStore, * pCur;
272 // find the first dot
273 for ( pEnd = pFileName; *pEnd; pEnd++ )
274 if ( *pEnd == '.' )
275 break;
276 // find the first char
277 for ( pBeg = pEnd - 1; pBeg >= pFileName; pBeg-- )
278 if ( !((*pBeg >= 'a' && *pBeg <= 'z') || (*pBeg >= 'A' && *pBeg <= 'Z') || (*pBeg >= '0' && *pBeg <= '9') || *pBeg == '_') )
279 break;
280 pBeg++;
281 // fill up storage
282 pStore = ABC_ALLOC( char, pEnd - pBeg + 1 );
283 for ( pCur = pStore; pBeg < pEnd; pBeg++, pCur++ )
284 *pCur = *pBeg;
285 *pCur = 0;
286 return pStore;
287}
Here is the caller graph for this function:

◆ Extra_FileGetSimilarName()

char * Extra_FileGetSimilarName ( char * pFileNameWrong,
char * pS1,
char * pS2,
char * pS3,
char * pS4,
char * pS5 )
extern

CFile****************************************************************

FileName [extraUtilFile.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [extra]

Synopsis [File management utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
extraUtilFile.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] AutomaticStart AutomaticEnd Function*************************************************************

Synopsis [Tries to find a file name with a different extension.]

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file extraUtilFile.c.

79{
80 FILE * pFile;
81 char * pFileNameOther;
82 char * pFileGen;
83
84 if ( pS1 == NULL )
85 return NULL;
86
87 // get the generic file name
88 pFileGen = Extra_FileNameGeneric( pFileNameWrong );
89 pFileNameOther = Extra_FileNameAppend( pFileGen, pS1 );
90 pFile = fopen( pFileNameOther, "r" );
91 if ( pFile == NULL && pS2 )
92 { // try one more
93 pFileNameOther = Extra_FileNameAppend( pFileGen, pS2 );
94 pFile = fopen( pFileNameOther, "r" );
95 if ( pFile == NULL && pS3 )
96 { // try one more
97 pFileNameOther = Extra_FileNameAppend( pFileGen, pS3 );
98 pFile = fopen( pFileNameOther, "r" );
99 if ( pFile == NULL && pS4 )
100 { // try one more
101 pFileNameOther = Extra_FileNameAppend( pFileGen, pS4 );
102 pFile = fopen( pFileNameOther, "r" );
103 if ( pFile == NULL && pS5 )
104 { // try one more
105 pFileNameOther = Extra_FileNameAppend( pFileGen, pS5 );
106 pFile = fopen( pFileNameOther, "r" );
107 }
108 }
109 }
110 }
111 ABC_FREE( pFileGen );
112 if ( pFile )
113 {
114 fclose( pFile );
115 return pFileNameOther;
116 }
117 // did not find :(
118 return NULL;
119}
char * Extra_FileNameAppend(char *pBase, char *pSuffix)
char * Extra_FileNameGeneric(char *FileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileInTheSameDir()

char * Extra_FileInTheSameDir ( char * pPathFile,
char * pFileName )
extern

Definition at line 257 of file extraUtilFile.c.

258{
259 static char pBuffer[1000]; char * pThis;
260 assert( strlen(pPathFile) + strlen(pFileName) < 990 );
261 memmove( pBuffer, pPathFile, strlen(pPathFile) );
262 for ( pThis = pBuffer + strlen(pPathFile) - 1; pThis >= pBuffer; pThis-- )
263 if ( *pThis == '\\' || *pThis == '/' )
264 break;
265 memmove( ++pThis, pFileName, strlen(pFileName) );
266 pThis[strlen(pFileName)] = '\0';
267 return pBuffer;
268}
int strlen()
char * memmove()
Here is the call graph for this function:

◆ Extra_FileIsType()

int Extra_FileIsType ( char * pFileName,
char * pS1,
char * pS2,
char * pS3 )
extern

Function*************************************************************

Synopsis [Returns one if the file has a given extension.]

Description []

SideEffects []

SeeAlso []

Definition at line 439 of file extraUtilFile.c.

440{
441 int lenS, lenF = strlen(pFileName);
442 lenS = pS1 ? strlen(pS1) : 0;
443 if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS1, lenS ) )
444 return 1;
445 lenS = pS2 ? strlen(pS2) : 0;
446 if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS2, lenS ) )
447 return 1;
448 lenS = pS3 ? strlen(pS3) : 0;
449 if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS3, lenS ) )
450 return 1;
451 return 0;
452}
int strncmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileNameAppend()

char * Extra_FileNameAppend ( char * pBase,
char * pSuffix )
extern

Function*************************************************************

Synopsis [Returns the composite name of the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file extraUtilFile.c.

154{
155 static char Buffer[500];
156 assert( strlen(pBase) + strlen(pSuffix) < 500 );
157 sprintf( Buffer, "%s%s", pBase, pSuffix );
158 return Buffer;
159}
char * sprintf()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileNameCorrectPath()

void Extra_FileNameCorrectPath ( char * FileName)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 215 of file extraUtilFile.c.

216{
217 char * pStart;
218 if ( FileName )
219 for ( pStart = FileName; *pStart; pStart++ )
220 if ( *pStart == '>' || *pStart == '\\' )
221 *pStart = '/';
222}
Here is the caller graph for this function:

◆ Extra_FileNameExtension()

char * Extra_FileNameExtension ( char * FileName)
extern

Function*************************************************************

Synopsis [Returns the pointer to the file extension.]

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file extraUtilFile.c.

133{
134 char * pDot;
135 // find the last "dot" in the file name, if it is present
136 for ( pDot = FileName + strlen(FileName)-1; pDot >= FileName; pDot-- )
137 if ( *pDot == '.' )
138 return pDot + 1;
139 return FileName;
140}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileNameGeneric()

char * Extra_FileNameGeneric ( char * FileName)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file extraUtilFile.c.

173{
174 char * pDot, * pRes;
175 pRes = Extra_UtilStrsav( FileName );
176 if ( (pDot = strrchr( pRes, '.' )) )
177 *pDot = 0;
178 return pRes;
179}
char * Extra_UtilStrsav(const char *s)
char * strrchr()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileNameGenericAppend()

char * Extra_FileNameGenericAppend ( char * pBase,
char * pSuffix )
extern

Function*************************************************************

Synopsis [Returns the composite name of the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file extraUtilFile.c.

193{
194 static char Buffer[PATH_MAX];
195 char * pDot;
196 assert( strlen(pBase) + strlen(pSuffix) < PATH_MAX );
197 strcpy( Buffer, pBase );
198 if ( (pDot = strrchr( Buffer, '.' )) )
199 *pDot = 0;
200 strcat( Buffer, pSuffix );
201 return Buffer;
202}
char * strcpy()
char * strcat()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileNameWithoutPath()

char * Extra_FileNameWithoutPath ( char * FileName)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file extraUtilFile.c.

236{
237 char * pRes;
238 for ( pRes = FileName + strlen(FileName) - 1; pRes >= FileName; pRes-- )
239 if ( *pRes == '\\' || *pRes == '/' )
240 return pRes + 1;
241 return FileName;
242}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FilePathWithoutName()

char * Extra_FilePathWithoutName ( char * FileName)
extern

Definition at line 243 of file extraUtilFile.c.

244{
245 char * pRes;
246 FileName = Abc_UtilStrsav( FileName );
247 for ( pRes = FileName + strlen(FileName) - 1; pRes >= FileName; pRes-- )
248 if ( *pRes == '\\' || *pRes == '/' )
249 {
250 pRes[1] = '\0';
251 Extra_FileNameCorrectPath( FileName );
252 return FileName;
253 }
254 ABC_FREE( FileName );
255 return NULL;
256}
void Extra_FileNameCorrectPath(char *FileName)
Here is the call graph for this function:

◆ Extra_FileRead()

char * Extra_FileRead ( FILE * pFile)
extern

Function*************************************************************

Synopsis [Read the file into the internal buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 355 of file extraUtilFile.c.

356{
357 int nFileSize;
358 char * pBuffer;
359 int RetValue;
360 // get the file size, in bytes
361 fseek( pFile, 0, SEEK_END );
362 nFileSize = ftell( pFile );
363 // move the file current reading position to the beginning
364 rewind( pFile );
365 // load the contents of the file into memory
366 pBuffer = ABC_ALLOC( char, nFileSize + 3 );
367 RetValue = fread( pBuffer, nFileSize, 1, pFile );
368 // terminate the string with '\0'
369 pBuffer[ nFileSize + 0] = '\n';
370 pBuffer[ nFileSize + 1] = '\0';
371 return pBuffer;
372}
VOID_HACK rewind()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileRead2()

char * Extra_FileRead2 ( FILE * pFile,
FILE * pFile2 )
extern

Definition at line 373 of file extraUtilFile.c.

374{
375 char * pBuffer;
376 int nSize, nSize2;
377 int RetValue;
378 // get the file size, in bytes
379 fseek( pFile, 0, SEEK_END );
380 nSize = ftell( pFile );
381 rewind( pFile );
382 // get the file size, in bytes
383 fseek( pFile2, 0, SEEK_END );
384 nSize2 = ftell( pFile2 );
385 rewind( pFile2 );
386 // load the contents of the file into memory
387 pBuffer = ABC_ALLOC( char, nSize + nSize2 + 3 );
388 RetValue = fread( pBuffer, nSize, 1, pFile );
389 RetValue = fread( pBuffer + nSize, nSize2, 1, pFile2 );
390 // terminate the string with '\0'
391 pBuffer[ nSize + nSize2 + 0] = '\n';
392 pBuffer[ nSize + nSize2 + 1] = '\0';
393 return pBuffer;
394}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileReadContents()

char * Extra_FileReadContents ( char * pFileName)
extern

Function*************************************************************

Synopsis [Read the file into the internal buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 407 of file extraUtilFile.c.

408{
409 FILE * pFile;
410 char * pBuffer;
411 pFile = fopen( pFileName, "rb" );
412 pBuffer = pFile ? Extra_FileRead( pFile ) : NULL;
413 if ( pFile ) fclose( pFile );
414 return pBuffer;
415}
char * Extra_FileRead(FILE *pFile)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileReadContents2()

char * Extra_FileReadContents2 ( char * pFileName,
char * pFileName2 )
extern

Definition at line 416 of file extraUtilFile.c.

417{
418 FILE * pFile, * pFile2;
419 char * pBuffer;
420 pFile = fopen( pFileName, "rb" );
421 pFile2 = fopen( pFileName2, "rb" );
422 pBuffer = (pFile && pFile2) ? Extra_FileRead2( pFile, pFile2 ) : NULL;
423 if ( pFile ) fclose( pFile );
424 if ( pFile2 ) fclose( pFile2 );
425 return pBuffer;
426}
char * Extra_FileRead2(FILE *pFile, FILE *pFile2)
Here is the call graph for this function:

◆ Extra_FileReaderAlloc()

Extra_FileReader_t * Extra_FileReaderAlloc ( char * pFileName,
char * pCharsComment,
char * pCharsStop,
char * pCharsClean )
extern

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Starts the file reader.]

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file extraUtilReader.c.

92{
94 FILE * pFile;
95 char * pChar;
96 int nCharsToRead;
97 int RetValue;
98 // check if the file can be opened
99 pFile = fopen( pFileName, "rb" );
100 if ( pFile == NULL )
101 {
102 printf( "Extra_FileReaderAlloc(): Cannot open input file \"%s\".\n", pFileName );
103 return NULL;
104 }
105 // start the file reader
107 memset( p, 0, sizeof(Extra_FileReader_t) );
108 p->pFileName = pFileName;
109 p->pFile = pFile;
110 // set the character map
111 memset( p->pCharMap, EXTRA_CHAR_NORMAL, 256 );
112 for ( pChar = pCharsComment; *pChar; pChar++ )
113 p->pCharMap[(unsigned char)*pChar] = EXTRA_CHAR_COMMENT;
114 for ( pChar = pCharsStop; *pChar; pChar++ )
115 p->pCharMap[(unsigned char)*pChar] = EXTRA_CHAR_STOP;
116 for ( pChar = pCharsClean; *pChar; pChar++ )
117 p->pCharMap[(unsigned char)*pChar] = EXTRA_CHAR_CLEAN;
118 // get the file size, in bytes
119 fseek( pFile, 0, SEEK_END );
120 p->nFileSize = ftell( pFile );
121 rewind( pFile );
122 // allocate the buffer
123 p->pBuffer = ABC_ALLOC( char, EXTRA_BUFFER_SIZE+1 );
124 p->nBufferSize = EXTRA_BUFFER_SIZE;
125 p->pBufferCur = p->pBuffer;
126 // determine how many chars to read
127 nCharsToRead = EXTRA_MINIMUM(p->nFileSize, EXTRA_BUFFER_SIZE);
128 // load the first part into the buffer
129 RetValue = fread( p->pBuffer, nCharsToRead, 1, p->pFile );
130 p->nFileRead = nCharsToRead;
131 // set the ponters to the end and the stopping point
132 p->pBufferEnd = p->pBuffer + nCharsToRead;
133 p->pBufferStop = (p->nFileRead == p->nFileSize)? p->pBufferEnd : p->pBuffer + EXTRA_BUFFER_SIZE - EXTRA_OFFSET_SIZE;
134 // start the arrays
135 p->vTokens = Vec_PtrAlloc( 100 );
136 p->vLines = Vec_IntAlloc( 100 );
137 p->nLineCounter = 1; // 1-based line counting
138 return p;
139}
#define EXTRA_OFFSET_SIZE
@ EXTRA_CHAR_STOP
@ EXTRA_CHAR_CLEAN
@ EXTRA_CHAR_COMMENT
@ EXTRA_CHAR_NORMAL
#define EXTRA_MINIMUM(a, b)
#define EXTRA_BUFFER_SIZE
DECLARATIONS ///.
struct Extra_FileReader_t_ Extra_FileReader_t
Definition extra.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_FileReaderFree()

void Extra_FileReaderFree ( Extra_FileReader_t * p)
extern

Function*************************************************************

Synopsis [Stops the file reader.]

Description []

SideEffects []

SeeAlso []

Definition at line 152 of file extraUtilReader.c.

153{
154 if ( p->pFile )
155 fclose( p->pFile );
156 ABC_FREE( p->pBuffer );
157 Vec_PtrFree( p->vTokens );
158 Vec_IntFree( p->vLines );
159 ABC_FREE( p );
160}
Here is the caller graph for this function:

◆ Extra_FileReaderGetCurPosition()

int Extra_FileReaderGetCurPosition ( Extra_FileReader_t * p)
extern

Function*************************************************************

Synopsis [Returns the current reading position.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file extraUtilReader.c.

206{
207 return p->nFileRead - (p->pBufferEnd - p->pBufferCur);
208}

◆ Extra_FileReaderGetFileName()

char * Extra_FileReaderGetFileName ( Extra_FileReader_t * p)
extern

Function*************************************************************

Synopsis [Returns the file size.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file extraUtilReader.c.

174{
175 return p->pFileName;
176}

◆ Extra_FileReaderGetFileSize()

int Extra_FileReaderGetFileSize ( Extra_FileReader_t * p)
extern

Function*************************************************************

Synopsis [Returns the file size.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file extraUtilReader.c.

190{
191 return p->nFileSize;
192}

◆ Extra_FileReaderGetLineNumber()

int Extra_FileReaderGetLineNumber ( Extra_FileReader_t * p,
int iToken )
extern

Function*************************************************************

Synopsis [Returns the line number for the given token.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file extraUtilReader.c.

222{
223 assert( iToken >= 0 && iToken < p->vTokens->nSize );
224 return p->vLines->pArray[iToken];
225}

◆ Extra_FileReaderGetTokens()

void * Extra_FileReaderGetTokens ( Extra_FileReader_t * p)
extern

Function*************************************************************

Synopsis [Returns the next set of tokens.]

Description []

SideEffects []

SeeAlso []

Definition at line 239 of file extraUtilReader.c.

240{
241 Vec_Ptr_t * vTokens;
242 while ( (vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens_int( p )) )
243 if ( vTokens->nSize > 0 )
244 break;
245 return vTokens;
246}
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42

◆ Extra_FileSize()

int Extra_FileSize ( char * pFileName)
extern

Function*************************************************************

Synopsis [Returns the file size.]

Description [The file should be closed.]

SideEffects []

SeeAlso []

Definition at line 327 of file extraUtilFile.c.

328{
329 FILE * pFile;
330 int nFileSize;
331 pFile = fopen( pFileName, "rb" );
332 if ( pFile == NULL )
333 {
334 printf( "Extra_FileSize(): The file is unavailable (absent or open).\n" );
335 return 0;
336 }
337 fseek( pFile, 0, SEEK_END );
338 nFileSize = ftell( pFile );
339 fclose( pFile );
340 return nFileSize;
341}
Here is the caller graph for this function:

◆ Extra_GetSoftDataLimit()

int Extra_GetSoftDataLimit ( )
extern

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [getSoftDataLimit()]

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file extraUtilUtil.c.

65{
67}
#define EXTRA_RLIMIT_DATA_DEFAULT
DECLARATIONS ///.

◆ Extra_GreyCodeSchedule()

int * Extra_GreyCodeSchedule ( int n)
extern

Function*************************************************************

Synopsis [Computes complementation schedule for 2^n Grey codes.]

Description []

SideEffects []

SeeAlso []

Definition at line 2170 of file extraUtilMisc.c.

2171{
2172 int * pRes = ABC_ALLOC( int, (1<<n) );
2173 int i, k, b = 0;
2174// pRes[b++] = -1;
2175 for ( k = 0; k < n; k++ )
2176 for ( pRes[b++] = k, i = 1; i < (1<<k); i++ )
2177 pRes[b++] = pRes[i-1]; // pRes[i];
2178 pRes[b++] = n-1;
2179 assert( b == (1<<n) );
2180
2181 if ( 0 )
2182 {
2183 unsigned uSign = 0;
2184 for ( b = 0; b < (1<<n); b++ )
2185 {
2186 uSign ^= (1 << pRes[b]);
2187 printf( "%3d %3d ", b, pRes[b] );
2188 Extra_PrintBinary( stdout, &uSign, n );
2189 printf( "\n" );
2190 }
2191 }
2192 return pRes;
2193}
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_MmFixedEntryFetch()

char * Extra_MmFixedEntryFetch ( Extra_MmFixed_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file extraUtilMemory.c.

203{
204 char * pTemp;
205 int i;
206
207 // check if there are still free entries
208 if ( p->nEntriesUsed == p->nEntriesAlloc )
209 { // need to allocate more entries
210 assert( p->pEntriesFree == NULL );
211 if ( p->nChunks == p->nChunksAlloc )
212 {
213 p->nChunksAlloc *= 2;
214 p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
215 }
216 p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize );
217 p->nMemoryAlloc += p->nEntrySize * p->nChunkSize;
218 // transform these entries into a linked list
219 pTemp = p->pEntriesFree;
220 for ( i = 1; i < p->nChunkSize; i++ )
221 {
222 *((char **)pTemp) = pTemp + p->nEntrySize;
223 pTemp += p->nEntrySize;
224 }
225 // set the last link
226 *((char **)pTemp) = NULL;
227 // add the chunk to the chunk storage
228 p->pChunks[ p->nChunks++ ] = p->pEntriesFree;
229 // add to the number of entries allocated
230 p->nEntriesAlloc += p->nChunkSize;
231 }
232 // incrememt the counter of used entries
233 p->nEntriesUsed++;
234 if ( p->nEntriesMax < p->nEntriesUsed )
235 p->nEntriesMax = p->nEntriesUsed;
236 // return the first entry in the free entry list
237 pTemp = p->pEntriesFree;
238 p->pEntriesFree = *((char **)pTemp);
239 return pTemp;
240}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
Here is the caller graph for this function:

◆ Extra_MmFixedEntryRecycle()

void Extra_MmFixedEntryRecycle ( Extra_MmFixed_t * p,
char * pEntry )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file extraUtilMemory.c.

254{
255 // decrement the counter of used entries
256 p->nEntriesUsed--;
257 // add the entry to the linked list of free entries
258 *((char **)pEntry) = p->pEntriesFree;
259 p->pEntriesFree = pEntry;
260}
Here is the caller graph for this function:

◆ Extra_MmFixedReadMaxEntriesUsed()

int Extra_MmFixedReadMaxEntriesUsed ( Extra_MmFixed_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file extraUtilMemory.c.

328{
329 return p->nEntriesMax;
330}

◆ Extra_MmFixedReadMemUsage()

int Extra_MmFixedReadMemUsage ( Extra_MmFixed_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file extraUtilMemory.c.

312{
313 return p->nMemoryAlloc;
314}

◆ Extra_MmFixedRestart()

void Extra_MmFixedRestart ( Extra_MmFixed_t * p)
extern

Function*************************************************************

Synopsis []

Description [Relocates all the memory except the first chunk.]

SideEffects []

SeeAlso []

Definition at line 273 of file extraUtilMemory.c.

274{
275 int i;
276 char * pTemp;
277
278 // deallocate all chunks except the first one
279 for ( i = 1; i < p->nChunks; i++ )
280 ABC_FREE( p->pChunks[i] );
281 p->nChunks = 1;
282 // transform these entries into a linked list
283 pTemp = p->pChunks[0];
284 for ( i = 1; i < p->nChunkSize; i++ )
285 {
286 *((char **)pTemp) = pTemp + p->nEntrySize;
287 pTemp += p->nEntrySize;
288 }
289 // set the last link
290 *((char **)pTemp) = NULL;
291 // set the free entry list
292 p->pEntriesFree = p->pChunks[0];
293 // set the correct statistics
294 p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
295 p->nMemoryUsed = 0;
296 p->nEntriesAlloc = p->nChunkSize;
297 p->nEntriesUsed = 0;
298}
Here is the caller graph for this function:

◆ Extra_MmFixedStart()

Extra_MmFixed_t * Extra_MmFixedStart ( int nEntrySize)
extern

AutomaticStart AutomaticEnd Function*************************************************************

Synopsis [Allocates memory pieces of fixed size.]

Description [The size of the chunk is computed as the minimum of 1024 entries and 64K. Can only work with entry size at least 4 byte long.]

SideEffects []

SeeAlso []

Definition at line 122 of file extraUtilMemory.c.

123{
125
127 memset( p, 0, sizeof(Extra_MmFixed_t) );
128
129 p->nEntrySize = nEntrySize;
130 p->nEntriesAlloc = 0;
131 p->nEntriesUsed = 0;
132 p->pEntriesFree = NULL;
133
134 if ( nEntrySize * (1 << 10) < (1<<16) )
135 p->nChunkSize = (1 << 10);
136 else
137 p->nChunkSize = (1<<16) / nEntrySize;
138 if ( p->nChunkSize < 8 )
139 p->nChunkSize = 8;
140
141 p->nChunksAlloc = 64;
142 p->nChunks = 0;
143 p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
144
145 p->nMemoryUsed = 0;
146 p->nMemoryAlloc = 0;
147 return p;
148}
struct Extra_MmFixed_t_ Extra_MmFixed_t
Definition extra.h:147
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_MmFixedStop()

void Extra_MmFixedStop ( Extra_MmFixed_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 180 of file extraUtilMemory.c.

181{
182 int i;
183 if ( p == NULL )
184 return;
185 for ( i = 0; i < p->nChunks; i++ )
186 ABC_FREE( p->pChunks[i] );
187 ABC_FREE( p->pChunks );
188 ABC_FREE( p );
189}
Here is the caller graph for this function:

◆ Extra_MmFlexEntryFetch()

char * Extra_MmFlexEntryFetch ( Extra_MmFlex_t * p,
int nBytes )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 418 of file extraUtilMemory.c.

419{
420 char * pTemp;
421 // check if there are still free entries
422 if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
423 { // need to allocate more entries
424 if ( p->nChunks == p->nChunksAlloc )
425 {
426 p->nChunksAlloc *= 2;
427 p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
428 }
429 if ( nBytes > p->nChunkSize )
430 {
431 // resize the chunk size if more memory is requested than it can give
432 // (ideally, this should never happen)
433 p->nChunkSize = 2 * nBytes;
434 }
435 p->pCurrent = ABC_ALLOC( char, p->nChunkSize );
436 p->pEnd = p->pCurrent + p->nChunkSize;
437 p->nMemoryAlloc += p->nChunkSize;
438 // add the chunk to the chunk storage
439 p->pChunks[ p->nChunks++ ] = p->pCurrent;
440 }
441 assert( p->pCurrent + nBytes <= p->pEnd );
442 // increment the counter of used entries
443 p->nEntriesUsed++;
444 // keep track of the memory used
445 p->nMemoryUsed += nBytes;
446 // return the next entry
447 pTemp = p->pCurrent;
448 p->pCurrent += nBytes;
449 return pTemp;
450}
Here is the caller graph for this function:

◆ Extra_MmFlexPrint()

void Extra_MmFlexPrint ( Extra_MmFlex_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 376 of file extraUtilMemory.c.

377{
378 printf( "Flexible memory manager: Chunk size = %d. Chunks used = %d.\n",
379 p->nChunkSize, p->nChunks );
380 printf( " Entries used = %d. Memory used = %d. Memory alloc = %d.\n",
381 p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc );
382}

◆ Extra_MmFlexReadMemUsage()

int Extra_MmFlexReadMemUsage ( Extra_MmFlex_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 463 of file extraUtilMemory.c.

464{
465 return p->nMemoryAlloc;
466}

◆ Extra_MmFlexStart()

Extra_MmFlex_t * Extra_MmFlexStart ( )
extern

Function*************************************************************

Synopsis [Allocates entries of flexible size.]

Description [Can only work with entry size at least 4 byte long.]

SideEffects []

SeeAlso []

Definition at line 344 of file extraUtilMemory.c.

345{
347//printf( "allocing flex\n" );
348 p = ABC_ALLOC( Extra_MmFlex_t, 1 );
349 memset( p, 0, sizeof(Extra_MmFlex_t) );
350
351 p->nEntriesUsed = 0;
352 p->pCurrent = NULL;
353 p->pEnd = NULL;
354
355 p->nChunkSize = (1 << 12);
356 p->nChunksAlloc = 64;
357 p->nChunks = 0;
358 p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
359
360 p->nMemoryUsed = 0;
361 p->nMemoryAlloc = 0;
362 return p;
363}
struct Extra_MmFlex_t_ Extra_MmFlex_t
Definition extra.h:148
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_MmFlexStop()

void Extra_MmFlexStop ( Extra_MmFlex_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file extraUtilMemory.c.

396{
397 int i;
398 if ( p == NULL )
399 return;
400//printf( "deleting flex\n" );
401 for ( i = 0; i < p->nChunks; i++ )
402 ABC_FREE( p->pChunks[i] );
403 ABC_FREE( p->pChunks );
404 ABC_FREE( p );
405}
Here is the caller graph for this function:

◆ Extra_MmStepEntryFetch()

char * Extra_MmStepEntryFetch ( Extra_MmStep_t * p,
int nBytes )
extern

Function*************************************************************

Synopsis [Creates the entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 555 of file extraUtilMemory.c.

556{
557 if ( nBytes == 0 )
558 return NULL;
559 if ( nBytes > p->nMapSize )
560 {
561// printf( "Allocating %d bytes.\n", nBytes );
562// return ABC_ALLOC( char, nBytes );
563 if ( p->nLargeChunks == p->nLargeChunksAlloc )
564 {
565 if ( p->nLargeChunksAlloc == 0 )
566 p->nLargeChunksAlloc = 32;
567 p->nLargeChunksAlloc *= 2;
568 p->pLargeChunks = ABC_REALLOC( void *, p->pLargeChunks, p->nLargeChunksAlloc );
569 }
570 p->pLargeChunks[ p->nLargeChunks++ ] = ABC_ALLOC( char, nBytes );
571 return (char *)p->pLargeChunks[ p->nLargeChunks - 1 ];
572 }
573 return Extra_MmFixedEntryFetch( p->pMap[nBytes] );
574}
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
Here is the call graph for this function:

◆ Extra_MmStepEntryRecycle()

void Extra_MmStepEntryRecycle ( Extra_MmStep_t * p,
char * pEntry,
int nBytes )
extern

Function*************************************************************

Synopsis [Recycles the entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 588 of file extraUtilMemory.c.

589{
590 if ( nBytes == 0 )
591 return;
592 if ( nBytes > p->nMapSize )
593 {
594// ABC_FREE( pEntry );
595 return;
596 }
597 Extra_MmFixedEntryRecycle( p->pMap[nBytes], pEntry );
598}
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
Here is the call graph for this function:

◆ Extra_MmStepReadMemUsage()

int Extra_MmStepReadMemUsage ( Extra_MmStep_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file extraUtilMemory.c.

612{
613 int i, nMemTotal = 0;
614 for ( i = 0; i < p->nMems; i++ )
615 nMemTotal += p->pMems[i]->nMemoryAlloc;
616 return nMemTotal;
617}

◆ Extra_MmStepStart()

Extra_MmStep_t * Extra_MmStepStart ( int nSteps)
extern

Function*************************************************************

Synopsis [Starts the hierarchical memory manager.]

Description [This manager can allocate entries of any size. Iternally they are mapped into the entries with the number of bytes equal to the power of 2. The smallest entry size is 8 bytes. The next one is 16 bytes etc. So, if the user requests 6 bytes, he gets 8 byte entry. If we asks for 25 bytes, he gets 32 byte entry etc. The input parameters "nSteps" says how many fixed memory managers are employed internally. Calling this procedure with nSteps equal to 10 results in 10 hierarchically arranged internal memory managers, which can allocate up to 4096 (1Kb) entries. Requests for larger entries are handed over to malloc() and then ABC_FREE()ed.]

SideEffects []

SeeAlso []

Definition at line 492 of file extraUtilMemory.c.

493{
495 int i, k;
496 p = ABC_ALLOC( Extra_MmStep_t, 1 );
497 memset( p, 0, sizeof(Extra_MmStep_t) );
498 p->nMems = nSteps;
499 // start the fixed memory managers
500 p->pMems = ABC_ALLOC( Extra_MmFixed_t *, p->nMems );
501 for ( i = 0; i < p->nMems; i++ )
502 p->pMems[i] = Extra_MmFixedStart( (8<<i) );
503 // set up the mapping of the required memory size into the corresponding manager
504 p->nMapSize = (4<<p->nMems);
505 p->pMap = ABC_ALLOC( Extra_MmFixed_t *, p->nMapSize+1 );
506 p->pMap[0] = NULL;
507 for ( k = 1; k <= 4; k++ )
508 p->pMap[k] = p->pMems[0];
509 for ( i = 0; i < p->nMems; i++ )
510 for ( k = (4<<i)+1; k <= (8<<i); k++ )
511 p->pMap[k] = p->pMems[i];
512//for ( i = 1; i < 100; i ++ )
513//printf( "%10d: size = %10d\n", i, p->pMap[i]->nEntrySize );
514 return p;
515}
struct Extra_MmStep_t_ Extra_MmStep_t
Definition extra.h:149
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
Here is the call graph for this function:

◆ Extra_MmStepStop()

void Extra_MmStepStop ( Extra_MmStep_t * p)
extern

Function*************************************************************

Synopsis [Stops the memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 528 of file extraUtilMemory.c.

529{
530 int i;
531 for ( i = 0; i < p->nMems; i++ )
532 Extra_MmFixedStop( p->pMems[i] );
533 if ( p->pLargeChunks )
534 {
535 for ( i = 0; i < p->nLargeChunks; i++ )
536 ABC_FREE( p->pLargeChunks[i] );
537 ABC_FREE( p->pLargeChunks );
538 }
539 ABC_FREE( p->pMems );
540 ABC_FREE( p->pMap );
541 ABC_FREE( p );
542}
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Here is the call graph for this function:

◆ Extra_NumCombinations()

int Extra_NumCombinations ( int k,
int n )
extern

Function********************************************************************

Synopsis [Finds the number of combinations of k elements out of n.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file extraUtilMisc.c.

143{
144 int i, Res = 1;
145 for ( i = 1; i <= k; i++ )
146 Res = Res * (n-i+1) / i;
147 return Res;
148} /* end of Extra_NumCombinations */

◆ Extra_PermSchedule()

int * Extra_PermSchedule ( int n)
extern

Function*************************************************************

Synopsis [Computes permutation schedule for n! permutations.]

Description []

SideEffects []

SeeAlso []

Definition at line 2206 of file extraUtilMisc.c.

2207{
2208 int nFact = Extra_Factorial(n);
2209 int nGroups = nFact / n / 2;
2210 int * pRes = ABC_ALLOC( int, nFact );
2211 int * pRes0, i, k, b = 0;
2212 assert( n > 0 );
2213 if ( n == 1 )
2214 {
2215 pRes[0] = 0;
2216 return pRes;
2217 }
2218 if ( n == 2 )
2219 {
2220 pRes[0] = pRes[1] = 0;
2221 return pRes;
2222 }
2223 pRes0 = Extra_PermSchedule( n-1 );
2224 for ( k = 0; k < nGroups; k++ )
2225 {
2226 for ( i = n-1; i > 0; i-- )
2227 pRes[b++] = i-1;
2228 pRes[b++] = pRes0[2*k]+1;
2229 for ( i = 0; i < n-1; i++ )
2230 pRes[b++] = i;
2231 pRes[b++] = pRes0[2*k+1];
2232 }
2233 ABC_FREE( pRes0 );
2234 assert( b == nFact );
2235
2236 if ( 0 )
2237 {
2238 int Perm[16];
2239 for ( i = 0; i < n; i++ )
2240 Perm[i] = i;
2241 for ( b = 0; b < nFact; b++ )
2242 {
2243 ABC_SWAP( int, Perm[pRes[b]], Perm[pRes[b]+1] );
2244 printf( "%3d %3d ", b, pRes[b] );
2245 for ( i = 0; i < n; i++ )
2246 printf( "%d", Perm[i] );
2247 printf( "\n" );
2248 }
2249 }
2250 return pRes;
2251}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
int * Extra_PermSchedule(int n)
int Extra_Factorial(int n)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_Permutations()

char ** Extra_Permutations ( int n)
extern

Function********************************************************************

Synopsis [Computes the set of all permutations.]

Description [The number of permutations in the array is n!. The number of entries in each permutation is n. Therefore, the resulting array is a two-dimentional array of the size: n! x n. To free the resulting array, call ABC_FREE() on the pointer returned by this procedure.]

SideEffects []

SeeAlso []

Definition at line 239 of file extraUtilMisc.c.

240{
241 char Array[50];
242 char ** pRes;
243 int nFact, i;
244 // allocate memory
245 nFact = Extra_Factorial( n );
246 pRes = (char **)Extra_ArrayAlloc( nFact, n, sizeof(char) );
247 // fill in the permutations
248 for ( i = 0; i < n; i++ )
249 Array[i] = i;
250 Extra_Permutations_rec( pRes, nFact, n, Array );
251 // print the permutations
252/*
253 {
254 int i, k;
255 for ( i = 0; i < nFact; i++ )
256 {
257 printf( "{" );
258 for ( k = 0; k < n; k++ )
259 printf( " %d", pRes[i][k] );
260 printf( " }\n" );
261 }
262 }
263*/
264 return pRes;
265}
void ** Extra_ArrayAlloc(int nCols, int nRows, int Size)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_Power2()

double Extra_Power2 ( int Degree)
extern

Function********************************************************************

Synopsis [Returns the power of two as a double.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file extraUtilMisc.c.

100{
101 double Res;
102 assert( Degree >= 0 );
103 if ( Degree < 32 )
104 return (double)(01<<Degree);
105 for ( Res = 1.0; Degree; Res *= 2.0, Degree-- );
106 return Res;
107}

◆ Extra_Power3()

int Extra_Power3 ( int Num)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file extraUtilMisc.c.

122{
123 int i;
124 int Res;
125 Res = 1;
126 for ( i = 0; i < Num; i++ )
127 Res *= 3;
128 return Res;
129}

◆ Extra_PrintBinary()

void Extra_PrintBinary ( FILE * pFile,
unsigned Sign[],
int nBits )
extern

Function*************************************************************

Synopsis [Prints the bit string.]

Description []

SideEffects []

SeeAlso []

Definition at line 516 of file extraUtilFile.c.

517{
518 int i;
519 for ( i = nBits-1; i >= 0; i-- )
520 fprintf( pFile, "%c", '0' + Abc_InfoHasBit(Sign, i) );
521// fprintf( pFile, "\n" );
522}

◆ Extra_PrintBinary2()

void Extra_PrintBinary2 ( FILE * pFile,
unsigned Sign[],
int nBits )
extern

Definition at line 523 of file extraUtilFile.c.

524{
525 int i;
526 for ( i = 0; i < nBits; i++ )
527 fprintf( pFile, "%c", '0' + Abc_InfoHasBit(Sign, i) );
528// fprintf( pFile, "\n" );
529}
Here is the caller graph for this function:

◆ Extra_PrintHex()

void Extra_PrintHex ( FILE * pFile,
unsigned * pTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Prints the hex unsigned into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file extraUtilFile.c.

644{
645 int nMints, nDigits, Digit, k;
646
647 // write the number into the file
648 fprintf( pFile, "0x" );
649 nMints = (1 << nVars);
650 nDigits = nMints / 4 + ((nMints % 4) > 0);
651 for ( k = nDigits - 1; k >= 0; k-- )
652 {
653 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
654 if ( Digit < 10 )
655 fprintf( pFile, "%d", Digit );
656 else
657 fprintf( pFile, "%c", 'A' + Digit-10 );
658 }
659// fprintf( pFile, "\n" );
660}

◆ Extra_PrintHex2()

void Extra_PrintHex2 ( FILE * pFile,
unsigned * pTruth,
int nVars )
extern

Definition at line 661 of file extraUtilFile.c.

662{
663 int nMints, nDigits, Digit, k;
664
665 // write the number into the file
666 //fprintf( pFile, "0x" );
667 nMints = (1 << nVars);
668 nDigits = nMints / 4 + ((nMints % 4) > 0);
669 for ( k = nDigits - 1; k >= 0; k-- )
670 {
671 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
672 if ( Digit < 10 )
673 fprintf( pFile, "%d", Digit );
674 else
675 fprintf( pFile, "%c", 'A' + Digit-10 );
676 }
677// fprintf( pFile, "\n" );
678}
Here is the caller graph for this function:

◆ Extra_PrintHexadecimal()

void Extra_PrintHexadecimal ( FILE * pFile,
unsigned Sign[],
int nVars )
extern

Function*************************************************************

Synopsis [Prints the hex unsigned into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 584 of file extraUtilFile.c.

585{
586 int nDigits, Digit, k;
587 // write the number into the file
588 nDigits = (1 << nVars) / 4;
589 for ( k = nDigits - 1; k >= 0; k-- )
590 {
591 Digit = ((Sign[k/8] >> ((k%8) * 4)) & 15);
592 if ( Digit < 10 )
593 fprintf( pFile, "%d", Digit );
594 else
595 fprintf( pFile, "%c", 'a' + Digit-10 );
596 }
597// fprintf( pFile, "\n" );
598}
Here is the caller graph for this function:

◆ Extra_PrintHexadecimalString()

void Extra_PrintHexadecimalString ( char * pString,
unsigned Sign[],
int nVars )
extern

Function*************************************************************

Synopsis [Prints the hex unsigned into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file extraUtilFile.c.

612{
613 int nDigits, Digit, k;
614 if ( nVars == 0 && !(Sign[0] & 1) ) { sprintf(pString, "0"); return; } // const0
615 if ( nVars == 0 && (Sign[0] & 1) ) { sprintf(pString, "1"); return; } // const1
616 if ( nVars == 1 && (Sign[0] & 1) ) { sprintf(pString, "1"); return; } // inverter
617 if ( nVars == 1 && !(Sign[0] & 1) ) { sprintf(pString, "2"); return; } // buffer
618 // write the number into the file
619 nDigits = (1 << nVars) / 4;
620 for ( k = nDigits - 1; k >= 0; k-- )
621 {
622 Digit = ((Sign[k/8] >> ((k%8) * 4)) & 15);
623 if ( Digit < 10 )
624 *pString++ = '0' + Digit;
625 else
626 *pString++ = 'a' + Digit-10;
627 }
628// fprintf( pFile, "\n" );
629 *pString = 0;
630}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_PrintHexReverse()

void Extra_PrintHexReverse ( FILE * pFile,
unsigned * pTruth,
int nVars )
extern

Definition at line 679 of file extraUtilFile.c.

680{
681 int nMints, nDigits, Digit, k;
682
683 // write the number into the file
684 fprintf( pFile, "0x" );
685 nMints = (1 << nVars);
686 nDigits = nMints / 4 + ((nMints % 4) > 0);
687 for ( k = 0; k < nDigits; k++ )
688 {
689 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
690 if ( Digit < 10 )
691 fprintf( pFile, "%d", Digit );
692 else
693 fprintf( pFile, "%c", 'A' + Digit-10 );
694 }
695// fprintf( pFile, "\n" );
696}

◆ Extra_PrintSymbols()

void Extra_PrintSymbols ( FILE * pFile,
char Char,
int nTimes,
int fPrintNewLine )
extern

Function*************************************************************

Synopsis [Returns the composite name of the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 709 of file extraUtilFile.c.

710{
711 int i;
712 for ( i = 0; i < nTimes; i++ )
713 printf( "%c", Char );
714 if ( fPrintNewLine )
715 printf( "\n" );
716}
char Char

◆ Extra_ProgressBarStart()

ProgressBar * Extra_ProgressBarStart ( FILE * pFile,
int nItemsTotal )
extern

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Starts the progress bar.]

Description [The first parameter is the output stream (pFile), where the progress is printed. The current printing position should be the first one on the given line. The second parameters is the total number of items that correspond to 100% position of the progress bar.]

SideEffects []

SeeAlso []

Definition at line 62 of file extraUtilProgress.c.

63{
64 ProgressBar * p;
66 p = ABC_ALLOC( ProgressBar, 1 );
67 memset( p, 0, sizeof(ProgressBar) );
68 p->pFile = pFile;
69 p->nItemsTotal = nItemsTotal;
70 p->posTotal = 78;
71 p->posCur = 1;
72 p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
73 Extra_ProgressBarShow( p, NULL );
74 return p;
75}
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL int Abc_FrameShowProgress(Abc_Frame_t *p)
Definition mainFrame.c:310
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_ProgressBarStop()

void Extra_ProgressBarStop ( ProgressBar * p)
extern

Function*************************************************************

Synopsis [Stops the progress bar.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file extraUtilProgress.c.

119{
120 if ( p == NULL ) return;
121 Extra_ProgressBarClean( p );
122 ABC_FREE( p );
123}
Here is the caller graph for this function:

◆ Extra_ProgressBarUpdate_int()

void Extra_ProgressBarUpdate_int ( ProgressBar * p,
int nItemsCur,
char * pString )
extern

Function*************************************************************

Synopsis [Updates the progress bar.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file extraUtilProgress.c.

89{
90 if ( p == NULL ) return;
91 if ( nItemsCur < p->nItemsNext )
92 return;
93 if ( nItemsCur >= p->nItemsTotal )
94 {
95 p->posCur = 78;
96 p->nItemsNext = 0x7FFFFFFF;
97 }
98 else
99 {
100 p->posCur += 7;
101 p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
102 }
103 Extra_ProgressBarShow( p, pString );
104}

◆ Extra_ReadBinary()

unsigned Extra_ReadBinary ( char * Buffer)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file extraUtilFile.c.

490{
491 unsigned Result;
492 int i;
493
494 Result = 0;
495 for ( i = 0; Buffer[i]; i++ )
496 if ( Buffer[i] == '0' || Buffer[i] == '1' )
497 Result = Result * 2 + Buffer[i] - '0';
498 else
499 {
500 assert( 0 );
501 }
502 return Result;
503}
Here is the caller graph for this function:

◆ Extra_ReadHex()

int Extra_ReadHex ( unsigned Sign[],
char * pString,
int nDigits )
extern

Function*************************************************************

Synopsis [Reads the hex unsigned into the bit-string.]

Description []

SideEffects []

SeeAlso []

Definition at line 542 of file extraUtilFile.c.

543{
544 int Digit, k, c;
545 for ( k = 0; k < nDigits; k++ )
546 {
547 c = nDigits-1-k;
548 if ( pString[c] >= '0' && pString[c] <= '9' )
549 Digit = pString[c] - '0';
550 else if ( pString[c] >= 'A' && pString[c] <= 'F' )
551 Digit = pString[c] - 'A' + 10;
552 else if ( pString[c] >= 'a' && pString[c] <= 'f' )
553 Digit = pString[c] - 'a' + 10;
554 else { assert( 0 ); return 0; }
555 Sign[k/8] |= ( (Digit & 15) << ((k%8) * 4) );
556 }
557 return 1;
558}
Here is the caller graph for this function:

◆ Extra_ReadHexadecimal()

int Extra_ReadHexadecimal ( unsigned Sign[],
char * pString,
int nVars )
extern

Definition at line 559 of file extraUtilFile.c.

560{
561 int nWords, nDigits, k;
562 nWords = Extra_TruthWordNum( nVars );
563 for ( k = 0; k < nWords; k++ )
564 Sign[k] = 0;
565 // read the number from the string
566 nDigits = (1 << nVars) / 4;
567 if ( nDigits == 0 )
568 nDigits = 1;
569 Extra_ReadHex( Sign, pString, nDigits );
570 return 1;
571}
int nWords
Definition abcNpn.c:127
int Extra_ReadHex(unsigned Sign[], char *pString, int nDigits)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_StringAppend()

char * Extra_StringAppend ( char * pStrGiven,
char * pStrAdd )
extern

Function*************************************************************

Synopsis [Appends the string.]

Description [Assumes that the given string (pStrGiven) has been allocated before using malloc(). The additional string has not been allocated. Allocs more root, appends the additional part, frees the old given string.]

SideEffects []

SeeAlso []

Definition at line 731 of file extraUtilFile.c.

732{
733 char * pTemp;
734 if ( pStrGiven )
735 {
736 pTemp = ABC_ALLOC( char, strlen(pStrGiven) + strlen(pStrAdd) + 2 );
737 sprintf( pTemp, "%s%s", pStrGiven, pStrAdd );
738 ABC_FREE( pStrGiven );
739 }
740 else
741 pTemp = Extra_UtilStrsav( pStrAdd );
742 return pTemp;
743}
Here is the call graph for this function:

◆ Extra_StringClean()

void Extra_StringClean ( char * pStrGiven,
char * pCharKeep )
extern

Function*************************************************************

Synopsis [Only keep characters belonging to the second string.]

Description []

SideEffects []

SeeAlso []

Definition at line 756 of file extraUtilFile.c.

757{
758 char * pTemp, * pChar, * pSave = pStrGiven;
759 for ( pTemp = pStrGiven; *pTemp; pTemp++ )
760 {
761 for ( pChar = pCharKeep; *pChar; pChar++ )
762 if ( *pTemp == *pChar )
763 break;
764 if ( *pChar == 0 )
765 continue;
766 *pSave++ = *pTemp;
767 }
768 *pSave = 0;
769}

◆ Extra_TimeStamp()

char * Extra_TimeStamp ( )
extern

Function*************************************************************

Synopsis [Returns the time stamp.]

Description [The file should be closed.]

SideEffects []

SeeAlso []

Definition at line 465 of file extraUtilFile.c.

466{
467 static char Buffer[100];
468 char * TimeStamp;
469 time_t ltime;
470 // get the current time
471 time( &ltime );
472 TimeStamp = asctime( localtime( &ltime ) );
473 TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
474 strcpy( Buffer, TimeStamp );
475 return Buffer;
476}
Here is the call graph for this function:

◆ Extra_Truth4VarN()

void Extra_Truth4VarN ( unsigned short ** puCanons,
char *** puPhases,
char ** ppCounters,
int nPhasesMax )
extern

Function*************************************************************

Synopsis [Computes NPN canonical forms for 4-variable functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 815 of file extraUtilMisc.c.

816{
817 unsigned short * uCanons;
818 unsigned uTruth, uPhase;
819 char ** uPhases, * pCounters;
820 int nFuncs, nClasses, i;
821
822 nFuncs = (1 << 16);
823 uCanons = ABC_ALLOC( unsigned short, nFuncs );
824 memset( uCanons, 0, sizeof(unsigned short) * nFuncs );
825 pCounters = ABC_ALLOC( char, nFuncs );
826 memset( pCounters, 0, sizeof(char) * nFuncs );
827 uPhases = (char **)Extra_ArrayAlloc( nFuncs, nPhasesMax, sizeof(char) );
828 nClasses = 0;
829 for ( uTruth = 0; uTruth < (unsigned)nFuncs; uTruth++ )
830 {
831 // skip already assigned
832 if ( uCanons[uTruth] )
833 {
834 assert( uTruth > uCanons[uTruth] );
835 continue;
836 }
837 nClasses++;
838 for ( i = 0; i < 16; i++ )
839 {
840 uPhase = Extra_TruthPolarize( uTruth, i, 4 );
841 if ( uCanons[uPhase] == 0 && (uTruth || i==0) )
842 {
843 uCanons[uPhase] = uTruth;
844 uPhases[uPhase][0] = i;
845 pCounters[uPhase] = 1;
846 }
847 else
848 {
849 assert( uCanons[uPhase] == uTruth );
850 if ( pCounters[uPhase] < nPhasesMax )
851 uPhases[uPhase][ (int)pCounters[uPhase]++ ] = i;
852 }
853 }
854 }
855 if ( puCanons )
856 *puCanons = uCanons;
857 else
858 ABC_FREE( uCanons );
859 if ( puPhases )
860 *puPhases = uPhases;
861 else
862 ABC_FREE( uPhases );
863 if ( ppCounters )
864 *ppCounters = pCounters;
865 else
866 ABC_FREE( pCounters );
867// printf( "The number of 4N-classes = %d.\n", nClasses );
868}
unsigned Extra_TruthPolarize(unsigned uTruth, int Polarity, int nVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_Truth4VarNPN()

void Extra_Truth4VarNPN ( unsigned short ** puCanons,
char ** puPhases,
char ** puPerms,
unsigned char ** puMap )
extern

Function*************************************************************

Synopsis [Computes NPN canonical forms for 4-variable functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file extraUtilMisc.c.

644{
645 unsigned short * uCanons;
646 unsigned char * uMap;
647 unsigned uTruth, uPhase, uPerm;
648 char ** pPerms4, * uPhases, * uPerms;
649 int nFuncs, nClasses;
650 int i, k;
651
652 nFuncs = (1 << 16);
653 uCanons = ABC_ALLOC( unsigned short, nFuncs );
654 uPhases = ABC_ALLOC( char, nFuncs );
655 uPerms = ABC_ALLOC( char, nFuncs );
656 uMap = ABC_ALLOC( unsigned char, nFuncs );
657 memset( uCanons, 0, sizeof(unsigned short) * nFuncs );
658 memset( uPhases, 0, sizeof(char) * nFuncs );
659 memset( uPerms, 0, sizeof(char) * nFuncs );
660 memset( uMap, 0, sizeof(unsigned char) * nFuncs );
661 pPerms4 = Extra_Permutations( 4 );
662
663 nClasses = 1;
664 nFuncs = (1 << 15);
665 for ( uTruth = 1; uTruth < (unsigned)nFuncs; uTruth++ )
666 {
667 // skip already assigned
668 if ( uCanons[uTruth] )
669 {
670 assert( uTruth > uCanons[uTruth] );
671 uMap[~uTruth & 0xFFFF] = uMap[uTruth] = uMap[uCanons[uTruth]];
672 continue;
673 }
674 uMap[uTruth] = nClasses++;
675 for ( i = 0; i < 16; i++ )
676 {
677 uPhase = Extra_TruthPolarize( uTruth, i, 4 );
678 for ( k = 0; k < 24; k++ )
679 {
680 uPerm = Extra_TruthPermute( uPhase, pPerms4[k], 4, 0 );
681 if ( uCanons[uPerm] == 0 )
682 {
683 uCanons[uPerm] = uTruth;
684 uPhases[uPerm] = i;
685 uPerms[uPerm] = k;
686
687 uPerm = ~uPerm & 0xFFFF;
688 uCanons[uPerm] = uTruth;
689 uPhases[uPerm] = i | 16;
690 uPerms[uPerm] = k;
691 }
692 else
693 assert( uCanons[uPerm] == uTruth );
694 }
695 uPhase = Extra_TruthPolarize( ~uTruth & 0xFFFF, i, 4 );
696 for ( k = 0; k < 24; k++ )
697 {
698 uPerm = Extra_TruthPermute( uPhase, pPerms4[k], 4, 0 );
699 if ( uCanons[uPerm] == 0 )
700 {
701 uCanons[uPerm] = uTruth;
702 uPhases[uPerm] = i;
703 uPerms[uPerm] = k;
704
705 uPerm = ~uPerm & 0xFFFF;
706 uCanons[uPerm] = uTruth;
707 uPhases[uPerm] = i | 16;
708 uPerms[uPerm] = k;
709 }
710 else
711 assert( uCanons[uPerm] == uTruth );
712 }
713 }
714 }
715 uPhases[(1<<16)-1] = 16;
716 assert( nClasses == 222 );
717 ABC_FREE( pPerms4 );
718 if ( puCanons )
719 *puCanons = uCanons;
720 else
721 ABC_FREE( uCanons );
722 if ( puPhases )
723 *puPhases = uPhases;
724 else
725 ABC_FREE( uPhases );
726 if ( puPerms )
727 *puPerms = uPerms;
728 else
729 ABC_FREE( uPerms );
730 if ( puMap )
731 *puMap = uMap;
732 else
733 ABC_FREE( uMap );
734}
char ** Extra_Permutations(int n)
unsigned Extra_TruthPermute(unsigned Truth, char *pPerms, int nVars, int fReverse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_Truth6MinimumExact()

word Extra_Truth6MinimumExact ( word t,
int * pComp,
int * pPerm )
extern

Definition at line 2292 of file extraUtilMisc.c.

2293{
2294 word tMin = ~(word)0;
2295 word tCur, tTemp1, tTemp2;
2296 int i, p, c;
2297 for ( i = 0; i < 2; i++ )
2298 {
2299 tCur = i ? ~t : t;
2300 tTemp1 = tCur;
2301 for ( p = 0; p < 720; p++ )
2302 {
2303// printf( "Trying perm %d:\n", p );
2304// Kit_DsdPrintFromTruth( &tCur, 6 ), printf( "\n" );;
2305 tTemp2 = tCur;
2306 for ( c = 0; c < 64; c++ )
2307 {
2308 tMin = Abc_MinWord( tMin, tCur );
2309 tCur = Extra_Truth6ChangePhase( tCur, pComp[c] );
2310 }
2311 assert( tTemp2 == tCur );
2312 tCur = Extra_Truth6SwapAdjacent( tCur, pPerm[p] );
2313 }
2314 assert( tTemp1 == tCur );
2315 }
2316 return tMin;
2317}
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
word Extra_Truth6SwapAdjacent(word t, int iVar)
Definition luckyFast6.c:73
word Extra_Truth6ChangePhase(word t, int iVar)
Definition luckyFast6.c:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_Truth6MinimumHeuristic()

word Extra_Truth6MinimumHeuristic ( word t)
extern

Definition at line 2380 of file extraUtilMisc.c.

2381{
2382 word tMin1, tMin2;
2383 int nOnes = Extra_Truth6Ones( t );
2384 if ( nOnes < 32 )
2385 return Extra_Truth6MinimumRoundMany( t );
2386 if ( nOnes > 32 )
2387 return Extra_Truth6MinimumRoundMany( ~t );
2388 tMin1 = Extra_Truth6MinimumRoundMany( t );
2389 tMin2 = Extra_Truth6MinimumRoundMany( ~t );
2390 return Abc_MinWord( tMin1, tMin2 );
2391}
word Extra_Truth6MinimumRoundMany(word t, int *pStore, char *pCanonPerm, unsigned *pCanonPhase)
Definition luckyFast6.c:176
Here is the call graph for this function:

◆ Extra_TruthCanonFastN()

int Extra_TruthCanonFastN ( int nVarsMax,
int nVarsReal,
unsigned * pt,
unsigned ** pptRes,
char ** ppfRes )
extern

AutomaticEnd Function********************************************************************

Synopsis [Computes the N-canonical form of the Boolean function up to 6 inputs.]

Description [The N-canonical form is defined as the truth table with the minimum integer value. This function exhaustively enumerates through the complete set of 2^N phase assignments. Returns pointers to the static storage to the truth table and phases. This data should be used before the function is called again.]

SideEffects []

SeeAlso []

Definition at line 374 of file extraUtilCanon.c.

375{
376 static unsigned uTruthStore6[2];
377 int RetValue;
378 assert( nVarsMax <= 6 );
379 assert( nVarsReal <= nVarsMax );
380 RetValue = Extra_TruthCanonN_rec( nVarsReal <= 3? 3: nVarsReal, (unsigned char *)pt, pptRes, ppfRes, 0 );
381 if ( nVarsMax == 6 && nVarsReal < nVarsMax )
382 {
383 uTruthStore6[0] = **pptRes;
384 uTruthStore6[1] = **pptRes;
385 *pptRes = uTruthStore6;
386 }
387 return RetValue;
388}
Here is the caller graph for this function:

◆ Extra_TruthCanonN()

unsigned Extra_TruthCanonN ( unsigned uTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Computes N-canonical form using brute-force methods.]

Description []

SideEffects []

SeeAlso []

Definition at line 440 of file extraUtilMisc.c.

441{
442 unsigned uTruthMin, uPhase;
443 int nMints, i;
444 nMints = (1 << nVars);
445 uTruthMin = 0xFFFFFFFF;
446 for ( i = 0; i < nMints; i++ )
447 {
448 uPhase = Extra_TruthPolarize( uTruth, i, nVars );
449 if ( uTruthMin > uPhase )
450 uTruthMin = uPhase;
451 }
452 return uTruthMin;
453}
Here is the call graph for this function:

◆ Extra_TruthCanonNN()

unsigned Extra_TruthCanonNN ( unsigned uTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Computes NN-canonical form using brute-force methods.]

Description []

SideEffects []

SeeAlso []

Definition at line 466 of file extraUtilMisc.c.

467{
468 unsigned uTruthMin, uTruthC, uPhase;
469 int nMints, i;
470 nMints = (1 << nVars);
471 uTruthC = (unsigned)( (~uTruth) & ((~((unsigned)0)) >> (32-nMints)) );
472 uTruthMin = 0xFFFFFFFF;
473 for ( i = 0; i < nMints; i++ )
474 {
475 uPhase = Extra_TruthPolarize( uTruth, i, nVars );
476 if ( uTruthMin > uPhase )
477 uTruthMin = uPhase;
478 uPhase = Extra_TruthPolarize( uTruthC, i, nVars );
479 if ( uTruthMin > uPhase )
480 uTruthMin = uPhase;
481 }
482 return uTruthMin;
483}
Here is the call graph for this function:

◆ Extra_TruthCanonNP()

unsigned Extra_TruthCanonNP ( unsigned uTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Computes NP-canonical form using brute-force methods.]

Description []

SideEffects []

SeeAlso []

Definition at line 539 of file extraUtilMisc.c.

540{
541 static int nVarsOld, nPerms;
542 static char ** pPerms = NULL;
543
544 unsigned uTruthMin, uPhase, uPerm;
545 int nMints, k, i;
546
547 if ( pPerms == NULL )
548 {
549 nPerms = Extra_Factorial( nVars );
550 pPerms = Extra_Permutations( nVars );
551 nVarsOld = nVars;
552 }
553 else if ( nVarsOld != nVars )
554 {
555 ABC_FREE( pPerms );
556 nPerms = Extra_Factorial( nVars );
557 pPerms = Extra_Permutations( nVars );
558 nVarsOld = nVars;
559 }
560
561 nMints = (1 << nVars);
562 uTruthMin = 0xFFFFFFFF;
563 for ( i = 0; i < nMints; i++ )
564 {
565 uPhase = Extra_TruthPolarize( uTruth, i, nVars );
566 for ( k = 0; k < nPerms; k++ )
567 {
568 uPerm = Extra_TruthPermute( uPhase, pPerms[k], nVars, 0 );
569 if ( uTruthMin > uPerm )
570 uTruthMin = uPerm;
571 }
572 }
573 return uTruthMin;
574}
Here is the call graph for this function:

◆ Extra_TruthCanonNPN()

unsigned Extra_TruthCanonNPN ( unsigned uTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Computes NPN-canonical form using brute-force methods.]

Description []

SideEffects []

SeeAlso []

Definition at line 587 of file extraUtilMisc.c.

588{
589 static int nVarsOld, nPerms;
590 static char ** pPerms = NULL;
591
592 unsigned uTruthMin, uTruthC, uPhase, uPerm;
593 int nMints, k, i;
594
595 if ( pPerms == NULL )
596 {
597 nPerms = Extra_Factorial( nVars );
598 pPerms = Extra_Permutations( nVars );
599 nVarsOld = nVars;
600 }
601 else if ( nVarsOld != nVars )
602 {
603 ABC_FREE( pPerms );
604 nPerms = Extra_Factorial( nVars );
605 pPerms = Extra_Permutations( nVars );
606 nVarsOld = nVars;
607 }
608
609 nMints = (1 << nVars);
610 uTruthC = (unsigned)( (~uTruth) & ((~((unsigned)0)) >> (32-nMints)) );
611 uTruthMin = 0xFFFFFFFF;
612 for ( i = 0; i < nMints; i++ )
613 {
614 uPhase = Extra_TruthPolarize( uTruth, i, nVars );
615 for ( k = 0; k < nPerms; k++ )
616 {
617 uPerm = Extra_TruthPermute( uPhase, pPerms[k], nVars, 0 );
618 if ( uTruthMin > uPerm )
619 uTruthMin = uPerm;
620 }
621 uPhase = Extra_TruthPolarize( uTruthC, i, nVars );
622 for ( k = 0; k < nPerms; k++ )
623 {
624 uPerm = Extra_TruthPermute( uPhase, pPerms[k], nVars, 0 );
625 if ( uTruthMin > uPerm )
626 uTruthMin = uPerm;
627 }
628 }
629 return uTruthMin;
630}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthCanonP()

unsigned Extra_TruthCanonP ( unsigned uTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Computes P-canonical form using brute-force methods.]

Description []

SideEffects []

SeeAlso []

Definition at line 496 of file extraUtilMisc.c.

497{
498 static int nVarsOld, nPerms;
499 static char ** pPerms = NULL;
500
501 unsigned uTruthMin, uPerm;
502 int k;
503
504 if ( pPerms == NULL )
505 {
506 nPerms = Extra_Factorial( nVars );
507 pPerms = Extra_Permutations( nVars );
508 nVarsOld = nVars;
509 }
510 else if ( nVarsOld != nVars )
511 {
512 ABC_FREE( pPerms );
513 nPerms = Extra_Factorial( nVars );
514 pPerms = Extra_Permutations( nVars );
515 nVarsOld = nVars;
516 }
517
518 uTruthMin = 0xFFFFFFFF;
519 for ( k = 0; k < nPerms; k++ )
520 {
521 uPerm = Extra_TruthPermute( uTruth, pPerms[k], nVars, 0 );
522 if ( uTruthMin > uPerm )
523 uTruthMin = uPerm;
524 }
525 return uTruthMin;
526}
Here is the call graph for this function:

◆ Extra_TruthChangePhase()

void Extra_TruthChangePhase ( unsigned * pTruth,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Changes phase of the function w.r.t. one variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 719 of file extraUtilTruth.c.

720{
721 int nWords = Extra_TruthWordNum( nVars );
722 int i, k, Step;
723 unsigned Temp;
724
725 assert( iVar < nVars );
726 switch ( iVar )
727 {
728 case 0:
729 for ( i = 0; i < nWords; i++ )
730 pTruth[i] = ((pTruth[i] & 0x55555555) << 1) | ((pTruth[i] & 0xAAAAAAAA) >> 1);
731 return;
732 case 1:
733 for ( i = 0; i < nWords; i++ )
734 pTruth[i] = ((pTruth[i] & 0x33333333) << 2) | ((pTruth[i] & 0xCCCCCCCC) >> 2);
735 return;
736 case 2:
737 for ( i = 0; i < nWords; i++ )
738 pTruth[i] = ((pTruth[i] & 0x0F0F0F0F) << 4) | ((pTruth[i] & 0xF0F0F0F0) >> 4);
739 return;
740 case 3:
741 for ( i = 0; i < nWords; i++ )
742 pTruth[i] = ((pTruth[i] & 0x00FF00FF) << 8) | ((pTruth[i] & 0xFF00FF00) >> 8);
743 return;
744 case 4:
745 for ( i = 0; i < nWords; i++ )
746 pTruth[i] = ((pTruth[i] & 0x0000FFFF) << 16) | ((pTruth[i] & 0xFFFF0000) >> 16);
747 return;
748 default:
749 Step = (1 << (iVar - 5));
750 for ( k = 0; k < nWords; k += 2*Step )
751 {
752 for ( i = 0; i < Step; i++ )
753 {
754 Temp = pTruth[i];
755 pTruth[i] = pTruth[Step+i];
756 pTruth[Step+i] = Temp;
757 }
758 pTruth += 2*Step;
759 }
760 return;
761 }
762}
Here is the caller graph for this function:

◆ Extra_TruthCofactor0()

void Extra_TruthCofactor0 ( unsigned * pTruth,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Computes negative cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 450 of file extraUtilTruth.c.

451{
452 int nWords = Extra_TruthWordNum( nVars );
453 int i, k, Step;
454
455 assert( iVar < nVars );
456 switch ( iVar )
457 {
458 case 0:
459 for ( i = 0; i < nWords; i++ )
460 pTruth[i] = (pTruth[i] & 0x55555555) | ((pTruth[i] & 0x55555555) << 1);
461 return;
462 case 1:
463 for ( i = 0; i < nWords; i++ )
464 pTruth[i] = (pTruth[i] & 0x33333333) | ((pTruth[i] & 0x33333333) << 2);
465 return;
466 case 2:
467 for ( i = 0; i < nWords; i++ )
468 pTruth[i] = (pTruth[i] & 0x0F0F0F0F) | ((pTruth[i] & 0x0F0F0F0F) << 4);
469 return;
470 case 3:
471 for ( i = 0; i < nWords; i++ )
472 pTruth[i] = (pTruth[i] & 0x00FF00FF) | ((pTruth[i] & 0x00FF00FF) << 8);
473 return;
474 case 4:
475 for ( i = 0; i < nWords; i++ )
476 pTruth[i] = (pTruth[i] & 0x0000FFFF) | ((pTruth[i] & 0x0000FFFF) << 16);
477 return;
478 default:
479 Step = (1 << (iVar - 5));
480 for ( k = 0; k < nWords; k += 2*Step )
481 {
482 for ( i = 0; i < Step; i++ )
483 pTruth[Step+i] = pTruth[i];
484 pTruth += 2*Step;
485 }
486 return;
487 }
488}
Here is the caller graph for this function:

◆ Extra_TruthCofactor1()

void Extra_TruthCofactor1 ( unsigned * pTruth,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Computes positive cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 399 of file extraUtilTruth.c.

400{
401 int nWords = Extra_TruthWordNum( nVars );
402 int i, k, Step;
403
404 assert( iVar < nVars );
405 switch ( iVar )
406 {
407 case 0:
408 for ( i = 0; i < nWords; i++ )
409 pTruth[i] = (pTruth[i] & 0xAAAAAAAA) | ((pTruth[i] & 0xAAAAAAAA) >> 1);
410 return;
411 case 1:
412 for ( i = 0; i < nWords; i++ )
413 pTruth[i] = (pTruth[i] & 0xCCCCCCCC) | ((pTruth[i] & 0xCCCCCCCC) >> 2);
414 return;
415 case 2:
416 for ( i = 0; i < nWords; i++ )
417 pTruth[i] = (pTruth[i] & 0xF0F0F0F0) | ((pTruth[i] & 0xF0F0F0F0) >> 4);
418 return;
419 case 3:
420 for ( i = 0; i < nWords; i++ )
421 pTruth[i] = (pTruth[i] & 0xFF00FF00) | ((pTruth[i] & 0xFF00FF00) >> 8);
422 return;
423 case 4:
424 for ( i = 0; i < nWords; i++ )
425 pTruth[i] = (pTruth[i] & 0xFFFF0000) | ((pTruth[i] & 0xFFFF0000) >> 16);
426 return;
427 default:
428 Step = (1 << (iVar - 5));
429 for ( k = 0; k < nWords; k += 2*Step )
430 {
431 for ( i = 0; i < Step; i++ )
432 pTruth[i] = pTruth[Step+i];
433 pTruth += 2*Step;
434 }
435 return;
436 }
437}
Here is the caller graph for this function:

◆ Extra_TruthCountOnesInCofs()

void Extra_TruthCountOnesInCofs ( unsigned * pTruth,
int nVars,
short * pStore )
extern

Function*************************************************************

Synopsis [Counts the number of 1's in each cofactor.]

Description [The resulting numbers are stored in the array of shorts, whose length is 2*nVars. The number of 1's is counted in a different space than the original function. For example, if the function depends on k variables, the cofactors are assumed to depend on k-1 variables.]

SideEffects []

SeeAlso []

Definition at line 828 of file extraUtilTruth.c.

829{
830 int nWords = Extra_TruthWordNum( nVars );
831 int i, k, Counter;
832 memset( pStore, 0, sizeof(short) * 2 * nVars );
833 if ( nVars <= 5 )
834 {
835 if ( nVars > 0 )
836 {
837 pStore[2*0+0] = Extra_WordCountOnes( pTruth[0] & 0x55555555 );
838 pStore[2*0+1] = Extra_WordCountOnes( pTruth[0] & 0xAAAAAAAA );
839 }
840 if ( nVars > 1 )
841 {
842 pStore[2*1+0] = Extra_WordCountOnes( pTruth[0] & 0x33333333 );
843 pStore[2*1+1] = Extra_WordCountOnes( pTruth[0] & 0xCCCCCCCC );
844 }
845 if ( nVars > 2 )
846 {
847 pStore[2*2+0] = Extra_WordCountOnes( pTruth[0] & 0x0F0F0F0F );
848 pStore[2*2+1] = Extra_WordCountOnes( pTruth[0] & 0xF0F0F0F0 );
849 }
850 if ( nVars > 3 )
851 {
852 pStore[2*3+0] = Extra_WordCountOnes( pTruth[0] & 0x00FF00FF );
853 pStore[2*3+1] = Extra_WordCountOnes( pTruth[0] & 0xFF00FF00 );
854 }
855 if ( nVars > 4 )
856 {
857 pStore[2*4+0] = Extra_WordCountOnes( pTruth[0] & 0x0000FFFF );
858 pStore[2*4+1] = Extra_WordCountOnes( pTruth[0] & 0xFFFF0000 );
859 }
860 return;
861 }
862 // nVars >= 6
863 // count 1's for all other variables
864 for ( k = 0; k < nWords; k++ )
865 {
866 Counter = Extra_WordCountOnes( pTruth[k] );
867 for ( i = 5; i < nVars; i++ )
868 if ( k & (1 << (i-5)) )
869 pStore[2*i+1] += Counter;
870 else
871 pStore[2*i+0] += Counter;
872 }
873 // count 1's for the first five variables
874 for ( k = 0; k < nWords/2; k++ )
875 {
876 pStore[2*0+0] += Extra_WordCountOnes( (pTruth[0] & 0x55555555) | ((pTruth[1] & 0x55555555) << 1) );
877 pStore[2*0+1] += Extra_WordCountOnes( (pTruth[0] & 0xAAAAAAAA) | ((pTruth[1] & 0xAAAAAAAA) >> 1) );
878 pStore[2*1+0] += Extra_WordCountOnes( (pTruth[0] & 0x33333333) | ((pTruth[1] & 0x33333333) << 2) );
879 pStore[2*1+1] += Extra_WordCountOnes( (pTruth[0] & 0xCCCCCCCC) | ((pTruth[1] & 0xCCCCCCCC) >> 2) );
880 pStore[2*2+0] += Extra_WordCountOnes( (pTruth[0] & 0x0F0F0F0F) | ((pTruth[1] & 0x0F0F0F0F) << 4) );
881 pStore[2*2+1] += Extra_WordCountOnes( (pTruth[0] & 0xF0F0F0F0) | ((pTruth[1] & 0xF0F0F0F0) >> 4) );
882 pStore[2*3+0] += Extra_WordCountOnes( (pTruth[0] & 0x00FF00FF) | ((pTruth[1] & 0x00FF00FF) << 8) );
883 pStore[2*3+1] += Extra_WordCountOnes( (pTruth[0] & 0xFF00FF00) | ((pTruth[1] & 0xFF00FF00) >> 8) );
884 pStore[2*4+0] += Extra_WordCountOnes( (pTruth[0] & 0x0000FFFF) | ((pTruth[1] & 0x0000FFFF) << 16) );
885 pStore[2*4+1] += Extra_WordCountOnes( (pTruth[0] & 0xFFFF0000) | ((pTruth[1] & 0xFFFF0000) >> 16) );
886 pTruth += 2;
887 }
888}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthElementary()

unsigned ** Extra_TruthElementary ( int nVars)
extern

AutomaticStart AutomaticEnd Function*************************************************************

Synopsis [Derive elementary truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file extraUtilTruth.c.

78{
79 unsigned ** pRes;
80 int i, k, nWords;
81 nWords = Extra_TruthWordNum(nVars);
82 pRes = (unsigned **)Extra_ArrayAlloc( nVars, nWords, 4 );
83 for ( i = 0; i < nVars; i++ )
84 {
85 if ( i < 5 )
86 {
87 for ( k = 0; k < nWords; k++ )
88 pRes[i][k] = s_VarMasks[i][1];
89 }
90 else
91 {
92 for ( k = 0; k < nWords; k++ )
93 if ( k & (1 << (i-5)) )
94 pRes[i][k] = ~(unsigned)0;
95 else
96 pRes[i][k] = 0;
97 }
98 }
99 return pRes;
100}
void ** Extra_ArrayAlloc(int nCols, int nRows, int Size)
Here is the call graph for this function:

◆ Extra_TruthExist()

void Extra_TruthExist ( unsigned * pTruth,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Existentially quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 502 of file extraUtilTruth.c.

503{
504 int nWords = Extra_TruthWordNum( nVars );
505 int i, k, Step;
506
507 assert( iVar < nVars );
508 switch ( iVar )
509 {
510 case 0:
511 for ( i = 0; i < nWords; i++ )
512 pTruth[i] |= ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
513 return;
514 case 1:
515 for ( i = 0; i < nWords; i++ )
516 pTruth[i] |= ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
517 return;
518 case 2:
519 for ( i = 0; i < nWords; i++ )
520 pTruth[i] |= ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
521 return;
522 case 3:
523 for ( i = 0; i < nWords; i++ )
524 pTruth[i] |= ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
525 return;
526 case 4:
527 for ( i = 0; i < nWords; i++ )
528 pTruth[i] |= ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
529 return;
530 default:
531 Step = (1 << (iVar - 5));
532 for ( k = 0; k < nWords; k += 2*Step )
533 {
534 for ( i = 0; i < Step; i++ )
535 {
536 pTruth[i] |= pTruth[Step+i];
537 pTruth[Step+i] = pTruth[i];
538 }
539 pTruth += 2*Step;
540 }
541 return;
542 }
543}

◆ Extra_TruthExpand()

void Extra_TruthExpand ( int nVars,
int nWords,
unsigned * puTruth,
unsigned uPhase,
unsigned * puTruthR )
extern

Function*************************************************************

Synopsis [Computes a phase of the 8-var function.]

Description []

SideEffects []

SeeAlso []

Definition at line 1280 of file extraUtilMisc.c.

1281{
1282 // elementary truth tables
1283 static unsigned uTruths[8][8] = {
1284 { 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
1285 { 0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC },
1286 { 0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0 },
1287 { 0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00 },
1288 { 0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000 },
1289 { 0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF },
1290 { 0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF },
1291 { 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF }
1292 };
1293 static signed char Cases[256] = {
1294 0, // 00000000
1295 0, // 00000001
1296 1, // 00000010
1297 0, // 00000011
1298 2, // 00000100
1299 -1, // 00000101
1300 -1, // 00000110
1301 0, // 00000111
1302 3, // 00001000
1303 -1, // 00001001
1304 -1, // 00001010
1305 -1, // 00001011
1306 -1, // 00001100
1307 -1, // 00001101
1308 -1, // 00001110
1309 0, // 00001111
1310 4, // 00010000
1311 -1, // 00010001
1312 -1, // 00010010
1313 -1, // 00010011
1314 -1, // 00010100
1315 -1, // 00010101
1316 -1, // 00010110
1317 -1, // 00010111
1318 -1, // 00011000
1319 -1, // 00011001
1320 -1, // 00011010
1321 -1, // 00011011
1322 -1, // 00011100
1323 -1, // 00011101
1324 -1, // 00011110
1325 0, // 00011111
1326 5, // 00100000
1327 -1, // 00100001
1328 -1, // 00100010
1329 -1, // 00100011
1330 -1, // 00100100
1331 -1, // 00100101
1332 -1, // 00100110
1333 -1, // 00100111
1334 -1, // 00101000
1335 -1, // 00101001
1336 -1, // 00101010
1337 -1, // 00101011
1338 -1, // 00101100
1339 -1, // 00101101
1340 -1, // 00101110
1341 -1, // 00101111
1342 -1, // 00110000
1343 -1, // 00110001
1344 -1, // 00110010
1345 -1, // 00110011
1346 -1, // 00110100
1347 -1, // 00110101
1348 -1, // 00110110
1349 -1, // 00110111
1350 -1, // 00111000
1351 -1, // 00111001
1352 -1, // 00111010
1353 -1, // 00111011
1354 -1, // 00111100
1355 -1, // 00111101
1356 -1, // 00111110
1357 0, // 00111111
1358 6, // 01000000
1359 -1, // 01000001
1360 -1, // 01000010
1361 -1, // 01000011
1362 -1, // 01000100
1363 -1, // 01000101
1364 -1, // 01000110
1365 -1, // 01000111
1366 -1, // 01001000
1367 -1, // 01001001
1368 -1, // 01001010
1369 -1, // 01001011
1370 -1, // 01001100
1371 -1, // 01001101
1372 -1, // 01001110
1373 -1, // 01001111
1374 -1, // 01010000
1375 -1, // 01010001
1376 -1, // 01010010
1377 -1, // 01010011
1378 -1, // 01010100
1379 -1, // 01010101
1380 -1, // 01010110
1381 -1, // 01010111
1382 -1, // 01011000
1383 -1, // 01011001
1384 -1, // 01011010
1385 -1, // 01011011
1386 -1, // 01011100
1387 -1, // 01011101
1388 -1, // 01011110
1389 -1, // 01011111
1390 -1, // 01100000
1391 -1, // 01100001
1392 -1, // 01100010
1393 -1, // 01100011
1394 -1, // 01100100
1395 -1, // 01100101
1396 -1, // 01100110
1397 -1, // 01100111
1398 -1, // 01101000
1399 -1, // 01101001
1400 -1, // 01101010
1401 -1, // 01101011
1402 -1, // 01101100
1403 -1, // 01101101
1404 -1, // 01101110
1405 -1, // 01101111
1406 -1, // 01110000
1407 -1, // 01110001
1408 -1, // 01110010
1409 -1, // 01110011
1410 -1, // 01110100
1411 -1, // 01110101
1412 -1, // 01110110
1413 -1, // 01110111
1414 -1, // 01111000
1415 -1, // 01111001
1416 -1, // 01111010
1417 -1, // 01111011
1418 -1, // 01111100
1419 -1, // 01111101
1420 -1, // 01111110
1421 0, // 01111111
1422 7, // 10000000
1423 -1, // 10000001
1424 -1, // 10000010
1425 -1, // 10000011
1426 -1, // 10000100
1427 -1, // 10000101
1428 -1, // 10000110
1429 -1, // 10000111
1430 -1, // 10001000
1431 -1, // 10001001
1432 -1, // 10001010
1433 -1, // 10001011
1434 -1, // 10001100
1435 -1, // 10001101
1436 -1, // 10001110
1437 -1, // 10001111
1438 -1, // 10010000
1439 -1, // 10010001
1440 -1, // 10010010
1441 -1, // 10010011
1442 -1, // 10010100
1443 -1, // 10010101
1444 -1, // 10010110
1445 -1, // 10010111
1446 -1, // 10011000
1447 -1, // 10011001
1448 -1, // 10011010
1449 -1, // 10011011
1450 -1, // 10011100
1451 -1, // 10011101
1452 -1, // 10011110
1453 -1, // 10011111
1454 -1, // 10100000
1455 -1, // 10100001
1456 -1, // 10100010
1457 -1, // 10100011
1458 -1, // 10100100
1459 -1, // 10100101
1460 -1, // 10100110
1461 -1, // 10100111
1462 -1, // 10101000
1463 -1, // 10101001
1464 -1, // 10101010
1465 -1, // 10101011
1466 -1, // 10101100
1467 -1, // 10101101
1468 -1, // 10101110
1469 -1, // 10101111
1470 -1, // 10110000
1471 -1, // 10110001
1472 -1, // 10110010
1473 -1, // 10110011
1474 -1, // 10110100
1475 -1, // 10110101
1476 -1, // 10110110
1477 -1, // 10110111
1478 -1, // 10111000
1479 -1, // 10111001
1480 -1, // 10111010
1481 -1, // 10111011
1482 -1, // 10111100
1483 -1, // 10111101
1484 -1, // 10111110
1485 -1, // 10111111
1486 -1, // 11000000
1487 -1, // 11000001
1488 -1, // 11000010
1489 -1, // 11000011
1490 -1, // 11000100
1491 -1, // 11000101
1492 -1, // 11000110
1493 -1, // 11000111
1494 -1, // 11001000
1495 -1, // 11001001
1496 -1, // 11001010
1497 -1, // 11001011
1498 -1, // 11001100
1499 -1, // 11001101
1500 -1, // 11001110
1501 -1, // 11001111
1502 -1, // 11010000
1503 -1, // 11010001
1504 -1, // 11010010
1505 -1, // 11010011
1506 -1, // 11010100
1507 -1, // 11010101
1508 -1, // 11010110
1509 -1, // 11010111
1510 -1, // 11011000
1511 -1, // 11011001
1512 -1, // 11011010
1513 -1, // 11011011
1514 -1, // 11011100
1515 -1, // 11011101
1516 -1, // 11011110
1517 -1, // 11011111
1518 -1, // 11100000
1519 -1, // 11100001
1520 -1, // 11100010
1521 -1, // 11100011
1522 -1, // 11100100
1523 -1, // 11100101
1524 -1, // 11100110
1525 -1, // 11100111
1526 -1, // 11101000
1527 -1, // 11101001
1528 -1, // 11101010
1529 -1, // 11101011
1530 -1, // 11101100
1531 -1, // 11101101
1532 -1, // 11101110
1533 -1, // 11101111
1534 -1, // 11110000
1535 -1, // 11110001
1536 -1, // 11110010
1537 -1, // 11110011
1538 -1, // 11110100
1539 -1, // 11110101
1540 -1, // 11110110
1541 -1, // 11110111
1542 -1, // 11111000
1543 -1, // 11111001
1544 -1, // 11111010
1545 -1, // 11111011
1546 -1, // 11111100
1547 -1, // 11111101
1548 -1, // 11111110
1549 0 // 11111111
1550 };
1551 static char Perms[256][8] = {
1552 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00000000
1553 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00000001
1554 { 1, 0, 2, 3, 4, 5, 6, 7 }, // 00000010
1555 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00000011
1556 { 1, 2, 0, 3, 4, 5, 6, 7 }, // 00000100
1557 { 0, 2, 1, 3, 4, 5, 6, 7 }, // 00000101
1558 { 2, 0, 1, 3, 4, 5, 6, 7 }, // 00000110
1559 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00000111
1560 { 1, 2, 3, 0, 4, 5, 6, 7 }, // 00001000
1561 { 0, 2, 3, 1, 4, 5, 6, 7 }, // 00001001
1562 { 2, 0, 3, 1, 4, 5, 6, 7 }, // 00001010
1563 { 0, 1, 3, 2, 4, 5, 6, 7 }, // 00001011
1564 { 2, 3, 0, 1, 4, 5, 6, 7 }, // 00001100
1565 { 0, 3, 1, 2, 4, 5, 6, 7 }, // 00001101
1566 { 3, 0, 1, 2, 4, 5, 6, 7 }, // 00001110
1567 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00001111
1568 { 1, 2, 3, 4, 0, 5, 6, 7 }, // 00010000
1569 { 0, 2, 3, 4, 1, 5, 6, 7 }, // 00010001
1570 { 2, 0, 3, 4, 1, 5, 6, 7 }, // 00010010
1571 { 0, 1, 3, 4, 2, 5, 6, 7 }, // 00010011
1572 { 2, 3, 0, 4, 1, 5, 6, 7 }, // 00010100
1573 { 0, 3, 1, 4, 2, 5, 6, 7 }, // 00010101
1574 { 3, 0, 1, 4, 2, 5, 6, 7 }, // 00010110
1575 { 0, 1, 2, 4, 3, 5, 6, 7 }, // 00010111
1576 { 2, 3, 4, 0, 1, 5, 6, 7 }, // 00011000
1577 { 0, 3, 4, 1, 2, 5, 6, 7 }, // 00011001
1578 { 3, 0, 4, 1, 2, 5, 6, 7 }, // 00011010
1579 { 0, 1, 4, 2, 3, 5, 6, 7 }, // 00011011
1580 { 3, 4, 0, 1, 2, 5, 6, 7 }, // 00011100
1581 { 0, 4, 1, 2, 3, 5, 6, 7 }, // 00011101
1582 { 4, 0, 1, 2, 3, 5, 6, 7 }, // 00011110
1583 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00011111
1584 { 1, 2, 3, 4, 5, 0, 6, 7 }, // 00100000
1585 { 0, 2, 3, 4, 5, 1, 6, 7 }, // 00100001
1586 { 2, 0, 3, 4, 5, 1, 6, 7 }, // 00100010
1587 { 0, 1, 3, 4, 5, 2, 6, 7 }, // 00100011
1588 { 2, 3, 0, 4, 5, 1, 6, 7 }, // 00100100
1589 { 0, 3, 1, 4, 5, 2, 6, 7 }, // 00100101
1590 { 3, 0, 1, 4, 5, 2, 6, 7 }, // 00100110
1591 { 0, 1, 2, 4, 5, 3, 6, 7 }, // 00100111
1592 { 2, 3, 4, 0, 5, 1, 6, 7 }, // 00101000
1593 { 0, 3, 4, 1, 5, 2, 6, 7 }, // 00101001
1594 { 3, 0, 4, 1, 5, 2, 6, 7 }, // 00101010
1595 { 0, 1, 4, 2, 5, 3, 6, 7 }, // 00101011
1596 { 3, 4, 0, 1, 5, 2, 6, 7 }, // 00101100
1597 { 0, 4, 1, 2, 5, 3, 6, 7 }, // 00101101
1598 { 4, 0, 1, 2, 5, 3, 6, 7 }, // 00101110
1599 { 0, 1, 2, 3, 5, 4, 6, 7 }, // 00101111
1600 { 2, 3, 4, 5, 0, 1, 6, 7 }, // 00110000
1601 { 0, 3, 4, 5, 1, 2, 6, 7 }, // 00110001
1602 { 3, 0, 4, 5, 1, 2, 6, 7 }, // 00110010
1603 { 0, 1, 4, 5, 2, 3, 6, 7 }, // 00110011
1604 { 3, 4, 0, 5, 1, 2, 6, 7 }, // 00110100
1605 { 0, 4, 1, 5, 2, 3, 6, 7 }, // 00110101
1606 { 4, 0, 1, 5, 2, 3, 6, 7 }, // 00110110
1607 { 0, 1, 2, 5, 3, 4, 6, 7 }, // 00110111
1608 { 3, 4, 5, 0, 1, 2, 6, 7 }, // 00111000
1609 { 0, 4, 5, 1, 2, 3, 6, 7 }, // 00111001
1610 { 4, 0, 5, 1, 2, 3, 6, 7 }, // 00111010
1611 { 0, 1, 5, 2, 3, 4, 6, 7 }, // 00111011
1612 { 4, 5, 0, 1, 2, 3, 6, 7 }, // 00111100
1613 { 0, 5, 1, 2, 3, 4, 6, 7 }, // 00111101
1614 { 5, 0, 1, 2, 3, 4, 6, 7 }, // 00111110
1615 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 00111111
1616 { 1, 2, 3, 4, 5, 6, 0, 7 }, // 01000000
1617 { 0, 2, 3, 4, 5, 6, 1, 7 }, // 01000001
1618 { 2, 0, 3, 4, 5, 6, 1, 7 }, // 01000010
1619 { 0, 1, 3, 4, 5, 6, 2, 7 }, // 01000011
1620 { 2, 3, 0, 4, 5, 6, 1, 7 }, // 01000100
1621 { 0, 3, 1, 4, 5, 6, 2, 7 }, // 01000101
1622 { 3, 0, 1, 4, 5, 6, 2, 7 }, // 01000110
1623 { 0, 1, 2, 4, 5, 6, 3, 7 }, // 01000111
1624 { 2, 3, 4, 0, 5, 6, 1, 7 }, // 01001000
1625 { 0, 3, 4, 1, 5, 6, 2, 7 }, // 01001001
1626 { 3, 0, 4, 1, 5, 6, 2, 7 }, // 01001010
1627 { 0, 1, 4, 2, 5, 6, 3, 7 }, // 01001011
1628 { 3, 4, 0, 1, 5, 6, 2, 7 }, // 01001100
1629 { 0, 4, 1, 2, 5, 6, 3, 7 }, // 01001101
1630 { 4, 0, 1, 2, 5, 6, 3, 7 }, // 01001110
1631 { 0, 1, 2, 3, 5, 6, 4, 7 }, // 01001111
1632 { 2, 3, 4, 5, 0, 6, 1, 7 }, // 01010000
1633 { 0, 3, 4, 5, 1, 6, 2, 7 }, // 01010001
1634 { 3, 0, 4, 5, 1, 6, 2, 7 }, // 01010010
1635 { 0, 1, 4, 5, 2, 6, 3, 7 }, // 01010011
1636 { 3, 4, 0, 5, 1, 6, 2, 7 }, // 01010100
1637 { 0, 4, 1, 5, 2, 6, 3, 7 }, // 01010101
1638 { 4, 0, 1, 5, 2, 6, 3, 7 }, // 01010110
1639 { 0, 1, 2, 5, 3, 6, 4, 7 }, // 01010111
1640 { 3, 4, 5, 0, 1, 6, 2, 7 }, // 01011000
1641 { 0, 4, 5, 1, 2, 6, 3, 7 }, // 01011001
1642 { 4, 0, 5, 1, 2, 6, 3, 7 }, // 01011010
1643 { 0, 1, 5, 2, 3, 6, 4, 7 }, // 01011011
1644 { 4, 5, 0, 1, 2, 6, 3, 7 }, // 01011100
1645 { 0, 5, 1, 2, 3, 6, 4, 7 }, // 01011101
1646 { 5, 0, 1, 2, 3, 6, 4, 7 }, // 01011110
1647 { 0, 1, 2, 3, 4, 6, 5, 7 }, // 01011111
1648 { 2, 3, 4, 5, 6, 0, 1, 7 }, // 01100000
1649 { 0, 3, 4, 5, 6, 1, 2, 7 }, // 01100001
1650 { 3, 0, 4, 5, 6, 1, 2, 7 }, // 01100010
1651 { 0, 1, 4, 5, 6, 2, 3, 7 }, // 01100011
1652 { 3, 4, 0, 5, 6, 1, 2, 7 }, // 01100100
1653 { 0, 4, 1, 5, 6, 2, 3, 7 }, // 01100101
1654 { 4, 0, 1, 5, 6, 2, 3, 7 }, // 01100110
1655 { 0, 1, 2, 5, 6, 3, 4, 7 }, // 01100111
1656 { 3, 4, 5, 0, 6, 1, 2, 7 }, // 01101000
1657 { 0, 4, 5, 1, 6, 2, 3, 7 }, // 01101001
1658 { 4, 0, 5, 1, 6, 2, 3, 7 }, // 01101010
1659 { 0, 1, 5, 2, 6, 3, 4, 7 }, // 01101011
1660 { 4, 5, 0, 1, 6, 2, 3, 7 }, // 01101100
1661 { 0, 5, 1, 2, 6, 3, 4, 7 }, // 01101101
1662 { 5, 0, 1, 2, 6, 3, 4, 7 }, // 01101110
1663 { 0, 1, 2, 3, 6, 4, 5, 7 }, // 01101111
1664 { 3, 4, 5, 6, 0, 1, 2, 7 }, // 01110000
1665 { 0, 4, 5, 6, 1, 2, 3, 7 }, // 01110001
1666 { 4, 0, 5, 6, 1, 2, 3, 7 }, // 01110010
1667 { 0, 1, 5, 6, 2, 3, 4, 7 }, // 01110011
1668 { 4, 5, 0, 6, 1, 2, 3, 7 }, // 01110100
1669 { 0, 5, 1, 6, 2, 3, 4, 7 }, // 01110101
1670 { 5, 0, 1, 6, 2, 3, 4, 7 }, // 01110110
1671 { 0, 1, 2, 6, 3, 4, 5, 7 }, // 01110111
1672 { 4, 5, 6, 0, 1, 2, 3, 7 }, // 01111000
1673 { 0, 5, 6, 1, 2, 3, 4, 7 }, // 01111001
1674 { 5, 0, 6, 1, 2, 3, 4, 7 }, // 01111010
1675 { 0, 1, 6, 2, 3, 4, 5, 7 }, // 01111011
1676 { 5, 6, 0, 1, 2, 3, 4, 7 }, // 01111100
1677 { 0, 6, 1, 2, 3, 4, 5, 7 }, // 01111101
1678 { 6, 0, 1, 2, 3, 4, 5, 7 }, // 01111110
1679 { 0, 1, 2, 3, 4, 5, 6, 7 }, // 01111111
1680 { 1, 2, 3, 4, 5, 6, 7, 0 }, // 10000000
1681 { 0, 2, 3, 4, 5, 6, 7, 1 }, // 10000001
1682 { 2, 0, 3, 4, 5, 6, 7, 1 }, // 10000010
1683 { 0, 1, 3, 4, 5, 6, 7, 2 }, // 10000011
1684 { 2, 3, 0, 4, 5, 6, 7, 1 }, // 10000100
1685 { 0, 3, 1, 4, 5, 6, 7, 2 }, // 10000101
1686 { 3, 0, 1, 4, 5, 6, 7, 2 }, // 10000110
1687 { 0, 1, 2, 4, 5, 6, 7, 3 }, // 10000111
1688 { 2, 3, 4, 0, 5, 6, 7, 1 }, // 10001000
1689 { 0, 3, 4, 1, 5, 6, 7, 2 }, // 10001001
1690 { 3, 0, 4, 1, 5, 6, 7, 2 }, // 10001010
1691 { 0, 1, 4, 2, 5, 6, 7, 3 }, // 10001011
1692 { 3, 4, 0, 1, 5, 6, 7, 2 }, // 10001100
1693 { 0, 4, 1, 2, 5, 6, 7, 3 }, // 10001101
1694 { 4, 0, 1, 2, 5, 6, 7, 3 }, // 10001110
1695 { 0, 1, 2, 3, 5, 6, 7, 4 }, // 10001111
1696 { 2, 3, 4, 5, 0, 6, 7, 1 }, // 10010000
1697 { 0, 3, 4, 5, 1, 6, 7, 2 }, // 10010001
1698 { 3, 0, 4, 5, 1, 6, 7, 2 }, // 10010010
1699 { 0, 1, 4, 5, 2, 6, 7, 3 }, // 10010011
1700 { 3, 4, 0, 5, 1, 6, 7, 2 }, // 10010100
1701 { 0, 4, 1, 5, 2, 6, 7, 3 }, // 10010101
1702 { 4, 0, 1, 5, 2, 6, 7, 3 }, // 10010110
1703 { 0, 1, 2, 5, 3, 6, 7, 4 }, // 10010111
1704 { 3, 4, 5, 0, 1, 6, 7, 2 }, // 10011000
1705 { 0, 4, 5, 1, 2, 6, 7, 3 }, // 10011001
1706 { 4, 0, 5, 1, 2, 6, 7, 3 }, // 10011010
1707 { 0, 1, 5, 2, 3, 6, 7, 4 }, // 10011011
1708 { 4, 5, 0, 1, 2, 6, 7, 3 }, // 10011100
1709 { 0, 5, 1, 2, 3, 6, 7, 4 }, // 10011101
1710 { 5, 0, 1, 2, 3, 6, 7, 4 }, // 10011110
1711 { 0, 1, 2, 3, 4, 6, 7, 5 }, // 10011111
1712 { 2, 3, 4, 5, 6, 0, 7, 1 }, // 10100000
1713 { 0, 3, 4, 5, 6, 1, 7, 2 }, // 10100001
1714 { 3, 0, 4, 5, 6, 1, 7, 2 }, // 10100010
1715 { 0, 1, 4, 5, 6, 2, 7, 3 }, // 10100011
1716 { 3, 4, 0, 5, 6, 1, 7, 2 }, // 10100100
1717 { 0, 4, 1, 5, 6, 2, 7, 3 }, // 10100101
1718 { 4, 0, 1, 5, 6, 2, 7, 3 }, // 10100110
1719 { 0, 1, 2, 5, 6, 3, 7, 4 }, // 10100111
1720 { 3, 4, 5, 0, 6, 1, 7, 2 }, // 10101000
1721 { 0, 4, 5, 1, 6, 2, 7, 3 }, // 10101001
1722 { 4, 0, 5, 1, 6, 2, 7, 3 }, // 10101010
1723 { 0, 1, 5, 2, 6, 3, 7, 4 }, // 10101011
1724 { 4, 5, 0, 1, 6, 2, 7, 3 }, // 10101100
1725 { 0, 5, 1, 2, 6, 3, 7, 4 }, // 10101101
1726 { 5, 0, 1, 2, 6, 3, 7, 4 }, // 10101110
1727 { 0, 1, 2, 3, 6, 4, 7, 5 }, // 10101111
1728 { 3, 4, 5, 6, 0, 1, 7, 2 }, // 10110000
1729 { 0, 4, 5, 6, 1, 2, 7, 3 }, // 10110001
1730 { 4, 0, 5, 6, 1, 2, 7, 3 }, // 10110010
1731 { 0, 1, 5, 6, 2, 3, 7, 4 }, // 10110011
1732 { 4, 5, 0, 6, 1, 2, 7, 3 }, // 10110100
1733 { 0, 5, 1, 6, 2, 3, 7, 4 }, // 10110101
1734 { 5, 0, 1, 6, 2, 3, 7, 4 }, // 10110110
1735 { 0, 1, 2, 6, 3, 4, 7, 5 }, // 10110111
1736 { 4, 5, 6, 0, 1, 2, 7, 3 }, // 10111000
1737 { 0, 5, 6, 1, 2, 3, 7, 4 }, // 10111001
1738 { 5, 0, 6, 1, 2, 3, 7, 4 }, // 10111010
1739 { 0, 1, 6, 2, 3, 4, 7, 5 }, // 10111011
1740 { 5, 6, 0, 1, 2, 3, 7, 4 }, // 10111100
1741 { 0, 6, 1, 2, 3, 4, 7, 5 }, // 10111101
1742 { 6, 0, 1, 2, 3, 4, 7, 5 }, // 10111110
1743 { 0, 1, 2, 3, 4, 5, 7, 6 }, // 10111111
1744 { 2, 3, 4, 5, 6, 7, 0, 1 }, // 11000000
1745 { 0, 3, 4, 5, 6, 7, 1, 2 }, // 11000001
1746 { 3, 0, 4, 5, 6, 7, 1, 2 }, // 11000010
1747 { 0, 1, 4, 5, 6, 7, 2, 3 }, // 11000011
1748 { 3, 4, 0, 5, 6, 7, 1, 2 }, // 11000100
1749 { 0, 4, 1, 5, 6, 7, 2, 3 }, // 11000101
1750 { 4, 0, 1, 5, 6, 7, 2, 3 }, // 11000110
1751 { 0, 1, 2, 5, 6, 7, 3, 4 }, // 11000111
1752 { 3, 4, 5, 0, 6, 7, 1, 2 }, // 11001000
1753 { 0, 4, 5, 1, 6, 7, 2, 3 }, // 11001001
1754 { 4, 0, 5, 1, 6, 7, 2, 3 }, // 11001010
1755 { 0, 1, 5, 2, 6, 7, 3, 4 }, // 11001011
1756 { 4, 5, 0, 1, 6, 7, 2, 3 }, // 11001100
1757 { 0, 5, 1, 2, 6, 7, 3, 4 }, // 11001101
1758 { 5, 0, 1, 2, 6, 7, 3, 4 }, // 11001110
1759 { 0, 1, 2, 3, 6, 7, 4, 5 }, // 11001111
1760 { 3, 4, 5, 6, 0, 7, 1, 2 }, // 11010000
1761 { 0, 4, 5, 6, 1, 7, 2, 3 }, // 11010001
1762 { 4, 0, 5, 6, 1, 7, 2, 3 }, // 11010010
1763 { 0, 1, 5, 6, 2, 7, 3, 4 }, // 11010011
1764 { 4, 5, 0, 6, 1, 7, 2, 3 }, // 11010100
1765 { 0, 5, 1, 6, 2, 7, 3, 4 }, // 11010101
1766 { 5, 0, 1, 6, 2, 7, 3, 4 }, // 11010110
1767 { 0, 1, 2, 6, 3, 7, 4, 5 }, // 11010111
1768 { 4, 5, 6, 0, 1, 7, 2, 3 }, // 11011000
1769 { 0, 5, 6, 1, 2, 7, 3, 4 }, // 11011001
1770 { 5, 0, 6, 1, 2, 7, 3, 4 }, // 11011010
1771 { 0, 1, 6, 2, 3, 7, 4, 5 }, // 11011011
1772 { 5, 6, 0, 1, 2, 7, 3, 4 }, // 11011100
1773 { 0, 6, 1, 2, 3, 7, 4, 5 }, // 11011101
1774 { 6, 0, 1, 2, 3, 7, 4, 5 }, // 11011110
1775 { 0, 1, 2, 3, 4, 7, 5, 6 }, // 11011111
1776 { 3, 4, 5, 6, 7, 0, 1, 2 }, // 11100000
1777 { 0, 4, 5, 6, 7, 1, 2, 3 }, // 11100001
1778 { 4, 0, 5, 6, 7, 1, 2, 3 }, // 11100010
1779 { 0, 1, 5, 6, 7, 2, 3, 4 }, // 11100011
1780 { 4, 5, 0, 6, 7, 1, 2, 3 }, // 11100100
1781 { 0, 5, 1, 6, 7, 2, 3, 4 }, // 11100101
1782 { 5, 0, 1, 6, 7, 2, 3, 4 }, // 11100110
1783 { 0, 1, 2, 6, 7, 3, 4, 5 }, // 11100111
1784 { 4, 5, 6, 0, 7, 1, 2, 3 }, // 11101000
1785 { 0, 5, 6, 1, 7, 2, 3, 4 }, // 11101001
1786 { 5, 0, 6, 1, 7, 2, 3, 4 }, // 11101010
1787 { 0, 1, 6, 2, 7, 3, 4, 5 }, // 11101011
1788 { 5, 6, 0, 1, 7, 2, 3, 4 }, // 11101100
1789 { 0, 6, 1, 2, 7, 3, 4, 5 }, // 11101101
1790 { 6, 0, 1, 2, 7, 3, 4, 5 }, // 11101110
1791 { 0, 1, 2, 3, 7, 4, 5, 6 }, // 11101111
1792 { 4, 5, 6, 7, 0, 1, 2, 3 }, // 11110000
1793 { 0, 5, 6, 7, 1, 2, 3, 4 }, // 11110001
1794 { 5, 0, 6, 7, 1, 2, 3, 4 }, // 11110010
1795 { 0, 1, 6, 7, 2, 3, 4, 5 }, // 11110011
1796 { 5, 6, 0, 7, 1, 2, 3, 4 }, // 11110100
1797 { 0, 6, 1, 7, 2, 3, 4, 5 }, // 11110101
1798 { 6, 0, 1, 7, 2, 3, 4, 5 }, // 11110110
1799 { 0, 1, 2, 7, 3, 4, 5, 6 }, // 11110111
1800 { 5, 6, 7, 0, 1, 2, 3, 4 }, // 11111000
1801 { 0, 6, 7, 1, 2, 3, 4, 5 }, // 11111001
1802 { 6, 0, 7, 1, 2, 3, 4, 5 }, // 11111010
1803 { 0, 1, 7, 2, 3, 4, 5, 6 }, // 11111011
1804 { 6, 7, 0, 1, 2, 3, 4, 5 }, // 11111100
1805 { 0, 7, 1, 2, 3, 4, 5, 6 }, // 11111101
1806 { 7, 0, 1, 2, 3, 4, 5, 6 }, // 11111110
1807 { 0, 1, 2, 3, 4, 5, 6, 7 } // 11111111
1808 };
1809
1810 assert( uPhase > 0 && uPhase < (unsigned)(1 << nVars) );
1811
1812 // the same function
1813 if ( Cases[uPhase] == 0 )
1814 {
1815 int i;
1816 for ( i = 0; i < nWords; i++ )
1817 puTruthR[i] = puTruth[i];
1818 return;
1819 }
1820
1821 // an elementary variable
1822 if ( Cases[uPhase] > 0 )
1823 {
1824 int i;
1825 for ( i = 0; i < nWords; i++ )
1826 puTruthR[i] = uTruths[(int)Cases[uPhase]][i];
1827 return;
1828 }
1829
1830 // truth table takes one word
1831 if ( nWords == 1 )
1832 {
1833 int i, k, nMints, iRes;
1834 char * pPerm = Perms[uPhase];
1835 puTruthR[0] = 0;
1836 nMints = (1 << nVars);
1837 for ( i = 0; i < nMints; i++ )
1838 if ( puTruth[0] & (1 << i) )
1839 {
1840 for ( iRes = 0, k = 0; k < nVars; k++ )
1841 if ( i & (1 << pPerm[k]) )
1842 iRes |= (1 << k);
1843 puTruthR[0] |= (1 << iRes);
1844 }
1845 return;
1846 }
1847 else if ( nWords == 2 )
1848 {
1849 int i, k, iRes;
1850 char * pPerm = Perms[uPhase];
1851 puTruthR[0] = puTruthR[1] = 0;
1852 for ( i = 0; i < 32; i++ )
1853 {
1854 if ( puTruth[0] & (1 << i) )
1855 {
1856 for ( iRes = 0, k = 0; k < 6; k++ )
1857 if ( i & (1 << pPerm[k]) )
1858 iRes |= (1 << k);
1859 if ( iRes < 32 )
1860 puTruthR[0] |= (1 << iRes);
1861 else
1862 puTruthR[1] |= (1 << (iRes-32));
1863 }
1864 }
1865 for ( ; i < 64; i++ )
1866 {
1867 if ( puTruth[1] & (1 << (i-32)) )
1868 {
1869 for ( iRes = 0, k = 0; k < 6; k++ )
1870 if ( i & (1 << pPerm[k]) )
1871 iRes |= (1 << k);
1872 if ( iRes < 32 )
1873 puTruthR[0] |= (1 << iRes);
1874 else
1875 puTruthR[1] |= (1 << (iRes-32));
1876 }
1877 }
1878 }
1879 // truth table takes more than one word
1880 else
1881 {
1882 int i, k, nMints, iRes;
1883 char * pPerm = Perms[uPhase];
1884 for ( i = 0; i < nWords; i++ )
1885 puTruthR[i] = 0;
1886 nMints = (1 << nVars);
1887 for ( i = 0; i < nMints; i++ )
1888 if ( puTruth[i>>5] & (1 << (i&31)) )
1889 {
1890 for ( iRes = 0, k = 0; k < 5; k++ )
1891 if ( i & (1 << pPerm[k]) )
1892 iRes |= (1 << k);
1893 puTruthR[iRes>>5] |= (1 << (iRes&31));
1894 }
1895 }
1896}
Here is the caller graph for this function:

◆ Extra_TruthForall()

void Extra_TruthForall ( unsigned * pTruth,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Existentially quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 556 of file extraUtilTruth.c.

557{
558 int nWords = Extra_TruthWordNum( nVars );
559 int i, k, Step;
560
561 assert( iVar < nVars );
562 switch ( iVar )
563 {
564 case 0:
565 for ( i = 0; i < nWords; i++ )
566 pTruth[i] &= ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
567 return;
568 case 1:
569 for ( i = 0; i < nWords; i++ )
570 pTruth[i] &= ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
571 return;
572 case 2:
573 for ( i = 0; i < nWords; i++ )
574 pTruth[i] &= ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
575 return;
576 case 3:
577 for ( i = 0; i < nWords; i++ )
578 pTruth[i] &= ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
579 return;
580 case 4:
581 for ( i = 0; i < nWords; i++ )
582 pTruth[i] &= ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
583 return;
584 default:
585 Step = (1 << (iVar - 5));
586 for ( k = 0; k < nWords; k += 2*Step )
587 {
588 for ( i = 0; i < Step; i++ )
589 {
590 pTruth[i] &= pTruth[Step+i];
591 pTruth[Step+i] = pTruth[i];
592 }
593 pTruth += 2*Step;
594 }
595 return;
596 }
597}

◆ Extra_TruthHash()

unsigned Extra_TruthHash ( unsigned * pIn,
int nWords )
extern

Function*************************************************************

Synopsis [Canonicize the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 902 of file extraUtilTruth.c.

903{
904 // The 1,024 smallest prime numbers used to compute the hash value
905 // http://www.math.utah.edu/~alfeld/math/primelist.html
906 static int HashPrimes[1024] = { 2, 3, 5,
907 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
908 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
909 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,
910 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401,
911 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
912 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631,
913 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751,
914 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877,
915 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,
916 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091,
917 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193,
918 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,
919 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
920 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493,
921 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601,
922 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699,
923 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
924 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931,
925 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029,
926 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137,
927 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267,
928 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,
929 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459,
930 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593,
931 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693,
932 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791,
933 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903,
934 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023,
935 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167,
936 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271,
937 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373,
938 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511,
939 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607,
940 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709,
941 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833,
942 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931,
943 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057,
944 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177,
945 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283,
946 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423,
947 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547,
948 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657,
949 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789,
950 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931,
951 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011,
952 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147,
953 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279,
954 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413,
955 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507,
956 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647,
957 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743,
958 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857,
959 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007,
960 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121,
961 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247,
962 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343,
963 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473,
964 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607,
965 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733,
966 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857,
967 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971,
968 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103,
969 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229,
970 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369,
971 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517,
972 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603,
973 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723,
974 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873,
975 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009,
976 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123,
977 8147, 8161 };
978 int i;
979 unsigned uHashKey;
980 assert( nWords <= 1024 );
981 uHashKey = 0;
982 for ( i = 0; i < nWords; i++ )
983 uHashKey ^= HashPrimes[i] * pIn[i];
984 return uHashKey;
985}
Here is the caller graph for this function:

◆ Extra_TruthMinCofSuppOverlap()

int Extra_TruthMinCofSuppOverlap ( unsigned * pTruth,
int nVars,
int * pVarMin )
extern

Function*************************************************************

Synopsis [Computes minimum overlap in supports of cofactors.]

Description []

SideEffects []

SeeAlso []

Definition at line 775 of file extraUtilTruth.c.

776{
777 static unsigned uCofactor[16];
778 int i, ValueCur, ValueMin, VarMin;
779 unsigned uSupp0, uSupp1;
780 int nVars0, nVars1;
781 assert( nVars <= 9 );
782 ValueMin = 32;
783 VarMin = -1;
784 for ( i = 0; i < nVars; i++ )
785 {
786 // get negative cofactor
787 Extra_TruthCopy( uCofactor, pTruth, nVars );
788 Extra_TruthCofactor0( uCofactor, nVars, i );
789 uSupp0 = Extra_TruthSupport( uCofactor, nVars );
790 nVars0 = Extra_WordCountOnes( uSupp0 );
791//Extra_PrintBinary( stdout, &uSupp0, 8 ); printf( "\n" );
792 // get positive cofactor
793 Extra_TruthCopy( uCofactor, pTruth, nVars );
794 Extra_TruthCofactor1( uCofactor, nVars, i );
795 uSupp1 = Extra_TruthSupport( uCofactor, nVars );
796 nVars1 = Extra_WordCountOnes( uSupp1 );
797//Extra_PrintBinary( stdout, &uSupp1, 8 ); printf( "\n" );
798 // get the number of common vars
799 ValueCur = Extra_WordCountOnes( uSupp0 & uSupp1 );
800 if ( ValueMin > ValueCur && nVars0 <= 5 && nVars1 <= 5 )
801 {
802 ValueMin = ValueCur;
803 VarMin = i;
804 }
805 if ( ValueMin == 0 )
806 break;
807 }
808 if ( pVarMin )
809 *pVarMin = VarMin;
810 return ValueMin;
811}
void Extra_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
void Extra_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
int Extra_TruthSupport(unsigned *pTruth, int nVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthMux()

void Extra_TruthMux ( unsigned * pOut,
unsigned * pCof0,
unsigned * pCof1,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Computes negative cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file extraUtilTruth.c.

612{
613 int nWords = Extra_TruthWordNum( nVars );
614 int i, k, Step;
615
616 assert( iVar < nVars );
617 switch ( iVar )
618 {
619 case 0:
620 for ( i = 0; i < nWords; i++ )
621 pOut[i] = (pCof0[i] & 0x55555555) | (pCof1[i] & 0xAAAAAAAA);
622 return;
623 case 1:
624 for ( i = 0; i < nWords; i++ )
625 pOut[i] = (pCof0[i] & 0x33333333) | (pCof1[i] & 0xCCCCCCCC);
626 return;
627 case 2:
628 for ( i = 0; i < nWords; i++ )
629 pOut[i] = (pCof0[i] & 0x0F0F0F0F) | (pCof1[i] & 0xF0F0F0F0);
630 return;
631 case 3:
632 for ( i = 0; i < nWords; i++ )
633 pOut[i] = (pCof0[i] & 0x00FF00FF) | (pCof1[i] & 0xFF00FF00);
634 return;
635 case 4:
636 for ( i = 0; i < nWords; i++ )
637 pOut[i] = (pCof0[i] & 0x0000FFFF) | (pCof1[i] & 0xFFFF0000);
638 return;
639 default:
640 Step = (1 << (iVar - 5));
641 for ( k = 0; k < nWords; k += 2*Step )
642 {
643 for ( i = 0; i < Step; i++ )
644 {
645 pOut[i] = pCof0[i];
646 pOut[Step+i] = pCof1[Step+i];
647 }
648 pOut += 2*Step;
649 }
650 return;
651 }
652}

◆ Extra_TruthPerm43()

unsigned short ** Extra_TruthPerm43 ( )
extern

Function*************************************************************

Synopsis [Allocated lookup table for truth table permutation.]

Description []

SideEffects []

SeeAlso []

Definition at line 1909 of file extraUtilMisc.c.

1910{
1911 unsigned short ** pTable;
1912 unsigned uTruth;
1913 int i, k;
1914 pTable = (unsigned short **)Extra_ArrayAlloc( 256, 16, 2 );
1915 for ( i = 0; i < 256; i++ )
1916 {
1917 uTruth = (i << 8) | i;
1918 for ( k = 0; k < 16; k++ )
1919 pTable[i][k] = Extra_TruthPerm4One( uTruth, k );
1920 }
1921 return pTable;
1922}
unsigned short Extra_TruthPerm4One(unsigned uTruth, int Phase)
Here is the call graph for this function:

◆ Extra_TruthPerm4One()

unsigned short Extra_TruthPerm4One ( unsigned uTruth,
int Phase )
extern

Function*************************************************************

Synopsis [Computes a phase of the 3-var function.]

Description []

SideEffects []

SeeAlso []

Definition at line 906 of file extraUtilMisc.c.

907{
908 // cases
909 static unsigned short Cases[16] = {
910 0, // 0000 - skip
911 0, // 0001 - skip
912 0xCCCC, // 0010 - single var
913 0, // 0011 - skip
914 0xF0F0, // 0100 - single var
915 1, // 0101
916 1, // 0110
917 0, // 0111 - skip
918 0xFF00, // 1000 - single var
919 1, // 1001
920 1, // 1010
921 1, // 1011
922 1, // 1100
923 1, // 1101
924 1, // 1110
925 0 // 1111 - skip
926 };
927 // permutations
928 static int Perms[16][4] = {
929 { 0, 0, 0, 0 }, // 0000 - skip
930 { 0, 0, 0, 0 }, // 0001 - skip
931 { 0, 0, 0, 0 }, // 0010 - single var
932 { 0, 0, 0, 0 }, // 0011 - skip
933 { 0, 0, 0, 0 }, // 0100 - single var
934 { 0, 2, 1, 3 }, // 0101
935 { 2, 0, 1, 3 }, // 0110
936 { 0, 0, 0, 0 }, // 0111 - skip
937 { 0, 0, 0, 0 }, // 1000 - single var
938 { 0, 2, 3, 1 }, // 1001
939 { 2, 0, 3, 1 }, // 1010
940 { 0, 1, 3, 2 }, // 1011
941 { 2, 3, 0, 1 }, // 1100
942 { 0, 3, 1, 2 }, // 1101
943 { 3, 0, 1, 2 }, // 1110
944 { 0, 0, 0, 0 } // 1111 - skip
945 };
946 int i, k, iRes;
947 unsigned uTruthRes;
948 assert( Phase >= 0 && Phase < 16 );
949 if ( Cases[Phase] == 0 )
950 return uTruth;
951 if ( Cases[Phase] > 1 )
952 return Cases[Phase];
953 uTruthRes = 0;
954 for ( i = 0; i < 16; i++ )
955 if ( uTruth & (1 << i) )
956 {
957 for ( iRes = 0, k = 0; k < 4; k++ )
958 if ( i & (1 << Perms[Phase][k]) )
959 iRes |= (1 << k);
960 uTruthRes |= (1 << iRes);
961 }
962 return uTruthRes;
963}
Here is the caller graph for this function:

◆ Extra_TruthPerm53()

unsigned ** Extra_TruthPerm53 ( )
extern

Function*************************************************************

Synopsis [Allocated lookup table for truth table permutation.]

Description []

SideEffects []

SeeAlso []

Definition at line 1935 of file extraUtilMisc.c.

1936{
1937 unsigned ** pTable;
1938 unsigned uTruth;
1939 int i, k;
1940 pTable = (unsigned **)Extra_ArrayAlloc( 256, 32, 4 );
1941 for ( i = 0; i < 256; i++ )
1942 {
1943 uTruth = (i << 24) | (i << 16) | (i << 8) | i;
1944 for ( k = 0; k < 32; k++ )
1945 pTable[i][k] = Extra_TruthPerm5One( uTruth, k );
1946 }
1947 return pTable;
1948}
unsigned Extra_TruthPerm5One(unsigned uTruth, int Phase)
Here is the call graph for this function:

◆ Extra_TruthPerm54()

unsigned ** Extra_TruthPerm54 ( )
extern

Function*************************************************************

Synopsis [Allocated lookup table for truth table permutation.]

Description []

SideEffects []

SeeAlso []

Definition at line 1961 of file extraUtilMisc.c.

1962{
1963 unsigned ** pTable;
1964 unsigned uTruth;
1965 int i;
1966 pTable = (unsigned **)Extra_ArrayAlloc( 256*256, 4, 4 );
1967 for ( i = 0; i < 256*256; i++ )
1968 {
1969 uTruth = (i << 16) | i;
1970 pTable[i][0] = Extra_TruthPerm5One( uTruth, 31-8 );
1971 pTable[i][1] = Extra_TruthPerm5One( uTruth, 31-4 );
1972 pTable[i][2] = Extra_TruthPerm5One( uTruth, 31-2 );
1973 pTable[i][3] = Extra_TruthPerm5One( uTruth, 31-1 );
1974 }
1975 return pTable;
1976}
Here is the call graph for this function:

◆ Extra_TruthPerm5One()

unsigned Extra_TruthPerm5One ( unsigned uTruth,
int Phase )
extern

Function*************************************************************

Synopsis [Computes a phase of the 3-var function.]

Description []

SideEffects []

SeeAlso []

Definition at line 976 of file extraUtilMisc.c.

977{
978 // cases
979 static unsigned Cases[32] = {
980 0, // 00000 - skip
981 0, // 00001 - skip
982 0xCCCCCCCC, // 00010 - single var
983 0, // 00011 - skip
984 0xF0F0F0F0, // 00100 - single var
985 1, // 00101
986 1, // 00110
987 0, // 00111 - skip
988 0xFF00FF00, // 01000 - single var
989 1, // 01001
990 1, // 01010
991 1, // 01011
992 1, // 01100
993 1, // 01101
994 1, // 01110
995 0, // 01111 - skip
996 0xFFFF0000, // 10000 - skip
997 1, // 10001
998 1, // 10010
999 1, // 10011
1000 1, // 10100
1001 1, // 10101
1002 1, // 10110
1003 1, // 10111 - four var
1004 1, // 11000
1005 1, // 11001
1006 1, // 11010
1007 1, // 11011 - four var
1008 1, // 11100
1009 1, // 11101 - four var
1010 1, // 11110 - four var
1011 0 // 11111 - skip
1012 };
1013 // permutations
1014 static int Perms[32][5] = {
1015 { 0, 0, 0, 0, 0 }, // 00000 - skip
1016 { 0, 0, 0, 0, 0 }, // 00001 - skip
1017 { 0, 0, 0, 0, 0 }, // 00010 - single var
1018 { 0, 0, 0, 0, 0 }, // 00011 - skip
1019 { 0, 0, 0, 0, 0 }, // 00100 - single var
1020 { 0, 2, 1, 3, 4 }, // 00101
1021 { 2, 0, 1, 3, 4 }, // 00110
1022 { 0, 0, 0, 0, 0 }, // 00111 - skip
1023 { 0, 0, 0, 0, 0 }, // 01000 - single var
1024 { 0, 2, 3, 1, 4 }, // 01001
1025 { 2, 0, 3, 1, 4 }, // 01010
1026 { 0, 1, 3, 2, 4 }, // 01011
1027 { 2, 3, 0, 1, 4 }, // 01100
1028 { 0, 3, 1, 2, 4 }, // 01101
1029 { 3, 0, 1, 2, 4 }, // 01110
1030 { 0, 0, 0, 0, 0 }, // 01111 - skip
1031 { 0, 0, 0, 0, 0 }, // 10000 - single var
1032 { 0, 4, 2, 3, 1 }, // 10001
1033 { 4, 0, 2, 3, 1 }, // 10010
1034 { 0, 1, 3, 4, 2 }, // 10011
1035 { 2, 3, 0, 4, 1 }, // 10100
1036 { 0, 3, 1, 4, 2 }, // 10101
1037 { 3, 0, 1, 4, 2 }, // 10110
1038 { 0, 1, 2, 4, 3 }, // 10111 - four var
1039 { 2, 3, 4, 0, 1 }, // 11000
1040 { 0, 3, 4, 1, 2 }, // 11001
1041 { 3, 0, 4, 1, 2 }, // 11010
1042 { 0, 1, 4, 2, 3 }, // 11011 - four var
1043 { 3, 4, 0, 1, 2 }, // 11100
1044 { 0, 4, 1, 2, 3 }, // 11101 - four var
1045 { 4, 0, 1, 2, 3 }, // 11110 - four var
1046 { 0, 0, 0, 0, 0 } // 11111 - skip
1047 };
1048 int i, k, iRes;
1049 unsigned uTruthRes;
1050 assert( Phase >= 0 && Phase < 32 );
1051 if ( Cases[Phase] == 0 )
1052 return uTruth;
1053 if ( Cases[Phase] > 1 )
1054 return Cases[Phase];
1055 uTruthRes = 0;
1056 for ( i = 0; i < 32; i++ )
1057 if ( uTruth & (1 << i) )
1058 {
1059 for ( iRes = 0, k = 0; k < 5; k++ )
1060 if ( i & (1 << Perms[Phase][k]) )
1061 iRes |= (1 << k);
1062 uTruthRes |= (1 << iRes);
1063 }
1064 return uTruthRes;
1065}
Here is the caller graph for this function:

◆ Extra_TruthPerm6One()

void Extra_TruthPerm6One ( unsigned * uTruth,
int Phase,
unsigned * uTruthRes )
extern

Function*************************************************************

Synopsis [Computes a phase of the 3-var function.]

Description []

SideEffects []

SeeAlso []

Definition at line 1078 of file extraUtilMisc.c.

1079{
1080 // cases
1081 static unsigned Cases[64] = {
1082 0, // 000000 - skip
1083 0, // 000001 - skip
1084 0xCCCCCCCC, // 000010 - single var
1085 0, // 000011 - skip
1086 0xF0F0F0F0, // 000100 - single var
1087 1, // 000101
1088 1, // 000110
1089 0, // 000111 - skip
1090 0xFF00FF00, // 001000 - single var
1091 1, // 001001
1092 1, // 001010
1093 1, // 001011
1094 1, // 001100
1095 1, // 001101
1096 1, // 001110
1097 0, // 001111 - skip
1098 0xFFFF0000, // 010000 - skip
1099 1, // 010001
1100 1, // 010010
1101 1, // 010011
1102 1, // 010100
1103 1, // 010101
1104 1, // 010110
1105 1, // 010111 - four var
1106 1, // 011000
1107 1, // 011001
1108 1, // 011010
1109 1, // 011011 - four var
1110 1, // 011100
1111 1, // 011101 - four var
1112 1, // 011110 - four var
1113 0, // 011111 - skip
1114 0xFFFFFFFF, // 100000 - single var
1115 1, // 100001
1116 1, // 100010
1117 1, // 100011
1118 1, // 100100
1119 1, // 100101
1120 1, // 100110
1121 1, // 100111
1122 1, // 101000
1123 1, // 101001
1124 1, // 101010
1125 1, // 101011
1126 1, // 101100
1127 1, // 101101
1128 1, // 101110
1129 1, // 101111
1130 1, // 110000
1131 1, // 110001
1132 1, // 110010
1133 1, // 110011
1134 1, // 110100
1135 1, // 110101
1136 1, // 110110
1137 1, // 110111
1138 1, // 111000
1139 1, // 111001
1140 1, // 111010
1141 1, // 111011
1142 1, // 111100
1143 1, // 111101
1144 1, // 111110
1145 0 // 111111 - skip
1146 };
1147 // permutations
1148 static int Perms[64][6] = {
1149 { 0, 0, 0, 0, 0, 0 }, // 000000 - skip
1150 { 0, 0, 0, 0, 0, 0 }, // 000001 - skip
1151 { 0, 0, 0, 0, 0, 0 }, // 000010 - single var
1152 { 0, 0, 0, 0, 0, 0 }, // 000011 - skip
1153 { 0, 0, 0, 0, 0, 0 }, // 000100 - single var
1154 { 0, 2, 1, 3, 4, 5 }, // 000101
1155 { 2, 0, 1, 3, 4, 5 }, // 000110
1156 { 0, 0, 0, 0, 0, 0 }, // 000111 - skip
1157 { 0, 0, 0, 0, 0, 0 }, // 001000 - single var
1158 { 0, 2, 3, 1, 4, 5 }, // 001001
1159 { 2, 0, 3, 1, 4, 5 }, // 001010
1160 { 0, 1, 3, 2, 4, 5 }, // 001011
1161 { 2, 3, 0, 1, 4, 5 }, // 001100
1162 { 0, 3, 1, 2, 4, 5 }, // 001101
1163 { 3, 0, 1, 2, 4, 5 }, // 001110
1164 { 0, 0, 0, 0, 0, 0 }, // 001111 - skip
1165 { 0, 0, 0, 0, 0, 0 }, // 010000 - skip
1166 { 0, 4, 2, 3, 1, 5 }, // 010001
1167 { 4, 0, 2, 3, 1, 5 }, // 010010
1168 { 0, 1, 3, 4, 2, 5 }, // 010011
1169 { 2, 3, 0, 4, 1, 5 }, // 010100
1170 { 0, 3, 1, 4, 2, 5 }, // 010101
1171 { 3, 0, 1, 4, 2, 5 }, // 010110
1172 { 0, 1, 2, 4, 3, 5 }, // 010111 - four var
1173 { 2, 3, 4, 0, 1, 5 }, // 011000
1174 { 0, 3, 4, 1, 2, 5 }, // 011001
1175 { 3, 0, 4, 1, 2, 5 }, // 011010
1176 { 0, 1, 4, 2, 3, 5 }, // 011011 - four var
1177 { 3, 4, 0, 1, 2, 5 }, // 011100
1178 { 0, 4, 1, 2, 3, 5 }, // 011101 - four var
1179 { 4, 0, 1, 2, 3, 5 }, // 011110 - four var
1180 { 0, 0, 0, 0, 0, 0 }, // 011111 - skip
1181 { 0, 0, 0, 0, 0, 0 }, // 100000 - single var
1182 { 0, 2, 3, 4, 5, 1 }, // 100001
1183 { 2, 0, 3, 4, 5, 1 }, // 100010
1184 { 0, 1, 3, 4, 5, 2 }, // 100011
1185 { 2, 3, 0, 4, 5, 1 }, // 100100
1186 { 0, 3, 1, 4, 5, 2 }, // 100101
1187 { 3, 0, 1, 4, 5, 2 }, // 100110
1188 { 0, 1, 2, 4, 5, 3 }, // 100111
1189 { 2, 3, 4, 0, 5, 1 }, // 101000
1190 { 0, 3, 4, 1, 5, 2 }, // 101001
1191 { 3, 0, 4, 1, 5, 2 }, // 101010
1192 { 0, 1, 4, 2, 5, 3 }, // 101011
1193 { 3, 4, 0, 1, 5, 2 }, // 101100
1194 { 0, 4, 1, 2, 5, 3 }, // 101101
1195 { 4, 0, 1, 2, 5, 3 }, // 101110
1196 { 0, 1, 2, 3, 5, 4 }, // 101111
1197 { 2, 3, 4, 5, 0, 1 }, // 110000
1198 { 0, 3, 4, 5, 1, 2 }, // 110001
1199 { 3, 0, 4, 5, 1, 2 }, // 110010
1200 { 0, 1, 4, 5, 2, 3 }, // 110011
1201 { 3, 4, 0, 5, 1, 2 }, // 110100
1202 { 0, 4, 1, 5, 2, 3 }, // 110101
1203 { 4, 0, 1, 5, 2, 3 }, // 110110
1204 { 0, 1, 2, 5, 3, 4 }, // 110111
1205 { 3, 4, 5, 0, 1, 2 }, // 111000
1206 { 0, 4, 5, 1, 2, 3 }, // 111001
1207 { 4, 0, 5, 1, 2, 3 }, // 111010
1208 { 0, 1, 5, 2, 3, 4 }, // 111011
1209 { 4, 5, 0, 1, 2, 3 }, // 111100
1210 { 0, 5, 1, 2, 3, 4 }, // 111101
1211 { 5, 0, 1, 2, 3, 4 }, // 111110
1212 { 0, 0, 0, 0, 0, 0 } // 111111 - skip
1213 };
1214 int i, k, iRes;
1215 assert( Phase >= 0 && Phase < 64 );
1216 if ( Cases[Phase] == 0 )
1217 {
1218 uTruthRes[0] = uTruth[0];
1219 uTruthRes[1] = uTruth[1];
1220 return;
1221 }
1222 if ( Cases[Phase] > 1 )
1223 {
1224 if ( Phase == 32 )
1225 {
1226 uTruthRes[0] = 0x00000000;
1227 uTruthRes[1] = 0xFFFFFFFF;
1228 }
1229 else
1230 {
1231 uTruthRes[0] = Cases[Phase];
1232 uTruthRes[1] = Cases[Phase];
1233 }
1234 return;
1235 }
1236 uTruthRes[0] = 0;
1237 uTruthRes[1] = 0;
1238 for ( i = 0; i < 64; i++ )
1239 {
1240 if ( i < 32 )
1241 {
1242 if ( uTruth[0] & (1 << i) )
1243 {
1244 for ( iRes = 0, k = 0; k < 6; k++ )
1245 if ( i & (1 << Perms[Phase][k]) )
1246 iRes |= (1 << k);
1247 if ( iRes < 32 )
1248 uTruthRes[0] |= (1 << iRes);
1249 else
1250 uTruthRes[1] |= (1 << (iRes-32));
1251 }
1252 }
1253 else
1254 {
1255 if ( uTruth[1] & (1 << (i-32)) )
1256 {
1257 for ( iRes = 0, k = 0; k < 6; k++ )
1258 if ( i & (1 << Perms[Phase][k]) )
1259 iRes |= (1 << k);
1260 if ( iRes < 32 )
1261 uTruthRes[0] |= (1 << iRes);
1262 else
1263 uTruthRes[1] |= (1 << (iRes-32));
1264 }
1265 }
1266 }
1267}
Here is the caller graph for this function:

◆ Extra_TruthPermute()

unsigned Extra_TruthPermute ( unsigned Truth,
char * pPerms,
int nVars,
int fReverse )

Function*************************************************************

Synopsis [Permutes the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 353 of file extraUtilMisc.c.

354{
355 unsigned Result;
356 int * pMints;
357 int * pMintsP;
358 int nMints;
359 int i, m;
360
361 assert( nVars < 6 );
362 nMints = (1 << nVars);
363 pMints = ABC_ALLOC( int, nMints );
364 pMintsP = ABC_ALLOC( int, nMints );
365 for ( i = 0; i < nMints; i++ )
366 pMints[i] = i;
367
368 Extra_TruthPermute_int( pMints, nMints, pPerms, nVars, pMintsP );
369
370 Result = 0;
371 if ( fReverse )
372 {
373 for ( m = 0; m < nMints; m++ )
374 if ( Truth & (1 << pMintsP[m]) )
375 Result |= (1 << m);
376 }
377 else
378 {
379 for ( m = 0; m < nMints; m++ )
380 if ( Truth & (1 << m) )
381 Result |= (1 << pMintsP[m]);
382 }
383
384 ABC_FREE( pMints );
385 ABC_FREE( pMintsP );
386
387 return Result;
388}
void Extra_TruthPermute_int(int *pMints, int nMints, char *pPerm, int nVars, int *pMintsP)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthPolarize()

unsigned Extra_TruthPolarize ( unsigned uTruth,
int Polarity,
int nVars )

Function*************************************************************

Synopsis [Changes the phase of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 401 of file extraUtilMisc.c.

402{
403 // elementary truth tables
404 static unsigned Signs[5] = {
405 0xAAAAAAAA, // 1010 1010 1010 1010 1010 1010 1010 1010
406 0xCCCCCCCC, // 1010 1010 1010 1010 1010 1010 1010 1010
407 0xF0F0F0F0, // 1111 0000 1111 0000 1111 0000 1111 0000
408 0xFF00FF00, // 1111 1111 0000 0000 1111 1111 0000 0000
409 0xFFFF0000 // 1111 1111 1111 1111 0000 0000 0000 0000
410 };
411 unsigned uTruthRes, uCof0, uCof1;
412 int nMints, Shift, v;
413 assert( nVars < 6 );
414 nMints = (1 << nVars);
415 uTruthRes = uTruth;
416 for ( v = 0; v < nVars; v++ )
417 if ( Polarity & (1 << v) )
418 {
419 uCof0 = uTruth & ~Signs[v];
420 uCof1 = uTruth & Signs[v];
421 Shift = (1 << v);
422 uCof0 <<= Shift;
423 uCof1 >>= Shift;
424 uTruth = uCof0 | uCof1;
425 }
426 return uTruth;
427}
Here is the caller graph for this function:

◆ Extra_TruthSemiCanonicize()

unsigned Extra_TruthSemiCanonicize ( unsigned * pInOut,
unsigned * pAux,
int nVars,
char * pCanonPerm,
short * pStore )
extern

Function*************************************************************

Synopsis [Canonicize the truth table.]

Description [Returns the phase. ]

SideEffects []

SeeAlso []

Definition at line 999 of file extraUtilTruth.c.

1000{
1001 unsigned * pIn = pInOut, * pOut = pAux, * pTemp;
1002 int nWords = Extra_TruthWordNum( nVars );
1003 int i, Temp, fChange, Counter, nOnes;//, k, j, w, Limit;
1004 unsigned uCanonPhase;
1005
1006 // canonicize output
1007 uCanonPhase = 0;
1008 nOnes = Extra_TruthCountOnes(pIn, nVars);
1009 if ( (nOnes > nWords * 16) || ((nOnes == nWords * 16) && (pIn[0] & 1)) )
1010 {
1011 uCanonPhase |= (1 << nVars);
1012 Extra_TruthNot( pIn, pIn, nVars );
1013 }
1014
1015 // collect the minterm counts
1016 Extra_TruthCountOnesInCofs( pIn, nVars, pStore );
1017
1018 // canonicize phase
1019 for ( i = 0; i < nVars; i++ )
1020 {
1021 if ( pStore[2*i+0] <= pStore[2*i+1] )
1022 continue;
1023 uCanonPhase |= (1 << i);
1024 Temp = pStore[2*i+0];
1025 pStore[2*i+0] = pStore[2*i+1];
1026 pStore[2*i+1] = Temp;
1027 Extra_TruthChangePhase( pIn, nVars, i );
1028 }
1029
1030// Extra_PrintHexadecimal( stdout, pIn, nVars );
1031// printf( "\n" );
1032
1033 // permute
1034 Counter = 0;
1035 do {
1036 fChange = 0;
1037 for ( i = 0; i < nVars-1; i++ )
1038 {
1039 if ( pStore[2*i] <= pStore[2*(i+1)] )
1040 continue;
1041 Counter++;
1042 fChange = 1;
1043
1044 Temp = pCanonPerm[i];
1045 pCanonPerm[i] = pCanonPerm[i+1];
1046 pCanonPerm[i+1] = Temp;
1047
1048 Temp = pStore[2*i];
1049 pStore[2*i] = pStore[2*(i+1)];
1050 pStore[2*(i+1)] = Temp;
1051
1052 Temp = pStore[2*i+1];
1053 pStore[2*i+1] = pStore[2*(i+1)+1];
1054 pStore[2*(i+1)+1] = Temp;
1055
1056 Extra_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
1057 pTemp = pIn; pIn = pOut; pOut = pTemp;
1058 }
1059 } while ( fChange );
1060
1061/*
1062 Extra_PrintBinary( stdout, &uCanonPhase, nVars+1 ); printf( " : " );
1063 for ( i = 0; i < nVars; i++ )
1064 printf( "%d=%d/%d ", pCanonPerm[i], pStore[2*i], pStore[2*i+1] );
1065 printf( " C = %d\n", Counter );
1066 Extra_PrintHexadecimal( stdout, pIn, nVars );
1067 printf( "\n" );
1068*/
1069
1070/*
1071 // process symmetric variable groups
1072 uSymms = 0;
1073 for ( i = 0; i < nVars-1; i++ )
1074 {
1075 if ( pStore[2*i] != pStore[2*(i+1)] ) // i and i+1 cannot be symmetric
1076 continue;
1077 if ( pStore[2*i] != pStore[2*i+1] )
1078 continue;
1079 if ( Extra_TruthVarsSymm( pIn, nVars, i, i+1 ) )
1080 continue;
1081 if ( Extra_TruthVarsAntiSymm( pIn, nVars, i, i+1 ) )
1082 Extra_TruthChangePhase( pIn, nVars, i+1 );
1083 }
1084*/
1085
1086/*
1087 // process symmetric variable groups
1088 uSymms = 0;
1089 for ( i = 0; i < nVars-1; i++ )
1090 {
1091 if ( pStore[2*i] != pStore[2*(i+1)] ) // i and i+1 cannot be symmetric
1092 continue;
1093 // i and i+1 can be symmetric
1094 // find the end of this group
1095 for ( k = i+1; k < nVars; k++ )
1096 if ( pStore[2*i] != pStore[2*k] )
1097 break;
1098 Limit = k;
1099 assert( i < Limit-1 );
1100 // go through the variables in this group
1101 for ( j = i + 1; j < Limit; j++ )
1102 {
1103 // check symmetry
1104 if ( Extra_TruthVarsSymm( pIn, nVars, i, j ) )
1105 {
1106 uSymms |= (1 << j);
1107 continue;
1108 }
1109 // they are phase-unknown
1110 if ( pStore[2*i] == pStore[2*i+1] )
1111 {
1112 if ( Extra_TruthVarsAntiSymm( pIn, nVars, i, j ) )
1113 {
1114 Extra_TruthChangePhase( pIn, nVars, j );
1115 uCanonPhase ^= (1 << j);
1116 uSymms |= (1 << j);
1117 continue;
1118 }
1119 }
1120
1121 // they are not symmetric - move j as far as it goes in the group
1122 for ( k = j; k < Limit-1; k++ )
1123 {
1124 Counter++;
1125
1126 Temp = pCanonPerm[k];
1127 pCanonPerm[k] = pCanonPerm[k+1];
1128 pCanonPerm[k+1] = Temp;
1129
1130 assert( pStore[2*k] == pStore[2*(k+1)] );
1131 Extra_TruthSwapAdjacentVars( pOut, pIn, nVars, k );
1132 pTemp = pIn; pIn = pOut; pOut = pTemp;
1133 }
1134 Limit--;
1135 j--;
1136 }
1137 i = Limit - 1;
1138 }
1139*/
1140
1141 // swap if it was moved an even number of times
1142 if ( Counter & 1 )
1143 Extra_TruthCopy( pOut, pIn, nVars );
1144 return uCanonPhase;
1145}
void Extra_TruthCountOnesInCofs(unsigned *pTruth, int nVars, short *pStore)
void Extra_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
void Extra_TruthChangePhase(unsigned *pTruth, int nVars, int iVar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthShrink()

void Extra_TruthShrink ( unsigned * pOut,
unsigned * pIn,
int nVars,
int nVarsAll,
unsigned Phase )
extern

Function*************************************************************

Synopsis [Shrinks the truth table according to the phase.]

Description [The input and output truth tables are in pIn/pOut. The current number of variables is nVars. The total number of variables in nVarsAll. The last argument (Phase) contains shows what variables should remain.]

SideEffects []

SeeAlso []

Definition at line 268 of file extraUtilTruth.c.

269{
270 unsigned * pTemp;
271 int i, k, Var = 0, Counter = 0;
272 for ( i = 0; i < nVarsAll; i++ )
273 if ( Phase & (1 << i) )
274 {
275 for ( k = i-1; k >= Var; k-- )
276 {
277 Extra_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
278 pTemp = pIn; pIn = pOut; pOut = pTemp;
279 Counter++;
280 }
281 Var++;
282 }
283 assert( Var == nVars );
284 // swap if it was moved an even number of times
285 if ( !(Counter & 1) )
286 Extra_TruthCopy( pOut, pIn, nVarsAll );
287}
int Var
Definition exorList.c:228
Here is the call graph for this function:

◆ Extra_TruthStretch()

void Extra_TruthStretch ( unsigned * pOut,
unsigned * pIn,
int nVars,
int nVarsAll,
unsigned Phase )
extern

Function*************************************************************

Synopsis [Expands the truth table according to the phase.]

Description [The input and output truth tables are in pIn/pOut. The current number of variables is nVars. The total number of variables in nVarsAll. The last argument (Phase) contains shows where the variables should go.]

SideEffects []

SeeAlso []

Definition at line 234 of file extraUtilTruth.c.

235{
236 unsigned * pTemp;
237 int i, k, Var = nVars - 1, Counter = 0;
238 for ( i = nVarsAll - 1; i >= 0; i-- )
239 if ( Phase & (1 << i) )
240 {
241 for ( k = Var; k < i; k++ )
242 {
243 Extra_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
244 pTemp = pIn; pIn = pOut; pOut = pTemp;
245 Counter++;
246 }
247 Var--;
248 }
249 assert( Var == -1 );
250 // swap if it was moved an even number of times
251 if ( !(Counter & 1) )
252 Extra_TruthCopy( pOut, pIn, nVarsAll );
253}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthSupport()

int Extra_TruthSupport ( unsigned * pTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Returns support of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 377 of file extraUtilTruth.c.

378{
379 int i, Support = 0;
380 for ( i = 0; i < nVars; i++ )
381 if ( Extra_TruthVarInSupport( pTruth, nVars, i ) )
382 Support |= (1 << i);
383 return Support;
384}
int Extra_TruthVarInSupport(unsigned *pTruth, int nVars, int iVar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthSupportSize()

int Extra_TruthSupportSize ( unsigned * pTruth,
int nVars )
extern

Function*************************************************************

Synopsis [Returns the number of support vars.]

Description []

SideEffects []

SeeAlso []

Definition at line 358 of file extraUtilTruth.c.

359{
360 int i, Counter = 0;
361 for ( i = 0; i < nVars; i++ )
362 Counter += Extra_TruthVarInSupport( pTruth, nVars, i );
363 return Counter;
364}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TruthSwapAdjacentVars()

void Extra_TruthSwapAdjacentVars ( unsigned * pOut,
unsigned * pIn,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Swaps two adjacent variables in the truth table.]

Description [Swaps var number Start and var number Start+1 (0-based numbers). The input truth table is pIn. The output truth table is pOut.]

SideEffects []

SeeAlso []

Definition at line 114 of file extraUtilTruth.c.

115{
116 static unsigned PMasks[4][3] = {
117 { 0x99999999, 0x22222222, 0x44444444 },
118 { 0xC3C3C3C3, 0x0C0C0C0C, 0x30303030 },
119 { 0xF00FF00F, 0x00F000F0, 0x0F000F00 },
120 { 0xFF0000FF, 0x0000FF00, 0x00FF0000 }
121 };
122 int nWords = Extra_TruthWordNum( nVars );
123 int i, k, Step, Shift;
124
125 assert( iVar < nVars - 1 );
126 if ( iVar < 4 )
127 {
128 Shift = (1 << iVar);
129 for ( i = 0; i < nWords; i++ )
130 pOut[i] = (pIn[i] & PMasks[iVar][0]) | ((pIn[i] & PMasks[iVar][1]) << Shift) | ((pIn[i] & PMasks[iVar][2]) >> Shift);
131 }
132 else if ( iVar > 4 )
133 {
134 Step = (1 << (iVar - 5));
135 for ( k = 0; k < nWords; k += 4*Step )
136 {
137 for ( i = 0; i < Step; i++ )
138 pOut[i] = pIn[i];
139 for ( i = 0; i < Step; i++ )
140 pOut[Step+i] = pIn[2*Step+i];
141 for ( i = 0; i < Step; i++ )
142 pOut[2*Step+i] = pIn[Step+i];
143 for ( i = 0; i < Step; i++ )
144 pOut[3*Step+i] = pIn[3*Step+i];
145 pIn += 4*Step;
146 pOut += 4*Step;
147 }
148 }
149 else // if ( iVar == 4 )
150 {
151 for ( i = 0; i < nWords; i += 2 )
152 {
153 pOut[i] = (pIn[i] & 0x0000FFFF) | ((pIn[i+1] & 0x0000FFFF) << 16);
154 pOut[i+1] = (pIn[i+1] & 0xFFFF0000) | ((pIn[i] & 0xFFFF0000) >> 16);
155 }
156 }
157}
Here is the caller graph for this function:

◆ Extra_TruthVarInSupport()

int Extra_TruthVarInSupport ( unsigned * pTruth,
int nVars,
int iVar )
extern

Function*************************************************************

Synopsis [Returns 1 if TT depends on the given variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 301 of file extraUtilTruth.c.

302{
303 int nWords = Extra_TruthWordNum( nVars );
304 int i, k, Step;
305
306 assert( iVar < nVars );
307 switch ( iVar )
308 {
309 case 0:
310 for ( i = 0; i < nWords; i++ )
311 if ( (pTruth[i] & 0x55555555) != ((pTruth[i] & 0xAAAAAAAA) >> 1) )
312 return 1;
313 return 0;
314 case 1:
315 for ( i = 0; i < nWords; i++ )
316 if ( (pTruth[i] & 0x33333333) != ((pTruth[i] & 0xCCCCCCCC) >> 2) )
317 return 1;
318 return 0;
319 case 2:
320 for ( i = 0; i < nWords; i++ )
321 if ( (pTruth[i] & 0x0F0F0F0F) != ((pTruth[i] & 0xF0F0F0F0) >> 4) )
322 return 1;
323 return 0;
324 case 3:
325 for ( i = 0; i < nWords; i++ )
326 if ( (pTruth[i] & 0x00FF00FF) != ((pTruth[i] & 0xFF00FF00) >> 8) )
327 return 1;
328 return 0;
329 case 4:
330 for ( i = 0; i < nWords; i++ )
331 if ( (pTruth[i] & 0x0000FFFF) != ((pTruth[i] & 0xFFFF0000) >> 16) )
332 return 1;
333 return 0;
334 default:
335 Step = (1 << (iVar - 5));
336 for ( k = 0; k < nWords; k += 2*Step )
337 {
338 for ( i = 0; i < Step; i++ )
339 if ( pTruth[i] != pTruth[Step+i] )
340 return 1;
341 pTruth += 2*Step;
342 }
343 return 0;
344 }
345}
Here is the caller graph for this function:

◆ Extra_UtilFileSearch()

char * Extra_UtilFileSearch ( char * file,
char * path,
char * mode )
extern

Function*************************************************************

Synopsis [util_file_search()]

Description []

SideEffects []

SeeAlso []

Definition at line 269 of file extraUtilUtil.c.

273{
274 int quit;
275 char *buffer, *filename, *save_path, *cp;
276
277 if (path == 0 || strcmp(path, "") == 0) {
278 path = "."; /* just look in the current directory */
279 }
280
281 save_path = path = Extra_UtilStrsav(path);
282 quit = 0;
283 for (;;) {
284 cp = strchr(path, ':');
285 if (cp != 0) {
286 *cp = '\0';
287 } else {
288 quit = 1;
289 }
290
291 /* cons up the filename out of the path and file name */
292 if (strcmp(path, ".") == 0) {
293 buffer = Extra_UtilStrsav(file);
294 } else {
295 buffer = ABC_ALLOC(char, strlen(path) + strlen(file) + 4);
296 (void) sprintf(buffer, "%s/%s", path, file);
297 }
299 ABC_FREE(buffer);
300
301 /* see if we can access it */
303 ABC_FREE(save_path);
304 return filename;
305 }
307 if (quit) {
308 break;
309 } else {
310 path = ++cp;
311 }
312 }
313
314 ABC_FREE(save_path);
315 return 0;
316}
char * filename
Definition globals.c:40
char * Extra_UtilStrsav(const char *s)
char * Extra_UtilTildeExpand(char *fname)
int Extra_UtilCheckFile(char *filename, const char *mode)
Definition file.h:23
Definition mode.h:11
int strcmp()
char * strchr()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_UtilGetopt()

int Extra_UtilGetopt ( int argc,
char * argv[],
const char * optstring )
extern

Function*************************************************************

Synopsis [util_getopt()]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file extraUtilUtil.c.

99{
100 int c;
101 const char *place;
102
103 globalUtilOptarg = NULL;
104
105 if (pScanStr == NULL || *pScanStr == '\0')
106 {
107 if (globalUtilOptind == 0)
109 if (globalUtilOptind >= argc)
110 return EOF;
111 place = argv[globalUtilOptind];
112 if (place[0] != '-' || place[1] == '\0')
113 return EOF;
115 if (place[1] == '-' && place[2] == '\0')
116 return EOF;
117 pScanStr = place+1;
118 }
119
120 c = *pScanStr++;
121 place = strchr(optstring, c);
122 if (place == NULL || c == ':') {
123 (void) fprintf(stderr, "%s: unknown option %c\n", argv[0], c);
124 return '?';
125 }
126 if (*++place == ':')
127 {
128 if (*pScanStr != '\0')
129 {
130 globalUtilOptarg = pScanStr;
131 pScanStr = NULL;
132 }
133 else
134 {
135 if (globalUtilOptind >= argc)
136 {
137 (void) fprintf(stderr, "%s: %c requires an argument\n",
138 argv[0], c);
139 return '?';
140 }
143 }
144 }
145 return c;
146}
int globalUtilOptind
const char * globalUtilOptarg
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_UtilGetoptReset()

ABC_DLL void Extra_UtilGetoptReset ( )
extern

Function*************************************************************

Synopsis [util_getopt_reset()]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file extraUtilUtil.c.

81{
84 pScanStr = 0;
85}
Here is the caller graph for this function:

◆ Extra_UtilPrintTime()

char * Extra_UtilPrintTime ( long t)
extern

Function*************************************************************

Synopsis [util_print_time()]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file extraUtilUtil.c.

160{
161 static char s[40];
162
163 (void) sprintf(s, "%ld.%02ld sec", t/1000, (t%1000)/10);
164 return s;
165}
Here is the call graph for this function:

◆ Extra_UtilStrsav()

char * Extra_UtilStrsav ( const char * s)
extern

Function*************************************************************

Synopsis [Extra_UtilStrsav()]

Description []

SideEffects []

SeeAlso []

Definition at line 179 of file extraUtilUtil.c.

180{
181 if(s == NULL) { /* added 7/95, for robustness */
182 return NULL;
183 }
184 else {
185 return strcpy(ABC_ALLOC(char, strlen(s)+1), s);
186 }
187}
Here is the call graph for this function:

◆ Extra_UtilTildeExpand()

char * Extra_UtilTildeExpand ( char * fname)
extern

Function*************************************************************

Synopsis [util_tilde_expand()]

Description [The code contributed by Niklas Sorensson.]

SideEffects []

SeeAlso []

Definition at line 200 of file extraUtilUtil.c.

201{
202 return Extra_UtilStrsav( fname );
203/*
204 int n_tildes = 0;
205 const char* home;
206 char* expanded;
207 int length;
208 int i, j, k;
209
210 for (i = 0; i < (int)strlen(fname); i++)
211 if (fname[i] == '~') n_tildes++;
212
213 home = getenv("HOME");
214 length = n_tildes * strlen(home) + strlen(fname);
215 expanded = ABC_ALLOC(char, length + 1);
216
217 j = 0;
218 for (i = 0; i < (int)strlen(fname); i++){
219 if (fname[i] == '~'){
220 for (k = 0; k < (int)strlen(home); k++)
221 expanded[j++] = home[k];
222 }else
223 expanded[j++] = fname[i];
224 }
225
226 expanded[j] = '\0';
227 return expanded;
228*/
229}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sdm_ManCanRead()

int Sdm_ManCanRead ( )
extern

Definition at line 1080 of file extraUtilDsd.c.

1081{
1082 char * pFileName = "dsdfuncs6.dat";
1083 FILE * pFile = fopen( pFileName, "rb" );
1084 if ( pFile == NULL )
1085 return 0;
1086 fclose( pFile );
1087 return 1;
1088}

◆ Sdm_ManComputeFunc()

int Sdm_ManComputeFunc ( Sdm_Man_t * p,
int iDsdLit0,
int iDsdLit1,
int * pCut,
int uMask,
int fXor )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 920 of file extraUtilDsd.c.

921{
922// int fVerbose = 0;
923 int i, Config, iClass, fCompl, Res;
924 int PermMask = uMask & 0x3FFFF;
925 int ComplMask = uMask >> 18;
926 word Truth0, Truth1p, t0, t1, t;
927 p->nAllDsd++;
928
929 assert( uMask > 1 );
930 assert( iDsdLit0 < DSD_CLASS_NUM * 2 );
931 assert( iDsdLit1 < DSD_CLASS_NUM * 2 );
932 Truth0 = p->pDsd6[Abc_Lit2Var(iDsdLit0)].uTruth;
933 Truth1p = Vec_WrdEntry( p->vPerm6, Abc_Lit2Var(iDsdLit1) * 720 + Vec_IntEntry(p->vMap2Perm, PermMask ) );
934 if ( ComplMask )
935 for ( i = 0; i < 6; i++ )
936 if ( (ComplMask >> i) & 1 )
937 Truth1p = Abc_Tt6Flip( Truth1p, i );
938 t0 = Abc_LitIsCompl(iDsdLit0) ? ~Truth0 : Truth0;
939 t1 = Abc_LitIsCompl(iDsdLit1) ? ~Truth1p : Truth1p;
940 t = fXor ? t0 ^ t1 : t0 & t1;
941/*
942if ( fVerbose )
943{
944Sdm_ManPrintPerm( PermMask ); printf( "\n" );
945Extra_PrintBinary( stdout, &ComplMask, 6 ); printf( "\n" );
946Kit_DsdPrintFromTruth( (unsigned *)&Truth0, 6 ); printf( "\n" );
947Kit_DsdPrintFromTruth( (unsigned *)&Truth1p, 6 ); printf( "\n" );
948Kit_DsdPrintFromTruth( (unsigned *)&t, 6 ); printf( "\n" );
949}
950*/
951 // find configuration
952 Config = Sdm_ManCheckDsd6( p, t );
953 if ( Config == -1 )
954 {
955 p->nNonDsd++;
956 return -1;
957 }
958
959 // get the class
960 iClass = Config >> 17;
961 fCompl = (Config >> 16) & 1;
962 Config &= 0xFFFF;
963
964 // set the function
965 Res = Abc_Var2Lit( iClass, fCompl );
966
967 // update cut
968 assert( (Config >> 6) < 720 );
969 if ( pCut )
970 {
971 int pLeavesNew[6] = { -1, -1, -1, -1, -1, -1 };
972 assert( pCut[0] <= 6 );
973 for ( i = 0; i < pCut[0]; i++ )
974 pLeavesNew[(int)(p->Perm6[Config >> 6][i])] = Abc_LitNotCond( pCut[i+1], (Config >> i) & 1 );
975 pCut[0] = p->pDsd6[iClass].nVars;
976 for ( i = 0; i < pCut[0]; i++ )
977 assert( pLeavesNew[i] != -1 );
978 for ( i = 0; i < pCut[0]; i++ )
979 pCut[i+1] = pLeavesNew[i];
980 }
981 assert( iClass < DSD_CLASS_NUM );
982 p->nCountDsd[iClass]++;
983 return Res;
984}
#define DSD_CLASS_NUM
int Sdm_ManCheckDsd6(Sdm_Man_t *p, word t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sdm_ManPrintDsdStats()

void Sdm_ManPrintDsdStats ( Sdm_Man_t * p,
int fVerbose )
extern

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 676 of file extraUtilDsd.c.

677{
678 int i, Absent = 0;
679 for ( i = 0; i < DSD_CLASS_NUM; i++ )
680 {
681 if ( p->nCountDsd[i] == 0 )
682 {
683 Absent++;
684 continue;
685 }
686 if ( fVerbose )
687 {
688 printf( "%5d : ", i );
689 printf( "%-20s ", p->pDsd6[i].pStr );
690 printf( "%8d ", p->nCountDsd[i] );
691 printf( "\n" );
692 }
693 }
694 printf( "Unused classes = %d (%.2f %%). ", Absent, 100.0 * Absent / DSD_CLASS_NUM );
695 printf( "Non-DSD cuts = %d (%.2f %%). ", p->nNonDsd, 100.0 * p->nNonDsd / Abc_MaxInt(1, p->nAllDsd) );
696 printf( "\n" );
697}
Here is the caller graph for this function:

◆ Sdm_ManQuit()

void Sdm_ManQuit ( )
extern

Definition at line 1074 of file extraUtilDsd.c.

1075{
1076 if ( s_SdmMan != NULL )
1077 Sdm_ManFree( s_SdmMan );
1078 s_SdmMan = NULL;
1079}
void Sdm_ManFree(Sdm_Man_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sdm_ManRead()

Sdm_Man_t * Sdm_ManRead ( )
extern

Definition at line 1067 of file extraUtilDsd.c.

1068{
1069 if ( s_SdmMan == NULL )
1070 s_SdmMan = Sdm_ManAlloc();
1071 memset( s_SdmMan->nCountDsd, 0, sizeof(int) * DSD_CLASS_NUM );
1072 return s_SdmMan;
1073}
Sdm_Man_t * Sdm_ManAlloc()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sdm_ManReadCnfCosts()

void Sdm_ManReadCnfCosts ( Sdm_Man_t * p,
int * pCosts,
int nCosts )
extern

Definition at line 1017 of file extraUtilDsd.c.

1018{
1019 int i;
1020 assert( nCosts == DSD_CLASS_NUM );
1021 pCosts[0] = pCosts[1] = 0;
1022 for ( i = 2; i < DSD_CLASS_NUM; i++ )
1023 pCosts[i] = Sdm_ManReadDsdClauseNum( p, i );
1024}
int Sdm_ManReadDsdClauseNum(Sdm_Man_t *p, int iDsd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sdm_ManReadDsdAndNum()

int Sdm_ManReadDsdAndNum ( Sdm_Man_t * p,
int iDsd )
extern

Definition at line 1001 of file extraUtilDsd.c.

1002{
1003 return p->pDsd6[iDsd].nAnds;
1004}

◆ Sdm_ManReadDsdClauseNum()

int Sdm_ManReadDsdClauseNum ( Sdm_Man_t * p,
int iDsd )
extern

Definition at line 1005 of file extraUtilDsd.c.

1006{
1007 return p->pDsd6[iDsd].nClauses;
1008}
Here is the caller graph for this function:

◆ Sdm_ManReadDsdStr()

char * Sdm_ManReadDsdStr ( Sdm_Man_t * p,
int iDsd )
extern

Definition at line 1013 of file extraUtilDsd.c.

1014{
1015 return p->pDsd6[iDsd].pStr;
1016}
Here is the caller graph for this function:

◆ Sdm_ManReadDsdTruth()

word Sdm_ManReadDsdTruth ( Sdm_Man_t * p,
int iDsd )
extern

Definition at line 1009 of file extraUtilDsd.c.

1010{
1011 return p->pDsd6[iDsd].uTruth;
1012}
Here is the caller graph for this function:

◆ Sdm_ManReadDsdVarNum()

int Sdm_ManReadDsdVarNum ( Sdm_Man_t * p,
int iDsd )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 997 of file extraUtilDsd.c.

998{
999 return p->pDsd6[iDsd].nVars;
1000}
Here is the caller graph for this function:

Variable Documentation

◆ Extra_UtilMMoutOfMemory

void(* Extra_UtilMMoutOfMemory) (long size) ( long size)
extern

Function*************************************************************

Synopsis [MMoutOfMemory()]

Description []

SideEffects []

SeeAlso []

Definition at line 350 of file extraUtilUtil.c.

◆ globalUtilOptarg

const char* globalUtilOptarg
extern

Definition at line 44 of file extraUtilUtil.c.

◆ globalUtilOptind

int globalUtilOptind
extern

Definition at line 45 of file extraUtilUtil.c.

◆ uint8

ABC_NAMESPACE_HEADER_START typedef unsigned char uint8

CFile****************************************************************

FileName [extra.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [extra]

Synopsis [Various reusable software utilities.]

Description [This library contains a number of operators and traversal routines developed to extend the functionality of CUDD v.2.3.x, by Fabio Somenzi (http://vlsi.colorado.edu/~fabio/) To compile your code with the library, #include "extra.h" in your source files and link your project to CUDD and this library. Use the library at your own risk and with caution. Note that debugging of some operators still continues.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
extra.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 71 of file extra.h.