Commit 2c7f6e39 by Alan Mishchenko

Version abc80330

parent 93c3f160
......@@ -19,7 +19,8 @@ MODULES := src/base/abc src/base/abci src/base/cmd \
src/aig/ivy src/aig/hop src/aig/rwt src/aig/deco \
src/aig/mem src/aig/dar src/aig/fra src/aig/cnf \
src/aig/csw src/aig/ioa src/aig/aig src/aig/kit \
src/aig/bdc src/aig/bar src/aig/ntl src/aig/tim
src/aig/bdc src/aig/bar src/aig/ntl src/aig/nwk src/aig/mfx \
src/aig/tim
default: $(PROG)
......
......@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/ntk" /I "src/aig/tim" /I "src/opt/mfs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
......@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/ntk" /I "src/aig/tim" /I "src/opt/mfs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /GZ /c
# SUBTRACT CPP /X
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
......@@ -182,6 +182,10 @@ SOURCE=.\src\base\abci\abc.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcAbc8.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcAttach.c
# End Source File
# Begin Source File
......@@ -3002,10 +3006,6 @@ SOURCE=.\src\aig\aig\aigScl.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\aig\aigSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\aig\aigShow.c
# End Source File
# Begin Source File
......@@ -3097,60 +3097,112 @@ SOURCE=.\src\aig\ntl\ntlTime.c
SOURCE=.\src\aig\ntl\ntlWriteBlif.c
# End Source File
# End Group
# Begin Group "ntk"
# Begin Group "tim"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\tim\tim.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\tim\tim.h
# End Source File
# End Group
# Begin Group "nwk"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\ntk\ntk.h
SOURCE=.\src\aig\nwk\nwk.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkBidec.c
SOURCE=.\src\aig\nwk\nwkBidec.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkCheck.c
SOURCE=.\src\aig\nwk\nwkCheck.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkDfs.c
SOURCE=.\src\aig\nwk\nwkDfs.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkFanio.c
SOURCE=.\src\aig\nwk\nwkFanio.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkMan.c
SOURCE=.\src\aig\nwk\nwkMan.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkMap.c
SOURCE=.\src\aig\nwk\nwkMap.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkObj.c
SOURCE=.\src\aig\nwk\nwkObj.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkTiming.c
SOURCE=.\src\aig\nwk\nwkSpeedup.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ntk\ntkUtil.c
SOURCE=.\src\aig\nwk\nwkStrash.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\nwk\nwkTiming.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\nwk\nwkUtil.c
# End Source File
# End Group
# Begin Group "tim"
# Begin Group "mfx"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\tim\tim.c
SOURCE=.\src\aig\mfx\mfx.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\tim\tim.h
SOURCE=.\src\aig\mfx\mfxCore.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxDiv.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxInt.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxInter.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxMan.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxResub.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxSat.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxStrash.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mfx\mfxWin.c
# End Source File
# End Group
# End Group
......
......@@ -471,6 +471,7 @@ extern void Aig_ManHaigRecord( Aig_Man_t * p );
/*=== aigMan.c ==========================================================*/
extern Aig_Man_t * Aig_ManStart( int nNodesMax );
extern Aig_Man_t * Aig_ManStartFrom( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupExor( Aig_Man_t * p );
extern Aig_Obj_t * Aig_ManDup_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj );
extern Aig_Man_t * Aig_ManDup( Aig_Man_t * p, int fOrdered );
extern Aig_Man_t * Aig_ManDupWithoutPos( Aig_Man_t * p );
......
......@@ -102,6 +102,71 @@ Aig_Man_t * Aig_ManStartFrom( Aig_Man_t * p )
return pNew;
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager to have EXOR gates.]
Description [Assumes topological ordering of the nodes.]
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Aig_ManDupExor( Aig_Man_t * p )
{
Aig_Man_t * pNew;
Aig_Obj_t * pObj, * pObjNew;
int i;
// create the new manager
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->fCatchExor = 1;
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->nRegs = p->nRegs;
pNew->nAsserts = p->nAsserts;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// create the PIs
Aig_ManCleanData( p );
// duplicate internal nodes
Aig_ManForEachObj( p, pObj, i )
{
if ( Aig_ObjIsBuf(pObj) )
{
pObjNew = Aig_ObjChild0Copy(pObj);
}
else if ( Aig_ObjIsNode(pObj) )
{
pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
}
else if ( Aig_ObjIsPi(pObj) )
{
pObjNew = Aig_ObjCreatePi( pNew );
pObjNew->Level = pObj->Level;
}
else if ( Aig_ObjIsPo(pObj) )
{
pObjNew = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
}
else if ( Aig_ObjIsConst1(pObj) )
{
pObjNew = Aig_ManConst1(pNew);
}
else
assert( 0 );
Aig_Regular(pObjNew)->pHaig = pObj->pHaig;
pObj->pData = pObjNew;
}
Aig_ManCleanup( pNew );
// duplicate the timing manager
if ( p->pManTime )
pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
// check the resulting network
if ( !Aig_ManCheck(pNew) )
printf( "Aig_ManDup(): The check has failed.\n" );
return pNew;
}
//#if 0
/**Function*************************************************************
......@@ -584,22 +649,24 @@ int Aig_ManHaigCounter( Aig_Man_t * pAig )
void Aig_ManPrintStats( Aig_Man_t * p )
{
int nChoices = Aig_ManCountChoices(p);
printf( "PI/PO = %5d/%5d ", Aig_ManPiNum(p), Aig_ManPoNum(p) );
printf( "A = %7d. ", Aig_ManAndNum(p) );
printf( "Eq = %7d. ", Aig_ManHaigCounter(p) );
if ( nChoices )
printf( "Ch = %5d. ", nChoices );
printf( "%-15s : ", p->pName );
printf( "pi = %5d ", Aig_ManPiNum(p) );
printf( "po = %5d ", Aig_ManPoNum(p) );
if ( Aig_ManRegNum(p) )
printf( "lat = %5d ", Aig_ManRegNum(p) );
printf( "and = %7d ", Aig_ManAndNum(p) );
// printf( "Eq = %7d ", Aig_ManHaigCounter(p) );
if ( Aig_ManExorNum(p) )
printf( "X = %5d. ", Aig_ManExorNum(p) );
printf( "xor = %5d ", Aig_ManExorNum(p) );
if ( nChoices )
printf( "ch = %5d ", nChoices );
if ( Aig_ManBufNum(p) )
printf( "B = %5d. ", Aig_ManBufNum(p) );
// printf( "Cre = %6d. ", p->nCreated );
// printf( "Del = %6d. ", p->nDeleted );
// printf( "Lev = %3d. ", Aig_ManCountLevels(p) );
printf( "Max = %7d. ", Aig_ManObjNumMax(p) );
printf( "Lev = %3d. ", Aig_ManLevels(p) );
if ( Aig_ManRegNum(p) )
printf( "Lat = %5d. ", Aig_ManRegNum(p) );
printf( "buf = %5d ", Aig_ManBufNum(p) );
// printf( "Cre = %6d ", p->nCreated );
// printf( "Del = %6d ", p->nDeleted );
// printf( "Lev = %3d ", Aig_ManCountLevels(p) );
// printf( "Max = %7d ", Aig_ManObjNumMax(p) );
printf( "lev = %3d", Aig_ManLevels(p) );
printf( "\n" );
fflush( stdout );
}
......
......@@ -80,6 +80,7 @@ extern void Dar_LibStart();
extern void Dar_LibStop();
/*=== darBalance.c ========================================================*/
extern Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel );
extern void Dar_BalancePrintStats( Aig_Man_t * p );
/*=== darCore.c ========================================================*/
extern void Dar_ManDefaultRwrParams( Dar_RwrPar_t * pPars );
extern int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars );
......@@ -93,6 +94,7 @@ extern Aig_Man_t * Dar_ManRwsat( Aig_Man_t * pAig, int fBalance, int fVerbos
extern Aig_Man_t * Dar_ManCompress( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fVerbose );
extern Aig_Man_t * Dar_ManCompress2( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fFanout, int fVerbose );
extern Aig_Man_t * Dar_ManChoice( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
extern Aig_Man_t * Dar_ManBalanceXor( Aig_Man_t * pAig, int fExor, int fUpdateLevel, int fVerbose );
#ifdef __cplusplus
}
......
......@@ -88,13 +88,13 @@ Aig_Man_t * Dar_ManRwsat( Aig_Man_t * pAig, int fBalance, int fVerbose )
pAig = Aig_ManDup( pTemp = pAig, 0 );
Aig_ManStop( pTemp );
if ( fVerbose ) Aig_ManPrintStats( pAig );
/*
// refactor
Dar_ManRefactor( pAig, pParsRef );
pAig = Aig_ManDup( pTemp = pAig, 0 );
Aig_ManStop( pTemp );
if ( fVerbose ) Aig_ManPrintStats( pAig );
*/
// balance
if ( fBalance )
{
......@@ -399,6 +399,35 @@ PRT( "Choicing time ", clock() - clk );
// return NULL;
}
/**Function*************************************************************
Synopsis [Reproduces script "compress2".]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Dar_ManBalanceXor( Aig_Man_t * pAig, int fExor, int fUpdateLevel, int fVerbose )
{
Aig_Man_t * pAigXor, * pRes;
if ( fExor )
{
pAigXor = Aig_ManDupExor( pAig );
if ( fVerbose )
Dar_BalancePrintStats( pAigXor );
pRes = Dar_ManBalance( pAigXor, fUpdateLevel );
Aig_ManStop( pAigXor );
}
else
{
pRes = Dar_ManBalance( pAig, fUpdateLevel );
}
return pRes;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -258,7 +258,7 @@ static inline int Fra_ImpCreate( int Left, int Right )
/*=== fraCec.c ========================================================*/
extern int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fVerbose );
extern int Fra_FraigCec( Aig_Man_t ** ppAig, int fVerbose );
extern int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int fVerbose );
extern int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nPartSize, int fVerbose );
/*=== fraClass.c ========================================================*/
extern int Fra_BmcNodeIsConst( Aig_Obj_t * pObj );
extern int Fra_BmcNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 );
......
......@@ -247,13 +247,13 @@ PRT( "Time", clock() - clk );
SeeAlso []
***********************************************************************/
int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int fVerbose )
int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nPartSize, int fVerbose )
{
Aig_Man_t * pAig;
Vec_Ptr_t * vParts;
int i, RetValue = 1, nOutputs;
// create partitions
vParts = Aig_ManMiterPartitioned( pMan1, pMan2, 100 );
vParts = Aig_ManMiterPartitioned( pMan1, pMan2, nPartSize );
// solve the partitions
nOutputs = -1;
Vec_PtrForEachEntry( vParts, pAig, i )
......@@ -295,6 +295,60 @@ int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int fVerbose
return RetValue;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Fra_FraigCecTop( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int fPartition, int fVerbose )
{
//Abc_NtkDarCec( pNtk1, pNtk2, fPartition, fVerbose );
int RetValue, clkTotal = clock();
if ( Aig_ManPiNum(pMan1) != Aig_ManPiNum(pMan1) )
{
printf( "Abc_CommandAbc8Cec(): Miters have different number of PIs.\n" );
return 0;
}
if ( Aig_ManPoNum(pMan1) != Aig_ManPoNum(pMan1) )
{
printf( "Abc_CommandAbc8Cec(): Miters have different number of POs.\n" );
return 0;
}
assert( Aig_ManPiNum(pMan1) == Aig_ManPiNum(pMan1) );
assert( Aig_ManPoNum(pMan1) == Aig_ManPoNum(pMan1) );
if ( fPartition )
RetValue = Fra_FraigCecPartitioned( pMan1, pMan2, 100, fVerbose );
else
RetValue = Fra_FraigCecPartitioned( pMan1, pMan2, Aig_ManPoNum(pMan1), fVerbose );
// report the miter
if ( RetValue == 1 )
{
printf( "Networks are equivalent. " );
PRT( "Time", clock() - clkTotal );
}
else if ( RetValue == 0 )
{
printf( "Networks are NOT EQUIVALENT. " );
PRT( "Time", clock() - clkTotal );
}
else
{
printf( "Networks are UNDECIDED. " );
PRT( "Time", clock() - clkTotal );
}
fflush( stdout );
return RetValue;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
/**CFile****************************************************************
FileName [mfx.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mfx.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __MFX_H__
#define __MFX_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef struct Mfx_Par_t_ Mfx_Par_t;
struct Mfx_Par_t_
{
// general parameters
int nWinTfoLevs; // the maximum fanout levels
int nFanoutsMax; // the maximum number of fanouts
int nDepthMax; // the maximum number of logic levels
int nDivMax; // the maximum number of divisors
int nWinSizeMax; // the maximum size of the window
int nGrowthLevel; // the maximum allowed growth in level
int nBTLimit; // the maximum number of conflicts in one SAT run
int fResub; // performs resubstitution
int fArea; // performs optimization for area
int fMoreEffort; // performs high-affort minimization
int fSwapEdge; // performs edge swapping
int fDelay; // performs optimization for delay
int fVerbose; // enable basic stats
int fVeryVerbose; // enable detailed stats
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== mfxCore.c ==========================================================*/
extern void Mfx_ParsDefault( Mfx_Par_t * pPars );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [mfxDiv.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis [Procedures to compute candidate divisors.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mfxDiv.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mfxInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Marks and collects the TFI cone of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_MfxWinMarkTfi_rec( Nwk_Obj_t * pObj, Vec_Ptr_t * vCone )
{
Nwk_Obj_t * pFanin;
int i;
if ( Nwk_ObjIsTravIdCurrent(pObj) )
return;
Nwk_ObjSetTravIdCurrent( pObj );
if ( Nwk_ObjIsCi(pObj) )
{
Vec_PtrPush( vCone, pObj );
return;
}
assert( Nwk_ObjIsNode(pObj) );
// visit the fanins of the node
Nwk_ObjForEachFanin( pObj, pFanin, i )
Abc_MfxWinMarkTfi_rec( pFanin, vCone );
Vec_PtrPush( vCone, pObj );
}
/**Function*************************************************************
Synopsis [Marks and collects the TFI cone of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Abc_MfxWinMarkTfi( Nwk_Obj_t * pNode )
{
Vec_Ptr_t * vCone;
vCone = Vec_PtrAlloc( 100 );
Abc_MfxWinMarkTfi_rec( pNode, vCone );
return vCone;
}
/**Function*************************************************************
Synopsis [Marks the TFO of the collected nodes up to the given level.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_MfxWinSweepLeafTfo_rec( Nwk_Obj_t * pObj, int nLevelLimit )
{
Nwk_Obj_t * pFanout;
int i;
if ( Nwk_ObjIsCo(pObj) || (int)pObj->Level > nLevelLimit )
return;
if ( Nwk_ObjIsTravIdCurrent(pObj) )
return;
Nwk_ObjSetTravIdCurrent( pObj );
Nwk_ObjForEachFanout( pObj, pFanout, i )
Abc_MfxWinSweepLeafTfo_rec( pFanout, nLevelLimit );
}
/**Function*************************************************************
Synopsis [Dereferences the node's MFFC.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_MfxNodeDeref_rec( Nwk_Obj_t * pNode )
{
Nwk_Obj_t * pFanin;
int i, Counter = 1;
if ( Nwk_ObjIsCi(pNode) )
return 0;
Nwk_ObjSetTravIdCurrent( pNode );
Nwk_ObjForEachFanin( pNode, pFanin, i )
{
assert( pFanin->nFanouts > 0 );
if ( --pFanin->nFanouts == 0 )
Counter += Abc_MfxNodeDeref_rec( pFanin );
}
return Counter;
}
/**Function*************************************************************
Synopsis [References the node's MFFC.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_MfxNodeRef_rec( Nwk_Obj_t * pNode )
{
Nwk_Obj_t * pFanin;
int i, Counter = 1;
if ( Nwk_ObjIsCi(pNode) )
return 0;
Nwk_ObjForEachFanin( pNode, pFanin, i )
{
if ( pFanin->nFanouts++ == 0 )
Counter += Abc_MfxNodeRef_rec( pFanin );
}
return Counter;
}
/**Function*************************************************************
Synopsis [Labels MFFC of the node with the current trav ID.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_MfxWinVisitMffc( Nwk_Obj_t * pNode )
{
int Count1, Count2;
assert( Nwk_ObjIsNode(pNode) );
// dereference the node (mark with the current trav ID)
Count1 = Abc_MfxNodeDeref_rec( pNode );
// reference it back
Count2 = Abc_MfxNodeRef_rec( pNode );
assert( Count1 == Count2 );
return Count1;
}
/**Function*************************************************************
Synopsis [Computes divisors and add them to nodes in the window.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, int nLevDivMax )
{
Vec_Ptr_t * vCone, * vDivs;
Nwk_Obj_t * pObj, * pFanout, * pFanin;
int k, f, m;
int nDivsPlus = 0, nTrueSupp;
assert( p->vDivs == NULL );
// mark the TFI with the current trav ID
Nwk_ManIncrementTravId( pNode->pMan );
vCone = Abc_MfxWinMarkTfi( pNode );
// count the number of PIs
nTrueSupp = 0;
Vec_PtrForEachEntry( vCone, pObj, k )
nTrueSupp += Nwk_ObjIsCi(pObj);
// printf( "%d(%d) ", Vec_PtrSize(p->vSupp), m );
// mark with the current trav ID those nodes that should not be divisors:
// (1) the node and its TFO
// (2) the MFFC of the node
// (3) the node's fanins (these are treated as a special case)
Nwk_ManIncrementTravId( pNode->pMan );
Abc_MfxWinSweepLeafTfo_rec( pNode, nLevDivMax );
Abc_MfxWinVisitMffc( pNode );
Nwk_ObjForEachFanin( pNode, pObj, k )
Nwk_ObjSetTravIdCurrent( pObj );
// at this point the nodes are marked with two trav IDs:
// nodes to be collected as divisors are marked with previous trav ID
// nodes to be avoided as divisors are marked with current trav ID
// start collecting the divisors
vDivs = Vec_PtrAlloc( p->pPars->nDivMax );
Vec_PtrForEachEntry( vCone, pObj, k )
{
if ( !Nwk_ObjIsTravIdPrevious(pObj) )
continue;
if ( (int)pObj->Level > nLevDivMax )
continue;
Vec_PtrPush( vDivs, pObj );
if ( Vec_PtrSize(vDivs) >= p->pPars->nDivMax )
break;
}
Vec_PtrFree( vCone );
// explore the fanouts of already collected divisors
if ( Vec_PtrSize(vDivs) < p->pPars->nDivMax )
Vec_PtrForEachEntry( vDivs, pObj, k )
{
// consider fanouts of this node
Nwk_ObjForEachFanout( pObj, pFanout, f )
{
// stop if there are too many fanouts
if ( f > 20 )
break;
// skip nodes that are already added
if ( Nwk_ObjIsTravIdPrevious(pFanout) )
continue;
// skip nodes in the TFO or in the MFFC of node
if ( Nwk_ObjIsTravIdCurrent(pFanout) )
continue;
// skip COs
if ( !Nwk_ObjIsNode(pFanout) )
continue;
// skip nodes with large level
if ( (int)pFanout->Level > nLevDivMax )
continue;
// skip nodes whose fanins are not divisors
Nwk_ObjForEachFanin( pFanout, pFanin, m )
if ( !Nwk_ObjIsTravIdPrevious(pFanin) )
break;
if ( m < Nwk_ObjFaninNum(pFanout) )
continue;
// make sure this divisor in not among the nodes
// Vec_PtrForEachEntry( p->vNodes, pFanin, m )
// assert( pFanout != pFanin );
// add the node to the divisors
Vec_PtrPush( vDivs, pFanout );
// Vec_PtrPush( p->vNodes, pFanout );
Vec_PtrPushUnique( p->vNodes, pFanout );
Nwk_ObjSetTravIdPrevious( pFanout );
nDivsPlus++;
if ( Vec_PtrSize(vDivs) >= p->pPars->nDivMax )
break;
}
if ( Vec_PtrSize(vDivs) >= p->pPars->nDivMax )
break;
}
// sort the divisors by level in the increasing order
Vec_PtrSort( vDivs, Nwk_NodeCompareLevelsIncrease );
// add the fanins of the node
Nwk_ObjForEachFanin( pNode, pFanin, k )
Vec_PtrPush( vDivs, pFanin );
/*
printf( "Node level = %d. ", Nwk_ObjLevel(p->pNode) );
Vec_PtrForEachEntryStart( vDivs, pObj, k, Vec_PtrSize(vDivs)-p->nDivsPlus )
printf( "%d ", Nwk_ObjLevel(pObj) );
printf( "\n" );
*/
//printf( "%d ", p->nDivsPlus );
// printf( "(%d+%d)(%d+%d+%d) ", Vec_PtrSize(p->vSupp), Vec_PtrSize(p->vNodes),
// nTrueSupp, Vec_PtrSize(vDivs)-nTrueSupp-nDivsPlus, nDivsPlus );
return vDivs;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [mfxInt.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis [Internal declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mfxInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __MFX_INT_H__
#define __MFX_INT_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "nwk.h"
#include "mfx.h"
#include "aig.h"
#include "cnf.h"
#include "satSolver.h"
#include "satStore.h"
#include "bdc.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
#define MFX_FANIN_MAX 12
typedef struct Mfx_Man_t_ Mfx_Man_t;
struct Mfx_Man_t_
{
// input data
Mfx_Par_t * pPars;
Nwk_Man_t * pNtk;
Aig_Man_t * pCare;
Vec_Ptr_t * vSuppsInv;
int nFaninMax;
// intermeditate data for the node
Vec_Ptr_t * vRoots; // the roots of the window
Vec_Ptr_t * vSupp; // the support of the window
Vec_Ptr_t * vNodes; // the internal nodes of the window
Vec_Ptr_t * vDivs; // the divisors of the node
Vec_Int_t * vDivLits; // the SAT literals of divisor nodes
Vec_Int_t * vProjVars; // the projection variables
// intermediate simulation data
Vec_Ptr_t * vDivCexes; // the counter-example for dividors
int nDivWords; // the number of words
int nCexes; // the numbe rof current counter-examples
int nSatCalls;
int nSatCexes;
// used for bidecomposition
Vec_Int_t * vTruth;
Bdc_Man_t * pManDec;
int nNodesDec;
int nNodesGained;
int nNodesGainedLevel;
// solving data
Aig_Man_t * pAigWin; // window AIG with constraints
Cnf_Dat_t * pCnf; // the CNF for the window
sat_solver * pSat; // the SAT solver used
Int_Man_t * pMan; // interpolation manager;
Vec_Int_t * vMem; // memory for intermediate SOPs
Vec_Vec_t * vLevels; // levelized structure for updating
Vec_Ptr_t * vFanins; // the new set of fanins
int nTotConfLim; // total conflict limit
int nTotConfLevel; // total conflicts on this level
// the result of solving
int nFanins; // the number of fanins
int nWords; // the number of words
int nCares; // the number of care minterms
unsigned uCare[(MFX_FANIN_MAX<=5)?1:1<<(MFX_FANIN_MAX-5)]; // the computed care-set
// performance statistics
int nNodesTried;
int nNodesResub;
int nMintsCare;
int nMintsTotal;
int nNodesBad;
int nTotalDivs;
int nTimeOuts;
int nTimeOutsLevel;
int nDcMints;
double dTotalRatios;
// node/edge stats
int nTotalNodesBeg;
int nTotalNodesEnd;
int nTotalEdgesBeg;
int nTotalEdgesEnd;
// statistics
int timeWin;
int timeDiv;
int timeAig;
int timeCnf;
int timeSat;
int timeInt;
int timeTotal;
};
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== mfxDiv.c ==========================================================*/
extern Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, int nLevDivMax );
/*=== mfxInter.c ==========================================================*/
extern sat_solver * Mfx_CreateSolverResub( Mfx_Man_t * p, int * pCands, int nCands, int fInvert );
extern Hop_Obj_t * Mfx_Interplate( Mfx_Man_t * p, int * pCands, int nCands );
extern int Mfx_InterplateEval( Mfx_Man_t * p, int * pCands, int nCands );
/*=== mfxMan.c ==========================================================*/
extern Mfx_Man_t * Mfx_ManAlloc( Mfx_Par_t * pPars );
extern void Mfx_ManStop( Mfx_Man_t * p );
extern void Mfx_ManClean( Mfx_Man_t * p );
/*=== mfxResub.c ==========================================================*/
extern void Mfx_PrintResubStats( Mfx_Man_t * p );
extern int Mfx_EdgeSwapEval( Mfx_Man_t * p, Nwk_Obj_t * pNode );
extern int Mfx_ResubNode( Mfx_Man_t * p, Nwk_Obj_t * pNode );
extern int Mfx_ResubNode2( Mfx_Man_t * p, Nwk_Obj_t * pNode );
/*=== mfxSat.c ==========================================================*/
extern int Mfx_SolveSat( Mfx_Man_t * p, Nwk_Obj_t * pNode );
/*=== mfxStrash.c ==========================================================*/
extern Aig_Man_t * Mfx_ConstructAig( Mfx_Man_t * p, Nwk_Obj_t * pNode );
extern double Mfx_ConstraintRatio( Mfx_Man_t * p, Nwk_Obj_t * pNode );
/*=== mfxWin.c ==========================================================*/
extern Vec_Ptr_t * Mfx_ComputeRoots( Nwk_Obj_t * pNode, int nWinTfoMax, int nFanoutLimit );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [mfxMan.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis [Procedures working with the manager.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mfxMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mfxInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Mfx_Man_t * Mfx_ManAlloc( Mfx_Par_t * pPars )
{
Mfx_Man_t * p;
// start the manager
p = ALLOC( Mfx_Man_t, 1 );
memset( p, 0, sizeof(Mfx_Man_t) );
p->pPars = pPars;
p->vProjVars = Vec_IntAlloc( 100 );
p->vDivLits = Vec_IntAlloc( 100 );
p->nDivWords = Aig_BitWordNum(p->pPars->nDivMax + MFX_FANIN_MAX);
p->vDivCexes = Vec_PtrAllocSimInfo( p->pPars->nDivMax+MFX_FANIN_MAX+1, p->nDivWords );
p->pMan = Int_ManAlloc();
p->vMem = Vec_IntAlloc( 0 );
p->vLevels = Vec_VecStart( 32 );
p->vFanins = Vec_PtrAlloc( 32 );
return p;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mfx_ManClean( Mfx_Man_t * p )
{
if ( p->pAigWin )
Aig_ManStop( p->pAigWin );
if ( p->pCnf )
Cnf_DataFree( p->pCnf );
if ( p->pSat )
sat_solver_delete( p->pSat );
if ( p->vRoots )
Vec_PtrFree( p->vRoots );
if ( p->vSupp )
Vec_PtrFree( p->vSupp );
if ( p->vNodes )
Vec_PtrFree( p->vNodes );
if ( p->vDivs )
Vec_PtrFree( p->vDivs );
p->pAigWin = NULL;
p->pCnf = NULL;
p->pSat = NULL;
p->vRoots = NULL;
p->vSupp = NULL;
p->vNodes = NULL;
p->vDivs = NULL;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mfx_ManPrint( Mfx_Man_t * p )
{
if ( p->pPars->fResub )
{
printf( "Reduction in nodes = %5d. (%.2f %%) ",
p->nTotalNodesBeg-p->nTotalNodesEnd,
100.0*(p->nTotalNodesBeg-p->nTotalNodesEnd)/p->nTotalNodesBeg );
printf( "Reduction in edges = %5d. (%.2f %%) ",
p->nTotalEdgesBeg-p->nTotalEdgesEnd,
100.0*(p->nTotalEdgesBeg-p->nTotalEdgesEnd)/p->nTotalEdgesBeg );
printf( "\n" );
printf( "Nodes = %d. Try = %d. Resub = %d. Div = %d. SAT calls = %d. Timeouts = %d.\n",
Nwk_ManNodeNum(p->pNtk), p->nNodesTried, p->nNodesResub, p->nTotalDivs, p->nSatCalls, p->nTimeOuts );
if ( p->pPars->fSwapEdge )
printf( "Swappable edges = %d. Total edges = %d. Ratio = %5.2f.\n",
p->nNodesResub, Nwk_ManGetTotalFanins(p->pNtk), 1.00 * p->nNodesResub / Nwk_ManGetTotalFanins(p->pNtk) );
else
Mfx_PrintResubStats( p );
// printf( "Average ratio of DCs in the resubed nodes = %.2f.\n", 1.0*p->nDcMints/(64 * p->nNodesResub) );
}
else
{
printf( "Nodes = %d. Try = %d. Total mints = %d. Local DC mints = %d. Ratio = %5.2f.\n",
Nwk_ManNodeNum(p->pNtk), p->nNodesTried, p->nMintsTotal, p->nMintsTotal-p->nMintsCare,
1.0 * (p->nMintsTotal-p->nMintsCare) / p->nMintsTotal );
// printf( "Average ratio of sequential DCs in the global space = %5.2f.\n",
// 1.0-(p->dTotalRatios/p->nNodesTried) );
printf( "Nodes resyn = %d. Ratio = %5.2f. Total AIG node gain = %d. Timeouts = %d.\n",
p->nNodesDec, 1.0 * p->nNodesDec / p->nNodesTried, p->nNodesGained, p->nTimeOuts );
}
/*
PRTP( "Win", p->timeWin , p->timeTotal );
PRTP( "Div", p->timeDiv , p->timeTotal );
PRTP( "Aig", p->timeAig , p->timeTotal );
PRTP( "Cnf", p->timeCnf , p->timeTotal );
PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal );
PRTP( "Int", p->timeInt , p->timeTotal );
PRTP( "ALL", p->timeTotal , p->timeTotal );
*/
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mfx_ManStop( Mfx_Man_t * p )
{
if ( p->pPars->fVerbose )
Mfx_ManPrint( p );
if ( p->vTruth )
Vec_IntFree( p->vTruth );
if ( p->pManDec )
Bdc_ManFree( p->pManDec );
if ( p->pCare )
Aig_ManStop( p->pCare );
if ( p->vSuppsInv )
Vec_VecFree( (Vec_Vec_t *)p->vSuppsInv );
Mfx_ManClean( p );
Int_ManFree( p->pMan );
Vec_IntFree( p->vMem );
Vec_VecFree( p->vLevels );
Vec_PtrFree( p->vFanins );
Vec_IntFree( p->vProjVars );
Vec_IntFree( p->vDivLits );
Vec_PtrFree( p->vDivCexes );
free( p );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [mfxSat.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis [Procedures to compute don't-cares using SAT.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mfxSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mfxInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Enumerates through the SAT assignments.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mfx_SolveSat_iter( Mfx_Man_t * p )
{
int Lits[MFX_FANIN_MAX];
int RetValue, nBTLimit, iVar, b, Mint;
if ( p->nTotConfLim && p->nTotConfLim <= p->pSat->stats.conflicts )
return -1;
nBTLimit = p->nTotConfLim? p->nTotConfLim - p->pSat->stats.conflicts : 0;
RetValue = sat_solver_solve( p->pSat, NULL, NULL, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
assert( RetValue == l_Undef || RetValue == l_True || RetValue == l_False );
if ( RetValue == l_Undef )
return -1;
if ( RetValue == l_False )
return 0;
p->nCares++;
// add SAT assignment to the solver
Mint = 0;
Vec_IntForEachEntry( p->vProjVars, iVar, b )
{
Lits[b] = toLit( iVar );
if ( sat_solver_var_value( p->pSat, iVar ) )
{
Mint |= (1 << b);
Lits[b] = lit_neg( Lits[b] );
}
}
assert( !Aig_InfoHasBit(p->uCare, Mint) );
Aig_InfoSetBit( p->uCare, Mint );
// add the blocking clause
RetValue = sat_solver_addclause( p->pSat, Lits, Lits + Vec_IntSize(p->vProjVars) );
if ( RetValue == 0 )
return 0;
return 1;
}
/**Function*************************************************************
Synopsis [Enumerates through the SAT assignments.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mfx_SolveSat( Mfx_Man_t * p, Nwk_Obj_t * pNode )
{
Aig_Obj_t * pObjPo;
int RetValue, i;
// collect projection variables
Vec_IntClear( p->vProjVars );
Vec_PtrForEachEntryStart( p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Nwk_ObjFaninNum(pNode) )
{
assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
Vec_IntPush( p->vProjVars, p->pCnf->pVarNums[pObjPo->Id] );
}
// prepare the truth table of care set
p->nFanins = Vec_IntSize( p->vProjVars );
p->nWords = Aig_TruthWordNum( p->nFanins );
memset( p->uCare, 0, sizeof(unsigned) * p->nWords );
// iterate through the SAT assignments
p->nCares = 0;
p->nTotConfLim = p->pPars->nBTLimit;
while ( (RetValue = Mfx_SolveSat_iter(p)) == 1 );
if ( RetValue == -1 )
return 0;
// write statistics
p->nMintsCare += p->nCares;
p->nMintsTotal += (1<<p->nFanins);
if ( p->pPars->fVeryVerbose )
{
printf( "Node %4d : Care = %2d. Total = %2d. ", pNode->Id, p->nCares, (1<<p->nFanins) );
// Kit_TruthPrintBinary( stdout, p->uCare, (1<<p->nFanins) );
printf( "\n" );
}
// map the care
if ( p->nFanins > 4 )
return 1;
if ( p->nFanins == 4 )
p->uCare[0] = p->uCare[0] | (p->uCare[0] << 16);
if ( p->nFanins == 3 )
p->uCare[0] = p->uCare[0] | (p->uCare[0] << 8) | (p->uCare[0] << 16) | (p->uCare[0] << 24);
if ( p->nFanins == 2 )
p->uCare[0] = p->uCare[0] | (p->uCare[0] << 4) | (p->uCare[0] << 8) | (p->uCare[0] << 12) |
(p->uCare[0] << 16) | (p->uCare[0] << 20) | (p->uCare[0] << 24) | (p->uCare[0] << 28);
assert( p->nFanins != 1 );
return 1;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [mfxWin.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis [Procedures to compute windows stretching to the PIs.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mfxWin.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mfxInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Returns 1 if the node should be a root.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Mfx_ComputeRootsCheck( Nwk_Obj_t * pNode, int nLevelMax, int nFanoutLimit )
{
Nwk_Obj_t * pFanout;
int i;
// the node is the root if one of the following is true:
// (1) the node has more than fanouts than the limit
if ( Nwk_ObjFanoutNum(pNode) > nFanoutLimit )
return 1;
// (2) the node has CO fanouts
// (3) the node has fanouts above the cutoff level
Nwk_ObjForEachFanout( pNode, pFanout, i )
if ( Nwk_ObjIsCo(pFanout) || pFanout->Level > nLevelMax )
return 1;
return 0;
}
/**Function*************************************************************
Synopsis [Recursively collects the root candidates.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mfx_ComputeRoots_rec( Nwk_Obj_t * pNode, int nLevelMax, int nFanoutLimit, Vec_Ptr_t * vRoots )
{
Nwk_Obj_t * pFanout;
int i;
assert( Nwk_ObjIsNode(pNode) );
if ( Nwk_ObjIsTravIdCurrent(pNode) )
return;
Nwk_ObjSetTravIdCurrent( pNode );
// check if the node should be the root
if ( Mfx_ComputeRootsCheck( pNode, nLevelMax, nFanoutLimit ) )
Vec_PtrPush( vRoots, pNode );
else // if not, explore its fanouts
Nwk_ObjForEachFanout( pNode, pFanout, i )
Mfx_ComputeRoots_rec( pFanout, nLevelMax, nFanoutLimit, vRoots );
}
/**Function*************************************************************
Synopsis [Recursively collects the root candidates.]
Description [Returns 1 if the only root is this node.]
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Mfx_ComputeRoots( Nwk_Obj_t * pNode, int nWinTfoMax, int nFanoutLimit )
{
Vec_Ptr_t * vRoots;
vRoots = Vec_PtrAlloc( 10 );
Nwk_ManIncrementTravId( pNode->pMan );
Mfx_ComputeRoots_rec( pNode, pNode->Level + nWinTfoMax, nFanoutLimit, vRoots );
assert( Vec_PtrSize(vRoots) > 0 );
// if ( Vec_PtrSize(vRoots) == 1 && Vec_PtrEntry(vRoots, 0) == pNode )
// return 0;
return vRoots;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [ntk_.c]
FileName [mfs_.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
PackageName [The good old minimization with complete don't-cares.]
Synopsis []
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntk_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: mfs_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "mfsInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......
SRC += src/aig/mfx/mfxCore.c \
src/aig/mfx/mfxDiv.c \
src/aig/mfx/mfxInter.c \
src/aig/mfx/mfxMan.c \
src/aig/mfx/mfxResub.c \
src/aig/mfx/mfxSat.c \
src/aig/mfx/mfxStrash.c \
src/aig/mfx/mfxWin.c
SRC += src/aig/ntk/ntkCheck.c \
src/aig/ntk/ntkBidec.c \
src/aig/ntk/ntkDfs.c \
src/aig/ntk/ntkFanio.c \
src/aig/ntk/ntkMan.c \
src/aig/ntk/ntkMap.c \
src/aig/ntk/ntkObj.c \
src/aig/ntk/ntkTiming.c \
src/aig/ntk/ntkUtil.c
/**CFile****************************************************************
FileName [ntkDfs.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
Synopsis [DFS traversals.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntkDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Computes the number of logic levels not counting PIs/POs.]
Description [Assumes that white boxes have unit level.]
SideEffects []
SeeAlso []
***********************************************************************/
int Ntk_ManLevel( Ntk_Man_t * pNtk )
{
Tim_Man_t * pManTimeUnit;
Ntk_Obj_t * pObj, * pFanin;
int i, k, LevelMax, Level;
// clean the levels
Ntk_ManForEachObj( pNtk, pObj, i )
Ntk_ObjSetLevel( pObj, 0 );
// perform level computation
LevelMax = 0;
pManTimeUnit = Tim_ManDupUnit( pNtk->pManTime );
Tim_ManIncrementTravId( pManTimeUnit );
Ntk_ManForEachObj( pNtk, pObj, i )
{
if ( Ntk_ObjIsCi(pObj) )
{
Level = (int)Tim_ManGetPiArrival( pManTimeUnit, pObj->PioId );
Ntk_ObjSetLevel( pObj, Level );
}
else if ( Ntk_ObjIsCo(pObj) )
{
Level = Ntk_ObjLevel( Ntk_ObjFanin0(pObj) );
Tim_ManSetPoArrival( pManTimeUnit, pObj->PioId, (float)Level );
Ntk_ObjSetLevel( pObj, Level );
if ( LevelMax < Ntk_ObjLevel(pObj) )
LevelMax = Ntk_ObjLevel(pObj);
}
else if ( Ntk_ObjIsNode(pObj) )
{
Level = 0;
Ntk_ObjForEachFanin( pObj, pFanin, k )
if ( Level < Ntk_ObjLevel(pFanin) )
Level = Ntk_ObjLevel(pFanin);
Ntk_ObjSetLevel( pObj, Level + 1 );
}
else
assert( 0 );
}
// set the old timing manager
Tim_ManStop( pManTimeUnit );
return LevelMax;
}
/**Function*************************************************************
Synopsis [Performs DFS for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ntk_ManLevel2_rec( Ntk_Obj_t * pObj )
{
Ntk_Obj_t * pNext;
int i, iBox, iTerm1, nTerms, LevelMax = 0;
if ( Ntk_ObjIsTravIdCurrent( pObj ) )
return;
Ntk_ObjSetTravIdCurrent( pObj );
if ( Ntk_ObjIsCi(pObj) )
{
iBox = Tim_ManBoxForCi( pObj->pMan->pManTime, pObj->PioId );
if ( iBox >= 0 ) // this is not a true PI
{
iTerm1 = Tim_ManBoxInputFirst( pObj->pMan->pManTime, iBox );
nTerms = Tim_ManBoxInputNum( pObj->pMan->pManTime, iBox );
for ( i = 0; i < nTerms; i++ )
{
pNext = Ntk_ManCo(pObj->pMan, iTerm1 + i);
Ntk_ManLevel2_rec( pNext );
if ( LevelMax < Ntk_ObjLevel(pNext) )
LevelMax = Ntk_ObjLevel(pNext);
}
LevelMax++;
}
}
else if ( Ntk_ObjIsNode(pObj) || Ntk_ObjIsCo(pObj) )
{
Ntk_ObjForEachFanin( pObj, pNext, i )
{
Ntk_ManLevel2_rec( pNext );
if ( LevelMax < Ntk_ObjLevel(pNext) )
LevelMax = Ntk_ObjLevel(pNext);
}
if ( Ntk_ObjIsNode(pObj) )
LevelMax++;
}
else
assert( 0 );
Ntk_ObjSetLevel( pObj, LevelMax );
}
/**Function*************************************************************
Synopsis [Returns the DFS ordered array of all objects except latches.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ntk_ManLevel2( Ntk_Man_t * pNtk )
{
Ntk_Obj_t * pObj;
int i, LevelMax = 0;
Ntk_ManForEachObj( pNtk, pObj, i )
Ntk_ObjSetLevel( pObj, 0 );
Ntk_ManIncrementTravId( pNtk );
Ntk_ManForEachPo( pNtk, pObj, i )
{
Ntk_ManLevel2_rec( pObj );
if ( LevelMax < Ntk_ObjLevel(pObj) )
LevelMax = Ntk_ObjLevel(pObj);
}
return LevelMax;
}
/**Function*************************************************************
Synopsis [Performs DFS for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ntk_ManDfs_rec( Ntk_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
Ntk_Obj_t * pNext;
int i;
if ( Ntk_ObjIsTravIdCurrent( pObj ) )
return;
Ntk_ObjSetTravIdCurrent( pObj );
Ntk_ObjForEachFanin( pObj, pNext, i )
Ntk_ManDfs_rec( pNext, vNodes );
Vec_PtrPush( vNodes, pObj );
}
/**Function*************************************************************
Synopsis [Returns the DFS ordered array of all objects except latches.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Ntk_ManDfs( Ntk_Man_t * pNtk )
{
Vec_Ptr_t * vNodes;
Ntk_Obj_t * pObj;
int i;
Ntk_ManIncrementTravId( pNtk );
vNodes = Vec_PtrAlloc( 100 );
Ntk_ManForEachObj( pNtk, pObj, i )
{
if ( Ntk_ObjIsCi(pObj) )
{
Ntk_ObjSetTravIdCurrent( pObj );
Vec_PtrPush( vNodes, pObj );
}
else if ( Ntk_ObjIsCo(pObj) )
Ntk_ManDfs_rec( pObj, vNodes );
}
return vNodes;
}
/**Function*************************************************************
Synopsis [Performs DFS for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ntk_ManDfsReverse_rec( Ntk_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
Ntk_Obj_t * pNext;
int i, iBox, iTerm1, nTerms;
if ( Ntk_ObjIsTravIdCurrent( pObj ) )
return;
Ntk_ObjSetTravIdCurrent( pObj );
if ( Ntk_ObjIsCo(pObj) )
{
iBox = Tim_ManBoxForCo( pObj->pMan->pManTime, pObj->PioId );
if ( iBox >= 0 ) // this is not a true PO
{
iTerm1 = Tim_ManBoxOutputFirst( pObj->pMan->pManTime, iBox );
nTerms = Tim_ManBoxOutputNum( pObj->pMan->pManTime, iBox );
for ( i = 0; i < nTerms; i++ )
{
pNext = Ntk_ManCi(pObj->pMan, iTerm1 + i);
Ntk_ManDfsReverse_rec( pNext, vNodes );
}
}
}
else if ( Ntk_ObjIsNode(pObj) || Ntk_ObjIsCi(pObj) )
{
Ntk_ObjForEachFanout( pObj, pNext, i )
Ntk_ManDfsReverse_rec( pNext, vNodes );
}
else
assert( 0 );
Vec_PtrPush( vNodes, pObj );
}
/**Function*************************************************************
Synopsis [Returns the DFS ordered array of all objects except latches.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Ntk_ManDfsReverse( Ntk_Man_t * pNtk )
{
Vec_Ptr_t * vNodes;
Ntk_Obj_t * pObj;
int i;
Ntk_ManIncrementTravId( pNtk );
vNodes = Vec_PtrAlloc( 100 );
Ntk_ManForEachPi( pNtk, pObj, i )
Ntk_ManDfsReverse_rec( pObj, vNodes );
return vNodes;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......@@ -31,7 +31,7 @@ extern "C" {
#include "aig.h"
#include "tim.h"
#include "ntk.h"
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
......@@ -94,11 +94,14 @@ struct Ntl_Mod_t_
Vec_Int_t * vArrivals;
Vec_Int_t * vRequireds;
float * pDelayTable;
// other data members
void * pCopy;
};
struct Ntl_Obj_t_
{
Ntl_Mod_t * pModel; // the model
void * pCopy; // the copy of this object
unsigned Type : 3; // object type
unsigned Id : 27; // object ID
unsigned MarkA : 1; // temporary mark
......@@ -115,9 +118,9 @@ struct Ntl_Obj_t_
struct Ntl_Net_t_
{
Ntl_Obj_t * pDriver; // driver of the net
Ntl_Net_t * pNext; // next net in the hash table
Aig_Obj_t * pFunc; // the AIG representation
void * pCopy; // the copy of this object
Ntl_Obj_t * pDriver; // driver of the net
char nVisits; // the number of times the net is visited
char fMark; // temporary mark
char pName[0]; // the name of this net
......@@ -140,6 +143,8 @@ struct Ntl_Lut_t_
/// INLINED FUNCTIONS ///
////////////////////////////////////////////////////////////////////////
static inline Ntl_Mod_t * Ntl_ManRootModel( Ntl_Man_t * p ) { return Vec_PtrEntry( p->vModels, 0 ); }
static inline int Ntl_ModelPiNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_PI]; }
static inline int Ntl_ModelPoNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_PO]; }
static inline int Ntl_ModelNodeNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_NODE]; }
......@@ -169,7 +174,7 @@ static inline Ntl_Net_t * Ntl_ObjFanin0( Ntl_Obj_t * p ) { return p->pF
static inline Ntl_Net_t * Ntl_ObjFanout0( Ntl_Obj_t * p ) { return p->pFanio[p->nFanins]; }
static inline Ntl_Net_t * Ntl_ObjFanin( Ntl_Obj_t * p, int i ) { return p->pFanio[i]; }
static inline Ntl_Net_t * Ntl_ObjFanout( Ntl_Obj_t * p, int i ) { return p->pFanio[p->nFanins+1]; }
static inline Ntl_Net_t * Ntl_ObjFanout( Ntl_Obj_t * p, int i ) { return p->pFanio[p->nFanins+i]; }
static inline void Ntl_ObjSetFanin( Ntl_Obj_t * p, Ntl_Net_t * pNet, int i ) { p->pFanio[i] = pNet; }
static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int i ) { p->pFanio[p->nFanins+i] = pNet; pNet->pDriver = p; }
......@@ -186,10 +191,10 @@ static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int
Vec_PtrForEachEntry( p->vCos, pNtl, i )
#define Ntl_ManForEachNode( p, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(p->vNodes)) && (((pObj) = Vec_PtrEntry(p->vNodes, i)), 1); i++ ) \
if ( !Ntl_ObjIsNode(pObj) ) {} else
if ( (pObj) == NULL || !Ntl_ObjIsNode(pObj) ) {} else
#define Ntl_ManForEachBox( p, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(p->vNodes)) && (((pObj) = Vec_PtrEntry(p->vNodes, i)), 1); i++ ) \
if ( !Ntl_ObjIsBox(pObj) ) {} else
if ( (pObj) == NULL || !Ntl_ObjIsBox(pObj) ) {} else
#define Ntl_ModelForEachPi( pNtl, pObj, i ) \
Vec_PtrForEachEntry( pNtl->vPis, pObj, i )
......@@ -200,13 +205,13 @@ static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int
if ( pObj == NULL ) {} else
#define Ntl_ModelForEachLatch( pNtl, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(pNtl->vObjs)) && (((pObj) = Vec_PtrEntry(pNtl->vObjs, i)), 1); i++ ) \
if ( !Ntl_ObjIsLatch(pObj) ) {} else
if ( (pObj) == NULL || !Ntl_ObjIsLatch(pObj) ) {} else
#define Ntl_ModelForEachNode( pNtl, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(pNtl->vObjs)) && (((pObj) = Vec_PtrEntry(pNtl->vObjs, i)), 1); i++ ) \
if ( !Ntl_ObjIsNode(pObj) ) {} else
if ( (pObj) == NULL || !Ntl_ObjIsNode(pObj) ) {} else
#define Ntl_ModelForEachBox( pNtl, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(pNtl->vObjs)) && (((pObj) = Vec_PtrEntry(pNtl->vObjs, i)), 1); i++ ) \
if ( !Ntl_ObjIsBox(pObj) ) {} else
if ( (pObj) == NULL || !Ntl_ObjIsBox(pObj) ) {} else
#define Ntl_ModelForEachNet( pNtl, pNet, i ) \
for ( i = 0; i < pNtl->nTableSize; i++ ) \
for ( pNet = pNtl->pTable[i]; pNet; pNet = pNet->pNext )
......@@ -225,21 +230,25 @@ extern int Ntl_ManInsertTest( Ntl_Man_t * p, Aig_Man_t * pAig );
extern int Ntl_ManInsertTestIf( Ntl_Man_t * p, Aig_Man_t * pAig );
/*=== ntlExtract.c ==========================================================*/
extern Aig_Man_t * Ntl_ManExtract( Ntl_Man_t * p );
extern Aig_Man_t * Ntl_ManCollapse( Ntl_Man_t * p );
extern char * Ntl_SopFromTruth( Ntl_Man_t * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover );
/*=== ntlInsert.c ==========================================================*/
extern int Ntl_ManInsert( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t * pAig );
extern int Ntl_ManInsertNtk( Ntl_Man_t * p, Ntk_Man_t * pNtk );
extern int Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk );
/*=== ntlCheck.c ==========================================================*/
extern int Ntl_ManCheck( Ntl_Man_t * pMan );
extern int Ntl_ModelCheck( Ntl_Mod_t * pModel );
extern void Ntl_ModelFixNonDrivenNets( Ntl_Mod_t * pModel );
/*=== ntlMan.c ============================================================*/
extern Ntl_Man_t * Ntl_ManAlloc( char * pFileName );
extern Ntl_Man_t * Ntl_ManStartFrom( Ntl_Man_t * p );
extern Ntl_Man_t * Ntl_ManDup( Ntl_Man_t * p );
extern void Ntl_ManFree( Ntl_Man_t * p );
extern Ntl_Mod_t * Ntl_ManFindModel( Ntl_Man_t * p, char * pName );
extern void Ntl_ManPrintStats( Ntl_Man_t * p );
extern Tim_Man_t * Ntl_ManReadTimeMan( Ntl_Man_t * p );
extern Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName );
extern Ntl_Mod_t * Ntl_ModelDup( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld );
extern void Ntl_ModelFree( Ntl_Mod_t * p );
/*=== ntlMap.c ============================================================*/
extern Vec_Ptr_t * Ntl_MappingAlloc( int nLuts, int nVars );
......@@ -252,14 +261,15 @@ extern Ntl_Obj_t * Ntl_ModelCreatePo( Ntl_Mod_t * pModel, Ntl_Net_t * pNet )
extern Ntl_Obj_t * Ntl_ModelCreateLatch( Ntl_Mod_t * pModel );
extern Ntl_Obj_t * Ntl_ModelCreateNode( Ntl_Mod_t * pModel, int nFanins );
extern Ntl_Obj_t * Ntl_ModelCreateBox( Ntl_Mod_t * pModel, int nFanins, int nFanouts );
extern Ntl_Obj_t * Ntl_ModelDupObj( Ntl_Mod_t * pModel, Ntl_Obj_t * pOld );
extern char * Ntl_ManStoreName( Ntl_Man_t * p, char * pName );
extern char * Ntl_ManStoreSop( Ntl_Man_t * p, char * pSop );
extern char * Ntl_ManStoreFileName( Ntl_Man_t * p, char * pFileName );
/*=== ntlTable.c ==========================================================*/
extern Ntl_Net_t * Ntl_ModelFindNet( Ntl_Mod_t * p, char * pName );
extern Ntl_Net_t * Ntl_ModelFindOrCreateNet( Ntl_Mod_t * p, char * pName );
extern int Ntl_ModelSetNetDriver( Ntl_Obj_t * pObj, Ntl_Net_t * pNet );
extern int Ntl_ModelFindPioNumber( Ntl_Mod_t * p, char * pName, int * pNumber );
extern int Ntl_ModelSetNetDriver( Ntl_Obj_t * pObj, Ntl_Net_t * pNet );
/*=== ntlTime.c ==========================================================*/
extern Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p );
/*=== ntlReadBlif.c ==========================================================*/
......
......@@ -40,11 +40,40 @@
SeeAlso []
***********************************************************************/
int Ntl_ManCheck( Ntl_Man_t * pMan )
int Ntl_ModelCheck( Ntl_Mod_t * pModel )
{
// check that the models have unique names
// check that the models (except the first one) do not have boxes
return 1;
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet;
int i, k, fStatus = 1;
Ntl_ModelForEachNet( pModel, pNet, i )
{
if ( pNet->pName == NULL )
{
printf( "Net %d does not have a name\n", i );
fStatus = 0;
}
if ( pNet->pDriver == NULL )
{
printf( "Net %d (%s) does not have a driver\n", i, pNet->pName );
fStatus = 0;
}
}
Ntl_ModelForEachObj( pModel, pObj, i )
{
Ntl_ObjForEachFanin( pObj, pNet, k )
if ( pNet == NULL )
{
printf( "Object %d does not have fanin net %d\n", i, k );
fStatus = 0;
}
Ntl_ObjForEachFanout( pObj, pNet, k )
if ( pNet == NULL )
{
printf( "Object %d does not have fanout net %d\n", i, k );
fStatus = 0;
}
}
return fStatus;
}
/**Function*************************************************************
......@@ -58,9 +87,45 @@ int Ntl_ManCheck( Ntl_Man_t * pMan )
SeeAlso []
***********************************************************************/
int Ntl_ModelCheck( Ntl_Mod_t * pModel )
int Ntl_ManCheck( Ntl_Man_t * pMan )
{
return 1;
Ntl_Mod_t * pMod1, * pMod2;
int i, k, fStatus = 1;
// check that the models have unique names
Ntl_ManForEachModel( pMan, pMod1, i )
{
if ( pMod1->pName == NULL )
{
printf( "Model %d does not have a name\n", i );
fStatus = 0;
}
Ntl_ManForEachModel( pMan, pMod2, k )
{
if ( i >= k )
continue;
if ( strcmp(pMod1->pName, pMod2->pName) == 0 )
{
printf( "Models %d and %d have the same name (%s).\n", i, k, pMod1->pName );
fStatus = 0;
}
}
}
// check that the models (except the first one) do not have boxes
Ntl_ManForEachModel( pMan, pMod1, i )
{
if ( i == 0 )
continue;
if ( Ntl_ModelBoxNum(pMod1) > 0 )
{
printf( "Non-root model %d (%s) has %d boxes.\n", i, pMod1->pName, Ntl_ModelBoxNum(pMod1) );
fStatus = 0;
}
}
// check models
Ntl_ManForEachModel( pMan, pMod1, i )
if ( !Ntl_ModelCheck( pMod1 ) )
fStatus = 0;
return fStatus;
}
......
......@@ -52,17 +52,17 @@ int Ntl_ManInsert( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t * pAig )
int i, k, nDigits;
// map the AIG back onto the design
Ntl_ManForEachCiNet( p, pNet, i )
pNet->pFunc = Aig_ManPi( pAig, i );
pNet->pCopy = Aig_ManPi( pAig, i );
Ntl_ManForEachCoNet( p, pNet, i )
pNet->pFunc = Aig_ObjChild0( Aig_ManPo( pAig, i ) );
pNet->pCopy = Aig_ObjChild0( Aig_ManPo( pAig, i ) );
// remove old nodes
pRoot = Vec_PtrEntry( p->vModels, 0 );
pRoot = Ntl_ManRootModel( p );
Ntl_ModelForEachNode( pRoot, pNode, i )
Vec_PtrWriteEntry( pRoot->vObjs, pNode->Id, NULL );
// start mapping of AIG nodes into their copies
vCopies = Vec_PtrStart( Aig_ManObjNumMax(pAig) );
Ntl_ManForEachCiNet( p, pNet, i )
Vec_PtrWriteEntry( vCopies, pNet->pFunc->Id, pNet );
Vec_PtrWriteEntry( vCopies, ((Aig_Obj_t *)pNet->pCopy)->Id, pNet );
// create a new node for each LUT
vCover = Vec_IntAlloc( 1 << 16 );
nDigits = Aig_Base10Log( Vec_PtrSize(vMapping) );
......@@ -100,16 +100,16 @@ int Ntl_ManInsert( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t * pAig )
Vec_IntFree( vCover );
// mark CIs and outputs of the registers
Ntl_ManForEachCiNet( p, pNetCo, i )
pNetCo->nVisits = 101;
pNetCo->nVisits = 101; // using "101" is harmless because nVisits can only be 0, 1 or 2
// update the CO pointers
Ntl_ManForEachCoNet( p, pNetCo, i )
{
if ( pNetCo->nVisits == 101 )
continue;
pNetCo->nVisits = 101;
pNet = Vec_PtrEntry( vCopies, Aig_Regular(pNetCo->pFunc)->Id );
pNet = Vec_PtrEntry( vCopies, Aig_Regular(pNetCo->pCopy)->Id );
pNode = Ntl_ModelCreateNode( pRoot, 1 );
pNode->pSop = Aig_IsComplement(pNetCo->pFunc)? Ntl_ManStoreSop( p, "0 1\n" ) : Ntl_ManStoreSop( p, "1 1\n" );
pNode->pSop = Aig_IsComplement(pNetCo->pCopy)? Ntl_ManStoreSop( p, "0 1\n" ) : Ntl_ManStoreSop( p, "1 1\n" );
Ntl_ObjSetFanin( pNode, pNet, 0 );
// update the CO driver net
pNetCo->pDriver = NULL;
......@@ -134,7 +134,7 @@ int Ntl_ManInsert( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t * pAig )
SeeAlso []
***********************************************************************/
int Ntl_ManInsertNtk( Ntl_Man_t * p, Ntk_Man_t * pNtk )
int Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk )
{
char Buffer[100];
Vec_Int_t * vTruth;
......@@ -142,32 +142,34 @@ int Ntl_ManInsertNtk( Ntl_Man_t * p, Ntk_Man_t * pNtk )
Ntl_Mod_t * pRoot;
Ntl_Obj_t * pNode;
Ntl_Net_t * pNet, * pNetCo;
Ntk_Obj_t * pObj, * pFanin;
Nwk_Obj_t * pObj, * pFanin;
int i, k, nDigits;
unsigned * pTruth;
assert( Vec_PtrSize(p->vCis) == Ntk_ManCiNum(pNtk) );
assert( Vec_PtrSize(p->vCos) == Ntk_ManCoNum(pNtk) );
assert( Vec_PtrSize(p->vCis) == Nwk_ManCiNum(pNtk) );
assert( Vec_PtrSize(p->vCos) == Nwk_ManCoNum(pNtk) );
// set the correspondence between the PI/PO nodes
Ntl_ManForEachCiNet( p, pNet, i )
Ntk_ManCi( pNtk, i )->pCopy = pNet;
Nwk_ManCi( pNtk, i )->pCopy = pNet;
// Ntl_ManForEachCoNet( p, pNet, i )
// Ntk_ManCo( pNtk, i )->pCopy = pNet;
// Nwk_ManCo( pNtk, i )->pCopy = pNet;
// remove old nodes
pRoot = Vec_PtrEntry( p->vModels, 0 );
pRoot = Ntl_ManRootModel( p );
Ntl_ModelForEachNode( pRoot, pNode, i )
Vec_PtrWriteEntry( pRoot->vObjs, pNode->Id, NULL );
// create a new node for each LUT
vTruth = Vec_IntAlloc( 1 << 16 );
vCover = Vec_IntAlloc( 1 << 16 );
nDigits = Aig_Base10Log( Ntk_ManNodeNum(pNtk) );
Ntk_ManForEachNode( pNtk, pObj, i )
nDigits = Aig_Base10Log( Nwk_ManNodeNum(pNtk) );
Nwk_ManForEachNode( pNtk, pObj, i )
{
pNode = Ntl_ModelCreateNode( pRoot, Ntk_ObjFaninNum(pObj) );
pTruth = Hop_ManConvertAigToTruth( pNtk->pManHop, pObj->pFunc, Ntk_ObjFaninNum(pObj), vTruth, 0 );
pNode->pSop = Ntl_SopFromTruth( p, pTruth, Ntk_ObjFaninNum(pObj), vCover );
if ( !Kit_TruthIsConst0(pTruth, Ntk_ObjFaninNum(pObj)) && !Kit_TruthIsConst1(pTruth, Ntk_ObjFaninNum(pObj)) )
pNode = Ntl_ModelCreateNode( pRoot, Nwk_ObjFaninNum(pObj) );
pTruth = Hop_ManConvertAigToTruth( pNtk->pManHop, Hop_Regular(pObj->pFunc), Nwk_ObjFaninNum(pObj), vTruth, 0 );
if ( Hop_IsComplement(pObj->pFunc) )
Kit_TruthNot( pTruth, pTruth, Nwk_ObjFaninNum(pObj) );
pNode->pSop = Ntl_SopFromTruth( p, pTruth, Nwk_ObjFaninNum(pObj), vCover );
if ( !Kit_TruthIsConst0(pTruth, Nwk_ObjFaninNum(pObj)) && !Kit_TruthIsConst1(pTruth, Nwk_ObjFaninNum(pObj)) )
{
Ntk_ObjForEachFanin( pObj, pFanin, k )
Nwk_ObjForEachFanin( pObj, pFanin, k )
{
pNet = pFanin->pCopy;
if ( pNet == NULL )
......@@ -204,12 +206,12 @@ int Ntl_ManInsertNtk( Ntl_Man_t * p, Ntk_Man_t * pNtk )
continue;
pNetCo->nVisits = 101;
// get the corresponding PO and its driver
pObj = Ntk_ManCo( pNtk, i );
pFanin = Ntk_ObjFanin0( pObj );
pObj = Nwk_ManCo( pNtk, i );
pFanin = Nwk_ObjFanin0( pObj );
// get the net driving the driver
pNet = pFanin->pCopy; //Vec_PtrEntry( vCopies, Aig_Regular(pNetCo->pFunc)->Id );
pNet = pFanin->pCopy; //Vec_PtrEntry( vCopies, Aig_Regular(pNetCo->pCopy)->Id );
pNode = Ntl_ModelCreateNode( pRoot, 1 );
pNode->pSop = pObj->fCompl /*Aig_IsComplement(pNetCo->pFunc)*/? Ntl_ManStoreSop( p, "0 1\n" ) : Ntl_ManStoreSop( p, "1 1\n" );
pNode->pSop = pObj->fCompl /*Aig_IsComplement(pNetCo->pCopy)*/? Ntl_ManStoreSop( p, "0 1\n" ) : Ntl_ManStoreSop( p, "1 1\n" );
Ntl_ObjSetFanin( pNode, pNet, 0 );
// update the CO driver net
pNetCo->pDriver = NULL;
......
......@@ -61,6 +61,57 @@ Ntl_Man_t * Ntl_ManAlloc( char * pFileName )
/**Function*************************************************************
Synopsis [Duplicates the interface of the top level model.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ntl_Man_t * Ntl_ManStartFrom( Ntl_Man_t * pOld )
{
return NULL;
}
/**Function*************************************************************
Synopsis [Duplicates the interface of the top level model.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ntl_Man_t * Ntl_ManDup( Ntl_Man_t * pOld )
{
Ntl_Man_t * pNew;
Ntl_Mod_t * pModel;
Ntl_Obj_t * pBox;
Ntl_Net_t * pNet;
int i, k;
pNew = Ntl_ManAlloc( pOld->pSpec );
Vec_PtrForEachEntry( pOld->vModels, pModel, i )
pModel->pCopy = Ntl_ModelDup( pNew, pModel );
Vec_PtrForEachEntry( pOld->vModels, pModel, i )
Ntl_ModelForEachBox( pModel, pBox, k )
((Ntl_Obj_t *)pBox->pCopy)->pImplem = pBox->pImplem->pCopy;
Ntl_ManForEachCiNet( pOld, pNet, i )
Vec_PtrPush( pNew->vCis, pNet->pCopy );
Ntl_ManForEachCoNet( pOld, pNet, i )
Vec_PtrPush( pNew->vCos, pNet->pCopy );
if ( pOld->pManTime )
pNew->pManTime = Tim_ManDup( pOld->pManTime, 0 );
if ( !Ntl_ManCheck( pNew ) )
printf( "Ntl_ManDup: The check has failed for design %s.\n", pNew->pName );
return pNew;
}
/**Function*************************************************************
Synopsis [Deallocates the netlist manager.]
Description []
......@@ -126,15 +177,16 @@ Ntl_Mod_t * Ntl_ManFindModel( Ntl_Man_t * p, char * pName )
void Ntl_ManPrintStats( Ntl_Man_t * p )
{
Ntl_Mod_t * pRoot;
pRoot = Vec_PtrEntry( p->vModels, 0 );
pRoot = Ntl_ManRootModel( p );
printf( "%-15s : ", p->pName );
printf( "pi = %5d ", Ntl_ModelPiNum(pRoot) );
printf( "po = %5d ", Ntl_ModelPoNum(pRoot) );
printf( "latch = %5d ", Ntl_ModelLatchNum(pRoot) );
printf( "lat = %5d ", Ntl_ModelLatchNum(pRoot) );
printf( "node = %5d ", Ntl_ModelNodeNum(pRoot) );
printf( "box = %4d ", Ntl_ModelBoxNum(pRoot) );
printf( "model = %3d", Vec_PtrSize(p->vModels) );
printf( "mod = %3d", Vec_PtrSize(p->vModels) );
printf( "\n" );
fflush( stdout );
}
/**Function*************************************************************
......@@ -173,11 +225,11 @@ Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName )
p->pMan = pMan;
p->pName = Ntl_ManStoreName( p->pMan, pName );
Vec_PtrPush( pMan->vModels, p );
p->vObjs = Vec_PtrAlloc( 10000 );
p->vPis = Vec_PtrAlloc( 1000 );
p->vPos = Vec_PtrAlloc( 1000 );
p->vObjs = Vec_PtrAlloc( 1000 );
p->vPis = Vec_PtrAlloc( 100 );
p->vPos = Vec_PtrAlloc( 100 );
// start the table
p->nTableSize = Aig_PrimeCudd( 10000 );
p->nTableSize = Aig_PrimeCudd( 1000 );
p->pTable = ALLOC( Ntl_Net_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Ntl_Net_t *) * p->nTableSize );
return p;
......@@ -185,6 +237,41 @@ Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName )
/**Function*************************************************************
Synopsis [Duplicates the model.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ntl_Mod_t * Ntl_ModelDup( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld )
{
Ntl_Mod_t * pModelNew;
Ntl_Net_t * pNet;
Ntl_Obj_t * pObj;
int i, k;
pModelNew = Ntl_ModelAlloc( pManNew, pModelOld->pName );
Ntl_ModelForEachNet( pModelOld, pNet, i )
pNet->pCopy = Ntl_ModelFindOrCreateNet( pModelNew, pNet->pName );
Ntl_ModelForEachObj( pModelOld, pObj, i )
{
pObj->pCopy = Ntl_ModelDupObj( pModelNew, pObj );
Ntl_ObjForEachFanin( pObj, pNet, k )
Ntl_ObjSetFanin( pObj->pCopy, pNet->pCopy, k );
Ntl_ObjForEachFanout( pObj, pNet, k )
Ntl_ObjSetFanout( pObj->pCopy, pNet->pCopy, k );
if ( Ntl_ObjIsLatch(pObj) )
((Ntl_Obj_t *)pObj->pCopy)->LatchId = pObj->LatchId;
if ( Ntl_ObjIsNode(pObj) )
((Ntl_Obj_t *)pObj->pCopy)->pSop = Ntl_ManStoreSop( pManNew, pObj->pSop );
}
return pModelNew;
}
/**Function*************************************************************
Synopsis [Deallocates the model.]
Description []
......
......@@ -136,7 +136,7 @@ void Ntl_ManSetIfParsDefault( If_Par_t * pPars )
pPars->fExpRed = 0;
pPars->fLatchPaths = 0;
pPars->fEdge = 1;
pPars->fCutMin = 1;
pPars->fCutMin = 0;
pPars->fSeqMap = 0;
pPars->fVerbose = 1;
// internal parameters
......
......@@ -163,6 +163,33 @@ Ntl_Obj_t * Ntl_ModelCreateBox( Ntl_Mod_t * pModel, int nFanins, int nFanouts )
/**Function*************************************************************
Synopsis [Create the latch.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ntl_Obj_t * Ntl_ModelDupObj( Ntl_Mod_t * pModel, Ntl_Obj_t * pOld )
{
Ntl_Obj_t * pNew;
if ( Ntl_ObjIsPi( pOld ) )
pNew = Ntl_ModelCreatePi( pModel );
else if ( Ntl_ObjIsPo( pOld ) )
pNew = Ntl_ModelCreatePo( pModel, NULL );
else if ( Ntl_ObjIsLatch( pOld ) )
pNew = Ntl_ModelCreateLatch( pModel );
else if ( Ntl_ObjIsNode( pOld ) )
pNew = Ntl_ModelCreateNode( pModel, Ntl_ObjFaninNum(pOld) );
else if ( Ntl_ObjIsBox( pOld ) )
pNew = Ntl_ModelCreateBox( pModel, Ntl_ObjFaninNum(pOld), Ntl_ObjFanoutNum(pOld) );
return pNew;
}
/**Function*************************************************************
Synopsis [Allocates memory and copies the name into it.]
Description []
......
......@@ -108,9 +108,7 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
{
FILE * pFile;
Ioa_ReadMan_t * p;
Ntl_Mod_t * pNtk;
Ntl_Man_t * pDesign;
int i;
// check that the file is available
pFile = fopen( pFileName, "rb" );
......@@ -158,20 +156,9 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
// make sure that everything is okay with the network structure
if ( fCheck )
{
// check individual models
Vec_PtrForEachEntry( pDesign->vModels, pNtk, i )
{
if ( !Ntl_ModelCheck( pNtk ) )
{
printf( "Ioa_ReadBlif: The network check has failed for network %s.\n", pNtk->pName );
Ntl_ManFree( pDesign );
return NULL;
}
}
// check the hierarchy
if ( !Ntl_ManCheck( pDesign ) )
{
printf( "Ioa_ReadBlif: The hierarchy check has failed for design %s.\n", pDesign->pName );
printf( "Ioa_ReadBlif: The check has failed for design %s.\n", pDesign->pName );
Ntl_ManFree( pDesign );
return NULL;
}
......
......@@ -151,28 +151,6 @@ Ntl_Net_t * Ntl_ModelFindOrCreateNet( Ntl_Mod_t * p, char * pName )
/**Function*************************************************************
Synopsis [Finds or creates the net.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ntl_ModelSetNetDriver( Ntl_Obj_t * pObj, Ntl_Net_t * pNet )
{
if ( pObj->pFanio[pObj->nFanins] != NULL )
return 0;
if ( pNet->pDriver != NULL )
return 0;
pObj->pFanio[pObj->nFanins] = pNet;
pNet->pDriver = pObj;
return 1;
}
/**Function*************************************************************
Synopsis [Returns -1, 0, +1 (when it is PI, not found, or PO).]
Description []
......@@ -210,6 +188,28 @@ int Ntl_ModelFindPioNumber( Ntl_Mod_t * p, char * pName, int * pNumber )
return 0;
}
/**Function*************************************************************
Synopsis [Finds or creates the net.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ntl_ModelSetNetDriver( Ntl_Obj_t * pObj, Ntl_Net_t * pNet )
{
if ( pObj->pFanio[pObj->nFanins] != NULL )
return 0;
if ( pNet->pDriver != NULL )
return 0;
pObj->pFanio[pObj->nFanins] = pNet;
pNet->pDriver = pObj;
return 1;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -84,7 +84,7 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p )
Ntl_Obj_t * pObj;
int i, curPi, iBox, Entry;
assert( p->pAig != NULL );
pRoot = Vec_PtrEntry( p->vModels, 0 );
pRoot = Ntl_ManRootModel( p );
// start the timing manager
pMan = Tim_ManStart( Aig_ManPiNum(p->pAig), Aig_ManPoNum(p->pAig) );
// unpack the data in the arrival times
......
SRC += src/aig/nwk/nwkCheck.c \
src/aig/nwk/nwkBidec.c \
src/aig/nwk/nwkDfs.c \
src/aig/nwk/nwkFanio.c \
src/aig/nwk/nwkMan.c \
src/aig/nwk/nwkMap.c \
src/aig/nwk/nwkObj.c \
src/aig/nwk/nwkSpeedup.c \
src/aig/nwk/nwkStrash.c \
src/aig/nwk/nwkTiming.c \
src/aig/nwk/nwkUtil.c
/**CFile****************************************************************
FileName [ntkBidec.c]
FileName [nwkBidec.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
PackageName [Logic network representation.]
Synopsis [Bi-decomposition of local functions.]
......@@ -14,12 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntkBidec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: nwkBidec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "bdc.h"
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -42,7 +41,7 @@ static inline Hop_Obj_t * Bdc_FunCopyHop( Bdc_Fun_t * pObj ) { return Hop_NotCo
SeeAlso []
***********************************************************************/
Hop_Obj_t * Ntk_NodeIfNodeResyn( Bdc_Man_t * p, Hop_Man_t * pHop, Hop_Obj_t * pRoot, int nVars, Vec_Int_t * vTruth, unsigned * puCare )
Hop_Obj_t * Nwk_NodeIfNodeResyn( Bdc_Man_t * p, Hop_Man_t * pHop, Hop_Obj_t * pRoot, int nVars, Vec_Int_t * vTruth, unsigned * puCare )
{
unsigned * pTruth;
Bdc_Fun_t * pFunc;
......@@ -79,15 +78,15 @@ Hop_Obj_t * Ntk_NodeIfNodeResyn( Bdc_Man_t * p, Hop_Man_t * pHop, Hop_Obj_t * pR
SeeAlso []
***********************************************************************/
void Ntk_ManBidecResyn( Ntk_Man_t * pNtk, int fVerbose )
void Nwk_ManBidecResyn( Nwk_Man_t * pNtk, int fVerbose )
{
Bdc_Par_t Pars = {0}, * pPars = &Pars;
Bdc_Man_t * p;
Ntk_Obj_t * pObj;
Nwk_Obj_t * pObj;
Vec_Int_t * vTruth;
int i, nGainTotal = 0, nNodes1, nNodes2;
int clk = clock();
pPars->nVarsMax = Ntk_ManGetFaninMax( pNtk );
pPars->nVarsMax = Nwk_ManGetFaninMax( pNtk );
pPars->fVerbose = fVerbose;
if ( pPars->nVarsMax > 15 )
{
......@@ -97,12 +96,12 @@ void Ntk_ManBidecResyn( Ntk_Man_t * pNtk, int fVerbose )
}
vTruth = Vec_IntAlloc( 0 );
p = Bdc_ManAlloc( pPars );
Ntk_ManForEachNode( pNtk, pObj, i )
Nwk_ManForEachNode( pNtk, pObj, i )
{
if ( Ntk_ObjFaninNum(pObj) > 15 )
if ( Nwk_ObjFaninNum(pObj) > 15 )
continue;
nNodes1 = Hop_DagSize(pObj->pFunc);
pObj->pFunc = Ntk_NodeIfNodeResyn( p, pNtk->pManHop, pObj->pFunc, Ntk_ObjFaninNum(pObj), vTruth, NULL );
pObj->pFunc = Nwk_NodeIfNodeResyn( p, pNtk->pManHop, pObj->pFunc, Nwk_ObjFaninNum(pObj), vTruth, NULL );
nNodes2 = Hop_DagSize(pObj->pFunc);
nGainTotal += nNodes1 - nNodes2;
}
......
/**CFile****************************************************************
FileName [nwkCheck.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Logic network representation.]
Synopsis [Consistency checking procedures.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkCheck.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [ntkMan.c]
FileName [nwkMan.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
PackageName [Logic network representation.]
Synopsis [Network manager.]
Author [Alan Mishchenko]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntkMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: nwkMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -30,7 +30,7 @@
/**Function*************************************************************
Synopsis [Allocates the netlist manager.]
Synopsis [Allocates the manager.]
Description []
......@@ -39,16 +39,16 @@
SeeAlso []
***********************************************************************/
Ntk_Man_t * Ntk_ManAlloc()
Nwk_Man_t * Nwk_ManAlloc()
{
Ntk_Man_t * p;
p = ALLOC( Ntk_Man_t, 1 );
memset( p, 0, sizeof(Ntk_Man_t) );
Nwk_Man_t * p;
p = ALLOC( Nwk_Man_t, 1 );
memset( p, 0, sizeof(Nwk_Man_t) );
p->vCis = Vec_PtrAlloc( 1000 );
p->vCos = Vec_PtrAlloc( 1000 );
p->vObjs = Vec_PtrAlloc( 1000 );
p->vTemp = Vec_PtrAlloc( 1000 );
p->nFanioPlus = 4;
p->nFanioPlus = 2;
p->pMemObjs = Aig_MmFlexStart();
p->pManHop = Hop_ManStart();
return p;
......@@ -56,7 +56,7 @@ Ntk_Man_t * Ntk_ManAlloc()
/**Function*************************************************************
Synopsis [Deallocates the netlist manager.]
Synopsis [Deallocates the manager.]
Description []
......@@ -65,8 +65,9 @@ Ntk_Man_t * Ntk_ManAlloc()
SeeAlso []
***********************************************************************/
void Ntk_ManFree( Ntk_Man_t * p )
void Nwk_ManFree( Nwk_Man_t * p )
{
// printf( "The number of realloced nodes = %d.\n", p->nRealloced );
if ( p->pName ) free( p->pName );
if ( p->pSpec ) free( p->pSpec );
if ( p->vCis ) Vec_PtrFree( p->vCis );
......@@ -81,7 +82,7 @@ void Ntk_ManFree( Ntk_Man_t * p )
/**Function*************************************************************
Synopsis [Deallocates the netlist manager.]
Synopsis [Prints stats of the manager.]
Description []
......@@ -90,23 +91,22 @@ void Ntk_ManFree( Ntk_Man_t * p )
SeeAlso []
***********************************************************************/
void Ntk_ManPrintStats( Ntk_Man_t * p, If_Lib_t * pLutLib )
void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib )
{
printf( "%-15s : ", p->pName );
printf( "pi = %5d ", Ntk_ManPiNum(p) );
printf( "po = %5d ", Ntk_ManPoNum(p) );
printf( "ci = %5d ", Ntk_ManCiNum(p) );
printf( "co = %5d ", Ntk_ManCoNum(p) );
printf( "lat = %5d ", Ntk_ManLatchNum(p) );
// printf( "box = %5d ", Ntk_ManBoxNum(p) );
printf( "node = %5d ", Ntk_ManNodeNum(p) );
printf( "aig = %6d ", Ntk_ManGetAigNodeNum(p) );
printf( "lev = %3d ", Ntk_ManLevel(p) );
printf( "lev2 = %3d ", Ntk_ManLevel2(p) );
printf( "delay = %5.2f", Ntk_ManDelayTraceLut(p, pLutLib) );
printf( "pi = %5d ", Nwk_ManPiNum(p) );
printf( "po = %5d ", Nwk_ManPoNum(p) );
printf( "ci = %5d ", Nwk_ManCiNum(p) );
printf( "co = %5d ", Nwk_ManCoNum(p) );
printf( "lat = %5d ", Nwk_ManLatchNum(p) );
printf( "node = %5d ", Nwk_ManNodeNum(p) );
printf( "aig = %6d ", Nwk_ManGetAigNodeNum(p) );
printf( "lev = %3d ", Nwk_ManLevel(p) );
// printf( "lev2 = %3d ", Nwk_ManLevel2(p) );
printf( "delay = %5.2f", Nwk_ManDelayTraceLut(p, pLutLib) );
printf( "\n" );
Ntk_ManDelayTracePrint( p, pLutLib );
// Nwk_ManDelayTracePrint( p, pLutLib );
fflush( stdout );
}
////////////////////////////////////////////////////////////////////////
......
/**CFile****************************************************************
FileName [ntkMap.c]
FileName [nwkMap.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
PackageName [Logic network representation.]
Synopsis [Interface to technology mapping.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntkMap.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: nwkMap.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "nwk.h"
#include "if.h"
////////////////////////////////////////////////////////////////////////
......@@ -40,7 +40,7 @@
SeeAlso []
***********************************************************************/
void Ntk_ManSetIfParsDefault( If_Par_t * pPars )
void Nwk_ManSetIfParsDefault( If_Par_t * pPars )
{
// extern void * Abc_FrameReadLibLut();
// set defaults
......@@ -59,9 +59,9 @@ void Ntk_ManSetIfParsDefault( If_Par_t * pPars )
pPars->fExpRed = 0;
pPars->fLatchPaths = 0;
pPars->fEdge = 1;
pPars->fCutMin = 1;
pPars->fCutMin = 0;
pPars->fSeqMap = 0;
pPars->fVerbose = 1;
pPars->fVerbose = 0;
// internal parameters
pPars->fTruth = 0;
pPars->nLatches = 0;
......@@ -96,7 +96,7 @@ void Ntk_ManSetIfParsDefault( If_Par_t * pPars )
SeeAlso []
***********************************************************************/
If_Man_t * Ntk_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
If_Man_t * Nwk_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
{
If_Man_t * pIfMan;
Aig_Obj_t * pNode;//, * pFanin, * pPrev;
......@@ -156,7 +156,7 @@ If_Man_t * Ntk_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
SeeAlso []
***********************************************************************/
Hop_Obj_t * Ntk_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t * pIfObj, Vec_Ptr_t * vVisited )
Hop_Obj_t * Nwk_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t * pIfObj, Vec_Ptr_t * vVisited )
{
If_Cut_t * pCut;
If_Obj_t * pTemp;
......@@ -176,10 +176,10 @@ Hop_Obj_t * Ntk_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj
// compute the functions of the children
for ( pTemp = pIfObj; pTemp; pTemp = pTemp->pEquiv )
{
gFunc0 = Ntk_NodeIfToHop2_rec( pHopMan, pIfMan, pTemp->pFanin0, vVisited );
gFunc0 = Nwk_NodeIfToHop2_rec( pHopMan, pIfMan, pTemp->pFanin0, vVisited );
if ( gFunc0 == (void *)1 )
continue;
gFunc1 = Ntk_NodeIfToHop2_rec( pHopMan, pIfMan, pTemp->pFanin1, vVisited );
gFunc1 = Nwk_NodeIfToHop2_rec( pHopMan, pIfMan, pTemp->pFanin1, vVisited );
if ( gFunc1 == (void *)1 )
continue;
// both branches are solved
......@@ -203,7 +203,7 @@ Hop_Obj_t * Ntk_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj
SeeAlso []
***********************************************************************/
Hop_Obj_t * Ntk_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t * pIfObj )
Hop_Obj_t * Nwk_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t * pIfObj )
{
If_Cut_t * pCut;
Hop_Obj_t * gFunc;
......@@ -217,10 +217,10 @@ Hop_Obj_t * Ntk_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t *
If_CutSetData( If_ObjCutBest(pLeaf), Hop_IthVar(pHopMan, i) );
// recursively compute the function while collecting visited cuts
Vec_PtrClear( pIfMan->vTemp );
gFunc = Ntk_NodeIfToHop2_rec( pHopMan, pIfMan, pIfObj, pIfMan->vTemp );
gFunc = Nwk_NodeIfToHop2_rec( pHopMan, pIfMan, pIfObj, pIfMan->vTemp );
if ( gFunc == (void *)1 )
{
printf( "Ntk_NodeIfToHop(): Computing local AIG has failed.\n" );
printf( "Nwk_NodeIfToHop(): Computing local AIG has failed.\n" );
return NULL;
}
// printf( "%d ", Vec_PtrSize(p->vTemp) );
......@@ -243,10 +243,10 @@ Hop_Obj_t * Ntk_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t *
SeeAlso []
***********************************************************************/
Ntk_Man_t * Ntk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p )
Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p )
{
Ntk_Man_t * pNtk;
Ntk_Obj_t * pObjNew;
Nwk_Man_t * pNtk;
Nwk_Obj_t * pObjNew;
Aig_Obj_t * pObj;
If_Obj_t * pIfObj;
If_Cut_t * pCutBest;
......@@ -256,7 +256,7 @@ Ntk_Man_t * Ntk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p )
assert( Aig_ManNodeNum(p) == If_ManAndNum(pIfMan) );
If_ManCleanCutData( pIfMan );
// construct the network
pNtk = Ntk_ManAlloc();
pNtk = Nwk_ManAlloc();
pNtk->pName = Aig_UtilStrsav( p->pName );
pNtk->pSpec = Aig_UtilStrsav( p->pSpec );
Aig_ManForEachObj( p, pObj, i )
......@@ -270,23 +270,23 @@ Ntk_Man_t * Ntk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p )
nLeaves = If_CutLeaveNum( pCutBest );
ppLeaves = If_CutLeaves( pCutBest );
// create node
pObjNew = Ntk_ManCreateNode( pNtk, nLeaves, pIfObj->nRefs );
pObjNew = Nwk_ManCreateNode( pNtk, nLeaves, pIfObj->nRefs );
for ( k = 0; k < nLeaves; k++ )
Ntk_ObjAddFanin( pObjNew, Aig_ManObj(p, ppLeaves[k])->pData );
Nwk_ObjAddFanin( pObjNew, Aig_ManObj(p, ppLeaves[k])->pData );
// get the functionality
pObjNew->pFunc = Ntk_NodeIfToHop( pNtk->pManHop, pIfMan, pIfObj );
pObjNew->pFunc = Nwk_NodeIfToHop( pNtk->pManHop, pIfMan, pIfObj );
}
else if ( Aig_ObjIsPi(pObj) )
pObjNew = Ntk_ManCreateCi( pNtk, pIfObj->nRefs );
pObjNew = Nwk_ManCreateCi( pNtk, pIfObj->nRefs );
else if ( Aig_ObjIsPo(pObj) )
{
pObjNew = Ntk_ManCreateCo( pNtk );
pObjNew = Nwk_ManCreateCo( pNtk );
pObjNew->fCompl = Aig_ObjFaninC0(pObj);
Ntk_ObjAddFanin( pObjNew, Aig_ObjFanin0(pObj)->pData );
Nwk_ObjAddFanin( pObjNew, Aig_ObjFanin0(pObj)->pData );
}
else if ( Aig_ObjIsConst1(pObj) )
{
pObjNew = Ntk_ManCreateNode( pNtk, 0, pIfObj->nRefs );
pObjNew = Nwk_ManCreateNode( pNtk, 0, pIfObj->nRefs );
pObjNew->pFunc = Hop_ManConst1( pNtk->pManHop );
}
else
......@@ -308,16 +308,16 @@ Ntk_Man_t * Ntk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p )
SeeAlso []
***********************************************************************/
Ntk_Man_t * Ntk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars )
Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars )
{
Ntk_Man_t * pNtk;
Nwk_Man_t * pNtk;
If_Man_t * pIfMan;
// perform FPGA mapping
// set the arrival times
pPars->pTimesArr = ALLOC( float, Aig_ManPiNum(p) );
memset( pPars->pTimesArr, 0, sizeof(float) * Aig_ManPiNum(p) );
// translate into the mapper
pIfMan = Ntk_ManToIf( p, pPars );
pIfMan = Nwk_ManToIf( p, pPars );
if ( pIfMan == NULL )
return NULL;
pIfMan->pManTim = Tim_ManDup( pManTime, 0 );
......@@ -327,7 +327,7 @@ Ntk_Man_t * Ntk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars
return NULL;
}
// transform the result of mapping into the new network
pNtk = Ntk_ManFromIf( pIfMan, p );
pNtk = Nwk_ManFromIf( pIfMan, p );
If_ManStop( pIfMan );
return pNtk;
}
......
/**CFile****************************************************************
FileName [ntkObj.c]
FileName [nwkObj.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
PackageName [Logic network representation.]
Synopsis [Manipulation of objects.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntkObj.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: nwkObj.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -39,11 +39,12 @@
SeeAlso []
***********************************************************************/
Ntk_Obj_t * Ntk_ManCreateObj( Ntk_Man_t * p, int nFanins, int nFanouts )
Nwk_Obj_t * Nwk_ManCreateObj( Nwk_Man_t * p, int nFanins, int nFanouts )
{
Ntk_Obj_t * pObj;
pObj = (Ntk_Obj_t *)Aig_MmFlexEntryFetch( p->pMemObjs, sizeof(Ntk_Obj_t) + (nFanins + nFanouts + p->nFanioPlus) * sizeof(Ntk_Obj_t *) );
memset( pObj, 0, sizeof(Ntk_Obj_t) );
Nwk_Obj_t * pObj;
pObj = (Nwk_Obj_t *)Aig_MmFlexEntryFetch( p->pMemObjs, sizeof(Nwk_Obj_t) + (nFanins + nFanouts + p->nFanioPlus) * sizeof(Nwk_Obj_t *) );
memset( pObj, 0, sizeof(Nwk_Obj_t) );
pObj->pFanio = (Nwk_Obj_t **)((char *)pObj + sizeof(Nwk_Obj_t));
pObj->Id = Vec_PtrSize( p->vObjs );
Vec_PtrPush( p->vObjs, pObj );
pObj->pMan = p;
......@@ -63,14 +64,14 @@ Ntk_Obj_t * Ntk_ManCreateObj( Ntk_Man_t * p, int nFanins, int nFanouts )
SeeAlso []
***********************************************************************/
Ntk_Obj_t * Ntk_ManCreateCi( Ntk_Man_t * p, int nFanouts )
Nwk_Obj_t * Nwk_ManCreateCi( Nwk_Man_t * p, int nFanouts )
{
Ntk_Obj_t * pObj;
pObj = Ntk_ManCreateObj( p, 1, nFanouts );
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, 1, nFanouts );
pObj->PioId = Vec_PtrSize( p->vCis );
Vec_PtrPush( p->vCis, pObj );
pObj->Type = NTK_OBJ_CI;
p->nObjs[NTK_OBJ_CI]++;
pObj->Type = NWK_OBJ_CI;
p->nObjs[NWK_OBJ_CI]++;
return pObj;
}
......@@ -85,14 +86,14 @@ Ntk_Obj_t * Ntk_ManCreateCi( Ntk_Man_t * p, int nFanouts )
SeeAlso []
***********************************************************************/
Ntk_Obj_t * Ntk_ManCreateCo( Ntk_Man_t * p )
Nwk_Obj_t * Nwk_ManCreateCo( Nwk_Man_t * p )
{
Ntk_Obj_t * pObj;
pObj = Ntk_ManCreateObj( p, 1, 1 );
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, 1, 1 );
pObj->PioId = Vec_PtrSize( p->vCos );
Vec_PtrPush( p->vCos, pObj );
pObj->Type = NTK_OBJ_CO;
p->nObjs[NTK_OBJ_CO]++;
pObj->Type = NWK_OBJ_CO;
p->nObjs[NWK_OBJ_CO]++;
return pObj;
}
......@@ -107,12 +108,12 @@ Ntk_Obj_t * Ntk_ManCreateCo( Ntk_Man_t * p )
SeeAlso []
***********************************************************************/
Ntk_Obj_t * Ntk_ManCreateLatch( Ntk_Man_t * p )
Nwk_Obj_t * Nwk_ManCreateLatch( Nwk_Man_t * p )
{
Ntk_Obj_t * pObj;
pObj = Ntk_ManCreateObj( p, 1, 1 );
pObj->Type = NTK_OBJ_LATCH;
p->nObjs[NTK_OBJ_LATCH]++;
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, 1, 1 );
pObj->Type = NWK_OBJ_LATCH;
p->nObjs[NWK_OBJ_LATCH]++;
return pObj;
}
......@@ -127,32 +128,12 @@ Ntk_Obj_t * Ntk_ManCreateLatch( Ntk_Man_t * p )
SeeAlso []
***********************************************************************/
Ntk_Obj_t * Ntk_ManCreateNode( Ntk_Man_t * p, int nFanins, int nFanouts )
Nwk_Obj_t * Nwk_ManCreateNode( Nwk_Man_t * p, int nFanins, int nFanouts )
{
Ntk_Obj_t * pObj;
pObj = Ntk_ManCreateObj( p, nFanins, nFanouts );
pObj->Type = NTK_OBJ_NODE;
p->nObjs[NTK_OBJ_NODE]++;
return pObj;
}
/**Function*************************************************************
Synopsis [Creates a box.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ntk_Obj_t * Ntk_ManCreateBox( Ntk_Man_t * p, int nFanins, int nFanouts )
{
Ntk_Obj_t * pObj;
pObj = Ntk_ManCreateObj( p, nFanins, nFanouts );
pObj->Type = NTK_OBJ_BOX;
p->nObjs[NTK_OBJ_BOX]++;
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, nFanins, nFanouts );
pObj->Type = NWK_OBJ_NODE;
p->nObjs[NWK_OBJ_NODE]++;
return pObj;
}
......@@ -168,22 +149,22 @@ Ntk_Obj_t * Ntk_ManCreateBox( Ntk_Man_t * p, int nFanins, int nFanouts )
SeeAlso []
***********************************************************************/
void Ntk_ManDeleteNode( Ntk_Obj_t * pObj )
void Nwk_ManDeleteNode( Nwk_Obj_t * pObj )
{
Vec_Ptr_t * vNodes = pObj->pMan->vTemp;
Ntk_Obj_t * pTemp;
Nwk_Obj_t * pTemp;
int i;
// delete fanins and fanouts
Ntk_ObjCollectFanouts( pObj, vNodes );
Nwk_ObjCollectFanouts( pObj, vNodes );
Vec_PtrForEachEntry( vNodes, pTemp, i )
Ntk_ObjDeleteFanin( pTemp, pObj );
Ntk_ObjCollectFanins( pObj, vNodes );
Nwk_ObjDeleteFanin( pTemp, pObj );
Nwk_ObjCollectFanins( pObj, vNodes );
Vec_PtrForEachEntry( vNodes, pTemp, i )
Ntk_ObjDeleteFanin( pObj, pTemp );
Nwk_ObjDeleteFanin( pObj, pTemp );
// remove from the list of objects
Vec_PtrWriteEntry( pObj->pMan->vObjs, pObj->Id, NULL );
pObj->pMan->nObjs[pObj->Type]--;
memset( pObj, 0, sizeof(Ntk_Obj_t) );
memset( pObj, 0, sizeof(Nwk_Obj_t) );
pObj->Id = -1;
}
......@@ -198,18 +179,18 @@ void Ntk_ManDeleteNode( Ntk_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Ntk_ManDeleteNode_rec( Ntk_Obj_t * pObj )
void Nwk_ManDeleteNode_rec( Nwk_Obj_t * pObj )
{
Vec_Ptr_t * vNodes;
int i;
assert( !Ntk_ObjIsCi(pObj) );
assert( Ntk_ObjFanoutNum(pObj) == 0 );
assert( !Nwk_ObjIsCi(pObj) );
assert( Nwk_ObjFanoutNum(pObj) == 0 );
vNodes = Vec_PtrAlloc( 100 );
Ntk_ObjCollectFanins( pObj, vNodes );
Ntk_ManDeleteNode( pObj );
Nwk_ObjCollectFanins( pObj, vNodes );
Nwk_ManDeleteNode( pObj );
Vec_PtrForEachEntry( vNodes, pObj, i )
if ( Ntk_ObjIsNode(pObj) && Ntk_ObjFanoutNum(pObj) == 0 )
Ntk_ManDeleteNode_rec( pObj );
if ( Nwk_ObjIsNode(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
Nwk_ManDeleteNode_rec( pObj );
Vec_PtrFree( vNodes );
}
......
/**CFile****************************************************************
FileName [nwkSpeedup.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
Synopsis [Global delay optimization using structural choices.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkSpeedup.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk )
{
return NULL;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [nwkStrash.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Logic network representation.]
Synopsis [Performs structural hashing for the network.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkStrash.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Derives AIG from the local functions of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ManStrashNode_rec( Aig_Man_t * p, Hop_Obj_t * pObj )
{
assert( !Hop_IsComplement(pObj) );
if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
Nwk_ManStrashNode_rec( p, Hop_ObjFanin0(pObj) );
Nwk_ManStrashNode_rec( p, Hop_ObjFanin1(pObj) );
pObj->pData = Aig_And( p, (Aig_Obj_t *)Hop_ObjChild0Copy(pObj), (Aig_Obj_t *)Hop_ObjChild1Copy(pObj) );
assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
Hop_ObjSetMarkA( pObj );
}
/**Function*************************************************************
Synopsis [Derives AIG from the local functions of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Obj_t * Nwk_ManStrashNode( Aig_Man_t * p, Nwk_Obj_t * pObj )
{
Hop_Man_t * pMan = pObj->pMan->pManHop;
Hop_Obj_t * pRoot = pObj->pFunc;
Nwk_Obj_t * pFanin;
int i;
assert( Nwk_ObjIsNode(pObj) );
// check the constant case
if ( Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
return Aig_NotCond( Aig_ManConst1(p), Hop_IsComplement(pRoot) );
// set elementary variables
Nwk_ObjForEachFanin( pObj, pFanin, i )
Hop_IthVar(pMan, i)->pData = pFanin->pCopy;
// strash the AIG of this node
Nwk_ManStrashNode_rec( p, Hop_Regular(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// return the final node
return Aig_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
/**Function*************************************************************
Synopsis [Derives AIG from the logic network.]
Description [Assumes topological ordering of nodes.]
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Nwk_ManStrash( Nwk_Man_t * pNtk )
{
Aig_Man_t * pMan;
Aig_Obj_t * pObjNew;
Nwk_Obj_t * pObj;
int i, Level;
pMan = Aig_ManStart( Nwk_ManGetAigNodeNum(pNtk) );
pMan->pManTime = Tim_ManDup( pNtk->pManTime, 1 );
Tim_ManIncrementTravId( pMan->pManTime );
Nwk_ManForEachObj( pNtk, pObj, i )
{
if ( Nwk_ObjIsCi(pObj) )
{
pObjNew = Aig_ObjCreatePi(pMan);
Level = Tim_ManGetPiArrival( pMan->pManTime, pObj->PioId );
Aig_ObjSetLevel( pObjNew, Level );
}
else if ( Nwk_ObjIsCo(pObj) )
{
pObjNew = Aig_ObjCreatePo( pMan, Aig_NotCond(Nwk_ObjFanin0(pObj)->pCopy, pObj->fCompl) );
Level = Aig_ObjLevel( pObjNew );
Tim_ManSetPoArrival( pMan->pManTime, pObj->PioId, (float)Level );
}
else if ( Nwk_ObjIsNode(pObj) )
{
pObjNew = Nwk_ManStrashNode( pMan, pObj );
}
else
assert( 0 );
pObj->pCopy = pObjNew;
}
Aig_ManCleanup( pMan );
return pMan;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [ntkUtil.c]
FileName [nwkUtil.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
PackageName [Logic network representation.]
Synopsis [Various utilities.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntkUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: nwkUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -39,14 +39,14 @@
SeeAlso []
***********************************************************************/
void Ntk_ManIncrementTravId( Ntk_Man_t * pNtk )
void Nwk_ManIncrementTravId( Nwk_Man_t * pNtk )
{
Ntk_Obj_t * pObj;
Nwk_Obj_t * pObj;
int i;
if ( pNtk->nTravIds >= (1<<26)-1 )
{
pNtk->nTravIds = 0;
Ntk_ManForEachObj( pNtk, pObj, i )
Nwk_ManForEachObj( pNtk, pObj, i )
pObj->TravId = 0;
}
pNtk->nTravIds++;
......@@ -63,14 +63,14 @@ void Ntk_ManIncrementTravId( Ntk_Man_t * pNtk )
SeeAlso []
***********************************************************************/
int Ntk_ManGetFaninMax( Ntk_Man_t * pNtk )
int Nwk_ManGetFaninMax( Nwk_Man_t * pNtk )
{
Ntk_Obj_t * pNode;
Nwk_Obj_t * pNode;
int i, nFaninsMax = 0;
Ntk_ManForEachNode( pNtk, pNode, i )
Nwk_ManForEachNode( pNtk, pNode, i )
{
if ( nFaninsMax < Ntk_ObjFaninNum(pNode) )
nFaninsMax = Ntk_ObjFaninNum(pNode);
if ( nFaninsMax < Nwk_ObjFaninNum(pNode) )
nFaninsMax = Nwk_ObjFaninNum(pNode);
}
return nFaninsMax;
}
......@@ -86,12 +86,12 @@ int Ntk_ManGetFaninMax( Ntk_Man_t * pNtk )
SeeAlso []
***********************************************************************/
int Ntk_ManGetTotalFanins( Ntk_Man_t * pNtk )
int Nwk_ManGetTotalFanins( Nwk_Man_t * pNtk )
{
Ntk_Obj_t * pNode;
Nwk_Obj_t * pNode;
int i, nFanins = 0;
Ntk_ManForEachNode( pNtk, pNode, i )
nFanins += Ntk_ObjFaninNum(pNode);
Nwk_ManForEachNode( pNtk, pNode, i )
nFanins += Nwk_ObjFaninNum(pNode);
return nFanins;
}
......@@ -107,12 +107,12 @@ int Ntk_ManGetTotalFanins( Ntk_Man_t * pNtk )
SeeAlso []
***********************************************************************/
int Ntk_ManPiNum( Ntk_Man_t * pNtk )
int Nwk_ManPiNum( Nwk_Man_t * pNtk )
{
Ntk_Obj_t * pNode;
Nwk_Obj_t * pNode;
int i, Counter = 0;
Ntk_ManForEachCi( pNtk, pNode, i )
Counter += Ntk_ObjIsPi( pNode );
Nwk_ManForEachCi( pNtk, pNode, i )
Counter += Nwk_ObjIsPi( pNode );
return Counter;
}
......@@ -127,12 +127,12 @@ int Ntk_ManPiNum( Ntk_Man_t * pNtk )
SeeAlso []
***********************************************************************/
int Ntk_ManPoNum( Ntk_Man_t * pNtk )
int Nwk_ManPoNum( Nwk_Man_t * pNtk )
{
Ntk_Obj_t * pNode;
Nwk_Obj_t * pNode;
int i, Counter = 0;
Ntk_ManForEachCo( pNtk, pNode, i )
Counter += Ntk_ObjIsPo( pNode );
Nwk_ManForEachCo( pNtk, pNode, i )
Counter += Nwk_ObjIsPo( pNode );
return Counter;
}
......@@ -147,24 +147,66 @@ int Ntk_ManPoNum( Ntk_Man_t * pNtk )
SeeAlso []
***********************************************************************/
int Ntk_ManGetAigNodeNum( Ntk_Man_t * pNtk )
int Nwk_ManGetAigNodeNum( Nwk_Man_t * pNtk )
{
Ntk_Obj_t * pNode;
Nwk_Obj_t * pNode;
int i, nNodes = 0;
Ntk_ManForEachNode( pNtk, pNode, i )
Nwk_ManForEachNode( pNtk, pNode, i )
{
if ( pNode->pFunc == NULL )
{
printf( "Ntk_ManGetAigNodeNum(): Local AIG of node %d is not assigned.\n", pNode->Id );
printf( "Nwk_ManGetAigNodeNum(): Local AIG of node %d is not assigned.\n", pNode->Id );
continue;
}
if ( Ntk_ObjFaninNum(pNode) < 2 )
if ( Nwk_ObjFaninNum(pNode) < 2 )
continue;
nNodes += Hop_DagSize( pNode->pFunc );
}
return nNodes;
}
/**Function*************************************************************
Synopsis [Procedure used for sorting the nodes in increasing order of levels.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Nwk_NodeCompareLevelsIncrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 )
{
int Diff = (*pp1)->Level - (*pp2)->Level;
if ( Diff < 0 )
return -1;
if ( Diff > 0 )
return 1;
return 0;
}
/**Function*************************************************************
Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Nwk_NodeCompareLevelsDecrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 )
{
int Diff = (*pp1)->Level - (*pp2)->Level;
if ( Diff > 0 )
return -1;
if ( Diff < 0 )
return 1;
return 0;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
/**CFile****************************************************************
FileName [ntk_.c]
FileName [nwk_.c]
SystemName [ABC: Logic synthesis and verification system.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ntk_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Revision [$Id: nwk_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ntk.h"
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......
......@@ -47,6 +47,7 @@ struct Tim_Man_t_
Vec_Ptr_t * vDelayTables; // pointers to the delay tables
Mem_Flex_t * pMemObj; // memory manager for boxes
int nTravIds; // traversal ID of the manager
int fUseTravId; // enables the use of traversal ID
int nPis; // the number of PIs
int nPos; // the number of POs
Tim_Obj_t * pPis; // timing info for the PIs
......@@ -143,6 +144,7 @@ Tim_Man_t * Tim_ManStart( int nPis, int nPos )
p->pPos[i].timeArr = 0.0;
p->pPos[i].TravId = 0;
}
p->fUseTravId = 1;
return p;
}
......@@ -238,6 +240,33 @@ Tim_Man_t * Tim_ManDupUnit( Tim_Man_t * p )
/**Function*************************************************************
Synopsis [Duplicates the timing manager.]
Description [Derives the approximate timing manager with realistic delays
but without white-boxes.]
SideEffects []
SeeAlso []
***********************************************************************/
Tim_Man_t * Tim_ManDupApprox( Tim_Man_t * p )
{
Tim_Man_t * pNew;
int k;
pNew = Tim_ManStart( p->nPis, p->nPos );
for ( k = 0; k < p->nPis; k++ )
if ( p->pPis[k].iObj2Box == -1 )
pNew->pPis[k].timeArr = p->pPis[k].timeArr;
else
pNew->pPis[k].timeArr = p->pPis[k].timeReq;
for ( k = 0; k < p->nPos; k++ )
pNew->pPos[k].timeReq = p->pPos[k].timeReq;
return pNew;
}
/**Function*************************************************************
Synopsis [Stops the timing manager.]
Description []
......@@ -302,6 +331,38 @@ void Tim_ManPrint( Tim_Man_t * p )
/**Function*************************************************************
Synopsis [Disables the use of the traversal ID.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Tim_ManTravIdDisable( Tim_Man_t * p )
{
p->fUseTravId = 0;
}
/**Function*************************************************************
Synopsis [Enables the use of the traversal ID.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Tim_ManTravIdEnable( Tim_Man_t * p )
{
p->fUseTravId = 1;
}
/**Function*************************************************************
Synopsis [Sets the vector of timing tables associated with the manager.]
Description []
......@@ -459,7 +520,7 @@ void Tim_ManInitPoRequired( Tim_Man_t * p, int iPo, float Delay )
void Tim_ManSetPoArrival( Tim_Man_t * p, int iPo, float Delay )
{
assert( iPo < p->nPos );
assert( p->pPos[iPo].TravId != p->nTravIds );
assert( !p->fUseTravId || p->pPos[iPo].TravId != p->nTravIds );
p->pPos[iPo].timeArr = Delay;
p->pPos[iPo].TravId = p->nTravIds;
}
......@@ -478,7 +539,7 @@ void Tim_ManSetPoArrival( Tim_Man_t * p, int iPo, float Delay )
void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay )
{
assert( iPi < p->nPis );
assert( p->pPis[iPi].TravId != p->nTravIds );
assert( !p->fUseTravId || p->pPis[iPi].TravId != p->nTravIds );
p->pPis[iPi].timeReq = Delay;
p->pPis[iPi].TravId = p->nTravIds;
}
......@@ -497,7 +558,7 @@ void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay )
void Tim_ManSetPoRequired( Tim_Man_t * p, int iPo, float Delay )
{
assert( iPo < p->nPos );
assert( p->pPos[iPo].TravId != p->nTravIds );
assert( !p->fUseTravId || p->pPos[iPo].TravId != p->nTravIds );
p->pPos[iPo].timeReq = Delay;
p->pPos[iPo].TravId = p->nTravIds;
}
......@@ -541,7 +602,7 @@ float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi )
int i, k;
// consider the already processed PI
pObjThis = Tim_ManPi( p, iPi );
if ( pObjThis->TravId == p->nTravIds )
if ( p->fUseTravId && pObjThis->TravId == p->nTravIds )
return pObjThis->timeArr;
pObjThis->TravId = p->nTravIds;
// consider the main PI
......@@ -551,9 +612,10 @@ float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi )
// update box timing
pBox->TravId = p->nTravIds;
// get the arrival times of the inputs of the box (POs)
if ( p->fUseTravId )
Tim_ManBoxForEachInput( p, pBox, pObj, i )
if ( pObj->TravId != p->nTravIds )
printf( "Tim_ManGetPiArrival(): PO arrival times of the box are not up to date!\n" );
printf( "Tim_ManGetPiArrival(): Input arrival times of the box are not up to date!\n" );
// compute the arrival times for each output of the box (PIs)
Tim_ManBoxForEachOutput( p, pBox, pObjRes, i )
{
......@@ -586,7 +648,7 @@ float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo )
int i, k;
// consider the already processed PO
pObjThis = Tim_ManPo( p, iPo );
if ( pObjThis->TravId == p->nTravIds )
if ( p->fUseTravId && pObjThis->TravId == p->nTravIds )
return pObjThis->timeReq;
pObjThis->TravId = p->nTravIds;
// consider the main PO
......@@ -595,11 +657,12 @@ float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo )
return pObjThis->timeReq;
// update box timing
pBox->TravId = p->nTravIds;
// get the required times of the inputs of the box (POs)
// get the required times of the outputs of the box (PIs)
if ( p->fUseTravId )
Tim_ManBoxForEachOutput( p, pBox, pObj, i )
if ( pObj->TravId != p->nTravIds )
printf( "Tim_ManGetPoRequired(): PI required times of the box are not up to date!\n" );
// compute the required times for each output of the box (PIs)
printf( "Tim_ManGetPoRequired(): Output required times of the box are not up to date!\n" );
// compute the required times for each input of the box (POs)
Tim_ManBoxForEachInput( p, pBox, pObjRes, i )
{
DelayBest = AIG_INFINITY;
......
......@@ -60,8 +60,11 @@ typedef struct Tim_Man_t_ Tim_Man_t;
extern Tim_Man_t * Tim_ManStart( int nPis, int nPos );
extern Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fDiscrete );
extern Tim_Man_t * Tim_ManDupUnit( Tim_Man_t * p );
extern Tim_Man_t * Tim_ManDupApprox( Tim_Man_t * p );
extern void Tim_ManStop( Tim_Man_t * p );
extern void Tim_ManPrint( Tim_Man_t * p );
extern void Tim_ManTravIdDisable( Tim_Man_t * p );
extern void Tim_ManTravIdEnable( Tim_Man_t * p );
extern void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables );
extern void Tim_ManCreateBox( Tim_Man_t * p, int * pIns, int nIns, int * pOuts, int nOuts, float * pDelayTable );
extern void Tim_ManCreateBoxFirst( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, float * pDelayTable );
......
......@@ -67,7 +67,7 @@ void Abc_NtkDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
Synopsis [Returns the DFS ordered array of logic nodes.]
Description [Collects only the internal nodes, leaving CIs and CO.
Description [Collects only the internal nodes, leaving out CIs and CO.
However it marks with the current TravId both CIs and COs.]
SideEffects []
......@@ -749,6 +749,31 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod
return vNodes;
}
/**Function*************************************************************
Synopsis [Computes the sum total of supports of all outputs.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkSupportSum( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vSupp;
Abc_Obj_t * pObj;
int i, nTotalSupps = 0;
Abc_NtkForEachCo( pNtk, pObj, i )
{
vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
nTotalSupps += Vec_PtrSize( vSupp );
Vec_PtrFree( vSupp );
}
printf( "Total supports = %d.\n", nTotalSupps );
}
/**Function*************************************************************
......
/**CFile****************************************************************
FileName [abcAbc8.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: abcAbc8.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
#include "nwk.h"
#include "mfx.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Converts old ABC network into new ABC network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Man_t * Abc_NtkToNtkNew( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vNodes;
Nwk_Man_t * pNtkNew;
Nwk_Obj_t * pObjNew;
Abc_Obj_t * pObj, * pFanin;
int i, k;
if ( !Abc_NtkIsLogic(pNtk) )
{
fprintf( stdout, "Thsi is not a logic network.\n" );
return 0;
}
// convert into the AIG
if ( !Abc_NtkToAig(pNtk) )
{
fprintf( stdout, "Converting to AIGs has failed.\n" );
return 0;
}
assert( Abc_NtkHasAig(pNtk) );
// construct the network
pNtkNew = Nwk_ManAlloc();
pNtkNew->pName = Extra_UtilStrsav( pNtk->pName );
pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Nwk_ManCreateCi( pNtkNew, Abc_ObjFanoutNum(pObj) );
vNodes = Abc_NtkDfs( pNtk, 1 );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
pObjNew = Nwk_ManCreateNode( pNtkNew, Abc_ObjFaninNum(pObj), Abc_ObjFanoutNum(pObj) );
Abc_ObjForEachFanin( pObj, pFanin, k )
Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)pFanin->pCopy );
pObjNew->pFunc = Hop_Transfer( pNtk->pManFunc, pNtkNew->pManHop, pObj->pData, Abc_ObjFaninNum(pObj) );
pObj->pCopy = (Abc_Obj_t *)pObjNew;
}
Vec_PtrFree( vNodes );
Abc_NtkForEachCo( pNtk, pObj, i )
{
pObjNew = Nwk_ManCreateCo( pNtkNew );
Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)Abc_ObjFanin0(pObj)->pCopy );
}
// if ( !Nwk_ManCheck( pNtkNew ) )
// fprintf( stdout, "Abc_NtkToNtkNew(): Network check has failed.\n" );
return pNtkNew;
}
/**Function*************************************************************
Synopsis [Converts new ABC network into old ABC network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkFromNtkNew( Abc_Ntk_t * pNtkOld, Nwk_Man_t * pNtk )
{
Vec_Ptr_t * vNodes;
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObjNew, * pFaninNew;
Nwk_Obj_t * pObj, * pFanin;
int i, k;
// construct the network
pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_AIG, 1 );
pNtkNew->pName = Extra_UtilStrsav( pNtk->pName );
pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
Nwk_ManForEachCi( pNtk, pObj, i )
{
pObjNew = Abc_NtkCreatePi( pNtkNew );
pObj->pCopy = (Nwk_Obj_t *)pObjNew;
Abc_ObjAssignName( pObjNew, Abc_ObjName( Abc_NtkCi(pNtkOld, i) ), NULL );
}
vNodes = Nwk_ManDfs( pNtk );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
if ( !Nwk_ObjIsNode(pObj) )
continue;
pObjNew = Abc_NtkCreateNode( pNtkNew );
Nwk_ObjForEachFanin( pObj, pFanin, k )
Abc_ObjAddFanin( pObjNew, pFanin->pCopy );
pObjNew->pData = Hop_Transfer( pNtk->pManHop, pNtkNew->pManFunc, pObj->pFunc, Nwk_ObjFaninNum(pObj) );
pObj->pCopy = (Nwk_Obj_t *)pObjNew;
}
Vec_PtrFree( vNodes );
Nwk_ManForEachCo( pNtk, pObj, i )
{
pObjNew = Abc_NtkCreatePo( pNtkNew );
if ( pObj->fCompl )
pFaninNew = Abc_NtkCreateNodeInv( pNtkNew, Nwk_ObjFanin0(pObj)->pCopy );
else
pFaninNew = Nwk_ObjFanin0(pObj)->pCopy;
Abc_ObjAddFanin( pObjNew, pFaninNew );
Abc_ObjAssignName( pObjNew, Abc_ObjName( Abc_NtkCo(pNtkOld, i) ), NULL );
}
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkFromNtkNew(): Network check has failed.\n" );
return pNtkNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkNtkTest2( Abc_Ntk_t * pNtk )
{
extern void Abc_NtkSupportSum( Abc_Ntk_t * pNtk );
Abc_Ntk_t * pNtkNew;
Nwk_Man_t * pMan;
int clk;
clk = clock();
Abc_NtkSupportSum( pNtk );
PRT( "Time", clock() - clk );
pMan = Abc_NtkToNtkNew( pNtk );
clk = clock();
Nwk_ManSupportSum( pMan );
PRT( "Time", clock() - clk );
pNtkNew = Abc_NtkFromNtkNew( pNtk, pMan );
Nwk_ManFree( pMan );
return pNtkNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkNtkTest3( Abc_Ntk_t * pNtk )
{
extern void Abc_NtkSupportSum( Abc_Ntk_t * pNtk );
extern void * Abc_FrameReadLibLut();
Abc_Ntk_t * pNtkNew;
Nwk_Man_t * pMan;
int clk;
clk = clock();
printf( "%6.2f\n", Abc_NtkDelayTraceLut( pNtk, 1 ) );
PRT( "Time", clock() - clk );
pMan = Abc_NtkToNtkNew( pNtk );
clk = clock();
printf( "%6.2f\n", Nwk_ManDelayTraceLut( pMan, Abc_FrameReadLibLut() ) );
PRT( "Time", clock() - clk );
pNtkNew = Abc_NtkFromNtkNew( pNtk, pMan );
Nwk_ManFree( pMan );
return pNtkNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkNtkTest( Abc_Ntk_t * pNtk )
{
extern int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars );
Mfx_Par_t Pars, * pPars = &Pars;
Abc_Ntk_t * pNtkNew;
Nwk_Man_t * pMan;
pMan = Abc_NtkToNtkNew( pNtk );
Mfx_ParsDefault( pPars );
Mfx_Perform( pMan, pPars );
pNtkNew = Abc_NtkFromNtkNew( pNtk, pMan );
Nwk_ManFree( pMan );
return pNtkNew;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......@@ -946,7 +946,7 @@ int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fPartition, int fVe
{
pMan1 = Abc_NtkToDar( pNtk1, 0, 0 );
pMan2 = Abc_NtkToDar( pNtk2, 0, 0 );
RetValue = Fra_FraigCecPartitioned( pMan1, pMan2, fVerbose );
RetValue = Fra_FraigCecPartitioned( pMan1, pMan2, 100, fVerbose );
Aig_ManStop( pMan1 );
Aig_ManStop( pMan2 );
goto finish;
......@@ -1716,43 +1716,6 @@ Abc_Ntk_t * Abc_NtkBalanceExor( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose
}
#include "ntl.h"
/**Function*************************************************************
Synopsis [Performs targe enlargement.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkDarTestBlif( char * pFileName )
{
/*
char Buffer[1000];
Ntl_Man_t * p;
p = Ioa_ReadBlif( pFileName, 1 );
if ( p == NULL )
{
printf( "Abc_NtkDarTestBlif(): Reading BLIF has failed.\n" );
return;
}
Ntl_ManPrintStats( p );
// if ( !Ntl_ManInsertTest( p ) )
if ( !Ntl_ManInsertTestIf( p ) )
{
printf( "Abc_NtkDarTestBlif(): Tranformation of the netlist has failed.\n" );
return;
}
// sprintf( Buffer, "%s_.blif", p->pName );
sprintf( Buffer, "test_.blif", p->pName );
Ioa_WriteBlif( p, Buffer );
Ntl_ManFree( p );
*/
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
SRC += src/base/abci/abc.c \
src/base/abci/abcAbc8.c \
src/base/abci/abcAttach.c \
src/base/abci/abcAuto.c \
src/base/abci/abcBalance.c \
......
......@@ -76,7 +76,7 @@ struct Abc_Frame_t_
// new code
void * pAbc8Ntl; // the current design
void * pAbc8Ntk; // the current mapped network
void * pAbc8Nwk; // the current mapped network
void * pAbc8Aig; // the current AIG
void * pAbc8Lib; // the current LUT library
};
......
......@@ -357,6 +357,15 @@ extern float If_CutEdgeDeref( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutEdgeRef( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutEdgeDerefed( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutEdgeRefed( If_Man_t * p, If_Cut_t * pCut );
/*=== ifLib.c =============================================================*/
extern If_Lib_t * If_LutLibRead( char * FileName );
extern If_Lib_t * If_LutLibDup( If_Lib_t * p );
extern void If_LutLibFree( If_Lib_t * pLutLib );
extern void If_LutLibPrint( If_Lib_t * pLutLib );
extern int If_LutLibDelaysAreDiscrete( If_Lib_t * pLutLib );
extern If_Lib_t * If_SetSimpleLutLib( int nLutSize );
extern float If_LutLibFastestPinDelay( If_Lib_t * p );
extern float If_LutLibSlowestPinDelay( If_Lib_t * p );
/*=== ifMan.c =============================================================*/
extern If_Man_t * If_ManStart( If_Par_t * pPars );
extern void If_ManRestart( If_Man_t * p );
......
......@@ -266,6 +266,38 @@ If_Lib_t * If_SetSimpleLutLib( int nLutSize )
return If_LutLibDup(pLutLib);
}
/**Function*************************************************************
Synopsis [Gets the delay of the fastest pin.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
float If_LutLibFastestPinDelay( If_Lib_t * p )
{
return !p? 1.0 : p->pLutDelays[p->LutMax][0];
}
/**Function*************************************************************
Synopsis [Gets the delay of the slowest pin.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
float If_LutLibSlowestPinDelay( If_Lib_t * p )
{
return !p? 1.0 : (p->fVarPinDelays? p->pLutDelays[p->LutMax][p->LutMax-1]: p->pLutDelays[p->LutMax][0]);
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -66,7 +66,9 @@ struct Mfs_Par_t_
////////////////////////////////////////////////////////////////////////
/*=== mfsCore.c ==========================================================*/
extern void Abc_NtkMfsParsDefault( Mfs_Par_t * pPars );
extern int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars );
#ifdef __cplusplus
}
......
......@@ -39,6 +39,34 @@
SeeAlso []
***********************************************************************/
void Abc_NtkMfsParsDefault( Mfs_Par_t * pPars )
{
pPars->nWinTfoLevs = 2;
pPars->nFanoutsMax = 10;
pPars->nDepthMax = 20;
pPars->nDivMax = 250;
pPars->nWinSizeMax = 300;
pPars->nGrowthLevel = 0;
pPars->nBTLimit = 5000;
pPars->fResub = 1;
pPars->fArea = 0;
pPars->fMoreEffort = 0;
pPars->fSwapEdge = 0;
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_NtkMfsResub( Mfs_Man_t * p, Abc_Obj_t * pNode )
{
int clk;
......@@ -201,7 +229,7 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars )
// convert into the AIG
if ( !Abc_NtkToAig(pNtk) )
{
fprintf( stdout, "Converting to BDD has failed.\n" );
fprintf( stdout, "Converting to AIGs has failed.\n" );
return 0;
}
assert( Abc_NtkHasAig(pNtk) );
......
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