00001
00021 #include "abc.h"
00022
00026
00027 static void Abc_NtkChangeCiOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vSupp, int fReverse );
00028
00032
00044 void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose )
00045 {
00046 Vec_Ptr_t * vSupp;
00047 vSupp = Abc_NtkSupport( pNtk );
00048 Abc_NtkChangeCiOrder( pNtk, vSupp, fReverse );
00049 Vec_PtrFree( vSupp );
00050 }
00051
00063 void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose )
00064 {
00065 char Buffer[1000];
00066 FILE * pFile;
00067 Vec_Ptr_t * vSupp;
00068 Abc_Obj_t * pObj;
00069 pFile = fopen( pFileName, "r" );
00070 vSupp = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
00071 while ( fscanf( pFile, "%s", Buffer ) == 1 )
00072 {
00073 pObj = Abc_NtkFindCi( pNtk, Buffer );
00074 if ( pObj == NULL || !Abc_ObjIsCi(pObj) )
00075 {
00076 printf( "Name \"%s\" is not a PI name. Cannot use this order.\n", Buffer );
00077 Vec_PtrFree( vSupp );
00078 fclose( pFile );
00079 return;
00080 }
00081 Vec_PtrPush( vSupp, pObj );
00082 }
00083 fclose( pFile );
00084 if ( Vec_PtrSize(vSupp) != Abc_NtkCiNum(pNtk) )
00085 {
00086 printf( "The number of names in the order (%d) is not the same as the number of PIs (%d).\n", Vec_PtrSize(vSupp), Abc_NtkCiNum(pNtk) );
00087 Vec_PtrFree( vSupp );
00088 return;
00089 }
00090 Abc_NtkChangeCiOrder( pNtk, vSupp, fReverse );
00091 Vec_PtrFree( vSupp );
00092 }
00093
00105 void Abc_NtkChangeCiOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vSupp, int fReverse )
00106 {
00107 Abc_Obj_t * pObj;
00108 int i;
00109 assert( Vec_PtrSize(vSupp) == Abc_NtkCiNum(pNtk) );
00110
00111 if ( fReverse )
00112 Vec_PtrForEachEntry( vSupp, pObj, i )
00113 Vec_PtrWriteEntry( pNtk->vCis, Vec_PtrSize(vSupp)-1-i, pObj );
00114 else
00115 Vec_PtrForEachEntry( vSupp, pObj, i )
00116 Vec_PtrWriteEntry( pNtk->vCis, i, pObj );
00117
00118 Vec_PtrClear( pNtk->vPis );
00119 Abc_NtkForEachCi( pNtk, pObj, i )
00120 if ( Abc_ObjIsPi(pObj) )
00121 Vec_PtrPush( pNtk->vPis, pObj );
00122
00123
00124
00125 }
00126
00130
00131