diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/abci/abc.c | 133 | ||||
-rw-r--r-- | src/base/abci/abcDar.c | 191 |
2 files changed, 237 insertions, 87 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 9c2c0153..6b305033 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -27,6 +27,8 @@ #include "if.h" #include "res.h" #include "lpk.h" +#include "aig.h" +#include "dar.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -108,6 +110,7 @@ static int Abc_CommandQuaReach ( Abc_Frame_t * pAbc, int argc, char ** arg static int Abc_CommandIStrash ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandICut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandDRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIRewriteSeq ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIResyn ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandISat ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -265,6 +268,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "New AIG", "istrash", Abc_CommandIStrash, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "icut", Abc_CommandICut, 0 ); Cmd_CommandAdd( pAbc, "New AIG", "irw", Abc_CommandIRewrite, 1 ); + Cmd_CommandAdd( pAbc, "New AIG", "drw", Abc_CommandDRewrite, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "irws", Abc_CommandIRewriteSeq, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "iresyn", Abc_CommandIResyn, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "isat", Abc_CommandISat, 1 ); @@ -337,7 +341,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) { extern void Dar_LibStart(); -// Dar_LibStart(); + Dar_LibStart(); } } @@ -354,13 +358,16 @@ void Abc_Init( Abc_Frame_t * pAbc ) ***********************************************************************/ void Abc_End() { +// Dar_LibDumpPriorities(); + { extern void Dar_LibStop(); -// Dar_LibStop(); + Dar_LibStop(); } Abc_NtkFraigStoreClean(); // Rwt_Man4ExplorePrint(); + } /**Function************************************************************* @@ -6081,14 +6088,13 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) // Abc_Ntk4VarTable( pNtk ); // Dar_NtkGenerateArrays( pNtk ); // Dar_ManDeriveCnfTest2(); -/* + if ( !Abc_NtkIsStrash(pNtk) ) { fprintf( pErr, "Network should be strashed. Command has failed.\n" ); return 1; } -*/ -// pNtkRes = Abc_NtkDar( pNtk ); + pNtkRes = Abc_NtkDar( pNtk ); // pNtkRes = Abc_NtkDarToCnf( pNtk, "any.cnf" ); pNtkRes = NULL; if ( pNtkRes == NULL ) @@ -6609,6 +6615,105 @@ usage: SeeAlso [] ***********************************************************************/ +int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + FILE * pOut, * pErr; + Abc_Ntk_t * pNtk, * pNtkRes; + Dar_Par_t Pars, * pPars = &Pars; + int c; + + extern Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_Par_t * pPars ); + + pNtk = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set defaults + Dar_ManDefaultParams( pPars ); + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "CNlzvwh" ) ) != EOF ) + { + switch ( c ) + { + case 'C': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nCutsMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nCutsMax < 0 ) + goto usage; + break; + case 'N': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nSubgMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nSubgMax < 0 ) + goto usage; + break; + case 'l': + pPars->fUpdateLevel ^= 1; + break; + case 'z': + pPars->fUseZeros ^= 1; + break; + case 'v': + pPars->fVerbose ^= 1; + break; + case 'w': + pPars->fVeryVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pNtk == NULL ) + { + fprintf( pErr, "Empty network.\n" ); + return 1; + } + pNtkRes = Abc_NtkDRewrite( pNtk, pPars ); + if ( pNtkRes == NULL ) + { + fprintf( pErr, "Command has failed.\n" ); + return 0; + } + // replace the current network + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + return 0; + +usage: + fprintf( pErr, "usage: drw [-C num] [-N num] [-lzvwh]\n" ); + fprintf( pErr, "\t perform combinational AIG rewriting\n" ); + fprintf( pErr, "\t-C num : limit on the number of cuts at a node [default = %d]\n", pPars->nCutsMax ); + fprintf( pErr, "\t-N num : limit on the number of subgraphs tried [default = %d]\n", pPars->nSubgMax ); + fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" ); + fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" ); + fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" ); + fprintf( pErr, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); + fprintf( pErr, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; @@ -7023,7 +7128,7 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) // set defaults nCutsMax = 8; - nLeafMax = 8; + nLeafMax = 6; fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "CKvh" ) ) != EOF ) @@ -7067,6 +7172,18 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } + if ( nCutsMax < 2 ) + { + fprintf( pErr, "The number of cuts cannot be less than 2.\n" ); + return 1; + } + + if ( nLeafMax < 3 || nLeafMax > 16 ) + { + fprintf( pErr, "The number of leaves is infeasible.\n" ); + return 1; + } + pNtkRes = Abc_NtkCSweep( pNtk, nCutsMax, nLeafMax, fVerbose ); if ( pNtkRes == NULL ) { @@ -7080,8 +7197,8 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) usage: fprintf( pErr, "usage: csweep [-C num] [-K num] [-vh]\n" ); fprintf( pErr, "\t performs cut sweeping using a new method\n" ); - fprintf( pErr, "\t-C num : limit on the number of cuts [default = %d]\n", nCutsMax ); - fprintf( pErr, "\t-K num : limit on the cut size [default = %d]\n", nLeafMax ); + fprintf( pErr, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax ); + fprintf( pErr, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index ed6fa77e..c4020127 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -19,6 +19,7 @@ ***********************************************************************/ #include "abc.h" +#include "aig.h" #include "dar.h" #include "cnf.h" #include "fra.h" @@ -42,27 +43,33 @@ SeeAlso [] ***********************************************************************/ -Dar_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk ) +Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk ) { - Dar_Man_t * pMan; + Aig_Man_t * pMan; Abc_Obj_t * pObj; int i; // create the manager - pMan = Dar_ManStart( Abc_NtkNodeNum(pNtk) + 100 ); + pMan = Aig_ManStart( Abc_NtkNodeNum(pNtk) + 100 ); // transfer the pointers to the basic nodes - Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Dar_ManConst1(pMan); + Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Aig_ManConst1(pMan); Abc_NtkForEachCi( pNtk, pObj, i ) - pObj->pCopy = (Abc_Obj_t *)Dar_ObjCreatePi(pMan); + pObj->pCopy = (Abc_Obj_t *)Aig_ObjCreatePi(pMan); // perform the conversion of the internal nodes (assumes DFS ordering) Abc_NtkForEachNode( pNtk, pObj, i ) { - pObj->pCopy = (Abc_Obj_t *)Dar_And( pMan, (Dar_Obj_t *)Abc_ObjChild0Copy(pObj), (Dar_Obj_t *)Abc_ObjChild1Copy(pObj) ); -// printf( "%d->%d ", pObj->Id, ((Dar_Obj_t *)pObj->pCopy)->Id ); + pObj->pCopy = (Abc_Obj_t *)Aig_And( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj), (Aig_Obj_t *)Abc_ObjChild1Copy(pObj) ); +// printf( "%d->%d ", pObj->Id, ((Aig_Obj_t *)pObj->pCopy)->Id ); } // create the POs Abc_NtkForEachCo( pNtk, pObj, i ) - Dar_ObjCreatePo( pMan, (Dar_Obj_t *)Abc_ObjChild0Copy(pObj) ); - Dar_ManCleanup( pMan ); + Aig_ObjCreatePo( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj) ); + Aig_ManCleanup( pMan ); + if ( !Aig_ManCheck( pMan ) ) + { + printf( "Abc_NtkToDar: AIG check has failed.\n" ); + Aig_ManStop( pMan ); + return NULL; + } return pMan; } @@ -77,29 +84,29 @@ Dar_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk ) SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan ) +Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan ) { Vec_Ptr_t * vNodes; Abc_Ntk_t * pNtkNew; - Dar_Obj_t * pObj; + Aig_Obj_t * pObj; int i; // perform strashing pNtkNew = Abc_NtkStartFrom( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG ); // transfer the pointers to the basic nodes - Dar_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew); - Dar_ManForEachPi( pMan, pObj, i ) + Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew); + Aig_ManForEachPi( pMan, pObj, i ) pObj->pData = Abc_NtkCi(pNtkNew, i); // rebuild the AIG - vNodes = Dar_ManDfs( pMan ); + vNodes = Aig_ManDfs( pMan ); Vec_PtrForEachEntry( vNodes, pObj, i ) - if ( Dar_ObjIsBuf(pObj) ) - pObj->pData = (Abc_Obj_t *)Dar_ObjChild0Copy(pObj); + if ( Aig_ObjIsBuf(pObj) ) + pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj); else - pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Dar_ObjChild0Copy(pObj), (Abc_Obj_t *)Dar_ObjChild1Copy(pObj) ); + pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) ); Vec_PtrFree( vNodes ); // connect the PO nodes - Dar_ManForEachPo( pMan, pObj, i ) - Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Dar_ObjChild0Copy(pObj) ); + Aig_ManForEachPo( pMan, pObj, i ) + Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Aig_ObjChild0Copy(pObj) ); if ( !Abc_NtkCheck( pNtkNew ) ) fprintf( stdout, "Abc_NtkFromDar(): Network check has failed.\n" ); return pNtkNew; @@ -116,24 +123,24 @@ Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan ) SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan ) +Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan ) { Vec_Ptr_t * vNodes; Abc_Ntk_t * pNtkNew; Abc_Obj_t * pObjNew, * pFaninNew, * pFaninNew0, * pFaninNew1; - Dar_Obj_t * pObj; + Aig_Obj_t * pObj; int i; -// assert( Dar_ManLatchNum(pMan) > 0 ); +// assert( Aig_ManLatchNum(pMan) > 0 ); // perform strashing pNtkNew = Abc_NtkStartFromNoLatches( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG ); // transfer the pointers to the basic nodes - Dar_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew); - Dar_ManForEachPi( pMan, pObj, i ) + Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew); + Aig_ManForEachPi( pMan, pObj, i ) pObj->pData = Abc_NtkPi(pNtkNew, i); // create latches of the new network - Dar_ManForEachObj( pMan, pObj, i ) + Aig_ManForEachObj( pMan, pObj, i ) { - if ( !Dar_ObjIsLatch(pObj) ) + if ( !Aig_ObjIsLatch(pObj) ) continue; pObjNew = Abc_NtkCreateLatch( pNtkNew ); pFaninNew0 = Abc_NtkCreateBi( pNtkNew ); @@ -145,34 +152,34 @@ Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan ) } Abc_NtkAddDummyBoxNames( pNtkNew ); // rebuild the AIG - vNodes = Dar_ManDfs( pMan ); + vNodes = Aig_ManDfs( pMan ); Vec_PtrForEachEntry( vNodes, pObj, i ) { // add the first fanin - pObj->pData = pFaninNew0 = (Abc_Obj_t *)Dar_ObjChild0Copy(pObj); - if ( Dar_ObjIsBuf(pObj) ) + pObj->pData = pFaninNew0 = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj); + if ( Aig_ObjIsBuf(pObj) ) continue; // add the second fanin - pFaninNew1 = (Abc_Obj_t *)Dar_ObjChild1Copy(pObj); + pFaninNew1 = (Abc_Obj_t *)Aig_ObjChild1Copy(pObj); // create the new node - if ( Dar_ObjIsExor(pObj) ) + if ( Aig_ObjIsExor(pObj) ) pObj->pData = pObjNew = Abc_AigXor( pNtkNew->pManFunc, pFaninNew0, pFaninNew1 ); else pObj->pData = pObjNew = Abc_AigAnd( pNtkNew->pManFunc, pFaninNew0, pFaninNew1 ); } Vec_PtrFree( vNodes ); // connect the PO nodes - Dar_ManForEachPo( pMan, pObj, i ) + Aig_ManForEachPo( pMan, pObj, i ) { - pFaninNew = (Abc_Obj_t *)Dar_ObjChild0Copy( pObj ); + pFaninNew = (Abc_Obj_t *)Aig_ObjChild0Copy( pObj ); Abc_ObjAddFanin( Abc_NtkPo(pNtkNew, i), pFaninNew ); } // connect the latches - Dar_ManForEachObj( pMan, pObj, i ) + Aig_ManForEachObj( pMan, pObj, i ) { - if ( !Dar_ObjIsLatch(pObj) ) + if ( !Aig_ObjIsLatch(pObj) ) continue; - pFaninNew = (Abc_Obj_t *)Dar_ObjChild0Copy( pObj ); + pFaninNew = (Abc_Obj_t *)Aig_ObjChild0Copy( pObj ); Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pObj->pData)), pFaninNew ); } if ( !Abc_NtkCheck( pNtkNew ) ) @@ -215,7 +222,7 @@ int * Abc_NtkGetLatchValues( Abc_Ntk_t * pNtk ) void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) { int fRemove1, fRemove2; - Dar_Man_t * pMan1, * pMan2; + Aig_Man_t * pMan1, * pMan2; int * pArray; fRemove1 = (!Abc_NtkIsStrash(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0, 0, 0)); @@ -225,22 +232,22 @@ void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) pMan1 = Abc_NtkToDar( pNtk1 ); pMan2 = Abc_NtkToDar( pNtk2 ); - Dar_ManPrintStats( pMan1 ); - Dar_ManPrintStats( pMan2 ); + Aig_ManPrintStats( pMan1 ); + Aig_ManPrintStats( pMan2 ); pArray = Abc_NtkGetLatchValues(pNtk1); - Dar_ManSeqStrash( pMan1, Abc_NtkLatchNum(pNtk1), pArray ); + Aig_ManSeqStrash( pMan1, Abc_NtkLatchNum(pNtk1), pArray ); free( pArray ); pArray = Abc_NtkGetLatchValues(pNtk2); - Dar_ManSeqStrash( pMan2, Abc_NtkLatchNum(pNtk2), pArray ); + Aig_ManSeqStrash( pMan2, Abc_NtkLatchNum(pNtk2), pArray ); free( pArray ); - Dar_ManPrintStats( pMan1 ); - Dar_ManPrintStats( pMan2 ); + Aig_ManPrintStats( pMan1 ); + Aig_ManPrintStats( pMan2 ); - Dar_ManStop( pMan1 ); - Dar_ManStop( pMan2 ); + Aig_ManStop( pMan1 ); + Aig_ManStop( pMan2 ); if ( fRemove1 ) Abc_NtkDelete( pNtk1 ); @@ -261,7 +268,7 @@ void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) Abc_Ntk_t * Abc_NtkDar( Abc_Ntk_t * pNtk ) { Abc_Ntk_t * pNtkAig; - Dar_Man_t * pMan;//, * pTemp; + Aig_Man_t * pMan;//, * pTemp; // int * pArray; assert( Abc_NtkIsStrash(pNtk) ); @@ -269,45 +276,44 @@ Abc_Ntk_t * Abc_NtkDar( Abc_Ntk_t * pNtk ) pMan = Abc_NtkToDar( pNtk ); if ( pMan == NULL ) return NULL; - if ( !Dar_ManCheck( pMan ) ) + if ( !Aig_ManCheck( pMan ) ) { printf( "Abc_NtkDar: AIG check has failed.\n" ); - Dar_ManStop( pMan ); + Aig_ManStop( pMan ); return NULL; } // perform balance - Dar_ManPrintStats( pMan ); + Aig_ManPrintStats( pMan ); /* pArray = Abc_NtkGetLatchValues(pNtk); - Dar_ManSeqStrash( pMan, Abc_NtkLatchNum(pNtk), pArray ); + Aig_ManSeqStrash( pMan, Abc_NtkLatchNum(pNtk), pArray ); free( pArray ); */ -// Dar_ManDumpBlif( pMan, "aig_temp.blif" ); +// Aig_ManDumpBlif( pMan, "aig_temp.blif" ); // pMan->pPars = Dar_ManDefaultParams(); - Dar_ManRewrite( pMan ); - Dar_ManPrintStats( pMan ); - Dar_ManPrintRuntime( pMan ); + Dar_ManRewrite( pMan, NULL ); + Aig_ManPrintStats( pMan ); // Dar_ManComputeCuts( pMan ); /* { -extern Dar_Cnf_t * Dar_ManDeriveCnf( Dar_Man_t * p ); -extern void Dar_CnfFree( Dar_Cnf_t * pCnf ); -Dar_Cnf_t * pCnf; -pCnf = Dar_ManDeriveCnf( pMan ); -Dar_CnfFree( pCnf ); +extern Aig_Cnf_t * Aig_ManDeriveCnf( Aig_Man_t * p ); +extern void Aig_CnfFree( Aig_Cnf_t * pCnf ); +Aig_Cnf_t * pCnf; +pCnf = Aig_ManDeriveCnf( pMan ); +Aig_CnfFree( pCnf ); } */ // convert from the AIG manager - if ( Dar_ManLatchNum(pMan) ) + if ( Aig_ManLatchNum(pMan) ) pNtkAig = Abc_NtkFromDarSeq( pNtk, pMan ); else pNtkAig = Abc_NtkFromDar( pNtk, pMan ); if ( pNtkAig == NULL ) return NULL; - Dar_ManStop( pMan ); + Aig_ManStop( pMan ); // make sure everything is okay if ( !Abc_NtkCheck( pNtkAig ) ) { @@ -334,7 +340,7 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t { Abc_Ntk_t * pNtkNew; Abc_Obj_t * pNode, * pNodeNew; - Dar_Obj_t * pObj, * pLeaf; + Aig_Obj_t * pObj, * pLeaf; Cnf_Cut_t * pCut; Vec_Int_t * vCover; unsigned uTruth; @@ -342,9 +348,9 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t // create the new network pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP ); // make the mapper point to the new network - Dar_ManConst1(p->pManAig)->pData = Abc_NtkCreateNodeConst1(pNtkNew); + Aig_ManConst1(p->pManAig)->pData = Abc_NtkCreateNodeConst1(pNtkNew); Abc_NtkForEachCi( pNtk, pNode, i ) - Dar_ManPi(p->pManAig, i)->pData = pNode->pCopy; + Aig_ManPi(p->pManAig, i)->pData = pNode->pCopy; // process the nodes in topological order vCover = Vec_IntAlloc( 1 << 16 ); Vec_PtrForEachEntry( vMapped, pObj, i ) @@ -371,13 +377,13 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t // add the CO drivers Abc_NtkForEachCo( pNtk, pNode, i ) { - pObj = Dar_ManPo(p->pManAig, i); - pNodeNew = Abc_ObjNotCond( Dar_ObjFanin0(pObj)->pData, Dar_ObjFaninC0(pObj) ); + pObj = Aig_ManPo(p->pManAig, i); + pNodeNew = Abc_ObjNotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) ); Abc_ObjAddFanin( pNode->pCopy, pNodeNew ); } // remove the constant node if not used - pNodeNew = (Abc_Obj_t *)Dar_ManConst1(p->pManAig)->pData; + pNodeNew = (Abc_Obj_t *)Aig_ManConst1(p->pManAig)->pData; if ( Abc_ObjFanoutNum(pNodeNew) == 0 ) Abc_NtkDeleteObj( pNodeNew ); // minimize the node @@ -406,21 +412,21 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName ) { Abc_Ntk_t * pNtkNew = NULL; Cnf_Man_t * pCnf; - Dar_Man_t * pMan; + Aig_Man_t * pMan; Cnf_Dat_t * pData; assert( Abc_NtkIsStrash(pNtk) ); // convert to the AIG manager pMan = Abc_NtkToDar( pNtk ); if ( pMan == NULL ) return NULL; - if ( !Dar_ManCheck( pMan ) ) + if ( !Aig_ManCheck( pMan ) ) { printf( "Abc_NtkDarToCnf: AIG check has failed.\n" ); - Dar_ManStop( pMan ); + Aig_ManStop( pMan ); return NULL; } // perform balance - Dar_ManPrintStats( pMan ); + Aig_ManPrintStats( pMan ); // derive CNF pCnf = Cnf_ManStart(); @@ -433,7 +439,7 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName ) Vec_PtrFree( vMapped ); } - Dar_ManStop( pMan ); + Aig_ManStop( pMan ); Cnf_ManStop( pCnf ); // write CNF into a file @@ -459,7 +465,7 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in { Fra_Par_t Params, * pParams = &Params; Abc_Ntk_t * pNtkAig; - Dar_Man_t * pMan, * pTemp; + Aig_Man_t * pMan, * pTemp; pMan = Abc_NtkToDar( pNtk ); if ( pMan == NULL ) return NULL; @@ -471,8 +477,8 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in pParams->fSpeculate = fSpeculate; pMan = Fra_Perform( pTemp = pMan, pParams ); pNtkAig = Abc_NtkFromDar( pNtk, pMan ); - Dar_ManStop( pTemp ); - Dar_ManStop( pMan ); + Aig_ManStop( pTemp ); + Aig_ManStop( pMan ); return pNtkAig; } @@ -489,16 +495,43 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in ***********************************************************************/ Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose ) { - extern Dar_Man_t * Csw_Sweep( Dar_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose ); + extern Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose ); Abc_Ntk_t * pNtkAig; - Dar_Man_t * pMan, * pTemp; + Aig_Man_t * pMan, * pTemp; pMan = Abc_NtkToDar( pNtk ); if ( pMan == NULL ) return NULL; pMan = Csw_Sweep( pTemp = pMan, nCutsMax, nLeafMax, fVerbose ); pNtkAig = Abc_NtkFromDar( pNtk, pMan ); - Dar_ManStop( pTemp ); - Dar_ManStop( pMan ); + Aig_ManStop( pTemp ); + Aig_ManStop( pMan ); + return pNtkAig; +} + +/**Function************************************************************* + + Synopsis [Gives the current ABC network to AIG manager for processing.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_Par_t * pPars ) +{ + Aig_Man_t * pMan; + Abc_Ntk_t * pNtkAig; + assert( Abc_NtkIsStrash(pNtk) ); + pMan = Abc_NtkToDar( pNtk ); + if ( pMan == NULL ) + return NULL; +// Aig_ManPrintStats( pMan ); + Dar_ManRewrite( pMan, pPars ); +// Aig_ManPrintStats( pMan ); + pNtkAig = Abc_NtkFromDar( pNtk, pMan ); + Aig_ManStop( pMan ); return pNtkAig; } |