ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraigInt.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/util/abc_global.h"
#include "fraig.h"
#include "sat/msat/msat.h"
Include dependency graph for fraigInt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Fraig_ManStruct_t_
 
struct  Fraig_NodeStruct_t_
 
struct  Fraig_NodeVecStruct_t_
 
struct  Fraig_HashTableStruct_t_
 

Macros

#define FRAIG_ENABLE_FANOUTS
 INCLUDES ///.
 
#define FRAIG_PATTERNS_RANDOM   2048
 
#define FRAIG_PATTERNS_DYNAMIC   2048
 
#define FRAIG_MAX_PRIMES   1024
 
#define FRAIG_WORDS_STORE   5
 
#define FRAIG_MASK(n)
 
#define FRAIG_FULL   (~((unsigned)0))
 
#define FRAIG_NUM_WORDS(n)
 
#define FRAIG_RANDOM_UNSIGNED   Aig_ManRandom(0)
 
#define Fraig_BitStringSetBit(p, i)
 
#define Fraig_BitStringXorBit(p, i)
 
#define Fraig_BitStringHasBit(p, i)
 
#define Fraig_NodeSetVarStr(p, i)
 
#define Fraig_NodeHasVarStr(p, i)
 
#define Fraig_PrintTime(a, t)
 
#define Fraig_HashKey2(a, b, TSIZE)
 
#define Fraig_NodeReadNextFanout(pNode, pFanout)
 
#define Fraig_NodeReadNextFanoutPlace(pNode, pFanout)
 
#define Fraig_NodeForEachFanout(pNode, pFanout)
 
#define Fraig_NodeForEachFanoutSafe(pNode, pFanout, pFanout2)
 
#define Fraig_TableBinForEachEntryS(pBin, pEnt)
 
#define Fraig_TableBinForEachEntrySafeS(pBin, pEnt, pEnt2)
 
#define Fraig_TableBinForEachEntryF(pBin, pEnt)
 
#define Fraig_TableBinForEachEntrySafeF(pBin, pEnt, pEnt2)
 
#define Fraig_TableBinForEachEntryD(pBin, pEnt)
 
#define Fraig_TableBinForEachEntrySafeD(pBin, pEnt, pEnt2)
 
#define Fraig_TableBinForEachEntryE(pBin, pEnt)
 
#define Fraig_TableBinForEachEntrySafeE(pBin, pEnt, pEnt2)
 

Typedefs

typedef struct Fraig_MemFixed_t_ Fraig_MemFixed_t
 STRUCTURE DEFINITIONS ///.
 

Functions

unsigned Aig_ManRandom (int fReset)
 GLOBAL VARIABLES ///.
 
Fraig_Node_tFraig_NodeAndCanon (Fraig_Man_t *pMan, Fraig_Node_t *p1, Fraig_Node_t *p2)
 FUNCTION DEFINITIONS ///.
 
void Fraig_NodeAddFaninFanout (Fraig_Node_t *pFanin, Fraig_Node_t *pFanout)
 DECLARATIONS ///.
 
void Fraig_NodeRemoveFaninFanout (Fraig_Node_t *pFanin, Fraig_Node_t *pFanoutToRemove)
 
int Fraig_NodeGetFanoutNum (Fraig_Node_t *pNode)
 
void Fraig_FeedBackInit (Fraig_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
void Fraig_FeedBack (Fraig_Man_t *p, int *pModel, Msat_IntVec_t *vVars, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
void Fraig_FeedBackTest (Fraig_Man_t *p)
 
int Fraig_FeedBackCompress (Fraig_Man_t *p)
 
int * Fraig_ManAllocCounterExample (Fraig_Man_t *p)
 
int * Fraig_ManSaveCounterExample (Fraig_Man_t *p, Fraig_Node_t *pNode)
 
void Fraig_ManCreateSolver (Fraig_Man_t *p)
 
Fraig_MemFixed_tFraig_MemFixedStart (int nEntrySize)
 FUNCTION DEFINITIONS ///.
 
void Fraig_MemFixedStop (Fraig_MemFixed_t *p, int fVerbose)
 
char * Fraig_MemFixedEntryFetch (Fraig_MemFixed_t *p)
 
void Fraig_MemFixedEntryRecycle (Fraig_MemFixed_t *p, char *pEntry)
 
void Fraig_MemFixedRestart (Fraig_MemFixed_t *p)
 
int Fraig_MemFixedReadMemUsage (Fraig_MemFixed_t *p)
 
Fraig_Node_tFraig_NodeCreateConst (Fraig_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
Fraig_Node_tFraig_NodeCreatePi (Fraig_Man_t *p)
 
Fraig_Node_tFraig_NodeCreate (Fraig_Man_t *p, Fraig_Node_t *p1, Fraig_Node_t *p2)
 
void Fraig_NodeSimulate (Fraig_Node_t *pNode, int iWordStart, int iWordStop, int fUseRand)
 
int Fraig_NodeIsImplification (Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit)
 
Fraig_HashTable_tFraig_HashTableCreate (int nSize)
 FUNCTION DEFINITIONS ///.
 
void Fraig_HashTableFree (Fraig_HashTable_t *p)
 
int Fraig_HashTableLookupS (Fraig_Man_t *pMan, Fraig_Node_t *p1, Fraig_Node_t *p2, Fraig_Node_t **ppNodeRes)
 
Fraig_Node_tFraig_HashTableLookupF (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
Fraig_Node_tFraig_HashTableLookupF0 (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
void Fraig_HashTableInsertF0 (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_CompareSimInfo (Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int iWordLast, int fUseRand)
 
int Fraig_CompareSimInfoUnderMask (Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int iWordLast, int fUseRand, unsigned *puMask)
 
int Fraig_FindFirstDiff (Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int fCompl, int iWordLast, int fUseRand)
 
void Fraig_CollectXors (Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int iWordLast, int fUseRand, unsigned *puMask)
 
void Fraig_TablePrintStatsS (Fraig_Man_t *pMan)
 
void Fraig_TablePrintStatsF (Fraig_Man_t *pMan)
 
void Fraig_TablePrintStatsF0 (Fraig_Man_t *pMan)
 
int Fraig_TableRehashF0 (Fraig_Man_t *pMan, int fLinkEquiv)
 
int Fraig_NodeCountPis (Msat_IntVec_t *vVars, int nVarsPi)
 
int Fraig_NodeCountSuppVars (Fraig_Man_t *p, Fraig_Node_t *pNode, int fSuppStr)
 
int Fraig_NodesCompareSupps (Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
int Fraig_NodeAndSimpleCase_rec (Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
int Fraig_NodeIsExorType (Fraig_Node_t *pNode)
 
void Fraig_ManSelectBestChoice (Fraig_Man_t *p)
 
int Fraig_BitStringCountOnes (unsigned *pString, int nWords)
 
void Fraig_PrintBinary (FILE *pFile, unsigned *pSign, int nBits)
 
int Fraig_NodeIsExor (Fraig_Node_t *pNode)
 
int Fraig_NodeIsMuxType (Fraig_Node_t *pNode)
 
Fraig_Node_tFraig_NodeRecognizeMux (Fraig_Node_t *pNode, Fraig_Node_t **ppNodeT, Fraig_Node_t **ppNodeE)
 
int Fraig_ManCountExors (Fraig_Man_t *pMan)
 
int Fraig_ManCountMuxes (Fraig_Man_t *pMan)
 
int Fraig_NodeSimsContained (Fraig_Man_t *pMan, Fraig_Node_t *pNode1, Fraig_Node_t *pNode2)
 
int Fraig_NodeIsInSupergate (Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
Fraig_NodeVec_tFraig_CollectSupergate (Fraig_Node_t *pNode, int fStopAtMux)
 
int Fraig_CountPis (Fraig_Man_t *p, Msat_IntVec_t *vVarNums)
 
void Fraig_ManIncrementTravId (Fraig_Man_t *pMan)
 
void Fraig_NodeSetTravIdCurrent (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_NodeIsTravIdCurrent (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_NodeIsTravIdPrevious (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
void Fraig_NodeVecSortByRefCount (Fraig_NodeVec_t *p)
 

Variables

int s_FraigPrimes [FRAIG_MAX_PRIMES]
 DECLARATIONS ///.
 

Macro Definition Documentation

◆ Fraig_BitStringHasBit

#define Fraig_BitStringHasBit ( p,
i )
Value:
(((p)[(i)>>5] & (1<<((i) & 31))) > 0)
Cube * p
Definition exorList.c:222

Definition at line 81 of file fraigInt.h.

◆ Fraig_BitStringSetBit

#define Fraig_BitStringSetBit ( p,
i )
Value:
((p)[(i)>>5] |= (1<<((i) & 31)))

Definition at line 79 of file fraigInt.h.

◆ Fraig_BitStringXorBit

#define Fraig_BitStringXorBit ( p,
i )
Value:
((p)[(i)>>5] ^= (1<<((i) & 31)))

Definition at line 80 of file fraigInt.h.

◆ FRAIG_ENABLE_FANOUTS

#define FRAIG_ENABLE_FANOUTS

INCLUDES ///.

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

FileName [fraigInt.h]

PackageName [FRAIG: Functionally reduced AND-INV graphs.]

Synopsis [Internal declarations of the FRAIG package.]

Author [Alan Mishchenko alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - October 1, 2004]

Revision [

Id
fraigInt.h,v 1.15 2005/07/08 01:01:31 alanmi Exp

] PARAMETERS /// MACRO DEFINITIONS ///

Definition at line 57 of file fraigInt.h.

◆ FRAIG_FULL

#define FRAIG_FULL   (~((unsigned)0))

Definition at line 71 of file fraigInt.h.

◆ Fraig_HashKey2

#define Fraig_HashKey2 ( a,
b,
TSIZE )
Value:
(((ABC_PTRUINT_T)(a) + (ABC_PTRUINT_T)(b) * 12582917) % TSIZE)

Definition at line 92 of file fraigInt.h.

◆ FRAIG_MASK

#define FRAIG_MASK ( n)
Value:
((~((unsigned)0)) >> (32-(n)))

Definition at line 70 of file fraigInt.h.

◆ FRAIG_MAX_PRIMES

#define FRAIG_MAX_PRIMES   1024

Definition at line 60 of file fraigInt.h.

◆ Fraig_NodeForEachFanout

#define Fraig_NodeForEachFanout ( pNode,
pFanout )
Value:
for ( pFanout = (pNode)->pFanPivot; pFanout; \
pFanout = Fraig_NodeReadNextFanout(pNode, pFanout) )
#define Fraig_NodeReadNextFanout(pNode, pFanout)
Definition fraigInt.h:279

Definition at line 288 of file fraigInt.h.

288#define Fraig_NodeForEachFanout( pNode, pFanout ) \
289 for ( pFanout = (pNode)->pFanPivot; pFanout; \
290 pFanout = Fraig_NodeReadNextFanout(pNode, pFanout) )

◆ Fraig_NodeForEachFanoutSafe

#define Fraig_NodeForEachFanoutSafe ( pNode,
pFanout,
pFanout2 )
Value:
for ( pFanout = (pNode)->pFanPivot, \
pFanout2 = Fraig_NodeReadNextFanout(pNode, pFanout); \
pFanout; \
pFanout = pFanout2, \
pFanout2 = Fraig_NodeReadNextFanout(pNode, pFanout) )

Definition at line 292 of file fraigInt.h.

292#define Fraig_NodeForEachFanoutSafe( pNode, pFanout, pFanout2 ) \
293 for ( pFanout = (pNode)->pFanPivot, \
294 pFanout2 = Fraig_NodeReadNextFanout(pNode, pFanout); \
295 pFanout; \
296 pFanout = pFanout2, \
297 pFanout2 = Fraig_NodeReadNextFanout(pNode, pFanout) )

◆ Fraig_NodeHasVarStr

#define Fraig_NodeHasVarStr ( p,
i )
Value:
#define Fraig_BitStringHasBit(p, i)
Definition fraigInt.h:81
#define Fraig_Regular(p)
Definition fraig.h:108

Definition at line 87 of file fraigInt.h.

◆ Fraig_NodeReadNextFanout

#define Fraig_NodeReadNextFanout ( pNode,
pFanout )
Value:
( ( pFanout == NULL )? NULL : \
((Fraig_Regular((pFanout)->p1) == (pNode))? \
(pFanout)->pFanFanin1 : (pFanout)->pFanFanin2) )

Definition at line 279 of file fraigInt.h.

279#define Fraig_NodeReadNextFanout( pNode, pFanout ) \
280 ( ( pFanout == NULL )? NULL : \
281 ((Fraig_Regular((pFanout)->p1) == (pNode))? \
282 (pFanout)->pFanFanin1 : (pFanout)->pFanFanin2) )

◆ Fraig_NodeReadNextFanoutPlace

#define Fraig_NodeReadNextFanoutPlace ( pNode,
pFanout )
Value:
( (Fraig_Regular((pFanout)->p1) == (pNode))? \
&(pFanout)->pFanFanin1 : &(pFanout)->pFanFanin2 )

Definition at line 284 of file fraigInt.h.

284#define Fraig_NodeReadNextFanoutPlace( pNode, pFanout ) \
285 ( (Fraig_Regular((pFanout)->p1) == (pNode))? \
286 &(pFanout)->pFanFanin1 : &(pFanout)->pFanFanin2 )

◆ Fraig_NodeSetVarStr

#define Fraig_NodeSetVarStr ( p,
i )
Value:
#define Fraig_BitStringSetBit(p, i)
Definition fraigInt.h:79

Definition at line 86 of file fraigInt.h.

◆ FRAIG_NUM_WORDS

#define FRAIG_NUM_WORDS ( n)
Value:
(((n)>>5) + (((n)&31) > 0))

Definition at line 72 of file fraigInt.h.

◆ FRAIG_PATTERNS_DYNAMIC

#define FRAIG_PATTERNS_DYNAMIC   2048

Definition at line 59 of file fraigInt.h.

◆ FRAIG_PATTERNS_RANDOM

#define FRAIG_PATTERNS_RANDOM   2048

Definition at line 58 of file fraigInt.h.

◆ Fraig_PrintTime

#define Fraig_PrintTime ( a,
t )
Value:
printf( "%s = ", (a) ); printf( "%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC) )

Definition at line 90 of file fraigInt.h.

◆ FRAIG_RANDOM_UNSIGNED

#define FRAIG_RANDOM_UNSIGNED   Aig_ManRandom(0)

Definition at line 76 of file fraigInt.h.

◆ Fraig_TableBinForEachEntryD

#define Fraig_TableBinForEachEntryD ( pBin,
pEnt )
Value:
for ( pEnt = pBin; \
pEnt; \
pEnt = pEnt->pNextD )

Definition at line 323 of file fraigInt.h.

323#define Fraig_TableBinForEachEntryD( pBin, pEnt ) \
324 for ( pEnt = pBin; \
325 pEnt; \
326 pEnt = pEnt->pNextD )

◆ Fraig_TableBinForEachEntryE

#define Fraig_TableBinForEachEntryE ( pBin,
pEnt )
Value:
for ( pEnt = pBin; \
pEnt; \
pEnt = pEnt->pNextE )

