summaryrefslogtreecommitdiffstats
path: root/src/aig/gia
diff options
context:
space:
mode:
Diffstat (limited to 'src/aig/gia')
-rw-r--r--src/aig/gia/giaDup.c38
-rw-r--r--src/aig/gia/giaHash.c322
-rw-r--r--src/aig/gia/giaResub.c41
-rw-r--r--src/aig/gia/giaUtil.c160
4 files changed, 561 insertions, 0 deletions
diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c
index a2ed4942..c1da11da 100644
--- a/src/aig/gia/giaDup.c
+++ b/src/aig/gia/giaDup.c
@@ -2966,6 +2966,44 @@ Vec_Ptr_t * Gia_ManMiterNames( Vec_Ptr_t * p, int nOuts )
/**Function*************************************************************
+ Synopsis [Pair-wise miter.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManPairWiseMiter( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pObj2;
+ int i, k, iLit;
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Abc_UtilStrsav( p->pName );
+ pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManHashAlloc( pNew );
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachPo( p, pObj, i )
+ Gia_ManForEachPo( p, pObj2, k )
+ {
+ if ( i >= k )
+ continue;
+ iLit = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(pObj2) );
+ Gia_ManAppendCo( pNew, iLit );
+ }
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
+}
+
+/**Function*************************************************************
+
Synopsis [Transforms the circuit into a regular miter.]
Description []
diff --git a/src/aig/gia/giaHash.c b/src/aig/gia/giaHash.c
index 64e39613..063cfd31 100644
--- a/src/aig/gia/giaHash.c
+++ b/src/aig/gia/giaHash.c
@@ -814,6 +814,328 @@ int Gia_ManHashDualMiter( Gia_Man_t * p, Vec_Int_t * vOuts )
return iRes;
}
+
+
+/**Function*************************************************************
+
+ Synopsis [Create multi-input tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Gia_ManCollectLiterals( int nVars )
+{
+ int i, * pRes = ABC_CALLOC( int, nVars );
+ for ( i = 0; i < nVars; i++ )
+ pRes[i] = Abc_Var2Lit( i+1, 0 );
+ return pRes;
+}
+int * Gia_ManGenZero( int nBits )
+{
+ return ABC_CALLOC( int, nBits );
+}
+int * Gia_ManGenPerm( int nBits )
+{
+ int i, * pRes = ABC_CALLOC( int, nBits );
+ srand( time(NULL) );
+ for ( i = 0; i < nBits; i++ )
+ pRes[i] = i;
+ for ( i = 0; i < nBits; i++ )
+ {
+ int iPerm = rand() % nBits;
+ ABC_SWAP( int, pRes[i], pRes[iPerm] );
+ }
+ return pRes;
+}
+int * Gia_ManGenPerm2( int nBits )
+{
+ int i, * pRes = ABC_CALLOC( int, nBits );
+ srand( time(NULL) );
+ for ( i = 0; i < nBits; i++ )
+ pRes[i] = rand() % nBits;
+ return pRes;
+}
+int Gia_ManMultiCheck( int * pPerm, int nPerm )
+{
+ int i;
+ for ( i = 1; i < nPerm; i++ )
+ if ( pPerm[i-1] <= pPerm[i] )
+ return 0;
+ return 1;
+}
+int Gia_ManMultiInputPerm( Gia_Man_t * pNew, int * pVars, int nVars, int * pPerm, int fOr, int fXor )
+{
+ int fPrint = 1;
+ int i, iLit;
+ if ( fPrint )
+ {
+ for ( i = 0; i < nVars; i++ )
+ printf( "%d ", pPerm[i] );
+ printf( "\n" );
+ }
+ while ( 1 )
+ {
+ for ( i = 1; i < nVars; i++ )
+ if ( pPerm[i-1] >= pPerm[i] )
+ break;
+ if ( i == nVars )
+ break;
+ assert( pPerm[i-1] >= pPerm[i] );
+ if ( pPerm[i-1] > pPerm[i] )
+ {
+ ABC_SWAP( int, pPerm[i-1], pPerm[i] );
+ ABC_SWAP( int, pVars[i-1], pVars[i] );
+ }
+ else
+ {
+ assert( pPerm[i-1] == pPerm[i] );
+ pPerm[i-1]++;
+ if ( fXor )
+ pVars[i-1] = Gia_ManHashXor( pNew, pVars[i-1], pVars[i] );
+ else if ( fOr )
+ pVars[i-1] = Gia_ManHashOr( pNew, pVars[i-1], pVars[i] );
+ else
+ pVars[i-1] = Gia_ManHashAnd( pNew, pVars[i-1], pVars[i] );
+ for ( i = i+1; i < nVars; i++ )
+ {
+ pPerm[i-1] = pPerm[i];
+ pVars[i-1] = pVars[i];
+ }
+ nVars--;
+ }
+ if ( fPrint )
+ {
+ for ( i = 0; i < nVars; i++ )
+ printf( "%d ", pPerm[i] );
+ printf( "\n" );
+ }
+ }
+ iLit = pVars[0];
+ for ( i = 1; i < nVars; i++ )
+ if ( fXor )
+ iLit = Gia_ManHashXor( pNew, iLit, pVars[i] );
+ else if ( fOr )
+ iLit = Gia_ManHashOr( pNew, iLit, pVars[i] );
+ else
+ iLit = Gia_ManHashAnd( pNew, iLit, pVars[i] );
+ return iLit;
+}
+Gia_Man_t * Gia_ManMultiInputTest( int nBits )
+{
+ Gia_Man_t * pNew;
+ int i, iRes, * pPerm;
+ int * pMulti = Gia_ManCollectLiterals( nBits );
+ pNew = Gia_ManStart( 1000 );
+ pNew->pName = Abc_UtilStrsav( "multi" );
+ for ( i = 0; i < nBits; i++ )
+ Gia_ManAppendCi( pNew );
+ Gia_ManHashAlloc( pNew );
+ pPerm = Gia_ManGenPerm2( nBits );
+ //pPerm = Gia_ManGenZero( nBits );
+ iRes = Gia_ManMultiInputPerm( pNew, pMulti, nBits, pPerm, 0, 0 );
+ Gia_ManAppendCo( pNew, iRes );
+ ABC_FREE( pPerm );
+ ABC_FREE( pMulti );
+ return pNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Create MUX tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCube( Gia_Man_t * pNew, int Vars, int nVars, int * pLits )
+{
+ int i, iLit = 1;
+ for ( i = 0; i < nVars; i++ )
+ iLit = Gia_ManHashAnd( pNew, iLit, Abc_LitNotCond(pLits[i], !((Vars >> i) & 1)) );
+ return iLit;
+}
+int Gia_ManMuxTree_rec( Gia_Man_t * pNew, int * pCtrl, int nCtrl, int * pData )
+{
+ int iLit0, iLit1;
+ if ( nCtrl == 0 )
+ return pData[0];
+ iLit0 = Gia_ManMuxTree_rec( pNew, pCtrl, nCtrl-1, pData );
+ iLit1 = Gia_ManMuxTree_rec( pNew, pCtrl, nCtrl-1, pData + (1<<(nCtrl-1)) );
+ return Gia_ManHashMux( pNew, pCtrl[nCtrl-1], iLit1, iLit0 );
+}
+void Gia_ManUsePerm( int * pTree, int nBits, int * pPerm )
+{
+ int fPrint = 0;
+ int i, k, m, nVars = nBits + (1 << nBits);
+ if ( fPrint )
+ {
+ for ( i = 0; i < nVars; i++ )
+ printf( "%d ", pPerm[i] );
+ printf( "\n" );
+ }
+ for ( i = 0; i < nBits; i++ )
+ {
+ for ( k = i+1; k < nBits; k++ )
+ if ( pPerm[i] > pPerm[k] )
+ break;
+ if ( k == nBits )
+ break;
+ assert( pPerm[i] > pPerm[k] );
+ ABC_SWAP( int, pPerm[i], pPerm[k] );
+ ABC_SWAP( int, pTree[i], pTree[k] );
+ for ( m = 0; m < (1 << nBits); m++ )
+ if ( ((m >> i) & 1) && !((m >> k) & 1) )
+ {
+ ABC_SWAP( int, pTree[nBits+m], pTree[nBits+(m^(1<<i)^(1<<k))] );
+ ABC_SWAP( int, pPerm[nBits+m], pPerm[nBits+(m^(1<<i)^(1<<k))] );
+ }
+ }
+ if ( fPrint )
+ {
+ for ( i = 0; i < nVars; i++ )
+ printf( "%d ", pPerm[i] );
+ printf( "\n" );
+ }
+}
+int Gia_ManFindCond( int * pLits, int nBits, int iLate1, int iLate2 )
+{
+ int i;
+ assert( iLate1 != iLate2 );
+ for ( i = 0; i < nBits; i++ )
+ if ( (((iLate1 ^ iLate2) >> i) & 1) )
+ return Abc_LitNotCond( pLits[i], (iLate1 >> i) & 1 );
+ return -1;
+}
+int Gia_ManLatest( int * pPerm, int nVars, int iPrev1, int iPrev2, int iPrev3 )
+{
+ int i, Value = -1, iLate = -1;
+ for ( i = 0; i < nVars; i++ )
+ if ( Value < pPerm[i] && i != iPrev1 && i != iPrev2 && i != iPrev3 )
+ {
+ Value = pPerm[i];
+ iLate = i;
+ }
+ return iLate;
+}
+int Gia_ManEarliest( int * pPerm, int nVars )
+{
+ int i, Value = ABC_INFINITY, iLate = -1;
+ for ( i = 0; i < nVars; i++ )
+ if ( Value > pPerm[i] )
+ {
+ Value = pPerm[i];
+ iLate = i;
+ }
+ return iLate;
+}
+int Gia_ManDecompOne( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm, int iLate )
+{
+ int iRes, iData;
+ assert( iLate >= 0 && iLate < (1<<nBits) );
+ iData = pTree[nBits+iLate];
+ pTree[nBits+iLate] = pTree[nBits+(iLate^1)];
+ iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
+ return Gia_ManHashMux( pNew, Gia_ManCube(pNew, iLate, nBits, pTree), iData, iRes );
+}
+int Gia_ManDecompTwo( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm, int iLate1, int iLate2 )
+{
+ int iRes, iData1, iData2, iData, iCond, iCond2;
+ assert( iLate1 != iLate2 );
+ assert( iLate1 >= 0 && iLate1 < (1<<nBits) );
+ assert( iLate2 >= 0 && iLate2 < (1<<nBits) );
+ iData1 = pTree[nBits+iLate1];
+ iData2 = pTree[nBits+iLate2];
+ pTree[nBits+iLate1] = pTree[nBits+(iLate1^1)];
+ pTree[nBits+iLate2] = pTree[nBits+(iLate2^1)];
+ iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
+ iCond = Gia_ManHashOr( pNew, Gia_ManCube(pNew, iLate1, nBits, pTree), Gia_ManCube(pNew, iLate2, nBits, pTree) );
+ iCond2 = Gia_ManFindCond( pTree, nBits, iLate1, iLate2 );
+ iData = Gia_ManHashMux( pNew, iCond2, iData2, iData1 );
+ return Gia_ManHashMux( pNew, iCond, iData, iRes );
+}
+int Gia_ManDecompThree( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm, int iLate1, int iLate2, int iLate3 )
+{
+ int iRes, iData1, iData2, iData3, iCube1, iCube2, iCube3, iCtrl0, iCtrl1, iMux10, iMux11;
+ assert( iLate1 != iLate2 );
+ assert( iLate1 != iLate3 );
+ assert( iLate2 != iLate3 );
+ assert( iLate1 >= 0 && iLate1 < (1<<nBits) );
+ assert( iLate2 >= 0 && iLate2 < (1<<nBits) );
+ assert( iLate3 >= 0 && iLate3 < (1<<nBits) );
+ iData1 = pTree[nBits+iLate1];
+ iData2 = pTree[nBits+iLate2];
+ iData3 = pTree[nBits+iLate3];
+ pTree[nBits+iLate1] = pTree[nBits+(iLate1^1)];
+ pTree[nBits+iLate2] = pTree[nBits+(iLate2^1)];
+ pTree[nBits+iLate3] = pTree[nBits+(iLate3^1)];
+ iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
+ iCube1 = Gia_ManCube( pNew, iLate1, nBits, pTree );
+ iCube2 = Gia_ManCube( pNew, iLate2, nBits, pTree );
+ iCube3 = Gia_ManCube( pNew, iLate3, nBits, pTree );
+ iCtrl0 = Gia_ManHashOr( pNew, iCube1, iCube3 );
+ iCtrl1 = Gia_ManHashOr( pNew, iCube2, iCube3 );
+ iMux10 = Gia_ManHashMux( pNew, iCtrl0, iData1, iRes );
+ iMux11 = Gia_ManHashMux( pNew, iCtrl0, iData3, iData2 );
+ return Gia_ManHashMux( pNew, iCtrl1, iMux11, iMux10 );
+}
+int Gia_ManDecomp( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm )
+{
+ if ( nBits == 2 )
+ return Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
+ else
+ {
+ int iBase = Gia_ManEarliest( pPerm+nBits, 1<<nBits ), BaseValue = pPerm[nBits+iBase];
+ int iLate1 = Gia_ManLatest( pPerm+nBits, 1<<nBits, -1, -1, -1 );
+ int iLate2 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, -1, -1 );
+ int iLate3 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, iLate2, -1 );
+ int iLate4 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, iLate2, iLate3 );
+ if ( 0 )
+ {
+ int i;
+ for ( i = 0; i < (1<<nBits); i++ )
+ printf( "%d ", pPerm[nBits+i] );
+ printf( "\n" );
+ }
+ if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] > BaseValue && pPerm[nBits+iLate3] > BaseValue && pPerm[nBits+iLate4] == BaseValue )
+ return Gia_ManDecompThree( pNew, pTree, nBits, pPerm, iLate1, iLate2, iLate3 );
+ if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] > BaseValue && pPerm[nBits+iLate3] == BaseValue )
+ return Gia_ManDecompTwo( pNew, pTree, nBits, pPerm, iLate1, iLate2 );
+ if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] == BaseValue )
+ return Gia_ManDecompOne( pNew, pTree, nBits, pPerm, iLate1 );
+ return Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
+ }
+}
+Gia_Man_t * Gia_ManMuxTreeTest( int nBits )
+{
+ Gia_Man_t * pNew;
+ int i, iLit, nVars = nBits + (1 << nBits);
+ int * pPerm, * pTree = Gia_ManCollectLiterals( nVars );
+ pNew = Gia_ManStart( 1000 );
+ pNew->pName = Abc_UtilStrsav( "mux_tree" );
+ for ( i = 0; i < nVars; i++ )
+ Gia_ManAppendCi( pNew );
+ Gia_ManHashAlloc( pNew );
+ pPerm = Gia_ManGenPerm( nVars );
+ //pPerm = Gia_ManGenZero( nVars );
+ pPerm[nBits+1] = 100;
+ pPerm[nBits+5] = 100;
+ pPerm[nBits+4] = 100;
+ Gia_ManUsePerm( pTree, nBits, pPerm );
+ iLit = Gia_ManDecomp( pNew, pTree, nBits, pPerm );
+ Gia_ManAppendCo( pNew, iLit );
+ ABC_FREE( pPerm );
+ ABC_FREE( pTree );
+ return pNew;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/gia/giaResub.c b/src/aig/gia/giaResub.c
index a1343290..06e002af 100644
--- a/src/aig/gia/giaResub.c
+++ b/src/aig/gia/giaResub.c
@@ -1581,6 +1581,47 @@ void Gia_ManResubTest3_()
SeeAlso []
***********************************************************************/
+void Gia_ManResubPair( Vec_Wrd_t * vOn, Vec_Wrd_t * vOff, int nWords, int nIns )
+{
+ Gia_ResbMan_t * p = Gia_ResbAlloc( nWords*2 );
+ Vec_Ptr_t * vDivs = Vec_PtrAllocSimInfo( nIns+2, nWords*2 );
+ word * pSim; int i;
+ Vec_PtrForEachEntry( word *, vDivs, pSim, i )
+ {
+ if ( i == 0 )
+ {
+ memset( pSim, 0x00, sizeof(word)*nWords );
+ memset( pSim+nWords, 0xFF, sizeof(word)*nWords );
+ }
+ else if ( i == 1 )
+ {
+ memset( pSim, 0xFF, sizeof(word)*nWords );
+ memset( pSim+nWords, 0x00, sizeof(word)*nWords );
+ }
+ else
+ {
+ memmove( pSim, Vec_WrdEntryP(vOn, (i-2)*nWords), sizeof(word)*nWords );
+ memmove( pSim+nWords, Vec_WrdEntryP(vOff, (i-2)*nWords), sizeof(word)*nWords );
+ }
+ }
+ Gia_ManResubPerform( p, vDivs, nWords*2, 100, 0, 50, 1, 1, 0 );
+ Gia_ManResubPrint( p->vGates, Vec_PtrSize(vDivs) );
+ printf( "\n" );
+ //Vec_PtrFree( vDivs );
+ Gia_ResbFree( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Top level.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Gia_ManCheckResub( Vec_Ptr_t * vDivs, int nWords )
{
//int i, nVars = 6, pVarSet[10] = { 2, 189, 2127, 2125, 177, 178 };
diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c
index efc866b8..85d8b1d2 100644
--- a/src/aig/gia/giaUtil.c
+++ b/src/aig/gia/giaUtil.c
@@ -2923,6 +2923,166 @@ Gia_Man_t * Gia_ManConvertSupp( Gia_Man_t * p )
return pNew;
}
+
+/**Function*************************************************************
+
+ Synopsis [Transform flops.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManTransformCond2( Gia_Man_t * p )
+{
+ int fOnly1 = 0;
+ int fVerbose = 1;
+ abctime clk = Abc_Clock();
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObjPi, * pObjRi, * pObjRo;
+ int i, n, iTempLit, iLits[2];
+ assert( Gia_ManRegNum(p) > 0 );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Abc_UtilStrsav( p->pName );
+ pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+ Gia_ManFillValue(p);
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObjPi, i )
+ pObjPi->Value = Gia_ManAppendCi( pNew );
+ Gia_ManHashAlloc( pNew );
+ Gia_ManForEachRi( p, pObjRi, i )
+ {
+ //if ( (i - Gia_ManPoNum(p)) % 8 != 0 )
+ // continue;
+ pObjRo = Gia_ObjRiToRo(p, pObjRi);
+ iTempLit = pObjRo->Value;
+ for ( n = 0; n < 2; n++ )
+ {
+ pObjRo->Value = n;
+ Gia_ManIncrementTravId( p );
+ Gia_ManConvertSupp_rec( pNew, p, Gia_ObjFanin0(pObjRi) );
+ iLits[n] = Gia_ObjFanin0Copy(pObjRi);
+ }
+ pObjRo->Value = iTempLit;
+ Gia_ManAppendCo( pNew, Abc_LitNot(Gia_ManHashAnd( pNew, iLits[1], Abc_LitNot(iLits[0]) )) );
+ Gia_ManAppendCo( pNew, Abc_LitNot(Gia_ManHashAnd( pNew, iLits[0], Abc_LitNot(iLits[1]) )) );
+ }
+ Gia_ManHashStop( pNew );
+ //Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ if ( fVerbose )
+ printf( "Created %d outputs. ", Gia_ManPoNum(pNew) );
+ if ( fVerbose )
+ Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transform flops.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Wrd_t * Gia_ManDetectSims( Gia_Man_t * p, int iCo, int nWords )
+{
+ extern int Cec4_ManGeneratePatterns_rec( Gia_Man_t * p, Gia_Obj_t * pObj, int Value, Vec_Int_t * vPat, Vec_Int_t * vVisit );
+ Vec_Wrd_t * vSim = Vec_WrdStart( nWords * Gia_ManCiNum(p) );
+ Vec_Int_t * vPat = Vec_IntAlloc( Gia_ManCiNum(p) );
+ Vec_Int_t * vVis = Vec_IntAlloc( Gia_ManAndNum(p) );
+ Gia_Obj_t * pObj = Gia_ManCo( p, iCo ), * pTemp; int iLit, i, k, nTries = 0;
+ if ( Gia_ObjFanin0(pObj) == Gia_ManConst0(p) )
+ return NULL;
+ Gia_ManForEachObj( p, pTemp, k )
+ assert( !pTemp->fMark0 && !pTemp->fMark1 );
+ for ( i = 0; i < 64*nWords; )
+ {
+ int Res = Cec4_ManGeneratePatterns_rec( p, Gia_ObjFanin0(pObj), !Gia_ObjFaninC0(pObj), vPat, vVis );
+ if ( Res )
+ {
+ Vec_IntForEachEntry( vPat, iLit, k )
+ {
+ if ( Abc_LitIsCompl(iLit) )
+ continue;
+ pTemp = Gia_ManObj( p, Abc_Lit2Var(iLit) );
+ assert( Gia_ObjIsCi(pTemp) );
+ Abc_InfoSetBit( (unsigned *)Vec_WrdEntryP(vSim, nWords*Gia_ObjCioId(pTemp)), i );
+ }
+ i++;
+ }
+ Gia_ManForEachObjVec( vVis, p, pTemp, k )
+ pTemp->fMark0 = pTemp->fMark1 = 0;
+ nTries++;
+ }
+ //printf( "%d ", nTries );
+ Vec_IntFree( vPat );
+ Vec_IntFree( vVis );
+ return vSim;
+}
+Vec_Wrd_t * Vec_WrdInterleave( Vec_Wrd_t * p1, Vec_Wrd_t * p2, int nWords, int nIns )
+{
+ Vec_Wrd_t * p = Vec_WrdAlloc( Vec_WrdSize(p1)+Vec_WrdSize(p2) );
+ int i, k;
+ assert( Vec_WrdSize(p1) == nWords*nIns );
+ assert( Vec_WrdSize(p2) == nWords*nIns );
+ for ( i = 0; i < nIns; i++ )
+ {
+ for ( k = 0; k < nWords; k++ )
+ Vec_WrdPush( p, Vec_WrdEntry(p1, i*nWords+k) );
+ for ( k = 0; k < nWords; k++ )
+ Vec_WrdPush( p, Vec_WrdEntry(p2, i*nWords+k) );
+ }
+ return p;
+}
+Gia_Man_t * Gia_ManTransformCond( Gia_Man_t * p )
+{
+ extern void Gia_ManResubPair( Vec_Wrd_t * vOn, Vec_Wrd_t * vOff, int nWords, int nIns );
+ abctime clk = Abc_Clock();
+ Vec_Wrd_t * vSims;
+ Vec_Wrd_t * vSim[4];
+ Vec_Wrd_t * vInt[6];
+ int i;
+ for ( i = 0; i < Gia_ManCoNum(p); i++ )
+ {
+ vSims = Gia_ManDetectSims( p, i, 1 );
+ if ( i >= Gia_ManCoNum(p)-4 )
+ vSim[i-(Gia_ManCoNum(p)-4)] = vSims;
+ else
+ Vec_WrdFreeP( &vSims );
+ //Vec_PtrPush( vAll, vSims );
+ }
+ vInt[0] = Vec_WrdInterleave( vSim[0], vSim[1], 1, Gia_ManCiNum(p) );
+ vInt[1] = Vec_WrdInterleave( vSim[0], vSim[2], 1, Gia_ManCiNum(p) );
+ vInt[2] = Vec_WrdInterleave( vSim[0], vSim[3], 1, Gia_ManCiNum(p) );
+ vInt[3] = Vec_WrdInterleave( vSim[1], vSim[2], 1, Gia_ManCiNum(p) );
+ vInt[4] = Vec_WrdInterleave( vSim[1], vSim[3], 1, Gia_ManCiNum(p) );
+ vInt[5] = Vec_WrdInterleave( vSim[2], vSim[3], 1, Gia_ManCiNum(p) );
+
+ Gia_ManResubPair( vInt[0], vInt[5], 2, Gia_ManCiNum(p) );
+ Gia_ManResubPair( vInt[1], vInt[4], 2, Gia_ManCiNum(p) );
+ Gia_ManResubPair( vInt[2], vInt[3], 2, Gia_ManCiNum(p) );
+
+ Gia_ManResubPair( vInt[5], vInt[0], 2, Gia_ManCiNum(p) );
+ Gia_ManResubPair( vInt[4], vInt[1], 2, Gia_ManCiNum(p) );
+ Gia_ManResubPair( vInt[3], vInt[2], 2, Gia_ManCiNum(p) );
+
+/*
+ for ( i = 0; i < 4; i++ )
+ for ( k = i+1; k < 4; k++ )
+ Gia_ManResubPair( vSim[i], vSim[k], 1, Gia_ManCiNum(p) );
+*/
+ Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
+ return NULL;
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////