Commit ab7cb9c6 by Alan Mishchenko

Version abc50831

parent 2b85f5ba
...@@ -237,6 +237,10 @@ SOURCE=.\src\base\abc\abcSweep.c ...@@ -237,6 +237,10 @@ SOURCE=.\src\base\abc\abcSweep.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\abc\abcSymm.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abc\abcTiming.c SOURCE=.\src\base\abc\abcTiming.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -321,6 +325,10 @@ SOURCE=.\src\base\io\ioReadEdif.c ...@@ -321,6 +325,10 @@ SOURCE=.\src\base\io\ioReadEdif.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\io\ioReadEqn.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioReadPla.c SOURCE=.\src\base\io\ioReadPla.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -345,6 +353,18 @@ SOURCE=.\src\base\io\ioWriteCnf.c ...@@ -345,6 +353,18 @@ SOURCE=.\src\base\io\ioWriteCnf.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\io\ioWriteDot.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioWriteEqn.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioWriteGml.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioWritePla.c SOURCE=.\src\base\io\ioWritePla.c
# End Source File # End Source File
# End Group # End Group
...@@ -1413,7 +1433,11 @@ SOURCE=.\src\misc\extra\extra.h ...@@ -1413,7 +1433,11 @@ SOURCE=.\src\misc\extra\extra.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\misc\extra\extraUtilBdd.c SOURCE=.\src\misc\extra\extraBddMisc.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddSymm.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
No preview for this file type
...@@ -11,6 +11,7 @@ alias pl print_level ...@@ -11,6 +11,7 @@ alias pl print_level
alias pio print_io alias pio print_io
alias ps print_stats alias ps print_stats
alias psu print_supp alias psu print_supp
alias psy print_symm
alias q quit alias q quit
alias r read alias r read
alias rl read_blif alias rl read_blif
...@@ -32,7 +33,7 @@ alias wl write_blif ...@@ -32,7 +33,7 @@ alias wl write_blif
alias wp write_pla alias wp write_pla
alias cnf "st; renode -c; write_cnf" alias cnf "st; renode -c; write_cnf"
alias prove "st; renode -c; sat" alias prove "st; renode -c; sat"
alias opt "b; renode; b; ps" alias opt "b; renode; b"
alias share "b; renode -m; fx; b; ps" alias share "b; renode -m; fx; b"
alias resyn "b; rw; rf; b; rwz; rfz; b; ps" alias resyn "b; rw; rf; b; rw; rwz; b; rfz; rwz; b"
...@@ -51,7 +51,7 @@ typedef enum { ...@@ -51,7 +51,7 @@ typedef enum {
ABC_TYPE_OTHER // 5: unused ABC_TYPE_OTHER // 5: unused
} Abc_NtkType_t; } Abc_NtkType_t;
// functionality types // network functionality
typedef enum { typedef enum {
ABC_FUNC_NONE, // 0: unknown ABC_FUNC_NONE, // 0: unknown
ABC_FUNC_SOP, // 1: sum-of-products ABC_FUNC_SOP, // 1: sum-of-products
...@@ -155,6 +155,9 @@ struct Abc_Ntk_t_ ...@@ -155,6 +155,9 @@ struct Abc_Ntk_t_
int nPos; // the number of primary outputs int nPos; // the number of primary outputs
// the functionality manager // the functionality manager
void * pManFunc; // AIG manager, BDD manager, or memory manager for SOPs void * pManFunc; // AIG manager, BDD manager, or memory manager for SOPs
// the global functions (BDDs)
void * pManGlob; // the BDD manager
Vec_Ptr_t * vFuncsGlob; // the BDDs of CO functions
// the timing manager (for mapped networks) // the timing manager (for mapped networks)
Abc_ManTime_t * pManTime; // stores arrival/required times for all nodes Abc_ManTime_t * pManTime; // stores arrival/required times for all nodes
// the cut manager (for AIGs) // the cut manager (for AIGs)
...@@ -401,8 +404,11 @@ extern void Abc_AigDeleteNode( Abc_Aig_t * pMan, Abc_Obj_t * pOld ...@@ -401,8 +404,11 @@ extern void Abc_AigDeleteNode( Abc_Aig_t * pMan, Abc_Obj_t * pOld
extern bool Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode ); extern bool Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode );
extern bool Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode ); extern bool Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode );
extern void Abc_AigPrintNode( Abc_Obj_t * pNode ); extern void Abc_AigPrintNode( Abc_Obj_t * pNode );
extern bool Abc_AigNodeIsAcyclic( Abc_Obj_t * pNode, Abc_Obj_t * pRoot );
/*=== abcAttach.c ==========================================================*/ /*=== abcAttach.c ==========================================================*/
extern int Abc_NtkAttach( Abc_Ntk_t * pNtk ); extern int Abc_NtkAttach( Abc_Ntk_t * pNtk );
/*=== abcBalance.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate );
/*=== abcCheck.c ==========================================================*/ /*=== abcCheck.c ==========================================================*/
extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk ); extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk );
extern bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj ); extern bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
...@@ -410,7 +416,7 @@ extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * ...@@ -410,7 +416,7 @@ extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t *
/*=== abcCollapse.c ==========================================================*/ /*=== abcCollapse.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose ); extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose );
extern DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly ); extern DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly );
extern void Abc_NtkFreeGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ); extern void Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk );
/*=== abcCreate.c ==========================================================*/ /*=== abcCreate.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func ); extern Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func );
extern Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func ); extern Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func );
...@@ -475,6 +481,7 @@ extern char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager ...@@ -475,6 +481,7 @@ extern char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager
extern int Abc_NtkBddToSop( Abc_Ntk_t * pNtk ); extern int Abc_NtkBddToSop( Abc_Ntk_t * pNtk );
extern void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, char ** ppSop0, char ** ppSop1 ); extern void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, char ** ppSop0, char ** ppSop1 );
extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover ); extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
extern void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk );
/*=== abcLatch.c ==========================================================*/ /*=== abcLatch.c ==========================================================*/
extern bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch ); extern bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch );
extern int Abc_NtkCountSelfFeedLatches( Abc_Ntk_t * pNtk ); extern int Abc_NtkCountSelfFeedLatches( Abc_Ntk_t * pNtk );
...@@ -519,13 +526,15 @@ extern void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode ) ...@@ -519,13 +526,15 @@ extern void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode )
extern void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile ); extern void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile );
extern void Abc_NodePrintLevel( FILE * pFile, Abc_Obj_t * pNode ); extern void Abc_NodePrintLevel( FILE * pFile, Abc_Obj_t * pNode );
/*=== abcReconv.c ==========================================================*/ /*=== abcReconv.c ==========================================================*/
extern Abc_ManCut_t * Abc_NtkManCutStart( int nNodeSizeMax, int nConeSizeMax ); extern Abc_ManCut_t * Abc_NtkManCutStart( int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop );
extern void Abc_NtkManCutStop( Abc_ManCut_t * p ); extern void Abc_NtkManCutStop( Abc_ManCut_t * p );
extern Vec_Ptr_t * Abc_NtkManCutReadLeaves( Abc_ManCut_t * p ); extern Vec_Ptr_t * Abc_NtkManCutReadCutLarge( Abc_ManCut_t * p );
extern Vec_Ptr_t * Abc_NtkManCutReadVisited( Abc_ManCut_t * p );
extern Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, bool fContain ); extern Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, bool fContain );
extern void Abc_NodeConeCollect( Abc_Obj_t ** ppRoots, int nRoots, Vec_Ptr_t * vFanins, Vec_Ptr_t * vVisited, int fIncludeFanins );
extern DdNode * Abc_NodeConeBdd( DdManager * dd, DdNode ** pbVars, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, Vec_Ptr_t * vVisited ); extern DdNode * Abc_NodeConeBdd( DdManager * dd, DdNode ** pbVars, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, Vec_Ptr_t * vVisited );
extern DdNode * Abc_NodeConeDcs( DdManager * dd, DdNode ** pbVarsX, DdNode ** pbVarsY, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vRoots, Vec_Ptr_t * vVisited ); extern DdNode * Abc_NodeConeDcs( DdManager * dd, DdNode ** pbVarsX, DdNode ** pbVarsY, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vRoots, Vec_Ptr_t * vVisited );
extern void Abc_NodeCollectTfoCands( Abc_Ntk_t * pNtk, Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins, int LevelMax, Vec_Vec_t * vLevels, Vec_Ptr_t * vResult ); extern Vec_Ptr_t * Abc_NodeCollectTfoCands( Abc_ManCut_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins, int LevelMax );
/*=== abcRefs.c ==========================================================*/ /*=== abcRefs.c ==========================================================*/
extern int Abc_NodeMffcSize( Abc_Obj_t * pNode ); extern int Abc_NodeMffcSize( Abc_Obj_t * pNode );
extern int Abc_NodeMffcLabel( Abc_Obj_t * pNode ); extern int Abc_NodeMffcLabel( Abc_Obj_t * pNode );
...@@ -576,12 +585,11 @@ extern bool Abc_SopCheck( char * pSop, int nFanins ); ...@@ -576,12 +585,11 @@ extern bool Abc_SopCheck( char * pSop, int nFanins );
extern void Abc_SopWriteCnf( FILE * pFile, char * pClauses, Vec_Int_t * vVars ); extern void Abc_SopWriteCnf( FILE * pFile, char * pClauses, Vec_Int_t * vVars );
extern void Abc_SopAddCnfToSolver( solver * pSat, char * pClauses, Vec_Int_t * vVars, Vec_Int_t * vTemp ); extern void Abc_SopAddCnfToSolver( solver * pSat, char * pClauses, Vec_Int_t * vVars, Vec_Int_t * vTemp );
/*=== abcStrash.c ==========================================================*/ /*=== abcStrash.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes ); extern Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup );
extern Abc_Obj_t * Abc_NodeStrash( Abc_Aig_t * pMan, Abc_Obj_t * pNode ); extern Abc_Obj_t * Abc_NodeStrash( Abc_Aig_t * pMan, Abc_Obj_t * pNode );
extern Abc_Obj_t * Abc_NodeStrashDec( Abc_Aig_t * pMan, Vec_Ptr_t * vFanins, Vec_Int_t * vForm ); extern Abc_Obj_t * Abc_NodeStrashDec( Abc_Aig_t * pMan, Vec_Ptr_t * vFanins, Vec_Int_t * vForm );
extern int Abc_NodeStrashDecCount( Abc_Aig_t * pMan, Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins, Vec_Int_t * vForm, Vec_Int_t * vLevels, int NodeMax, int LevelMax ); extern int Abc_NodeStrashDecCount( Abc_Aig_t * pMan, Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins, Vec_Int_t * vForm, Vec_Int_t * vLevels, int NodeMax, int LevelMax );
extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ); extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
extern Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate );
/*=== abcSweep.c ==========================================================*/ /*=== abcSweep.c ==========================================================*/
extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose ); extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose );
extern int Abc_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose ); extern int Abc_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose );
...@@ -643,6 +651,7 @@ extern char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollect ...@@ -643,6 +651,7 @@ extern char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollect
extern void Abc_NtkAlphaOrderSignals( Abc_Ntk_t * pNtk, int fComb ); extern void Abc_NtkAlphaOrderSignals( Abc_Ntk_t * pNtk, int fComb );
extern void Abc_NtkShortNames( Abc_Ntk_t * pNtk ); extern void Abc_NtkShortNames( Abc_Ntk_t * pNtk );
extern Vec_Int_t * Abc_NtkFanoutCounts( Abc_Ntk_t * pNtk ); extern Vec_Int_t * Abc_NtkFanoutCounts( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_NtkCollectObjects( Abc_Ntk_t * pNtk );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -705,8 +705,10 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan ) ...@@ -705,8 +705,10 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan )
assert( iFanin == 0 || iFanin == 1 ); assert( iFanin == 0 || iFanin == 1 );
// get the new fanin // get the new fanin
pFanin1 = Abc_ObjNotCond( pNew, Abc_ObjFaninC(pFanout, iFanin) ); pFanin1 = Abc_ObjNotCond( pNew, Abc_ObjFaninC(pFanout, iFanin) );
assert( Abc_ObjRegular(pFanin1) != pFanout );
// get another fanin // get another fanin
pFanin2 = Abc_ObjChild( pFanout, iFanin ^ 1 ); pFanin2 = Abc_ObjChild( pFanout, iFanin ^ 1 );
assert( Abc_ObjRegular(pFanin2) != pFanout );
// check if the node with these fanins exists // check if the node with these fanins exists
if ( pFanoutNew = Abc_AigAndLookup( pMan, pFanin1, pFanin2 ) ) if ( pFanoutNew = Abc_AigAndLookup( pMan, pFanin1, pFanin2 ) )
{ // such node exists (it may be a constant) { // such node exists (it may be a constant)
...@@ -732,6 +734,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan ) ...@@ -732,6 +734,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan )
Abc_ObjRemoveFanins( pFanout ); Abc_ObjRemoveFanins( pFanout );
// recreate the old fanout with new fanins and add it to the table // recreate the old fanout with new fanins and add it to the table
Abc_AigAndCreateFrom( pMan, pFanin1, pFanin2, pFanout ); Abc_AigAndCreateFrom( pMan, pFanin1, pFanin2, pFanout );
assert( Abc_AigNodeIsAcyclic(pFanout, pFanout) );
// schedule the updated fanout for updating direct level // schedule the updated fanout for updating direct level
assert( pFanout->fMarkA == 0 ); assert( pFanout->fMarkA == 0 );
...@@ -876,6 +879,7 @@ void Abc_AigUpdateLevel_int( Abc_Aig_t * pMan ) ...@@ -876,6 +879,7 @@ void Abc_AigUpdateLevel_int( Abc_Aig_t * pMan )
if ( pNode == NULL ) if ( pNode == NULL )
continue; continue;
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
assert( (int)pNode->Level == i );
// clean the mark // clean the mark
assert( pNode->fMarkA == 1 ); assert( pNode->fMarkA == 1 );
pNode->fMarkA = 0; pNode->fMarkA = 0;
...@@ -931,6 +935,7 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan ) ...@@ -931,6 +935,7 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan )
if ( pNode == NULL ) if ( pNode == NULL )
continue; continue;
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
assert( Abc_NodeReadReverseLevel(pNode) == i );
// clean the mark // clean the mark
assert( pNode->fMarkB == 1 ); assert( pNode->fMarkB == 1 );
pNode->fMarkB = 0; pNode->fMarkB = 0;
...@@ -1113,6 +1118,56 @@ void Abc_AigPrintNode( Abc_Obj_t * pNode ) ...@@ -1113,6 +1118,56 @@ void Abc_AigPrintNode( Abc_Obj_t * pNode )
printf( "\n" ); printf( "\n" );
} }
/**Function*************************************************************
Synopsis [Check if the node has a combination loop of depth 1 or 2.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
bool Abc_AigNodeIsAcyclic( Abc_Obj_t * pNode, Abc_Obj_t * pRoot )
{
Abc_Obj_t * pFanin0, * pFanin1;
Abc_Obj_t * pChild00, * pChild01;
Abc_Obj_t * pChild10, * pChild11;
if ( !Abc_NodeIsAigAnd(pNode) )
return 1;
pFanin0 = Abc_ObjFanin0(pNode);
pFanin1 = Abc_ObjFanin1(pNode);
if ( pRoot == pFanin0 || pRoot == pFanin1 )
return 0;
if ( Abc_ObjIsCi(pFanin0) )
{
pChild00 = NULL;
pChild01 = NULL;
}
else
{
pChild00 = Abc_ObjFanin0(pFanin0);
pChild01 = Abc_ObjFanin1(pFanin0);
if ( pRoot == pChild00 || pRoot == pChild01 )
return 0;
}
if ( Abc_ObjIsCi(pFanin1) )
{
pChild10 = NULL;
pChild11 = NULL;
}
else
{
pChild10 = Abc_ObjFanin0(pFanin1);
pChild11 = Abc_ObjFanin1(pFanin1);
if ( pRoot == pChild10 || pRoot == pChild11 )
return 0;
}
return 1;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static DdNode * Abc_NtkGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode ); static DdNode * Abc_NtkGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode );
static Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ); static Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk );
static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc ); static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -47,26 +47,26 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -47,26 +47,26 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose )
{ {
int fCheck = 1; int fCheck = 1;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
DdManager * dd;
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
// compute the global BDDs // compute the global BDDs
dd = Abc_NtkGlobalBdds( pNtk, 0 ); if ( Abc_NtkGlobalBdds(pNtk, 0) == NULL )
if ( dd == NULL )
return NULL; return NULL;
if ( fVerbose ) if ( fVerbose )
printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) ); printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(pNtk->pManGlob) - Cudd_ReadDead(pNtk->pManGlob) );
// create the new network // create the new network
pNtkNew = Abc_NtkFromGlobalBdds( dd, pNtk ); pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
Abc_NtkFreeGlobalBdds( dd, pNtk ); Abc_NtkFreeGlobalBdds( pNtk );
if ( pNtkNew == NULL ) if ( pNtkNew == NULL )
{ {
Cudd_Quit( dd ); Cudd_Quit( pNtk->pManGlob );
pNtk->pManGlob = NULL;
return NULL; return NULL;
} }
Extra_StopManager( dd ); Extra_StopManager( pNtk->pManGlob );
pNtk->pManGlob = NULL;
// make the network minimum base // make the network minimum base
Abc_NtkMinimumBase( pNtkNew ); Abc_NtkMinimumBase( pNtkNew );
...@@ -96,12 +96,14 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly ) ...@@ -96,12 +96,14 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly )
{ {
int fReorder = 1; int fReorder = 1;
ProgressBar * pProgress; ProgressBar * pProgress;
Vec_Ptr_t * vFuncsGlob;
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
DdNode * bFunc; DdNode * bFunc;
DdManager * dd; DdManager * dd;
int i; int i;
// start the manager // start the manager
assert( pNtk->pManGlob == NULL );
dd = Cudd_Init( Abc_NtkCiNum(pNtk), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); dd = Cudd_Init( Abc_NtkCiNum(pNtk), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
if ( fReorder ) if ( fReorder )
Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT ); Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
...@@ -114,6 +116,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly ) ...@@ -114,6 +116,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly )
pNode = Abc_AigConst1( pNtk->pManFunc ); pNode = Abc_AigConst1( pNtk->pManFunc );
pNode->pCopy = (Abc_Obj_t *)dd->one; Cudd_Ref( dd->one ); pNode->pCopy = (Abc_Obj_t *)dd->one; Cudd_Ref( dd->one );
vFuncsGlob = Vec_PtrAlloc( 100 );
if ( fLatchOnly ) if ( fLatchOnly )
{ {
// construct the BDDs // construct the BDDs
...@@ -129,8 +132,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly ) ...@@ -129,8 +132,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly )
Cudd_Quit( dd ); Cudd_Quit( dd );
return NULL; return NULL;
} }
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); Cudd_Ref( bFunc );
pNode->pNext = (Abc_Obj_t *)bFunc; Cudd_Ref( bFunc ); Vec_PtrPush( vFuncsGlob, bFunc );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
} }
...@@ -149,8 +152,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly ) ...@@ -149,8 +152,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly )
Cudd_Quit( dd ); Cudd_Quit( dd );
return NULL; return NULL;
} }
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); Cudd_Ref( bFunc );
pNode->pNext = (Abc_Obj_t *)bFunc; Cudd_Ref( bFunc ); Vec_PtrPush( vFuncsGlob, bFunc );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
} }
...@@ -168,6 +171,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly ) ...@@ -168,6 +171,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly )
Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 ); Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
Cudd_AutodynDisable( dd ); Cudd_AutodynDisable( dd );
} }
pNtk->pManGlob = dd;
pNtk->vFuncsGlob = vFuncsGlob;
return dd; return dd;
} }
...@@ -223,11 +228,12 @@ DdNode * Abc_NtkGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode ) ...@@ -223,11 +228,12 @@ DdNode * Abc_NtkGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
{ {
ProgressBar * pProgress; ProgressBar * pProgress;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pNode, * pNodeNew; Abc_Obj_t * pNode, * pNodeNew;
DdManager * dd = pNtk->pManGlob;
int i; int i;
// start the new network // start the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_TYPE_LOGIC, ABC_FUNC_BDD ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_TYPE_LOGIC, ABC_FUNC_BDD );
...@@ -238,7 +244,7 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ) ...@@ -238,7 +244,7 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk )
Abc_NtkForEachCo( pNtk, pNode, i ) Abc_NtkForEachCo( pNtk, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, (DdNode *)pNode->pNext ); pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Vec_PtrEntry(pNtk->vFuncsGlob, i) );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew ); Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
...@@ -281,17 +287,16 @@ Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode ...@@ -281,17 +287,16 @@ Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_NtkFreeGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ) void Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pNode; DdNode * bFunc;
int i; int i;
Abc_NtkForEachCo( pNtk, pNode, i ) assert( pNtk->pManGlob );
{ assert( pNtk->vFuncsGlob );
if ( pNode->pNext == NULL ) Vec_PtrForEachEntry( pNtk->vFuncsGlob, bFunc, i )
continue; Cudd_RecursiveDeref( pNtk->pManGlob, bFunc );
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pNext ); Vec_PtrFree( pNtk->vFuncsGlob );
pNode->pNext = NULL; pNtk->vFuncsGlob = NULL;
}
} }
......
...@@ -818,7 +818,7 @@ Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName ) ...@@ -818,7 +818,7 @@ Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
// find the internal node // find the internal node
if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' ) if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' )
{ {
printf( "Node \"%s\" has non-standard name (expected name is \"[integer]\").\n", pName ); printf( "Name \"%s\" is not found among CIs/COs (internal name looks like this: \"[integer]\").\n", pName );
return NULL; return NULL;
} }
Num = atoi( pName + 1 ); Num = atoi( pName + 1 );
......
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static Abc_Ntk_t * Abc_NtkDsdInternal( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort ); static Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort );
static Dsd_Manager_t * Abc_NtkDsdPerform( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose );
static void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ); static void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
static Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNodeDsd, Abc_Ntk_t * pNtkNew ); static Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNodeDsd, Abc_Ntk_t * pNtkNew );
...@@ -58,25 +57,25 @@ Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool ...@@ -58,25 +57,25 @@ Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool
{ {
int fCheck = 1; int fCheck = 1;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
DdManager * dd;
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
// perform FPGA mapping // perform FPGA mapping
dd = Abc_NtkGlobalBdds( pNtk, 0 ); if ( Abc_NtkGlobalBdds(pNtk, 0) == NULL )
if ( dd == NULL )
return NULL; return NULL;
if ( fVerbose ) if ( fVerbose )
printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) ); printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(pNtk->pManGlob) - Cudd_ReadDead(pNtk->pManGlob) );
// transform the result of mapping into a BDD network // transform the result of mapping into a BDD network
pNtkNew = Abc_NtkDsdInternal( dd, pNtk, fVerbose, fPrint, fShort ); pNtkNew = Abc_NtkDsdInternal( pNtk, fVerbose, fPrint, fShort );
if ( pNtkNew == NULL ) if ( pNtkNew == NULL )
{ {
Cudd_Quit( dd ); Cudd_Quit( pNtk->pManGlob );
pNtk->pManGlob = NULL;
return NULL; return NULL;
} }
Extra_StopManager( dd ); Extra_StopManager( pNtk->pManGlob );
pNtk->pManGlob = NULL;
// make sure that everything is okay // make sure that everything is okay
if ( fCheck && !Abc_NtkCheck( pNtkNew ) ) if ( fCheck && !Abc_NtkCheck( pNtkNew ) )
...@@ -99,17 +98,33 @@ Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool ...@@ -99,17 +98,33 @@ Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkDsdInternal( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort ) Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort )
{ {
DdManager * dd = pNtk->pManGlob;
Dsd_Manager_t * pManDsd; Dsd_Manager_t * pManDsd;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
DdNode * bFunc;
char ** ppNamesCi, ** ppNamesCo; char ** ppNamesCi, ** ppNamesCo;
Abc_Obj_t * pObj;
int i;
// complement the global functions
Abc_NtkForEachCo( pNtk, pObj, i )
{
bFunc = Vec_PtrEntry(pNtk->vFuncsGlob, i);
Vec_PtrWriteEntry(pNtk->vFuncsGlob, i, Cudd_NotCond(bFunc, Abc_ObjFaninC0(pObj)) );
}
// perform the decomposition // perform the decomposition
pManDsd = Abc_NtkDsdPerform( dd, pNtk, fVerbose ); assert( Vec_PtrSize(pNtk->vFuncsGlob) == Abc_NtkCoNum(pNtk) );
Abc_NtkFreeGlobalBdds( dd, pNtk ); pManDsd = Dsd_ManagerStart( dd, Abc_NtkCiNum(pNtk), fVerbose );
Dsd_Decompose( pManDsd, (DdNode **)pNtk->vFuncsGlob->pArray, Abc_NtkCoNum(pNtk) );
Abc_NtkFreeGlobalBdds( pNtk );
if ( pManDsd == NULL ) if ( pManDsd == NULL )
{
Cudd_Quit( dd );
return NULL; return NULL;
}
// start the new network // start the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_TYPE_LOGIC, ABC_FUNC_BDD ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_TYPE_LOGIC, ABC_FUNC_BDD );
...@@ -119,6 +134,8 @@ Abc_Ntk_t * Abc_NtkDsdInternal( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose, ...@@ -119,6 +134,8 @@ Abc_Ntk_t * Abc_NtkDsdInternal( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose,
Abc_NtkDsdConstruct( pManDsd, pNtk, pNtkNew ); Abc_NtkDsdConstruct( pManDsd, pNtk, pNtkNew );
// finalize the new network // finalize the new network
Abc_NtkFinalize( pNtk, pNtkNew ); Abc_NtkFinalize( pNtk, pNtkNew );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
if ( fPrint ) if ( fPrint )
{ {
...@@ -136,39 +153,6 @@ Abc_Ntk_t * Abc_NtkDsdInternal( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose, ...@@ -136,39 +153,6 @@ Abc_Ntk_t * Abc_NtkDsdInternal( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose,
/**Function************************************************************* /**Function*************************************************************
Synopsis [Performs DSD by creating the manager and decomposing the functions.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dsd_Manager_t * Abc_NtkDsdPerform( DdManager * dd, Abc_Ntk_t * pNtk, bool fVerbose )
{
Dsd_Manager_t * pManDsd;
DdNode ** pbFuncsGlo;
Abc_Obj_t * pNode;
int i;
// collect global functions into the array
pbFuncsGlo = ALLOC( DdNode *, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
{
pbFuncsGlo[i] = Cudd_NotCond( pNode->pNext, Abc_ObjFaninC0(pNode) );
//printf( "Output %3d : Support size = %3d. Nodes = %5d.\n", i, Cudd_SupportSize(dd, pbFuncsGlo[i]), Cudd_DagSize(pbFuncsGlo[i]) );
}
// start the DSD manager and decompose global functions
pManDsd = Dsd_ManagerStart( dd, Abc_NtkCiNum(pNtk), fVerbose );
Dsd_Decompose( pManDsd, pbFuncsGlo, Abc_NtkCoNum(pNtk) );
FREE( pbFuncsGlo );
return pManDsd;
}
/**Function*************************************************************
Synopsis [Constructs the decomposed network.] Synopsis [Constructs the decomposed network.]
Description [] Description []
......
...@@ -433,7 +433,7 @@ int Abc_NtkFraigStore( Abc_Ntk_t * pNtk ) ...@@ -433,7 +433,7 @@ int Abc_NtkFraigStore( Abc_Ntk_t * pNtk )
if ( pStore == NULL ) if ( pStore == NULL )
{ {
// start the stored network // start the stored network
pStore = Abc_NtkStrash( pNtk, 0 ); pStore = Abc_NtkStrash( pNtk, 0, 0 );
if ( pStore == NULL ) if ( pStore == NULL )
{ {
printf( "Abc_NtkFraigStore: Initial strashing has failed.\n" ); printf( "Abc_NtkFraigStore: Initial strashing has failed.\n" );
......
...@@ -128,6 +128,57 @@ DdNode * Abc_ConvertSopToBdd( DdManager * dd, char * pSop, int nFanins ) ...@@ -128,6 +128,57 @@ DdNode * Abc_ConvertSopToBdd( DdManager * dd, char * pSop, int nFanins )
return bRes; return bRes;
} }
/**Function*************************************************************
Synopsis [Removes complemented SOP covers.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk )
{
DdManager * dd;
DdNode * bFunc;
Vec_Str_t * vCube;
Abc_Obj_t * pNode;
int nFaninsMax, fFound, i;
assert( Abc_NtkIsSopLogic(pNtk) );
// check if there are nodes with complemented SOPs
fFound = 0;
Abc_NtkForEachNode( pNtk, pNode, i )
if ( Abc_SopIsComplement(pNode->pData) )
{
fFound = 1;
break;
}
if ( !fFound )
return;
// start the BDD package
nFaninsMax = Abc_NtkGetFaninMax( pNtk );
if ( nFaninsMax == 0 )
printf( "Warning: The network has only constant nodes.\n" );
dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
// change the cover of negated nodes
vCube = Vec_StrAlloc( 100 );
Abc_NtkForEachNode( pNtk, pNode, i )
if ( Abc_SopIsComplement(pNode->pData) )
{
bFunc = Abc_ConvertSopToBdd( dd, pNode->pData, Abc_ObjFaninNum(pNode) ); Cudd_Ref( bFunc );
pNode->pData = Abc_ConvertBddToSop( pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), vCube, 1 );
Cudd_RecursiveDeref( dd, bFunc );
assert( !Abc_SopIsComplement(pNode->pData) );
}
Vec_StrFree( vCube );
Extra_StopManager( dd );
}
......
...@@ -55,8 +55,8 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -55,8 +55,8 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, fComb ) ) if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, fComb ) )
return NULL; return NULL;
// make sure the circuits are strashed // make sure the circuits are strashed
fRemove1 = (!Abc_NtkIsStrash(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0)); fRemove1 = (!Abc_NtkIsStrash(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0, 0));
fRemove2 = (!Abc_NtkIsStrash(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2, 0)); fRemove2 = (!Abc_NtkIsStrash(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2, 0, 0));
if ( pNtk1 && pNtk2 ) if ( pNtk1 && pNtk2 )
pTemp = Abc_NtkMiterInt( pNtk1, pNtk2, fComb ); pTemp = Abc_NtkMiterInt( pNtk1, pNtk2, fComb );
if ( fRemove1 ) Abc_NtkDelete( pNtk1 ); if ( fRemove1 ) Abc_NtkDelete( pNtk1 );
......
...@@ -44,7 +44,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -44,7 +44,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
{ {
int Num; int Num;
fprintf( pFile, "%-15s:", pNtk->pName ); fprintf( pFile, "%-13s:", pNtk->pName );
fprintf( pFile, " i/o = %4d/%4d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) ); fprintf( pFile, " i/o = %4d/%4d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
if ( !Abc_NtkIsSeq(pNtk) ) if ( !Abc_NtkIsSeq(pNtk) )
......
...@@ -96,9 +96,9 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool ...@@ -96,9 +96,9 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
// start the managers // start the managers
pManCut = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax ); pManCut = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, 1000 );
pManRef = Abc_NtkManRefStart( nNodeSizeMax, nConeSizeMax, fUseDcs, fVerbose ); pManRef = Abc_NtkManRefStart( nNodeSizeMax, nConeSizeMax, fUseDcs, fVerbose );
pManRef->vLeaves = Abc_NtkManCutReadLeaves( pManCut ); pManRef->vLeaves = Abc_NtkManCutReadCutLarge( pManCut );
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk );
// resynthesize each node once // resynthesize each node once
......
...@@ -174,6 +174,10 @@ void Abc_NodeUpdate( Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, Vec_Int_t * vForm, ...@@ -174,6 +174,10 @@ void Abc_NodeUpdate( Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, Vec_Int_t * vForm,
// create the new structure of nodes // create the new structure of nodes
assert( vForm->nSize == 1 || Vec_PtrSize(vFanins) < Vec_IntSize(vForm) ); assert( vForm->nSize == 1 || Vec_PtrSize(vFanins) < Vec_IntSize(vForm) );
pNodeNew = Abc_NodeStrashDec( pNtk->pManFunc, vFanins, vForm ); pNodeNew = Abc_NodeStrashDec( pNtk->pManFunc, vFanins, vForm );
// in some cases, the new node may have a minor redundancy
// (has to do with the precomputed subgraph library)
if ( !Abc_AigNodeIsAcyclic( Abc_ObjRegular(pNodeNew), pNode ) )
return;
// remove the old nodes // remove the old nodes
Abc_AigReplace( pNtk->pManFunc, pNode, pNodeNew ); Abc_AigReplace( pNtk->pManFunc, pNode, pNodeNew );
// compare the gains // compare the gains
......
...@@ -18,22 +18,27 @@ ...@@ -18,22 +18,27 @@
***********************************************************************/ ***********************************************************************/
#include "abc.h"
#ifdef WIN32 #ifdef WIN32
#include "process.h" #include <process.h>
#endif #endif
#include "abc.h"
#include "io.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static void Abc_ShowFile( char * FileNameDot );
static void Abc_ShowGetFileName( char * pName, char * pBuffer );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [Prints the factored form of one node.] Synopsis [Visualizes BDD of the node.]
Description [] Description []
...@@ -42,15 +47,152 @@ ...@@ -42,15 +47,152 @@
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_NodePrintBdd( Abc_Obj_t * pNode ) void Abc_NodeShowBdd( Abc_Obj_t * pNode )
{ {
FILE * pFile; FILE * pFile;
Vec_Ptr_t * vNamesIn; Vec_Ptr_t * vNamesIn;
char * FileNameIn;
char * FileNameOut;
char * FileGeneric;
char * pCur, * pNameOut;
char FileNameDot[200]; char FileNameDot[200];
char * pNameOut;
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
// create the file names
Abc_ShowGetFileName( Abc_ObjName(pNode), FileNameDot );
// check that the file can be opened
if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
{
fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
return;
}
// set the node names
vNamesIn = Abc_NodeGetFaninNames( pNode );
pNameOut = Abc_ObjName(pNode);
Cudd_DumpDot( pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
Abc_NodeFreeFaninNames( vNamesIn );
Abc_NtkCleanCopy( pNode->pNtk );
fclose( pFile );
// visualize the file
Abc_ShowFile( FileNameDot );
}
/**Function*************************************************************
Synopsis [Visualizes AIG with choices.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkShowAig( Abc_Ntk_t * pNtk )
{
FILE * pFile;
Abc_Obj_t * pNode;
Vec_Ptr_t * vNodes;
char FileNameDot[200];
int i;
assert( Abc_NtkIsStrash(pNtk) );
// create the file names
Abc_ShowGetFileName( pNtk->pName, FileNameDot );
// check that the file can be opened
if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
{
fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
return;
}
// collect all nodes in the network
vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachObj( pNtk, pNode, i )
Vec_PtrPush( vNodes, pNode );
// write the DOT file
Io_WriteDot( pNtk, vNodes, NULL, FileNameDot );
Vec_PtrFree( vNodes );
// visualize the file
Abc_ShowFile( FileNameDot );
}
/**Function*************************************************************
Synopsis [Visualizes reconvergence driven cut at the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax )
{
FILE * pFile;
char FileNameDot[200];
Abc_ManCut_t * p;
Vec_Ptr_t * vCutSmall;
Vec_Ptr_t * vCutLarge;
Vec_Ptr_t * vInside;
Vec_Ptr_t * vNodesTfo;
Abc_Obj_t * pTemp;
int i;
assert( Abc_NtkIsStrash(pNode->pNtk) );
// start the cut computation manager
p = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, ABC_INFINITY );
// get the recovergence driven cut
vCutSmall = Abc_NodeFindCut( p, pNode, 1 );
// get the containing cut
vCutLarge = Abc_NtkManCutReadCutLarge( p );
// get the array for the inside nodes
vInside = Abc_NtkManCutReadVisited( p );
// get the inside nodes of the containing cone
Abc_NodeConeCollect( &pNode, 1, vCutLarge, vInside, 1 );
// add the nodes in the TFO
vNodesTfo = Abc_NodeCollectTfoCands( p, pNode, vCutSmall, ABC_INFINITY );
Vec_PtrForEachEntry( vNodesTfo, pTemp, i )
Vec_PtrPushUnique( vInside, pTemp );
// create the file names
Abc_ShowGetFileName( Abc_ObjName(pNode), FileNameDot );
// check that the file can be opened
if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
{
fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
return;
}
// add the root node to the cone (for visualization)
Vec_PtrPush( vCutSmall, pNode );
// write the DOT file
Io_WriteDot( pNode->pNtk, vInside, vCutSmall, FileNameDot );
// stop the cut computation manager
Abc_NtkManCutStop( p );
// visualize the file
Abc_ShowFile( FileNameDot );
}
/**Function*************************************************************
Synopsis [Shows the given DOT file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_ShowFile( char * FileNameDot )
{
FILE * pFile;
char * FileGeneric;
char FileNamePs[200]; char FileNamePs[200];
char CommandDot[1000]; char CommandDot[1000];
#ifndef WIN32 #ifndef WIN32
...@@ -60,8 +202,6 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode ) ...@@ -60,8 +202,6 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode )
char * pProgGsViewName; char * pProgGsViewName;
int RetValue; int RetValue;
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
#ifdef WIN32 #ifdef WIN32
pProgDotName = "dot.exe"; pProgDotName = "dot.exe";
pProgGsViewName = NULL; pProgGsViewName = NULL;
...@@ -70,34 +210,6 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode ) ...@@ -70,34 +210,6 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode )
pProgGsViewName = "gv"; pProgGsViewName = "gv";
#endif #endif
FileNameIn = NULL;
FileNameOut = NULL;
// get the generic file name
pNode->pCopy = NULL;
FileGeneric = Abc_ObjName(pNode);
// get rid of not-alpha-numeric characters
for ( pCur = FileGeneric; *pCur; pCur++ )
if ( !((*pCur >= '0' && *pCur <= '9') || (*pCur >= 'a' && *pCur <= 'z') || (*pCur >= 'A' && *pCur <= 'Z')) )
*pCur = '_';
// create the file names
sprintf( FileNameDot, "%s.dot", FileGeneric );
sprintf( FileNamePs, "%s.ps", FileGeneric );
// write the DOT file
if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
{
fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
return;
}
// set the node names
vNamesIn = Abc_NodeGetFaninNames( pNode );
pNameOut = Abc_ObjName(pNode);
Cudd_DumpDot( pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
Abc_NodeFreeFaninNames( vNamesIn );
Abc_NtkCleanCopy( pNode->pNtk );
fclose( pFile );
// check that the input file is okay // check that the input file is okay
if ( (pFile = fopen( FileNameDot, "r" )) == NULL ) if ( (pFile = fopen( FileNameDot, "r" )) == NULL )
{ {
...@@ -106,6 +218,12 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode ) ...@@ -106,6 +218,12 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode )
} }
fclose( pFile ); fclose( pFile );
// get the generic file name
FileGeneric = Extra_FileNameGeneric( FileNameDot );
// create the PostScript file name
sprintf( FileNamePs, "%s.ps", FileGeneric );
free( FileGeneric );
// generate the DOT file // generate the DOT file
sprintf( CommandDot, "%s -Tps -o %s %s", pProgDotName, FileNamePs, FileNameDot ); sprintf( CommandDot, "%s -Tps -o %s %s", pProgDotName, FileNamePs, FileNameDot );
RetValue = system( CommandDot ); RetValue = system( CommandDot );
...@@ -146,10 +264,9 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode ) ...@@ -146,10 +264,9 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode )
#endif #endif
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis [Derives the DOT file name.]
Description [] Description []
...@@ -158,6 +275,18 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode ) ...@@ -158,6 +275,18 @@ void Abc_NodePrintBdd( Abc_Obj_t * pNode )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_ShowGetFileName( char * pName, char * pBuffer )
{
char * pCur;
// creat the file name
sprintf( pBuffer, "%s.dot", pName );
// get rid of not-alpha-numeric characters
for ( pCur = pBuffer; *pCur; pCur++ )
if ( !((*pCur >= '0' && *pCur <= '9') || (*pCur >= 'a' && *pCur <= 'z') ||
(*pCur >= 'A' && *pCur <= 'Z') || (*pCur == '.')) )
*pCur = '_';
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -49,7 +49,7 @@ extern char * Mio_GateReadSop( void * pGate ); ...@@ -49,7 +49,7 @@ extern char * Mio_GateReadSop( void * pGate );
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes ) Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup )
{ {
int fCheck = 1; int fCheck = 1;
Abc_Ntk_t * pNtkAig; Abc_Ntk_t * pNtkAig;
...@@ -68,11 +68,11 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes ) ...@@ -68,11 +68,11 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes )
// print warning about self-feed latches // print warning about self-feed latches
if ( Abc_NtkCountSelfFeedLatches(pNtkAig) ) if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
printf( "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) ); printf( "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
if ( nNodes = Abc_AigCleanup(pNtkAig->pManFunc) ) if ( fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
printf( "Cleanup has removed %d nodes.\n", nNodes ); printf( "Cleanup has removed %d nodes.\n", nNodes );
// duplicate EXDC // duplicate EXDC
if ( pNtk->pExdc ) if ( pNtk->pExdc )
pNtkAig->pExdc = Abc_NtkStrash( pNtk->pExdc, 0 ); pNtkAig->pExdc = Abc_NtkStrash( pNtk->pExdc, 0, 1 );
// make sure everything is okay // make sure everything is okay
if ( fCheck && !Abc_NtkCheck( pNtkAig ) ) if ( fCheck && !Abc_NtkCheck( pNtkAig ) )
{ {
......
...@@ -61,7 +61,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose ) ...@@ -61,7 +61,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose )
assert( !Abc_NtkIsStrash(pNtk) ); assert( !Abc_NtkIsStrash(pNtk) );
// derive the AIG // derive the AIG
pNtkAig = Abc_NtkStrash( pNtk, 0 ); pNtkAig = Abc_NtkStrash( pNtk, 0, 1 );
// perform fraiging of the AIG // perform fraiging of the AIG
Fraig_ParamsSetDefault( &Params ); Fraig_ParamsSetDefault( &Params );
pMan = Abc_NtkToFraig( pNtkAig, &Params, 0 ); pMan = Abc_NtkToFraig( pNtkAig, &Params, 0 );
......
/**CFile****************************************************************
FileName [abcSymm.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Computation of two-variable symmetries.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: abcSymm.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static void Abc_NtkSymmetriesUsingBdds( Abc_Ntk_t * pNtk, int fNaive, int fVerbose );
static void Ntk_NetworkSymmsBdd( DdManager * dd, Abc_Ntk_t * pNtk, int fNaive, int fVerbose );
static void Ntk_NetworkSymmsPrint( Abc_Ntk_t * pNtk, Extra_SymmInfo_t * pSymms );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [The top level procedure to compute symmetries.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fVerbose )
{
if ( fUseBdds || fNaive )
Abc_NtkSymmetriesUsingBdds( pNtk, fNaive, fVerbose );
else
printf( "This option is currently not implemented.\n" );
}
/**Function*************************************************************
Synopsis [Symmetry computation using BDDs (both naive and smart).]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkSymmetriesUsingBdds( Abc_Ntk_t * pNtk, int fNaive, int fVerbose )
{
DdManager * dd;
int clk, clkBdd, clkSym;
// compute the global functions
clk = clock();
dd = Abc_NtkGlobalBdds( pNtk, 0 );
Cudd_AutodynDisable( dd );
Cudd_zddVarsFromBddVars( dd, 2 );
clkBdd = clock() - clk;
// create the collapsed network
clk = clock();
Ntk_NetworkSymmsBdd( dd, pNtk, fNaive, fVerbose );
clkSym = clock() - clk;
// undo the global functions
Abc_NtkFreeGlobalBdds( pNtk );
Extra_StopManager( dd );
pNtk->pManGlob = NULL;
PRT( "Constructing BDDs", clkBdd );
PRT( "Computing symms ", clkSym );
PRT( "TOTAL ", clkBdd + clkSym );
}
/**Function*************************************************************
Synopsis [Symmetry computation using BDDs (both naive and smart).]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ntk_NetworkSymmsBdd( DdManager * dd, Abc_Ntk_t * pNtk, int fNaive, int fVerbose )
{
Extra_SymmInfo_t * pSymms;
Abc_Obj_t * pNode;
DdNode * bFunc;
int nSymms = 0;
int i;
// compute symmetry info for each PO
Abc_NtkForEachCo( pNtk, pNode, i )
{
bFunc = pNtk->vFuncsGlob->pArray[i];
if ( Cudd_IsConstant(bFunc) )
continue;
if ( fNaive )
pSymms = Extra_SymmPairsComputeNaive( dd, bFunc );
else
pSymms = Extra_SymmPairsCompute( dd, bFunc );
nSymms += pSymms->nSymms;
if ( fVerbose )
{
printf( "Output %6s (%d): ", Abc_ObjName(pNode), pSymms->nSymms );
Ntk_NetworkSymmsPrint( pNtk, pSymms );
}
//Extra_SymmPairsPrint( pSymms );
Extra_SymmPairsDissolve( pSymms );
}
printf( "The total number of symmetries is %d.\n", nSymms );
}
/**Function*************************************************************
Synopsis [Printing symmetry groups from the symmetry data structure.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ntk_NetworkSymmsPrint( Abc_Ntk_t * pNtk, Extra_SymmInfo_t * pSymms )
{
char ** pInputNames;
int * pVarTaken;
int i, k, nVars, nSize, fStart;
// get variable names
nVars = Abc_NtkCiNum(pNtk);
pInputNames = Abc_NtkCollectCioNames( pNtk, 0 );
// alloc the array of marks
pVarTaken = ALLOC( int, nVars );
memset( pVarTaken, 0, sizeof(int) * nVars );
// print the groups
fStart = 1;
nSize = pSymms->nVars;
for ( i = 0; i < nSize; i++ )
{
// skip the variable already considered
if ( pVarTaken[i] )
continue;
// find all the vars symmetric with this one
for ( k = 0; k < nSize; k++ )
{
if ( k == i )
continue;
if ( pSymms->pSymms[i][k] == 0 )
continue;
// vars i and k are symmetric
assert( pVarTaken[k] == 0 );
// there is a new symmetry pair
if ( fStart == 1 )
{ // start a new symmetry class
fStart = 0;
printf( " { %s", pInputNames[ pSymms->pVars[i] ] );
// mark the var as taken
pVarTaken[i] = 1;
}
printf( " %s", pInputNames[ pSymms->pVars[k] ] );
// mark the var as taken
pVarTaken[k] = 1;
}
if ( fStart == 0 )
{
printf( " }" );
fStart = 1;
}
}
printf( "\n" );
free( pInputNames );
free( pVarTaken );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -91,6 +91,7 @@ int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNtk, bool fVerbose ) ...@@ -91,6 +91,7 @@ int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNtk, bool fVerbose )
pNtk->pExdc = Abc_NtkConstructExdc( dd, pNtk, bUnreach ); pNtk->pExdc = Abc_NtkConstructExdc( dd, pNtk, bUnreach );
Cudd_RecursiveDeref( dd, bUnreach ); Cudd_RecursiveDeref( dd, bUnreach );
Extra_StopManager( dd ); Extra_StopManager( dd );
pNtk->pManGlob = NULL;
// make sure that everything is okay // make sure that everything is okay
if ( fCheck && !Abc_NtkCheck( pNtk->pExdc ) ) if ( fCheck && !Abc_NtkCheck( pNtk->pExdc ) )
...@@ -135,13 +136,13 @@ DdNode * Abc_NtkTransitionRelation( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo ...@@ -135,13 +136,13 @@ DdNode * Abc_NtkTransitionRelation( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachLatch( pNtk, pNode, i )
{ {
bVar = Cudd_bddIthVar( dd, Abc_NtkCiNum(pNtk) + i ); bVar = Cudd_bddIthVar( dd, Abc_NtkCiNum(pNtk) + i );
bProd = Cudd_bddXnor( dd, bVar, (DdNode *)pNode->pNext ); Cudd_Ref( bProd ); bProd = Cudd_bddXnor( dd, bVar, pNtk->vFuncsGlob->pArray[i] ); Cudd_Ref( bProd );
bRel = Cudd_bddAnd( dd, bTemp = bRel, bProd ); Cudd_Ref( bRel ); bRel = Cudd_bddAnd( dd, bTemp = bRel, bProd ); Cudd_Ref( bRel );
Cudd_RecursiveDeref( dd, bTemp ); Cudd_RecursiveDeref( dd, bTemp );
Cudd_RecursiveDeref( dd, bProd ); Cudd_RecursiveDeref( dd, bProd );
} }
// free the global BDDs // free the global BDDs
Abc_NtkFreeGlobalBdds( dd, pNtk ); Abc_NtkFreeGlobalBdds( pNtk );
// quantify the PI variables // quantify the PI variables
bInputs = Extra_bddComputeRangeCube( dd, 0, Abc_NtkPiNum(pNtk) ); Cudd_Ref( bInputs ); bInputs = Extra_bddComputeRangeCube( dd, 0, Abc_NtkPiNum(pNtk) ); Cudd_Ref( bInputs );
......
...@@ -1046,6 +1046,29 @@ Vec_Int_t * Abc_NtkFanoutCounts( Abc_Ntk_t * pNtk ) ...@@ -1046,6 +1046,29 @@ Vec_Int_t * Abc_NtkFanoutCounts( Abc_Ntk_t * pNtk )
return vFanNums; return vFanNums;
} }
/**Function*************************************************************
Synopsis [Collects all objects into one array.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Abc_NtkCollectObjects( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vNodes;
Abc_Obj_t * pNode;
int i;
vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachObj( pNtk, pNode, i )
Vec_PtrPush( vNodes, pNode );
return vNodes;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -32,6 +32,7 @@ SRC += src/base/abc/abc.c \ ...@@ -32,6 +32,7 @@ SRC += src/base/abc/abc.c \
src/base/abc/abcSop.c \ src/base/abc/abcSop.c \
src/base/abc/abcStrash.c \ src/base/abc/abcStrash.c \
src/base/abc/abcSweep.c \ src/base/abc/abcSweep.c \
src/base/abc/abcSymm.c \
src/base/abc/abcTiming.c \ src/base/abc/abcTiming.c \
src/base/abc/abcUnreach.c \ src/base/abc/abcUnreach.c \
src/base/abc/abcUtil.c \ src/base/abc/abcUtil.c \
......
...@@ -53,6 +53,8 @@ extern Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck ); ...@@ -53,6 +53,8 @@ extern Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck );
extern Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck ); extern Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck );
/*=== abcReadEdif.c ==========================================================*/ /*=== abcReadEdif.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck ); extern Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck );
/*=== abcReadEqn.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadEqn( char * pFileName, int fCheck );
/*=== abcReadVerilog.c ==========================================================*/ /*=== abcReadVerilog.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck ); extern Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck );
/*=== abcReadPla.c ==========================================================*/ /*=== abcReadPla.c ==========================================================*/
...@@ -73,6 +75,12 @@ extern void Io_WriteTimingInfo( FILE * pFile, Abc_Ntk_t * pNtk ); ...@@ -73,6 +75,12 @@ extern void Io_WriteTimingInfo( FILE * pFile, Abc_Ntk_t * pNtk );
extern int Io_WriteBench( Abc_Ntk_t * pNtk, char * FileName ); extern int Io_WriteBench( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteCnf.c ==========================================================*/ /*=== abcWriteCnf.c ==========================================================*/
extern int Io_WriteCnf( Abc_Ntk_t * pNtk, char * FileName ); extern int Io_WriteCnf( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteDot.c ==========================================================*/
extern void Io_WriteDot( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName );
/*=== abcWriteEqn.c ==========================================================*/
extern void Io_WriteEqn( Abc_Ntk_t * pNtk, char * pFileName );
/*=== abcWriteGml.c ==========================================================*/
extern void Io_WriteGml( Abc_Ntk_t * pNtk, char * pFileName );
/*=== abcWritePla.c ==========================================================*/ /*=== abcWritePla.c ==========================================================*/
extern int Io_WritePla( Abc_Ntk_t * pNtk, char * FileName ); extern int Io_WritePla( Abc_Ntk_t * pNtk, char * FileName );
......
...@@ -53,6 +53,8 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck ) ...@@ -53,6 +53,8 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck )
pNtk = Io_ReadEdif( pFileName, fCheck ); pNtk = Io_ReadEdif( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "pla" ) ) else if ( Extra_FileNameCheckExtension( pFileName, "pla" ) )
pNtk = Io_ReadPla( pFileName, fCheck ); pNtk = Io_ReadPla( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "eqn" ) )
pNtk = Io_ReadEqn( pFileName, fCheck );
else else
{ {
fprintf( stderr, "Unknown file format\n" ); fprintf( stderr, "Unknown file format\n" );
......
/**CFile****************************************************************
FileName [ioReadEqn.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedures to read equation format files.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ioReadEqn.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "io.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p );
static void Io_ReadEqnStrCompact( char * pStr );
static int Io_ReadEqnStrFind( Vec_Ptr_t * vTokens, char * pName );
static void Io_ReadEqnStrCutAt( char * pStr, char * pStop, int fUniqueOnly, Vec_Ptr_t * vTokens );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Reads the network from a BENCH file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Io_ReadEqn( char * pFileName, int fCheck )
{
Extra_FileReader_t * p;
Abc_Ntk_t * pNtk;
// start the file
p = Extra_FileReaderAlloc( pFileName, "#", ";", "=" );
if ( p == NULL )
return NULL;
// read the network
pNtk = Io_ReadEqnNetwork( p );
Extra_FileReaderFree( p );
if ( pNtk == NULL )
return NULL;
// make sure that everything is okay with the network structure
if ( fCheck && !Abc_NtkCheck( pNtk ) )
{
printf( "Io_ReadEqn: The network check has failed.\n" );
Abc_NtkDelete( pNtk );
return NULL;
}
return pNtk;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p )
{
ProgressBar * pProgress;
Vec_Ptr_t * vTokens;
Vec_Ptr_t * vCubes, * vLits, * vVars;
Abc_Ntk_t * pNtk;
Abc_Obj_t * pNode;
char * pCubesCopy, * pSopCube, * pVarName;
int iLine, iNum, i, k;
// allocate the empty network
pNtk = Abc_NtkStartRead( Extra_FileReaderGetFileName(p) );
// go through the lines of the file
vCubes = Vec_PtrAlloc( 100 );
vVars = Vec_PtrAlloc( 100 );
vLits = Vec_PtrAlloc( 100 );
pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
for ( iLine = 0; vTokens = Extra_FileReaderGetTokens(p); iLine++ )
{
Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
// check if the first token contains anything
Io_ReadEqnStrCompact( vTokens->pArray[0] );
if ( strlen(vTokens->pArray[0]) == 0 )
break;
// if the number of tokens is different from two, error
if ( vTokens->nSize != 2 )
{
printf( "%s: Wrong input file format.\n", Extra_FileReaderGetFileName(p) );
Abc_NtkDelete( pNtk );
return NULL;
}
// get the type of the line
if ( strncmp( vTokens->pArray[0], "INORDER", 7 ) == 0 )
{
Io_ReadEqnStrCutAt( vTokens->pArray[1], " \n\r\t", 0, vVars );
Vec_PtrForEachEntry( vVars, pVarName, i )
Io_ReadCreatePi( pNtk, pVarName );
}
else if ( strncmp( vTokens->pArray[0], "OUTORDER", 8 ) == 0 )
{
Io_ReadEqnStrCutAt( vTokens->pArray[1], " \n\r\t", 0, vVars );
Vec_PtrForEachEntry( vVars, pVarName, i )
Io_ReadCreatePo( pNtk, pVarName );
}
else
{
// remove spaces
pCubesCopy = vTokens->pArray[1];
Io_ReadEqnStrCompact( pCubesCopy );
// consider the case of the constant node
if ( (pCubesCopy[0] == '0' || pCubesCopy[0] == '1') && pCubesCopy[1] == 0 )
{
pNode = Io_ReadCreateNode( pNtk, vTokens->pArray[0], NULL, 0 );
if ( pCubesCopy[0] == '0' )
pNode->pData = Abc_SopCreateConst0( pNtk->pManFunc );
else
pNode->pData = Abc_SopCreateConst1( pNtk->pManFunc );
continue;
}
// determine unique variables
pCubesCopy = util_strsav( pCubesCopy );
// find the names of the fanins of this node
Io_ReadEqnStrCutAt( pCubesCopy, "!*+", 1, vVars );
// create the node
pNode = Io_ReadCreateNode( pNtk, vTokens->pArray[0], (char **)vVars->pArray, vVars->nSize );
// split the string into cubes
Io_ReadEqnStrCutAt( vTokens->pArray[1], "+", 0, vCubes );
// start the sop
pNode->pData = Abc_SopStart( pNtk->pManFunc, vCubes->nSize, vVars->nSize );
// read the cubes
i = 0;
Abc_SopForEachCube( pNode->pData, vVars->nSize, pSopCube )
{
// split this cube into lits
Io_ReadEqnStrCutAt( vCubes->pArray[i], "*", 0, vLits );
// read the literals
Vec_PtrForEachEntry( vLits, pVarName, k )
{
iNum = Io_ReadEqnStrFind( vVars, pVarName + (pVarName[0] == '!') );
assert( iNum >= 0 );
pSopCube[iNum] = '1' - (pVarName[0] == '!');
}
i++;
}
assert( i == vCubes->nSize );
// remove the cubes
free( pCubesCopy );
}
}
Extra_ProgressBarStop( pProgress );
Vec_PtrFree( vCubes );
Vec_PtrFree( vLits );
Vec_PtrFree( vVars );
Abc_NtkFinalizeRead( pNtk );
return pNtk;
}
/**Function*************************************************************
Synopsis [Compacts the string by throwing away space-like chars.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_ReadEqnStrCompact( char * pStr )
{
char * pCur, * pNew;
for ( pNew = pCur = pStr; *pCur; pCur++ )
if ( !(*pCur == ' ' || *pCur == '\n' || *pCur == '\r' || *pCur == '\t') )
*pNew++ = *pCur;
*pNew = 0;
}
/**Function*************************************************************
Synopsis [Determines unique variables in the string.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Io_ReadEqnStrFind( Vec_Ptr_t * vTokens, char * pName )
{
char * pToken;
int i;
Vec_PtrForEachEntry( vTokens, pToken, i )
if ( strcmp( pToken, pName ) == 0 )
return i;
return -1;
}
/**Function*************************************************************
Synopsis [Cuts the string into pieces using stop chars.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_ReadEqnStrCutAt( char * pStr, char * pStop, int fUniqueOnly, Vec_Ptr_t * vTokens )
{
char * pToken;
Vec_PtrClear( vTokens );
for ( pToken = strtok( pStr, pStop ); pToken; pToken = strtok( NULL, pStop ) )
if ( !fUniqueOnly || Io_ReadEqnStrFind( vTokens, pToken ) == -1 )
Vec_PtrPush( vTokens, pToken );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -107,10 +107,7 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches ) ...@@ -107,10 +107,7 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
Synopsis [Write one network.] Synopsis [Write one network.]
Description [Writes a network composed of PIs, POs, internal nodes, Description []
and latches. The following rules are used to print the names of
internal nodes:
]
SideEffects [] SideEffects []
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
PackageName [Command processing package.] PackageName [Command processing package.]
Synopsis [Procedures to CNF of the miter cone.] Synopsis [Procedures to output CNF of the miter cone.]
Author [Alan Mishchenko] Author [Alan Mishchenko]
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static void Io_WriteCnfInt( FILE * pFile, Abc_Ntk_t * pNtk );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
/**CFile****************************************************************
FileName [ioWriteEqn.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedures to write equation representation of the network.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ioWriteEqn.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "io.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static void Io_NtkWriteEqnOne( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_NtkWriteEqnPis( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_NtkWriteEqnPos( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_NtkWriteEqnNode( FILE * pFile, Abc_Obj_t * pNode );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Writes the logic network in the equation format.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_WriteEqn( Abc_Ntk_t * pNtk, char * pFileName )
{
FILE * pFile;
assert( Abc_NtkIsSopNetlist(pNtk) );
if ( Abc_NtkLatchNum(pNtk) > 0 )
printf( "Warning: only combinational portion is being written.\n" );
// start the output stream
pFile = fopen( pFileName, "w" );
if ( pFile == NULL )
{
fprintf( stdout, "Io_WriteEqn(): Cannot open the output file \"%s\".\n", pFileName );
return;
}
fprintf( pFile, "# Equations for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
// write the equations for the network
Io_NtkWriteEqnOne( pFile, pNtk );
fprintf( pFile, "\n" );
fclose( pFile );
}
/**Function*************************************************************
Synopsis [Write one network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_NtkWriteEqnOne( FILE * pFile, Abc_Ntk_t * pNtk )
{
ProgressBar * pProgress;
Abc_Obj_t * pNode;
int i;
// write the PIs
fprintf( pFile, "INORDER =" );
Io_NtkWriteEqnPis( pFile, pNtk );
fprintf( pFile, ";\n" );
// write the POs
fprintf( pFile, "OUTORDER =" );
Io_NtkWriteEqnPos( pFile, pNtk );
fprintf( pFile, ";\n" );
// write each internal node
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
Io_NtkWriteEqnNode( pFile, pNode );
}
Extra_ProgressBarStop( pProgress );
}
/**Function*************************************************************
Synopsis [Writes the primary input list.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_NtkWriteEqnPis( FILE * pFile, Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pTerm, * pNet;
int LineLength;
int AddedLength;
int NameCounter;
int i;
LineLength = 9;
NameCounter = 0;
Abc_NtkForEachCi( pNtk, pTerm, i )
{
pNet = Abc_ObjFanout0(pTerm);
// get the line length after this name is written
AddedLength = strlen(Abc_ObjName(pNet)) + 1;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender
fprintf( pFile, " \n" );
// reset the line length
LineLength = 0;
NameCounter = 0;
}
fprintf( pFile, " %s", Abc_ObjName(pNet) );
LineLength += AddedLength;
NameCounter++;
}
}
/**Function*************************************************************
Synopsis [Writes the primary input list.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_NtkWriteEqnPos( FILE * pFile, Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pTerm, * pNet;
int LineLength;
int AddedLength;
int NameCounter;
int i;
LineLength = 10;
NameCounter = 0;
Abc_NtkForEachCo( pNtk, pTerm, i )
{
pNet = Abc_ObjFanin0(pTerm);
// get the line length after this name is written
AddedLength = strlen(Abc_ObjName(pNet)) + 1;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender
fprintf( pFile, " \n" );
// reset the line length
LineLength = 0;
NameCounter = 0;
}
fprintf( pFile, " %s", Abc_ObjName(pNet) );
LineLength += AddedLength;
NameCounter++;
}
}
/**Function*************************************************************
Synopsis [Write the node into a file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_NtkWriteEqnNode( FILE * pFile, Abc_Obj_t * pNode )
{
Abc_Obj_t * pNet;
int LineLength;
int AddedLength;
int NameCounter;
char * pCube;
int Value, fFirstLit, i;
fprintf( pFile, "%s = ", Abc_ObjName(pNode) );
if ( Abc_SopIsConst0(pNode->pData) )
{
fprintf( pFile, "0;\n" );
return;
}
if ( Abc_SopIsConst1(pNode->pData) )
{
fprintf( pFile, "1;\n" );
return;
}
NameCounter = 0;
LineLength = strlen(Abc_ObjName(pNode)) + 3;
Abc_SopForEachCube( pNode->pData, Abc_ObjFaninNum(pNode), pCube )
{
if ( pCube != pNode->pData )
{
fprintf( pFile, " + " );
LineLength += 3;
}
// add the cube
fFirstLit = 1;
Abc_CubeForEachVar( pCube, Value, i )
{
if ( Value == '-' )
continue;
pNet = Abc_ObjFanin( pNode, i );
// get the line length after this name is written
AddedLength = !fFirstLit + (Value == '0') + strlen(Abc_ObjName(pNet));
if ( NameCounter && LineLength + AddedLength + 6 > IO_WRITE_LINE_LENGTH )
{ // write the line extender
fprintf( pFile, " \n " );
// reset the line length
LineLength = 0;
NameCounter = 0;
}
fprintf( pFile, "%s%s%s", (fFirstLit? "": "*"), ((Value == '0')? "!":""), Abc_ObjName(pNet) );
LineLength += AddedLength;
NameCounter++;
fFirstLit = 0;
}
}
fprintf( pFile, ";\n" );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [ioWriteGml.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedures to write the graph structure of AIG in GML.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ioWriteGml.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "io.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Writes the graph structure of AIG in GML.]
Description [Useful for graph visualization using tools such as yEd:
http://www.yworks.com/]
SideEffects []
SeeAlso []
***********************************************************************/
void Io_WriteGml( Abc_Ntk_t * pNtk, char * pFileName )
{
FILE * pFile;
Abc_Obj_t * pObj, * pFanin;
int i, k;
assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
// start the output stream
pFile = fopen( pFileName, "w" );
if ( pFile == NULL )
{
fprintf( stdout, "Io_WriteGml(): Cannot open the output file \"%s\".\n", pFileName );
return;
}
fprintf( pFile, "# GML for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
fprintf( pFile, "graph [\n" );
// output the POs
fprintf( pFile, "\n" );
Abc_NtkForEachPo( pNtk, pObj, i )
{
fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" ); // blue
fprintf( pFile, " ]\n" );
}
// output the PIs
fprintf( pFile, "\n" );
Abc_NtkForEachPi( pNtk, pObj, i )
{
fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FF00\" ]\n" ); // green
fprintf( pFile, " ]\n" );
}
// output the latches
fprintf( pFile, "\n" );
Abc_NtkForEachLatch( pNtk, pObj, i )
{
fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
fprintf( pFile, " graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" ); // red
fprintf( pFile, " ]\n" );
}
// output the nodes
fprintf( pFile, "\n" );
Abc_NtkForEachNode( pNtk, pObj, i )
{
fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
fprintf( pFile, " ]\n" );
}
// output the edges
fprintf( pFile, "\n" );
Abc_NtkForEachObj( pNtk, pObj, i )
{
Abc_ObjForEachFanin( pObj, pFanin, k )
{
fprintf( pFile, " edge [ source %5d target %5d\n", pObj->Id, pFanin->Id );
fprintf( pFile, " graphics [ type \"line\" arrow \"first\" ]\n" );
fprintf( pFile, " ]\n" );
}
}
fprintf( pFile, "]\n" );
fprintf( pFile, "\n" );
fclose( pFile );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -3,10 +3,14 @@ SRC += src/base/io/io.c \ ...@@ -3,10 +3,14 @@ SRC += src/base/io/io.c \
src/base/io/ioReadBench.c \ src/base/io/ioReadBench.c \
src/base/io/ioReadBlif.c \ src/base/io/ioReadBlif.c \
src/base/io/ioReadEdif.c \ src/base/io/ioReadEdif.c \
src/base/io/ioReadEqn.c \
src/base/io/ioReadPla.c \ src/base/io/ioReadPla.c \
src/base/io/ioReadVerilog.c \ src/base/io/ioReadVerilog.c \
src/base/io/ioUtil.c \ src/base/io/ioUtil.c \
src/base/io/ioWriteBench.c \ src/base/io/ioWriteBench.c \
src/base/io/ioWriteBlif.c \ src/base/io/ioWriteBlif.c \
src/base/io/ioWriteCnf.c \ src/base/io/ioWriteCnf.c \
src/base/io/ioWriteDot.c \
src/base/io/ioWriteEqn.c \
src/base/io/ioWriteGml.c \
src/base/io/ioWritePla.c src/base/io/ioWritePla.c
...@@ -71,7 +71,7 @@ int Fpga_Mapping( Fpga_Man_t * p ) ...@@ -71,7 +71,7 @@ int Fpga_Mapping( Fpga_Man_t * p )
return 0; return 0;
p->timeRecover = clock() - clk; p->timeRecover = clock() - clk;
} }
PRT( "Total mapping time", clock() - clkTotal ); //PRT( "Total mapping time", clock() - clkTotal );
// print the AI-graph used for mapping // print the AI-graph used for mapping
//Fpga_ManShow( p, "test" ); //Fpga_ManShow( p, "test" );
......
...@@ -117,6 +117,57 @@ extern DdNode * Extra_bddFindOneCube( DdManager * dd, DdNode * bF ); ...@@ -117,6 +117,57 @@ extern DdNode * Extra_bddFindOneCube( DdManager * dd, DdNode * bF );
extern DdNode * Extra_bddGetOneCube( DdManager * dd, DdNode * bFunc ); extern DdNode * Extra_bddGetOneCube( DdManager * dd, DdNode * bFunc );
extern DdNode * Extra_bddComputeRangeCube( DdManager * dd, int iStart, int iStop ); extern DdNode * Extra_bddComputeRangeCube( DdManager * dd, int iStart, int iStop );
/*=== extraBddSymm.c =================================================================*/
typedef struct Extra_SymmInfo_t_ Extra_SymmInfo_t;
struct Extra_SymmInfo_t_ {
int nVars; // the number of variables in the support
int nVarsMax; // the number of variables in the DD manager
int nSymms; // the number of pair-wise symmetries
int nNodes; // the number of nodes in a ZDD (if applicable)
int * pVars; // the list of all variables present in the support
char ** pSymms; // the symmetry information
};
/* computes the classical symmetry information for the function - recursive */
extern Extra_SymmInfo_t * Extra_SymmPairsCompute( DdManager * dd, DdNode * bFunc );
/* computes the classical symmetry information for the function - using naive approach */
extern Extra_SymmInfo_t * Extra_SymmPairsComputeNaive( DdManager * dd, DdNode * bFunc );
extern int Extra_bddCheckVarsSymmetricNaive( DdManager * dd, DdNode * bF, int iVar1, int iVar2 );
/* allocates the data structure */
extern Extra_SymmInfo_t * Extra_SymmPairsAllocate( int nVars );
/* deallocates the data structure */
extern void Extra_SymmPairsDissolve( Extra_SymmInfo_t * );
/* print the contents the data structure */
extern void Extra_SymmPairsPrint( Extra_SymmInfo_t * );
/* converts the ZDD into the Extra_SymmInfo_t structure */
extern Extra_SymmInfo_t * Extra_SymmPairsCreateFromZdd( DdManager * dd, DdNode * zPairs, DdNode * bVars );
/* computes the classical symmetry information as a ZDD */
extern DdNode * Extra_zddSymmPairsCompute( DdManager * dd, DdNode * bF, DdNode * bVars );
extern DdNode * extraZddSymmPairsCompute( DdManager * dd, DdNode * bF, DdNode * bVars );
/* returns a singleton-set ZDD containing all variables that are symmetric with the given one */
extern DdNode * Extra_zddGetSymmetricVars( DdManager * dd, DdNode * bF, DdNode * bG, DdNode * bVars );
extern DdNode * extraZddGetSymmetricVars( DdManager * dd, DdNode * bF, DdNode * bG, DdNode * bVars );
/* converts a set of variables into a set of singleton subsets */
extern DdNode * Extra_zddGetSingletons( DdManager * dd, DdNode * bVars );
extern DdNode * extraZddGetSingletons( DdManager * dd, DdNode * bVars );
/* filters the set of variables using the support of the function */
extern DdNode * Extra_bddReduceVarSet( DdManager * dd, DdNode * bVars, DdNode * bF );
extern DdNode * extraBddReduceVarSet( DdManager * dd, DdNode * bVars, DdNode * bF );
/* checks the possibility that the two vars are symmetric */
extern int Extra_bddCheckVarsSymmetric( DdManager * dd, DdNode * bF, int iVar1, int iVar2 );
extern DdNode * extraBddCheckVarsSymmetric( DdManager * dd, DdNode * bF, DdNode * bVars );
/* build the set of all tuples of K variables out of N from the BDD cube */
extern DdNode * Extra_zddTuplesFromBdd( DdManager * dd, int K, DdNode * bVarsN );
extern DdNode * extraZddTuplesFromBdd( DdManager * dd, DdNode * bVarsK, DdNode * bVarsN );
/* selects one subset from a ZDD representing the set of subsets */
extern DdNode * Extra_zddSelectOneSubset( DdManager * dd, DdNode * zS );
extern DdNode * extraZddSelectOneSubset( DdManager * dd, DdNode * zS );
/*=== extraUtilBitMatrix.c ================================================================*/ /*=== extraUtilBitMatrix.c ================================================================*/
typedef struct Extra_BitMat_t_ Extra_BitMat_t; typedef struct Extra_BitMat_t_ Extra_BitMat_t;
......
/**CFile**************************************************************** /**CFile****************************************************************
FileName [extraUtilBdd.c] FileName [extraBddMisc.c]
SystemName [ABC: Logic synthesis and verification system.] SystemName [ABC: Logic synthesis and verification system.]
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - June 20, 2005.] Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: extraUtilBdd.c,v 1.0 2003/09/01 00:00:00 alanmi Exp $] Revision [$Id: extraBddMisc.c,v 1.0 2003/09/01 00:00:00 alanmi Exp $]
***********************************************************************/ ***********************************************************************/
......
...@@ -321,6 +321,7 @@ void * Extra_FileReaderGetTokens_int( Extra_FileReader_t * p ) ...@@ -321,6 +321,7 @@ void * Extra_FileReaderGetTokens_int( Extra_FileReader_t * p )
// through EXTRA_OFFSET_SIZE chars till the end of the buffer // through EXTRA_OFFSET_SIZE chars till the end of the buffer
if ( p->pBufferStop == p->pBufferEnd ) // end of file if ( p->pBufferStop == p->pBufferEnd ) // end of file
{ {
*pChar = 0;
p->fStop = 1; p->fStop = 1;
return p->vTokens; return p->vTokens;
} }
......
SRC += src/misc/extra/extraUtilBdd.c \ SRC += src/misc/extra/extraBddMisc.c \
src/misc/extra/extraBddSymm.c \
src/misc/extra/extraUtilBitMatrix.c \ src/misc/extra/extraUtilBitMatrix.c \
src/misc/extra/extraUtilCanon.c \ src/misc/extra/extraUtilCanon.c \
src/misc/extra/extraUtilFile.c \ src/misc/extra/extraUtilFile.c \
......
...@@ -52,7 +52,7 @@ struct Vec_Vec_t_ ...@@ -52,7 +52,7 @@ struct Vec_Vec_t_
#define Vec_VecForEachLevel( vGlob, vVec, i ) \ #define Vec_VecForEachLevel( vGlob, vVec, i ) \
for ( i = 0; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ ) for ( i = 0; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
#define Vec_VecForEachLevelStart( vGlob, vVec, i, LevelStart ) \ #define Vec_VecForEachLevelStart( vGlob, vVec, i, LevelStart ) \
for ( i = LevelStart; (i < Vec_PtrSize(vGlob)) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ ) for ( i = LevelStart; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
#define Vec_VecForEachLevelStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \ #define Vec_VecForEachLevelStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
for ( i = LevelStart; (i <= LevelStop) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ ) for ( i = LevelStart; (i <= LevelStop) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
#define Vec_VecForEachLevelReverse( vGlob, vVec, i ) \ #define Vec_VecForEachLevelReverse( vGlob, vVec, i ) \
...@@ -234,6 +234,25 @@ static inline void Vec_VecPush( Vec_Vec_t * p, int Level, void * Entry ) ...@@ -234,6 +234,25 @@ static inline void Vec_VecPush( Vec_Vec_t * p, int Level, void * Entry )
Vec_PtrPush( p->pArray[Level], Entry ); Vec_PtrPush( p->pArray[Level], Entry );
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_VecPushUnique( Vec_Vec_t * p, int Level, void * Entry )
{
if ( p->nSize < Level + 1 )
Vec_VecPush( p, Level, Entry );
else
Vec_PtrPushUnique( p->pArray[Level], Entry );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
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