Definition at line 334 of file fraigInt.h.

334#define Fraig_TableBinForEachEntryE( pBin, pEnt ) \
335 for ( pEnt = pBin; \
336 pEnt; \
337 pEnt = pEnt->pNextE )

◆ Fraig_TableBinForEachEntryF

#define Fraig_TableBinForEachEntryF ( pBin,
pEnt )
Value:
for ( pEnt = pBin; \
pEnt; \
pEnt = pEnt->pNextF )

Definition at line 312 of file fraigInt.h.

312#define Fraig_TableBinForEachEntryF( pBin, pEnt ) \
313 for ( pEnt = pBin; \
314 pEnt; \
315 pEnt = pEnt->pNextF )

◆ Fraig_TableBinForEachEntryS

#define Fraig_TableBinForEachEntryS ( pBin,
pEnt )
Value:
for ( pEnt = pBin; \
pEnt; \
pEnt = pEnt->pNextS )

Definition at line 301 of file fraigInt.h.

301#define Fraig_TableBinForEachEntryS( pBin, pEnt ) \
302 for ( pEnt = pBin; \
303 pEnt; \
304 pEnt = pEnt->pNextS )

◆ Fraig_TableBinForEachEntrySafeD

#define Fraig_TableBinForEachEntrySafeD ( pBin,
pEnt,
pEnt2 )
Value:
for ( pEnt = pBin, \
pEnt2 = pEnt? pEnt->pNextD: NULL; \
pEnt; \
pEnt = pEnt2, \
pEnt2 = pEnt? pEnt->pNextD: NULL )

Definition at line 327 of file fraigInt.h.

327#define Fraig_TableBinForEachEntrySafeD( pBin, pEnt, pEnt2 ) \
328 for ( pEnt = pBin, \
329 pEnt2 = pEnt? pEnt->pNextD: NULL; \
330 pEnt; \
331 pEnt = pEnt2, \
332 pEnt2 = pEnt? pEnt->pNextD: NULL )

◆ Fraig_TableBinForEachEntrySafeE

#define Fraig_TableBinForEachEntrySafeE ( pBin,
pEnt,
pEnt2 )
Value:
for ( pEnt = pBin, \
pEnt2 = pEnt? pEnt->pNextE: NULL; \
pEnt; \
pEnt = pEnt2, \
pEnt2 = pEnt? pEnt->pNextE: NULL )

Definition at line 338 of file fraigInt.h.

338#define Fraig_TableBinForEachEntrySafeE( pBin, pEnt, pEnt2 ) \
339 for ( pEnt = pBin, \
340 pEnt2 = pEnt? pEnt->pNextE: NULL; \
341 pEnt; \
342 pEnt = pEnt2, \
343 pEnt2 = pEnt? pEnt->pNextE: NULL )

◆ Fraig_TableBinForEachEntrySafeF

#define Fraig_TableBinForEachEntrySafeF ( pBin,
pEnt,
pEnt2 )
Value:
for ( pEnt = pBin, \
pEnt2 = pEnt? pEnt->pNextF: NULL; \
pEnt; \
pEnt = pEnt2, \
pEnt2 = pEnt? pEnt->pNextF: NULL )

Definition at line 316 of file fraigInt.h.

316#define Fraig_TableBinForEachEntrySafeF( pBin, pEnt, pEnt2 ) \
317 for ( pEnt = pBin, \
318 pEnt2 = pEnt? pEnt->pNextF: NULL; \
319 pEnt; \
320 pEnt = pEnt2, \
321 pEnt2 = pEnt? pEnt->pNextF: NULL )

◆ Fraig_TableBinForEachEntrySafeS

#define Fraig_TableBinForEachEntrySafeS ( pBin,
pEnt,
pEnt2 )
Value:
for ( pEnt = pBin, \
pEnt2 = pEnt? pEnt->pNextS: NULL; \
pEnt; \
pEnt = pEnt2, \
pEnt2 = pEnt? pEnt->pNextS: NULL )

Definition at line 305 of file fraigInt.h.

305#define Fraig_TableBinForEachEntrySafeS( pBin, pEnt, pEnt2 ) \
306 for ( pEnt = pBin, \
307 pEnt2 = pEnt? pEnt->pNextS: NULL; \
308 pEnt; \
309 pEnt = pEnt2, \
310 pEnt2 = pEnt? pEnt->pNextS: NULL )

◆ FRAIG_WORDS_STORE

#define FRAIG_WORDS_STORE   5

Definition at line 67 of file fraigInt.h.

Typedef Documentation

◆ Fraig_MemFixed_t

STRUCTURE DEFINITIONS ///.

Definition at line 101 of file fraigInt.h.

Function Documentation

◆ Aig_ManRandom()

unsigned Aig_ManRandom ( int fReset)
extern

GLOBAL VARIABLES ///.

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

