Commit c062cc18 by Alan Mishchenko

Changes to LUT mappers.

parent a8a08035
...@@ -482,10 +482,11 @@ int If_DsdObjCompare( Vec_Ptr_t * p, int iLit0, int iLit1 ) ...@@ -482,10 +482,11 @@ int If_DsdObjCompare( Vec_Ptr_t * p, int iLit0, int iLit1 )
if ( Res != 0 ) if ( Res != 0 )
return Res; return Res;
} }
if ( Abc_LitIsCompl(iLit0) < Abc_LitIsCompl(iLit1) )
return -1;
if ( Abc_LitIsCompl(iLit0) > Abc_LitIsCompl(iLit1) ) if ( Abc_LitIsCompl(iLit0) > Abc_LitIsCompl(iLit1) )
return -1;
if ( Abc_LitIsCompl(iLit0) < Abc_LitIsCompl(iLit1) )
return 1; return 1;
assert( iLit0 == iLit1 );
return 0; return 0;
} }
void If_DsdObjSort( Vec_Ptr_t * p, int * pLits, int nLits, int * pPerm ) void If_DsdObjSort( Vec_Ptr_t * p, int * pLits, int nLits, int * pPerm )
...@@ -554,7 +555,7 @@ int If_DsdObjCreate( If_DsdMan_t * p, int Type, int * pLits, int nLits, int trut ...@@ -554,7 +555,7 @@ int If_DsdObjCreate( If_DsdMan_t * p, int Type, int * pLits, int nLits, int trut
int i, iPrev = -1; int i, iPrev = -1;
// check structural canonicity // check structural canonicity
assert( Type != DAU_DSD_MUX || nLits == 3 ); assert( Type != DAU_DSD_MUX || nLits == 3 );
assert( Type != DAU_DSD_MUX || !Abc_LitIsCompl(pLits[0]) ); // assert( Type != DAU_DSD_MUX || !Abc_LitIsCompl(pLits[0]) );
assert( Type != DAU_DSD_MUX || !Abc_LitIsCompl(pLits[1]) || !Abc_LitIsCompl(pLits[2]) ); assert( Type != DAU_DSD_MUX || !Abc_LitIsCompl(pLits[1]) || !Abc_LitIsCompl(pLits[2]) );
// check that leaves are in good order // check that leaves are in good order
if ( Type == DAU_DSD_AND || Type == DAU_DSD_XOR ) if ( Type == DAU_DSD_AND || Type == DAU_DSD_XOR )
...@@ -844,6 +845,117 @@ word * If_DsdManComputeTruth( If_DsdMan_t * p, int iDsd, unsigned char * pPermLi ...@@ -844,6 +845,117 @@ word * If_DsdManComputeTruth( If_DsdMan_t * p, int iDsd, unsigned char * pPermLi
/**Function************************************************************* /**Function*************************************************************
Synopsis [Procedures to propagate the invertor.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int If_DsdManCheckInv_rec( If_DsdMan_t * p, int iLit )
{
If_DsdObj_t * pObj;
int i, iFanin;
pObj = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iLit) );
if ( If_DsdObjType(pObj) == IF_DSD_VAR )
return 1;
if ( If_DsdObjType(pObj) == IF_DSD_AND || If_DsdObjType(pObj) == IF_DSD_PRIME )
return 0;
if ( If_DsdObjType(pObj) == IF_DSD_XOR )
{
If_DsdObjForEachFaninLit( p->vObjs, pObj, iFanin, i )
if ( If_DsdManCheckInv_rec(p, iFanin) )
return 1;
return 0;
}
if ( If_DsdObjType(pObj) == IF_DSD_MUX )
return If_DsdManCheckInv_rec(p, pObj->pFans[1]) && If_DsdManCheckInv_rec(p, pObj->pFans[2]);
assert( 0 );
return 0;
}
/*
int If_DsdManPushInv_rec( If_DsdMan_t * p, int iLit, unsigned char * pPerm )
{
If_DsdObj_t * pObj;
int i, iFanin, RetValue;
pObj = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iLit) );
if ( If_DsdObjType(pObj) == IF_DSD_VAR )
{
pPerm[0] = (unsigned char)Abc_LitNot((int)pPerm[0]);
return 1;
}
if ( If_DsdObjType(pObj) == IF_DSD_AND || If_DsdObjType(pObj) == IF_DSD_PRIME )
return 0;
if ( If_DsdObjType(pObj) == IF_DSD_XOR )
{
If_DsdObjForEachFaninLit( p->vObjs, pObj, iFanin, i )
{
if ( If_DsdManCheckInv_rec(p, iFanin) )
{
RetValue = If_DsdManPushInv_rec(p, iFanin, pPerm); assert( RetValue );
return 1;
}
pPerm += If_DsdVecLitSuppSize(p->vObjs, iFanin);
}
return 0;
}
if ( If_DsdObjType(pObj) == IF_DSD_MUX )
{
if ( If_DsdManCheckInv_rec(p, pObj->pFans[1]) && If_DsdManCheckInv_rec(p, pObj->pFans[2]) )
{
pPerm += If_DsdVecLitSuppSize(p->vObjs, pObj->pFans[0]);
RetValue = If_DsdManPushInv_rec(p, pObj->pFans[1], pPerm); assert( RetValue );
pPerm += If_DsdVecLitSuppSize(p->vObjs, pObj->pFans[1]);
RetValue = If_DsdManPushInv_rec(p, pObj->pFans[2], pPerm); assert( RetValue );
return 1;
}
return 0;
}
assert( 0 );
return 0;
}
*/
int If_DsdManPushInv_rec( If_DsdMan_t * p, int iLit, unsigned char * pPerm )
{
If_DsdObj_t * pObj;
int i, iFanin;
pObj = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iLit) );
if ( If_DsdObjType(pObj) == IF_DSD_VAR )
pPerm[0] = (unsigned char)Abc_LitNot((int)pPerm[0]);
else if ( If_DsdObjType(pObj) == IF_DSD_XOR )
{
If_DsdObjForEachFaninLit( p->vObjs, pObj, iFanin, i )
{
if ( If_DsdManCheckInv_rec(p, iFanin) )
{
If_DsdManPushInv_rec( p, iFanin, pPerm );
break;
}
pPerm += If_DsdVecLitSuppSize(p->vObjs, iFanin);
}
}
else if ( If_DsdObjType(pObj) == IF_DSD_MUX )
{
assert( If_DsdManCheckInv_rec(p, pObj->pFans[1]) && If_DsdManCheckInv_rec(p, pObj->pFans[2]) );
pPerm += If_DsdVecLitSuppSize(p->vObjs, pObj->pFans[0]);
If_DsdManPushInv_rec(p, pObj->pFans[1], pPerm);
pPerm += If_DsdVecLitSuppSize(p->vObjs, pObj->pFans[1]);
If_DsdManPushInv_rec(p, pObj->pFans[2], pPerm);
}
else assert( 0 );
return 1;
}
int If_DsdManPushInv( If_DsdMan_t * p, int iLit, unsigned char * pPerm )
{
if ( Abc_LitIsCompl(iLit) && If_DsdManCheckInv_rec(p, iLit) )
return If_DsdManPushInv_rec( p, iLit, pPerm );
return 0;
}
/**Function*************************************************************
Synopsis [Performs DSD operation.] Synopsis [Performs DSD operation.]
Description [] Description []
...@@ -870,111 +982,86 @@ int If_DsdManComputeFirst( If_DsdMan_t * p, If_DsdObj_t * pObj, int * pFirsts ) ...@@ -870,111 +982,86 @@ int If_DsdManComputeFirst( If_DsdMan_t * p, If_DsdObj_t * pObj, int * pFirsts )
int If_DsdManOperation( If_DsdMan_t * p, int Type, int * pLits, int nLits, unsigned char * pPerm, word * pTruth ) int If_DsdManOperation( If_DsdMan_t * p, int Type, int * pLits, int nLits, unsigned char * pPerm, word * pTruth )
{ {
If_DsdObj_t * pObj, * pFanin; If_DsdObj_t * pObj, * pFanin;
unsigned char pPermNew[DAU_MAX_VAR]; unsigned char pPermNew[DAU_MAX_VAR], * pPermStart = pPerm;
int nChildren = 0, pChildren[DAU_MAX_VAR], pBegEnd[DAU_MAX_VAR]; int nChildren = 0, pChildren[DAU_MAX_VAR], pBegEnd[DAU_MAX_VAR];
int i, k, j, Id, iFanin, fComplFan, fCompl = 0, nSSize = 0; int i, k, j, Id, iFanin, fCompl = 0, nSSize = 0;
if ( Type == IF_DSD_AND ) if ( Type == IF_DSD_AND || Type == IF_DSD_XOR )
{ {
for ( k = 0; k < nLits; k++ ) for ( k = 0; k < nLits; k++ )
{ {
pObj = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pLits[k]) ); if ( Type == IF_DSD_XOR && Abc_LitIsCompl(pLits[k]) )
if ( Abc_LitIsCompl(pLits[k]) || If_DsdObjType(pObj) != IF_DSD_AND )
{ {
fComplFan = If_DsdObjIsVar(pObj) && Abc_LitIsCompl(pLits[k]); pLits[k] = Abc_LitNot(pLits[k]);
pBegEnd[nChildren] = (nSSize << 16) | (fComplFan << 8) | (nSSize + pObj->nSupp); fCompl ^= 1;
nSSize += pObj->nSupp;
pChildren[nChildren++] = Abc_LitNotCond( pLits[k], fComplFan );
} }
else pObj = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pLits[k]) );
if ( Type == If_DsdObjType(pObj) && (Type == IF_DSD_XOR || !Abc_LitIsCompl(pLits[k])) )
{ {
If_DsdObjForEachFaninLit( p->vObjs, pObj, iFanin, i ) If_DsdObjForEachFaninLit( p->vObjs, pObj, iFanin, i )
{ {
pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iFanin) ); assert( Type == IF_DSD_AND || !Abc_LitIsCompl(iFanin) );
fComplFan = If_DsdObjIsVar(pFanin) && Abc_LitIsCompl(iFanin); pChildren[nChildren] = iFanin;
pBegEnd[nChildren] = (nSSize << 16) | (fComplFan << 8) | (nSSize + pFanin->nSupp); pBegEnd[nChildren++] = (nSSize << 16) | (nSSize + If_DsdVecLitSuppSize(p->vObjs, iFanin));
pChildren[nChildren++] = Abc_LitNotCond( iFanin, fComplFan ); nSSize += If_DsdVecLitSuppSize(p->vObjs, iFanin);
nSSize += pFanin->nSupp;
}
} }
} }
If_DsdObjSort( p->vObjs, pChildren, nChildren, pBegEnd );
// create permutation
for ( j = i = 0; i < nChildren; i++ )
for ( k = (pBegEnd[i] >> 16); k < (pBegEnd[i] & 0xFF); k++ )
pPermNew[j++] = (unsigned char)Abc_LitNotCond( pPerm[k], (pBegEnd[i] >> 8) & 1 );
assert( j == nSSize );
for ( j = 0; j < nSSize; j++ )
pPerm[j] = pPermNew[j];
}
else if ( Type == IF_DSD_XOR )
{
fComplFan = 0;
for ( k = 0; k < nLits; k++ )
{
fCompl ^= Abc_LitIsCompl(pLits[k]);
pObj = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pLits[k]) );
if ( If_DsdObjType(pObj) != IF_DSD_XOR )
{
pBegEnd[nChildren] = (nSSize << 16) | (fComplFan << 8) | (nSSize + pObj->nSupp);
pChildren[nChildren++] = Abc_LitRegular(pLits[k]);
nSSize += pObj->nSupp;
}
else else
{ {
If_DsdObjForEachFaninLit( p->vObjs, pObj, iFanin, i ) pChildren[nChildren] = Abc_LitNotCond( pLits[k], If_DsdManPushInv(p, pLits[k], pPermStart) );
{ pBegEnd[nChildren++] = (nSSize << 16) | (nSSize + If_DsdObjSuppSize(pObj));
assert( !Abc_LitIsCompl(iFanin) ); nSSize += If_DsdObjSuppSize(pObj);
pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iFanin) );
pBegEnd[nChildren] = (nSSize << 16) | (fComplFan << 8) | (nSSize + pFanin->nSupp);
pChildren[nChildren++] = Abc_LitRegular(iFanin);
nSSize += pFanin->nSupp;
}
} }
pPermStart += If_DsdObjSuppSize(pObj);
} }
If_DsdObjSort( p->vObjs, pChildren, nChildren, pBegEnd ); If_DsdObjSort( p->vObjs, pChildren, nChildren, pBegEnd );
// create permutation // create permutation
for ( j = i = 0; i < nChildren; i++ ) for ( j = i = 0; i < nChildren; i++ )
for ( k = (pBegEnd[i] >> 16); k < (pBegEnd[i] & 0xFF); k++ ) for ( k = (pBegEnd[i] >> 16); k < (pBegEnd[i] & 0xFF); k++ )
pPermNew[j++] = (unsigned char)Abc_LitNotCond( pPerm[k], (pBegEnd[i] >> 8) & 1 ); pPermNew[j++] = pPerm[k];
assert( j == nSSize ); assert( j == nSSize );
for ( j = 0; j < nSSize; j++ ) for ( j = 0; j < nSSize; j++ )
pPerm[j] = pPermNew[j]; pPerm[j] = pPermNew[j];
} }
else if ( Type == IF_DSD_MUX ) else if ( Type == IF_DSD_MUX )
{ {
int RetValue;
assert( nLits == 3 );
for ( k = 0; k < nLits; k++ ) for ( k = 0; k < nLits; k++ )
{ {
pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pLits[k]) ); pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pLits[k]) );
fComplFan = If_DsdObjIsVar(pFanin) && Abc_LitIsCompl(pLits[k]); pLits[k] = Abc_LitNotCond( pLits[k], If_DsdManPushInv(p, pLits[k], pPermStart) );
pChildren[nChildren++] = Abc_LitNotCond( pLits[k], fComplFan ); pPermStart += pFanin->nSupp;
pPerm[k] = (unsigned char)Abc_LitNotCond( (int)pPerm[k], fComplFan ); }
nSSize += pFanin->nSupp; RetValue = If_DsdObjCompare( p->vObjs, pLits[1], pLits[2] );
} if ( RetValue == 1 || (RetValue == 0 && Abc_LitIsCompl(pLits[0])) )
if ( Abc_LitIsCompl(pChildren[0]) ) {
{ int nSupp0 = If_DsdVecLitSuppSize( p->vObjs, pLits[0] );
If_DsdObj_t * pFans[3]; int nSupp1 = If_DsdVecLitSuppSize( p->vObjs, pLits[1] );
pChildren[0] = Abc_LitNot(pChildren[0]); int nSupp2 = If_DsdVecLitSuppSize( p->vObjs, pLits[2] );
ABC_SWAP( int, pChildren[1], pChildren[2] ); pLits[0] = Abc_LitNot(pLits[0]);
pFans[0] = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pChildren[0]) ); ABC_SWAP( int, pLits[1], pLits[2] );
pFans[1] = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pChildren[1]) ); for ( j = k = 0; k < nSupp0; k++ )
pFans[2] = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pChildren[2]) );
nSSize = pFans[0]->nSupp + pFans[1]->nSupp + pFans[2]->nSupp;
for ( j = k = 0; k < If_DsdObjSuppSize(pFans[0]); k++ )
pPermNew[j++] = pPerm[k]; pPermNew[j++] = pPerm[k];
for ( k = 0; k < If_DsdObjSuppSize(pFans[2]); k++ ) for ( k = 0; k < nSupp2; k++ )
pPermNew[j++] = pPerm[pFans[0]->nSupp + pFans[1]->nSupp + k]; pPermNew[j++] = pPerm[nSupp0 + nSupp1 + k];
for ( k = 0; k < If_DsdObjSuppSize(pFans[1]); k++ ) for ( k = 0; k < nSupp1; k++ )
pPermNew[j++] = pPerm[pFans[0]->nSupp + k]; pPermNew[j++] = pPerm[nSupp0 + k];
assert( j == nSSize ); for ( j = 0; j < nSupp0 + nSupp1 + nSupp2; j++ )
for ( j = 0; j < nSSize; j++ )
pPerm[j] = pPermNew[j]; pPerm[j] = pPermNew[j];
} }
if ( Abc_LitIsCompl(pChildren[1]) ) if ( Abc_LitIsCompl(pLits[1]) )
{ {
pChildren[1] = Abc_LitNot(pChildren[1]); pLits[1] = Abc_LitNot(pLits[1]);
pChildren[2] = Abc_LitNot(pChildren[2]); pLits[2] = Abc_LitNot(pLits[2]);
fCompl ^= 1; fCompl ^= 1;
} }
pPermStart = pPerm;
for ( k = 0; k < nLits; k++ )
{
pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(pLits[k]) );
pChildren[nChildren++] = Abc_LitNotCond( pLits[k], If_DsdManPushInv(p, pLits[k], pPermStart) );
pPermStart += pFanin->nSupp;
}
} }
else if ( Type == IF_DSD_PRIME ) else if ( Type == IF_DSD_PRIME )
{ {
...@@ -987,10 +1074,10 @@ int If_DsdManOperation( If_DsdMan_t * p, int Type, int * pLits, int nLits, unsig ...@@ -987,10 +1074,10 @@ int If_DsdManOperation( If_DsdMan_t * p, int Type, int * pLits, int nLits, unsig
{ {
int iLitNew = Abc_LitNotCond( pLits[(int)pCanonPerm[i]], ((uCanonPhase>>i)&1) ); int iLitNew = Abc_LitNotCond( pLits[(int)pCanonPerm[i]], ((uCanonPhase>>i)&1) );
pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iLitNew) ); pFanin = If_DsdVecObj( p->vObjs, Abc_Lit2Var(iLitNew) );
fComplFan = If_DsdObjIsVar(pFanin) && Abc_LitIsCompl(iLitNew); pPermStart = pPerm + pFirsts[(int)pCanonPerm[i]];
pChildren[nChildren++] = Abc_LitNotCond( iLitNew, fComplFan ); pChildren[nChildren++] = Abc_LitNotCond( iLitNew, If_DsdManPushInv(p, iLitNew, pPermStart) );
for ( k = 0; k < (int)pFanin->nSupp; k++ ) for ( k = 0; k < (int)pFanin->nSupp; k++ )
pPermNew[j++] = (unsigned char)Abc_LitNotCond( (int)pPerm[pFirsts[(int)pCanonPerm[i]] + k], fComplFan ); pPermNew[j++] = pPermStart[k];
} }
assert( j == nSSize ); assert( j == nSSize );
for ( j = 0; j < nSSize; j++ ) for ( j = 0; j < nSSize; j++ )
......
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