diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2008-02-22 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2008-02-22 08:01:00 -0800 |
commit | 7d23cc522e416ae1f3d2d53292ef438d1a08b0d7 (patch) | |
tree | 5f59908955de0cc52217c159db6c9c5688c959d8 /src/base/abci/abcPrint.c | |
parent | bd995ee2ca86bcb488d2e9592012b6077a6283f6 (diff) | |
download | abc-7d23cc522e416ae1f3d2d53292ef438d1a08b0d7.tar.gz abc-7d23cc522e416ae1f3d2d53292ef438d1a08b0d7.tar.bz2 abc-7d23cc522e416ae1f3d2d53292ef438d1a08b0d7.zip |
Version abc80222
Diffstat (limited to 'src/base/abci/abcPrint.c')
-rw-r--r-- | src/base/abci/abcPrint.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index 6135d009..5d35f329 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -42,6 +42,66 @@ int s_ResynTime = 0; /**Function************************************************************* + Synopsis [If the network is best, saves it in "best.blif" and returns 1.] + + Description [If the networks are incomparable, saves the new network, + returns its parameters in the internal parameter structure, and returns 1. + If the new network is not a logic network, quits without saving and returns 0.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk ) +{ + extern void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType ); + static struct ParStruct { + char * pName; // name of the best saved network + int Depth; // depth of the best saved network + int Flops; // flops in the best saved network + int Nodes; // nodes in the best saved network + int nPis; // the number of primary inputs + int nPos; // the number of primary outputs + } ParsNew, ParsBest = { 0 }; + // free storage for the name + if ( pNtk == NULL ) + { + FREE( ParsBest.pName ); + return 0; + } + // quit if not a logic network + if ( !Abc_NtkIsLogic(pNtk) ) + return 0; + // get the parameters + ParsNew.Depth = Abc_NtkLevel( pNtk ); + ParsNew.Flops = Abc_NtkLatchNum( pNtk ); + ParsNew.Nodes = Abc_NtkNodeNum( pNtk ); + ParsNew.nPis = Abc_NtkPiNum( pNtk ); + ParsNew.nPos = Abc_NtkPoNum( pNtk ); + // reset the parameters if the network has the same name + if ( ParsBest.pName == NULL || + strcmp(ParsBest.pName, pNtk->pName) || + ParsBest.Depth > ParsNew.Depth || + ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops || + ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes ) + { + FREE( ParsBest.pName ); + ParsBest.pName = Extra_UtilStrsav( pNtk->pName ); + ParsBest.Depth = ParsNew.Depth; + ParsBest.Flops = ParsNew.Flops; + ParsBest.Nodes = ParsNew.Nodes; + ParsBest.nPis = ParsNew.nPis; + ParsBest.nPos = ParsNew.nPos; + // writ the network + Io_Write( pNtk, "best.blif", IO_FILE_BLIF ); + return 1; + } + return 0; +} + +/**Function************************************************************* + Synopsis [Print the vital stats of the network.] Description [] @@ -51,10 +111,13 @@ int s_ResynTime = 0; SeeAlso [] ***********************************************************************/ -void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) +void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSaveBest ) { int Num; + if ( fSaveBest ) + Abc_NtkCompareAndSaveBest( pNtk ); + // if ( Abc_NtkIsStrash(pNtk) ) // Abc_AigCountNext( pNtk->pManFunc ); @@ -220,6 +283,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) // if ( Abc_NtkHasSop(pNtk) ) // printf( "The total number of cube pairs = %d.\n", Abc_NtkGetCubePairNum(pNtk) ); + } /**Function************************************************************* |