mirror of https://github.com/YosysHQ/abc.git
Various changes.
This commit is contained in:
parent
787dbb9433
commit
2ce1ce8bed
|
|
@ -177,15 +177,19 @@ static inline void Gia_ManSimPatSimAnd3( Gia_Man_t * p, int i, Gia_Obj_t * pObj,
|
|||
pSimsC1[w] |= (pSims2[w] | (pSims1[w] ^ Diff1)) & pSimsC2[w];
|
||||
}
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSimIn( Gia_Man_t * pGia, Vec_Wrd_t * vSims, int fIns )
|
||||
Vec_Wrd_t * Gia_ManSimPatSimIn( Gia_Man_t * pGia, Vec_Wrd_t * vSims, int fIns, Vec_Int_t * vAnds )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, Id, nWords = Vec_WrdSize(vSims) / Gia_ManObjNum(pGia);
|
||||
Vec_Wrd_t * vSimsCi = fIns ? Vec_WrdStart( Gia_ManCiNum(pGia) * nWords ) : NULL;
|
||||
Vec_Wrd_t * vSimsC = Vec_WrdStart( Vec_WrdSize(vSims) );
|
||||
assert( Vec_WrdSize(vSims) % Gia_ManObjNum(pGia) == 0 );
|
||||
Gia_ManForEachCoDriverId( pGia, Id, i )
|
||||
memset( Vec_WrdEntryP(vSimsC, Id*nWords), 0xFF, sizeof(word)*nWords );
|
||||
if ( vAnds )
|
||||
Vec_IntForEachEntry( vAnds, Id, i )
|
||||
memset( Vec_WrdEntryP(vSimsC, Id*nWords), 0xFF, sizeof(word)*nWords );
|
||||
else
|
||||
Gia_ManForEachCoDriverId( pGia, Id, i )
|
||||
memset( Vec_WrdEntryP(vSimsC, Id*nWords), 0xFF, sizeof(word)*nWords );
|
||||
Gia_ManForEachAndReverse( pGia, pObj, i )
|
||||
Gia_ManSimPatSimAnd3( pGia, i, pObj, nWords, vSims, vSimsC );
|
||||
if ( !fIns )
|
||||
|
|
@ -200,7 +204,7 @@ void Gia_ManSimPatSimInTest( Gia_Man_t * pGia )
|
|||
int nWords = 10;
|
||||
Vec_Wrd_t * vSimsCi = Vec_WrdStartRandom( Gia_ManCiNum(pGia) * nWords );
|
||||
Vec_Wrd_t * vSims = Gia_ManSimPatSimOut( pGia, vSimsCi, 0 );
|
||||
Vec_Wrd_t * vSims2 = Gia_ManSimPatSimIn( pGia, vSims, 0 );
|
||||
Vec_Wrd_t * vSims2 = Gia_ManSimPatSimIn( pGia, vSims, 0, NULL );
|
||||
int nOnes = Abc_TtCountOnesVec( Vec_WrdArray(vSims2), Vec_WrdSize(vSims2) );
|
||||
int nTotal = 64*nWords*Gia_ManCandNum(pGia);
|
||||
printf( "Ratio = %6.2f %%\n", 100.0*nOnes/nTotal );
|
||||
|
|
@ -208,6 +212,54 @@ void Gia_ManSimPatSimInTest( Gia_Man_t * pGia )
|
|||
Vec_WrdFree( vSims2 );
|
||||
Vec_WrdFree( vSimsCi );
|
||||
}
|
||||
static inline void Gia_ManSimPatSimAnd4( Gia_Man_t * p, int i, Gia_Obj_t * pObj, int nWords, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsC )
|
||||
{
|
||||
word pComps[2] = { ~(word)0, 0 };
|
||||
word Diff0 = pComps[Gia_ObjFaninC0(pObj)];
|
||||
word Diff1 = pComps[Gia_ObjFaninC1(pObj)];
|
||||
word * pSims0 = Vec_WrdArray(vSims) + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSims1 = Vec_WrdArray(vSims) + nWords*Gia_ObjFaninId1(pObj, i);
|
||||
word * pSimsC0 = Vec_WrdArray(vSimsC) + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSimsC1 = Vec_WrdArray(vSimsC) + nWords*Gia_ObjFaninId1(pObj, i);
|
||||
word * pSimsC2 = Vec_WrdArray(vSimsC) + nWords*i; int w;
|
||||
if ( Gia_ObjIsXor(pObj) )
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSimsC2[w] = pSimsC0[w] & pSimsC1[w];
|
||||
else
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSimsC2[w] = (pSimsC0[w] & pSimsC1[w]) | ((pSims0[w] ^ Diff0) & pSimsC0[w]) | ((pSims1[w] ^ Diff1) & pSimsC1[w]);
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSimC( Gia_Man_t * pGia, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsCiC )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, Id, nWords = Vec_WrdSize(vSims) / Gia_ManObjNum(pGia);
|
||||
Vec_Wrd_t * vSimsC = Vec_WrdStart( Vec_WrdSize(vSims) );
|
||||
assert( Vec_WrdSize(vSims) % Gia_ManObjNum(pGia) == 0 );
|
||||
memset( Vec_WrdEntryP(vSimsC, 0), 0xFF, sizeof(word)*nWords );
|
||||
Gia_ManForEachCiId( pGia, Id, i )
|
||||
memmove( Vec_WrdEntryP(vSimsC, Id*nWords), Vec_WrdEntryP(vSimsCiC, i*nWords), sizeof(word)*nWords );
|
||||
Gia_ManForEachAnd( pGia, pObj, i )
|
||||
Gia_ManSimPatSimAnd4( pGia, i, pObj, nWords, vSims, vSimsC );
|
||||
return vSimsC;
|
||||
}
|
||||
void Gia_ManSimPatSimCTest( Gia_Man_t * pGia )
|
||||
{
|
||||
int nWords = 10;
|
||||
Vec_Wrd_t * vSimsCi = Vec_WrdStartRandom( Gia_ManCiNum(pGia) * nWords );
|
||||
Vec_Wrd_t * vSims = Gia_ManSimPatSimOut( pGia, vSimsCi, 0 );
|
||||
Vec_Wrd_t * vSims2 = Gia_ManSimPatSimIn( pGia, vSims, 0, NULL );
|
||||
Vec_Wrd_t * vSimsCi2 = Gia_ManSimPatSimIn( pGia, vSims, 1, NULL );
|
||||
Vec_Wrd_t * vSims3 = Gia_ManSimPatSimC( pGia, vSims, vSimsCi2 );
|
||||
int nOnes2 = Abc_TtCountOnesVec( Vec_WrdArray(vSims2), Vec_WrdSize(vSims2) );
|
||||
int nOnes3 = Abc_TtCountOnesVec( Vec_WrdArray(vSims3), Vec_WrdSize(vSims3) );
|
||||
int nTotal = 64*nWords*Gia_ManCandNum(pGia);
|
||||
printf( "Ratio = %6.2f %% Ratio = %6.2f %%\n", 100.0*nOnes2/nTotal, 100.0*nOnes3/nTotal );
|
||||
Vec_WrdFree( vSims );
|
||||
Vec_WrdFree( vSims2 );
|
||||
Vec_WrdFree( vSims3 );
|
||||
Vec_WrdFree( vSimsCi );
|
||||
Vec_WrdFree( vSimsCi2 );
|
||||
}
|
||||
void Gia_ManSimPatResim( Gia_Man_t * pGia, Vec_Int_t * vObjs, int nWords, Vec_Wrd_t * vSims )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i;
|
||||
|
|
|
|||
|
|
@ -516,6 +516,7 @@ static inline void Abc_ReverseOrder( int * pA, int nA )
|
|||
extern void Abc_MergeSort( int * pInput, int nSize );
|
||||
extern int * Abc_MergeSortCost( int * pCosts, int nSize );
|
||||
extern void Abc_MergeSortCost2( int * pInput, int nSize, int * pCost );
|
||||
extern void Abc_MergeSortCost2Reverse( int * pInput, int nSize, int * pCost );
|
||||
extern void Abc_QuickSort1( word * pData, int nSize, int fDecrease );
|
||||
extern void Abc_QuickSort2( word * pData, int nSize, int fDecrease );
|
||||
extern void Abc_QuickSort3( word * pData, int nSize, int fDecrease );
|
||||
|
|
|
|||
|
|
@ -239,6 +239,109 @@ void Abc_MergeSortCost2( int * pInput, int nSize, int * pCost )
|
|||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Merging two lists of entries.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_SortMergeCost2Reverse( int * p1Beg, int * p1End, int * p2Beg, int * p2End, int * pOut, int * pCost )
|
||||
{
|
||||
int nEntries = (p1End - p1Beg) + (p2End - p2Beg);
|
||||
int * pOutBeg = pOut;
|
||||
while ( p1Beg < p1End && p2Beg < p2End )
|
||||
{
|
||||
if ( pCost[*p1Beg] == pCost[*p2Beg] )
|
||||
*pOut++ = *p1Beg++, *pOut++ = *p2Beg++;
|
||||
else if ( pCost[*p1Beg] > pCost[*p2Beg] )
|
||||
*pOut++ = *p1Beg++;
|
||||
else // if ( pCost[*p1Beg] < pCost[*p2Beg] )
|
||||
*pOut++ = *p2Beg++;
|
||||
}
|
||||
while ( p1Beg < p1End )
|
||||
*pOut++ = *p1Beg++;
|
||||
while ( p2Beg < p2End )
|
||||
*pOut++ = *p2Beg++;
|
||||
assert( pOut - pOutBeg == nEntries );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Recursive sorting.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_SortCost2Reverse_rec( int * pInBeg, int * pInEnd, int * pOutBeg, int * pCost )
|
||||
{
|
||||
int nSize = pInEnd - pInBeg;
|
||||
assert( nSize > 0 );
|
||||
if ( nSize == 1 )
|
||||
return;
|
||||
if ( nSize == 2 )
|
||||
{
|
||||
if ( pCost[pInBeg[0]] < pCost[pInBeg[1]] )
|
||||
{
|
||||
pInBeg[0] ^= pInBeg[1];
|
||||
pInBeg[1] ^= pInBeg[0];
|
||||
pInBeg[0] ^= pInBeg[1];
|
||||
}
|
||||
}
|
||||
else if ( nSize < 8 )
|
||||
{
|
||||
int temp, i, j, best_i;
|
||||
for ( i = 0; i < nSize-1; i++ )
|
||||
{
|
||||
best_i = i;
|
||||
for ( j = i+1; j < nSize; j++ )
|
||||
if ( pCost[pInBeg[j]] > pCost[pInBeg[best_i]] )
|
||||
best_i = j;
|
||||
temp = pInBeg[i];
|
||||
pInBeg[i] = pInBeg[best_i];
|
||||
pInBeg[best_i] = temp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Abc_SortCost2Reverse_rec( pInBeg, pInBeg + nSize/2, pOutBeg, pCost );
|
||||
Abc_SortCost2Reverse_rec( pInBeg + nSize/2, pInEnd, pOutBeg + nSize/2, pCost );
|
||||
Abc_SortMergeCost2Reverse( pInBeg, pInBeg + nSize/2, pInBeg + nSize/2, pInEnd, pOutBeg, pCost );
|
||||
memcpy( pInBeg, pOutBeg, sizeof(int) * nSize );
|
||||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Returns the sorted array of integers.]
|
||||
|
||||
Description [This procedure is about 10% faster than qsort().]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_MergeSortCost2Reverse( int * pInput, int nSize, int * pCost )
|
||||
{
|
||||
int * pOutput;
|
||||
if ( nSize < 2 )
|
||||
return;
|
||||
pOutput = (int *) malloc( sizeof(int) * nSize );
|
||||
Abc_SortCost2Reverse_rec( pInput, pInput + nSize, pOutput, pCost );
|
||||
free( pOutput );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Merging two lists of entries.]
|
||||
|
|
|
|||
Loading…
Reference in New Issue