Commit d63a0cbb by Alan Mishchenko

Version abc80717

parent 05772a79
......@@ -14,7 +14,7 @@ MODULES := \
src/map/fpga src/map/mapper src/map/mio src/map/super \
src/map/if \
src/misc/extra src/misc/mvc src/misc/st src/misc/util \
src/misc/espresso src/misc/nm src/misc/vec src/misc/hash \
src/misc/nm src/misc/vec src/misc/hash \
src/misc/bzlib src/misc/zlib \
src/opt/cut src/opt/dec src/opt/fxu src/opt/rwr src/opt/mfs \
src/opt/sim src/opt/ret src/opt/res src/opt/lpk src/opt/fret \
......
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "abclib"=.\abclib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
# Microsoft Developer Studio Project File - Name="abctestlib" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=abctestlib - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "abctestlib.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "abctestlib.mak" CFG="abctestlib - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "abctestlib - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "abctestlib - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "abctestlib - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# 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 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib C:\_projects\abc\abclib\abclib_release.lib /nologo /subsystem:console /machine:I386 /out:"_TEST/abctestlib.exe"
!ELSEIF "$(CFG)" == "abctestlib - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# 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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib C:\_projects\abc\abclib\abclib_debug.lib /nologo /subsystem:console /debug /machine:I386 /out:"_TEST/abctestlib.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "abctestlib - Win32 Release"
# Name "abctestlib - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\demo.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "abctestlib"=.\abctestlib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
......@@ -505,6 +505,7 @@ extern int Aig_ManPoCleanup( Aig_Man_t * p );
extern void Aig_ManPrintStats( Aig_Man_t * p );
extern void Aig_ManReportImprovement( Aig_Man_t * p, Aig_Man_t * pNew );
extern void Aig_ManSetRegNum( Aig_Man_t * p, int nRegs );
extern void Aig_ManFlipFirstPo( Aig_Man_t * p );
/*=== aigMem.c ==========================================================*/
extern void Aig_ManStartMemory( Aig_Man_t * p );
extern void Aig_ManStopMemory( Aig_Man_t * p );
......
......@@ -433,6 +433,23 @@ void Aig_ManSetRegNum( Aig_Man_t * p, int nRegs )
p->nTruePos = Aig_ManPoNum(p) - nRegs;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Aig_ManFlipFirstPo( Aig_Man_t * p )
{
Aig_ObjChild0Flip( Aig_ManPo(p, 0) );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -238,26 +238,26 @@ void Cnf_DataPrint( Cnf_Dat_t * p, int fReadable )
SeeAlso []
***********************************************************************/
void Cnf_DataWriteIntoFile_old( Cnf_Dat_t * p, char * pFileName, int fReadable )
void Cnf_DataWriteIntoFileGz( Cnf_Dat_t * p, char * pFileName, int fReadable )
{
FILE * pFile;
gzFile pFile;
int * pLit, * pStop, i;
pFile = fopen( pFileName, "w" );
pFile = gzopen( pFileName, "wb" );
if ( pFile == NULL )
{
printf( "Cnf_WriteIntoFile(): Output file cannot be opened.\n" );
return;
}
fprintf( pFile, "c Result of efficient AIG-to-CNF conversion using package CNF\n" );
fprintf( pFile, "p cnf %d %d\n", p->nVars, p->nClauses );
gzprintf( pFile, "c Result of efficient AIG-to-CNF conversion using package CNF\n" );
gzprintf( pFile, "p cnf %d %d\n", p->nVars, p->nClauses );
for ( i = 0; i < p->nClauses; i++ )
{
for ( pLit = p->pClauses[i], pStop = p->pClauses[i+1]; pLit < pStop; pLit++ )
fprintf( pFile, "%d ", fReadable? Cnf_Lit2Var2(*pLit) : Cnf_Lit2Var(*pLit) );
fprintf( pFile, "0\n" );
gzprintf( pFile, "%d ", fReadable? Cnf_Lit2Var2(*pLit) : Cnf_Lit2Var(*pLit) );
gzprintf( pFile, "0\n" );
}
fprintf( pFile, "\n" );
fclose( pFile );
gzprintf( pFile, "\n" );
gzclose( pFile );
}
/**Function*************************************************************
......@@ -273,24 +273,29 @@ void Cnf_DataWriteIntoFile_old( Cnf_Dat_t * p, char * pFileName, int fReadable )
***********************************************************************/
void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable )
{
gzFile pFile;
FILE * pFile;
int * pLit, * pStop, i;
pFile = gzopen( pFileName, "wb" );
if ( !strncmp(pFileName+strlen(pFileName)-3,".gz",3) )
{
Cnf_DataWriteIntoFileGz( p, pFileName, fReadable );
return;
}
pFile = fopen( pFileName, "w" );
if ( pFile == NULL )
{
printf( "Cnf_WriteIntoFile(): Output file cannot be opened.\n" );
return;
}
gzprintf( pFile, "c Result of efficient AIG-to-CNF conversion using package CNF\n" );
gzprintf( pFile, "p cnf %d %d\n", p->nVars, p->nClauses );
fprintf( pFile, "c Result of efficient AIG-to-CNF conversion using package CNF\n" );
fprintf( pFile, "p cnf %d %d\n", p->nVars, p->nClauses );
for ( i = 0; i < p->nClauses; i++ )
{
for ( pLit = p->pClauses[i], pStop = p->pClauses[i+1]; pLit < pStop; pLit++ )
gzprintf( pFile, "%d ", fReadable? Cnf_Lit2Var2(*pLit) : Cnf_Lit2Var(*pLit) );
gzprintf( pFile, "0\n" );
fprintf( pFile, "%d ", fReadable? Cnf_Lit2Var2(*pLit) : Cnf_Lit2Var(*pLit) );
fprintf( pFile, "0\n" );
}
gzprintf( pFile, "\n" );
gzclose( pFile );
fprintf( pFile, "\n" );
fclose( pFile );
}
/**Function*************************************************************
......
......@@ -389,11 +389,11 @@ PRT( "Time", clock() - clkTotal );
clk = clock();
if ( pParSec->fInterpolation && RetValue == -1 && Aig_ManRegNum(pNew) > 0 && Aig_ManPoNum(pNew)-Aig_ManRegNum(pNew) == 1 )
{
extern int Saig_Interpolate( Aig_Man_t * pAig, int nConfLimit, int fRewrite, int fTransLoop, int fVerbose, int * pDepth );
extern int Saig_Interpolate( Aig_Man_t * pAig, int nConfLimit, int fRewrite, int fTransLoop, int fUsePudlak, int fVerbose, int * pDepth );
int Depth;
pNew->nTruePis = Aig_ManPiNum(pNew) - Aig_ManRegNum(pNew);
pNew->nTruePos = Aig_ManPoNum(pNew) - Aig_ManRegNum(pNew);
RetValue = Saig_Interpolate( pNew, 5000, 0, 1, pParSec->fVeryVerbose, &Depth );
RetValue = Saig_Interpolate( pNew, 5000, 0, 1, 0, pParSec->fVeryVerbose, &Depth );
if ( pParSec->fVerbose )
{
if ( RetValue == 1 )
......
......@@ -876,6 +876,8 @@ static int Ioa_ReadParseLineAttrib( Ioa_ReadMod_t * p, char * pLine )
p->pNtk->attrWhite = 0;
else if ( strcmp( pToken, "box" ) == 0 )
p->pNtk->attrBox = 1;
else if ( strcmp( pToken, "logic" ) == 0 )
p->pNtk->attrBox = 0;
else if ( strcmp( pToken, "white" ) == 0 )
p->pNtk->attrWhite = 1;
else if ( strcmp( pToken, "comb" ) == 0 )
......
......@@ -24,7 +24,7 @@
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
......@@ -86,7 +86,10 @@ struct Nwk_Obj_t_
Nwk_Man_t * pMan; // the manager
Hop_Obj_t * pFunc; // functionality
void * pCopy; // temporary pointer
void * pNext; // temporary pointer
union {
void * pNext; // temporary pointer
int iTemp; // temporary number
};
// node information
unsigned Type : 3; // object type
unsigned fInvert : 1; // complemented attribute
......
......@@ -153,7 +153,7 @@ int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
ParsBest.Nodes = ParsNew.Nodes;
ParsBest.nPis = ParsNew.nPis;
ParsBest.nPos = ParsNew.nPos;
// writ the network
// write the network
Ioa_WriteBlifLogic( pNtk, pNtl, "best.blif" );
// Nwk_ManDumpBlif( pNtk, "best_map.blif", NULL, NULL );
return 1;
......
......@@ -348,6 +348,45 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p )
/**Function*************************************************************
Synopsis [Sort pairs by the first vertex in the topological order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ManGraphSortPairs( Nwk_Grf_t * p )
{
int nSize = Vec_IntSize(p->vPairs);
int * pIdToPair, i;
// allocate storage
pIdToPair = ALLOC( int, p->nObjs+1 );
for ( i = 0; i <= p->nObjs; i++ )
pIdToPair[i] = -1;
// create mapping
for ( i = 0; i < p->vPairs->nSize; i += 2 )
{
assert( pIdToPair[ p->vPairs->pArray[i] ] == -1 );
pIdToPair[ p->vPairs->pArray[i] ] = p->vPairs->pArray[i+1];
}
// recreate pairs
Vec_IntClear( p->vPairs );
for ( i = 0; i <= p->nObjs; i++ )
if ( pIdToPair[i] >= 0 )
{
assert( i < pIdToPair[i] );
Vec_IntPush( p->vPairs, i );
Vec_IntPush( p->vPairs, pIdToPair[i] );
}
assert( nSize == Vec_IntSize(p->vPairs) );
free( pIdToPair );
}
/**Function*************************************************************
Synopsis [Updates the problem after pulling out one edge.]
Description []
......@@ -615,6 +654,7 @@ void Nwk_ManGraphSolve( Nwk_Grf_t * p )
if ( j == NWK_MAX_LIST + 1 )
break;
}
Nwk_ManGraphSortPairs( p );
}
/**Function*************************************************************
......@@ -982,6 +1022,9 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
Nwk_ManGraphReportMemoryUsage( p );
}
vResult = p->vPairs; p->vPairs = NULL;
for ( i = 0; i < vResult->nSize; i += 2 )
printf( "(%d,%d) ", vResult->pArray[i], vResult->pArray[i+1] );
printf( "\n" );
Nwk_ManGraphFree( p );
return vResult;
}
......
SRC += src/aig/nwk/nwkCheck.c \
src/aig/nwk/nwkDfs.c \
src/aig/nwk/nwkFanio.c \
src/aig/nwk/nwkMan.c \
src/aig/nwk/nwkMerge.c \
src/aig/nwk/nwkObj.c \
src/aig/nwk/nwkUtil.c
/**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 [Checking the logic network for consistency.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Nwk_ManCheck( Nwk_Man_t * p )
{
Nwk_Obj_t * pObj;
int i, k, m;
// check if the nodes have duplicated fanins
Nwk_ManForEachNode( p, pObj, i )
{
for ( k = 0; k < pObj->nFanins; k++ )
for ( m = k + 1; m < pObj->nFanins; m++ )
if ( pObj->pFanio[k] == pObj->pFanio[m] )
printf( "Node %d has duplicated fanin %d.\n", pObj->Id, pObj->pFanio[k]->Id );
}
/*
// check if all nodes are in the correct fanin/fanout relationship
Nwk_ManForEachObj( p, pObj, i )
{
Nwk_ObjForEachFanin( pObj, pNext, k )
if ( Nwk_ObjFindFanout( pNext, pObj ) == -1 )
printf( "Nwk_ManCheck(): Object %d has fanin %d which does not have a corresponding fanout.\n", pObj->Id, pNext->Id );
Nwk_ObjForEachFanout( pObj, pNext, k )
if ( Nwk_ObjFindFanin( pNext, pObj ) == -1 )
printf( "Nwk_ManCheck(): Object %d has fanout %d which does not have a corresponding fanin.\n", pObj->Id, pNext->Id );
}
*/
return 1;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [nwkFanio.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Logic network representation.]
Synopsis [Manipulation of fanins/fanouts.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkFanio.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Collects fanins of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjCollectFanins( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes )
{
Nwk_Obj_t * pFanin;
int i;
Vec_PtrClear(vNodes);
Nwk_ObjForEachFanin( pNode, pFanin, i )
Vec_PtrPush( vNodes, pFanin );
}
/**Function*************************************************************
Synopsis [Collects fanouts of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjCollectFanouts( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes )
{
Nwk_Obj_t * pFanout;
int i;
Vec_PtrClear(vNodes);
Nwk_ObjForEachFanout( pNode, pFanout, i )
Vec_PtrPush( vNodes, pFanout );
}
/**Function*************************************************************
Synopsis [Returns the number of the fanin of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Nwk_ObjFindFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
{
Nwk_Obj_t * pTemp;
int i;
Nwk_ObjForEachFanin( pObj, pTemp, i )
if ( pTemp == pFanin )
return i;
return -1;
}
/**Function*************************************************************
Synopsis [Returns the number of the fanout of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Nwk_ObjFindFanout( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanout )
{
Nwk_Obj_t * pTemp;
int i;
Nwk_ObjForEachFanout( pObj, pTemp, i )
if ( pTemp == pFanout )
return i;
return -1;
}
/**Function*************************************************************
Synopsis [Returns 1 if the node has to be reallocated.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Nwk_ObjReallocIsNeeded( Nwk_Obj_t * pObj )
{
return pObj->nFanins + pObj->nFanouts == pObj->nFanioAlloc;
}
/**Function*************************************************************
Synopsis [Reallocates the object.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static Nwk_Obj_t * Nwk_ManReallocNode( Nwk_Obj_t * pObj )
{
Nwk_Obj_t ** pFanioOld = pObj->pFanio;
assert( Nwk_ObjReallocIsNeeded(pObj) );
pObj->pFanio = (Nwk_Obj_t **)Aig_MmFlexEntryFetch( pObj->pMan->pMemObjs, 2 * pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
memmove( pObj->pFanio, pFanioOld, pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
pObj->nFanioAlloc *= 2;
pObj->pMan->nRealloced++;
return NULL;
}
/**Function*************************************************************
Synopsis [Creates fanout/fanin relationship between the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjAddFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
{
int i;
assert( pObj->pMan == pFanin->pMan );
assert( pObj->Id >= 0 && pFanin->Id >= 0 );
if ( Nwk_ObjReallocIsNeeded(pObj) )
Nwk_ManReallocNode( pObj );
if ( Nwk_ObjReallocIsNeeded(pFanin) )
Nwk_ManReallocNode( pFanin );
for ( i = pObj->nFanins + pObj->nFanouts; i > pObj->nFanins; i-- )
pObj->pFanio[i] = pObj->pFanio[i-1];
pObj->pFanio[pObj->nFanins++] = pFanin;
pFanin->pFanio[pFanin->nFanins + pFanin->nFanouts++] = pObj;
pObj->Level = AIG_MAX( pObj->Level, pFanin->Level + Nwk_ObjIsNode(pObj) );
}
/**Function*************************************************************
Synopsis [Removes fanout/fanin relationship between the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjDeleteFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
{
int i, k, Limit;
// remove pFanin from the fanin list of pObj
Limit = pObj->nFanins + pObj->nFanouts;
for ( k = i = 0; i < Limit; i++ )
if ( pObj->pFanio[i] != pFanin )
pObj->pFanio[k++] = pObj->pFanio[i];
assert( i == k + 1 ); // if it fails, likely because of duplicated fanin
pObj->nFanins--;
// remove pObj from the fanout list of pFanin
Limit = pFanin->nFanins + pFanin->nFanouts;
for ( k = i = pFanin->nFanins; i < Limit; i++ )
if ( pFanin->pFanio[i] != pObj )
pFanin->pFanio[k++] = pFanin->pFanio[i];
assert( i == k + 1 ); // if it fails, likely because of duplicated fanout
pFanin->nFanouts--;
}
/**Function*************************************************************
Synopsis [Replaces a fanin of the node.]
Description [The node is pObj. An old fanin of this node (pFaninOld) has to be
replaced by a new fanin (pFaninNew). Assumes that the node and the old fanin
are not complemented. The new fanin can be complemented. In this case, the
polarity of the new fanin will change, compared to the polarity of the old fanin.]
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjPatchFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFaninOld, Nwk_Obj_t * pFaninNew )
{
int i, k, iFanin, Limit;
assert( pFaninOld != pFaninNew );
assert( pObj != pFaninOld );
assert( pObj != pFaninNew );
assert( pObj->pMan == pFaninOld->pMan );
assert( pObj->pMan == pFaninNew->pMan );
// update the fanin
iFanin = Nwk_ObjFindFanin( pObj, pFaninOld );
if ( iFanin == -1 )
{
printf( "Nwk_ObjPatchFanin(); Error! Node %d is not among", pFaninOld->Id );
printf( " the fanins of node %d...\n", pObj->Id );
return;
}
pObj->pFanio[iFanin] = pFaninNew;
// remove pObj from the fanout list of pFaninOld
Limit = pFaninOld->nFanins + pFaninOld->nFanouts;
for ( k = i = pFaninOld->nFanins; i < Limit; i++ )
if ( pFaninOld->pFanio[i] != pObj )
pFaninOld->pFanio[k++] = pFaninOld->pFanio[i];
pFaninOld->nFanouts--;
// add pObj to the fanout list of pFaninNew
if ( Nwk_ObjReallocIsNeeded(pFaninNew) )
Nwk_ManReallocNode( pFaninNew );
pFaninNew->pFanio[pFaninNew->nFanins + pFaninNew->nFanouts++] = pObj;
}
/**Function*************************************************************
Synopsis [Transfers fanout from the old node to the new node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjTransferFanout( Nwk_Obj_t * pNodeFrom, Nwk_Obj_t * pNodeTo )
{
Vec_Ptr_t * vFanouts = pNodeFrom->pMan->vTemp;
Nwk_Obj_t * pTemp;
int nFanoutsOld, i;
assert( !Nwk_ObjIsCo(pNodeFrom) && !Nwk_ObjIsCo(pNodeTo) );
assert( pNodeFrom->pMan == pNodeTo->pMan );
assert( pNodeFrom != pNodeTo );
assert( Nwk_ObjFanoutNum(pNodeFrom) > 0 );
// get the fanouts of the old node
nFanoutsOld = Nwk_ObjFanoutNum(pNodeTo);
Nwk_ObjCollectFanouts( pNodeFrom, vFanouts );
// patch the fanin of each of them
Vec_PtrForEachEntry( vFanouts, pTemp, i )
Nwk_ObjPatchFanin( pTemp, pNodeFrom, pNodeTo );
assert( Nwk_ObjFanoutNum(pNodeFrom) == 0 );
assert( Nwk_ObjFanoutNum(pNodeTo) == nFanoutsOld + Vec_PtrSize(vFanouts) );
}
/**Function*************************************************************
Synopsis [Replaces the node by a new node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ObjReplace( Nwk_Obj_t * pNodeOld, Nwk_Obj_t * pNodeNew )
{
assert( pNodeOld->pMan == pNodeNew->pMan );
assert( pNodeOld != pNodeNew );
assert( Nwk_ObjFanoutNum(pNodeOld) > 0 );
// transfer the fanouts to the old node
Nwk_ObjTransferFanout( pNodeOld, pNodeNew );
// remove the old node
Nwk_ManDeleteNode_rec( pNodeOld );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [nwkMan.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Logic network representation.]
Synopsis [Network manager.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Allocates the manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Man_t * Nwk_ManAlloc()
{
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 = 2;
p->pMemObjs = Aig_MmFlexStart();
p->pManHop = Hop_ManStart();
return p;
}
/**Function*************************************************************
Synopsis [Deallocates the manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
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 );
if ( p->vCos ) Vec_PtrFree( p->vCos );
if ( p->vObjs ) Vec_PtrFree( p->vObjs );
if ( p->vTemp ) Vec_PtrFree( p->vTemp );
if ( p->pManTime ) Tim_ManStop( p->pManTime );
if ( p->pMemObjs ) Aig_MmFlexStop( p->pMemObjs, 0 );
if ( p->pManHop ) Hop_ManStop( p->pManHop );
free( p );
}
/**Function*************************************************************
Synopsis [Prints stats of the manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
/*
void Nwk_ManPrintLutSizes( Nwk_Man_t * p, If_Lib_t * pLutLib )
{
Nwk_Obj_t * pObj;
int i, Counters[256] = {0};
Nwk_ManForEachNode( p, pObj, i )
Counters[Nwk_ObjFaninNum(pObj)]++;
printf( "LUTs by size: " );
for ( i = 0; i <= pLutLib->LutMax; i++ )
printf( "%d:%d ", i, Counters[i] );
}
*/
/**Function*************************************************************
Synopsis [If the network is best, saves it in "best.blif" and returns 1.]
Description [If the networks are incomparable, saves the new network,
returns its parameters in the internal parameter structure, and returns 1.
If the new network is not a logic network, quits without saving and returns 0.]
SideEffects []
SeeAlso []
***********************************************************************/
int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
{
extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
extern void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vPiNames, Vec_Ptr_t * vPoNames );
static struct ParStruct {
char * pName; // name of the best saved network
int Depth; // depth of the best saved network
int Flops; // flops in the best saved network
int Nodes; // nodes in the best saved network
int nPis; // the number of primary inputs
int nPos; // the number of primary outputs
} ParsNew, ParsBest = { 0 };
// free storage for the name
if ( pNtk == NULL )
{
FREE( ParsBest.pName );
return 0;
}
// get the parameters
ParsNew.Depth = Nwk_ManLevel( pNtk );
ParsNew.Flops = Nwk_ManLatchNum( pNtk );
ParsNew.Nodes = Nwk_ManNodeNum( pNtk );
ParsNew.nPis = Nwk_ManPiNum( pNtk );
ParsNew.nPos = Nwk_ManPoNum( pNtk );
// reset the parameters if the network has the same name
if ( ParsBest.pName == NULL ||
strcmp(ParsBest.pName, pNtk->pName) ||
ParsBest.Depth > ParsNew.Depth ||
(ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops) ||
(ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes) )
{
FREE( ParsBest.pName );
ParsBest.pName = Aig_UtilStrsav( pNtk->pName );
ParsBest.Depth = ParsNew.Depth;
ParsBest.Flops = ParsNew.Flops;
ParsBest.Nodes = ParsNew.Nodes;
ParsBest.nPis = ParsNew.nPis;
ParsBest.nPos = ParsNew.nPos;
// write the network
// Ioa_WriteBlifLogic( pNtk, pNtl, "best.blif" );
// Nwk_ManDumpBlif( pNtk, "best_map.blif", NULL, NULL );
return 1;
}
return 0;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
char * Nwk_FileNameGeneric( char * FileName )
{
char * pDot, * pRes;
pRes = Aig_UtilStrsav( FileName );
if ( (pDot = strrchr( pRes, '.' )) )
*pDot = 0;
return pRes;
}
/**Function*************************************************************
Synopsis [Prints stats of the manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
/*
void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, void * pNtl )
{
extern int Ntl_ManLatchNum( void * p );
extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
if ( fSaveBest )
Nwk_ManCompareAndSaveBest( pNtk, pNtl );
if ( fDumpResult )
{
char Buffer[1000] = {0};
char * pNameGen = pNtk->pSpec? Nwk_FileNameGeneric( pNtk->pSpec ) : "nameless_";
sprintf( Buffer, "%s_dump.blif", pNameGen );
Ioa_WriteBlifLogic( pNtk, pNtl, Buffer );
// sprintf( Buffer, "%s_dump_map.blif", pNameGen );
// Nwk_ManDumpBlif( pNtk, Buffer, NULL, NULL );
if ( pNtk->pSpec ) free( pNameGen );
}
pNtk->pLutLib = pLutLib;
printf( "%-15s : ", pNtk->pName );
printf( "pi = %5d ", Nwk_ManPiNum(pNtk) );
printf( "po = %5d ", Nwk_ManPoNum(pNtk) );
printf( "ci = %5d ", Nwk_ManCiNum(pNtk) );
printf( "co = %5d ", Nwk_ManCoNum(pNtk) );
printf( "lat = %5d ", Ntl_ManLatchNum(pNtl) );
printf( "node = %5d ", Nwk_ManNodeNum(pNtk) );
printf( "edge = %5d ", Nwk_ManGetTotalFanins(pNtk) );
printf( "aig = %6d ", Nwk_ManGetAigNodeNum(pNtk) );
printf( "lev = %3d ", Nwk_ManLevel(pNtk) );
// printf( "lev2 = %3d ", Nwk_ManLevelBackup(pNtk) );
printf( "delay = %5.2f ", Nwk_ManDelayTraceLut(pNtk) );
Nwk_ManPrintLutSizes( pNtk, pLutLib );
printf( "\n" );
// Nwk_ManDelayTracePrint( pNtk, pLutLib );
fflush( stdout );
}
*/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [nwkMerge.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Logic network representation.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkMerge.h,v 1.1 2008/05/14 22:13:09 wudenni Exp $]
***********************************************************************/
#ifndef __NWK_MERGE_H__
#define __NWK_MERGE_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
#define NWK_MAX_LIST 16
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
// the LUT merging parameters
typedef struct Nwk_LMPars_t_ Nwk_LMPars_t;
struct Nwk_LMPars_t_
{
int nMaxLutSize; // the max LUT size for merging (N=5)
int nMaxSuppSize; // the max total support size after merging (S=5)
int nMaxDistance; // the max number of nodes separating LUTs
int nMaxLevelDiff; // the max difference in levels
int nMaxFanout; // the max number of fanouts to traverse
int fUseDiffSupp; // enables the use of nodes with different support
int fUseTfiTfo; // enables the use of TFO/TFO nodes as candidates
int fVeryVerbose; // enables additional verbose output
int fVerbose; // enables verbose output
};
// edge of the graph
typedef struct Nwk_Edg_t_ Nwk_Edg_t;
struct Nwk_Edg_t_
{
int iNode1; // the first node
int iNode2; // the second node
Nwk_Edg_t * pNext; // the next edge
};
// vertex of the graph
typedef struct Nwk_Vrt_t_ Nwk_Vrt_t;
struct Nwk_Vrt_t_
{
int Id; // the vertex number
int iPrev; // the previous vertex in the list
int iNext; // the next vertex in the list
int nEdges; // the number of edges
int pEdges[0]; // the array of edges
};
// the connectivity graph
typedef struct Nwk_Grf_t_ Nwk_Grf_t;
struct Nwk_Grf_t_
{
// preliminary graph representation
int nObjs; // the number of objects
int nVertsMax; // the upper bound on the number of vertices
int nEdgeHash; // an approximate number of edges
Nwk_Edg_t ** pEdgeHash; // hash table for edges
Aig_MmFixed_t * pMemEdges; // memory for edges
// graph representation
int nEdges; // the number of edges
int nVerts; // the number of vertices
Nwk_Vrt_t ** pVerts; // the array of vertices
Aig_MmFlex_t * pMemVerts; // memory for vertices
// intermediate data
int pLists1[NWK_MAX_LIST+1]; // lists of nodes with one edge
int pLists2[NWK_MAX_LIST+1]; // lists of nodes with more than one edge
// the results of matching
Vec_Int_t * vPairs; // pairs matched in the graph
// object mappings
int * pMapLut2Id; // LUT numbers into vertex IDs
int * pMapId2Lut; // vertex IDs into LUT numbers
// other things
int nMemBytes1; // memory usage in bytes
int nMemBytes2; // memory usage in bytes
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#define Nwk_GraphForEachEdge( p, pEdge, k ) \
for ( k = 0; k < p->nEdgeHash; k++ ) \
for ( pEdge = p->pEdgeHash[k]; pEdge; pEdge = pEdge->pNext )
#define Nwk_ListForEachVertex( p, List, pVrt ) \
for ( pVrt = List? p->pVerts[List] : NULL; pVrt; \
pVrt = pVrt->iNext? p->pVerts[pVrt->iNext] : NULL )
#define Nwk_VertexForEachAdjacent( p, pVrt, pNext, k ) \
for ( k = 0; (k < pVrt->nEdges) && (((pNext) = p->pVerts[pVrt->pEdges[k]]), 1); k++ )
////////////////////////////////////////////////////////////////////////
/// INLINED FUNCTIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// ITERATORS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== nwkMerge.c ==========================================================*/
extern Nwk_Grf_t * Nwk_ManGraphAlloc( int nVertsMax );
extern void Nwk_ManGraphFree( Nwk_Grf_t * p );
extern void Nwk_ManGraphReportMemoryUsage( Nwk_Grf_t * p );
extern void Nwk_ManGraphHashEdge( Nwk_Grf_t * p, int iLut1, int iLut2 );
extern void Nwk_ManGraphSolve( Nwk_Grf_t * p );
extern int Nwk_ManLutMergeGraphTest( char * pFileName );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [nwkObj.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Logic network representation.]
Synopsis [Manipulation of objects.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwkObj.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "nwk.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Creates an object.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Obj_t * Nwk_ManCreateObj( Nwk_Man_t * p, int nFanins, int nFanouts )
{
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;
pObj->nFanioAlloc = nFanins + nFanouts + p->nFanioPlus;
return pObj;
}
/**Function*************************************************************
Synopsis [Creates a primary input.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Obj_t * Nwk_ManCreateCi( Nwk_Man_t * p, int nFanouts )
{
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, 1, nFanouts );
pObj->PioId = Vec_PtrSize( p->vCis );
Vec_PtrPush( p->vCis, pObj );
pObj->Type = NWK_OBJ_CI;
p->nObjs[NWK_OBJ_CI]++;
return pObj;
}
/**Function*************************************************************
Synopsis [Creates a primary output.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Obj_t * Nwk_ManCreateCo( Nwk_Man_t * p )
{
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, 1, 1 );
pObj->PioId = Vec_PtrSize( p->vCos );
Vec_PtrPush( p->vCos, pObj );
pObj->Type = NWK_OBJ_CO;
p->nObjs[NWK_OBJ_CO]++;
return pObj;
}
/**Function*************************************************************
Synopsis [Creates a latch.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Obj_t * Nwk_ManCreateLatch( Nwk_Man_t * p )
{
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, 1, 1 );
pObj->Type = NWK_OBJ_LATCH;
p->nObjs[NWK_OBJ_LATCH]++;
return pObj;
}
/**Function*************************************************************
Synopsis [Creates a node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Nwk_Obj_t * Nwk_ManCreateNode( Nwk_Man_t * p, int nFanins, int nFanouts )
{
Nwk_Obj_t * pObj;
pObj = Nwk_ManCreateObj( p, nFanins, nFanouts );
pObj->Type = NWK_OBJ_NODE;
p->nObjs[NWK_OBJ_NODE]++;
return pObj;
}
/**Function*************************************************************
Synopsis [Deletes the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ManDeleteNode( Nwk_Obj_t * pObj )
{
Vec_Ptr_t * vNodes = pObj->pMan->vTemp;
Nwk_Obj_t * pTemp;
int i;
assert( Nwk_ObjFanoutNum(pObj) == 0 );
// delete fanins
Nwk_ObjCollectFanins( pObj, vNodes );
Vec_PtrForEachEntry( vNodes, pTemp, i )
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(Nwk_Obj_t) );
pObj->Id = -1;
}
/**Function*************************************************************
Synopsis [Deletes the node and MFFC of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nwk_ManDeleteNode_rec( Nwk_Obj_t * pObj )
{
Vec_Ptr_t * vNodes;
int i;
assert( !Nwk_ObjIsCi(pObj) );
assert( Nwk_ObjFanoutNum(pObj) == 0 );
vNodes = Vec_PtrAlloc( 100 );
Nwk_ObjCollectFanins( pObj, vNodes );
Nwk_ManDeleteNode( pObj );
Vec_PtrForEachEntry( vNodes, pObj, i )
if ( Nwk_ObjIsNode(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
Nwk_ManDeleteNode_rec( pObj );
Vec_PtrFree( vNodes );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [nwk_.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Netlist representation.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: nwk_.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 ///
////////////////////////////////////////////////////////////////////////
......@@ -85,7 +85,7 @@ extern Aig_Man_t * Saig_ManHaigRecord( Aig_Man_t * p, int nIters, int nSte
extern void Saig_ManDumpBlif( Aig_Man_t * p, char * pFileName );
extern Aig_Man_t * Saig_ManReadBlif( char * pFileName );
/*=== saigInter.c ==========================================================*/
extern int Saig_Interpolate( Aig_Man_t * pAig, int nConfLimit, int fRewrite, int fTransLoop, int fVerbose, int * pDepth );
extern int Saig_Interpolate( Aig_Man_t * pAig, int nConfLimit, int fRewrite, int fTransLoop, int fUsePudlak, int fVerbose, int * pDepth );
/*=== saigMiter.c ==========================================================*/
extern Aig_Man_t * Saig_ManCreateMiter( Aig_Man_t * p1, Aig_Man_t * p2, int Oper );
/*=== saigPhase.c ==========================================================*/
......
......@@ -297,6 +297,7 @@ void Abc_FrameClearDesign()
void Abc_Init( Abc_Frame_t * pAbc )
{
// Abc_NtkBddImplicationTest();
// Ply_LutPairTest();
Cmd_CommandAdd( pAbc, "Printing", "print_stats", Abc_CommandPrintStats, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_exdc", Abc_CommandPrintExdc, 0 );
......@@ -7072,6 +7073,9 @@ int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
printf( "This command is currently disabled.\n" );
return 0;
// set defaults
fVerbose = 0;
Extra_UtilGetoptReset();
......@@ -7098,7 +7102,7 @@ int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pErr, "SOP minimization is possible for logic networks (run \"renode\").\n" );
return 1;
}
Abc_NtkEspresso( pNtk, fVerbose );
// Abc_NtkEspresso( pNtk, fVerbose );
return 0;
usage:
......@@ -7764,6 +7768,8 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
}
*/
/*
// pNtkRes = Abc_NtkDar( pNtk );
// pNtkRes = Abc_NtkDarRetime( pNtk, nLevels, 1 );
......@@ -7776,8 +7782,10 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
*/
// Abc_NtkDarClau( pNtk, nFrames, nLevels, fBmc, fVerbose, fVeryVerbose );
/*
if ( globalUtilOptind != 1 )
......@@ -15337,9 +15345,10 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
int nBTLimit;
int fRewrite;
int fTransLoop;
int fUsePudlak;
int fVerbose;
extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fRewrite, int fTransLoop, int fVerbose );
extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fRewrite, int fTransLoop, int fUsePudlak, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
......@@ -15349,9 +15358,10 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
nBTLimit = 20000;
fRewrite = 0;
fTransLoop = 1;
fUsePudlak = 0;
fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Crtvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Crtpvh" ) ) != EOF )
{
switch ( c )
{
......@@ -15372,6 +15382,9 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
case 't':
fTransLoop ^= 1;
break;
case 'p':
fUsePudlak ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
......@@ -15401,15 +15414,16 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( stdout, "Currently only works for single-output miters (run \"orpos\").\n" );
return 0;
}
Abc_NtkDarBmcInter( pNtk, nBTLimit, fRewrite, fTransLoop, fVerbose );
Abc_NtkDarBmcInter( pNtk, nBTLimit, fRewrite, fTransLoop, fUsePudlak, fVerbose );
return 0;
usage:
fprintf( pErr, "usage: int [-C num] [-rtvh]\n" );
fprintf( pErr, "usage: int [-C num] [-rtpvh]\n" );
fprintf( pErr, "\t uses interpolation to prove the property\n" );
fprintf( pErr, "\t-C num : the limit on conflicts for one SAT run [default = %d]\n", nBTLimit );
fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
fprintf( pErr, "\t-t : toggle adding transition into the init state [default = %s]\n", fTransLoop? "yes": "no" );
fprintf( pErr, "\t-p : toggle using original Pudlak's interpolation procedure [default = %s]\n", fUsePudlak? "yes": "no" );
fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
......
......@@ -1270,7 +1270,7 @@ PRT( "Time", clock() - clk );
SeeAlso []
***********************************************************************/
int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fRewrite, int fTransLoop, int fVerbose )
int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fRewrite, int fTransLoop, int fUsePudlak, int fVerbose )
{
Aig_Man_t * pMan;
int RetValue, Depth, clk = clock();
......@@ -1282,7 +1282,7 @@ int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fRewrite, int fTra
return -1;
}
assert( pMan->nRegs > 0 );
RetValue = Saig_Interpolate( pMan, nConfLimit, fRewrite, fTransLoop, fVerbose, &Depth );
RetValue = Saig_Interpolate( pMan, nConfLimit, fRewrite, fTransLoop, fUsePudlak, fVerbose, &Depth );
if ( RetValue == 1 )
printf( "Property proved. " );
else if ( RetValue == 0 )
......@@ -2148,12 +2148,12 @@ Abc_Ntk_t * Abc_NtkDarCleanupAig( Abc_Ntk_t * pNtk, int fCleanupPis, int fCleanu
***********************************************************************/
void Abc_NtkDarReach( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fPartition, int fReorder, int fVerbose )
{
extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fVerbose );
extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fVerbose, int fSilent );
Aig_Man_t * pMan;
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
return;
Aig_ManVerifyUsingBdds( pMan, nBddMax, nIterMax, fPartition, fReorder, fVerbose );
Aig_ManVerifyUsingBdds( pMan, nBddMax, nIterMax, fPartition, fReorder, fVerbose, 0 );
Aig_ManStop( pMan );
}
......
......@@ -14,7 +14,6 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcDelay.c \
src/base/abci/abcDress.c \
src/base/abci/abcDsd.c \
src/base/abci/abcEspresso.c \
src/base/abci/abcExtract.c \
src/base/abci/abcFpga.c \
src/base/abci/abcFpgaFast.c \
......
......@@ -275,10 +275,16 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, " Level%d;\n", Level );
Vec_PtrForEachEntry( vNodes, pNode, i )
{
int SuppSize;
Vec_Ptr_t * vSupp;
if ( (int)pNode->Level != Level )
continue;
if ( Abc_ObjFaninNum(pNode) == 0 )
continue;
vSupp = Abc_NtkNodeSupport( pNtk, &pNode, 1 );
SuppSize = Vec_PtrSize( vSupp );
Vec_PtrFree( vSupp );
// fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
if ( Abc_NtkIsStrash(pNtk) )
pSopString = "";
......@@ -288,7 +294,10 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
else
pSopString = Abc_NtkPrintSop(pNode->pData);
fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
// fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id,
SuppSize,
pSopString );
fprintf( pFile, ", shape = ellipse" );
if ( pNode->fMarkB )
......
......@@ -56,8 +56,10 @@ int main( int argc, char * argv[] )
// added to detect memory leaks:
#ifdef _DEBUG
#ifdef ABC_CHECK_LEAKS
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
#endif
// Npn_Experiment();
// Npn_Generate();
......@@ -255,8 +257,10 @@ void Abc_Start()
Abc_Frame_t * pAbc;
// added to detect memory leaks:
#ifdef _DEBUG
#ifdef ABC_CHECK_LEAKS
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
#endif
// start the glocal frame
pAbc = Abc_FrameGetGlobalFrame();
// source the resource file
......
......@@ -40,10 +40,6 @@ typedef struct Abc_Frame_t_ Abc_Frame_t;
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
// this include should be the first one in the list
// it is used to catch memory leaks on Windows
#include "leaks.h"
// data structure packages
#include "extra.h"
#include "vec.h"
......
......@@ -114,8 +114,8 @@ Abc_Frame_t * Abc_FrameAllocate()
// networks to be used by choice
p->vStore = Vec_PtrAlloc( 16 );
// initialize decomposition manager
define_cube_size(20);
set_espresso_flags();
// define_cube_size(20);
// set_espresso_flags();
// initialize the trace manager
// Abc_HManStart();
return p;
......@@ -139,7 +139,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p )
extern void undefine_cube_size();
// extern void Ivy_TruthManStop();
// Abc_HManStop();
undefine_cube_size();
// undefine_cube_size();
Rwt_ManGlobalStop();
// Ivy_TruthManStop();
if ( p->pLibVer ) Abc_LibFree( p->pLibVer, NULL );
......
......@@ -23,7 +23,6 @@
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
//#include "leaks.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -23,7 +23,6 @@
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
//#include "leaks.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -43,7 +43,9 @@ extern "C" {
// this include should be the first one in the list
// it is used to catch memory leaks on Windows
#ifdef ABC_CHECK_LEAKS
#include "leaks.h"
#endif
#include <stdio.h>
#include <stdlib.h>
......
......@@ -50,7 +50,9 @@ typedef long long sint64;
// this include should be the first one in the list
// it is used to catch memory leaks on Windows
#ifdef ABC_CHECK_LEAKS
#include "leaks.h"
#endif
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
......
SRC += src/sat/bsat/satMem.c \
src/sat/bsat/satInter.c \
src/sat/bsat/satInterA.c \
src/sat/bsat/satInterB.c \
src/sat/bsat/satInterP.c \
src/sat/bsat/satSolver.c \
src/sat/bsat/satStore.c \
......
......@@ -965,6 +965,51 @@ p->timeTotal += clock() - clkTotal;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Inta_ManDeriveClauses( Inta_Man_t * pMan, Sto_Man_t * pCnf, int fClausesA )
{
Aig_Man_t * p;
Aig_Obj_t * pMiter, * pSum, * pLit;
Sto_Cls_t * pClause;
int Var, VarAB, v;
p = Aig_ManStart( 10000 );
pMiter = Aig_ManConst1(p);
Sto_ManForEachClauseRoot( pCnf, pClause )
{
if ( fClausesA ^ pClause->fA ) // clause of B
continue;
// clause of A
pSum = Aig_ManConst0(p);
for ( v = 0; v < (int)pClause->nLits; v++ )
{
Var = lit_var(pClause->pLits[v]);
if ( pMan->pVarTypes[Var] < 0 ) // global var
{
VarAB = -pMan->pVarTypes[Var]-1;
assert( VarAB >= 0 && VarAB < Vec_IntSize(pMan->vVarsAB) );
pLit = Aig_NotCond( Aig_IthVar(p, VarAB), lit_sign(pClause->pLits[v]) );
}
else
pLit = Aig_NotCond( Aig_IthVar(p, Vec_IntSize(pMan->vVarsAB)+1+Var), lit_sign(pClause->pLits[v]) );
pSum = Aig_Or( p, pSum, pLit );
}
pMiter = Aig_And( p, pMiter, pSum );
}
Aig_ObjCreatePo( p, pMiter );
return p;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -23,7 +23,6 @@
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
//#include "leaks.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -135,6 +135,12 @@ extern Inta_Man_t * Inta_ManAlloc();
extern void Inta_ManFree( Inta_Man_t * p );
extern void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose );
/*=== satInterB.c ==========================================================*/
typedef struct Intb_Man_t_ Intb_Man_t;
extern Intb_Man_t * Intb_ManAlloc();
extern void Intb_ManFree( Intb_Man_t * p );
extern void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose );
/*=== satInterP.c ==========================================================*/
typedef struct Intp_Man_t_ Intp_Man_t;
extern Intp_Man_t * Intp_ManAlloc();
......
......@@ -23,7 +23,6 @@
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
//#include "leaks.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -25,7 +25,6 @@
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
//#include "leaks.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
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