49 int i, nBytes =
sizeof(
Amap_Cut_t) +
sizeof(
int);
50 char * pBuffer =
ABC_ALLOC(
char, Amap_ManPiNum(
p) * nBytes );
57 pCut->
Fans[0] = Abc_Var2Lit( pObj->
Id, 0 );
86 iFan = Abc_Var2Lit( pNew->
iMat, pNew->
fInv );
87 if (
p->ppCutsTemp[ iFan ] == NULL )
88 Vec_IntPushOrder(
p->vTemp, iFan );
89 *Amap_ManCutNextP( pNew ) =
p->ppCutsTemp[ iFan ];
90 p->ppCutsTemp[ iFan ] = pNew;
116 for ( i = 0; i < (int)pCut0->
nFans; i++ )
118 for ( i = 0; i < (int)pCut1->
nFans; i++ )
121 if (
p->ppCutsTemp[ pCut->
iMat ] == NULL )
122 Vec_IntPushOrder(
p->vTemp, pCut->
iMat );
123 *Amap_ManCutNextP( pCut ) =
p->ppCutsTemp[ pCut->
iMat ];
124 p->ppCutsTemp[ pCut->
iMat ] = pCut;
149 for ( i = 0; i < (int)pCut0->
nFans; i++ )
151 for ( i = 0; i < (int)pCut1->
nFans; i++ )
153 for ( i = 0; i < (int)pCut2->
nFans; i++ )
156 if (
p->ppCutsTemp[ pCut->
iMat ] == NULL )
157 Vec_IntPushOrder(
p->vTemp, pCut->
iMat );
158 *Amap_ManCutNextP( pCut ) =
p->ppCutsTemp[ pCut->
iMat ];
159 p->ppCutsTemp[ pCut->
iMat ] = pCut;
176 int nMaxCuts =
p->pPars->nCutsMax;
179 int i,
nWords, Entry, nCuts, nCuts2;
186 for ( pCut =
p->ppCutsTemp[Entry]; pCut; pCut = *Amap_ManCutNextP(pCut) )
189 if ( nCuts < nMaxCuts )
201 pNext->
Fans[0] = Abc_Var2Lit(pNode->
Id, 0);
207 for ( pCut =
p->ppCutsTemp[Entry]; pCut; pCut = *Amap_ManCutNextP(pCut) )
210 if ( nCuts2 < nMaxCuts )
212 memcpy( pNext, pCut,
sizeof(
int) * (pCut->
nFans + 1) );
216 p->ppCutsTemp[Entry] = NULL;
218 assert( nCuts == nCuts2 );
221 Vec_IntClear(
p->vTemp );
223 for ( i = 0; i < 2*
p->pLib->nNodes; i++ )
224 if (
p->ppCutsTemp[i] != NULL )
225 printf(
"Amap_ManCutSaveStored(): Error!\n" );
227 pNode->
nCuts = Abc_MinInt( nCuts, nMaxCuts-1 );
228 assert( nCuts < (1<<20) );
259 int Entry, c0, c1, iCompl0, iCompl1, iFan0, iFan1;
264 iCompl0 = pCut0->
fInv ^ Amap_ObjFaninC0(pNode);
265 iCompl1 = pCut1->
fInv ^ Amap_ObjFaninC1(pNode);
266 iFan0 = !pCut0->
iMat? 0: Abc_Var2Lit( pCut0->
iMat, iCompl0 );
267 iFan1 = !pCut1->
iMat? 0: Abc_Var2Lit( pCut1->
iMat, iCompl1 );
269 Counter += ( Entry >=0 );
291 printf(
"NODE %5d : Type = ", pNode->
Id );
298 printf(
" Cuts = %d\n", pNode->
nCuts );
301 printf(
"%3d : Mat= %3d Inv=%d ", c, pCut->
iMat, pCut->
fInv );
302 for ( i = 0; i < (int)pCut->
nFans; i++ )
303 printf(
"%d%c ", Abc_Lit2Var(pCut->
Fans[i]), Abc_LitIsCompl(pCut->
Fans[i])?
'-':
'+' );
325 for ( pTemp = pNode; pTemp; pTemp = Amap_ObjChoice(
p, pTemp) )
355 Vec_PtrClear( vCuts );
358 iCompl = pCut->
fInv ^ fComplFanin;
359 iFan = !pCut->
iMat? 0: Abc_Var2Lit( pCut->
iMat, iCompl );
361 Vec_PtrPush( vCuts, pCut );
363 return Vec_PtrSize(vCuts) == 0;
383 int fComplFanin0 = Amap_ObjFaninC0( pNode );
384 int fComplFanin1 = Amap_ObjFaninC1( pNode );
385 int fComplFanin2 = Amap_ObjFaninC2( pNode );
392 for ( x = 0; x < Vec_IntSize(vRules); x += 4 )
394 if (
Amap_ManFindCut( pNode, pFanin0, fComplFanin0, Vec_IntEntry(vRules, x),
p->vCuts0 ) )
396 if (
Amap_ManFindCut( pNode, pFanin1, fComplFanin1, Vec_IntEntry(vRules, x+1),
p->vCuts1 ) )
398 if (
Amap_ManFindCut( pNode, pFanin2, fComplFanin2, Vec_IntEntry(vRules, x+2),
p->vCuts2 ) )
404 Amap_Nod_t * pNod = Amap_LibNod(
p->pLib, Vec_IntEntry(vRules, x+3) );
405 if ( pNod->
pSets == NULL )
408 if ( pCut0->
nFans == 1 && (pCut0->
fInv ^ fComplFanin0) )
409 pCut0->
Fans[0] = Abc_LitNot(pCut0->
Fans[0]);
410 if ( pCut1->
nFans == 1 && (pCut1->
fInv ^ fComplFanin1) )
411 pCut1->
Fans[0] = Abc_LitNot(pCut1->
Fans[0]);
412 if ( pCut2->
nFans == 1 && (pCut2->
fInv ^ fComplFanin2) )
413 pCut2->
Fans[0] = Abc_LitNot(pCut2->
Fans[0]);
417 if ( pCut0->
nFans == 1 && (pCut0->
fInv ^ fComplFanin0) )
418 pCut0->
Fans[0] = Abc_LitNot(pCut0->
Fans[0]);
419 if ( pCut1->
nFans == 1 && (pCut1->
fInv ^ fComplFanin1) )
420 pCut1->
Fans[0] = Abc_LitNot(pCut1->
Fans[0]);
421 if ( pCut2->
nFans == 1 && (pCut2->
fInv ^ fComplFanin2) )
422 pCut2->
Fans[0] = Abc_LitNot(pCut2->
Fans[0]);
426 p->nCutsUsed += pNode->
nCuts;
448 int ** pRules, Entry, i, k, c, iCompl0, iCompl1, iFan0, iFan1;
459 iCompl0 = pCut0->
fInv ^ Amap_ObjFaninC0(pNode);
460 iFan0 = !pCut0->
iMat? 0: Abc_Var2Lit( pCut0->
iMat, iCompl0 );
462 if ( pCut0->
nFans == 1 && iCompl0 )
463 pCut0->
Fans[0] = Abc_LitNot(pCut0->
Fans[0]);
465 for ( i = 0; (Entry = pRules[iFan0][i]); i++ )
466 p->pMatsTemp[Entry & 0xffff] = (Entry >> 16);
470 iCompl1 = pCut1->
fInv ^ Amap_ObjFaninC1(pNode);
471 iFan1 = !pCut1->
iMat? 0: Abc_Var2Lit( pCut1->
iMat, iCompl1 );
472 if (
p->pMatsTemp[iFan1] == 0 )
475 if ( pCut1->
nFans == 1 && iCompl1 )
476 pCut1->
Fans[0] = Abc_LitNot(pCut1->
Fans[0]);
478 if ( iFan0 >= iFan1 )
483 if ( pCut1->
nFans == 1 && iCompl1 )
484 pCut1->
Fans[0] = Abc_LitNot(pCut1->
Fans[0]);
487 if ( pCut0->
nFans == 1 && iCompl0 )
488 pCut0->
Fans[0] = Abc_LitNot(pCut0->
Fans[0]);
490 for ( i = 0; (Entry = pRules[iFan0][i]); i++ )
491 p->pMatsTemp[Entry & 0xffff] = 0;
494 p->nCutsUsed += pNode->
nCuts;
522 if (
p->pPars->fVerbose )
524 printf(
"AIG object is %d bytes. ", (
int)
sizeof(
Amap_Obj_t) );
525 printf(
"Internal AIG = %5.2f MB. Cuts = %5.2f MB. CutsMax = %d.\n",
526 1.0*Amap_ManObjNum(
p)*
sizeof(
Amap_Obj_t)/(1<<20), 1.0*
p->nBytesUsed/(1<<20),
p->pPars->nCutsMax );
527 printf(
"Node =%6d. Try =%9d. Try3 =%10d. Used =%7d. R =%6.2f. ",
528 Amap_ManNodeNum(
p),
p->nCutsTried,
p->nCutsTried3,
p->nCutsUsed,
529 1.0*
p->nCutsUsed/Amap_ManNodeNum(
p) );
530ABC_PRT(
"Time ", Abc_Clock() - clk );
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_MmFlexRestart(Aig_MmFlex_t *p)
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
struct Amap_Obj_t_ Amap_Obj_t
#define Amap_NodeForEachCut(pNode, pCut, i)
struct Amap_Man_t_ Amap_Man_t
#define Amap_ManForEachNode(p, pObj, i)
int Amap_LibFindNode(Amap_Lib_t *pLib, int iFan0, int iFan1, int fXor)
#define Amap_ManForEachPi(p, pObj, i)
MACRO DEFINITIONS ///.
struct Amap_Nod_t_ Amap_Nod_t
struct Amap_Cut_t_ Amap_Cut_t
int Amap_ManFindCut(Amap_Obj_t *pNode, Amap_Obj_t *pFanin, int fComplFanin, int Val, Vec_Ptr_t *vCuts)
void Amap_ManMergeNodeChoice(Amap_Man_t *p, Amap_Obj_t *pNode)
void Amap_ManCutSaveStored(Amap_Man_t *p, Amap_Obj_t *pNode)
int Amap_ManMergeCountCuts(Amap_Man_t *p, Amap_Obj_t *pNode)
void Amap_ManMerge(Amap_Man_t *p)
Amap_Cut_t * Amap_ManCutStore(Amap_Man_t *p, Amap_Cut_t *pCut, int fCompl)
ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManSetupPis(Amap_Man_t *p)
DECLARATIONS ///.
void Amap_ManMergeNodeCutsMux(Amap_Man_t *p, Amap_Obj_t *pNode)
Amap_Cut_t * Amap_ManCutCreate(Amap_Man_t *p, Amap_Cut_t *pCut0, Amap_Cut_t *pCut1, int iMat)
Amap_Cut_t * Amap_ManCutCreate3(Amap_Man_t *p, Amap_Cut_t *pCut0, Amap_Cut_t *pCut1, Amap_Cut_t *pCut2, int iMat)
void Amap_ManPrintCuts(Amap_Obj_t *pNode)
void Amap_ManMergeNodeCuts(Amap_Man_t *p, Amap_Obj_t *pNode)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.