src/base/io/io.h File Reference

#include "abc.h"
Include dependency graph for io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define IO_WRITE_LINE_LENGTH   78

Enumerations

enum  Io_FileType_t {
  IO_FILE_NONE = 0, IO_FILE_AIGER, IO_FILE_BAF, IO_FILE_BLIF,
  IO_FILE_BLIFMV, IO_FILE_BENCH, IO_FILE_CNF, IO_FILE_DOT,
  IO_FILE_EDIF, IO_FILE_EQN, IO_FILE_GML, IO_FILE_LIST,
  IO_FILE_PLA, IO_FILE_VERILOG, IO_FILE_UNKNOWN
}

Functions

Abc_Ntk_tIo_ReadAiger (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadBaf (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadBlif (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadBlifMv (char *pFileName, int fBlifMv, int fCheck)
Abc_Ntk_tIo_ReadBench (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadEdif (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadEqn (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadPla (char *pFileName, int fCheck)
Abc_Ntk_tIo_ReadVerilog (char *pFileName, int fCheck)
void Io_WriteAiger (Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols)
void Io_WriteBaf (Abc_Ntk_t *pNtk, char *pFileName)
void Io_WriteBlifLogic (Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
void Io_WriteBlif (Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
void Io_WriteTimingInfo (FILE *pFile, Abc_Ntk_t *pNtk)
void Io_WriteBlifMv (Abc_Ntk_t *pNtk, char *FileName)
int Io_WriteBench (Abc_Ntk_t *pNtk, char *FileName)
int Io_WriteBenchLut (Abc_Ntk_t *pNtk, char *FileName)
int Io_WriteCnf (Abc_Ntk_t *pNtk, char *FileName, int fAllPrimes)
void Io_WriteDot (Abc_Ntk_t *pNtk, char *FileName)
void Io_WriteDotNtk (Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse)
void Io_WriteDotSeq (Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse)
void Io_WriteEqn (Abc_Ntk_t *pNtk, char *pFileName)
void Io_WriteGml (Abc_Ntk_t *pNtk, char *pFileName)
void Io_WriteList (Abc_Ntk_t *pNtk, char *pFileName, int fUseHost)
int Io_WritePla (Abc_Ntk_t *pNtk, char *FileName)
void Io_WriteVerilog (Abc_Ntk_t *pNtk, char *FileName)
Io_FileType_t Io_ReadFileType (char *pFileName)
Abc_Ntk_tIo_ReadNetlist (char *pFileName, Io_FileType_t FileType, int fCheck)
Abc_Ntk_tIo_Read (char *pFileName, Io_FileType_t FileType, int fCheck)
void Io_Write (Abc_Ntk_t *pNtk, char *pFileName, Io_FileType_t FileType)
void Io_WriteHie (Abc_Ntk_t *pNtk, char *pBaseName, char *pFileName)
Abc_Obj_tIo_ReadCreatePi (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tIo_ReadCreatePo (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tIo_ReadCreateAssert (Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_tIo_ReadCreateLatch (Abc_Ntk_t *pNtk, char *pNetLI, char *pNetLO)
Abc_Obj_tIo_ReadCreateResetLatch (Abc_Ntk_t *pNtk, int fBlifMv)
Abc_Obj_tIo_ReadCreateResetMux (Abc_Ntk_t *pNtk, char *pResetLO, char *pDataLI, int fBlifMv)
Abc_Obj_tIo_ReadCreateNode (Abc_Ntk_t *pNtk, char *pNameOut, char *pNamesIn[], int nInputs)
Abc_Obj_tIo_ReadCreateConst (Abc_Ntk_t *pNtk, char *pName, bool fConst1)
Abc_Obj_tIo_ReadCreateInv (Abc_Ntk_t *pNtk, char *pNameIn, char *pNameOut)
Abc_Obj_tIo_ReadCreateBuf (Abc_Ntk_t *pNtk, char *pNameIn, char *pNameOut)
FILE * Io_FileOpen (const char *FileName, const char *PathVar, const char *Mode, int fVerbose)

Define Documentation

#define IO_WRITE_LINE_LENGTH   78

MACRO DEFINITIONS ///

Definition at line 65 of file io.h.


Enumeration Type Documentation

CFile****************************************************************

FileName [io.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
io.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] INCLUDES /// PARAMETERS /// BASIC TYPES ///

Enumerator:
IO_FILE_NONE 
IO_FILE_AIGER 
IO_FILE_BAF 
IO_FILE_BLIF 
IO_FILE_BLIFMV 
IO_FILE_BENCH 
IO_FILE_CNF 
IO_FILE_DOT 
IO_FILE_EDIF 
IO_FILE_EQN 
IO_FILE_GML 
IO_FILE_LIST 
IO_FILE_PLA 
IO_FILE_VERILOG 
IO_FILE_UNKNOWN 

Definition at line 43 of file io.h.

00043              { 
00044     IO_FILE_NONE = 0, 
00045     IO_FILE_AIGER,      
00046     IO_FILE_BAF,      
00047     IO_FILE_BLIF,      
00048     IO_FILE_BLIFMV,      
00049     IO_FILE_BENCH,      
00050     IO_FILE_CNF,      
00051     IO_FILE_DOT,      
00052     IO_FILE_EDIF,      
00053     IO_FILE_EQN,      
00054     IO_FILE_GML,      
00055     IO_FILE_LIST,      
00056     IO_FILE_PLA,      
00057     IO_FILE_VERILOG,    
00058     IO_FILE_UNKNOWN       
00059 } Io_FileType_t;


Function Documentation

FILE* Io_FileOpen ( const char *  FileName,
const char *  PathVar,
const char *  Mode,
int  fVerbose 
)

Function*************************************************************

Synopsis [Provide an fopen replacement with path lookup]

Description [Provide an fopen replacement where the path stored in pathvar MVSIS variable is used to look up the path for name. Returns NULL if file cannot be opened.]

SideEffects []

SeeAlso []

Definition at line 707 of file ioUtil.c.

00708 {
00709     char * t = 0, * c = 0, * i;
00710     extern char * Abc_FrameReadFlag( char * pFlag ); 
00711 
00712     if ( PathVar == 0 )
00713     {
00714         return fopen( FileName, Mode );
00715     }
00716     else
00717     {
00718         if ( c = Abc_FrameReadFlag( (char*)PathVar ) )
00719         {
00720             char ActualFileName[4096];
00721             FILE * fp = 0;
00722             t = Extra_UtilStrsav( c );
00723             for (i = strtok( t, ":" ); i != 0; i = strtok( 0, ":") )
00724             {
00725 #ifdef WIN32
00726                 _snprintf ( ActualFileName, 4096, "%s/%s", i, FileName );
00727 #else
00728                 snprintf ( ActualFileName, 4096, "%s/%s", i, FileName );
00729 #endif
00730                 if ( ( fp = fopen ( ActualFileName, Mode ) ) )
00731                 {
00732                     if ( fVerbose )
00733                     fprintf ( stdout, "Using file %s\n", ActualFileName );
00734                     free( t );
00735                     return fp;
00736                 }
00737             }
00738             free( t );
00739             return 0;
00740         }
00741         else
00742         {
00743             return fopen( FileName, Mode );
00744         }
00745     }
00746 }

Abc_Ntk_t* Io_Read ( char *  pFileName,
Io_FileType_t  FileType,
int  fCheck 
)

Function*************************************************************

Synopsis [Read the network from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file ioUtil.c.

00168 {
00169     Abc_Ntk_t * pNtk, * pTemp;
00170     // get the netlist
00171     pNtk = Io_ReadNetlist( pFileName, FileType, fCheck );
00172     if ( pNtk == NULL )
00173         return NULL;
00174     if ( !Abc_NtkIsNetlist(pNtk) )
00175         return pNtk;
00176     // flatten logic hierarchy
00177     assert( Abc_NtkIsNetlist(pNtk) );
00178     if ( Abc_NtkWhiteboxNum(pNtk) > 0 )
00179     {
00180         pNtk = Abc_NtkFlattenLogicHierarchy( pTemp = pNtk );
00181         Abc_NtkDelete( pTemp );
00182         if ( pNtk == NULL )
00183         {
00184             fprintf( stdout, "Flattening logic hierarchy has failed.\n" );
00185             return NULL;
00186         }
00187     }
00188     // convert blackboxes
00189     if ( Abc_NtkBlackboxNum(pNtk) > 0 )
00190     {
00191         printf( "Hierarchy reader converted %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtk) );
00192         pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk );
00193         Abc_NtkDelete( pTemp );
00194         if ( pNtk == NULL )
00195         {
00196             fprintf( stdout, "Converting blackboxes has failed.\n" );
00197             return NULL;
00198         }
00199     }
00200     // consider the case of BLIF-MV
00201     if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
00202     {
00203 //Abc_NtkPrintStats( stdout, pNtk, 0 );
00204 //    Io_WriteBlifMv( pNtk, "_temp_.mv" );
00205         pNtk = Abc_NtkStrashBlifMv( pTemp = pNtk );
00206         Abc_NtkDelete( pTemp );
00207         if ( pNtk == NULL )
00208         {
00209             fprintf( stdout, "Converting BLIF-MV to AIG has failed.\n" );
00210             return NULL;
00211         }
00212         return pNtk;
00213     }
00214     // convert the netlist into the logic network
00215     pNtk = Abc_NtkToLogic( pTemp = pNtk );
00216     Abc_NtkDelete( pTemp );
00217     if ( pNtk == NULL )
00218     {
00219         fprintf( stdout, "Converting netlist to logic network after reading has failed.\n" );
00220         return NULL;
00221     }
00222     return pNtk;
00223 }

Abc_Ntk_t* Io_ReadAiger ( char *  pFileName,
int  fCheck 
)

FUNCTION DECLARATIONS ///

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the AIG in the binary AIGER format.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ioReadAiger.c.

00046 {
00047     ProgressBar * pProgress;
00048     FILE * pFile;
00049     Vec_Ptr_t * vNodes, * vTerms;
00050     Abc_Obj_t * pObj, * pNode0, * pNode1;
00051     Abc_Ntk_t * pNtkNew;
00052     int nTotal, nInputs, nOutputs, nLatches, nAnds, nFileSize, iTerm, nDigits, i;
00053     char * pContents, * pDrivers, * pSymbols, * pCur, * pName, * pType;
00054     unsigned uLit0, uLit1, uLit;
00055 
00056     // read the file into the buffer
00057     nFileSize = Extra_FileSize( pFileName );
00058     pFile = fopen( pFileName, "rb" );
00059     pContents = ALLOC( char, nFileSize );
00060     fread( pContents, nFileSize, 1, pFile );
00061     fclose( pFile );
00062 
00063     // check if the input file format is correct
00064     if ( strncmp(pContents, "aig", 3) != 0 )
00065     {
00066         fprintf( stdout, "Wrong input file format.\n" );
00067         return NULL;
00068     }
00069 
00070     // allocate the empty AIG
00071     pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00072     pName = Extra_FileNameGeneric( pFileName );
00073     pNtkNew->pName = Extra_UtilStrsav( pName );
00074     pNtkNew->pSpec = Extra_UtilStrsav( pFileName );
00075     free( pName );
00076 
00077 
00078     // read the file type
00079     pCur = pContents;         while ( *pCur++ != ' ' );
00080     // read the number of objects
00081     nTotal = atoi( pCur );    while ( *pCur++ != ' ' );
00082     // read the number of inputs
00083     nInputs = atoi( pCur );   while ( *pCur++ != ' ' );
00084     // read the number of latches
00085     nLatches = atoi( pCur );  while ( *pCur++ != ' ' );
00086     // read the number of outputs
00087     nOutputs = atoi( pCur );  while ( *pCur++ != ' ' );
00088     // read the number of nodes
00089     nAnds = atoi( pCur );     while ( *pCur++ != '\n' );  
00090     // check the parameters
00091     if ( nTotal != nInputs + nLatches + nAnds )
00092     {
00093         fprintf( stdout, "The paramters are wrong.\n" );
00094         return NULL;
00095     }
00096 
00097     // prepare the array of nodes
00098     vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
00099     Vec_PtrPush( vNodes, Abc_ObjNot( Abc_AigConst1(pNtkNew) ) );
00100 
00101     // create the PIs
00102     for ( i = 0; i < nInputs; i++ )
00103     {
00104         pObj = Abc_NtkCreatePi(pNtkNew);    
00105         Vec_PtrPush( vNodes, pObj );
00106     }
00107     // create the POs
00108     for ( i = 0; i < nOutputs; i++ )
00109     {
00110         pObj = Abc_NtkCreatePo(pNtkNew);   
00111     }
00112     // create the latches
00113     nDigits = Extra_Base10Log( nLatches );
00114     for ( i = 0; i < nLatches; i++ )
00115     {
00116         pObj = Abc_NtkCreateLatch(pNtkNew);
00117         Abc_LatchSetInit0( pObj );
00118         pNode0 = Abc_NtkCreateBi(pNtkNew);
00119         pNode1 = Abc_NtkCreateBo(pNtkNew);
00120         Abc_ObjAddFanin( pObj, pNode0 );
00121         Abc_ObjAddFanin( pNode1, pObj );
00122         Vec_PtrPush( vNodes, pNode1 );
00123         // assign names to latch and its input
00124 //        Abc_ObjAssignName( pObj, Abc_ObjNameDummy("_L", i, nDigits), NULL );
00125 //        printf( "Creating latch %s with input %d and output %d.\n", Abc_ObjName(pObj), pNode0->Id, pNode1->Id );
00126     } 
00127     
00128     // remember the beginning of latch/PO literals
00129     pDrivers = pCur;
00130 
00131     // scroll to the beginning of the binary data
00132     for ( i = 0; i < nLatches + nOutputs; )
00133         if ( *pCur++ == '\n' )
00134             i++;
00135 
00136     // create the AND gates
00137     pProgress = Extra_ProgressBarStart( stdout, nAnds );
00138     for ( i = 0; i < nAnds; i++ )
00139     {
00140         Extra_ProgressBarUpdate( pProgress, i, NULL );
00141         uLit = ((i + 1 + nInputs + nLatches) << 1);
00142         uLit1 = uLit  - Io_ReadAigerDecode( &pCur );
00143         uLit0 = uLit1 - Io_ReadAigerDecode( &pCur );
00144 //        assert( uLit1 > uLit0 );
00145         pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
00146         pNode1 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
00147         assert( Vec_PtrSize(vNodes) == i + 1 + nInputs + nLatches );
00148         Vec_PtrPush( vNodes, Abc_AigAnd(pNtkNew->pManFunc, pNode0, pNode1) );
00149     }
00150     Extra_ProgressBarStop( pProgress );
00151 
00152     // remember the place where symbols begin
00153     pSymbols = pCur;
00154 
00155     // read the latch driver literals
00156     pCur = pDrivers;
00157     Abc_NtkForEachLatchInput( pNtkNew, pObj, i )
00158     {
00159         uLit0 = atoi( pCur );  while ( *pCur++ != '\n' );
00160         pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
00161         Abc_ObjAddFanin( pObj, pNode0 );
00162 
00163 //        printf( "Adding input %d to latch input %d.\n", pNode0->Id, pObj->Id );
00164 
00165     }
00166     // read the PO driver literals
00167     Abc_NtkForEachPo( pNtkNew, pObj, i )
00168     {
00169         uLit0 = atoi( pCur );  while ( *pCur++ != '\n' );
00170         pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
00171         Abc_ObjAddFanin( pObj, pNode0 );
00172     }
00173  
00174     // read the names if present
00175     pCur = pSymbols;
00176     if ( *pCur != 'c' )
00177     {
00178         int Counter = 0;
00179         while ( pCur < pContents + nFileSize && *pCur != 'c' )
00180         {
00181             // get the terminal type
00182             pType = pCur;
00183             if ( *pCur == 'i' )
00184                 vTerms = pNtkNew->vPis;
00185             else if ( *pCur == 'l' )
00186                 vTerms = pNtkNew->vBoxes;
00187             else if ( *pCur == 'o' )
00188                 vTerms = pNtkNew->vPos;
00189             else
00190             {
00191                 fprintf( stdout, "Wrong terminal type.\n" );
00192                 return NULL;
00193             }
00194             // get the terminal number
00195             iTerm = atoi( ++pCur );  while ( *pCur++ != ' ' );
00196             // get the node
00197             if ( iTerm >= Vec_PtrSize(vTerms) )
00198             {
00199                 fprintf( stdout, "The number of terminal is out of bound.\n" );
00200                 return NULL;
00201             }
00202             pObj = Vec_PtrEntry( vTerms, iTerm );
00203             if ( *pType == 'l' )
00204                 pObj = Abc_ObjFanout0(pObj);
00205             // assign the name
00206             pName = pCur;          while ( *pCur++ != '\n' );
00207             // assign this name 
00208             *(pCur-1) = 0;
00209             Abc_ObjAssignName( pObj, pName, NULL );
00210             if ( *pType == 'l' )
00211             {
00212                 Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
00213                 Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "_in" );
00214             }
00215             // mark the node as named
00216             pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
00217         } 
00218 
00219         // assign the remaining names
00220         Abc_NtkForEachPi( pNtkNew, pObj, i )
00221         {
00222             if ( pObj->pCopy ) continue;
00223             Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
00224             Counter++;
00225         }
00226         Abc_NtkForEachLatchOutput( pNtkNew, pObj, i )
00227         {
00228             if ( pObj->pCopy ) continue;
00229             Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
00230             Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
00231             Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "_in" );
00232             Counter++;
00233         }
00234         Abc_NtkForEachPo( pNtkNew, pObj, i )
00235         {
00236             if ( pObj->pCopy ) continue;
00237             Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
00238             Counter++;
00239         }
00240         if ( Counter )
00241             printf( "Io_ReadAiger(): Added %d default names for nameless I/O/register objects.\n", Counter );
00242     }
00243     else
00244     {
00245 //        printf( "Io_ReadAiger(): I/O/register names are not given. Generating short names.\n" );
00246         Abc_NtkShortNames( pNtkNew );
00247     }
00248 
00249     // read the name of the model if given
00250     if ( *pCur == 'c' )
00251     {
00252         if ( !strncmp( pCur + 2, ".model", 6 ) )
00253         {
00254             char * pTemp;
00255             for ( pTemp = pCur + 9; *pTemp && *pTemp != '\n'; pTemp++ );
00256             *pTemp = 0;
00257             free( pNtkNew->pName );
00258             pNtkNew->pName = Extra_UtilStrsav( pCur + 9 );
00259         }
00260     }
00261 
00262 
00263     // skipping the comments
00264     free( pContents );
00265     Vec_PtrFree( vNodes );
00266 
00267     // remove the extra nodes
00268     Abc_AigCleanup( pNtkNew->pManFunc );
00269 
00270     // check the result
00271     if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
00272     {
00273         printf( "Io_ReadAiger: The network check has failed.\n" );
00274         Abc_NtkDelete( pNtkNew );
00275         return NULL;
00276     }
00277     return pNtkNew;
00278 }

Abc_Ntk_t* Io_ReadBaf ( char *  pFileName,
int  fCheck 
)

CFile****************************************************************

FileName [ioReadBaf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to read AIG in the binary format.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
ioReadBaf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file ioReadBaf.c.

00043 {
00044     ProgressBar * pProgress;
00045     FILE * pFile;
00046     Vec_Ptr_t * vNodes;
00047     Abc_Obj_t * pObj, * pNode0, * pNode1;
00048     Abc_Ntk_t * pNtkNew;
00049     int nInputs, nOutputs, nLatches, nAnds, nFileSize, Num, i;
00050     char * pContents, * pName, * pCur;
00051     unsigned * pBufferNode;
00052 
00053     // read the file into the buffer
00054     nFileSize = Extra_FileSize( pFileName );
00055     pFile = fopen( pFileName, "rb" );
00056     pContents = ALLOC( char, nFileSize );
00057     fread( pContents, nFileSize, 1, pFile );
00058     fclose( pFile );
00059 
00060     // skip the comments (comment lines begin with '#' and end with '\n')
00061     for ( pCur = pContents; *pCur == '#'; )
00062         while ( *pCur++ != '\n' );
00063 
00064     // read the name
00065     pName = pCur;             while ( *pCur++ );
00066     // read the number of inputs
00067     nInputs = atoi( pCur );   while ( *pCur++ );
00068     // read the number of outputs
00069     nOutputs = atoi( pCur );  while ( *pCur++ );
00070     // read the number of latches
00071     nLatches = atoi( pCur );  while ( *pCur++ );
00072     // read the number of nodes
00073     nAnds = atoi( pCur );     while ( *pCur++ );
00074 
00075     // allocate the empty AIG
00076     pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
00077     pNtkNew->pName = Extra_UtilStrsav( pName );
00078     pNtkNew->pSpec = Extra_UtilStrsav( pFileName );
00079 
00080     // prepare the array of nodes
00081     vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
00082     Vec_PtrPush( vNodes, Abc_AigConst1(pNtkNew) );
00083 
00084     // create the PIs
00085     for ( i = 0; i < nInputs; i++ )
00086     {
00087         pObj = Abc_NtkCreatePi(pNtkNew);    
00088         Abc_ObjAssignName( pObj, pCur, NULL );  while ( *pCur++ );
00089         Vec_PtrPush( vNodes, pObj );
00090     }
00091     // create the POs
00092     for ( i = 0; i < nOutputs; i++ )
00093     {
00094         pObj = Abc_NtkCreatePo(pNtkNew);   
00095         Abc_ObjAssignName( pObj, pCur, NULL );  while ( *pCur++ ); 
00096     }
00097     // create the latches
00098     for ( i = 0; i < nLatches; i++ )
00099     {
00100         pObj = Abc_NtkCreateLatch(pNtkNew);
00101         Abc_ObjAssignName( pObj, pCur, NULL );  while ( *pCur++ ); 
00102 
00103         pNode0 = Abc_NtkCreateBi(pNtkNew);
00104         Abc_ObjAssignName( pNode0, pCur, NULL );  while ( *pCur++ ); 
00105 
00106         pNode1 = Abc_NtkCreateBo(pNtkNew);
00107         Abc_ObjAssignName( pNode1, pCur, NULL );  while ( *pCur++ ); 
00108         Vec_PtrPush( vNodes, pNode1 );
00109 
00110         Abc_ObjAddFanin( pObj, pNode0 );
00111         Abc_ObjAddFanin( pNode1, pObj );
00112     }
00113 
00114     // get the pointer to the beginning of the node array
00115     pBufferNode = (int *)(pContents + (nFileSize - (2 * nAnds + nOutputs + nLatches) * sizeof(int)) );
00116     // make sure we are at the place where the nodes begin
00117     if ( pBufferNode != (int *)pCur )
00118     {
00119         free( pContents );
00120         Vec_PtrFree( vNodes );
00121         Abc_NtkDelete( pNtkNew );
00122         printf( "Warning: Internal reader error.\n" );
00123         return NULL;
00124     }
00125 
00126     // create the AND gates
00127     pProgress = Extra_ProgressBarStart( stdout, nAnds );
00128     for ( i = 0; i < nAnds; i++ )
00129     {
00130         Extra_ProgressBarUpdate( pProgress, i, NULL );
00131         pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, pBufferNode[2*i+0] >> 1), pBufferNode[2*i+0] & 1 );
00132         pNode1 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, pBufferNode[2*i+1] >> 1), pBufferNode[2*i+1] & 1 );
00133         Vec_PtrPush( vNodes, Abc_AigAnd(pNtkNew->pManFunc, pNode0, pNode1) );
00134     }
00135     Extra_ProgressBarStop( pProgress );
00136 
00137     // read the POs
00138     Abc_NtkForEachCo( pNtkNew, pObj, i )
00139     {
00140         Num = pBufferNode[2*nAnds+i];
00141         if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
00142         {
00143             Abc_ObjSetData( Abc_ObjFanout0(pObj), (void *)(Num & 3) );
00144             Num >>= 2;
00145         }
00146         pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, Num >> 1), Num & 1 );
00147         Abc_ObjAddFanin( pObj, pNode0 );
00148     }
00149     free( pContents );
00150     Vec_PtrFree( vNodes );
00151 
00152     // remove the extra nodes
00153 //    Abc_AigCleanup( pNtkNew->pManFunc );
00154 
00155     // check the result
00156     if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
00157     {
00158         printf( "Io_ReadBaf: The network check has failed.\n" );
00159         Abc_NtkDelete( pNtkNew );
00160         return NULL;
00161     }
00162     return pNtkNew;
00163 
00164 }

Abc_Ntk_t* Io_ReadBench ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the network from a BENCH file.]

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file ioReadBench.c.

00045 {
00046     Extra_FileReader_t * p;
00047     Abc_Ntk_t * pNtk;
00048 
00049     // start the file
00050     p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t,()=" );
00051     if ( p == NULL )
00052         return NULL;
00053 
00054     // read the network
00055     pNtk = Io_ReadBenchNetwork( p );
00056     Extra_FileReaderFree( p );
00057     if ( pNtk == NULL )
00058         return NULL;
00059 
00060     // make sure that everything is okay with the network structure
00061     if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
00062     {
00063         printf( "Io_ReadBench: The network check has failed.\n" );
00064         Abc_NtkDelete( pNtk );
00065         return NULL;
00066     }
00067     return pNtk;
00068 }

Abc_Ntk_t* Io_ReadBlif ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the (hierarchical) network from the BLIF file.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file ioReadBlif.c.

00084 {
00085     Io_ReadBlif_t * p;
00086     Abc_Ntk_t * pNtk;
00087 
00088     // start the file
00089     p = Io_ReadBlifFile( pFileName );
00090     if ( p == NULL )
00091         return NULL;
00092 
00093     // read the hierarchical network
00094     pNtk = Io_ReadBlifNetwork( p );
00095     if ( pNtk == NULL )
00096     {
00097         Io_ReadBlifFree( p );
00098         return NULL;
00099     }
00100     pNtk->pSpec = Extra_UtilStrsav( pFileName );
00101     Abc_NtkTimeInitialize( pNtk );
00102     Io_ReadBlifFree( p );
00103 
00104     // make sure that everything is okay with the network structure
00105     if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
00106     {
00107         printf( "Io_ReadBlif: The network check has failed.\n" );
00108         Abc_NtkDelete( pNtk );
00109         return NULL;
00110     }
00111     return pNtk;
00112 }

Abc_Ntk_t* Io_ReadBlifMv ( char *  pFileName,
int  fBlifMv,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the network from the BLIF or BLIF-MV file.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file ioReadBlifMv.c.

00127 {
00128     FILE * pFile;
00129     Io_MvMan_t * p;
00130     Abc_Ntk_t * pNtk;
00131     Abc_Lib_t * pDesign;
00132     char * pDesignName;
00133     int RetValue, i;
00134 
00135     // check that the file is available
00136     pFile = fopen( pFileName, "rb" );
00137     if ( pFile == NULL )
00138     {
00139         printf( "Io_ReadBlifMv(): The file is unavailable (absent or open).\n" );
00140         return 0;
00141     }
00142     fclose( pFile );
00143 
00144     // start the file reader
00145     p = Io_MvAlloc();
00146     p->fBlifMv   = fBlifMv;
00147     p->fUseReset = 0;
00148     p->pFileName = pFileName;
00149     p->pBuffer   = Io_MvLoadFile( pFileName );
00150     if ( p->pBuffer == NULL )
00151     {
00152         Io_MvFree( p );
00153         return NULL;
00154     }
00155     // set the design name
00156     pDesignName  = Extra_FileNameGeneric( pFileName );
00157     p->pDesign   = Abc_LibCreate( pDesignName );
00158     free( pDesignName );
00159     // free the HOP manager
00160     Hop_ManStop( p->pDesign->pManFunc );
00161     p->pDesign->pManFunc = NULL;
00162     // prepare the file for parsing
00163     Io_MvReadPreparse( p );
00164     // parse interfaces of each network
00165     Io_MvReadInterfaces( p );
00166     // construct the network
00167     pDesign = Io_MvParse( p );
00168     if ( p->sError[0] )
00169         fprintf( stdout, "%s\n", p->sError );
00170     if ( pDesign == NULL )
00171         return NULL;
00172     Io_MvFree( p );
00173 // pDesign should be linked to all models of the design
00174 
00175     // make sure that everything is okay with the network structure
00176     if ( fCheck )
00177     {
00178         Vec_PtrForEachEntry( pDesign->vModules, pNtk, i )
00179         {
00180             if ( !Abc_NtkCheckRead( pNtk ) )
00181             {
00182                 printf( "Io_ReadBlifMv: The network check has failed for network %s.\n", pNtk->pName );
00183                 Abc_LibFree( pDesign, NULL );
00184                 return NULL;
00185             }
00186         }
00187     }
00188 
00189 //Abc_LibPrint( pDesign );
00190 
00191     // detect top-level model
00192     RetValue = Abc_LibFindTopLevelModels( pDesign );
00193     pNtk = Vec_PtrEntry( pDesign->vTops, 0 );
00194     if ( RetValue > 1 )
00195         printf( "Warning: The design has %d root-level modules. The first one (%s) will be used.\n",
00196             Vec_PtrSize(pDesign->vTops), pNtk->pName );
00197 
00198     // extract the master network
00199     pNtk->pDesign = pDesign;
00200     pDesign->pManFunc = NULL;
00201 
00202     // verify the design for cyclic dependence
00203     assert( Vec_PtrSize(pDesign->vModules) > 0 );
00204     if ( Vec_PtrSize(pDesign->vModules) == 1 )
00205     {
00206 //        printf( "Warning: The design is not hierarchical.\n" );
00207         Abc_LibFree( pDesign, pNtk );
00208         pNtk->pDesign = NULL;
00209         pNtk->pSpec = Extra_UtilStrsav( pFileName );
00210     }
00211     else
00212         Abc_NtkIsAcyclicHierarchy( pNtk );
00213 
00214 //Io_WriteBlifMv( pNtk, "_temp_.mv" );
00215     if ( pNtk->pSpec == NULL )
00216         pNtk->pSpec = Extra_UtilStrsav( pFileName );
00217     return pNtk;
00218 }

Abc_Obj_t* Io_ReadCreateAssert ( Abc_Ntk_t pNtk,
char *  pName 
)

Function*************************************************************

Synopsis [Creates PO terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 523 of file ioUtil.c.

00524 {
00525     Abc_Obj_t * pNet, * pTerm;
00526     // get the PO net
00527     pNet  = Abc_NtkFindNet( pNtk, pName );
00528     if ( pNet && Abc_ObjFaninNum(pNet) == 0 )
00529         printf( "Warning: Assert \"%s\" appears twice in the list.\n", pName );
00530     pNet  = Abc_NtkFindOrCreateNet( pNtk, pName );
00531     // add the PO node
00532     pTerm = Abc_NtkCreateAssert( pNtk );
00533     Abc_ObjAddFanin( pTerm, pNet );
00534     return pTerm;
00535 }

Abc_Obj_t* Io_ReadCreateBuf ( Abc_Ntk_t pNtk,
char *  pNameIn,
char *  pNameOut 
)

Function*************************************************************

Synopsis [Create an inverter or buffer for the given net.]

Description [Assumes that the nets already exist.]

SideEffects []

SeeAlso []

Definition at line 683 of file ioUtil.c.

00684 {
00685     Abc_Obj_t * pNet, * pNode;
00686     pNet  = Abc_NtkFindNet(pNtk, pNameIn);     assert( pNet );
00687     pNode = Abc_NtkCreateNodeBuf(pNtk, pNet);
00688     pNet  = Abc_NtkFindNet(pNtk, pNameOut);    assert( pNet );
00689     Abc_ObjAddFanin( pNet, pNode );
00690     return pNet;
00691 }

Abc_Obj_t* Io_ReadCreateConst ( Abc_Ntk_t pNtk,
char *  pName,
bool  fConst1 
)

Function*************************************************************

Synopsis [Create a constant 0 node driving the net with this name.]

Description [Assumes that the net already exists.]

SideEffects []

SeeAlso []

Definition at line 642 of file ioUtil.c.

00643 {
00644     Abc_Obj_t * pNet, * pTerm;
00645     pTerm = fConst1? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
00646     pNet  = Abc_NtkFindNet(pNtk, pName);    assert( pNet );
00647     Abc_ObjAddFanin( pNet, pTerm );
00648     return pTerm;
00649 }

Abc_Obj_t* Io_ReadCreateInv ( Abc_Ntk_t pNtk,
char *  pNameIn,
char *  pNameOut 
)

Function*************************************************************

Synopsis [Create an inverter or buffer for the given net.]

Description [Assumes that the nets already exist.]

SideEffects []

SeeAlso []

Definition at line 662 of file ioUtil.c.

00663 {
00664     Abc_Obj_t * pNet, * pNode;
00665     pNet  = Abc_NtkFindNet(pNtk, pNameIn);     assert( pNet );
00666     pNode = Abc_NtkCreateNodeInv(pNtk, pNet);
00667     pNet  = Abc_NtkFindNet(pNtk, pNameOut);    assert( pNet );
00668     Abc_ObjAddFanin( pNet, pNode );
00669     return pNode;
00670 }

Abc_Obj_t* Io_ReadCreateLatch ( Abc_Ntk_t pNtk,
char *  pNetLI,
char *  pNetLO 
)

Function*************************************************************

Synopsis [Create a latch with the given input/output.]

Description [By default, the latch value is unknown (ABC_INIT_NONE).]

SideEffects []

SeeAlso []

Definition at line 548 of file ioUtil.c.

00549 {
00550     Abc_Obj_t * pLatch, * pTerm, * pNet;
00551     // get the LI net
00552     pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLI );
00553     // add the BO terminal
00554     pTerm = Abc_NtkCreateBi( pNtk );
00555     Abc_ObjAddFanin( pTerm, pNet );
00556     // add the latch box
00557     pLatch = Abc_NtkCreateLatch( pNtk );
00558     Abc_ObjAddFanin( pLatch, pTerm  );
00559     // add the BI terminal
00560     pTerm = Abc_NtkCreateBo( pNtk );
00561     Abc_ObjAddFanin( pTerm, pLatch );
00562     // get the LO net
00563     pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO );
00564     Abc_ObjAddFanin( pNet, pTerm );
00565     // set latch name
00566     Abc_ObjAssignName( pLatch, pNetLO, "L" );
00567     return pLatch;
00568 }

Abc_Obj_t* Io_ReadCreateNode ( Abc_Ntk_t pNtk,
char *  pNameOut,
char *  pNamesIn[],
int  nInputs 
)

Function*************************************************************

Synopsis [Create node and the net driven by it.]

Description []

SideEffects []

SeeAlso []

Definition at line 613 of file ioUtil.c.

00614 {
00615     Abc_Obj_t * pNet, * pNode;
00616     int i;
00617     // create a new node 
00618     pNode = Abc_NtkCreateNode( pNtk );
00619     // add the fanin nets
00620     for ( i = 0; i < nInputs; i++ )
00621     {
00622         pNet = Abc_NtkFindOrCreateNet( pNtk, pNamesIn[i] );
00623         Abc_ObjAddFanin( pNode, pNet );
00624     }
00625     // add the fanout net
00626     pNet = Abc_NtkFindOrCreateNet( pNtk, pNameOut );
00627     Abc_ObjAddFanin( pNet, pNode );
00628     return pNode;
00629 }

Abc_Obj_t* Io_ReadCreatePi ( Abc_Ntk_t pNtk,
char *  pName 
)

Function*************************************************************

Synopsis [Creates PI terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 473 of file ioUtil.c.

00474 {
00475     Abc_Obj_t * pNet, * pTerm;
00476     // get the PI net
00477     pNet  = Abc_NtkFindNet( pNtk, pName );
00478     if ( pNet )
00479         printf( "Warning: PI \"%s\" appears twice in the list.\n", pName );
00480     pNet  = Abc_NtkFindOrCreateNet( pNtk, pName );
00481     // add the PI node
00482     pTerm = Abc_NtkCreatePi( pNtk );
00483     Abc_ObjAddFanin( pNet, pTerm );
00484     return pTerm;
00485 }

Abc_Obj_t* Io_ReadCreatePo ( Abc_Ntk_t pNtk,
char *  pName 
)

Function*************************************************************

Synopsis [Creates PO terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 498 of file ioUtil.c.

00499 {
00500     Abc_Obj_t * pNet, * pTerm;
00501     // get the PO net
00502     pNet  = Abc_NtkFindNet( pNtk, pName );
00503     if ( pNet && Abc_ObjFaninNum(pNet) == 0 )
00504         printf( "Warning: PO \"%s\" appears twice in the list.\n", pName );
00505     pNet  = Abc_NtkFindOrCreateNet( pNtk, pName );
00506     // add the PO node
00507     pTerm = Abc_NtkCreatePo( pNtk );
00508     Abc_ObjAddFanin( pTerm, pNet );
00509     return pTerm;
00510 }

Abc_Obj_t* Io_ReadCreateResetLatch ( Abc_Ntk_t pNtk,
int  fBlifMv 
)

Function*************************************************************

Synopsis [Create the reset latch with data=1 and init=0.]

Description []

SideEffects []

SeeAlso []

Definition at line 581 of file ioUtil.c.

00582 {
00583     Abc_Obj_t * pLatch, * pNode;
00584     Abc_Obj_t * pNetLI, * pNetLO;
00585     // create latch with 0 init value
00586 //    pLatch = Io_ReadCreateLatch( pNtk, "_resetLI_", "_resetLO_" );
00587     pNetLI = Abc_NtkCreateNet( pNtk );
00588     pNetLO = Abc_NtkCreateNet( pNtk );
00589     Abc_ObjAssignName( pNetLI, Abc_ObjName(pNetLI), NULL );
00590     Abc_ObjAssignName( pNetLO, Abc_ObjName(pNetLO), NULL );
00591     pLatch = Io_ReadCreateLatch( pNtk, Abc_ObjName(pNetLI), Abc_ObjName(pNetLO) );
00592     // set the initial value
00593     Abc_LatchSetInit0( pLatch );
00594     // feed the latch with constant1- node
00595 //    pNode = Abc_NtkCreateNode( pNtk );   
00596 //    pNode->pData = Abc_SopRegister( pNtk->pManFunc, "2\n1\n" );
00597     pNode = Abc_NtkCreateNodeConst1( pNtk );
00598     Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pNode );
00599     return pLatch;
00600 }

Abc_Obj_t* Io_ReadCreateResetMux ( Abc_Ntk_t pNtk,
char *  pResetLO,
char *  pDataLI,
int  fBlifMv 
)
Abc_Ntk_t* Io_ReadEdif ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the network from an EDIF file.]

Description [Works only for the ISCAS benchmarks.]

SideEffects []

SeeAlso []

Definition at line 44 of file ioReadEdif.c.

00045 {
00046     Extra_FileReader_t * p;
00047     Abc_Ntk_t * pNtk;
00048 
00049     printf( "Currently this parser does not work!\n" );
00050     return NULL;
00051 
00052     // start the file
00053     p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t()" );
00054     if ( p == NULL )
00055         return NULL;
00056 
00057     // read the network
00058     pNtk = Io_ReadEdifNetwork( p );
00059     Extra_FileReaderFree( p );
00060     if ( pNtk == NULL )
00061         return NULL;
00062 
00063     // make sure that everything is okay with the network structure
00064     if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
00065     {
00066         printf( "Io_ReadEdif: The network check has failed.\n" );
00067         Abc_NtkDelete( pNtk );
00068         return NULL;
00069     }
00070     return pNtk;
00071 }

Abc_Ntk_t* Io_ReadEqn ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the network from a BENCH file.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioReadEqn.c.

00048 {
00049     Extra_FileReader_t * p;
00050     Abc_Ntk_t * pNtk;
00051 
00052     // start the file
00053     p = Extra_FileReaderAlloc( pFileName, "#", ";", "=" );
00054     if ( p == NULL )
00055         return NULL;
00056 
00057     // read the network
00058     pNtk = Io_ReadEqnNetwork( p );
00059     Extra_FileReaderFree( p );
00060     if ( pNtk == NULL )
00061         return NULL;
00062 
00063     // make sure that everything is okay with the network structure
00064     if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
00065     {
00066         printf( "Io_ReadEqn: The network check has failed.\n" );
00067         Abc_NtkDelete( pNtk );
00068         return NULL;
00069     }
00070     return pNtk;
00071 }

Io_FileType_t Io_ReadFileType ( char *  pFileName  ) 

CFile****************************************************************

FileName [ioUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write the network in BENCH format.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
ioUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Returns the file type.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file ioUtil.c.

00043 {
00044     char * pExt;
00045     if ( pFileName == NULL )
00046         return IO_FILE_NONE;
00047     pExt = Extra_FileNameExtension( pFileName );
00048     if ( pExt == NULL )
00049         return IO_FILE_NONE;
00050     if ( !strcmp( pExt, "aig" ) )
00051         return IO_FILE_AIGER;
00052     if ( !strcmp( pExt, "baf" ) )
00053         return IO_FILE_BAF;
00054     if ( !strcmp( pExt, "blif" ) )
00055         return IO_FILE_BLIF;
00056     if ( !strcmp( pExt, "bench" ) )
00057         return IO_FILE_BENCH;
00058     if ( !strcmp( pExt, "cnf" ) )
00059         return IO_FILE_CNF;
00060     if ( !strcmp( pExt, "dot" ) )
00061         return IO_FILE_DOT;
00062     if ( !strcmp( pExt, "edif" ) )
00063         return IO_FILE_EDIF;
00064     if ( !strcmp( pExt, "eqn" ) )
00065         return IO_FILE_EQN;
00066     if ( !strcmp( pExt, "gml" ) )
00067         return IO_FILE_GML;
00068     if ( !strcmp( pExt, "list" ) )
00069         return IO_FILE_LIST;
00070     if ( !strcmp( pExt, "mv" ) )
00071         return IO_FILE_BLIFMV;
00072     if ( !strcmp( pExt, "pla" ) )
00073         return IO_FILE_PLA;
00074     if ( !strcmp( pExt, "v" ) )
00075         return IO_FILE_VERILOG;
00076     return IO_FILE_UNKNOWN;
00077 }

Abc_Ntk_t* Io_ReadNetlist ( char *  pFileName,
Io_FileType_t  FileType,
int  fCheck 
)

Function*************************************************************

Synopsis [Read the network from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file ioUtil.c.

00091 {
00092     FILE * pFile;
00093     Abc_Ntk_t * pNtk;
00094     if ( FileType == IO_FILE_NONE || FileType == IO_FILE_UNKNOWN )
00095     {
00096         fprintf( stdout, "The generic file reader requires a known file extension.\n" );
00097         return NULL;
00098     }
00099     // check if the file exists
00100     pFile = fopen( pFileName, "r" );
00101     if ( pFile == NULL )
00102     {
00103         fprintf( stdout, "Cannot open input file \"%s\". ", pFileName );
00104         if ( pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" ) )
00105             fprintf( stdout, "Did you mean \"%s\"?", pFileName );
00106         fprintf( stdout, "\n" );
00107        return NULL;
00108     }
00109     fclose( pFile );
00110     // read the AIG
00111     if ( FileType == IO_FILE_AIGER || FileType == IO_FILE_BAF )
00112     {
00113         if ( FileType == IO_FILE_AIGER )
00114             pNtk = Io_ReadAiger( pFileName, fCheck );
00115         else // if ( FileType == IO_FILE_BAF )
00116             pNtk = Io_ReadBaf( pFileName, fCheck );
00117         if ( pNtk == NULL )
00118         {
00119             fprintf( stdout, "Reading AIG from file has failed.\n" );
00120             return NULL;
00121         }
00122         return pNtk;
00123     }
00124     // read the new netlist
00125     if ( FileType == IO_FILE_BLIF )
00126 //        pNtk = Io_ReadBlif( pFileName, fCheck );
00127         pNtk = Io_ReadBlifMv( pFileName, 0, fCheck );
00128     else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
00129         pNtk = Io_ReadBlifMv( pFileName, 1, fCheck );
00130     else if ( FileType == IO_FILE_BENCH )
00131         pNtk = Io_ReadBench( pFileName, fCheck );
00132     else if ( FileType == IO_FILE_EDIF )
00133         pNtk = Io_ReadEdif( pFileName, fCheck );
00134     else if ( FileType == IO_FILE_EQN )
00135         pNtk = Io_ReadEqn( pFileName, fCheck );
00136     else if ( FileType == IO_FILE_PLA )
00137         pNtk = Io_ReadPla( pFileName, fCheck );
00138     else if ( FileType == IO_FILE_VERILOG )
00139         pNtk = Io_ReadVerilog( pFileName, fCheck );
00140     else 
00141     {
00142         fprintf( stderr, "Unknown file format.\n" );
00143         return NULL;
00144     }
00145     if ( pNtk == NULL )
00146     {
00147         fprintf( stdout, "Reading network from file has failed.\n" );
00148         return NULL;
00149     }
00150     if ( Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk) )
00151         fprintf( stdout, "Warning: The network contains hierarchy.\n" );
00152     return pNtk;
00153 }

Abc_Ntk_t* Io_ReadPla ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads the network from a PLA file.]

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file ioReadPla.c.

00045 {
00046     Extra_FileReader_t * p;
00047     Abc_Ntk_t * pNtk;
00048 
00049     // start the file
00050     p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t|" );
00051     if ( p == NULL )
00052         return NULL;
00053 
00054     // read the network
00055     pNtk = Io_ReadPlaNetwork( p );
00056     Extra_FileReaderFree( p );
00057     if ( pNtk == NULL )
00058         return NULL;
00059 
00060     // make sure that everything is okay with the network structure
00061     if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
00062     {
00063         printf( "Io_ReadPla: The network check has failed.\n" );
00064         Abc_NtkDelete( pNtk );
00065         return NULL;
00066     }
00067     return pNtk;
00068 }

Abc_Ntk_t* Io_ReadVerilog ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Reads hierarchical design from the Verilog file.]

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file ioReadVerilog.c.

00045 {
00046     Abc_Ntk_t * pNtk;
00047     Abc_Lib_t * pDesign;
00048     int RetValue;
00049 
00050     // parse the verilog file
00051     pDesign = Ver_ParseFile( pFileName, NULL, fCheck, 1 );
00052     if ( pDesign == NULL )
00053         return NULL;
00054 
00055     // detect top-level model
00056     RetValue = Abc_LibFindTopLevelModels( pDesign );
00057     pNtk = Vec_PtrEntry( pDesign->vTops, 0 );
00058     if ( RetValue > 1 )
00059         printf( "Warning: The design has %d root-level modules. The first one (%s) will be used.\n",
00060             Vec_PtrSize(pDesign->vTops), pNtk->pName );
00061 
00062     // extract the master network
00063     pNtk->pDesign = pDesign;
00064     pDesign->pManFunc = NULL;
00065 
00066     // verify the design for cyclic dependence
00067     assert( Vec_PtrSize(pDesign->vModules) > 0 );
00068     if ( Vec_PtrSize(pDesign->vModules) == 1 )
00069     {
00070 //        printf( "Warning: The design is not hierarchical.\n" );
00071         Abc_LibFree( pDesign, pNtk );
00072         pNtk->pDesign = NULL;
00073         pNtk->pSpec = Extra_UtilStrsav( pFileName );
00074     }
00075     else
00076     {
00077         // check that there is no cyclic dependency
00078         Abc_NtkIsAcyclicHierarchy( pNtk );
00079     }
00080 
00081 //Io_WriteVerilog( pNtk, "_temp.v" );
00082     return pNtk;
00083 }

void Io_Write ( Abc_Ntk_t pNtk,
char *  pFileName,
Io_FileType_t  FileType 
)

Function*************************************************************

Synopsis [Write the network into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file ioUtil.c.

00237 {
00238     Abc_Ntk_t * pNtkTemp, * pNtkCopy;
00239     // check if the current network is available
00240     if ( pNtk == NULL )
00241     {
00242         fprintf( stdout, "Empty network.\n" );
00243         return;
00244     }
00245     // check if the file extension if given
00246     if ( FileType == IO_FILE_NONE || FileType == IO_FILE_UNKNOWN )
00247     {
00248         fprintf( stdout, "The generic file writer requires a known file extension.\n" );
00249         return;
00250     }
00251     // write the AIG formats
00252     if ( FileType == IO_FILE_AIGER || FileType == IO_FILE_BAF )
00253     {
00254         if ( !Abc_NtkIsStrash(pNtk) )
00255         {
00256             fprintf( stdout, "Writing this format is only possible for structurally hashed AIGs.\n" );
00257             return;
00258         }
00259         if ( FileType == IO_FILE_AIGER )
00260             Io_WriteAiger( pNtk, pFileName, 1 );
00261         else // if ( FileType == IO_FILE_BAF )
00262             Io_WriteBaf( pNtk, pFileName );
00263         return;
00264     }
00265     // write non-netlist types
00266     if ( FileType == IO_FILE_CNF )
00267     {
00268         Io_WriteCnf( pNtk, pFileName, 0 );
00269         return;
00270     }
00271     if ( FileType == IO_FILE_DOT )
00272     {
00273         Io_WriteDot( pNtk, pFileName );
00274         return;
00275     }
00276     if ( FileType == IO_FILE_GML )
00277     {
00278         Io_WriteGml( pNtk, pFileName );
00279         return;
00280     }
00281 /*
00282     if ( FileType == IO_FILE_BLIFMV )
00283     {
00284         Io_WriteBlifMv( pNtk, pFileName );
00285         return;
00286     }
00287 */
00288     // convert logic network into netlist
00289     if ( FileType == IO_FILE_PLA )
00290     {
00291         if ( Abc_NtkLevel(pNtk) > 1 )
00292         {
00293             fprintf( stdout, "PLA writing is available for collapsed networks.\n" );
00294             return;
00295         }
00296         if ( Abc_NtkIsComb(pNtk) )
00297             pNtkTemp = Abc_NtkToNetlist( pNtk );
00298         else
00299         {
00300             fprintf( stdout, "Latches are writen into the PLA file at PI/PO pairs.\n" );
00301             pNtkCopy = Abc_NtkDup( pNtk );
00302             Abc_NtkMakeComb( pNtkCopy );
00303             pNtkTemp = Abc_NtkToNetlist( pNtk );
00304             Abc_NtkDelete( pNtkCopy );
00305         }
00306         if ( !Abc_NtkToSop( pNtk, 1 ) )
00307             return;
00308     }
00309     else if ( FileType == IO_FILE_BENCH )
00310     {
00311         if ( !Abc_NtkIsStrash(pNtk) )
00312         {
00313             fprintf( stdout, "Writing traditional BENCH is available for AIGs only (use \"write_bench\").\n" );
00314             return;
00315         }
00316         pNtkTemp = Abc_NtkToNetlistBench( pNtk );
00317     }
00318     else
00319         pNtkTemp = Abc_NtkToNetlist( pNtk );
00320 
00321     if ( pNtkTemp == NULL )
00322     {
00323         fprintf( stdout, "Converting to netlist has failed.\n" );
00324         return;
00325     }
00326 
00327     if ( FileType == IO_FILE_BLIF )
00328     {
00329         if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
00330             Abc_NtkToSop( pNtkTemp, 0 );
00331         Io_WriteBlif( pNtkTemp, pFileName, 1 );
00332     }
00333     else if ( FileType == IO_FILE_BLIFMV )
00334     {
00335         if ( !Abc_NtkConvertToBlifMv( pNtkTemp ) )
00336             return;
00337         Io_WriteBlifMv( pNtkTemp, pFileName );
00338     }
00339     else if ( FileType == IO_FILE_BENCH )
00340         Io_WriteBench( pNtkTemp, pFileName );
00341     else if ( FileType == IO_FILE_PLA )
00342         Io_WritePla( pNtkTemp, pFileName );
00343     else if ( FileType == IO_FILE_EQN )
00344     {
00345         if ( !Abc_NtkHasAig(pNtkTemp) )
00346             Abc_NtkToAig( pNtkTemp );
00347         Io_WriteEqn( pNtkTemp, pFileName );
00348     }
00349     else if ( FileType == IO_FILE_VERILOG )
00350     {
00351         if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
00352             Abc_NtkToAig( pNtkTemp );
00353         Io_WriteVerilog( pNtkTemp, pFileName );
00354     }
00355     else 
00356         fprintf( stderr, "Unknown file format.\n" );
00357     Abc_NtkDelete( pNtkTemp );
00358 }

void Io_WriteAiger ( Abc_Ntk_t pNtk,
char *  pFileName,
int  fWriteSymbols 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the AIG in the binary AIGER format.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file ioWriteAiger.c.

00150 {
00151     ProgressBar * pProgress;
00152     FILE * pFile;
00153     Abc_Obj_t * pObj, * pDriver;
00154     int i, nNodes, Pos, nBufferSize;
00155     unsigned char * pBuffer;
00156     unsigned uLit0, uLit1, uLit;
00157 
00158     assert( Abc_NtkIsStrash(pNtk) );
00159     // start the output stream
00160     pFile = fopen( pFileName, "wb" );
00161     if ( pFile == NULL )
00162     {
00163         fprintf( stdout, "Io_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
00164         return;
00165     }
00166     Abc_NtkForEachLatch( pNtk, pObj, i )
00167         if ( !Abc_LatchIsInit0(pObj) )
00168         {
00169             fprintf( stdout, "Io_WriteAiger(): Cannot write AIGER format with non-0 latch init values. Run \"zero\".\n" );
00170             return;
00171         }
00172 
00173     // set the node numbers to be used in the output file
00174     nNodes = 0;
00175     Io_ObjSetAigerNum( Abc_AigConst1(pNtk), nNodes++ );
00176     Abc_NtkForEachCi( pNtk, pObj, i )
00177         Io_ObjSetAigerNum( pObj, nNodes++ );
00178     Abc_AigForEachAnd( pNtk, pObj, i )
00179         Io_ObjSetAigerNum( pObj, nNodes++ );
00180 
00181     // write the header "M I L O A" where M = I + L + A
00182     fprintf( pFile, "aig %u %u %u %u %u\n", 
00183         Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) + Abc_NtkNodeNum(pNtk), 
00184         Abc_NtkPiNum(pNtk),
00185         Abc_NtkLatchNum(pNtk),
00186         Abc_NtkPoNum(pNtk),
00187         Abc_NtkNodeNum(pNtk) );
00188 
00189     // if the driver node is a constant, we need to complement the literal below
00190     // because, in the AIGER format, literal 0/1 is represented as number 0/1
00191     // while, in ABC, constant 1 node has number 0 and so literal 0/1 will be 1/0
00192 
00193     // write latch drivers
00194     Abc_NtkForEachLatchInput( pNtk, pObj, i )
00195     {
00196         pDriver = Abc_ObjFanin0(pObj);
00197         fprintf( pFile, "%u\n", Io_ObjMakeLit( Io_ObjAigerNum(pDriver), Abc_ObjFaninC0(pObj) ^ (Io_ObjAigerNum(pDriver) == 0) ) );
00198     }
00199 
00200     // write PO drivers
00201     Abc_NtkForEachPo( pNtk, pObj, i )
00202     {
00203         pDriver = Abc_ObjFanin0(pObj);
00204         fprintf( pFile, "%u\n", Io_ObjMakeLit( Io_ObjAigerNum(pDriver), Abc_ObjFaninC0(pObj) ^ (Io_ObjAigerNum(pDriver) == 0) ) );
00205     }
00206 
00207     // write the nodes into the buffer
00208     Pos = 0;
00209     nBufferSize = 6 * Abc_NtkNodeNum(pNtk) + 100; // skeptically assuming 3 chars per one AIG edge
00210     pBuffer = ALLOC( char, nBufferSize );
00211     pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
00212     Abc_AigForEachAnd( pNtk, pObj, i )
00213     {
00214         Extra_ProgressBarUpdate( pProgress, i, NULL );
00215         uLit  = Io_ObjMakeLit( Io_ObjAigerNum(pObj), 0 );
00216         uLit0 = Io_ObjMakeLit( Io_ObjAigerNum(Abc_ObjFanin0(pObj)), Abc_ObjFaninC0(pObj) );
00217         uLit1 = Io_ObjMakeLit( Io_ObjAigerNum(Abc_ObjFanin1(pObj)), Abc_ObjFaninC1(pObj) );
00218         assert( uLit0 < uLit1 );
00219         Pos = Io_WriteAigerEncode( pBuffer, Pos, uLit  - uLit1 );
00220         Pos = Io_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
00221         if ( Pos > nBufferSize - 10 )
00222         {
00223             printf( "Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
00224                 fclose( pFile );
00225             return;
00226         }
00227     }
00228     assert( Pos < nBufferSize );
00229     Extra_ProgressBarStop( pProgress );
00230 
00231     // write the buffer
00232     fwrite( pBuffer, 1, Pos, pFile );
00233     free( pBuffer );
00234 
00235     // write the symbol table
00236     if ( fWriteSymbols )
00237     {
00238         // write PIs
00239         Abc_NtkForEachPi( pNtk, pObj, i )
00240             fprintf( pFile, "i%d %s\n", i, Abc_ObjName(pObj) );
00241         // write latches
00242         Abc_NtkForEachLatch( pNtk, pObj, i )
00243             fprintf( pFile, "l%d %s\n", i, Abc_ObjName(Abc_ObjFanout0(pObj)) );
00244         // write POs
00245         Abc_NtkForEachPo( pNtk, pObj, i )
00246             fprintf( pFile, "o%d %s\n", i, Abc_ObjName(pObj) );
00247     }
00248 
00249     // write the comment
00250     fprintf( pFile, "c\n" );
00251     if ( pNtk->pName && strlen(pNtk->pName) > 0 )
00252         fprintf( pFile, ".model %s\n", pNtk->pName );
00253     fprintf( pFile, "This file was produced by ABC on %s\n", Extra_TimeStamp() );
00254     fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
00255         fclose( pFile );
00256 }

void Io_WriteBaf ( Abc_Ntk_t pNtk,
char *  pFileName 
)

CFile****************************************************************

FileName [ioWriteBaf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write AIG in the binary format.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
ioWriteBaf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file ioWriteBaf.c.

00082 {
00083     ProgressBar * pProgress;
00084     FILE * pFile;
00085     Abc_Obj_t * pObj;
00086     int i, nNodes, nAnds, nBufferSize;
00087     unsigned * pBufferNode;
00088     assert( Abc_NtkIsStrash(pNtk) );
00089     // start the output stream
00090     pFile = fopen( pFileName, "wb" );
00091     if ( pFile == NULL )
00092     {
00093         fprintf( stdout, "Io_WriteBaf(): Cannot open the output file \"%s\".\n", pFileName );
00094         return;
00095     }
00096 
00097     // write the comment
00098     fprintf( pFile, "# BAF (Binary Aig Format) for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00099 
00100     // write the network name
00101     fprintf( pFile, "%s%c", pNtk->pName, 0 );
00102     // write the number of PIs
00103     fprintf( pFile, "%d%c", Abc_NtkPiNum(pNtk), 0 );
00104     // write the number of POs
00105     fprintf( pFile, "%d%c", Abc_NtkPoNum(pNtk), 0 );
00106     // write the number of latches
00107     fprintf( pFile, "%d%c", Abc_NtkLatchNum(pNtk), 0 );
00108     // write the number of internal nodes
00109     fprintf( pFile, "%d%c", Abc_NtkNodeNum(pNtk), 0 );
00110 
00111     // write PIs
00112     Abc_NtkForEachPi( pNtk, pObj, i )
00113         fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
00114     // write POs
00115     Abc_NtkForEachPo( pNtk, pObj, i )
00116         fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
00117     // write latches
00118     Abc_NtkForEachLatch( pNtk, pObj, i )
00119     {
00120         fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
00121         fprintf( pFile, "%s%c", Abc_ObjName(Abc_ObjFanin0(pObj)), 0 );
00122         fprintf( pFile, "%s%c", Abc_ObjName(Abc_ObjFanout0(pObj)), 0 );
00123     }
00124 
00125     // set the node numbers to be used in the output file
00126     Abc_NtkCleanCopy( pNtk );
00127     nNodes = 1;
00128     Abc_NtkForEachCi( pNtk, pObj, i )
00129         pObj->pCopy = (void *)nNodes++;
00130     Abc_AigForEachAnd( pNtk, pObj, i )
00131         pObj->pCopy = (void *)nNodes++;
00132 
00133     // write the nodes into the buffer
00134     nAnds = 0;
00135     nBufferSize = Abc_NtkNodeNum(pNtk) * 2 + Abc_NtkCoNum(pNtk);
00136     pBufferNode = ALLOC( int, nBufferSize );
00137     pProgress = Extra_ProgressBarStart( stdout, nBufferSize );
00138     Abc_AigForEachAnd( pNtk, pObj, i )
00139     {
00140         Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
00141         pBufferNode[nAnds++] = (((int)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj);
00142         pBufferNode[nAnds++] = (((int)Abc_ObjFanin1(pObj)->pCopy) << 1) | Abc_ObjFaninC1(pObj);
00143     }
00144 
00145     // write the COs into the buffer
00146     Abc_NtkForEachCo( pNtk, pObj, i )
00147     {
00148         Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
00149         pBufferNode[nAnds] = (((int)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj);
00150         if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
00151             pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((unsigned)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3);
00152         nAnds++;
00153     }
00154     Extra_ProgressBarStop( pProgress );
00155     assert( nBufferSize == nAnds );
00156 
00157     // write the buffer
00158     fwrite( pBufferNode, 1, sizeof(int) * nBufferSize, pFile );
00159         fclose( pFile );
00160     free( pBufferNode );
00161 }

int Io_WriteBench ( Abc_Ntk_t pNtk,
char *  pFileName 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file ioWriteBench.c.

00051 {
00052     Abc_Ntk_t * pExdc;
00053     FILE * pFile;
00054     assert( Abc_NtkIsSopNetlist(pNtk) );
00055     if ( !Io_WriteBenchCheckNames(pNtk) )
00056     {
00057         fprintf( stdout, "Io_WriteBench(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
00058         return 0;
00059     }
00060     pFile = fopen( pFileName, "w" );
00061     if ( pFile == NULL )
00062     {
00063         fprintf( stdout, "Io_WriteBench(): Cannot open the output file.\n" );
00064         return 0;
00065     }
00066     fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00067     // write the network
00068     Io_WriteBenchOne( pFile, pNtk );
00069     // write EXDC network if it exists
00070     pExdc = Abc_NtkExdc( pNtk );
00071     if ( pExdc )
00072         printf( "Io_WriteBench: EXDC is not written (warning).\n" );
00073     // finalize the file
00074     fclose( pFile );
00075     return 1;
00076 }

int Io_WriteBenchLut ( Abc_Ntk_t pNtk,
char *  pFileName 
)

Function*************************************************************

Synopsis [Writes the network in BENCH format with LUTs and DFFRSE.]

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file ioWriteBench.c.

00173 {
00174     Abc_Ntk_t * pExdc;
00175     FILE * pFile;
00176     assert( Abc_NtkIsAigNetlist(pNtk) );
00177     if ( !Io_WriteBenchCheckNames(pNtk) )
00178     {
00179         fprintf( stdout, "Io_WriteBenchLut(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
00180         return 0;
00181     }
00182     pFile = fopen( pFileName, "w" );
00183     if ( pFile == NULL )
00184     {
00185         fprintf( stdout, "Io_WriteBench(): Cannot open the output file.\n" );
00186         return 0;
00187     }
00188     fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00189     // write the network
00190     Io_WriteBenchLutOne( pFile, pNtk );
00191     // write EXDC network if it exists
00192     pExdc = Abc_NtkExdc( pNtk );
00193     if ( pExdc )
00194         printf( "Io_WriteBench: EXDC is not written (warning).\n" );
00195     // finalize the file
00196     fclose( pFile );
00197     return 1;
00198 }

void Io_WriteBlif ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches 
)

Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file ioWriteBlif.c.

00081 {
00082     FILE * pFile;
00083     Abc_Ntk_t * pNtkTemp;
00084     int i;
00085     assert( Abc_NtkIsNetlist(pNtk) );
00086     // start writing the file
00087     pFile = fopen( FileName, "w" );
00088     if ( pFile == NULL )
00089     {
00090         fprintf( stdout, "Io_WriteBlif(): Cannot open the output file.\n" );
00091         return;
00092     }
00093     fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00094     // write the master network
00095     Io_NtkWrite( pFile, pNtk, fWriteLatches );
00096     // make sure there is no logic hierarchy
00097     assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
00098     // write the hierarchy if present
00099     if ( Abc_NtkBlackboxNum(pNtk) > 0 )
00100     {
00101         Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNtkTemp, i )
00102         {
00103             if ( pNtkTemp == pNtk )
00104                 continue;
00105             fprintf( pFile, "\n\n" );
00106             Io_NtkWrite( pFile, pNtkTemp, fWriteLatches );
00107         }
00108     }
00109     fclose( pFile );
00110 }

void Io_WriteBlifLogic ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file ioWriteBlif.c.

00056 {
00057     Abc_Ntk_t * pNtkTemp;
00058     // derive the netlist
00059     pNtkTemp = Abc_NtkToNetlist(pNtk);
00060     if ( pNtkTemp == NULL )
00061     {
00062         fprintf( stdout, "Writing BLIF has failed.\n" );
00063         return;
00064     }
00065     Io_WriteBlif( pNtkTemp, FileName, fWriteLatches );
00066     Abc_NtkDelete( pNtkTemp );
00067 }

void Io_WriteBlifMv ( Abc_Ntk_t pNtk,
char *  FileName 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file ioWriteBlifMv.c.

00056 {
00057     FILE * pFile;
00058     Abc_Ntk_t * pNtkTemp;
00059     int i;
00060     assert( Abc_NtkIsNetlist(pNtk) );
00061     assert( Abc_NtkHasBlifMv(pNtk) );
00062     // start writing the file
00063     pFile = fopen( FileName, "w" );
00064     if ( pFile == NULL )
00065     {
00066         fprintf( stdout, "Io_WriteBlifMv(): Cannot open the output file.\n" );
00067         return;
00068     }
00069     fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00070     // write the master network
00071     Io_NtkWriteBlifMv( pFile, pNtk );
00072     // write the remaining networks
00073     if ( pNtk->pDesign )
00074     {
00075         Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNtkTemp, i )
00076         {
00077             if ( pNtkTemp == pNtk )
00078                 continue;
00079             fprintf( pFile, "\n\n" );
00080             Io_NtkWriteBlifMv( pFile, pNtkTemp );
00081         }
00082     }
00083     fclose( pFile );
00084 }

int Io_WriteCnf ( Abc_Ntk_t pNtk,
char *  pFileName,
int  fAllPrimes 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Write the miter cone into a CNF file for the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ioWriteCnf.c.

00046 {
00047     sat_solver * pSat;
00048     if ( Abc_NtkIsStrash(pNtk) )
00049         printf( "Io_WriteCnf() warning: Generating CNF by applying heuristic AIG to CNF conversion.\n" );
00050     else
00051         printf( "Io_WriteCnf() warning: Generating CNF by convering logic nodes into CNF clauses.\n" );
00052     if ( Abc_NtkPoNum(pNtk) != 1 )
00053     {
00054         fprintf( stdout, "Io_WriteCnf(): Currently can only process the miter (the network with one PO).\n" );
00055         return 0;
00056     }
00057     if ( Abc_NtkLatchNum(pNtk) != 0 )
00058     {
00059         fprintf( stdout, "Io_WriteCnf(): Currently can only process the miter for combinational circuits.\n" );
00060         return 0;
00061     }
00062     if ( Abc_NtkNodeNum(pNtk) == 0 )
00063     {
00064         fprintf( stdout, "The network has no logic nodes. No CNF file is generaled.\n" );
00065         return 0;
00066     }
00067     // convert to logic BDD network
00068     if ( Abc_NtkIsLogic(pNtk) )
00069         Abc_NtkToBdd( pNtk );
00070     // create solver with clauses
00071     pSat = Abc_NtkMiterSatCreate( pNtk, fAllPrimes );
00072     if ( pSat == NULL )
00073     {
00074         fprintf( stdout, "The problem is trivially UNSAT. No CNF file is generated.\n" );
00075         return 1;
00076     }        
00077     // write the clauses
00078     s_pNtk = pNtk;
00079     Sat_SolverWriteDimacs( pSat, pFileName, 0, 0, 1 );
00080     s_pNtk = NULL;
00081     // free the solver
00082     sat_solver_delete( pSat );
00083     return 1;
00084 }

void Io_WriteDot ( Abc_Ntk_t pNtk,
char *  FileName 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the graph structure of network for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 48 of file ioWriteDot.c.

00049 {
00050     Vec_Ptr_t * vNodes;
00051     vNodes = Abc_NtkCollectObjects( pNtk );
00052     Io_WriteDotNtk( pNtk, vNodes, NULL, FileName, 0, 0 );
00053     Vec_PtrFree( vNodes );
00054 }

void Io_WriteDotNtk ( Abc_Ntk_t pNtk,
Vec_Ptr_t vNodes,
Vec_Ptr_t vNodesShow,
char *  pFileName,
int  fGateNames,
int  fUseReverse 
)

Function*************************************************************

Synopsis [Writes the graph structure of network for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 68 of file ioWriteDot.c.

00069 {
00070     FILE * pFile;
00071     Abc_Obj_t * pNode, * pFanin;
00072     char * pSopString;
00073     int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl;
00074     int Limit = 300;
00075 
00076     assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
00077 
00078     if ( vNodes->nSize < 1 )
00079     {
00080         printf( "The set has no nodes. DOT file is not written.\n" );
00081         return;
00082     }
00083 
00084     if ( vNodes->nSize > Limit )
00085     {
00086         printf( "The set has more than %d nodes. DOT file is not written.\n", Limit );
00087         return;
00088     }
00089 
00090     // start the stream
00091     if ( (pFile = fopen( pFileName, "w" )) == NULL )
00092     {
00093         fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", pFileName );
00094         return;
00095     }
00096 
00097     // transform logic functions from BDD to SOP
00098     if ( fHasBdds = Abc_NtkIsBddLogic(pNtk) )
00099     {
00100         if ( !Abc_NtkBddToSop(pNtk, 0) )
00101         {
00102             printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" );
00103             return;
00104         }
00105     }
00106 
00107     // mark the nodes from the set
00108     Vec_PtrForEachEntry( vNodes, pNode, i )
00109         pNode->fMarkC = 1;
00110     if ( vNodesShow )
00111         Vec_PtrForEachEntry( vNodesShow, pNode, i )
00112             pNode->fMarkB = 1;
00113 
00114     // get the levels of nodes
00115     LevelMax = Abc_NtkLevel( pNtk );
00116     if ( fUseReverse )
00117     {
00118         LevelMin = Abc_NtkLevelReverse( pNtk );
00119         assert( LevelMax == LevelMin );
00120         Vec_PtrForEachEntry( vNodes, pNode, i )
00121             if ( Abc_ObjIsNode(pNode) )
00122                 pNode->Level = LevelMax - pNode->Level + 1;
00123     }
00124 
00125     // find the largest and the smallest levels
00126     LevelMin = 10000;
00127     LevelMax = -1;
00128     fHasCos  = 0;
00129     Vec_PtrForEachEntry( vNodes, pNode, i )
00130     {
00131         if ( Abc_ObjIsCo(pNode) )
00132         {
00133             fHasCos = 1;
00134             continue;
00135         }
00136         if ( LevelMin > (int)pNode->Level )
00137             LevelMin = pNode->Level;
00138         if ( LevelMax < (int)pNode->Level )
00139             LevelMax = pNode->Level;
00140     }
00141 
00142     // set the level of the CO nodes
00143     if ( fHasCos )
00144     {
00145         LevelMax++;
00146         Vec_PtrForEachEntry( vNodes, pNode, i )
00147         {
00148             if ( Abc_ObjIsCo(pNode) )
00149                 pNode->Level = LevelMax;
00150         }
00151     }
00152 
00153     // write the DOT header
00154     fprintf( pFile, "# %s\n",  "Network structure generated by ABC" );
00155     fprintf( pFile, "\n" );
00156     fprintf( pFile, "digraph network {\n" );
00157     fprintf( pFile, "size = \"7.5,10\";\n" );
00158 //    fprintf( pFile, "size = \"10,8.5\";\n" );
00159 //    fprintf( pFile, "size = \"14,11\";\n" );
00160 //    fprintf( pFile, "page = \"8,11\";\n" );
00161 //  fprintf( pFile, "ranksep = 0.5;\n" );
00162 //  fprintf( pFile, "nodesep = 0.5;\n" );
00163     fprintf( pFile, "center = true;\n" );
00164 //    fprintf( pFile, "orientation = landscape;\n" );
00165 //  fprintf( pFile, "edge [fontsize = 10];\n" );
00166 //  fprintf( pFile, "edge [dir = none];\n" );
00167     fprintf( pFile, "edge [dir = back];\n" );
00168     fprintf( pFile, "\n" );
00169 
00170     // labels on the left of the picture
00171     fprintf( pFile, "{\n" );
00172     fprintf( pFile, "  node [shape = plaintext];\n" );
00173     fprintf( pFile, "  edge [style = invis];\n" );
00174     fprintf( pFile, "  LevelTitle1 [label=\"\"];\n" );
00175     fprintf( pFile, "  LevelTitle2 [label=\"\"];\n" );
00176     // generate node names with labels
00177     for ( Level = LevelMax; Level >= LevelMin; Level-- )
00178     {
00179         // the visible node name
00180         fprintf( pFile, "  Level%d", Level );
00181         fprintf( pFile, " [label = " );
00182         // label name
00183         fprintf( pFile, "\"" );
00184         fprintf( pFile, "\"" );
00185         fprintf( pFile, "];\n" );
00186     }
00187 
00188     // genetate the sequence of visible/invisible nodes to mark levels
00189     fprintf( pFile, "  LevelTitle1 ->  LevelTitle2 ->" );
00190     for ( Level = LevelMax; Level >= LevelMin; Level-- )
00191     {
00192         // the visible node name
00193         fprintf( pFile, "  Level%d",  Level );
00194         // the connector
00195         if ( Level != LevelMin )
00196             fprintf( pFile, " ->" );
00197         else
00198             fprintf( pFile, ";" );
00199     }
00200     fprintf( pFile, "\n" );
00201     fprintf( pFile, "}" );
00202     fprintf( pFile, "\n" );
00203     fprintf( pFile, "\n" );
00204 
00205     // generate title box on top
00206     fprintf( pFile, "{\n" );
00207     fprintf( pFile, "  rank = same;\n" );
00208     fprintf( pFile, "  LevelTitle1;\n" );
00209     fprintf( pFile, "  title1 [shape=plaintext,\n" );
00210     fprintf( pFile, "          fontsize=20,\n" );
00211     fprintf( pFile, "          fontname = \"Times-Roman\",\n" );
00212     fprintf( pFile, "          label=\"" );
00213     fprintf( pFile, "%s", "Network structure visualized by ABC" );
00214     fprintf( pFile, "\\n" );
00215     fprintf( pFile, "Benchmark \\\"%s\\\". ", pNtk->pName );
00216     fprintf( pFile, "Time was %s. ",  Extra_TimeStamp() );
00217     fprintf( pFile, "\"\n" );
00218     fprintf( pFile, "         ];\n" );
00219     fprintf( pFile, "}" );
00220     fprintf( pFile, "\n" );
00221     fprintf( pFile, "\n" );
00222 
00223     // generate statistics box
00224     fprintf( pFile, "{\n" );
00225     fprintf( pFile, "  rank = same;\n" );
00226     fprintf( pFile, "  LevelTitle2;\n" );
00227     fprintf( pFile, "  title2 [shape=plaintext,\n" );
00228     fprintf( pFile, "          fontsize=18,\n" );
00229     fprintf( pFile, "          fontname = \"Times-Roman\",\n" );
00230     fprintf( pFile, "          label=\"" );
00231     if ( Abc_NtkObjNum(pNtk) == Vec_PtrSize(vNodes) )
00232         fprintf( pFile, "The network contains %d logic nodes and %d latches.", Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk) );
00233     else
00234         fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
00235     fprintf( pFile, "\\n" );
00236     fprintf( pFile, "\"\n" );
00237     fprintf( pFile, "         ];\n" );
00238     fprintf( pFile, "}" );
00239     fprintf( pFile, "\n" );
00240     fprintf( pFile, "\n" );
00241 
00242     // generate the POs
00243     if ( fHasCos )
00244     {
00245         fprintf( pFile, "{\n" );
00246         fprintf( pFile, "  rank = same;\n" );
00247         // the labeling node of this level
00248         fprintf( pFile, "  Level%d;\n",  LevelMax );
00249         // generate the PO nodes
00250         Vec_PtrForEachEntry( vNodes, pNode, i )
00251         {
00252             if ( !Abc_ObjIsCo(pNode) )
00253                 continue;
00254             fprintf( pFile, "  Node%d [label = \"%s%s\"", 
00255                 pNode->Id, 
00256                 (Abc_ObjIsBi(pNode)? Abc_ObjName(Abc_ObjFanout0(pNode)):Abc_ObjName(pNode)), 
00257                 (Abc_ObjIsBi(pNode)? "_in":"") );
00258             fprintf( pFile, ", shape = %s", (Abc_ObjIsBi(pNode)? "box":"invtriangle") );
00259             if ( pNode->fMarkB )
00260                 fprintf( pFile, ", style = filled" );
00261             fprintf( pFile, ", color = coral, fillcolor = coral" );
00262             fprintf( pFile, "];\n" );
00263         }
00264         fprintf( pFile, "}" );
00265         fprintf( pFile, "\n" );
00266         fprintf( pFile, "\n" );
00267     }
00268 
00269     // generate nodes of each rank
00270     for ( Level = LevelMax - fHasCos; Level >= LevelMin && Level > 0; Level-- )
00271     {
00272         fprintf( pFile, "{\n" );
00273         fprintf( pFile, "  rank = same;\n" );
00274         // the labeling node of this level
00275         fprintf( pFile, "  Level%d;\n",  Level );
00276         Vec_PtrForEachEntry( vNodes, pNode, i )
00277         {
00278             if ( (int)pNode->Level != Level )
00279                 continue;
00280             if ( Abc_ObjFaninNum(pNode) == 0 )
00281                 continue;
00282 //            fprintf( pFile, "  Node%d [label = \"%d\"", pNode->Id, pNode->Id );
00283             if ( Abc_NtkIsStrash(pNtk) )
00284                 pSopString = "";
00285             else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
00286                 pSopString = Mio_GateReadName(pNode->pData);
00287             else if ( Abc_NtkHasMapping(pNtk) )
00288                 pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
00289             else
00290                 pSopString = Abc_NtkPrintSop(pNode->pData);
00291             fprintf( pFile, "  Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
00292 
00293             fprintf( pFile, ", shape = ellipse" );
00294             if ( pNode->fMarkB )
00295                 fprintf( pFile, ", style = filled" );
00296             fprintf( pFile, "];\n" );
00297         }
00298         fprintf( pFile, "}" );
00299         fprintf( pFile, "\n" );
00300         fprintf( pFile, "\n" );
00301     }
00302 
00303     // generate the PI nodes if any
00304     if ( LevelMin == 0 )
00305     {
00306         fprintf( pFile, "{\n" );
00307         fprintf( pFile, "  rank = same;\n" );
00308         // the labeling node of this level
00309         fprintf( pFile, "  Level%d;\n",  LevelMin );
00310         // generate the PO nodes
00311         Vec_PtrForEachEntry( vNodes, pNode, i )
00312         {
00313             if ( !Abc_ObjIsCi(pNode) )
00314             {
00315                 // check if the costant node is present
00316                 if ( Abc_ObjFaninNum(pNode) == 0 && Abc_ObjFanoutNum(pNode) > 0 )
00317                 {
00318                     fprintf( pFile, "  Node%d [label = \"Const%d\"", pNode->Id, Abc_NtkIsStrash(pNode->pNtk) || Abc_NodeIsConst1(pNode) );
00319                     fprintf( pFile, ", shape = ellipse" );
00320                     if ( pNode->fMarkB )
00321                         fprintf( pFile, ", style = filled" );
00322                     fprintf( pFile, ", color = coral, fillcolor = coral" );
00323                     fprintf( pFile, "];\n" );
00324                 }
00325                 continue;
00326             }
00327             fprintf( pFile, "  Node%d [label = \"%s\"", 
00328                 pNode->Id, 
00329                 (Abc_ObjIsBo(pNode)? Abc_ObjName(Abc_ObjFanin0(pNode)):Abc_ObjName(pNode)) );
00330             fprintf( pFile, ", shape = %s", (Abc_ObjIsBo(pNode)? "box":"triangle") );
00331             if ( pNode->fMarkB )
00332                 fprintf( pFile, ", style = filled" );
00333             fprintf( pFile, ", color = coral, fillcolor = coral" );
00334             fprintf( pFile, "];\n" );
00335         }
00336         fprintf( pFile, "}" );
00337         fprintf( pFile, "\n" );
00338         fprintf( pFile, "\n" );
00339     }
00340 
00341     // generate invisible edges from the square down
00342     fprintf( pFile, "title1 -> title2 [style = invis];\n" );
00343     Vec_PtrForEachEntry( vNodes, pNode, i )
00344     {
00345         if ( (int)pNode->Level != LevelMax )
00346             continue;
00347         fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
00348     }
00349 
00350     // generate edges
00351     Vec_PtrForEachEntry( vNodes, pNode, i )
00352     {
00353         if ( Abc_ObjIsLatch(pNode) )
00354             continue;
00355         Abc_ObjForEachFanin( pNode, pFanin, k )
00356         {
00357             if ( Abc_ObjIsLatch(pFanin) )
00358                 continue;
00359             fCompl = 0;
00360             if ( Abc_NtkIsStrash(pNtk) )
00361                 fCompl = Abc_ObjFaninC(pNode, k);
00362             // generate the edge from this node to the next
00363             fprintf( pFile, "Node%d",  pNode->Id );
00364             fprintf( pFile, " -> " );
00365             fprintf( pFile, "Node%d",  pFanin->Id );
00366             fprintf( pFile, " [style = %s", fCompl? "dotted" : "bold" );
00367 //            fprintf( pFile, ", label = \"%c\"", 'a' + k );
00368             fprintf( pFile, "]" );
00369             fprintf( pFile, ";\n" );
00370         }
00371     }
00372 
00373     fprintf( pFile, "}" );
00374     fprintf( pFile, "\n" );
00375     fprintf( pFile, "\n" );
00376     fclose( pFile );
00377 
00378     // unmark the nodes from the set
00379     Vec_PtrForEachEntry( vNodes, pNode, i )
00380         pNode->fMarkC = 0;
00381     if ( vNodesShow )
00382         Vec_PtrForEachEntry( vNodesShow, pNode, i )
00383             pNode->fMarkB = 0;
00384 
00385     // convert the network back into BDDs if this is how it was
00386     if ( fHasBdds )
00387         Abc_NtkSopToBdd(pNtk);
00388 }

void Io_WriteDotSeq ( Abc_Ntk_t pNtk,
Vec_Ptr_t vNodes,
Vec_Ptr_t vNodesShow,
char *  pFileName,
int  fGateNames,
int  fUseReverse 
)

Function*************************************************************

Synopsis [Writes the graph structure of network for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 403 of file ioWriteDot.c.

00404 {
00405     FILE * pFile;
00406     Abc_Obj_t * pNode, * pFanin;
00407     char * pSopString;
00408     int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl;
00409     int Limit = 300;
00410 
00411     assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
00412 
00413     if ( vNodes->nSize < 1 )
00414     {
00415         printf( "The set has no nodes. DOT file is not written.\n" );
00416         return;
00417     }
00418 
00419     if ( vNodes->nSize > Limit )
00420     {
00421         printf( "The set has more than %d nodes. DOT file is not written.\n", Limit );
00422         return;
00423     }
00424 
00425     // start the stream
00426     if ( (pFile = fopen( pFileName, "w" )) == NULL )
00427     {
00428         fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", pFileName );
00429         return;
00430     }
00431 
00432     // transform logic functions from BDD to SOP
00433     if ( fHasBdds = Abc_NtkIsBddLogic(pNtk) )
00434     {
00435         if ( !Abc_NtkBddToSop(pNtk, 0) )
00436         {
00437             printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" );
00438             return;
00439         }
00440     }
00441 
00442     // mark the nodes from the set
00443     Vec_PtrForEachEntry( vNodes, pNode, i )
00444         pNode->fMarkC = 1;
00445     if ( vNodesShow )
00446         Vec_PtrForEachEntry( vNodesShow, pNode, i )
00447             pNode->fMarkB = 1;
00448 
00449     // get the levels of nodes
00450     LevelMax = Abc_NtkLevel( pNtk );
00451     if ( fUseReverse )
00452     {
00453         LevelMin = Abc_NtkLevelReverse( pNtk );
00454         assert( LevelMax == LevelMin );
00455         Vec_PtrForEachEntry( vNodes, pNode, i )
00456             if ( Abc_ObjIsNode(pNode) )
00457                 pNode->Level = LevelMax - pNode->Level + 1;
00458     }
00459 
00460     // find the largest and the smallest levels
00461     LevelMin = 10000;
00462     LevelMax = -1;
00463     fHasCos  = 0;
00464     Vec_PtrForEachEntry( vNodes, pNode, i )
00465     {
00466         if ( Abc_ObjIsCo(pNode) )
00467         {
00468             fHasCos = 1;
00469             continue;
00470         }
00471         if ( LevelMin > (int)pNode->Level )
00472             LevelMin = pNode->Level;
00473         if ( LevelMax < (int)pNode->Level )
00474             LevelMax = pNode->Level;
00475     }
00476 
00477     // set the level of the CO nodes
00478     if ( fHasCos )
00479     {
00480         LevelMax++;
00481         Vec_PtrForEachEntry( vNodes, pNode, i )
00482         {
00483             if ( Abc_ObjIsCo(pNode) )
00484                 pNode->Level = LevelMax;
00485         }
00486     }
00487 
00488     // write the DOT header
00489     fprintf( pFile, "# %s\n",  "Network structure generated by ABC" );
00490     fprintf( pFile, "\n" );
00491     fprintf( pFile, "digraph network {\n" );
00492     fprintf( pFile, "size = \"7.5,10\";\n" );
00493 //    fprintf( pFile, "size = \"10,8.5\";\n" );
00494 //    fprintf( pFile, "size = \"14,11\";\n" );
00495 //    fprintf( pFile, "page = \"8,11\";\n" );
00496 //  fprintf( pFile, "ranksep = 0.5;\n" );
00497 //  fprintf( pFile, "nodesep = 0.5;\n" );
00498     fprintf( pFile, "center = true;\n" );
00499 //    fprintf( pFile, "orientation = landscape;\n" );
00500 //  fprintf( pFile, "edge [fontsize = 10];\n" );
00501 //  fprintf( pFile, "edge [dir = none];\n" );
00502     fprintf( pFile, "edge [dir = back];\n" );
00503     fprintf( pFile, "\n" );
00504 
00505     // labels on the left of the picture
00506     fprintf( pFile, "{\n" );
00507     fprintf( pFile, "  node [shape = plaintext];\n" );
00508     fprintf( pFile, "  edge [style = invis];\n" );
00509     fprintf( pFile, "  LevelTitle1 [label=\"\"];\n" );
00510     fprintf( pFile, "  LevelTitle2 [label=\"\"];\n" );
00511     // generate node names with labels
00512     for ( Level = LevelMax; Level >= LevelMin; Level-- )
00513     {
00514         // the visible node name
00515         fprintf( pFile, "  Level%d", Level );
00516         fprintf( pFile, " [label = " );
00517         // label name
00518         fprintf( pFile, "\"" );
00519         fprintf( pFile, "\"" );
00520         fprintf( pFile, "];\n" );
00521     }
00522 
00523     // genetate the sequence of visible/invisible nodes to mark levels
00524     fprintf( pFile, "  LevelTitle1 ->  LevelTitle2 ->" );
00525     for ( Level = LevelMax; Level >= LevelMin; Level-- )
00526     {
00527         // the visible node name
00528         fprintf( pFile, "  Level%d",  Level );
00529         // the connector
00530         if ( Level != LevelMin )
00531             fprintf( pFile, " ->" );
00532         else
00533             fprintf( pFile, ";" );
00534     }
00535     fprintf( pFile, "\n" );
00536     fprintf( pFile, "}" );
00537     fprintf( pFile, "\n" );
00538     fprintf( pFile, "\n" );
00539 
00540     // generate title box on top
00541     fprintf( pFile, "{\n" );
00542     fprintf( pFile, "  rank = same;\n" );
00543     fprintf( pFile, "  LevelTitle1;\n" );
00544     fprintf( pFile, "  title1 [shape=plaintext,\n" );
00545     fprintf( pFile, "          fontsize=20,\n" );
00546     fprintf( pFile, "          fontname = \"Times-Roman\",\n" );
00547     fprintf( pFile, "          label=\"" );
00548     fprintf( pFile, "%s", "Network structure visualized by ABC" );
00549     fprintf( pFile, "\\n" );
00550     fprintf( pFile, "Benchmark \\\"%s\\\". ", pNtk->pName );
00551     fprintf( pFile, "Time was %s. ",  Extra_TimeStamp() );
00552     fprintf( pFile, "\"\n" );
00553     fprintf( pFile, "         ];\n" );
00554     fprintf( pFile, "}" );
00555     fprintf( pFile, "\n" );
00556     fprintf( pFile, "\n" );
00557 
00558     // generate statistics box
00559     fprintf( pFile, "{\n" );
00560     fprintf( pFile, "  rank = same;\n" );
00561     fprintf( pFile, "  LevelTitle2;\n" );
00562     fprintf( pFile, "  title2 [shape=plaintext,\n" );
00563     fprintf( pFile, "          fontsize=18,\n" );
00564     fprintf( pFile, "          fontname = \"Times-Roman\",\n" );
00565     fprintf( pFile, "          label=\"" );
00566     if ( Abc_NtkObjNum(pNtk) == Vec_PtrSize(vNodes) )
00567         fprintf( pFile, "The network contains %d logic nodes and %d latches.", Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk) );
00568     else
00569         fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
00570     fprintf( pFile, "\\n" );
00571     fprintf( pFile, "\"\n" );
00572     fprintf( pFile, "         ];\n" );
00573     fprintf( pFile, "}" );
00574     fprintf( pFile, "\n" );
00575     fprintf( pFile, "\n" );
00576 
00577     // generate the POs
00578     if ( fHasCos )
00579     {
00580         fprintf( pFile, "{\n" );
00581         fprintf( pFile, "  rank = same;\n" );
00582         // the labeling node of this level
00583         fprintf( pFile, "  Level%d;\n",  LevelMax );
00584         // generate the PO nodes
00585         Vec_PtrForEachEntry( vNodes, pNode, i )
00586         {
00587             if ( !Abc_ObjIsPo(pNode) )
00588                 continue;
00589             fprintf( pFile, "  Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
00590             fprintf( pFile, ", shape = %s", "invtriangle" );
00591             if ( pNode->fMarkB )
00592                 fprintf( pFile, ", style = filled" );
00593             fprintf( pFile, ", color = coral, fillcolor = coral" );
00594             fprintf( pFile, "];\n" );
00595         }
00596         fprintf( pFile, "}" );
00597         fprintf( pFile, "\n" );
00598         fprintf( pFile, "\n" );
00599     }
00600 
00601     // generate nodes of each rank
00602     for ( Level = LevelMax - fHasCos; Level >= LevelMin && Level > 0; Level-- )
00603     {
00604         fprintf( pFile, "{\n" );
00605         fprintf( pFile, "  rank = same;\n" );
00606         // the labeling node of this level
00607         fprintf( pFile, "  Level%d;\n",  Level );
00608         Abc_NtkForEachNode( pNtk, pNode, i )
00609         {
00610             if ( (int)pNode->Level != Level )
00611                 continue;
00612 //            fprintf( pFile, "  Node%d [label = \"%d\"", pNode->Id, pNode->Id );
00613             if ( Abc_NtkIsStrash(pNtk) )
00614                 pSopString = "";
00615             else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
00616                 pSopString = Mio_GateReadName(pNode->pData);
00617             else if ( Abc_NtkHasMapping(pNtk) )
00618                 pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
00619             else
00620                 pSopString = Abc_NtkPrintSop(pNode->pData);
00621             fprintf( pFile, "  Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
00622 
00623             fprintf( pFile, ", shape = ellipse" );
00624             if ( pNode->fMarkB )
00625                 fprintf( pFile, ", style = filled" );
00626             fprintf( pFile, "];\n" );
00627         }
00628         fprintf( pFile, "}" );
00629         fprintf( pFile, "\n" );
00630         fprintf( pFile, "\n" );
00631     }
00632 
00633     // generate the PI nodes if any
00634     if ( LevelMin == 0 )
00635     {
00636         fprintf( pFile, "{\n" );
00637         fprintf( pFile, "  rank = same;\n" );
00638         // the labeling node of this level
00639         fprintf( pFile, "  Level%d;\n",  LevelMin );
00640         // generate the PO nodes
00641         Vec_PtrForEachEntry( vNodes, pNode, i )
00642         {
00643             if ( pNode->Level > 0 )
00644                 continue;
00645             if ( !Abc_ObjIsPi(pNode) )
00646             {
00647                 // check if the costant node is present
00648                 if ( Abc_ObjFaninNum(pNode) == 0 && Abc_ObjFanoutNum(pNode) > 0 )
00649                 {
00650                     fprintf( pFile, "  Node%d [label = \"Const1\"", pNode->Id );
00651                     fprintf( pFile, ", shape = ellipse" );
00652                     if ( pNode->fMarkB )
00653                         fprintf( pFile, ", style = filled" );
00654                     fprintf( pFile, ", color = coral, fillcolor = coral" );
00655                     fprintf( pFile, "];\n" );
00656                 }
00657                 continue;
00658             }
00659             fprintf( pFile, "  Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
00660             fprintf( pFile, ", shape = %s", "triangle" );
00661             if ( pNode->fMarkB )
00662                 fprintf( pFile, ", style = filled" );
00663             fprintf( pFile, ", color = coral, fillcolor = coral" );
00664             fprintf( pFile, "];\n" );
00665         }
00666         fprintf( pFile, "}" );
00667         fprintf( pFile, "\n" );
00668         fprintf( pFile, "\n" );
00669     }
00670 
00671 //    fprintf( pFile, "{\n" );
00672     Vec_PtrForEachEntry( vNodes, pNode, i )
00673     {
00674         if ( !Abc_ObjIsLatch(pNode) )
00675             continue;
00676         fprintf( pFile, "Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
00677         fprintf( pFile, ", shape = box" );
00678         if ( pNode->fMarkB )
00679             fprintf( pFile, ", style = filled" );
00680         fprintf( pFile, ", color = coral, fillcolor = coral" );
00681         fprintf( pFile, "];\n" );
00682     }
00683 //    fprintf( pFile, "}" );
00684 //    fprintf( pFile, "\n" );
00685     fprintf( pFile, "\n" );
00686 
00687     // generate invisible edges from the square down
00688     fprintf( pFile, "title1 -> title2 [style = invis];\n" );
00689     Vec_PtrForEachEntry( vNodes, pNode, i )
00690     {
00691         if ( (int)pNode->Level != LevelMax )
00692             continue;
00693         if ( !Abc_ObjIsPo(pNode) )
00694             continue;
00695         fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
00696     }
00697 
00698     // generate edges
00699     Vec_PtrForEachEntry( vNodes, pNode, i )
00700     {
00701         if ( Abc_ObjIsBi(pNode) || Abc_ObjIsBo(pNode) )
00702             continue;
00703         Abc_ObjForEachFanin( pNode, pFanin, k )
00704         {
00705             fCompl = 0;
00706             if ( Abc_NtkIsStrash(pNtk) )
00707             {
00708                 if ( Abc_ObjIsBi(pFanin) )
00709                     fCompl = Abc_ObjFaninC(pFanin, k);
00710                 else
00711                     fCompl = Abc_ObjFaninC(pNode, k);
00712             }
00713             if ( Abc_ObjIsBi(pFanin) || Abc_ObjIsBo(pFanin) )
00714                 pFanin = Abc_ObjFanin0(pFanin);
00715             if ( Abc_ObjIsBi(pFanin) || Abc_ObjIsBo(pFanin) )
00716                 pFanin = Abc_ObjFanin0(pFanin);
00717             if ( !pFanin->fMarkC )
00718                 continue;
00719 
00720             // generate the edge from this node to the next
00721             fprintf( pFile, "Node%d",  pNode->Id );
00722             fprintf( pFile, " -> " );
00723             fprintf( pFile, "Node%d",  pFanin->Id );
00724             fprintf( pFile, " [style = %s", fCompl? "dotted" : "bold" );
00725 //            fprintf( pFile, ", label = \"%c\"", 'a' + k );
00726             fprintf( pFile, "]" );
00727             fprintf( pFile, ";\n" );
00728         }
00729     }
00730 
00731     fprintf( pFile, "}" );
00732     fprintf( pFile, "\n" );
00733     fprintf( pFile, "\n" );
00734     fclose( pFile );
00735 
00736     // unmark the nodes from the set
00737     Vec_PtrForEachEntry( vNodes, pNode, i )
00738         pNode->fMarkC = 0;
00739     if ( vNodesShow )
00740         Vec_PtrForEachEntry( vNodesShow, pNode, i )
00741             pNode->fMarkB = 0;
00742 
00743     // convert the network back into BDDs if this is how it was
00744     if ( fHasBdds )
00745         Abc_NtkSopToBdd(pNtk);
00746 }

void Io_WriteEqn ( Abc_Ntk_t pNtk,
char *  pFileName 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the logic network in the equation format.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioWriteEqn.c.

00048 {
00049     FILE * pFile;
00050 
00051     assert( Abc_NtkIsAigNetlist(pNtk) );
00052     if ( Abc_NtkLatchNum(pNtk) > 0 )
00053         printf( "Warning: only combinational portion is being written.\n" );
00054 
00055     // check that the names are fine for the EQN format
00056     if ( !Io_NtkWriteEqnCheck(pNtk) )
00057         return;
00058 
00059     // start the output stream
00060     pFile = fopen( pFileName, "w" );
00061     if ( pFile == NULL )
00062     {
00063         fprintf( stdout, "Io_WriteEqn(): Cannot open the output file \"%s\".\n", pFileName );
00064         return;
00065     }
00066     fprintf( pFile, "# Equations for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00067 
00068     // write the equations for the network
00069     Io_NtkWriteEqnOne( pFile, pNtk );
00070         fprintf( pFile, "\n" );
00071         fclose( pFile );
00072 }

void Io_WriteGml ( Abc_Ntk_t pNtk,
char *  pFileName 
)

CFile****************************************************************

FileName [ioWriteGml.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write the graph structure of AIG in GML.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
ioWriteGml.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the graph structure of AIG in GML.]

Description [Useful for graph visualization using tools such as yEd: http://www.yworks.com/]

SideEffects []

SeeAlso []

Definition at line 43 of file ioWriteGml.c.

00044 {
00045     FILE * pFile;
00046     Abc_Obj_t * pObj, * pFanin;
00047     int i, k;
00048 
00049     assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk)  );
00050 
00051     // start the output stream
00052     pFile = fopen( pFileName, "w" );
00053     if ( pFile == NULL )
00054     {
00055         fprintf( stdout, "Io_WriteGml(): Cannot open the output file \"%s\".\n", pFileName );
00056         return;
00057     }
00058     fprintf( pFile, "# GML for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00059         fprintf( pFile, "graph [\n" );
00060 
00061     // output the POs
00062     fprintf( pFile, "\n" );
00063     Abc_NtkForEachPo( pNtk, pObj, i )
00064     {
00065         fprintf( pFile, "    node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00066         fprintf( pFile, "        graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" );   // blue
00067         fprintf( pFile, "    ]\n" );
00068     }
00069     // output the PIs
00070     fprintf( pFile, "\n" );
00071     Abc_NtkForEachPi( pNtk, pObj, i )
00072     {
00073         fprintf( pFile, "    node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00074         fprintf( pFile, "        graphics [ type \"triangle\" fill \"#00FF00\" ]\n" );   // green
00075         fprintf( pFile, "    ]\n" );
00076     }
00077     // output the latches
00078     fprintf( pFile, "\n" );
00079     Abc_NtkForEachLatch( pNtk, pObj, i )
00080     {
00081         fprintf( pFile, "    node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00082         fprintf( pFile, "        graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" );   // red
00083         fprintf( pFile, "    ]\n" );
00084     }
00085     // output the nodes
00086     fprintf( pFile, "\n" );
00087     Abc_NtkForEachNode( pNtk, pObj, i )
00088     {
00089         fprintf( pFile, "    node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00090         fprintf( pFile, "        graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" );     // grey
00091         fprintf( pFile, "    ]\n" );
00092     }
00093 
00094     // output the edges
00095     fprintf( pFile, "\n" );
00096     Abc_NtkForEachObj( pNtk, pObj, i )
00097     {
00098         Abc_ObjForEachFanin( pObj, pFanin, k )
00099         {
00100             fprintf( pFile, "    edge [ source %5d   target %5d\n", pObj->Id, pFanin->Id );
00101             fprintf( pFile, "        graphics [ type \"line\" arrow \"first\" ]\n" );
00102             fprintf( pFile, "    ]\n" );
00103         }
00104     }
00105 
00106         fprintf( pFile, "]\n" );
00107         fprintf( pFile, "\n" );
00108         fclose( pFile );
00109 }

void Io_WriteHie ( Abc_Ntk_t pNtk,
char *  pBaseName,
char *  pFileName 
)

Function*************************************************************

Synopsis [Write the network into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 371 of file ioUtil.c.

00372 {
00373     Abc_Ntk_t * pNtkTemp, * pNtkResult, * pNtkBase = NULL;
00374     // check if the current network is available
00375     if ( pNtk == NULL )
00376     {
00377         fprintf( stdout, "Empty network.\n" );
00378         return;
00379     }
00380 
00381     // read the base network
00382     assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
00383     if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIF )
00384         pNtkBase = Io_ReadBlifMv( pBaseName, 0, 1 );
00385     else if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV )
00386         pNtkBase = Io_ReadBlifMv( pBaseName, 1, 1 );
00387     else if ( Io_ReadFileType(pBaseName) == IO_FILE_VERILOG )
00388         pNtkBase = Io_ReadVerilog( pBaseName, 1 );
00389     else 
00390         fprintf( stderr, "Unknown input file format.\n" );
00391     if ( pNtkBase == NULL )
00392         return;
00393 
00394     // flatten logic hierarchy if present
00395     if ( Abc_NtkWhiteboxNum(pNtkBase) > 0 )
00396     {
00397         pNtkBase = Abc_NtkFlattenLogicHierarchy( pNtkTemp = pNtkBase );
00398         if ( pNtkBase == NULL )
00399             return;
00400         Abc_NtkDelete( pNtkTemp );
00401     }
00402 
00403     // reintroduce the boxes into the netlist
00404     if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV ) 
00405     {
00406         if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
00407         {
00408             printf( "Hierarchy writer does not support BLIF-MV with blackboxes.\n" );
00409             Abc_NtkDelete( pNtkBase );
00410             return;
00411         }
00412         // convert the current network to BLIF-MV
00413         assert( !Abc_NtkIsNetlist(pNtk) );
00414         pNtkResult = Abc_NtkToNetlist( pNtk );
00415         if ( !Abc_NtkConvertToBlifMv( pNtkResult ) )
00416             return;
00417         // reintroduce the network
00418         pNtkResult = Abc_NtkInsertBlifMv( pNtkBase, pNtkTemp = pNtkResult );
00419         Abc_NtkDelete( pNtkTemp );
00420     }
00421     else if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
00422     {
00423         // derive the netlist
00424         pNtkResult = Abc_NtkToNetlist( pNtk );
00425         pNtkResult = Abc_NtkInsertNewLogic( pNtkBase, pNtkTemp = pNtkResult );
00426         Abc_NtkDelete( pNtkTemp );
00427         if ( pNtkResult )
00428             printf( "Hierarchy writer reintroduced %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtkBase) );
00429     }
00430     else
00431     {
00432         printf( "Warning: The output network does not contain blackboxes.\n" );
00433         pNtkResult = Abc_NtkToNetlist( pNtk );
00434     }
00435     Abc_NtkDelete( pNtkBase );
00436     if ( pNtkResult == NULL )
00437         return;
00438 
00439     // write the resulting network
00440     if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF )
00441     {
00442         if ( !Abc_NtkHasSop(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
00443             Abc_NtkToSop( pNtkResult, 0 );
00444         Io_WriteBlif( pNtkResult, pFileName, 1 );
00445     }
00446     else if ( Io_ReadFileType(pFileName) == IO_FILE_VERILOG )
00447     {
00448         if ( !Abc_NtkHasAig(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
00449             Abc_NtkToAig( pNtkResult );
00450         Io_WriteVerilog( pNtkResult, pFileName );
00451     }
00452     else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
00453     {
00454         Io_WriteBlifMv( pNtkResult, pFileName );
00455     }
00456     else 
00457         fprintf( stderr, "Unknown output file format.\n" );
00458 
00459     Abc_NtkDelete( pNtkResult );
00460 }

void Io_WriteList ( Abc_Ntk_t pNtk,
char *  pFileName,
int  fUseHost 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the adjacency list for a sequential AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file ioWriteList.c.

00100 {
00101     FILE * pFile;
00102     Abc_Obj_t * pObj;
00103     int i;
00104 
00105 //    assert( Abc_NtkIsSeq(pNtk)  );
00106 
00107     // start the output stream
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     // write the constant node
00119     if ( Abc_ObjFanoutNum( Abc_AigConst1(pNtk) ) > 0 )
00120         Io_WriteListEdge( pFile, Abc_AigConst1(pNtk) );
00121 
00122     // write the PI edges
00123     Abc_NtkForEachPi( pNtk, pObj, i )
00124         Io_WriteListEdge( pFile, pObj );
00125 
00126     // write the internal nodes
00127     Abc_AigForEachAnd( pNtk, pObj, i )
00128         Io_WriteListEdge( pFile, pObj );
00129 
00130     // write the host node
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 }

int Io_WritePla ( Abc_Ntk_t pNtk,
char *  pFileName 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Writes the network in PLA format.]

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file ioWritePla.c.

00045 {
00046     Abc_Ntk_t * pExdc;
00047     FILE * pFile;
00048 
00049     assert( Abc_NtkIsSopNetlist(pNtk) );
00050     assert( Abc_NtkLevel(pNtk) == 1 );
00051 
00052     pFile = fopen( pFileName, "w" );
00053     if ( pFile == NULL )
00054     {
00055         fprintf( stdout, "Io_WritePla(): Cannot open the output file.\n" );
00056         return 0;
00057     }
00058     fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00059     // write the network
00060     Io_WritePlaOne( pFile, pNtk );
00061     // write EXDC network if it exists
00062     pExdc = Abc_NtkExdc( pNtk );
00063     if ( pExdc )
00064         printf( "Io_WritePla: EXDC is not written (warning).\n" );
00065     // finalize the file
00066     fclose( pFile );
00067     return 1;
00068 }

void Io_WriteTimingInfo ( FILE *  pFile,
Abc_Ntk_t pNtk 
)

Function*************************************************************

Synopsis [Writes the timing info.]

Description []

SideEffects []

SeeAlso []

Definition at line 566 of file ioWriteBlif.c.

00567 {
00568     Abc_Obj_t * pNode;
00569     Abc_Time_t * pTime, * pTimeDef;
00570     int i;
00571 
00572     if ( pNtk->pManTime == NULL )
00573         return;
00574 
00575     pTimeDef = Abc_NtkReadDefaultArrival( pNtk );
00576     fprintf( pFile, ".default_input_arrival %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
00577     Abc_NtkForEachPi( pNtk, pNode, i )
00578     {
00579         pTime = Abc_NodeReadArrival(pNode);
00580         if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
00581             continue;
00582         fprintf( pFile, ".input_arrival %s %g %g\n", Abc_ObjName(pNode), pTime->Rise, pTime->Fall );
00583     }
00584 }

void Io_WriteVerilog ( Abc_Ntk_t pNtk,
char *  pFileName 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Write verilog.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file ioWriteVerilog.c.

00055 {
00056     Abc_Ntk_t * pNetlist;
00057     FILE * pFile;
00058     int i;
00059     // can only write nodes represented using local AIGs
00060     if ( !Abc_NtkIsAigNetlist(pNtk) && !Abc_NtkIsMappedNetlist(pNtk) )
00061     {
00062         printf( "Io_WriteVerilog(): Can produce Verilog for mapped or AIG netlists only.\n" );
00063         return;
00064     }
00065     // start the output stream
00066     pFile = fopen( pFileName, "w" );
00067     if ( pFile == NULL )
00068     {
00069         fprintf( stdout, "Io_WriteVerilog(): Cannot open the output file \"%s\".\n", pFileName );
00070         return;
00071     }
00072 
00073     // write the equations for the network
00074     fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00075         fprintf( pFile, "\n" );
00076 
00077     // write modules
00078     if ( pNtk->pDesign )
00079     {
00080         // write the network first
00081         Io_WriteVerilogInt( pFile, pNtk );
00082         // write other things
00083         Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNetlist, i )
00084         {
00085             assert( Abc_NtkIsNetlist(pNetlist) );
00086             if ( pNetlist == pNtk )
00087                 continue;
00088                 fprintf( pFile, "\n" );
00089             Io_WriteVerilogInt( pFile, pNetlist );
00090         }
00091     }
00092     else
00093     {
00094         Io_WriteVerilogInt( pFile, pNtk );
00095     }
00096 
00097         fprintf( pFile, "\n" );
00098         fclose( pFile );
00099 }


Generated on Tue Jan 5 12:18:44 2010 for abc70930 by  doxygen 1.6.1