00001
00021 #include "io.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00080
00081 static void Io_WriteListEdge( FILE * pFile, Abc_Obj_t * pObj );
00082 static void Io_WriteListHost( FILE * pFile, Abc_Ntk_t * pNtk );
00083
00087
00099 void Io_WriteList( Abc_Ntk_t * pNtk, char * pFileName, int fUseHost )
00100 {
00101 FILE * pFile;
00102 Abc_Obj_t * pObj;
00103 int i;
00104
00105
00106
00107
00108 pFile = fopen( pFileName, "w" );
00109 if ( pFile == NULL )
00110 {
00111 fprintf( stdout, "Io_WriteList(): Cannot open the output file \"%s\".\n", pFileName );
00112 return;
00113 }
00114
00115 fprintf( pFile, "# Adjacency list for sequential AIG \"%s\"\n", pNtk->pName );
00116 fprintf( pFile, "# written by ABC on %s\n", Extra_TimeStamp() );
00117
00118
00119 if ( Abc_ObjFanoutNum( Abc_AigConst1(pNtk) ) > 0 )
00120 Io_WriteListEdge( pFile, Abc_AigConst1(pNtk) );
00121
00122
00123 Abc_NtkForEachPi( pNtk, pObj, i )
00124 Io_WriteListEdge( pFile, pObj );
00125
00126
00127 Abc_AigForEachAnd( pNtk, pObj, i )
00128 Io_WriteListEdge( pFile, pObj );
00129
00130
00131 if ( fUseHost )
00132 Io_WriteListHost( pFile, pNtk );
00133 else
00134 Abc_NtkForEachPo( pNtk, pObj, i )
00135 Io_WriteListEdge( pFile, pObj );
00136
00137 fprintf( pFile, "\n" );
00138 fclose( pFile );
00139 }
00140
00152 void Io_WriteListEdge( FILE * pFile, Abc_Obj_t * pObj )
00153 {
00154 Abc_Obj_t * pFanout;
00155 int i;
00156 fprintf( pFile, "%-10s > ", Abc_ObjName(pObj) );
00157 Abc_ObjForEachFanout( pObj, pFanout, i )
00158 {
00159 fprintf( pFile, " %s", Abc_ObjName(pFanout) );
00160 fprintf( pFile, " ([%s_to_", Abc_ObjName(pObj) );
00161
00162 fprintf( pFile, "%s] = %d)", Abc_ObjName(pFanout), 0 );
00163 if ( i != Abc_ObjFanoutNum(pObj) - 1 )
00164 fprintf( pFile, "," );
00165 }
00166 fprintf( pFile, "." );
00167 fprintf( pFile, "\n" );
00168 }
00169
00181 void Io_WriteListHost( FILE * pFile, Abc_Ntk_t * pNtk )
00182 {
00183 Abc_Obj_t * pObj;
00184 int i;
00185
00186 Abc_NtkForEachPo( pNtk, pObj, i )
00187 {
00188 fprintf( pFile, "%-10s > ", Abc_ObjName(pObj) );
00189 fprintf( pFile, " %s ([%s_to_%s] = %d)", "HOST", Abc_ObjName(pObj), "HOST", 0 );
00190 fprintf( pFile, "." );
00191 fprintf( pFile, "\n" );
00192 }
00193
00194 fprintf( pFile, "%-10s > ", "HOST" );
00195 Abc_NtkForEachPi( pNtk, pObj, i )
00196 {
00197 fprintf( pFile, " %s", Abc_ObjName(pObj) );
00198 fprintf( pFile, " ([%s_to_%s] = %d)", "HOST", Abc_ObjName(pObj), 0 );
00199 if ( i != Abc_NtkPiNum(pNtk) - 1 )
00200 fprintf( pFile, "," );
00201 }
00202 fprintf( pFile, "." );
00203 fprintf( pFile, "\n" );
00204 }
00205
00206
00218 void Io_WriteCellNet( Abc_Ntk_t * pNtk, char * pFileName )
00219 {
00220 FILE * pFile;
00221 Abc_Obj_t * pObj, * pFanout;
00222 int i, k;
00223
00224 assert( Abc_NtkIsLogic(pNtk) );
00225
00226
00227 pFile = fopen( pFileName, "w" );
00228 if ( pFile == NULL )
00229 {
00230 fprintf( stdout, "Io_WriteCellNet(): Cannot open the output file \"%s\".\n", pFileName );
00231 return;
00232 }
00233
00234 fprintf( pFile, "# CellNet file for network \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00235
00236
00237
00238
00239
00240
00241
00242 Abc_NtkForEachPi( pNtk, pObj, i )
00243 fprintf( pFile, "cell %d is 0\n", pObj->Id );
00244
00245 Abc_NtkForEachPo( pNtk, pObj, i )
00246 fprintf( pFile, "cell %d is 1\n", pObj->Id );
00247
00248 Abc_NtkForEachLatch( pNtk, pObj, i )
00249 fprintf( pFile, "cell %d is 2\n", Abc_ObjFanin0(pObj)->Id );
00250
00251 Abc_NtkForEachNode( pNtk, pObj, i )
00252 fprintf( pFile, "cell %d is %d\n", pObj->Id, 3+Abc_ObjFaninNum(pObj) );
00253
00254
00255 Abc_NtkForEachPi( pNtk, pObj, i )
00256 {
00257 fprintf( pFile, "net %d %d 0", pObj->Id, pObj->Id );
00258 Abc_ObjForEachFanout( pObj, pFanout, k )
00259 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
00260 fprintf( pFile, "\n" );
00261 }
00262
00263 Abc_NtkForEachLatch( pNtk, pObj, i )
00264 {
00265 fprintf( pFile, "net %d %d 0", Abc_ObjFanin0(pObj)->Id, Abc_ObjFanin0(pObj)->Id );
00266 pObj = Abc_ObjFanout0(pObj);
00267 Abc_ObjForEachFanout( pObj, pFanout, k )
00268 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
00269 fprintf( pFile, "\n" );
00270 }
00271
00272 Abc_NtkForEachNode( pNtk, pObj, i )
00273 {
00274 fprintf( pFile, "net %d %d 0", pObj->Id, pObj->Id );
00275 Abc_ObjForEachFanout( pObj, pFanout, k )
00276 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
00277 fprintf( pFile, "\n" );
00278 }
00279
00280 fprintf( pFile, "\n" );
00281 fclose( pFile );
00282 }
00283
00287
00288