Commit 2ccd0f9b by Alan Mishchenko

Experiments with don't-cares.

parent 23151498
......@@ -897,6 +897,7 @@ extern ABC_DLL char * Abc_SopCreateInv( Mem_Flex_t * pMan );
extern ABC_DLL char * Abc_SopCreateBuf( Mem_Flex_t * pMan );
extern ABC_DLL char * Abc_SopCreateFromTruth( Mem_Flex_t * pMan, int nVars, unsigned * pTruth );
extern ABC_DLL char * Abc_SopCreateFromIsop( Mem_Flex_t * pMan, int nVars, Vec_Int_t * vCover );
extern ABC_DLL char * Abc_SopCreateFromTruthIsop( Mem_Flex_t * pMan, int nVars, word * pTruth, Vec_Int_t * vCover );
extern ABC_DLL int Abc_SopGetCubeNum( char * pSop );
extern ABC_DLL int Abc_SopGetLitNum( char * pSop );
extern ABC_DLL int Abc_SopGetVarNum( char * pSop );
......
......@@ -19,6 +19,7 @@
***********************************************************************/
#include "abc.h"
#include "bool/kit/kit.h"
ABC_NAMESPACE_IMPL_START
......@@ -453,6 +454,37 @@ char * Abc_SopCreateFromIsop( Mem_Flex_t * pMan, int nVars, Vec_Int_t * vCover )
SeeAlso []
***********************************************************************/
char * Abc_SopCreateFromTruthIsop( Mem_Flex_t * pMan, int nVars, word * pTruth, Vec_Int_t * vCover )
{
char * pSop = NULL;
assert( nVars <= 6 );
if ( pTruth[0] == 0 )
pSop = Abc_SopRegister( pMan, " 0\n" );
else if ( ~pTruth[0] == 0 )
pSop = Abc_SopRegister( pMan, " 1\n" );
else
{
int RetValue = Kit_TruthIsop( (unsigned *)pTruth, nVars, vCover, 1 );
assert( nVars > 0 );
assert( RetValue == 0 || RetValue == 1 );
pSop = Abc_SopCreateFromIsop( pMan, nVars, vCover );
if ( RetValue )
Abc_SopComplement( pSop );
}
return pSop;
}
/**Function*************************************************************
Synopsis [Creates the cover from the ISOP computed from TT.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_SopToIsop( char * pSop, Vec_Int_t * vCover )
{
char * pCube;
......
......@@ -5672,7 +5672,7 @@ usage:
int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Abc_Ntk_t * Abc_NtkOptMfse( Abc_Ntk_t * pNtk, Acb_Par_t * pPars );
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Ntk_t * pNtkNew, * pNtk = Abc_FrameReadNtk(pAbc);
Acb_Par_t Pars, * pPars = &Pars; int c;
Acb_ParSetDefault( pPars );
Extra_UtilGetoptReset();
......@@ -5771,6 +5771,19 @@ int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
pPars->nLutSize = Abc_NtkGetFaninMax( pNtk );
if ( pPars->nLutSize > 6 )
{
Abc_Print( -1, "Command is only applicable to LUT size no more than 6.\n" );
return 1;
}
pNtkNew = Abc_NtkOptMfse( pNtk, pPars );
if ( pNtkNew == NULL )
{
Abc_Print( -1, "Command \"mfse\" has failed.\n" );
return 1;
}
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
return 0;
usage:
......@@ -216,21 +216,8 @@ void Abc_NtkInsertMfs( Abc_Ntk_t * pNtk, Sfm_Ntk_t * p )
vArray = Sfm_NodeReadFanins( p, pNode->iTemp );
Vec_IntForEachEntry( vArray, Fanin, k )
Abc_ObjAddFanin( pNode, Abc_NtkObj(pNtk, Vec_IntEntry(vMap, Fanin)) );
// update function
pTruth = Sfm_NodeReadTruth( p, pNode->iTemp );
if ( pTruth[0] == 0 )
pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 0\n" );
else if ( ~pTruth[0] == 0 )
pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 1\n" );
else
{
int RetValue = Kit_TruthIsop( (unsigned *)pTruth, Vec_IntSize(vArray), vCover, 1 );
assert( Vec_IntSize(vArray) > 0 );
assert( RetValue == 0 || RetValue == 1 );
pNode->pData = Abc_SopCreateFromIsop( (Mem_Flex_t *)pNtk->pManFunc, Vec_IntSize(vArray), vCover );
if ( RetValue )
Abc_SopComplement( (char *)pNode->pData );
}
pNode->pData = Abc_SopCreateFromTruthIsop( (Mem_Flex_t *)pNtk->pManFunc, Vec_IntSize(vArray), pTruth, vCover );
assert( Abc_SopGetVarNum((char *)pNode->pData) == Vec_IntSize(vArray) );
}
Vec_IntFree( vCover );
......
......@@ -86,15 +86,23 @@ Abc_Ntk_t * Acb_NtkToAbc( Abc_Ntk_t * pNtk, Acb_Ntk_t * p )
int i, k, iObj, iFanin;
Abc_Ntk_t * pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
Mem_Flex_t * pMan = (Mem_Flex_t *)pNtkNew->pManFunc;
Vec_Int_t * vCover = Vec_IntAlloc( 1000 );
Acb_NtkCleanObjCopies( p );
Acb_NtkForEachCi( p, iObj, i )
Acb_ObjSetCopy( p, iObj, Abc_ObjId(Abc_NtkCi(pNtkNew, i)) );
Acb_NtkForEachNode( p, iObj )
{
Abc_Obj_t * pObjNew = Abc_NtkCreateNode( pNtkNew );
pObjNew->pData = Abc_SopCreateFromTruthIsop( pMan, Acb_ObjFaninNum(p, iObj), Acb_ObjTruthP(p, iObj), vCover );
Acb_ObjSetCopy( p, iObj, Abc_ObjId(pObjNew) );
}
Vec_IntFree( vCover );
Acb_NtkForEachNode( p, iObj )
{
Abc_Obj_t * pObjNew = Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iObj));
Acb_ObjForEachFanin( p, iObj, iFanin, k )
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iFanin)) );
pObjNew->pData = Abc_SopCreateFromTruth( pMan, Acb_ObjFaninNum(p, iObj), (unsigned *)Acb_ObjTruthP(p, iObj) );
assert( Abc_SopGetVarNum((char *)pObjNew->pData) == Abc_ObjFaninNum(pObjNew) );
}
Acb_NtkForEachCoDriver( p, iFanin, i )
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iFanin)) );
......@@ -222,7 +230,7 @@ Abc_Ntk_t * Abc_NtkOptMfse( Abc_Ntk_t * pNtk, Acb_Par_t * pPars )
extern void Acb_NtkOpt( Acb_Ntk_t * p, Acb_Par_t * pPars );
Abc_Ntk_t * pNtkNew;
Acb_Ntk_t * p = Acb_NtkFromAbc( pNtk );
Acb_NtkOpt( p, pPars );
//Acb_NtkOpt( p, pPars );
pNtkNew = Acb_NtkToAbc( pNtk, p );
Acb_ManFree( p->pDesign );
return pNtkNew;
......
......@@ -95,7 +95,7 @@ Vec_Wec_t * Acb_DeriveCnfForWindow( Acb_Ntk_t * p, Vec_Int_t * vWin, int PivotVa
if ( Abc_LitIsCompl(iObj) && i < PivotVar )
continue;
vCnfBase = (Vec_Str_t *)Vec_WecEntry( vCnfs, iObj );
if ( vCnfBase != NULL )
if ( Vec_StrSize(vCnfBase) > 0 )
continue;
if ( vCnf == NULL )
vCnf = Vec_StrAlloc( 1000 );
......
......@@ -362,6 +362,7 @@ void Acb_NtkUpdateNode( Acb_Ntk_t * p, int Pivot, word uTruth, Vec_Int_t * vSupp
Acb_ObjAddFanin( p, Pivot, iFanin );
Acb_ObjAddFanout( p, Pivot );
Acb_NtkUpdateTiming( p, Pivot );
Vec_IntErase( Vec_WecEntry(&p->vCnfs, Pivot) );
}
......
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