00001
00021 #include "retInt.h"
00022
00026
00027 int timeRetime = 0;
00028
00032
00044 int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose )
00045 {
00046 int nLatches = Abc_NtkLatchNum(pNtk);
00047 int nLevels = Abc_NtkLevel(pNtk);
00048 int RetValue = 0, clkTotal = clock();
00049 int nNodesOld, nLatchesOld;
00050 assert( Mode > 0 && Mode < 7 );
00051 assert( !fForwardOnly || !fBackwardOnly );
00052
00053
00054 nNodesOld = Abc_NtkNodeNum(pNtk);
00055 nLatchesOld = Abc_NtkLatchNum(pNtk);
00056 Abc_NtkCleanupSeq(pNtk, 0, 0, 0);
00057 if ( nNodesOld > Abc_NtkNodeNum(pNtk) || nLatchesOld > Abc_NtkLatchNum(pNtk) )
00058 printf( "Cleanup before retiming removed %d dangling nodes and %d dangling latches.\n",
00059 nNodesOld - Abc_NtkNodeNum(pNtk), nLatchesOld - Abc_NtkLatchNum(pNtk) );
00060
00061
00062 switch ( Mode )
00063 {
00064 case 1:
00065 RetValue = Abc_NtkRetimeIncremental( pNtk, 1, 0, 0, fVerbose );
00066 break;
00067 case 2:
00068 RetValue = Abc_NtkRetimeIncremental( pNtk, 0, 0, 0, fVerbose );
00069 break;
00070 case 3:
00071 RetValue = Abc_NtkRetimeMinArea( pNtk, fForwardOnly, fBackwardOnly, fVerbose );
00072 break;
00073 case 4:
00074 if ( !fBackwardOnly )
00075 RetValue += Abc_NtkRetimeIncremental( pNtk, 1, 1, fOneStep, fVerbose );
00076 if ( !fForwardOnly )
00077 RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, fOneStep, fVerbose );
00078 break;
00079 case 5:
00080 RetValue = Abc_NtkRetimeMinArea( pNtk, fForwardOnly, fBackwardOnly, fVerbose );
00081 if ( !fBackwardOnly )
00082 RetValue += Abc_NtkRetimeIncremental( pNtk, 1, 1, 0, fVerbose );
00083 if ( !fForwardOnly )
00084 RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, 0, fVerbose );
00085 break;
00086 case 6:
00087 RetValue = Abc_NtkRetimeLValue( pNtk, 500, fVerbose );
00088 break;
00089 default:
00090 printf( "Unknown retiming option.\n" );
00091 break;
00092 }
00093 if ( fVerbose )
00094 {
00095 printf( "Reduction in area = %3d. Reduction in delay = %3d. ",
00096 nLatches - Abc_NtkLatchNum(pNtk), nLevels - Abc_NtkLevel(pNtk) );
00097 PRT( "Total runtime", clock() - clkTotal );
00098 }
00099 timeRetime = clock() - clkTotal;
00100 return RetValue;
00101 }
00102
00114 int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk )
00115 {
00116 extern int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFrames, int fVerbose );
00117 Abc_Ntk_t * pNtkRet;
00118 assert( Abc_NtkIsLogic(pNtk) );
00119 Abc_NtkToSop( pNtk, 0 );
00120
00121
00122
00123 pNtkRet = Abc_NtkDup( pNtk );
00124 Abc_NtkRetime( pNtkRet, 3, 0, 1, 0, 0 );
00125 return !Abc_NtkSecFraig( pNtk, pNtkRet, 10000, 3, 0 );
00126 }
00127
00131
00132