mirror of https://github.com/YosysHQ/abc.git
merge
This commit is contained in:
commit
72c23923da
|
|
@ -0,0 +1,646 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaCut.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Stand-alone cut computation.]
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaCut.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GIA_MAX_CUTSIZE 8
|
||||
#define GIA_MAX_CUTNUM 51
|
||||
#define GIA_MAX_TT_WORDS ((GIA_MAX_CUTSIZE > 6) ? 1 << (GIA_MAX_CUTSIZE-6) : 1)
|
||||
|
||||
#define GIA_CUT_NO_LEAF 0xF
|
||||
|
||||
typedef struct Gia_Cut_t_ Gia_Cut_t;
|
||||
struct Gia_Cut_t_
|
||||
{
|
||||
word Sign; // signature
|
||||
int iFunc; // functionality
|
||||
int Cost; // cut cost
|
||||
int CostLev; // cut cost
|
||||
unsigned nTreeLeaves : 28; // tree leaves
|
||||
unsigned nLeaves : 4; // leaf count
|
||||
int pLeaves[GIA_MAX_CUTSIZE]; // leaves
|
||||
};
|
||||
|
||||
typedef struct Gia_Sto_t_ Gia_Sto_t;
|
||||
struct Gia_Sto_t_
|
||||
{
|
||||
int nCutSize;
|
||||
int nCutNum;
|
||||
int fCutMin;
|
||||
int fTruthMin;
|
||||
int fVerbose;
|
||||
Gia_Man_t * pGia; // user's AIG manager (will be modified by adding nodes)
|
||||
Vec_Int_t * vRefs; // refs for each node
|
||||
Vec_Wec_t * vCuts; // cuts for each node
|
||||
Vec_Mem_t * vTtMem; // truth tables
|
||||
Gia_Cut_t pCuts[3][GIA_MAX_CUTNUM]; // temporary cuts
|
||||
Gia_Cut_t * ppCuts[GIA_MAX_CUTNUM]; // temporary cut pointers
|
||||
int nCutsR; // the number of cuts
|
||||
int Pivot; // current object
|
||||
int iCutBest; // best-delay cut
|
||||
int nCutsOver; // overflow cuts
|
||||
double CutCount[4]; // cut counters
|
||||
abctime clkStart; // starting time
|
||||
};
|
||||
|
||||
static inline word * Gia_CutTruth( Gia_Sto_t * p, Gia_Cut_t * pCut ) { return Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut->iFunc)); }
|
||||
|
||||
#define Sdb_ForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += pCut[0] + 2 )
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Check correctness of cuts.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline word Gia_CutGetSign( Gia_Cut_t * pCut )
|
||||
{
|
||||
word Sign = 0; int i;
|
||||
for ( i = 0; i < (int)pCut->nLeaves; i++ )
|
||||
Sign |= ((word)1) << (pCut->pLeaves[i] & 0x3F);
|
||||
return Sign;
|
||||
}
|
||||
static inline int Gia_CutCheck( Gia_Cut_t * pBase, Gia_Cut_t * pCut ) // check if pCut is contained in pBase
|
||||
{
|
||||
int nSizeB = pBase->nLeaves;
|
||||
int nSizeC = pCut->nLeaves;
|
||||
int i, * pB = pBase->pLeaves;
|
||||
int k, * pC = pCut->pLeaves;
|
||||
for ( i = 0; i < nSizeC; i++ )
|
||||
{
|
||||
for ( k = 0; k < nSizeB; k++ )
|
||||
if ( pC[i] == pB[k] )
|
||||
break;
|
||||
if ( k == nSizeB )
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
static inline int Gia_CutSetCheckArray( Gia_Cut_t ** ppCuts, int nCuts )
|
||||
{
|
||||
Gia_Cut_t * pCut0, * pCut1;
|
||||
int i, k, m, n, Value;
|
||||
assert( nCuts > 0 );
|
||||
for ( i = 0; i < nCuts; i++ )
|
||||
{
|
||||
pCut0 = ppCuts[i];
|
||||
assert( pCut0->nLeaves <= GIA_MAX_CUTSIZE );
|
||||
assert( pCut0->Sign == Gia_CutGetSign(pCut0) );
|
||||
// check duplicates
|
||||
for ( m = 0; m < (int)pCut0->nLeaves; m++ )
|
||||
for ( n = m + 1; n < (int)pCut0->nLeaves; n++ )
|
||||
assert( pCut0->pLeaves[m] < pCut0->pLeaves[n] );
|
||||
// check pairs
|
||||
for ( k = 0; k < nCuts; k++ )
|
||||
{
|
||||
pCut1 = ppCuts[k];
|
||||
if ( pCut0 == pCut1 )
|
||||
continue;
|
||||
// check containments
|
||||
Value = Gia_CutCheck( pCut0, pCut1 );
|
||||
assert( Value == 0 );
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline int Gia_CutMergeOrder( Gia_Cut_t * pCut0, Gia_Cut_t * pCut1, Gia_Cut_t * pCut, int nCutSize )
|
||||
{
|
||||
int nSize0 = pCut0->nLeaves;
|
||||
int nSize1 = pCut1->nLeaves;
|
||||
int i, * pC0 = pCut0->pLeaves;
|
||||
int k, * pC1 = pCut1->pLeaves;
|
||||
int c, * pC = pCut->pLeaves;
|
||||
// the case of the largest cut sizes
|
||||
if ( nSize0 == nCutSize && nSize1 == nCutSize )
|
||||
{
|
||||
for ( i = 0; i < nSize0; i++ )
|
||||
{
|
||||
if ( pC0[i] != pC1[i] ) return 0;
|
||||
pC[i] = pC0[i];
|
||||
}
|
||||
pCut->nLeaves = nCutSize;
|
||||
pCut->iFunc = -1;
|
||||
pCut->Sign = pCut0->Sign | pCut1->Sign;
|
||||
return 1;
|
||||
}
|
||||
// compare two cuts with different numbers
|
||||
i = k = c = 0;
|
||||
if ( nSize0 == 0 ) goto FlushCut1;
|
||||
if ( nSize1 == 0 ) goto FlushCut0;
|
||||
while ( 1 )
|
||||
{
|
||||
if ( c == nCutSize ) return 0;
|
||||
if ( pC0[i] < pC1[k] )
|
||||
{
|
||||
pC[c++] = pC0[i++];
|
||||
if ( i >= nSize0 ) goto FlushCut1;
|
||||
}
|
||||
else if ( pC0[i] > pC1[k] )
|
||||
{
|
||||
pC[c++] = pC1[k++];
|
||||
if ( k >= nSize1 ) goto FlushCut0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pC[c++] = pC0[i++]; k++;
|
||||
if ( i >= nSize0 ) goto FlushCut1;
|
||||
if ( k >= nSize1 ) goto FlushCut0;
|
||||
}
|
||||
}
|
||||
|
||||
FlushCut0:
|
||||
if ( c + nSize0 > nCutSize + i ) return 0;
|
||||
while ( i < nSize0 )
|
||||
pC[c++] = pC0[i++];
|
||||
pCut->nLeaves = c;
|
||||
pCut->iFunc = -1;
|
||||
pCut->Sign = pCut0->Sign | pCut1->Sign;
|
||||
return 1;
|
||||
|
||||
FlushCut1:
|
||||
if ( c + nSize1 > nCutSize + k ) return 0;
|
||||
while ( k < nSize1 )
|
||||
pC[c++] = pC1[k++];
|
||||
pCut->nLeaves = c;
|
||||
pCut->iFunc = -1;
|
||||
pCut->Sign = pCut0->Sign | pCut1->Sign;
|
||||
return 1;
|
||||
}
|
||||
static inline int Gia_CutMergeOrder2( Gia_Cut_t * pCut0, Gia_Cut_t * pCut1, Gia_Cut_t * pCut, int nCutSize )
|
||||
{
|
||||
int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
|
||||
int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
|
||||
int xMin, c = 0, * pC = pCut->pLeaves;
|
||||
while ( 1 )
|
||||
{
|
||||
x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
|
||||
x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
|
||||
xMin = Abc_MinInt(x0, x1);
|
||||
if ( xMin == ABC_INFINITY ) break;
|
||||
if ( c == nCutSize ) return 0;
|
||||
pC[c++] = xMin;
|
||||
if (x0 == xMin) i0++;
|
||||
if (x1 == xMin) i1++;
|
||||
}
|
||||
pCut->nLeaves = c;
|
||||
pCut->iFunc = -1;
|
||||
pCut->Sign = pCut0->Sign | pCut1->Sign;
|
||||
return 1;
|
||||
}
|
||||
static inline int Gia_CutSetCutIsContainedOrder( Gia_Cut_t * pBase, Gia_Cut_t * pCut ) // check if pCut is contained in pBase
|
||||
{
|
||||
int i, nSizeB = pBase->nLeaves;
|
||||
int k, nSizeC = pCut->nLeaves;
|
||||
if ( nSizeB == nSizeC )
|
||||
{
|
||||
for ( i = 0; i < nSizeB; i++ )
|
||||
if ( pBase->pLeaves[i] != pCut->pLeaves[i] )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
assert( nSizeB > nSizeC );
|
||||
if ( nSizeC == 0 )
|
||||
return 1;
|
||||
for ( i = k = 0; i < nSizeB; i++ )
|
||||
{
|
||||
if ( pBase->pLeaves[i] > pCut->pLeaves[k] )
|
||||
return 0;
|
||||
if ( pBase->pLeaves[i] == pCut->pLeaves[k] )
|
||||
{
|
||||
if ( ++k == nSizeC )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static inline int Gia_CutSetLastCutIsContained( Gia_Cut_t ** pCuts, int nCuts )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < nCuts; i++ )
|
||||
if ( pCuts[i]->nLeaves <= pCuts[nCuts]->nLeaves && (pCuts[i]->Sign & pCuts[nCuts]->Sign) == pCuts[i]->Sign && Gia_CutSetCutIsContainedOrder(pCuts[nCuts], pCuts[i]) )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline int Gia_CutCompare( Gia_Cut_t * pCut0, Gia_Cut_t * pCut1 )
|
||||
{
|
||||
if ( pCut0->nTreeLeaves < pCut1->nTreeLeaves ) return -1;
|
||||
if ( pCut0->nTreeLeaves > pCut1->nTreeLeaves ) return 1;
|
||||
if ( pCut0->nLeaves < pCut1->nLeaves ) return -1;
|
||||
if ( pCut0->nLeaves > pCut1->nLeaves ) return 1;
|
||||
return 0;
|
||||
}
|
||||
static inline int Gia_CutSetLastCutContains( Gia_Cut_t ** pCuts, int nCuts )
|
||||
{
|
||||
int i, k, fChanges = 0;
|
||||
for ( i = 0; i < nCuts; i++ )
|
||||
if ( pCuts[nCuts]->nLeaves < pCuts[i]->nLeaves && (pCuts[nCuts]->Sign & pCuts[i]->Sign) == pCuts[nCuts]->Sign && Gia_CutSetCutIsContainedOrder(pCuts[i], pCuts[nCuts]) )
|
||||
pCuts[i]->nLeaves = GIA_CUT_NO_LEAF, fChanges = 1;
|
||||
if ( !fChanges )
|
||||
return nCuts;
|
||||
for ( i = k = 0; i <= nCuts; i++ )
|
||||
{
|
||||
if ( pCuts[i]->nLeaves == GIA_CUT_NO_LEAF )
|
||||
continue;
|
||||
if ( k < i )
|
||||
ABC_SWAP( Gia_Cut_t *, pCuts[k], pCuts[i] );
|
||||
k++;
|
||||
}
|
||||
return k - 1;
|
||||
}
|
||||
static inline void Gia_CutSetSortByCost( Gia_Cut_t ** pCuts, int nCuts )
|
||||
{
|
||||
int i;
|
||||
for ( i = nCuts; i > 0; i-- )
|
||||
{
|
||||
if ( Gia_CutCompare(pCuts[i - 1], pCuts[i]) < 0 )//!= 1 )
|
||||
return;
|
||||
ABC_SWAP( Gia_Cut_t *, pCuts[i - 1], pCuts[i] );
|
||||
}
|
||||
}
|
||||
static inline int Gia_CutSetAddCut( Gia_Cut_t ** pCuts, int nCuts, int nCutNum )
|
||||
{
|
||||
if ( nCuts == 0 )
|
||||
return 1;
|
||||
nCuts = Gia_CutSetLastCutContains(pCuts, nCuts);
|
||||
assert( nCuts >= 0 );
|
||||
Gia_CutSetSortByCost( pCuts, nCuts );
|
||||
// add new cut if there is room
|
||||
return Abc_MinInt( nCuts + 1, nCutNum - 1 );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline int Gia_CutComputeTruth6( Gia_Sto_t * p, Gia_Cut_t * pCut0, Gia_Cut_t * pCut1, int fCompl0, int fCompl1, Gia_Cut_t * pCutR, int fIsXor )
|
||||
{
|
||||
int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
|
||||
word t0 = *Gia_CutTruth(p, pCut0);
|
||||
word t1 = *Gia_CutTruth(p, pCut1);
|
||||
if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
|
||||
if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
|
||||
t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
|
||||
t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
|
||||
t = fIsXor ? t0 ^ t1 : t0 & t1;
|
||||
if ( (fCompl = (int)(t & 1)) ) t = ~t;
|
||||
if ( p->fTruthMin )
|
||||
pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
|
||||
assert( (int)(t & 1) == 0 );
|
||||
truthId = Vec_MemHashInsert(p->vTtMem, &t);
|
||||
pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
|
||||
assert( (int)pCutR->nLeaves <= nOldSupp );
|
||||
return (int)pCutR->nLeaves < nOldSupp;
|
||||
}
|
||||
static inline int Gia_CutComputeTruth( Gia_Sto_t * p, Gia_Cut_t * pCut0, Gia_Cut_t * pCut1, int fCompl0, int fCompl1, Gia_Cut_t * pCutR, int fIsXor )
|
||||
{
|
||||
if ( p->nCutSize <= 6 )
|
||||
return Gia_CutComputeTruth6( p, pCut0, pCut1, fCompl0, fCompl1, pCutR, fIsXor );
|
||||
{
|
||||
word uTruth[GIA_MAX_TT_WORDS], uTruth0[GIA_MAX_TT_WORDS], uTruth1[GIA_MAX_TT_WORDS];
|
||||
int nOldSupp = pCutR->nLeaves, truthId;
|
||||
int nCutSize = p->nCutSize, fCompl;
|
||||
int nWords = Abc_Truth6WordNum(nCutSize);
|
||||
word * pTruth0 = Gia_CutTruth(p, pCut0);
|
||||
word * pTruth1 = Gia_CutTruth(p, pCut1);
|
||||
Abc_TtCopy( uTruth0, pTruth0, nWords, Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 );
|
||||
Abc_TtCopy( uTruth1, pTruth1, nWords, Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 );
|
||||
Abc_TtExpand( uTruth0, nCutSize, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
|
||||
Abc_TtExpand( uTruth1, nCutSize, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
|
||||
if ( fIsXor )
|
||||
Abc_TtXor( uTruth, uTruth0, uTruth1, nWords, (fCompl = (int)((uTruth0[0] ^ uTruth1[0]) & 1)) );
|
||||
else
|
||||
Abc_TtAnd( uTruth, uTruth0, uTruth1, nWords, (fCompl = (int)((uTruth0[0] & uTruth1[0]) & 1)) );
|
||||
if ( p->fTruthMin )
|
||||
pCutR->nLeaves = Abc_TtMinBase( uTruth, pCutR->pLeaves, pCutR->nLeaves, nCutSize );
|
||||
assert( (uTruth[0] & 1) == 0 );
|
||||
//Kit_DsdPrintFromTruth( uTruth, pCutR->nLeaves ), printf("\n" ), printf("\n" );
|
||||
truthId = Vec_MemHashInsert(p->vTtMem, uTruth);
|
||||
pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
|
||||
assert( (int)pCutR->nLeaves <= nOldSupp );
|
||||
return (int)pCutR->nLeaves < nOldSupp;
|
||||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline int Gia_CutCountBits( word i )
|
||||
{
|
||||
i = i - ((i >> 1) & 0x5555555555555555);
|
||||
i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
|
||||
i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
|
||||
return (i*(0x0101010101010101))>>56;
|
||||
}
|
||||
static inline void Gia_CutAddUnit( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Vec_Int_t * vThis = Vec_WecEntry( p->vCuts, iObj );
|
||||
if ( Vec_IntSize(vThis) == 0 )
|
||||
Vec_IntPush( vThis, 1 );
|
||||
else
|
||||
Vec_IntAddToEntry( vThis, 0, 1 );
|
||||
Vec_IntPush( vThis, 1 );
|
||||
Vec_IntPush( vThis, iObj );
|
||||
Vec_IntPush( vThis, 2 );
|
||||
}
|
||||
static inline void Gia_CutAddZero( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Vec_Int_t * vThis = Vec_WecEntry( p->vCuts, iObj );
|
||||
assert( Vec_IntSize(vThis) == 0 );
|
||||
Vec_IntPush( vThis, 1 );
|
||||
Vec_IntPush( vThis, 0 );
|
||||
Vec_IntPush( vThis, 0 );
|
||||
}
|
||||
static inline int Gia_CutTreeLeaves( Gia_Sto_t * p, Gia_Cut_t * pCut )
|
||||
{
|
||||
int i, Cost = 0;
|
||||
for ( i = 0; i < (int)pCut->nLeaves; i++ )
|
||||
Cost += Vec_IntEntry( p->vRefs, pCut->pLeaves[i] ) == 1;
|
||||
return Cost;
|
||||
}
|
||||
static inline int Gia_StoPrepareSet( Gia_Sto_t * p, int iObj, int Index )
|
||||
{
|
||||
Vec_Int_t * vThis = Vec_WecEntry( p->vCuts, iObj );
|
||||
int i, v, * pCut, * pList = Vec_IntArray( vThis );
|
||||
Sdb_ForEachCut( pList, pCut, i )
|
||||
{
|
||||
Gia_Cut_t * pCutTemp = &p->pCuts[Index][i];
|
||||
pCutTemp->nLeaves = pCut[0];
|
||||
for ( v = 1; v <= pCut[0]; v++ )
|
||||
pCutTemp->pLeaves[v-1] = pCut[v];
|
||||
pCutTemp->iFunc = pCut[pCut[0]+1];
|
||||
pCutTemp->Sign = Gia_CutGetSign( pCutTemp );
|
||||
pCutTemp->nTreeLeaves = Gia_CutTreeLeaves( p, pCutTemp );
|
||||
}
|
||||
return pList[0];
|
||||
}
|
||||
static inline void Gia_StoInitResult( Gia_Sto_t * p )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < GIA_MAX_CUTNUM; i++ )
|
||||
p->ppCuts[i] = &p->pCuts[2][i];
|
||||
}
|
||||
static inline void Gia_StoStoreResult( Gia_Sto_t * p, int iObj, Gia_Cut_t ** pCuts, int nCuts )
|
||||
{
|
||||
int i, v;
|
||||
Vec_Int_t * vList = Vec_WecEntry( p->vCuts, iObj );
|
||||
Vec_IntPush( vList, nCuts );
|
||||
for ( i = 0; i < nCuts; i++ )
|
||||
{
|
||||
Vec_IntPush( vList, pCuts[i]->nLeaves );
|
||||
for ( v = 0; v < (int)pCuts[i]->nLeaves; v++ )
|
||||
Vec_IntPush( vList, pCuts[i]->pLeaves[v] );
|
||||
Vec_IntPush( vList, pCuts[i]->iFunc );
|
||||
}
|
||||
}
|
||||
static inline void Gia_CutPrint( Gia_Sto_t * p, int iObj, Gia_Cut_t * pCut )
|
||||
{
|
||||
int i, nDigits = Abc_Base10Log(Gia_ManObjNum(p->pGia));
|
||||
if ( pCut == NULL ) { printf( "No cut.\n" ); return; }
|
||||
printf( "%d {", pCut->nLeaves );
|
||||
for ( i = 0; i < (int)pCut->nLeaves; i++ )
|
||||
printf( " %*d", nDigits, pCut->pLeaves[i] );
|
||||
for ( ; i < (int)p->nCutSize; i++ )
|
||||
printf( " %*s", nDigits, " " );
|
||||
printf( " } Cost = %3d CostL = %3d Tree = %d ",
|
||||
pCut->Cost, pCut->CostLev, pCut->nTreeLeaves );
|
||||
printf( "\n" );
|
||||
}
|
||||
void Gia_StoMergeCuts( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
|
||||
int fIsXor = Gia_ObjIsXor(pObj);
|
||||
int nCutSize = p->nCutSize;
|
||||
int nCutNum = p->nCutNum;
|
||||
int fComp0 = Gia_ObjFaninC0(pObj);
|
||||
int fComp1 = Gia_ObjFaninC1(pObj);
|
||||
int Fan0 = Gia_ObjFaninId0(pObj, iObj);
|
||||
int Fan1 = Gia_ObjFaninId1(pObj, iObj);
|
||||
int nCuts0 = Gia_StoPrepareSet( p, Fan0, 0 );
|
||||
int nCuts1 = Gia_StoPrepareSet( p, Fan1, 1 );
|
||||
int i, k, nCutsR = 0;
|
||||
Gia_Cut_t * pCut0, * pCut1, ** pCutsR = p->ppCuts;
|
||||
assert( !Gia_ObjIsBuf(pObj) );
|
||||
assert( !Gia_ObjIsMux(p->pGia, pObj) );
|
||||
Gia_StoInitResult( p );
|
||||
p->CutCount[0] += nCuts0 * nCuts1;
|
||||
for ( i = 0, pCut0 = p->pCuts[0]; i < nCuts0; i++, pCut0++ )
|
||||
for ( k = 0, pCut1 = p->pCuts[1]; k < nCuts1; k++, pCut1++ )
|
||||
{
|
||||
if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nCutSize && Gia_CutCountBits(pCut0->Sign | pCut1->Sign) > nCutSize )
|
||||
continue;
|
||||
p->CutCount[1]++;
|
||||
if ( !Gia_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nCutSize) )
|
||||
continue;
|
||||
if ( Gia_CutSetLastCutIsContained(pCutsR, nCutsR) )
|
||||
continue;
|
||||
p->CutCount[2]++;
|
||||
if ( p->fCutMin && Gia_CutComputeTruth(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
|
||||
pCutsR[nCutsR]->Sign = Gia_CutGetSign(pCutsR[nCutsR]);
|
||||
pCutsR[nCutsR]->nTreeLeaves = Gia_CutTreeLeaves( p, pCutsR[nCutsR] );
|
||||
nCutsR = Gia_CutSetAddCut( pCutsR, nCutsR, nCutNum );
|
||||
}
|
||||
p->CutCount[3] += nCutsR;
|
||||
p->nCutsOver += nCutsR == nCutNum-1;
|
||||
p->nCutsR = nCutsR;
|
||||
p->Pivot = iObj;
|
||||
// debug printout
|
||||
if ( 0 )
|
||||
{
|
||||
printf( "*** Obj = %4d NumCuts = %4d\n", iObj, nCutsR );
|
||||
for ( i = 0; i < nCutsR; i++ )
|
||||
Gia_CutPrint( p, iObj, pCutsR[i] );
|
||||
printf( "\n" );
|
||||
}
|
||||
// verify
|
||||
assert( nCutsR > 0 && nCutsR < nCutNum );
|
||||
assert( Gia_CutSetCheckArray(pCutsR, nCutsR) );
|
||||
// store the cutset
|
||||
Gia_StoStoreResult( p, iObj, pCutsR, nCutsR );
|
||||
if ( nCutsR > 1 || pCutsR[0]->nLeaves > 1 )
|
||||
Gia_CutAddUnit( p, iObj );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Incremental cut computation.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Sto_t * Gia_StoAlloc( Gia_Man_t * pGia, int nCutSize, int nCutNum, int fCutMin, int fTruthMin, int fVerbose )
|
||||
{
|
||||
Gia_Sto_t * p;
|
||||
assert( nCutSize < GIA_CUT_NO_LEAF );
|
||||
assert( nCutSize > 1 && nCutSize <= GIA_MAX_CUTSIZE );
|
||||
assert( nCutNum > 1 && nCutNum < GIA_MAX_CUTNUM );
|
||||
p = ABC_CALLOC( Gia_Sto_t, 1 );
|
||||
p->clkStart = Abc_Clock();
|
||||
p->nCutSize = nCutSize;
|
||||
p->nCutNum = nCutNum;
|
||||
p->fCutMin = fCutMin;
|
||||
p->fTruthMin = fTruthMin;
|
||||
p->fVerbose = fVerbose;
|
||||
p->pGia = pGia;
|
||||
p->vRefs = Vec_IntAlloc( Gia_ManObjNum(pGia) );
|
||||
p->vCuts = Vec_WecStart( Gia_ManObjNum(pGia) );
|
||||
p->vTtMem = fCutMin ? Vec_MemAllocForTT( nCutSize, 0 ) : NULL;
|
||||
return p;
|
||||
}
|
||||
void Gia_StoFree( Gia_Sto_t * p )
|
||||
{
|
||||
Vec_IntFree( p->vRefs );
|
||||
Vec_WecFree( p->vCuts );
|
||||
if ( p->fCutMin )
|
||||
Vec_MemHashFree( p->vTtMem );
|
||||
if ( p->fCutMin )
|
||||
Vec_MemFree( p->vTtMem );
|
||||
ABC_FREE( p );
|
||||
}
|
||||
void Gia_StoComputeCutsConst0( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Gia_CutAddZero( p, iObj );
|
||||
}
|
||||
void Gia_StoComputeCutsCi( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Gia_CutAddUnit( p, iObj );
|
||||
}
|
||||
void Gia_StoComputeCutsNode( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Gia_StoMergeCuts( p, iObj );
|
||||
}
|
||||
void Gia_StoRefObj( Gia_Sto_t * p, int iObj )
|
||||
{
|
||||
Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
|
||||
assert( iObj == Vec_IntSize(p->vRefs) );
|
||||
Vec_IntPush( p->vRefs, 0 );
|
||||
if ( Gia_ObjIsAnd(pObj) )
|
||||
{
|
||||
Vec_IntAddToEntry( p->vRefs, Gia_ObjFaninId0(pObj, iObj), 1 );
|
||||
Vec_IntAddToEntry( p->vRefs, Gia_ObjFaninId1(pObj, iObj), 1 );
|
||||
}
|
||||
else if ( Gia_ObjIsCo(pObj) )
|
||||
Vec_IntAddToEntry( p->vRefs, Gia_ObjFaninId0(pObj, iObj), 1 );
|
||||
}
|
||||
void Gia_StoComputeCuts( Gia_Man_t * pGia )
|
||||
{
|
||||
int nCutSize = 6;
|
||||
int nCutNum = 25;
|
||||
int fCutMin = 1;
|
||||
int fTruthMin = 1;
|
||||
int fVerbose = 1;
|
||||
Gia_Sto_t * p = Gia_StoAlloc( pGia, nCutSize, nCutNum, fCutMin, fTruthMin, fVerbose );
|
||||
Gia_Obj_t * pObj; int i, iObj;
|
||||
assert( nCutSize <= GIA_MAX_CUTSIZE );
|
||||
assert( nCutNum < GIA_MAX_CUTNUM );
|
||||
// prepare references
|
||||
Gia_ManForEachObj( p->pGia, pObj, iObj )
|
||||
Gia_StoRefObj( p, iObj );
|
||||
// compute cuts
|
||||
Gia_StoComputeCutsConst0( p, 0 );
|
||||
Gia_ManForEachCiId( p->pGia, iObj, i )
|
||||
Gia_StoComputeCutsCi( p, iObj );
|
||||
Gia_ManForEachAnd( p->pGia, pObj, iObj )
|
||||
Gia_StoComputeCutsNode( p, iObj );
|
||||
if ( p->fVerbose )
|
||||
{
|
||||
printf( "Running cut computation with CutSize = %d CutNum = %d CutMin = %s TruthMin = %s\n",
|
||||
p->nCutSize, p->nCutNum, p->fCutMin ? "yes":"no", p->fTruthMin ? "yes":"no" );
|
||||
printf( "CutPair = %.0f ", p->CutCount[0] );
|
||||
printf( "Merge = %.0f (%.2f %%) ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
|
||||
printf( "Eval = %.0f (%.2f %%) ", p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
|
||||
printf( "Cut = %.0f (%.2f %%) ", p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
|
||||
printf( "Cut/Node = %.2f ", p->CutCount[3] / Gia_ManAndNum(p->pGia) );
|
||||
printf( "\n" );
|
||||
printf( "The number of nodes with cut count over the limit (%d cuts) = %d nodes (out of %d). ",
|
||||
p->nCutNum, p->nCutsOver, Gia_ManAndNum(pGia) );
|
||||
Abc_PrintTime( 0, "Time", Abc_Clock() - p->clkStart );
|
||||
}
|
||||
Gia_StoFree( p );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
||||
|
|
@ -14,6 +14,7 @@ SRC += src/aig/gia/giaAig.c \
|
|||
src/aig/gia/giaCSatOld.c \
|
||||
src/aig/gia/giaCSat.c \
|
||||
src/aig/gia/giaCTas.c \
|
||||
src/aig/gia/giaCut.c \
|
||||
src/aig/gia/giaDfs.c \
|
||||
src/aig/gia/giaDup.c \
|
||||
src/aig/gia/giaEdge.c \
|
||||
|
|
|
|||
|
|
@ -5676,30 +5676,19 @@ int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Acb_Par_t Pars, * pPars = &Pars; int c;
|
||||
Acb_ParSetDefault( pPars );
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "MDOFLCavwh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "IOWFLCadvwh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
case 'M':
|
||||
case 'I':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
|
||||
Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->nTabooMax = atoi(argv[globalUtilOptind]);
|
||||
pPars->nTfiLevMax = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( pPars->nTabooMax < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'D':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->nDivMax = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( pPars->nDivMax < 0 )
|
||||
if ( pPars->nTfiLevMax < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'O':
|
||||
|
|
@ -5713,6 +5702,17 @@ int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( pPars->nTfoLevMax < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'W':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->nWinNodeMax = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( pPars->nWinNodeMax < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'F':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
|
|
@ -5749,6 +5749,9 @@ int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'a':
|
||||
pPars->fArea ^= 1;
|
||||
break;
|
||||
case 'd':
|
||||
pPars->fUseAshen ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
pPars->fVerbose ^= 1;
|
||||
break;
|
||||
|
|
@ -5777,6 +5780,7 @@ int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Abc_Print( -1, "Command is only applicable to LUT size no more than 6.\n" );
|
||||
return 1;
|
||||
}
|
||||
Abc_NtkToSop( pNtk, -1, ABC_INFINITY );
|
||||
pNtkNew = Abc_NtkOptMfse( pNtk, pPars );
|
||||
if ( pNtkNew == NULL )
|
||||
{
|
||||
|
|
@ -5787,15 +5791,16 @@ int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: mfse [-MDOFLC <num>] [-avwh]\n" );
|
||||
Abc_Print( -2, "usage: mfse [-IOWFLC <num>] [-advwh]\n" );
|
||||
Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" );
|
||||
Abc_Print( -2, "\t-M <num> : the max number of fanin nodes to skip (num >= 1) [default = %d]\n", pPars->nTabooMax );
|
||||
Abc_Print( -2, "\t-D <num> : the max number of divisors [default = %d]\n", pPars->nDivMax );
|
||||
Abc_Print( -2, "\t-I <num> : the number of levels in the TFI cone (2 <= num) [default = %d]\n", pPars->nTfiLevMax );
|
||||
Abc_Print( -2, "\t-O <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax );
|
||||
Abc_Print( -2, "\t-W <num> : the max number of nodes in the window (1 <= num) [default = %d]\n", pPars->nWinNodeMax );
|
||||
Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax );
|
||||
Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
|
||||
Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
|
||||
Abc_Print( -2, "\t-a : toggle minimizing area [default = %s]\n", pPars->fArea? "area": "delay" );
|
||||
Abc_Print( -2, "\t-d : toggle using Ashenhurst decomposition [default = %s]\n", pPars->fUseAshen? "yes": "no" );
|
||||
Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
|
||||
Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n");
|
||||
|
|
@ -12379,6 +12384,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
// extern void Cba_PrsReadBlifTest();
|
||||
// Cba_PrsReadBlifTest();
|
||||
}
|
||||
// Abc_NtkComputePaths( Abc_FrameReadNtk(pAbc) );
|
||||
return 0;
|
||||
usage:
|
||||
Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] <file_name>\n" );
|
||||
|
|
@ -43485,7 +43491,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
// extern void Gia_ManCheckFalseTest( Gia_Man_t * p, int nSlackMax );
|
||||
// extern void Gia_ParTest( Gia_Man_t * p, int nWords, int nProcs );
|
||||
// extern void Gia_ManTisTest( Gia_Man_t * pInit );
|
||||
extern void Gia_Iso3Test( Gia_Man_t * p );
|
||||
extern void Gia_StoComputeCuts( Gia_Man_t * p );
|
||||
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "WPFsvh" ) ) != EOF )
|
||||
|
|
@ -43589,7 +43595,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
// Jf_ManTestCnf( pAbc->pGia );
|
||||
// Gia_ManCheckFalseTest( pAbc->pGia, nFrames );
|
||||
// Gia_ParTest( pAbc->pGia, nWords, nProcs );
|
||||
//Cec2_ManSimulateTest( pAbc->pGia );
|
||||
Gia_StoComputeCuts( pAbc->pGia );
|
||||
// printf( "\nThis command is currently disabled.\n\n" );
|
||||
return 0;
|
||||
usage:
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ struct Acb_Ntk_t_
|
|||
Vec_Flt_t vCounts; // priority counts
|
||||
Vec_Wec_t vFanouts; // fanouts
|
||||
Vec_Wec_t vCnfs; // CNF
|
||||
Vec_Str_t vCnf; // CNF
|
||||
// other
|
||||
Vec_Que_t * vQue; // temporary
|
||||
Vec_Int_t vCover; // temporary
|
||||
|
|
@ -503,7 +504,10 @@ static inline void Acb_ObjRemoveFaninFanout( Acb_Ntk_t * p, int iObj )
|
|||
{
|
||||
int k, iFanin, * pFanins;
|
||||
Acb_ObjForEachFaninFast( p, iObj, pFanins, iFanin, k )
|
||||
Vec_IntRemove( Vec_WecEntry(&p->vFanouts, iFanin), iObj );
|
||||
{
|
||||
int RetValue = Vec_IntRemove( Vec_WecEntry(&p->vFanouts, iFanin), iObj );
|
||||
assert( RetValue );
|
||||
}
|
||||
}
|
||||
static inline void Acb_NtkCreateFanout( Acb_Ntk_t * p )
|
||||
{
|
||||
|
|
@ -569,6 +573,7 @@ static inline void Acb_NtkFree( Acb_Ntk_t * p )
|
|||
Vec_FltErase( &p->vCounts );
|
||||
Vec_WecErase( &p->vFanouts );
|
||||
Vec_WecErase( &p->vCnfs );
|
||||
Vec_StrErase( &p->vCnf );
|
||||
// other
|
||||
Vec_QueFreeP( &p->vQue );
|
||||
Vec_IntErase( &p->vCover );
|
||||
|
|
@ -967,7 +972,7 @@ extern int Acb_NtkComputeLevelD( Acb_Ntk_t * p, Vec_Int_t * vTfo );
|
|||
extern void Acb_NtkUpdateLevelD( Acb_Ntk_t * p, int iObj );
|
||||
extern void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj );
|
||||
|
||||
extern void Acb_NtkCreateNode( Acb_Ntk_t * p, word uTruth, Vec_Int_t * vSupp );
|
||||
extern int Acb_NtkCreateNode( Acb_Ntk_t * p, word uTruth, Vec_Int_t * vSupp );
|
||||
extern void Acb_NtkUpdateNode( Acb_Ntk_t * p, int Pivot, word uTruth, Vec_Int_t * vSupp );
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
|
|
|||
|
|
@ -44,27 +44,18 @@ ABC_NAMESPACE_IMPL_START
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Acb_Ntk_t * Acb_NtkFromAbc( Abc_Ntk_t * p )
|
||||
Acb_Ntk_t * Acb_NtkFromAbc2( Abc_Ntk_t * p )
|
||||
{
|
||||
int fTrack = 1;
|
||||
Acb_Man_t * pMan = Acb_ManAlloc( Abc_NtkSpec(p), 1, NULL, NULL, NULL, NULL );
|
||||
int i, k, NameId = Abc_NamStrFindOrAdd( pMan->pStrs, Abc_NtkName(p), NULL );
|
||||
Acb_Ntk_t * pNtk = Acb_NtkAlloc( pMan, NameId, Abc_NtkCiNum(p), Abc_NtkCoNum(p), Abc_NtkObjNum(p) );
|
||||
Abc_Obj_t * pObj, * pFanin;
|
||||
assert( Abc_NtkIsSopLogic(p) );
|
||||
pNtk->nFaninMax = 6;
|
||||
if ( fTrack ) Vec_IntFill( &pNtk->vArray2, Abc_NtkObjNumMax(p), -1 );
|
||||
Abc_NtkForEachCi( p, pObj, i )
|
||||
{
|
||||
pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CI, 0, 0 );
|
||||
if ( fTrack ) Vec_IntWriteEntry( &pNtk->vArray2, pObj->iTemp, Abc_ObjId(pObj) );
|
||||
}
|
||||
Abc_NtkForEachNode( p, pObj, i )
|
||||
{
|
||||
pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_LUT, Abc_ObjFaninNum(pObj), 0 );
|
||||
if ( fTrack ) Vec_IntWriteEntry( &pNtk->vArray2, pObj->iTemp, Abc_ObjId(pObj) );
|
||||
// printf( "%d -> %d\n%s", i, pObj->iTemp, (char *)pObj->pData );
|
||||
}
|
||||
Abc_NtkForEachCo( p, pObj, i )
|
||||
pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CO, 1, 0 );
|
||||
Abc_NtkForEachNode( p, pObj, i )
|
||||
|
|
@ -79,6 +70,40 @@ Acb_Ntk_t * Acb_NtkFromAbc( Abc_Ntk_t * p )
|
|||
Acb_NtkAdd( pMan, pNtk );
|
||||
return pNtk;
|
||||
}
|
||||
Acb_Ntk_t * Acb_NtkFromAbc( Abc_Ntk_t * p )
|
||||
{
|
||||
Acb_Man_t * pMan = Acb_ManAlloc( Abc_NtkSpec(p), 1, NULL, NULL, NULL, NULL );
|
||||
int i, k, NameId = Abc_NamStrFindOrAdd( pMan->pStrs, Abc_NtkName(p), NULL );
|
||||
Acb_Ntk_t * pNtk = Acb_NtkAlloc( pMan, NameId, Abc_NtkCiNum(p), Abc_NtkCoNum(p), Abc_NtkObjNumMax(p)-1 );
|
||||
Abc_Obj_t * pObj, * pFanin;
|
||||
assert( Abc_NtkIsSopLogic(p) );
|
||||
pNtk->nFaninMax = 6;
|
||||
for ( i = 1; i < Abc_NtkObjNumMax(p); i++ )
|
||||
{
|
||||
pObj = Abc_NtkObj( p, i );
|
||||
if ( pObj == NULL )
|
||||
Acb_ObjAlloc( pNtk, ABC_OPER_NONE, 0, 0 );
|
||||
else if ( Abc_ObjIsCi(pObj) )
|
||||
pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CI, 0, 0 );
|
||||
else if ( Abc_ObjIsCo(pObj) )
|
||||
pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_CO, 1, 0 );
|
||||
else if ( Abc_ObjIsNode(pObj) )
|
||||
pObj->iTemp = Acb_ObjAlloc( pNtk, ABC_OPER_LUT, Abc_ObjFaninNum(pObj), 0 );
|
||||
else assert( 0 );
|
||||
assert( pObj == NULL || pObj->iTemp == (int)Abc_ObjId(pObj) );
|
||||
}
|
||||
Abc_NtkForEachNode( p, pObj, i )
|
||||
Abc_ObjForEachFanin( pObj, pFanin, k )
|
||||
Acb_ObjAddFanin( pNtk, pObj->iTemp, pFanin->iTemp );
|
||||
Abc_NtkForEachCo( p, pObj, i )
|
||||
Acb_ObjAddFanin( pNtk, pObj->iTemp, Abc_ObjFanin(pObj, 0)->iTemp );
|
||||
Acb_NtkCleanObjTruths( pNtk );
|
||||
Abc_NtkForEachNode( p, pObj, i )
|
||||
Acb_ObjSetTruth( pNtk, pObj->iTemp, Abc_SopToTruth((char *)pObj->pData, Abc_ObjFaninNum(pObj)) );
|
||||
Acb_NtkSetRegNum( pNtk, Abc_NtkLatchNum(p) );
|
||||
Acb_NtkAdd( pMan, pNtk );
|
||||
return pNtk;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -209,16 +234,16 @@ void Acb_ParSetDefault( Acb_Par_t * pPars )
|
|||
{
|
||||
memset( pPars, 0, sizeof(Acb_Par_t) );
|
||||
pPars->nLutSize = 4; // LUT size
|
||||
pPars->nTfoLevMax = 1; // the maximum fanout levels
|
||||
pPars->nTfiLevMax = 2; // the maximum fanin levels
|
||||
pPars->nFanoutMax = 10; // the maximum number of fanouts
|
||||
pPars->nDivMax = 16; // the maximum divisor count
|
||||
pPars->nTabooMax = 4; // the minimum MFFC size
|
||||
pPars->nTfoLevMax = 2; // the maximum fanout levels
|
||||
pPars->nTfiLevMax = 3; // the maximum fanin levels
|
||||
pPars->nFanoutMax = 20; // the maximum number of fanouts
|
||||
pPars->nWinNodeMax = 100; // the maximum number of nodes in the window
|
||||
pPars->nGrowthLevel = 0; // the maximum allowed growth in level
|
||||
pPars->nBTLimit = 0; // the maximum number of conflicts in one SAT run
|
||||
pPars->nNodesMax = 0; // the maximum number of nodes to try
|
||||
pPars->iNodeOne = 0; // one particular node to try
|
||||
pPars->fArea = 1; // performs optimization for area
|
||||
pPars->fUseAshen = 0; // use Ashenhurst decomposition
|
||||
pPars->fMoreEffort = 0; // enables using more effort
|
||||
pPars->fVerbose = 0; // enable basic stats
|
||||
pPars->fVeryVerbose = 0; // enable detailed stats
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -42,11 +42,11 @@ struct Acb_Par_t_
|
|||
int nTfoLevMax; // the maximum fanout levels
|
||||
int nTfiLevMax; // the maximum fanin levels
|
||||
int nFanoutMax; // the maximum number of fanouts
|
||||
int nDivMax; // the maximum divisor count
|
||||
int nTabooMax; // the minimum MFFC size
|
||||
int nWinNodeMax; // the maximum number of nodes in the window
|
||||
int nGrowthLevel; // the maximum allowed growth in level
|
||||
int nBTLimit; // the maximum number of conflicts in one SAT run
|
||||
int nNodesMax; // the maximum number of nodes to try
|
||||
int fUseAshen; // user Ashenhurst decomposition
|
||||
int iNodeOne; // one particular node to try
|
||||
int fArea; // performs optimization for area
|
||||
int fMoreEffort; // performs high-affort minimization
|
||||
|
|
|
|||
|
|
@ -133,13 +133,14 @@ int Acb_NtkComputeLevelR( Acb_Ntk_t * p, Vec_Int_t * vTfi )
|
|||
{
|
||||
// it is assumed that vTfi contains CI nodes
|
||||
int i, iObj, Level = 0;
|
||||
if ( !Acb_NtkHasObjLevelD( p ) )
|
||||
Acb_NtkCleanObjLevelD( p );
|
||||
if ( !Acb_NtkHasObjLevelR( p ) )
|
||||
Acb_NtkCleanObjLevelR( p );
|
||||
Vec_IntForEachEntryReverse( vTfi, iObj, i )
|
||||
Acb_ObjComputeLevelR( p, iObj );
|
||||
Acb_NtkForEachCi( p, iObj, i )
|
||||
Level = Abc_MaxInt( Level, Acb_ObjLevelR(p, iObj) );
|
||||
assert( p->LevelMax == Level );
|
||||
// assert( p->LevelMax == Level );
|
||||
p->LevelMax = Level;
|
||||
return Level;
|
||||
}
|
||||
|
||||
|
|
@ -176,16 +177,38 @@ int Acb_ObjComputePathD( Acb_Ntk_t * p, int iObj )
|
|||
Path += Acb_ObjPathD(p, iFanin);
|
||||
return Acb_ObjSetPathD( p, iObj, Path );
|
||||
}
|
||||
int Acb_NtkComputePathsD( Acb_Ntk_t * p, Vec_Int_t * vTfo )
|
||||
int Acb_NtkComputePathsD( Acb_Ntk_t * p, Vec_Int_t * vTfo, int fReverse )
|
||||
{
|
||||
int i, iObj, Path = 0;
|
||||
// it is assumed that vTfo contains CO nodes
|
||||
//Vec_IntPrint( vTfo );
|
||||
if ( !Acb_NtkHasObjPathD( p ) )
|
||||
Acb_NtkCleanObjPathD( p );
|
||||
// it is assumed that vTfo contains CI nodes
|
||||
//assert( Acb_ObjSlack(p, Vec_IntEntry(vTfo, 0)) );
|
||||
Vec_IntForEachEntryReverse( vTfo, iObj, i )
|
||||
if ( !Acb_ObjSlack(p, iObj) )
|
||||
Acb_ObjComputePathD( p, iObj );
|
||||
else
|
||||
Acb_ObjSetPathD( p, iObj, 0 );
|
||||
if ( fReverse )
|
||||
{
|
||||
Vec_IntForEachEntryReverse( vTfo, iObj, i )
|
||||
{
|
||||
if ( Acb_ObjIsCi(p, iObj) )
|
||||
Acb_ObjSetPathD( p, iObj, Acb_ObjSlack(p, iObj) == 0 );
|
||||
else if ( Acb_ObjSlack(p, iObj) )
|
||||
Acb_ObjSetPathD( p, iObj, 0 );
|
||||
else
|
||||
Acb_ObjComputePathD( p, iObj );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec_IntForEachEntry( vTfo, iObj, i )
|
||||
{
|
||||
if ( Acb_ObjIsCi(p, iObj) )
|
||||
Acb_ObjSetPathD( p, iObj, Acb_ObjSlack(p, iObj) == 0 );
|
||||
else if ( Acb_ObjSlack(p, iObj) )
|
||||
Acb_ObjSetPathD( p, iObj, 0 );
|
||||
else
|
||||
Acb_ObjComputePathD( p, iObj );
|
||||
}
|
||||
}
|
||||
Acb_NtkForEachCo( p, iObj, i )
|
||||
Path += Acb_ObjPathD(p, iObj);
|
||||
p->nPaths = Path;
|
||||
|
|
@ -201,30 +224,69 @@ int Acb_ObjComputePathR( Acb_Ntk_t * p, int iObj )
|
|||
Path += Acb_ObjPathR(p, iFanout);
|
||||
return Acb_ObjSetPathR( p, iObj, Path );
|
||||
}
|
||||
int Acb_NtkComputePathsR( Acb_Ntk_t * p, Vec_Int_t * vTfi )
|
||||
int Acb_NtkComputePathsR( Acb_Ntk_t * p, Vec_Int_t * vTfi, int fReverse )
|
||||
{
|
||||
int i, iObj, Path = 0;
|
||||
// it is assumed that vTfi contains CI nodes
|
||||
if ( !Acb_NtkHasObjPathR( p ) )
|
||||
Acb_NtkCleanObjPathR( p );
|
||||
// it is assumed that vTfi contains CO nodes
|
||||
//assert( Acb_ObjSlack(p, Vec_IntEntry(vTfi, 0)) );
|
||||
Vec_IntForEachEntryReverse( vTfi, iObj, i )
|
||||
if ( !Acb_ObjSlack(p, iObj) )
|
||||
Acb_ObjComputePathR( p, iObj );
|
||||
else
|
||||
Acb_ObjSetPathR( p, iObj, 0 );
|
||||
if ( fReverse )
|
||||
{
|
||||
Vec_IntForEachEntryReverse( vTfi, iObj, i )
|
||||
{
|
||||
if ( Acb_ObjIsCo(p, iObj) )
|
||||
Acb_ObjSetPathR( p, iObj, Acb_ObjSlack(p, iObj) == 0 );
|
||||
else if ( Acb_ObjSlack(p, iObj) )
|
||||
Acb_ObjSetPathR( p, iObj, 0 );
|
||||
else
|
||||
Acb_ObjComputePathR( p, iObj );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec_IntForEachEntry( vTfi, iObj, i )
|
||||
{
|
||||
if ( Acb_ObjIsCo(p, iObj) )
|
||||
Acb_ObjSetPathR( p, iObj, Acb_ObjSlack(p, iObj) == 0 );
|
||||
else if ( Acb_ObjSlack(p, iObj) )
|
||||
Acb_ObjSetPathR( p, iObj, 0 );
|
||||
else
|
||||
Acb_ObjComputePathR( p, iObj );
|
||||
}
|
||||
}
|
||||
Acb_NtkForEachCi( p, iObj, i )
|
||||
Path += Acb_ObjPathR(p, iObj);
|
||||
assert( p->nPaths == Path );
|
||||
// assert( p->nPaths == Path );
|
||||
p->nPaths = Path;
|
||||
return Path;
|
||||
}
|
||||
|
||||
void Acb_NtkPrintPaths( Acb_Ntk_t * p )
|
||||
{
|
||||
int iObj;
|
||||
Acb_NtkForEachObj( p, iObj )
|
||||
{
|
||||
printf( "Obj = %5d : ", iObj );
|
||||
printf( "PathD = %5d ", Acb_ObjPathD(p, iObj) );
|
||||
printf( "PathR = %5d ", Acb_ObjPathR(p, iObj) );
|
||||
printf( "Paths = %5d ", Acb_ObjPathD(p, iObj) + Acb_ObjPathR(p, iObj) );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
int Acb_NtkComputePaths( Acb_Ntk_t * p )
|
||||
{
|
||||
int LevelD, LevelR;
|
||||
Vec_Int_t * vTfi = Acb_ObjCollectTfi( p, -1, 1 );
|
||||
Vec_Int_t * vTfo = Acb_ObjCollectTfo( p, -1, 1 );
|
||||
Acb_NtkComputeLevelD( p, vTfi );
|
||||
Acb_NtkComputeLevelR( p, vTfo );
|
||||
Acb_NtkComputePathsD( p, vTfi );
|
||||
Acb_NtkComputePathsR( p, vTfo );
|
||||
Acb_NtkComputeLevelD( p, vTfo );
|
||||
LevelD = p->LevelMax;
|
||||
Acb_NtkComputeLevelR( p, vTfi );
|
||||
LevelR = p->LevelMax;
|
||||
assert( LevelD == LevelR );
|
||||
Acb_NtkComputePathsD( p, vTfo, 1 );
|
||||
Acb_NtkComputePathsR( p, vTfi, 1 );
|
||||
return p->nPaths;
|
||||
}
|
||||
void Abc_NtkComputePaths( Abc_Ntk_t * p )
|
||||
|
|
@ -232,7 +294,9 @@ void Abc_NtkComputePaths( Abc_Ntk_t * p )
|
|||
extern Acb_Ntk_t * Acb_NtkFromAbc( Abc_Ntk_t * p );
|
||||
Acb_Ntk_t * pNtk = Acb_NtkFromAbc( p );
|
||||
Acb_NtkCreateFanout( pNtk );
|
||||
Acb_NtkCleanObjCounts( pNtk );
|
||||
printf( "Computed %d paths.\n", Acb_NtkComputePaths(pNtk) );
|
||||
Acb_NtkPrintPaths( pNtk );
|
||||
Acb_ManFree( pNtk->pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -251,6 +315,8 @@ void Abc_NtkComputePaths( Abc_Ntk_t * p )
|
|||
void Acb_ObjUpdatePriority( Acb_Ntk_t * p, int iObj )
|
||||
{
|
||||
int nPaths;
|
||||
if ( Acb_ObjIsCio(p, iObj) || Acb_ObjLevelD(p, iObj) == 1 )
|
||||
return;
|
||||
if ( p->vQue == NULL )
|
||||
{
|
||||
Acb_NtkCleanObjCounts( p );
|
||||
|
|
@ -258,35 +324,63 @@ void Acb_ObjUpdatePriority( Acb_Ntk_t * p, int iObj )
|
|||
Vec_QueSetPriority( p->vQue, Vec_FltArrayP(&p->vCounts) );
|
||||
}
|
||||
nPaths = Acb_ObjPathD(p, iObj) + Acb_ObjPathR(p, iObj);
|
||||
if ( nPaths == 0 )
|
||||
return;
|
||||
Acb_ObjSetCounts( p, iObj, (float)nPaths );
|
||||
if ( Vec_QueIsMember( p->vQue, iObj ) )
|
||||
{
|
||||
//printf( "Updating object %d with count %d\n", iObj, nPaths );
|
||||
Vec_QueUpdate( p->vQue, iObj );
|
||||
else
|
||||
}
|
||||
else if ( nPaths )
|
||||
{
|
||||
//printf( "Adding object %d with count %d\n", iObj, nPaths );
|
||||
Vec_QuePush( p->vQue, iObj );
|
||||
}
|
||||
}
|
||||
void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj )
|
||||
{
|
||||
int i, Entry, LevelMax = p->LevelMax;
|
||||
// assuming that level of the new nodes is up to date
|
||||
int LevelD, LevelR, nPaths1, nPaths2;
|
||||
// assuming that direct level of the new nodes (including iObj) is up to date
|
||||
Vec_Int_t * vTfi = Acb_ObjCollectTfi( p, iObj, 1 );
|
||||
Vec_Int_t * vTfo = Acb_ObjCollectTfo( p, iObj, 1 );
|
||||
if ( iObj > 0 )
|
||||
{
|
||||
assert( Vec_IntEntryLast(vTfi) == iObj );
|
||||
assert( Vec_IntEntryLast(vTfo) == iObj );
|
||||
Vec_IntPop( vTfo );
|
||||
}
|
||||
Acb_NtkComputeLevelD( p, vTfo );
|
||||
LevelD = p->LevelMax;
|
||||
Acb_NtkComputeLevelR( p, vTfi );
|
||||
LevelR = p->LevelMax;
|
||||
assert( LevelD == LevelR );
|
||||
if ( iObj > 0 && LevelMax > p->LevelMax ) // reduced level
|
||||
{
|
||||
iObj = -1;
|
||||
vTfi = Acb_ObjCollectTfi( p, -1, 1 );
|
||||
vTfo = Acb_ObjCollectTfo( p, -1, 1 );
|
||||
Vec_QueClear( p->vQue );
|
||||
// add backup here
|
||||
}
|
||||
Acb_NtkComputePathsD( p, vTfo );
|
||||
Acb_NtkComputePathsR( p, vTfi );
|
||||
if ( iObj > 0 )
|
||||
Acb_NtkComputePathsD( p, vTfi, 0 );
|
||||
Acb_NtkComputePathsD( p, vTfo, 1 );
|
||||
nPaths1 = p->nPaths;
|
||||
if ( iObj > 0 )
|
||||
Acb_NtkComputePathsR( p, vTfo, 0 );
|
||||
Acb_NtkComputePathsR( p, vTfi, 1 );
|
||||
nPaths2 = p->nPaths;
|
||||
assert( nPaths1 == nPaths2 );
|
||||
Vec_IntForEachEntry( vTfi, Entry, i )
|
||||
Acb_ObjUpdatePriority( p, Entry );
|
||||
if ( iObj > 0 )
|
||||
Vec_IntForEachEntry( vTfo, Entry, i )
|
||||
Acb_ObjUpdatePriority( p, Entry );
|
||||
|
||||
// printf( "Updating timing for object %d.\n", iObj );
|
||||
// Acb_NtkPrintPaths( p );
|
||||
// while ( (Entry = (int)Vec_QueTopPriority(p->vQue)) > 0 )
|
||||
// printf( "Obj = %5d : Prio = %d.\n", Vec_QuePop(p->vQue), Entry );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
@ -300,22 +394,48 @@ void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_NtkCreateNode( Acb_Ntk_t * p, word uTruth, Vec_Int_t * vSupp )
|
||||
int Acb_NtkCreateNode( Acb_Ntk_t * p, word uTruth, Vec_Int_t * vSupp )
|
||||
{
|
||||
int Pivot = Acb_ObjAlloc( p, ABC_OPER_LUT, Vec_IntSize(vSupp), 0 );
|
||||
Acb_ObjSetTruth( p, Pivot, uTruth );
|
||||
Acb_ObjAddFanins( p, Pivot, vSupp );
|
||||
Acb_ObjAddFaninFanout( p, Pivot );
|
||||
Acb_ObjComputeLevelD( p, Pivot );
|
||||
return Pivot;
|
||||
}
|
||||
void Acb_NtkResetNode( Acb_Ntk_t * p, int Pivot, word uTruth, Vec_Int_t * vSupp )
|
||||
{
|
||||
// remember old fanins
|
||||
int k, iFanin, * pFanins;
|
||||
Vec_Int_t * vFanins = Vec_IntAlloc( 6 );
|
||||
assert( !Acb_ObjIsCio(p, Pivot) );
|
||||
Acb_ObjForEachFaninFast( p, Pivot, pFanins, iFanin, k )
|
||||
Vec_IntPush( vFanins, iFanin );
|
||||
// update function
|
||||
Vec_WrdSetEntry( &p->vObjTruth, Pivot, uTruth );
|
||||
Vec_IntErase( Vec_WecEntry(&p->vCnfs, Pivot) );
|
||||
// remove old fanins
|
||||
Acb_ObjRemoveFaninFanout( p, Pivot );
|
||||
Acb_ObjRemoveFanins( p, Pivot );
|
||||
// add new fanins
|
||||
if ( vSupp != NULL )
|
||||
{
|
||||
assert( Acb_ObjFanoutNum(p, Pivot) > 0 );
|
||||
Acb_ObjAddFanins( p, Pivot, vSupp );
|
||||
Acb_ObjAddFaninFanout( p, Pivot );
|
||||
}
|
||||
else if ( Acb_ObjFanoutNum(p, Pivot) == 0 )
|
||||
Acb_ObjCleanType( p, Pivot );
|
||||
// delete dangling fanins
|
||||
Vec_IntForEachEntry( vFanins, iFanin, k )
|
||||
if ( !Acb_ObjIsCio(p, iFanin) && Acb_ObjFanoutNum(p, iFanin) == 0 )
|
||||
Acb_NtkResetNode( p, iFanin, 0, NULL );
|
||||
Vec_IntFree( vFanins );
|
||||
}
|
||||
void Acb_NtkUpdateNode( Acb_Ntk_t * p, int Pivot, word uTruth, Vec_Int_t * vSupp )
|
||||
{
|
||||
Vec_WrdSetEntry( &p->vObjTruth, Pivot, uTruth );
|
||||
Vec_IntErase( Vec_WecEntry(&p->vCnfs, Pivot) );
|
||||
Acb_ObjRemoveFaninFanout( p, Pivot );
|
||||
Acb_ObjRemoveFanins( p, Pivot );
|
||||
Acb_ObjAddFanins( p, Pivot, vSupp );
|
||||
Acb_ObjAddFaninFanout( p, Pivot );
|
||||
Acb_NtkResetNode( p, Pivot, uTruth, vSupp );
|
||||
Acb_ObjComputeLevelD( p, Pivot );
|
||||
if ( p->vQue == NULL )
|
||||
Acb_NtkUpdateLevelD( p, Pivot );
|
||||
else
|
||||
|
|
|
|||
|
|
@ -124,6 +124,10 @@ static inline void Hsh_IntManStop( Hsh_IntMan_t * p )
|
|||
Vec_WrdFree( p->vObjs );
|
||||
ABC_FREE( p );
|
||||
}
|
||||
static inline int Hsh_IntManEntryNum( Hsh_IntMan_t * p )
|
||||
{
|
||||
return Vec_WrdSize(p->vObjs);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -164,7 +168,7 @@ static inline int Hsh_IntManAdd( Hsh_IntMan_t * p, int iData )
|
|||
Vec_IntFill( p->vTable, Abc_PrimeCudd(2*Vec_IntSize(p->vTable)), -1 );
|
||||
for ( i = 0; i < Vec_WrdSize(p->vObjs); i++ )
|
||||
{
|
||||
pPlace = Vec_IntEntryP( p->vTable, Hsh_IntManHash(Hsh_IntData(p, i), p->nSize, Vec_IntSize(p->vTable)) );
|
||||
pPlace = Vec_IntEntryP( p->vTable, Hsh_IntManHash(Hsh_IntData(p, Hsh_IntObj(p, i)->iData), p->nSize, Vec_IntSize(p->vTable)) );
|
||||
Hsh_IntObj(p, i)->iNext = *pPlace; *pPlace = i;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ void Sfm_ParSetDefault( Sfm_Par_t * pPars )
|
|||
void Sfm_NtkPrintStats( Sfm_Ntk_t * p )
|
||||
{
|
||||
p->timeOther = p->timeTotal - p->timeWin - p->timeDiv - p->timeCnf - p->timeSat;
|
||||
printf( "Nodes = %d. Try = %d. Resub = %d. Div = %d. SAT calls = %d. Timeouts = %d. MaxDivs = %d.\n",
|
||||
Sfm_NtkNodeNum(p), p->nNodesTried, p->nRemoves + p->nResubs, p->nTotalDivs, p->nSatCalls, p->nTimeOuts, p->nMaxDivs );
|
||||
printf( "Nodes = %d. Try = %d. Resub = %d. Div = %d (ave = %d). SAT calls = %d. Timeouts = %d. MaxDivs = %d.\n",
|
||||
Sfm_NtkNodeNum(p), p->nNodesTried, p->nRemoves + p->nResubs, p->nTotalDivs, p->nTotalDivs/Abc_MaxInt(1, p->nNodesTried), p->nSatCalls, p->nTimeOuts, p->nMaxDivs );
|
||||
|
||||
printf( "Attempts : " );
|
||||
printf( "Remove %6d out of %6d (%6.2f %%) ", p->nRemoves, p->nTryRemoves, 100.0*p->nRemoves/Abc_MaxInt(1, p->nTryRemoves) );
|
||||
|
|
|
|||
|
|
@ -1334,6 +1334,9 @@ void sat_solver_delete(sat_solver* s)
|
|||
veci_delete(&s->temp_clause);
|
||||
veci_delete(&s->conf_final);
|
||||
|
||||
veci_delete(&s->user_vars);
|
||||
veci_delete(&s->user_values);
|
||||
|
||||
// delete arrays
|
||||
if (s->reasons != 0){
|
||||
int i;
|
||||
|
|
@ -1963,6 +1966,13 @@ int sat_solver_solve_internal(sat_solver* s)
|
|||
printf("==============================================================================\n");
|
||||
|
||||
sat_solver_canceluntil(s,s->root_level);
|
||||
// save variable values
|
||||
if ( status == l_True && s->user_vars.size )
|
||||
{
|
||||
int v;
|
||||
for ( v = 0; v < s->user_vars.size; v++ )
|
||||
veci_push(&s->user_values, sat_solver_var_value(s, s->user_vars.ptr[v]));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -2186,6 +2196,7 @@ int sat_solver_minimize_assumptions( sat_solver* s, int * pLits, int nLits, int
|
|||
s->nConfLimit = nConfLimit;
|
||||
status = sat_solver_solve_internal( s );
|
||||
s->nConfLimit = Temp;
|
||||
//printf( "%c", status == l_False ? 'u' : 's' );
|
||||
return (int)(status != l_False); // return 1 if the problem is not UNSAT
|
||||
}
|
||||
assert( nLits >= 2 );
|
||||
|
|
|
|||
|
|
@ -193,6 +193,10 @@ struct sat_solver_t
|
|||
|
||||
veci temp_clause; // temporary storage for a CNF clause
|
||||
|
||||
// assignment storage
|
||||
veci user_vars; // variable IDs
|
||||
veci user_values; // values of these variables
|
||||
|
||||
// CNF loading
|
||||
void * pCnfMan; // external CNF manager
|
||||
int(*pCnfFunc)(void * p, int); // external callback
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumpBegin,
|
|||
nUnits++;
|
||||
|
||||
// start the file
|
||||
pFile = fopen( pFileName, "wb" );
|
||||
pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Sat_SolverWriteDimacs(): Cannot open the ouput file.\n" );
|
||||
|
|
@ -121,7 +121,7 @@ void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumpBegin,
|
|||
}
|
||||
|
||||
fprintf( pFile, "\n" );
|
||||
fclose( pFile );
|
||||
if ( pFileName ) fclose( pFile );
|
||||
}
|
||||
void Sat_Solver2WriteDimacs( sat_solver2 * p, char * pFileName, lit* assumpBegin, lit* assumpEnd, int incrementVars )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses,
|
|||
extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p );
|
||||
extern void Cnf_DataFree( Cnf_Dat_t * p );
|
||||
extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus );
|
||||
extern Vec_Int_t * Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar );
|
||||
extern void Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar, Vec_Int_t * vFlips );
|
||||
extern void Cnf_DataLiftAndFlipLits( Cnf_Dat_t * p, int nVarsPlus, Vec_Int_t * vLits );
|
||||
extern void Cnf_DataPrint( Cnf_Dat_t * p, int fReadable );
|
||||
extern void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable, Vec_Int_t * vForAlls, Vec_Int_t * vExists );
|
||||
|
|
|
|||
|
|
@ -215,14 +215,14 @@ void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus )
|
|||
for ( v = 0; v < p->nLiterals; v++ )
|
||||
p->pClauses[0][v] += 2*nVarsPlus;
|
||||
}
|
||||
Vec_Int_t * Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar )
|
||||
void Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar, Vec_Int_t * vFlips )
|
||||
{
|
||||
Vec_Int_t * vLits = Vec_IntAlloc( 100 ); int v;
|
||||
int v;
|
||||
assert( p->pMan == NULL );
|
||||
Vec_IntClear( vFlips );
|
||||
for ( v = 0; v < p->nLiterals; v++ )
|
||||
if ( Abc_Lit2Var(p->pClauses[0][v]) == iFlipVar )
|
||||
Vec_IntPush( vLits, v );
|
||||
return vLits;
|
||||
Vec_IntPush( vFlips, v );
|
||||
}
|
||||
void Cnf_DataLiftAndFlipLits( Cnf_Dat_t * p, int nVarsPlus, Vec_Int_t * vLits )
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue