32static int Sim_ComputeSuppRound(
Sim_Man_t *
p,
int fUseTargets );
33static int Sim_ComputeSuppRoundNode(
Sim_Man_t *
p,
int iNumCi,
int fUseTargets );
34static void Sim_ComputeSuppSetTargets(
Sim_Man_t *
p );
36static void Sim_UtilAssignRandom(
Sim_Man_t *
p );
37static void Sim_UtilAssignFromFifo(
Sim_Man_t *
p );
38static void Sim_SolveTargetsUsingSat(
Sim_Man_t *
p,
int nCounters );
39static int Sim_SolveSuppModelVerify(
Abc_Ntk_t * pNtk,
int * pModel,
int Input,
int Output );
61 unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
74 pSimmNode = (
unsigned *)vSuppStr->pArray[ pNode->
Id ];
75 pSimmNode1 = (
unsigned *)vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
76 pSimmNode2 = (
unsigned *)vSuppStr->pArray[ Abc_ObjFaninId1(pNode) ];
77 for ( k = 0; k < nSuppWords; k++ )
78 pSimmNode[k] = pSimmNode1[k] | pSimmNode2[k];
83 pSimmNode = (
unsigned *)vSuppStr->pArray[ pNode->
Id ];
84 pSimmNode1 = (
unsigned *)vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
85 for ( k = 0; k < nSuppWords; k++ )
86 pSimmNode[k] = pSimmNode1[k];
116 Sim_UtilAssignRandom(
p );
117 Sim_ComputeSuppRound(
p, 0 );
120 Sim_ComputeSuppSetTargets(
p );
122 printf(
"Number of support targets after simulation = %5d.\n", Vec_VecSizeSize(
p->vSuppTargs) );
123 if ( Vec_VecSizeSize(
p->vSuppTargs) == 0 )
126 for ( i = 0; i < 1; i++ )
129 Sim_UtilAssignRandom(
p );
130 nSolved = Sim_ComputeSuppRound(
p, 1 );
131 if ( Vec_VecSizeSize(
p->vSuppTargs) == 0 )
135 printf(
"Targets = %5d. Solved = %5d. Fifo = %5d.\n",
136 Vec_VecSizeSize(
p->vSuppTargs), nSolved, Vec_PtrSize(
p->vFifo) );
140 while ( Vec_VecSizeSize(
p->vSuppTargs) > 0 )
143 Sim_SolveTargetsUsingSat(
p,
p->nSimWords/
p->nSuppWords );
145 Sim_UtilAssignFromFifo(
p );
146 nSolved = Sim_ComputeSuppRound(
p, 1 );
149 printf(
"Targets = %5d. Solved = %5d. Fifo = %5d. SAT runs = %3d.\n",
150 Vec_VecSizeSize(
p->vSuppTargs), nSolved, Vec_PtrSize(
p->vFifo),
p->nSatRuns );
154p->timeTotal = Abc_Clock() - clk;
155 vResult =
p->vSuppFun;
172int Sim_ComputeSuppRound(
Sim_Man_t *
p,
int fUseTargets )
180p->timeSim += Abc_Clock() - clk;
182 for ( i =
p->iInput; i < p->nInputs; i++ )
184 vTargets = (
Vec_Ptr_t *)
p->vSuppTargs->pArray[i];
185 if ( fUseTargets && vTargets->nSize == 0 )
187 Counter += Sim_ComputeSuppRoundNode(
p, i, fUseTargets );
203int Sim_ComputeSuppRoundNode(
Sim_Man_t *
p,
int iNumCi,
int fUseTargets )
210 int i, k, v, Output, LuckyPat, fType0, fType1;
218 pNodeCi = Abc_NtkCi(
p->pNtk, iNumCi );
220p->timeTrav += Abc_Clock() - clk;
226 fType0 = Abc_NodeIsTravIdCurrent( Abc_ObjFanin0(pNode) );
227 fType1 = Abc_NodeIsTravIdCurrent( Abc_ObjFanin1(pNode) );
230p->timeSim += Abc_Clock() - clk;
235 vTargets = (
Vec_Ptr_t *)
p->vSuppTargs->pArray[iNumCi];
236 for ( i = vTargets->nSize - 1; i >= 0; i-- )
239 Output = (int)(ABC_PTRUINT_T)vTargets->pArray[i];
241 pNode = Abc_ObjFanin0( Abc_NtkCo(
p->pNtk, Output) );
243 assert( Abc_NodeIsTravIdCurrent(pNode) );
250 Vec_PtrRemove( vTargets, vTargets->pArray[i] );
252 printf(
"(%d,%d) ", iNumCi, Output );
262 if ( !fFirst &&
p->vFifo->nSize > 1000 )
269 pPat->
Input = iNumCi;
274 Vec_PtrPush(
p->vFifo, pPat );
280if ( fVerbose && Counter )
287 if ( !Abc_NodeIsTravIdCurrent( pNode ) )
299 Vec_VecFree( vNodesByLevel );
314void Sim_ComputeSuppSetTargets(
Sim_Man_t *
p )
317 unsigned * pSuppStr, * pSuppFun;
321 pSuppStr = (
unsigned *)
p->vSuppStr->pArray[pNode->
Id];
322 pSuppFun = (
unsigned *)
p->vSuppFun->pArray[i];
326 Vec_VecPush(
p->vSuppTargs, Num, (
void *)(ABC_PTRUINT_T)i );
349 pSimInfo = (
unsigned *)
p->vSim0->pArray[pNode->
Id];
350 for ( k = 0; k <
p->nSimWords; k++ )
372 int nWordsNew, iWord, iWordLim, i, w;
376 for ( iWord = 0;
p->vFifo->nSize > 0; iWord = iWordLim )
384 iWordLim = iWord + 1;
387 iEnd = Abc_MinInt( iBeg + 32,
p->nInputs );
391 pNode = Abc_NtkCi(
p->pNtk,i);
392 pSimInfo = (
unsigned *)
p->vSim0->pArray[pNode->
Id];
398 if ( i >= iBeg && i < iEnd )
405 nWordsNew =
p->nSuppWords;
408 iWordLim = (iWord + nWordsNew <
p->nSimWords)? iWord + nWordsNew :
p->nSimWords;
412 pSimInfo = (
unsigned *)
p->vSim0->pArray[pNode->
Id];
415 for ( w = iWord; w < iWordLim; w++ )
420 for ( w = iWord; w < iWordLim; w++ )
431 if ( iWordLim ==
p->nSimWords )
449void Sim_SolveTargetsUsingSat(
Sim_Man_t *
p,
int Limit )
458 int RetValue, Output, Input, k, v;
467 Output = (int)(ABC_PTRUINT_T)pEntry;
478p->timeFraig += Abc_Clock() - clk;
481p->timeSat += Abc_Clock() - clk;
490 Vec_PtrRemove( (
Vec_Ptr_t *)
p->vSuppTargs->pArray[Input], pEntry );
497 assert( Sim_SolveSuppModelVerify(
p->pNtk, pModel, Input, Output ) );
507 Vec_PtrPush(
p->vFifo, pPat );
551 if ( Abc_NodeIsTravIdCurrent( pNode ) )
552 return (
int)(ABC_PTRUINT_T)pNode->
pCopy;
553 Abc_NodeSetTravIdCurrent( pNode );
556 if ( Abc_ObjFaninC0(pNode) )
558 if ( Abc_ObjFaninC1(pNode) )
561 return Value0 & Value1;
575int Sim_SolveSuppModelVerify(
Abc_Ntk_t * pNtk,
int * pModel,
int Input,
int Output )
580 Abc_NtkIncrementTravId( pNtk );
583 Abc_NodeSetTravIdCurrent( pNode );
584 if ( pNode == Abc_NtkCi(pNtk,Input) )
586 else if ( pModel[i] == 1 )
594 return RetValue == 1 || RetValue == 2;
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL Vec_Vec_t * Abc_DfsLevelized(Abc_Obj_t *pNode, int fTfi)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL Abc_Ntk_t * Abc_NtkMiterForCofactors(Abc_Ntk_t *pNtk, int Out, int In1, int In2)
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL void * Abc_NtkToFraig(Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Fraig_ManProveMiter(Fraig_Man_t *p)
void Fraig_ManFree(Fraig_Man_t *pMan)
int Fraig_ManCheckMiter(Fraig_Man_t *p)
void Fraig_ParamsSetDefault(Fraig_Params_t *pParams)
int * Fraig_ManReadModel(Fraig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Fraig_ManStruct_t_ Fraig_Man_t
INCLUDES ///.
struct Fraig_ParamsStruct_t_ Fraig_Params_t
int Sim_NtkSimTwoPats_rec(Abc_Obj_t *pNode)
Vec_Ptr_t * Sim_ComputeStrSupp(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Vec_Ptr_t * Sim_ComputeFunSupp(Abc_Ntk_t *pNtk, int fVerbose)
struct Sim_Pat_t_ Sim_Pat_t
int Sim_UtilInfoCompare(Sim_Man_t *p, Abc_Obj_t *pNode)
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
void Sim_ManPatFree(Sim_Man_t *p, Sim_Pat_t *pPat)
Sim_Pat_t * Sim_ManPatAlloc(Sim_Man_t *p)
void Sim_UtilInfoDetectNews(unsigned *pInfo1, unsigned *pInfo2, int nWords, Vec_Int_t *vDiffs)
struct Sim_Man_t_ Sim_Man_t
#define Sim_SuppFunHasVar(vSupps, Output, v)
void Sim_UtilInfoFlip(Sim_Man_t *p, Abc_Obj_t *pNode)
#define SIM_RANDOM_UNSIGNED
Sim_Man_t * Sim_ManStart(Abc_Ntk_t *pNtk, int fLightweight)
void Sim_ManStop(Sim_Man_t *p)
void Sim_UtilSimulate(Sim_Man_t *p, int fFirst)
void Sim_UtilSimulateNode(Sim_Man_t *p, Abc_Obj_t *pNode, int fType, int fType1, int fType2)
#define Sim_SuppFunSetVar(vSupps, Output, v)
void Sim_UtilInfoDetectDiffs(unsigned *pInfo1, unsigned *pInfo2, int nWords, Vec_Int_t *vDiffs)
#define Sim_SimInfoHasVar(vSupps, pNode, v)
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
#define Sim_SuppStrSetVar(vSupps, pNode, v)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
#define Vec_VecForEachEntryReverse(Type, vGlob, pEntry, i, k)
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.