SeeAlso [http://www.codeproject.com/KB/recipes/SimpleRNG.aspx]

Definition at line 1170 of file aigUtil.c.

1171{
1172#ifdef _MSC_VER
1173 static unsigned int m_z = NUMBER1;
1174 static unsigned int m_w = NUMBER2;
1175#else
1176 static __thread unsigned int m_z = NUMBER1;
1177 static __thread unsigned int m_w = NUMBER2;
1178#endif
1179 if ( fReset )
1180 {
1181 m_z = NUMBER1;
1182 m_w = NUMBER2;
1183 }
1184 m_z = 36969 * (m_z & 65535) + (m_z >> 16);
1185 m_w = 18000 * (m_w & 65535) + (m_w >> 16);
1186 return (m_z << 16) + m_w;
1187}
#define NUMBER2
Definition aigUtil.c:1157
#define NUMBER1
Definition aigUtil.c:1156
Here is the caller graph for this function:

◆ Fraig_BitStringCountOnes()

int Fraig_BitStringCountOnes ( unsigned * pString,
int nWords )
extern

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

Synopsis [Creates the constant 1 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 288 of file fraigUtil.c.

289{
290 unsigned char * pSuppBytes = (unsigned char *)pString;
291 int i, nOnes, nBytes = sizeof(unsigned) * nWords;
292 // count the number of ones in the simulation vector
293 for ( i = nOnes = 0; i < nBytes; i++ )
294 nOnes += bit_count[pSuppBytes[i]];
295 return nOnes;
296}
int nWords
Definition abcNpn.c:127
Here is the caller graph for this function:

◆ Fraig_CollectSupergate()

Fraig_NodeVec_t * Fraig_CollectSupergate ( Fraig_Node_t * pNode,
int fStopAtMux )
extern

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

Synopsis [Returns the array of nodes to be combined into one multi-input AND-gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 960 of file fraigUtil.c.

961{
962 Fraig_NodeVec_t * vSuper;
963 vSuper = Fraig_NodeVecAlloc( 8 );
964 Fraig_CollectSupergate_rec( pNode, vSuper, 1, fStopAtMux );
965 return vSuper;
966}
void Fraig_CollectSupergate_rec(Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, int fFirst, int fStopAtMux)
Definition fraigUtil.c:933
struct Fraig_NodeVecStruct_t_ Fraig_NodeVec_t
Definition fraig.h:42
Fraig_NodeVec_t * Fraig_NodeVecAlloc(int nCap)
DECLARATIONS ///.
Definition fraigVec.c:43

◆ Fraig_CollectXors()

void Fraig_CollectXors ( Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2,
int iWordLast,
int fUseRand,
unsigned * puMask )
extern

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

Synopsis [Compares two pieces of simulation info.]

Description [Returns 1 if they are equal.]

SideEffects []

SeeAlso []

Definition at line 478 of file fraigTable.c.

479{
480 unsigned * pSims1, * pSims2;
481 int i;
482 assert( !Fraig_IsComplement(pNode1) );
483 assert( !Fraig_IsComplement(pNode2) );
484 // get hold of simulation info
485 pSims1 = fUseRand? pNode1->puSimR : pNode1->puSimD;
486 pSims2 = fUseRand? pNode2->puSimR : pNode2->puSimD;
487 // check the simulation info
488 for ( i = 0; i < iWordLast; i++ )
489 puMask[i] = ( pSims1[i] ^ pSims2[i] );
490}
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition fraig.h:107
unsigned * puSimR
Definition fraigInt.h:247
unsigned * puSimD
Definition fraigInt.h:248
#define assert(ex)
Definition util_old.h:213

◆ Fraig_CompareSimInfo()

int Fraig_CompareSimInfo ( Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2,
int iWordLast,
int fUseRand )
extern

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

Synopsis [Compares two pieces of simulation info.]

Description [Returns 1 if they are equal.]

SideEffects []

SeeAlso []

Definition at line 351 of file fraigTable.c.

352{
353 int i;
354 assert( !Fraig_IsComplement(pNode1) );
355 assert( !Fraig_IsComplement(pNode2) );
356 if ( fUseRand )
357 {
358 // if their signatures differ, skip
359 if ( pNode1->uHashR != pNode2->uHashR )
360 return 0;
361 // check the simulation info
362 for ( i = 0; i < iWordLast; i++ )
363 if ( pNode1->puSimR[i] != pNode2->puSimR[i] )
364 return 0;
365 }
366 else
367 {
368 // if their signatures differ, skip
369 if ( pNode1->uHashD != pNode2->uHashD )
370 return 0;
371 // check the simulation info
372 for ( i = 0; i < iWordLast; i++ )
373 if ( pNode1->puSimD[i] != pNode2->puSimD[i] )
374 return 0;
375 }
376 return 1;
377}
Here is the caller graph for this function:

◆ Fraig_CompareSimInfoUnderMask()

int Fraig_CompareSimInfoUnderMask ( Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2,
int iWordLast,
int fUseRand,
unsigned * puMask )
extern

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

Synopsis [Compares two pieces of simulation info.]

Description [Returns 1 if they are equal.]

SideEffects []

SeeAlso []

Definition at line 451 of file fraigTable.c.

452{
453 unsigned * pSims1, * pSims2;
454 int i;
455 assert( !Fraig_IsComplement(pNode1) );
456 assert( !Fraig_IsComplement(pNode2) );
457 // get hold of simulation info
458 pSims1 = fUseRand? pNode1->puSimR : pNode1->puSimD;
459 pSims2 = fUseRand? pNode2->puSimR : pNode2->puSimD;
460 // check the simulation info
461 for ( i = 0; i < iWordLast; i++ )
462 if ( (pSims1[i] & puMask[i]) != (pSims2[i] & puMask[i]) )
463 return 0;
464 return 1;
465}

◆ Fraig_CountPis()

int Fraig_CountPis ( Fraig_Man_t * p,
Msat_IntVec_t * vVarNums )
extern

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

Synopsis [Count the number of PI variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 817 of file fraigUtil.c.

818{
819 int * pVars, nVars, i, Counter;
820
821 nVars = Msat_IntVecReadSize(vVarNums);
822 pVars = Msat_IntVecReadArray(vVarNums);
823 Counter = 0;
824 for ( i = 0; i < nVars; i++ )
825 Counter += Fraig_NodeIsVar( p->vNodes->pArray[pVars[i]] );
826 return Counter;
827}
int Fraig_NodeIsVar(Fraig_Node_t *p)
Definition fraigApi.c:152
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition msatVec.c:217
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_FeedBack()

void Fraig_FeedBack ( Fraig_Man_t * p,
int * pModel,
Msat_IntVec_t * vVars,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew )
extern

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

Synopsis [Processes the feedback from teh solver.]

Description [Array pModel gives the value of each variable in the SAT solver. Array vVars is the array of integer numbers of variables involves in this conflict.]

SideEffects []

SeeAlso []

Definition at line 80 of file fraigFeed.c.

81{
82 int nVarsPi, nWords;
83 int i;
84 abctime clk = Abc_Clock();
85
86 // get the number of PI vars in the feedback (also sets the PI values)
87 nVarsPi = Fraig_FeedBackPrepare( p, pModel, vVars );
88
89 // set the PI values
90 nWords = Fraig_FeedBackInsert( p, nVarsPi );
91 assert( p->iWordStart + nWords <= p->nWordsDyna );
92
93 // resimulates the words from p->iWordStart to iWordStop
94 for ( i = 1; i < p->vNodes->nSize; i++ )
95 if ( Fraig_NodeIsAnd(p->vNodes->pArray[i]) )
96 Fraig_NodeSimulate( p->vNodes->pArray[i], p->iWordStart, p->iWordStart + nWords, 0 );
97
98 if ( p->fDoSparse )
100
101 if ( !p->fChoicing )
102 Fraig_FeedBackVerify( p, pOld, pNew );
103
104 // if there is no room left, compress the patterns
105 if ( p->iWordStart + nWords == p->nWordsDyna )
106 p->iWordStart = Fraig_FeedBackCompress( p );
107 else // otherwise, update the starting word
108 p->iWordStart += nWords;
109
110p->timeFeed += Abc_Clock() - clk;
111}
ABC_INT64_T abctime
Definition abc_global.h:332
int Fraig_FeedBackCompress(Fraig_Man_t *p)
Definition fraigFeed.c:278
int Fraig_TableRehashF0(Fraig_Man_t *pMan, int fLinkEquiv)
Definition fraigTable.c:604
void Fraig_NodeSimulate(Fraig_Node_t *pNode, int iWordStart, int iWordStop, int fUseRand)
Definition fraigNode.c:226
int Fraig_NodeIsAnd(Fraig_Node_t *p)
Definition fraigApi.c:153
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_FeedBackCompress()

int Fraig_FeedBackCompress ( Fraig_Man_t * p)
extern

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

Synopsis [Compress the simulation patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file fraigFeed.c.

279{
280 unsigned * pSims;
281 unsigned uHash;
282 int i, w, t, nPats, * pPats;
283 int fPerformChecks = (p->nBTLimit == -1);
284
285 // solve the covering problem
286 if ( fPerformChecks )
287 {
288 Fraig_FeedBackCheckTable( p );
289 if ( p->fDoSparse )
290 Fraig_FeedBackCheckTableF0( p );
291 }
292
293 // solve the covering problem
294 Fraig_FeedBackCovering( p, p->vPatsReal );
295
296
297 // get the number of additional patterns
298 nPats = Msat_IntVecReadSize( p->vPatsReal );
299 pPats = Msat_IntVecReadArray( p->vPatsReal );
300 // get the new starting word
301 p->iWordStart = FRAIG_NUM_WORDS( p->iPatsPerm + nPats );
302
303 // set the simulation info for the PIs
304 for ( i = 0; i < p->vInputs->nSize; i++ )
305 {
306 // get hold of the simulation info for this PI
307 pSims = p->vInputs->pArray[i]->puSimD;
308 // clean the storage for the new patterns
309 for ( w = p->iWordPerm; w < p->iWordStart; w++ )
310 p->pSimsTemp[w] = 0;
311 // set the patterns
312 for ( t = 0; t < nPats; t++ )
313 if ( Fraig_BitStringHasBit( pSims, pPats[t] ) )
314 {
315 // check if this pattern falls into temporary storage
316 if ( p->iPatsPerm + t < p->iWordPerm * 32 )
317 Fraig_BitStringSetBit( pSims, p->iPatsPerm + t );
318 else
319 Fraig_BitStringSetBit( p->pSimsTemp, p->iPatsPerm + t );
320 }
321 // copy the pattern
322 for ( w = p->iWordPerm; w < p->iWordStart; w++ )
323 pSims[w] = p->pSimsTemp[w];
324 // recompute the hashing info
325 uHash = 0;
326 for ( w = 0; w < p->iWordStart; w++ )
327 uHash ^= pSims[w] * s_FraigPrimes[w];
328 p->vInputs->pArray[i]->uHashD = uHash;
329 }
330
331 // update info about the permanently stored patterns
332 p->iWordPerm = p->iWordStart;
333 p->iPatsPerm += nPats;
334 assert( p->iWordPerm == FRAIG_NUM_WORDS( p->iPatsPerm ) );
335
336 // resimulate and recompute the hash values
337 for ( i = 1; i < p->vNodes->nSize; i++ )
338 if ( Fraig_NodeIsAnd(p->vNodes->pArray[i]) )
339 {
340 p->vNodes->pArray[i]->uHashD = 0;
341 Fraig_NodeSimulate( p->vNodes->pArray[i], 0, p->iWordPerm, 0 );
342 }
343
344 // double-check that the nodes are still distinguished
345 if ( fPerformChecks )
346 Fraig_FeedBackCheckTable( p );
347
348 // rehash the values in the F0 table
349 if ( p->fDoSparse )
350 {
352 if ( fPerformChecks )
353 Fraig_FeedBackCheckTableF0( p );
354 }
355
356 // check if we need to resize the simulation info
357 // if less than FRAIG_WORDS_STORE words are left, reallocate simulation info
358 if ( p->iWordPerm + FRAIG_WORDS_STORE > p->nWordsDyna )
359 Fraig_ReallocateSimulationInfo( p );
360
361 // set the real patterns
362 Msat_IntVecClear( p->vPatsReal );
363 memset( p->pSimsReal, 0, sizeof(unsigned)*p->nWordsDyna );
364 for ( w = 0; w < p->iWordPerm; w++ )
365 p->pSimsReal[w] = FRAIG_FULL;
366 if ( p->iPatsPerm % 32 > 0 )
367 p->pSimsReal[p->iWordPerm-1] = FRAIG_MASK( p->iPatsPerm % 32 );
368// printf( "The number of permanent words = %d.\n", p->iWordPerm );
369 return p->iWordStart;
370}
#define FRAIG_WORDS_STORE
Definition fraigInt.h:67
#define FRAIG_FULL
Definition fraigInt.h:71
#define FRAIG_MASK(n)
Definition fraigInt.h:70
#define FRAIG_NUM_WORDS(n)
Definition fraigInt.h:72
int s_FraigPrimes[FRAIG_MAX_PRIMES]
DECLARATIONS ///.
Definition fraigPrime.c:30
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition msatVec.c:335
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_FeedBackInit()

void Fraig_FeedBackInit ( Fraig_Man_t * p)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Initializes the feedback information.]

Description []

SideEffects []

SeeAlso []

Definition at line 57 of file fraigFeed.c.

58{
59 p->vCones = Fraig_NodeVecAlloc( 500 );
60 p->vPatsReal = Msat_IntVecAlloc( 1000 );
61 p->pSimsReal = (unsigned *)Fraig_MemFixedEntryFetch( p->mmSims );
62 memset( p->pSimsReal, 0, sizeof(unsigned) * p->nWordsDyna );
63 p->pSimsTemp = (unsigned *)Fraig_MemFixedEntryFetch( p->mmSims );
64 p->pSimsDiff = (unsigned *)Fraig_MemFixedEntryFetch( p->mmSims );
65}
char * Fraig_MemFixedEntryFetch(Fraig_MemFixed_t *p)
Definition fraigMem.c:131
Msat_IntVec_t * Msat_IntVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition msatVec.c:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_FeedBackTest()

void Fraig_FeedBackTest ( Fraig_Man_t * p)
extern

◆ Fraig_FindFirstDiff()

int Fraig_FindFirstDiff ( Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2,
int fCompl,
int iWordLast,
int fUseRand )
extern

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

Synopsis [Find the number of the different pattern.]

Description [Returns -1 if there is no such pattern]

SideEffects []

SeeAlso []

Definition at line 390 of file fraigTable.c.

391{
392 int i, v;
393 assert( !Fraig_IsComplement(pNode1) );
394 assert( !Fraig_IsComplement(pNode2) );
395 // take into account possible internal complementation
396 fCompl ^= pNode1->fInv;
397 fCompl ^= pNode2->fInv;
398 // find the pattern
399 if ( fCompl )
400 {
401 if ( fUseRand )
402 {
403 for ( i = 0; i < iWordLast; i++ )
404 if ( pNode1->puSimR[i] != ~pNode2->puSimR[i] )
405 for ( v = 0; v < 32; v++ )
406 if ( (pNode1->puSimR[i] ^ ~pNode2->puSimR[i]) & (1 << v) )
407 return i * 32 + v;
408 }
409 else
410 {
411 for ( i = 0; i < iWordLast; i++ )
412 if ( pNode1->puSimD[i] != ~pNode2->puSimD[i] )
413 for ( v = 0; v < 32; v++ )
414 if ( (pNode1->puSimD[i] ^ ~pNode2->puSimD[i]) & (1 << v) )
415 return i * 32 + v;
416 }
417 }
418 else
419 {
420 if ( fUseRand )
421 {
422 for ( i = 0; i < iWordLast; i++ )
423 if ( pNode1->puSimR[i] != pNode2->puSimR[i] )
424 for ( v = 0; v < 32; v++ )
425 if ( (pNode1->puSimR[i] ^ pNode2->puSimR[i]) & (1 << v) )
426 return i * 32 + v;
427 }
428 else
429 {
430 for ( i = 0; i < iWordLast; i++ )
431 if ( pNode1->puSimD[i] != pNode2->puSimD[i] )
432 for ( v = 0; v < 32; v++ )
433 if ( (pNode1->puSimD[i] ^ pNode2->puSimD[i]) & (1 << v) )
434 return i * 32 + v;
435 }
436 }
437 return -1;
438}
Here is the caller graph for this function:

◆ Fraig_HashTableCreate()

Fraig_HashTable_t * Fraig_HashTableCreate ( int nSize)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file fraigTable.c.

47{
49 // allocate the table
51 memset( p, 0, sizeof(Fraig_HashTable_t) );
52 // allocate and clean the bins
53 p->nBins = Abc_PrimeCudd(nSize);
54 p->pBins = ABC_ALLOC( Fraig_Node_t *, p->nBins );
55 memset( p->pBins, 0, sizeof(Fraig_Node_t *) * p->nBins );
56 return p;
57}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
struct Fraig_NodeStruct_t_ Fraig_Node_t
Definition fraig.h:41
struct Fraig_HashTableStruct_t_ Fraig_HashTable_t
Definition fraig.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_HashTableFree()

void Fraig_HashTableFree ( Fraig_HashTable_t * p)
extern

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

Synopsis [Deallocates the supergate hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file fraigTable.c.

71{
72 ABC_FREE( p->pBins );
73 ABC_FREE( p );
74}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Fraig_HashTableInsertF0()

void Fraig_HashTableInsertF0 ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )
extern

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

Synopsis [Insert the entry in the functional hash table.]

Description [Unconditionally add the node to the corresponding linked list in the table.]

SideEffects []

SeeAlso []

Definition at line 237 of file fraigTable.c.

238{
239 Fraig_HashTable_t * p = pMan->pTableF0;
240 unsigned Key = pNode->uHashD % p->nBins;
241
242 pNode->pNextF = p->pBins[Key];
243 p->pBins[Key] = pNode;
244 p->nEntries++;
245}
Fraig_Node_t * pNextF
Definition fraigInt.h:239

◆ Fraig_HashTableLookupF()

Fraig_Node_t * Fraig_HashTableLookupF ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )
extern

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

Synopsis [Insert the entry in the functional hash table.]

Description [If the entry with the same key exists, return it right away.
If the entry with the same key does not exists, inserts it and returns NULL. ]

SideEffects []

SeeAlso []

Definition at line 136 of file fraigTable.c.

137{
138 Fraig_HashTable_t * p = pMan->pTableF;
139 Fraig_Node_t * pEnt, * pEntD;
140 unsigned Key;
141
142 // go through the hash table entries
143 Key = pNode->uHashR % p->nBins;
144 Fraig_TableBinForEachEntryF( p->pBins[Key], pEnt )
145 {
146 // if their simulation info differs, skip
147 if ( !Fraig_CompareSimInfo( pNode, pEnt, pMan->nWordsRand, 1 ) )
148 continue;
149 // equivalent up to the complement
150 Fraig_TableBinForEachEntryD( pEnt, pEntD )
151 {
152 // if their simulation info differs, skip
153 if ( !Fraig_CompareSimInfo( pNode, pEntD, pMan->iWordStart, 0 ) )
154 continue;
155 // found a simulation-equivalent node
156 return pEntD;
157 }
158 // did not find a simulation equivalent node
159 // add the node to the corresponding linked list
160 pNode->pNextD = pEnt->pNextD;
161 pEnt->pNextD = pNode;
162 // return NULL, because there is no functional equivalence in this case
163 return NULL;
164 }
165
166 // check if it is a good time for table resizing
167 if ( p->nEntries >= 2 * p->nBins )
168 {
169 Fraig_TableResizeF( p, 1 );
170 Key = pNode->uHashR % p->nBins;
171 }
172
173 // add the node to the corresponding linked list in the table
174 pNode->pNextF = p->pBins[Key];
175 p->pBins[Key] = pNode;
176 p->nEntries++;
177 // return NULL, because there is no functional equivalence in this case
178 return NULL;
179}
#define Fraig_TableBinForEachEntryF(pBin, pEnt)
Definition fraigInt.h:312
#define Fraig_TableBinForEachEntryD(pBin, pEnt)
Definition fraigInt.h:323
int Fraig_CompareSimInfo(Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int iWordLast, int fUseRand)
Definition fraigTable.c:351
Fraig_Node_t * pNextD
Definition fraigInt.h:240
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_HashTableLookupF0()

Fraig_Node_t * Fraig_HashTableLookupF0 ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )
extern

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

Synopsis [Insert the entry in the functional hash table.]

Description [If the entry with the same key exists, return it right away.
If the entry with the same key does not exists, inserts it and returns NULL. ]

SideEffects []

SeeAlso []

Definition at line 193 of file fraigTable.c.

194{
195 Fraig_HashTable_t * p = pMan->pTableF0;
196 Fraig_Node_t * pEnt;
197 unsigned Key;
198
199 // go through the hash table entries
200 Key = pNode->uHashD % p->nBins;
201 Fraig_TableBinForEachEntryF( p->pBins[Key], pEnt )
202 {
203 // if their simulation info differs, skip
204 if ( !Fraig_CompareSimInfo( pNode, pEnt, pMan->iWordStart, 0 ) )
205 continue;
206 // found a simulation-equivalent node
207 return pEnt;
208 }
209
210 // check if it is a good time for table resizing
211 if ( p->nEntries >= 2 * p->nBins )
212 {
213 Fraig_TableResizeF( p, 0 );
214 Key = pNode->uHashD % p->nBins;
215 }
216
217 // add the node to the corresponding linked list in the table
218 pNode->pNextF = p->pBins[Key];
219 p->pBins[Key] = pNode;
220 p->nEntries++;
221 // return NULL, because there is no functional equivalence in this case
222 return NULL;
223}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_HashTableLookupS()

int Fraig_HashTableLookupS ( Fraig_Man_t * pMan,
Fraig_Node_t * p1,
Fraig_Node_t * p2,
Fraig_Node_t ** ppNodeRes )
extern

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

Synopsis [Looks up an entry in the structural hash table.]

Description [If the entry with the same children does not exists, creates it, inserts it into the table, and returns 0. If the entry with the same children exists, finds it, and return 1. In both cases, the new/old entry is returned in ppNodeRes.]

SideEffects []

SeeAlso []

Definition at line 90 of file fraigTable.c.

91{
92 Fraig_HashTable_t * p = pMan->pTableS;
93 Fraig_Node_t * pEnt;
94 unsigned Key;
95
96 // order the arguments
97 if ( Fraig_Regular(p1)->Num > Fraig_Regular(p2)->Num )
98 pEnt = p1, p1 = p2, p2 = pEnt;
99
100 Key = Fraig_HashKey2( p1, p2, p->nBins );
101 Fraig_TableBinForEachEntryS( p->pBins[Key], pEnt )
102 if ( pEnt->p1 == p1 && pEnt->p2 == p2 )
103 {
104 *ppNodeRes = pEnt;
105 return 1;
106 }
107 // check if it is a good time for table resizing
108 if ( p->nEntries >= 2 * p->nBins )
109 {
110 Fraig_TableResizeS( p );
111 Key = Fraig_HashKey2( p1, p2, p->nBins );
112 }
113 // create the new node
114 pEnt = Fraig_NodeCreate( pMan, p1, p2 );
115 // add the node to the corresponding linked list in the table
116 pEnt->pNextS = p->pBins[Key];
117 p->pBins[Key] = pEnt;
118 *ppNodeRes = pEnt;
119 p->nEntries++;
120 return 0;
121}
#define Fraig_HashKey2(a, b, TSIZE)
Definition fraigInt.h:92
#define Fraig_TableBinForEachEntryS(pBin, pEnt)
Definition fraigInt.h:301
Fraig_Node_t * Fraig_NodeCreate(Fraig_Man_t *p, Fraig_Node_t *p1, Fraig_Node_t *p2)
Definition fraigNode.c:160
Fraig_Node_t * p2
Definition fraigInt.h:233
Fraig_Node_t * pNextS
Definition fraigInt.h:238
Fraig_Node_t * p1
Definition fraigInt.h:232
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManAllocCounterExample()

int * Fraig_ManAllocCounterExample ( Fraig_Man_t * p)
extern

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

Synopsis [Generated trivial counter example.]

Description []

SideEffects []

SeeAlso []

Definition at line 787 of file fraigFeed.c.

788{
789 int * pModel;
790 pModel = ABC_ALLOC( int, p->vInputs->nSize );
791 memset( pModel, 0, sizeof(int) * p->vInputs->nSize );
792 return pModel;
793}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManCountExors()

int Fraig_ManCountExors ( Fraig_Man_t * pMan)
extern

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

Synopsis [Counts the number of EXOR type nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 742 of file fraigUtil.c.

743{
744 int i, nExors;
745 nExors = 0;
746 for ( i = 0; i < pMan->vNodes->nSize; i++ )
747 nExors += Fraig_NodeIsExorType( pMan->vNodes->pArray[i] );
748 return nExors;
749
750}
int Fraig_NodeIsExorType(Fraig_Node_t *pNode)
Definition fraigUtil.c:558
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManCountMuxes()

int Fraig_ManCountMuxes ( Fraig_Man_t * pMan)
extern

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

Synopsis [Counts the number of EXOR type nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 763 of file fraigUtil.c.

764{
765 int i, nMuxes;
766 nMuxes = 0;
767 for ( i = 0; i < pMan->vNodes->nSize; i++ )
768 nMuxes += Fraig_NodeIsMuxType( pMan->vNodes->pArray[i] );
769 return nMuxes;
770
771}
int Fraig_NodeIsMuxType(Fraig_Node_t *pNode)
Definition fraigUtil.c:591
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManCreateSolver()

void Fraig_ManCreateSolver ( Fraig_Man_t * p)
extern

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

Synopsis [Prepares the SAT solver to run on the two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 325 of file fraigMan.c.

326{
327 extern abctime timeSelect;
328 extern abctime timeAssign;
329 assert( p->pSat == NULL );
330 // allocate data for SAT solving
331 p->pSat = Msat_SolverAlloc( 500, 1, 1, 1, 1, 0 );
332 p->vVarsInt = Msat_SolverReadConeVars( p->pSat );
333 p->vAdjacents = Msat_SolverReadAdjacents( p->pSat );
334 p->vVarsUsed = Msat_SolverReadVarsUsed( p->pSat );
335 timeSelect = 0;
336 timeAssign = 0;
337}
ABC_NAMESPACE_IMPL_START abctime timeSelect
DECLARATIONS ///.
Definition fraigMan.c:28
abctime timeAssign
Definition fraigMan.c:29
Msat_ClauseVec_t * Msat_SolverReadAdjacents(Msat_Solver_t *p)
Msat_IntVec_t * Msat_SolverReadConeVars(Msat_Solver_t *p)
Msat_IntVec_t * Msat_SolverReadVarsUsed(Msat_Solver_t *p)
Msat_Solver_t * Msat_SolverAlloc(int nVars, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, int fVerbose)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManIncrementTravId()

void Fraig_ManIncrementTravId ( Fraig_Man_t * pMan)
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 980 of file fraigUtil.c.

981{
982 pMan->nTravIds2++;
983}
Here is the caller graph for this function:

◆ Fraig_ManSaveCounterExample()

int * Fraig_ManSaveCounterExample ( Fraig_Man_t * p,
Fraig_Node_t * pNode )
extern

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

Synopsis [Saves the counter example.]

Description []

SideEffects []

SeeAlso []

Definition at line 860 of file fraigFeed.c.

861{
862 int * pModel;
863 int iPattern;
864 int i, fCompl;
865
866 // the node can be complemented
867 fCompl = Fraig_IsComplement(pNode);
868 // because we compare with constant 0, p->pConst1 should also be complemented
869 fCompl = !fCompl;
870
871 // derive the model
873 iPattern = Fraig_FindFirstDiff( p->pConst1, Fraig_Regular(pNode), fCompl, p->nWordsRand, 1 );
874 if ( iPattern >= 0 )
875 {
876 for ( i = 0; i < p->vInputs->nSize; i++ )
877 if ( Fraig_BitStringHasBit( p->vInputs->pArray[i]->puSimR, iPattern ) )
878 pModel[i] = 1;
879/*
880printf( "SAT solver's pattern:\n" );
881for ( i = 0; i < p->vInputs->nSize; i++ )
882 printf( "%d", pModel[i] );
883printf( "\n" );
884*/
885 assert( Fraig_ManSimulateBitNode( p, pNode, pModel ) );
886 return pModel;
887 }
888 iPattern = Fraig_FindFirstDiff( p->pConst1, Fraig_Regular(pNode), fCompl, p->iWordStart, 0 );
889 if ( iPattern >= 0 )
890 {
891 for ( i = 0; i < p->vInputs->nSize; i++ )
892 if ( Fraig_BitStringHasBit( p->vInputs->pArray[i]->puSimD, iPattern ) )
893 pModel[i] = 1;
894/*
895printf( "SAT solver's pattern:\n" );
896for ( i = 0; i < p->vInputs->nSize; i++ )
897 printf( "%d", pModel[i] );
898printf( "\n" );
899*/
900 assert( Fraig_ManSimulateBitNode( p, pNode, pModel ) );
901 return pModel;
902 }
903 ABC_FREE( pModel );
904 return NULL;
905}
int * Fraig_ManAllocCounterExample(Fraig_Man_t *p)
Definition fraigFeed.c:787
int Fraig_ManSimulateBitNode(Fraig_Man_t *p, Fraig_Node_t *pNode, int *pModel)
Definition fraigFeed.c:832
int Fraig_FindFirstDiff(Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int fCompl, int iWordLast, int fUseRand)
Definition fraigTable.c:390
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManSelectBestChoice()

void Fraig_ManSelectBestChoice ( Fraig_Man_t * p)
extern

◆ Fraig_MemFixedEntryFetch()

char * Fraig_MemFixedEntryFetch ( Fraig_MemFixed_t * p)
extern

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

Synopsis [Extracts one entry from the memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file fraigMem.c.

132{
133 char * pTemp;
134 int i;
135
136 // check if there are still free entries
137 if ( p->nEntriesUsed == p->nEntriesAlloc )
138 { // need to allocate more entries
139 assert( p->pEntriesFree == NULL );
140 if ( p->nChunks == p->nChunksAlloc )
141 {
142 p->nChunksAlloc *= 2;
143 p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
144 }
145 p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize );
146 p->nMemoryAlloc += p->nEntrySize * p->nChunkSize;
147 // transform these entries into a linked list
148 pTemp = p->pEntriesFree;
149 for ( i = 1; i < p->nChunkSize; i++ )
150 {
151 *((char **)pTemp) = pTemp + p->nEntrySize;
152 pTemp += p->nEntrySize;
153 }
154 // set the last link
155 *((char **)pTemp) = NULL;
156 // add the chunk to the chunk storage
157 p->pChunks[ p->nChunks++ ] = p->pEntriesFree;
158 // add to the number of entries allocated
159 p->nEntriesAlloc += p->nChunkSize;
160 }
161 // incrememt the counter of used entries
162 p->nEntriesUsed++;
163 if ( p->nEntriesMax < p->nEntriesUsed )
164 p->nEntriesMax = p->nEntriesUsed;
165 // return the first entry in the free entry list
166 pTemp = p->pEntriesFree;
167 p->pEntriesFree = *((char **)pTemp);
168 return pTemp;
169}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
Here is the caller graph for this function:

◆ Fraig_MemFixedEntryRecycle()

void Fraig_MemFixedEntryRecycle ( Fraig_MemFixed_t * p,
char * pEntry )
extern

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

Synopsis [Returns one entry into the memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file fraigMem.c.

183{
184 // decrement the counter of used entries
185 p->nEntriesUsed--;
186 // add the entry to the linked list of free entries
187 *((char **)pEntry) = p->pEntriesFree;
188 p->pEntriesFree = pEntry;
189}

◆ Fraig_MemFixedReadMemUsage()

int Fraig_MemFixedReadMemUsage ( Fraig_MemFixed_t * p)
extern

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

Synopsis [Reports the memory usage.]

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file fraigMem.c.

241{
242 return p->nMemoryAlloc;
243}

◆ Fraig_MemFixedRestart()

void Fraig_MemFixedRestart ( Fraig_MemFixed_t * p)
extern

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

Synopsis [Frees all associated memory and resets the manager.]

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

SideEffects []

SeeAlso []

Definition at line 202 of file fraigMem.c.

203{
204 int i;
205 char * pTemp;
206
207 // deallocate all chunks except the first one
208 for ( i = 1; i < p->nChunks; i++ )
209 ABC_FREE( p->pChunks[i] );
210 p->nChunks = 1;
211 // transform these entries into a linked list
212 pTemp = p->pChunks[0];
213 for ( i = 1; i < p->nChunkSize; i++ )
214 {
215 *((char **)pTemp) = pTemp + p->nEntrySize;
216 pTemp += p->nEntrySize;
217 }
218 // set the last link
219 *((char **)pTemp) = NULL;
220 // set the free entry list
221 p->pEntriesFree = p->pChunks[0];
222 // set the correct statistics
223 p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
224 p->nMemoryUsed = 0;
225 p->nEntriesAlloc = p->nChunkSize;
226 p->nEntriesUsed = 0;
227}

◆ Fraig_MemFixedStart()

Fraig_MemFixed_t * Fraig_MemFixedStart ( int nEntrySize)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Starts the internal memory manager.]

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

SideEffects []

SeeAlso []

Definition at line 63 of file fraigMem.c.

64{
66
68 memset( p, 0, sizeof(Fraig_MemFixed_t) );
69
70 p->nEntrySize = nEntrySize;
71 p->nEntriesAlloc = 0;
72 p->nEntriesUsed = 0;
73 p->pEntriesFree = NULL;
74
75 if ( nEntrySize * (1 << 10) < (1<<16) )
76 p->nChunkSize = (1 << 10);
77 else
78 p->nChunkSize = (1<<16) / nEntrySize;
79 if ( p->nChunkSize < 8 )
80 p->nChunkSize = 8;
81
82 p->nChunksAlloc = 64;
83 p->nChunks = 0;
84 p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
85
86 p->nMemoryUsed = 0;
87 p->nMemoryAlloc = 0;
88 return p;
89}
struct Fraig_MemFixed_t_ Fraig_MemFixed_t
STRUCTURE DEFINITIONS ///.
Definition fraigInt.h:101
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_MemFixedStop()

void Fraig_MemFixedStop ( Fraig_MemFixed_t * p,
int fVerbose )
extern

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

Synopsis [Stops the internal memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file fraigMem.c.

103{
104 int i;
105 if ( p == NULL )
106 return;
107 if ( fVerbose )
108 {
109 printf( "Fixed memory manager: Entry = %5d. Chunk = %5d. Chunks used = %5d.\n",
110 p->nEntrySize, p->nChunkSize, p->nChunks );
111 printf( " Entries used = %8d. Entries peak = %8d. Memory used = %8d. Memory alloc = %8d.\n",
112 p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc );
113 }
114 for ( i = 0; i < p->nChunks; i++ )
115 ABC_FREE( p->pChunks[i] );
116 ABC_FREE( p->pChunks );
117 ABC_FREE( p );
118}
Here is the caller graph for this function:

◆ Fraig_NodeAddFaninFanout()

void Fraig_NodeAddFaninFanout ( Fraig_Node_t * pFanin,
Fraig_Node_t * pFanout )
extern

DECLARATIONS ///.

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

FileName [fraigFanout.c]

PackageName [FRAIG: Functionally reduced AND-INV graphs.]

Synopsis [Procedures to manipulate fanouts of the FRAIG nodes.]

Author [Alan Mishchenko alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - October 1, 2004]

Revision [

Id
fraigFanout.c,v 1.5 2005/07/08 01:01:31 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Add the fanout to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file fraigFanout.c.

46{
47 Fraig_Node_t * pPivot;
48
49 // pFanins is a fanin of pFanout
50 assert( !Fraig_IsComplement(pFanin) );
51 assert( !Fraig_IsComplement(pFanout) );
52 assert( Fraig_Regular(pFanout->p1) == pFanin || Fraig_Regular(pFanout->p2) == pFanin );
53
54 pPivot = pFanin->pFanPivot;
55 if ( pPivot == NULL )
56 {
57 pFanin->pFanPivot = pFanout;
58 return;
59 }
60
61 if ( Fraig_Regular(pPivot->p1) == pFanin )
62 {
63 if ( Fraig_Regular(pFanout->p1) == pFanin )
64 {
65 pFanout->pFanFanin1 = pPivot->pFanFanin1;
66 pPivot->pFanFanin1 = pFanout;
67 }
68 else // if ( Fraig_Regular(pFanout->p2) == pFanin )
69 {
70 pFanout->pFanFanin2 = pPivot->pFanFanin1;
71 pPivot->pFanFanin1 = pFanout;
72 }
73 }
74 else // if ( Fraig_Regular(pPivot->p2) == pFanin )
75 {
76 assert( Fraig_Regular(pPivot->p2) == pFanin );
77 if ( Fraig_Regular(pFanout->p1) == pFanin )
78 {
79 pFanout->pFanFanin1 = pPivot->pFanFanin2;
80 pPivot->pFanFanin2 = pFanout;
81 }
82 else // if ( Fraig_Regular(pFanout->p2) == pFanin )
83 {
84 pFanout->pFanFanin2 = pPivot->pFanFanin2;
85 pPivot->pFanFanin2 = pFanout;
86 }
87 }
88}
Fraig_Node_t * pFanFanin1
Definition fraigInt.h:257
Fraig_Node_t * pFanFanin2
Definition fraigInt.h:258
Fraig_Node_t * pFanPivot
Definition fraigInt.h:256
Here is the caller graph for this function:

◆ Fraig_NodeAndCanon()

Fraig_Node_t * Fraig_NodeAndCanon ( Fraig_Man_t * pMan,
Fraig_Node_t * p1,
Fraig_Node_t * p2 )
extern

FUNCTION DEFINITIONS ///.

FUNCTION DEFINITIONS ///.

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

FileName [fraigCanon.c]

PackageName [FRAIG: Functionally reduced AND-INV graphs.]

Synopsis [AND-node creation and elementary AND-operation.]

Author [Alan Mishchenko alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - October 1, 2004]

Revision [

Id
fraigCanon.c,v 1.4 2005/07/08 01:01:31 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [The internal AND operation for the two FRAIG nodes.]

Description [This procedure is the core of the FRAIG package, because it performs the two-step canonicization of FRAIG nodes. The first step involves the lookup in the structural hash table (which hashes two ANDs into a node that has them as fanins, if such a node exists). If the node is not found in the structural hash table, an attempt is made to find a functionally equivalent node in another hash table (which hashes the simulation info into the nodes, which has this simulation info). Some tricks used on the way are described in the comments to the code and in the paper "FRAIGs: Functionally reduced AND-INV graphs".]

SideEffects []

SeeAlso []

Definition at line 52 of file fraigCanon.c.

53{
54 Fraig_Node_t * pNodeNew, * pNodeOld, * pNodeRepr;
55 int fUseSatCheck;
56// int RetValue;
57
58 // check for trivial cases
59 if ( p1 == p2 )
60 return p1;
61 if ( p1 == Fraig_Not(p2) )
62 return Fraig_Not(pMan->pConst1);
63 if ( Fraig_NodeIsConst(p1) )
64 {
65 if ( p1 == pMan->pConst1 )
66 return p2;
67 return Fraig_Not(pMan->pConst1);
68 }
69 if ( Fraig_NodeIsConst(p2) )
70 {
71 if ( p2 == pMan->pConst1 )
72 return p1;
73 return Fraig_Not(pMan->pConst1);
74 }
75/*
76 // check for less trivial cases
77 if ( Fraig_IsComplement(p1) )
78 {
79 if ( RetValue = Fraig_NodeIsInSupergate( Fraig_Regular(p1), p2 ) )
80 {
81 if ( RetValue == -1 )
82 pMan->nImplies0++;
83 else
84 pMan->nImplies1++;
85
86 if ( RetValue == -1 )
87 return p2;
88 }
89 }
90 else
91 {
92 if ( RetValue = Fraig_NodeIsInSupergate( p1, p2 ) )
93 {
94 if ( RetValue == 1 )
95 pMan->nSimplifies1++;
96 else
97 pMan->nSimplifies0++;
98
99 if ( RetValue == 1 )
100 return p1;
101 return Fraig_Not(pMan->pConst1);
102 }
103 }
104
105 if ( Fraig_IsComplement(p2) )
106 {
107 if ( RetValue = Fraig_NodeIsInSupergate( Fraig_Regular(p2), p1 ) )
108 {
109 if ( RetValue == -1 )
110 pMan->nImplies0++;
111 else
112 pMan->nImplies1++;
113
114 if ( RetValue == -1 )
115 return p1;
116 }
117 }
118 else
119 {
120 if ( RetValue = Fraig_NodeIsInSupergate( p2, p1 ) )
121 {
122 if ( RetValue == 1 )
123 pMan->nSimplifies1++;
124 else
125 pMan->nSimplifies0++;
126
127 if ( RetValue == 1 )
128 return p2;
129 return Fraig_Not(pMan->pConst1);
130 }
131 }
132*/
133 // perform level-one structural hashing
134 if ( Fraig_HashTableLookupS( pMan, p1, p2, &pNodeNew ) ) // the node with these children is found
135 {
136 // if the existent node is part of the cone of unused logic
137 // (that is logic feeding the node which is equivalent to the given node)
138 // return the canonical representative of this node
139 // determine the phase of the given node, with respect to its canonical form
140 pNodeRepr = Fraig_Regular(pNodeNew)->pRepr;
141 if ( pMan->fFuncRed && pNodeRepr )
142 return Fraig_NotCond( pNodeRepr, Fraig_IsComplement(pNodeNew) ^ Fraig_NodeComparePhase(Fraig_Regular(pNodeNew), pNodeRepr) );
143 // otherwise, the node is itself a canonical representative, return it
144 return pNodeNew;
145 }
146 // the same node is not found, but the new one is created
147
148 // if one level hashing is requested (without functionality hashing), return
149 if ( !pMan->fFuncRed )
150 return pNodeNew;
151
152 // check if the new node is unique using the simulation info
153 if ( pNodeNew->nOnes == 0 || pNodeNew->nOnes == (unsigned)pMan->nWordsRand * 32 )
154 {
155 pMan->nSatZeros++;
156 if ( !pMan->fDoSparse ) // if we do not do sparse functions, skip
157 return pNodeNew;
158 // check the sparse function simulation hash table
159 pNodeOld = Fraig_HashTableLookupF0( pMan, pNodeNew );
160 if ( pNodeOld == NULL ) // the node is unique (it is added to the table)
161 return pNodeNew;
162 }
163 else
164 {
165 // check the simulation hash table
166 pNodeOld = Fraig_HashTableLookupF( pMan, pNodeNew );
167 if ( pNodeOld == NULL ) // the node is unique
168 return pNodeNew;
169 }
170 assert( pNodeOld->pRepr == 0 );
171 // there is another node which looks the same according to simulation
172
173 // use SAT to resolve the ambiguity
174 fUseSatCheck = (pMan->nInspLimit == 0 || Fraig_ManReadInspects(pMan) < pMan->nInspLimit);
175 if ( fUseSatCheck && Fraig_NodeIsEquivalent( pMan, pNodeOld, pNodeNew, pMan->nBTLimit, 1000000 ) )
176 {
177 // set the node to be equivalent with this node
178 // to prevent loops, only set if the old node is not in the TFI of the new node
179 // the loop may happen in the following case: suppose
180 // NodeC = AND(NodeA, NodeB) and at the same time NodeA => NodeB
181 // in this case, NodeA and NodeC are functionally equivalent
182 // however, NodeA is a fanin of node NodeC (this leads to the loop)
183 // add the node to the list of equivalent nodes or dereference it
184 if ( pMan->fChoicing && !Fraig_CheckTfi( pMan, pNodeOld, pNodeNew ) )
185 {
186 // if the old node is not in the TFI of the new node and choicing
187 // is enabled, add the new node to the list of equivalent ones
188 pNodeNew->pNextE = pNodeOld->pNextE;
189 pNodeOld->pNextE = pNodeNew;
190 }
191 // set the canonical representative of this node
192 pNodeNew->pRepr = pNodeOld;
193 // return the equivalent node
194 return Fraig_NotCond( pNodeOld, Fraig_NodeComparePhase(pNodeOld, pNodeNew) );
195 }
196
197 // now we add another member to this simulation class
198 if ( pNodeNew->nOnes == 0 || pNodeNew->nOnes == (unsigned)pMan->nWordsRand * 32 )
199 {
200 Fraig_Node_t * pNodeTemp;
201 assert( pMan->fDoSparse );
202 pNodeTemp = Fraig_HashTableLookupF0( pMan, pNodeNew );
203// assert( pNodeTemp == NULL );
204// Fraig_HashTableInsertF0( pMan, pNodeNew );
205 }
206 else
207 {
208 pNodeNew->pNextD = pNodeOld->pNextD;
209 pNodeOld->pNextD = pNodeNew;
210 }
211 // return the new node
212 assert( pNodeNew->pRepr == 0 );
213 return pNodeNew;
214}
Fraig_Node_t * Fraig_HashTableLookupF(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigTable.c:136
int Fraig_HashTableLookupS(Fraig_Man_t *pMan, Fraig_Node_t *p1, Fraig_Node_t *p2, Fraig_Node_t **ppNodeRes)
Definition fraigTable.c:90
Fraig_Node_t * Fraig_HashTableLookupF0(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigTable.c:193
int Fraig_ManReadInspects(Fraig_Man_t *p)
Definition fraigApi.c:75
int Fraig_NodeIsConst(Fraig_Node_t *p)
Definition fraigApi.c:151
#define Fraig_Not(p)
Definition fraig.h:109
int Fraig_NodeComparePhase(Fraig_Node_t *p1, Fraig_Node_t *p2)
Definition fraigApi.c:154
#define Fraig_NotCond(p, c)
Definition fraig.h:110
int Fraig_NodeIsEquivalent(Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit, int nTimeLimit)
Definition fraigSat.c:302
int Fraig_CheckTfi(Fraig_Man_t *pMan, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigUtil.c:173
Fraig_Node_t * pRepr
Definition fraigInt.h:242
Fraig_Node_t * pNextE
Definition fraigInt.h:241
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeAndSimpleCase_rec()

int Fraig_NodeAndSimpleCase_rec ( Fraig_Node_t * pOld,
Fraig_Node_t * pNew )
extern

◆ Fraig_NodeCountPis()

int Fraig_NodeCountPis ( Msat_IntVec_t * vVars,
int nVarsPi )
extern

◆ Fraig_NodeCountSuppVars()

int Fraig_NodeCountSuppVars ( Fraig_Man_t * p,
Fraig_Node_t * pNode,
int fSuppStr )
extern

◆ Fraig_NodeCreate()

Fraig_Node_t * Fraig_NodeCreate ( Fraig_Man_t * p,
Fraig_Node_t * p1,
Fraig_Node_t * p2 )
extern

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

Synopsis [Creates a new node.]

Description [This procedure should be called to create the constant node and the PI nodes first.]

SideEffects []

SeeAlso []

Definition at line 160 of file fraigNode.c.

161{
162 Fraig_Node_t * pNode;
163 abctime clk;
164
165 // create the node
166 pNode = (Fraig_Node_t *)Fraig_MemFixedEntryFetch( p->mmNodes );
167 memset( pNode, 0, sizeof(Fraig_Node_t) );
168
169 // assign the children
170 pNode->p1 = p1; Fraig_Ref(p1); Fraig_Regular(p1)->nRefs++;
171 pNode->p2 = p2; Fraig_Ref(p2); Fraig_Regular(p2)->nRefs++;
172
173 // assign the number and add to the array of nodes
174 pNode->Num = p->vNodes->nSize;
175 Fraig_NodeVecPush( p->vNodes, pNode );
176
177 // assign the PI number
178 pNode->NumPi = -1;
179
180 // compute the level of this node
181 pNode->Level = 1 + Abc_MaxInt(Fraig_Regular(p1)->Level, Fraig_Regular(p2)->Level);
183 pNode->fFailTfo = Fraig_Regular(p1)->fFailTfo | Fraig_Regular(p2)->fFailTfo;
184
185 // derive the simulation info
186clk = Abc_Clock();
187 // allocate memory for the simulation info
188 pNode->puSimR = (unsigned *)Fraig_MemFixedEntryFetch( p->mmSims );
189 pNode->puSimD = pNode->puSimR + p->nWordsRand;
190 // derive random simulation info
191 pNode->uHashR = 0;
192 Fraig_NodeSimulate( pNode, 0, p->nWordsRand, 1 );
193 // derive dynamic simulation info
194 pNode->uHashD = 0;
195 Fraig_NodeSimulate( pNode, 0, p->iWordStart, 0 );
196 // count the number of ones in the random simulation info
197 pNode->nOnes = Fraig_BitStringCountOnes( pNode->puSimR, p->nWordsRand );
198 if ( pNode->fInv )
199 pNode->nOnes = p->nWordsRand * 32 - pNode->nOnes;
200 // add to the runtime of simulation
201p->timeSims += Abc_Clock() - clk;
202
203#ifdef FRAIG_ENABLE_FANOUTS
204 // create the fanout info
207#endif
208 return pNode;
209}
ABC_NAMESPACE_IMPL_START void Fraig_NodeAddFaninFanout(Fraig_Node_t *pFanin, Fraig_Node_t *pFanout)
DECLARATIONS ///.
Definition fraigFanout.c:45
int Fraig_BitStringCountOnes(unsigned *pString, int nWords)
Definition fraigUtil.c:288
#define Fraig_NodeIsSimComplement(p)
DECLARATIONS ///.
Definition fraigNode.c:29
void Fraig_NodeSimulate(Fraig_Node_t *pNode, int iWordStart, int iWordStop, int fUseRand)
Definition fraigNode.c:226
#define Fraig_Ref(p)
Definition fraig.h:113
void Fraig_NodeVecPush(Fraig_NodeVec_t *p, Fraig_Node_t *Entry)
Definition fraigVec.c:189
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeCreateConst()

Fraig_Node_t * Fraig_NodeCreateConst ( Fraig_Man_t * p)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates the constant 1 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file fraigNode.c.

47{
48 Fraig_Node_t * pNode;
49
50 // create the node
51 pNode = (Fraig_Node_t *)Fraig_MemFixedEntryFetch( p->mmNodes );
52 memset( pNode, 0, sizeof(Fraig_Node_t) );
53
54 // assign the number and add to the array of nodes
55 pNode->Num = p->vNodes->nSize;
56 Fraig_NodeVecPush( p->vNodes, pNode );
57 pNode->NumPi = -1; // this is not a PI, so its number is -1
58 pNode->Level = 0; // just like a PI, it has 0 level
59 pNode->nRefs = 1; // it is a persistent node, which comes referenced
60 pNode->fInv = 1; // the simulation info is complemented
61
62 // create the simulation info
63 pNode->puSimR = (unsigned *)Fraig_MemFixedEntryFetch( p->mmSims );
64 pNode->puSimD = pNode->puSimR + p->nWordsRand;
65 memset( pNode->puSimR, 0, sizeof(unsigned) * p->nWordsRand );
66 memset( pNode->puSimD, 0, sizeof(unsigned) * p->nWordsDyna );
67
68 // count the number of ones in the simulation vector
69 pNode->nOnes = p->nWordsRand * sizeof(unsigned) * 8;
70
71 // insert it into the hash table
72 Fraig_HashTableLookupF0( p, pNode );
73 return pNode;
74}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeCreatePi()

Fraig_Node_t * Fraig_NodeCreatePi ( Fraig_Man_t * p)
extern

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

Synopsis [Creates a primary input node.]

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file fraigNode.c.

88{
89 Fraig_Node_t * pNode, * pNodeRes;
90 int i;
91 abctime clk;
92
93 // create the node
94 pNode = (Fraig_Node_t *)Fraig_MemFixedEntryFetch( p->mmNodes );
95 memset( pNode, 0, sizeof(Fraig_Node_t) );
96 pNode->puSimR = (unsigned *)Fraig_MemFixedEntryFetch( p->mmSims );
97 pNode->puSimD = pNode->puSimR + p->nWordsRand;
98 memset( pNode->puSimD, 0, sizeof(unsigned) * p->nWordsDyna );
99
100 // assign the number and add to the array of nodes
101 pNode->Num = p->vNodes->nSize;
102 Fraig_NodeVecPush( p->vNodes, pNode );
103
104 // assign the PI number and add to the array of primary inputs
105 pNode->NumPi = p->vInputs->nSize;
106 Fraig_NodeVecPush( p->vInputs, pNode );
107
108 pNode->Level = 0; // PI has 0 level
109 pNode->nRefs = 1; // it is a persistent node, which comes referenced
110 pNode->fInv = 0; // the simulation info of the PI is not complemented
111
112 // derive the simulation info for the new node
113clk = Abc_Clock();
114 // set the random simulation info for the primary input
115 pNode->uHashR = 0;
116 for ( i = 0; i < p->nWordsRand; i++ )
117 {
118 // generate the simulation info
119 pNode->puSimR[i] = FRAIG_RANDOM_UNSIGNED;
120 // for reasons that take very long to explain, it makes sense to have (0000000...)
121 // pattern in the set (this helps if we need to return the counter-examples)
122 if ( i == 0 )
123 pNode->puSimR[i] <<= 1;
124 // compute the hash key
125 pNode->uHashR ^= pNode->puSimR[i] * s_FraigPrimes[i];
126 }
127 // count the number of ones in the simulation vector
128 pNode->nOnes = Fraig_BitStringCountOnes( pNode->puSimR, p->nWordsRand );
129
130 // set the systematic simulation info for the primary input
131 pNode->uHashD = 0;
132 for ( i = 0; i < p->iWordStart; i++ )
133 {
134 // generate the simulation info
135 pNode->puSimD[i] = FRAIG_RANDOM_UNSIGNED;
136 // compute the hash key
137 pNode->uHashD ^= pNode->puSimD[i] * s_FraigPrimes[i];
138 }
139p->timeSims += Abc_Clock() - clk;
140
141 // insert it into the hash table
142 pNodeRes = Fraig_HashTableLookupF( p, pNode );
143 assert( pNodeRes == NULL );
144 // add to the runtime of simulation
145 return pNode;
146}
#define FRAIG_RANDOM_UNSIGNED
Definition fraigInt.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeGetFanoutNum()

int Fraig_NodeGetFanoutNum ( Fraig_Node_t * pNode)
extern

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

Synopsis [Returns the number of fanouts of a node.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file fraigFanout.c.

165{
166 Fraig_Node_t * pFanout;
167 int Counter = 0;
168 Fraig_NodeForEachFanout( pNode, pFanout )
169 Counter++;
170 return Counter;
171}
#define Fraig_NodeForEachFanout(pNode, pFanout)
Definition fraigInt.h:288

◆ Fraig_NodeIsExor()

int Fraig_NodeIsExor ( Fraig_Node_t * pNode)
extern

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

Synopsis [Returns 1 if the node is EXOR, 0 if it is NEXOR.]

Description [The node should be EXOR type and not complemented.]

SideEffects []

SeeAlso []

Definition at line 633 of file fraigUtil.c.

634{
635 Fraig_Node_t * pNode1;
636 assert( !Fraig_IsComplement(pNode) );
638 assert( Fraig_IsComplement(pNode->p1) );
639 // get children
640 pNode1 = Fraig_Regular(pNode->p1);
641 return Fraig_IsComplement(pNode1->p1) == Fraig_IsComplement(pNode1->p2);
642}
Here is the call graph for this function:

◆ Fraig_NodeIsExorType()

int Fraig_NodeIsExorType ( Fraig_Node_t * pNode)
extern

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

Synopsis [Returns 1 if the node is the root of EXOR/NEXOR gate.]

Description [The node can be complemented.]

SideEffects []

SeeAlso []

Definition at line 558 of file fraigUtil.c.

559{
560 Fraig_Node_t * pNode1, * pNode2;
561 // make the node regular (it does not matter for EXOR/NEXOR)
562 pNode = Fraig_Regular(pNode);
563 // if the node or its children are not ANDs or not compl, this cannot be EXOR type
564 if ( !Fraig_NodeIsAnd(pNode) )
565 return 0;
566 if ( !Fraig_NodeIsAnd(pNode->p1) || !Fraig_IsComplement(pNode->p1) )
567 return 0;
568 if ( !Fraig_NodeIsAnd(pNode->p2) || !Fraig_IsComplement(pNode->p2) )
569 return 0;
570
571 // get children
572 pNode1 = Fraig_Regular(pNode->p1);
573 pNode2 = Fraig_Regular(pNode->p2);
574 assert( pNode1->Num < pNode2->Num );
575
576 // compare grandchildren
577 return pNode1->p1 == Fraig_Not(pNode2->p1) && pNode1->p2 == Fraig_Not(pNode2->p2);
578}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsImplification()

int Fraig_NodeIsImplification ( Fraig_Man_t * p,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew,
int nBTLimit )
extern

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

Synopsis [Checks whether pOld => pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 551 of file fraigSat.c.

552{
553 int RetValue, RetValue1, i, fComp;
554 abctime clk;
555 int fVerbose = 0;
556
557 // make sure the nodes are not complemented
558 assert( !Fraig_IsComplement(pNew) );
559 assert( !Fraig_IsComplement(pOld) );
560 assert( pNew != pOld );
561
562 p->nSatCallsImp++;
563
564 // make sure the solver is allocated and has enough variables
565 if ( p->pSat == NULL )
567 // make sure the SAT solver has enough variables
568 for ( i = Msat_SolverReadVarNum(p->pSat); i < p->vNodes->nSize; i++ )
569 Msat_SolverAddVar( p->pSat, p->vNodes->pArray[i]->Level );
570
571 // get the logic cone
572clk = Abc_Clock();
573 Fraig_OrderVariables( p, pOld, pNew );
574// Fraig_PrepareCones( p, pOld, pNew );
575p->timeTrav += Abc_Clock() - clk;
576
577 if ( fVerbose )
578 printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) );
579
580
581 // get the complemented attribute
582 fComp = Fraig_NodeComparePhase( pOld, pNew );
583//Msat_SolverPrintClauses( p->pSat );
584
586 // prepare the solver to run incrementally on these variables
587//clk = Abc_Clock();
588 Msat_SolverPrepare( p->pSat, p->vVarsInt );
589//p->time3 += Abc_Clock() - clk;
590
591 // solve under assumptions
592 // A = 1; B = 0 OR A = 1; B = 1
593 Msat_IntVecClear( p->vProj );
594 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) );
595 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) );
596 // run the solver
597clk = Abc_Clock();
598 RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, 1000000 );
599p->timeSat += Abc_Clock() - clk;
600
601 if ( RetValue1 == MSAT_FALSE )
602 {
603//p->time1 += Abc_Clock() - clk;
604
605if ( fVerbose )
606{
607// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) );
608//ABC_PRT( "time", Abc_Clock() - clk );
609}
610
611 // add the clause
612 Msat_IntVecClear( p->vProj );
613 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) );
614 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) );
615 RetValue = Msat_SolverAddClause( p->pSat, p->vProj );
616 assert( RetValue );
617// p->nSatProofImp++;
618 return 1;
619 }
620 else if ( RetValue1 == MSAT_TRUE )
621 {
622//p->time2 += Abc_Clock() - clk;
623
624if ( fVerbose )
625{
626// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) );
627//ABC_PRT( "time", Abc_Clock() - clk );
628}
629 // record the counter example
630 Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew );
631 p->nSatCounterImp++;
632 return 0;
633 }
634 else // if ( RetValue1 == MSAT_UNKNOWN )
635 {
636p->time3 += Abc_Clock() - clk;
637 p->nSatFailsImp++;
638 return 0;
639 }
640}
void Fraig_FeedBack(Fraig_Man_t *p, int *pModel, Msat_IntVec_t *vVars, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigFeed.c:80
void Fraig_ManCreateSolver(Fraig_Man_t *p)
Definition fraigMan.c:325
int Fraig_CountPis(Fraig_Man_t *p, Msat_IntVec_t *vVarNums)
Definition fraigUtil.c:817
int Msat_SolverAddClause(Msat_Solver_t *p, Msat_IntVec_t *pLits)
int Msat_SolverSolve(Msat_Solver_t *p, Msat_IntVec_t *pVecAssumps, int nBackTrackLimit, int nTimeLimit)
#define MSAT_VAR2LIT(v, s)
Definition msat.h:56
int Msat_SolverReadVarNum(Msat_Solver_t *p)
FUNCTION DEFINITIONS ///.
@ MSAT_TRUE
Definition msat.h:50
@ MSAT_FALSE
Definition msat.h:50
int * Msat_SolverReadModelArray(Msat_Solver_t *p)
void Msat_SolverPrepare(Msat_Solver_t *pSat, Msat_IntVec_t *vVars)
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition msatVec.c:351
int Msat_SolverAddVar(Msat_Solver_t *p, int Level)
DECLARATIONS ///.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsInSupergate()

int Fraig_NodeIsInSupergate ( Fraig_Node_t * pOld,
Fraig_Node_t * pNew )
extern

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

Synopsis [Checks if pNew exists among the implication fanins of pOld.]

Description [If pNew is an implication fanin of pOld, returns 1. If Fraig_Not(pNew) is an implication fanin of pOld, return -1. Otherwise returns 0.]

SideEffects []

SeeAlso []

Definition at line 905 of file fraigUtil.c.

906{
907 int RetValue1, RetValue2;
908 if ( Fraig_Regular(pOld) == Fraig_Regular(pNew) )
909 return (pOld == pNew)? 1 : -1;
910 if ( Fraig_IsComplement(pOld) || Fraig_NodeIsVar(pOld) )
911 return 0;
912 RetValue1 = Fraig_NodeIsInSupergate( pOld->p1, pNew );
913 RetValue2 = Fraig_NodeIsInSupergate( pOld->p2, pNew );
914 if ( RetValue1 == -1 || RetValue2 == -1 )
915 return -1;
916 if ( RetValue1 == 1 || RetValue2 == 1 )
917 return 1;
918 return 0;
919}
int Fraig_NodeIsInSupergate(Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigUtil.c:905
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsMuxType()

int Fraig_NodeIsMuxType ( Fraig_Node_t * pNode)
extern

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

Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]

Description [The node can be complemented.]

SideEffects []

SeeAlso []

Definition at line 591 of file fraigUtil.c.

592{
593 Fraig_Node_t * pNode1, * pNode2;
594
595 // make the node regular (it does not matter for EXOR/NEXOR)
596 pNode = Fraig_Regular(pNode);
597 // if the node or its children are not ANDs or not compl, this cannot be EXOR type
598 if ( !Fraig_NodeIsAnd(pNode) )
599 return 0;
600 if ( !Fraig_NodeIsAnd(pNode->p1) || !Fraig_IsComplement(pNode->p1) )
601 return 0;
602 if ( !Fraig_NodeIsAnd(pNode->p2) || !Fraig_IsComplement(pNode->p2) )
603 return 0;
604
605 // get children
606 pNode1 = Fraig_Regular(pNode->p1);
607 pNode2 = Fraig_Regular(pNode->p2);
608 assert( pNode1->Num < pNode2->Num );
609
610 // compare grandchildren
611 // node is an EXOR/NEXOR
612 if ( pNode1->p1 == Fraig_Not(pNode2->p1) && pNode1->p2 == Fraig_Not(pNode2->p2) )
613 return 1;
614
615 // otherwise the node is MUX iff it has a pair of equal grandchildren
616 return pNode1->p1 == Fraig_Not(pNode2->p1) ||
617 pNode1->p1 == Fraig_Not(pNode2->p2) ||
618 pNode1->p2 == Fraig_Not(pNode2->p1) ||
619 pNode1->p2 == Fraig_Not(pNode2->p2);
620}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsTravIdCurrent()

int Fraig_NodeIsTravIdCurrent ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1012 of file fraigUtil.c.

1013{
1014 return pNode->TravId2 == pMan->nTravIds2;
1015}
Here is the caller graph for this function:

◆ Fraig_NodeIsTravIdPrevious()

int Fraig_NodeIsTravIdPrevious ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1028 of file fraigUtil.c.

1029{
1030 return pNode->TravId2 == pMan->nTravIds2 - 1;
1031}

◆ Fraig_NodeRecognizeMux()

Fraig_Node_t * Fraig_NodeRecognizeMux ( Fraig_Node_t * pNode,
Fraig_Node_t ** ppNodeT,
Fraig_Node_t ** ppNodeE )
extern

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

Synopsis [Recognizes what nodes are control and data inputs of a MUX.]

Description [If the node is a MUX, returns the control variable C. Assigns nodes T and E to be the then and else variables of the MUX. Node C is never complemented. Nodes T and E can be complemented. This function also recognizes EXOR/NEXOR gates as MUXes.]

SideEffects []

SeeAlso []

Definition at line 658 of file fraigUtil.c.

659{
660 Fraig_Node_t * pNode1, * pNode2;
661 assert( !Fraig_IsComplement(pNode) );
662 assert( Fraig_NodeIsMuxType(pNode) );
663 // get children
664 pNode1 = Fraig_Regular(pNode->p1);
665 pNode2 = Fraig_Regular(pNode->p2);
666 // find the control variable
667 if ( pNode1->p1 == Fraig_Not(pNode2->p1) )
668 {
669 if ( Fraig_IsComplement(pNode1->p1) )
670 { // pNode2->p1 is positive phase of C
671 *ppNodeT = Fraig_Not(pNode2->p2);
672 *ppNodeE = Fraig_Not(pNode1->p2);
673 return pNode2->p1;
674 }
675 else
676 { // pNode1->p1 is positive phase of C
677 *ppNodeT = Fraig_Not(pNode1->p2);
678 *ppNodeE = Fraig_Not(pNode2->p2);
679 return pNode1->p1;
680 }
681 }
682 else if ( pNode1->p1 == Fraig_Not(pNode2->p2) )
683 {
684 if ( Fraig_IsComplement(pNode1->p1) )
685 { // pNode2->p2 is positive phase of C
686 *ppNodeT = Fraig_Not(pNode2->p1);
687 *ppNodeE = Fraig_Not(pNode1->p2);
688 return pNode2->p2;
689 }
690 else
691 { // pNode1->p1 is positive phase of C
692 *ppNodeT = Fraig_Not(pNode1->p2);
693 *ppNodeE = Fraig_Not(pNode2->p1);
694 return pNode1->p1;
695 }
696 }
697 else if ( pNode1->p2 == Fraig_Not(pNode2->p1) )
698 {
699 if ( Fraig_IsComplement(pNode1->p2) )
700 { // pNode2->p1 is positive phase of C
701 *ppNodeT = Fraig_Not(pNode2->p2);
702 *ppNodeE = Fraig_Not(pNode1->p1);
703 return pNode2->p1;
704 }
705 else
706 { // pNode1->p2 is positive phase of C
707 *ppNodeT = Fraig_Not(pNode1->p1);
708 *ppNodeE = Fraig_Not(pNode2->p2);
709 return pNode1->p2;
710 }
711 }
712 else if ( pNode1->p2 == Fraig_Not(pNode2->p2) )
713 {
714 if ( Fraig_IsComplement(pNode1->p2) )
715 { // pNode2->p2 is positive phase of C
716 *ppNodeT = Fraig_Not(pNode2->p1);
717 *ppNodeE = Fraig_Not(pNode1->p1);
718 return pNode2->p2;
719 }
720 else
721 { // pNode1->p2 is positive phase of C
722 *ppNodeT = Fraig_Not(pNode1->p1);
723 *ppNodeE = Fraig_Not(pNode2->p1);
724 return pNode1->p2;
725 }
726 }
727 assert( 0 ); // this is not MUX
728 return NULL;
729}
Here is the call graph for this function:

◆ Fraig_NodeRemoveFaninFanout()

void Fraig_NodeRemoveFaninFanout ( Fraig_Node_t * pFanin,
Fraig_Node_t * pFanoutToRemove )
extern

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

Synopsis [Add the fanout to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file fraigFanout.c.

102{
103 Fraig_Node_t * pFanout, * pFanout2, ** ppFanList;
104 // start the linked list of fanouts
105 ppFanList = &pFanin->pFanPivot;
106 // go through the fanouts
107 Fraig_NodeForEachFanoutSafe( pFanin, pFanout, pFanout2 )
108 {
109 // skip the fanout-to-remove
110 if ( pFanout == pFanoutToRemove )
111 continue;
112 // add useful fanouts to the list
113 *ppFanList = pFanout;
114 ppFanList = Fraig_NodeReadNextFanoutPlace( pFanin, pFanout );
115 }
116 *ppFanList = NULL;
117}
#define Fraig_NodeReadNextFanoutPlace(pNode, pFanout)
Definition fraigInt.h:284
#define Fraig_NodeForEachFanoutSafe(pNode, pFanout, pFanout2)
Definition fraigInt.h:292

◆ Fraig_NodesCompareSupps()

int Fraig_NodesCompareSupps ( Fraig_Man_t * p,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew )
extern

◆ Fraig_NodeSetTravIdCurrent()

void Fraig_NodeSetTravIdCurrent ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 996 of file fraigUtil.c.

997{
998 pNode->TravId2 = pMan->nTravIds2;
999}
Here is the caller graph for this function:

◆ Fraig_NodeSimsContained()

int Fraig_NodeSimsContained ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2 )
extern

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

Synopsis [Returns 1 if siminfo of Node1 is contained in siminfo of Node2.]

Description []

SideEffects []

SeeAlso []

Definition at line 784 of file fraigUtil.c.

785{
786 unsigned * pUnsigned1, * pUnsigned2;
787 int i;
788
789 // compare random siminfo
790 pUnsigned1 = pNode1->puSimR;
791 pUnsigned2 = pNode2->puSimR;
792 for ( i = 0; i < pMan->nWordsRand; i++ )
793 if ( pUnsigned1[i] & ~pUnsigned2[i] )
794 return 0;
795
796 // compare systematic siminfo
797 pUnsigned1 = pNode1->puSimD;
798 pUnsigned2 = pNode2->puSimD;
799 for ( i = 0; i < pMan->iWordStart; i++ )
800 if ( pUnsigned1[i] & ~pUnsigned2[i] )
801 return 0;
802
803 return 1;
804}
Here is the caller graph for this function:

◆ Fraig_NodeSimulate()

void Fraig_NodeSimulate ( Fraig_Node_t * pNode,
int iWordStart,
int iWordStop,
int fUseRand )
extern

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

Synopsis [Simulates the node.]

Description [Simulates the random or dynamic simulation info through the node. Uses phases of the children to determine their real simulation info. Uses phase of the node to determine the way its simulation info is stored. The resulting info is guaranteed to be 0 for the first pattern.]

SideEffects [This procedure modified the hash value of the simulation info.]

SeeAlso []

Definition at line 226 of file fraigNode.c.

227{
228 unsigned * pSims, * pSims1, * pSims2;
229 unsigned uHash;
230 int fCompl, fCompl1, fCompl2, i;
231
232 assert( !Fraig_IsComplement(pNode) );
233
234 // get hold of the simulation information
235 pSims = fUseRand? pNode->puSimR : pNode->puSimD;
236 pSims1 = fUseRand? Fraig_Regular(pNode->p1)->puSimR : Fraig_Regular(pNode->p1)->puSimD;
237 pSims2 = fUseRand? Fraig_Regular(pNode->p2)->puSimR : Fraig_Regular(pNode->p2)->puSimD;
238
239 // get complemented attributes of the children using their random info
240 fCompl = pNode->fInv;
241 fCompl1 = Fraig_NodeIsSimComplement(pNode->p1);
242 fCompl2 = Fraig_NodeIsSimComplement(pNode->p2);
243
244 // simulate
245 uHash = 0;
246 if ( fCompl1 && fCompl2 )
247 {
248 if ( fCompl )
249 for ( i = iWordStart; i < iWordStop; i++ )
250 {
251 pSims[i] = (pSims1[i] | pSims2[i]);
252 uHash ^= pSims[i] * s_FraigPrimes[i];
253 }
254 else
255 for ( i = iWordStart; i < iWordStop; i++ )
256 {
257 pSims[i] = ~(pSims1[i] | pSims2[i]);
258 uHash ^= pSims[i] * s_FraigPrimes[i];
259 }
260 }
261 else if ( fCompl1 && !fCompl2 )
262 {
263 if ( fCompl )
264 for ( i = iWordStart; i < iWordStop; i++ )
265 {
266 pSims[i] = (pSims1[i] | ~pSims2[i]);
267 uHash ^= pSims[i] * s_FraigPrimes[i];
268 }
269 else
270 for ( i = iWordStart; i < iWordStop; i++ )
271 {
272 pSims[i] = (~pSims1[i] & pSims2[i]);
273 uHash ^= pSims[i] * s_FraigPrimes[i];
274 }
275 }
276 else if ( !fCompl1 && fCompl2 )
277 {
278 if ( fCompl )
279 for ( i = iWordStart; i < iWordStop; i++ )
280 {
281 pSims[i] = (~pSims1[i] | pSims2[i]);
282 uHash ^= pSims[i] * s_FraigPrimes[i];
283 }
284 else
285 for ( i = iWordStart; i < iWordStop; i++ )
286 {
287 pSims[i] = (pSims1[i] & ~pSims2[i]);
288 uHash ^= pSims[i] * s_FraigPrimes[i];
289 }
290 }
291 else // if ( !fCompl1 && !fCompl2 )
292 {
293 if ( fCompl )
294 for ( i = iWordStart; i < iWordStop; i++ )
295 {
296 pSims[i] = ~(pSims1[i] & pSims2[i]);
297 uHash ^= pSims[i] * s_FraigPrimes[i];
298 }
299 else
300 for ( i = iWordStart; i < iWordStop; i++ )
301 {
302 pSims[i] = (pSims1[i] & pSims2[i]);
303 uHash ^= pSims[i] * s_FraigPrimes[i];
304 }
305 }
306
307 if ( fUseRand )
308 pNode->uHashR ^= uHash;
309 else
310 pNode->uHashD ^= uHash;
311}
Here is the caller graph for this function:

◆ Fraig_NodeVecSortByRefCount()

void Fraig_NodeVecSortByRefCount ( Fraig_NodeVec_t * p)
extern

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

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 539 of file fraigVec.c.

540{
541 qsort( (void *)p->pArray, (size_t)p->nSize, sizeof(Fraig_Node_t *),
542 (int (*)(const void *, const void *)) Fraig_NodeVecCompareRefCounts );
543}
int Fraig_NodeVecCompareRefCounts(Fraig_Node_t **pp1, Fraig_Node_t **pp2)
Definition fraigVec.c:470
Here is the call graph for this function:

◆ Fraig_PrintBinary()

void Fraig_PrintBinary ( FILE * pFile,
unsigned * pSign,
int nBits )
extern

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

Synopsis [Prints the bit string.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file fraigUtil.c.

403{
404 int Remainder, nWords;
405 int w, i;
406
407 Remainder = (nBits%(sizeof(unsigned)*8));
408 nWords = (nBits/(sizeof(unsigned)*8)) + (Remainder>0);
409
410 for ( w = nWords-1; w >= 0; w-- )
411 for ( i = ((w == nWords-1 && Remainder)? Remainder-1: 31); i >= 0; i-- )
412 fprintf( pFile, "%c", '0' + (int)((pSign[w] & (1<<i)) > 0) );
413
414// fprintf( pFile, "\n" );
415}
Here is the caller graph for this function:

◆ Fraig_TablePrintStatsF()

void Fraig_TablePrintStatsF ( Fraig_Man_t * pMan)
extern

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

Synopsis [Prints stats of the structural table.]

Description []

SideEffects []

SeeAlso []

Definition at line 537 of file fraigTable.c.

538{
539 Fraig_HashTable_t * pT = pMan->pTableF;
540 Fraig_Node_t * pNode;
541 int i, Counter;
542
543 printf( "Functional table. Table size = %d. Number of entries = %d.\n", pT->nBins, pT->nEntries );
544 for ( i = 0; i < pT->nBins; i++ )
545 {
546 Counter = 0;
547 Fraig_TableBinForEachEntryF( pT->pBins[i], pNode )
548 Counter++;
549 if ( Counter > 1 )
550 printf( "{%d} ", Counter );
551 }
552 printf( "\n" );
553}
Fraig_Node_t ** pBins
Definition fraigInt.h:273

◆ Fraig_TablePrintStatsF0()

void Fraig_TablePrintStatsF0 ( Fraig_Man_t * pMan)
extern

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

Synopsis [Prints stats of the structural table.]

Description []

SideEffects []

SeeAlso []

Definition at line 566 of file fraigTable.c.

567{
568 Fraig_HashTable_t * pT = pMan->pTableF0;
569 Fraig_Node_t * pNode;
570 int i, Counter;
571
572 printf( "Zero-node table. Table size = %d. Number of entries = %d.\n", pT->nBins, pT->nEntries );
573 for ( i = 0; i < pT->nBins; i++ )
574 {
575 Counter = 0;
576 Fraig_TableBinForEachEntryF( pT->pBins[i], pNode )
577 Counter++;
578 if ( Counter == 0 )
579 continue;
580/*
581 printf( "\nBin = %4d : Number of entries = %4d\n", i, Counter );
582 Fraig_TableBinForEachEntryF( pT->pBins[i], pNode )
583 printf( "Node %5d. Hash = %10d.\n", pNode->Num, pNode->uHashD );
584*/
585 }
586 printf( "\n" );
587}

◆ Fraig_TablePrintStatsS()

void Fraig_TablePrintStatsS ( Fraig_Man_t * pMan)
extern

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

Synopsis [Prints stats of the structural table.]

Description []

SideEffects []

SeeAlso []

Definition at line 504 of file fraigTable.c.

505{
506 Fraig_HashTable_t * pT = pMan->pTableS;
507 Fraig_Node_t * pNode;
508 int i, Counter;
509
510 printf( "Structural table. Table size = %d. Number of entries = %d.\n", pT->nBins, pT->nEntries );
511 for ( i = 0; i < pT->nBins; i++ )
512 {
513 Counter = 0;
514 Fraig_TableBinForEachEntryS( pT->pBins[i], pNode )
515 Counter++;
516 if ( Counter > 1 )
517 {
518 printf( "%d ", Counter );
519 if ( Counter > 50 )
520 printf( "{%d} ", i );
521 }
522 }
523 printf( "\n" );
524}

◆ Fraig_TableRehashF0()

int Fraig_TableRehashF0 ( Fraig_Man_t * pMan,
int fLinkEquiv )
extern

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

Synopsis [Rehashes the table after the simulation info has changed.]

Description [Assumes that the hash values have been updated after performing additional simulation. Rehashes the table using the new hash values. Uses pNextF to link the entries in the bins. Uses pNextD to link the entries with identical hash values. Returns 1 if the identical entries have been found. Note that identical hash values may mean that the simulation data is different.]

SideEffects []

SeeAlso []

Definition at line 604 of file fraigTable.c.

605{
606 Fraig_HashTable_t * pT = pMan->pTableF0;
607 Fraig_Node_t ** pBinsNew;
608 Fraig_Node_t * pEntF, * pEntF2, * pEnt, * pEntD2, * pEntN;
609 int ReturnValue, Counter, i;
610 unsigned Key;
611
612 // allocate a new array of bins
613 pBinsNew = ABC_ALLOC( Fraig_Node_t *, pT->nBins );
614 memset( pBinsNew, 0, sizeof(Fraig_Node_t *) * pT->nBins );
615
616 // rehash the entries in the table
617 // go through all the nodes in the F-lists (and possible in D-lists, if used)
618 Counter = 0;
619 ReturnValue = 0;
620 for ( i = 0; i < pT->nBins; i++ )
621 Fraig_TableBinForEachEntrySafeF( pT->pBins[i], pEntF, pEntF2 )
622 Fraig_TableBinForEachEntrySafeD( pEntF, pEnt, pEntD2 )
623 {
624 // decide where to put entry pEnt
625 Key = pEnt->uHashD % pT->nBins;
626 if ( fLinkEquiv )
627 {
628 // go through the entries in the new bin
629 Fraig_TableBinForEachEntryF( pBinsNew[Key], pEntN )
630 {
631 // if they have different values skip
632 if ( pEnt->uHashD != pEntN->uHashD )
633 continue;
634 // they have the same hash value, add pEnt to the D-list pEnt3
635 pEnt->pNextD = pEntN->pNextD;
636 pEntN->pNextD = pEnt;
637 ReturnValue = 1;
638 Counter++;
639 break;
640 }
641 if ( pEntN != NULL ) // already linked
642 continue;
643 // we did not find equal entry
644 }
645 // link the new entry
646 pEnt->pNextF = pBinsNew[Key];
647 pBinsNew[Key] = pEnt;
648 pEnt->pNextD = NULL;
649 Counter++;
650 }
651 assert( Counter == pT->nEntries );
652 // replace the table and the parameters
653 ABC_FREE( pT->pBins );
654 pT->pBins = pBinsNew;
655 return ReturnValue;
656}
#define Fraig_TableBinForEachEntrySafeF(pBin, pEnt, pEnt2)
Definition fraigInt.h:316
#define Fraig_TableBinForEachEntrySafeD(pBin, pEnt, pEnt2)
Definition fraigInt.h:327
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ s_FraigPrimes

int s_FraigPrimes[FRAIG_MAX_PRIMES]
extern

DECLARATIONS ///.

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

FileName [fraigPrime.c]

PackageName [FRAIG: Functionally reduced AND-INV graphs.]

Synopsis [The table of the first 1000 primes.]

Author [Alan Mishchenko alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - October 1, 2004]

Revision [

Id
fraigPrime.c,v 1.4 2005/07/08 01:01:32 alanmi Exp

]

Definition at line 30 of file fraigPrime.c.

30 { 2, 3, 5,
317, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
32101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
33193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,
34293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401,
35409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
36521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631,
37641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751,
38757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877,
39881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,
401009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091,
411093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193,
421201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,
431297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
441427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493,
451499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601,
461607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699,
471709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
481823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931,
491933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029,
502039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137,
512141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267,
522269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,
532371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459,
542467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593,
552609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693,
562699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791,
572797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903,
582909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023,
593037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167,
603169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271,
613299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373,
623389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511,
633517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607,
643613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709,
653719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833,
663847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931,
673943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057,
684073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177,
694201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283,
704289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423,
714441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547,
724549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657,
734663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789,
744793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931,
754933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011,
765021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147,
775153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279,
785281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413,
795417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507,
805519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647,
815651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743,
825749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857,
835861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007,
846011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121,
856131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247,
866257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343,
876353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473,
886481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607,
896619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733,
906737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857,
916863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971,
926977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103,
937109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229,
947237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369,
957393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517,
967523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603,
977607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723,
987727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873,
997877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009,
1008011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123,
1018147, 8161 };