ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraigFeed.c File Reference
#include "fraigInt.h"
Include dependency graph for fraigFeed.c:

Go to the source code of this file.

Functions

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)
 
int Fraig_FeedBackCompress (Fraig_Man_t *p)
 
int * Fraig_ManAllocCounterExample (Fraig_Man_t *p)
 
int Fraig_ManSimulateBitNode_rec (Fraig_Man_t *p, Fraig_Node_t *pNode)
 
int Fraig_ManSimulateBitNode (Fraig_Man_t *p, Fraig_Node_t *pNode, int *pModel)
 
int * Fraig_ManSaveCounterExample (Fraig_Man_t *p, Fraig_Node_t *pNode)
 

Function Documentation

◆ Fraig_FeedBack()

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

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}
int nWords
Definition abcNpn.c:127
ABC_INT64_T abctime
Definition abc_global.h:332
Cube * p
Definition exorList.c:222
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
#define assert(ex)
Definition util_old.h:213
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)

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_BitStringHasBit(p, i)
Definition fraigInt.h:81
#define FRAIG_MASK(n)
Definition fraigInt.h:70
#define FRAIG_NUM_WORDS(n)
Definition fraigInt.h:72
#define Fraig_BitStringSetBit(p, i)
Definition fraigInt.h:79
int s_FraigPrimes[FRAIG_MAX_PRIMES]
DECLARATIONS ///.
Definition fraigPrime.c:30
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition msatVec.c:335
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition msatVec.c:217
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)

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
Fraig_NodeVec_t * Fraig_NodeVecAlloc(int nCap)
DECLARATIONS ///.
Definition fraigVec.c:43
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_ManAllocCounterExample()

int * Fraig_ManAllocCounterExample ( Fraig_Man_t * p)

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}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManSaveCounterExample()

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

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}
#define ABC_FREE(obj)
Definition abc_global.h:267
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
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition fraig.h:107
#define Fraig_Regular(p)
Definition fraig.h:108
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManSimulateBitNode()

int Fraig_ManSimulateBitNode ( Fraig_Man_t * p,
Fraig_Node_t * pNode,
int * pModel )

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

Synopsis [Simulates one bit.]

Description []

SideEffects []

SeeAlso []

Definition at line 832 of file fraigFeed.c.

833{
834 int fCompl, RetValue, i;
835 // set the PI values
837 for ( i = 0; i < p->vInputs->nSize; i++ )
838 {
839 Fraig_NodeSetTravIdCurrent( p, p->vInputs->pArray[i] );
840 p->vInputs->pArray[i]->fMark3 = pModel[i];
841 }
842 // perform the traversal
843 fCompl = Fraig_IsComplement(pNode);
844 RetValue = Fraig_ManSimulateBitNode_rec( p, Fraig_Regular(pNode) );
845 return fCompl ^ RetValue;
846}
int Fraig_ManSimulateBitNode_rec(Fraig_Man_t *p, Fraig_Node_t *pNode)
Definition fraigFeed.c:807
void Fraig_NodeSetTravIdCurrent(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigUtil.c:996
void Fraig_ManIncrementTravId(Fraig_Man_t *pMan)
Definition fraigUtil.c:980
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManSimulateBitNode_rec()

int Fraig_ManSimulateBitNode_rec ( Fraig_Man_t * p,
Fraig_Node_t * pNode )

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

Synopsis [Saves the counter example.]

Description []

SideEffects []

SeeAlso []

Definition at line 807 of file fraigFeed.c.

808{
809 int Value0, Value1;
810 if ( Fraig_NodeIsTravIdCurrent( p, pNode ) )
811 return pNode->fMark3;
813 Value0 = Fraig_ManSimulateBitNode_rec( p, Fraig_Regular(pNode->p1) );
814 Value1 = Fraig_ManSimulateBitNode_rec( p, Fraig_Regular(pNode->p2) );
815 Value0 ^= Fraig_IsComplement(pNode->p1);
816 Value1 ^= Fraig_IsComplement(pNode->p2);
817 pNode->fMark3 = Value0 & Value1;
818 return pNode->fMark3;
819}
int Fraig_NodeIsTravIdCurrent(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigUtil.c:1012
Fraig_Node_t * p2
Definition fraigInt.h:233
Fraig_Node_t * p1
Definition fraigInt.h:232
Here is the call graph for this function:
Here is the caller graph for this function: