Commit faf3bf34 by Alan Mishchenko

Improvement in SOP balancing.

parent 9c502b70
...@@ -51,6 +51,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -51,6 +51,7 @@ ABC_NAMESPACE_HEADER_START
typedef struct Kit_Sop_t_ Kit_Sop_t; typedef struct Kit_Sop_t_ Kit_Sop_t;
struct Kit_Sop_t_ struct Kit_Sop_t_
{ {
int nLits; // the number of literals
int nCubes; // the number of cubes int nCubes; // the number of cubes
unsigned * pCubes; // the storage for cubes unsigned * pCubes; // the storage for cubes
}; };
......
...@@ -87,7 +87,7 @@ int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryB ...@@ -87,7 +87,7 @@ int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryB
if ( pcRes2->nCubes >= 0 ) if ( pcRes2->nCubes >= 0 )
{ {
assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) ); assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
if ( pcRes->nCubes > pcRes2->nCubes ) if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
{ {
RetValue = 1; RetValue = 1;
pcRes = pcRes2; pcRes = pcRes2;
...@@ -157,6 +157,7 @@ unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit ...@@ -157,6 +157,7 @@ unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit
// check for constants // check for constants
if ( Kit_TruthIsConst0( puOn, nVars ) ) if ( Kit_TruthIsConst0( puOn, nVars ) )
{ {
pcRes->nLits = 0;
pcRes->nCubes = 0; pcRes->nCubes = 0;
pcRes->pCubes = NULL; pcRes->pCubes = NULL;
Kit_TruthClear( pTemp, nVars ); Kit_TruthClear( pTemp, nVars );
...@@ -164,6 +165,7 @@ unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit ...@@ -164,6 +165,7 @@ unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit
} }
if ( Kit_TruthIsConst1( puOnDc, nVars ) ) if ( Kit_TruthIsConst1( puOnDc, nVars ) )
{ {
pcRes->nLits = 0;
pcRes->nCubes = 1; pcRes->nCubes = 1;
pcRes->pCubes = Vec_IntFetch( vStore, 1 ); pcRes->pCubes = Vec_IntFetch( vStore, 1 );
if ( pcRes->pCubes == NULL ) if ( pcRes->pCubes == NULL )
...@@ -222,6 +224,7 @@ unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit ...@@ -222,6 +224,7 @@ unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit
return NULL; return NULL;
} }
// create the resulting cover // create the resulting cover
pcRes->nLits = pcRes0->nLits + pcRes1->nLits + pcRes2->nLits + pcRes0->nCubes + pcRes1->nCubes;
pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes; pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes ); pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes );
if ( pcRes->pCubes == NULL ) if ( pcRes->pCubes == NULL )
...@@ -273,12 +276,14 @@ unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t ...@@ -273,12 +276,14 @@ unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t
assert( (uOn & ~uOnDc) == 0 ); assert( (uOn & ~uOnDc) == 0 );
if ( uOn == 0 ) if ( uOn == 0 )
{ {
pcRes->nLits = 0;
pcRes->nCubes = 0; pcRes->nCubes = 0;
pcRes->pCubes = NULL; pcRes->pCubes = NULL;
return 0; return 0;
} }
if ( uOnDc == 0xFFFFFFFF ) if ( uOnDc == 0xFFFFFFFF )
{ {
pcRes->nLits = 0;
pcRes->nCubes = 1; pcRes->nCubes = 1;
pcRes->pCubes = Vec_IntFetch( vStore, 1 ); pcRes->pCubes = Vec_IntFetch( vStore, 1 );
if ( pcRes->pCubes == NULL ) if ( pcRes->pCubes == NULL )
...@@ -323,6 +328,7 @@ unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t ...@@ -323,6 +328,7 @@ unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t
return 0; return 0;
} }
// create the resulting cover // create the resulting cover
pcRes->nLits = pcRes0->nLits + pcRes1->nLits + pcRes2->nLits + pcRes0->nCubes + pcRes1->nCubes;
pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes; pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes ); pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes );
if ( pcRes->pCubes == NULL ) if ( pcRes->pCubes == NULL )
......
...@@ -245,7 +245,7 @@ word If_AigVerifyArray( Vec_Int_t * vAig, int nLeaves, int fCompl ) ...@@ -245,7 +245,7 @@ word If_AigVerifyArray( Vec_Int_t * vAig, int nLeaves, int fCompl )
} }
else else
{ {
word Truth0, Truth1, TruthR; word Truth0 = 0, Truth1 = 0, TruthR;
int i, iVar0, iVar1, iLit0, iLit1; int i, iVar0, iVar1, iLit0, iLit1;
assert( Vec_IntSize(vAig) & 1 ); assert( Vec_IntSize(vAig) & 1 );
Vec_IntForEachEntryDouble( vAig, iLit0, iLit1, i ) Vec_IntForEachEntryDouble( vAig, iLit0, iLit1, i )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment