src/base/io/ioReadEdif.c File Reference

#include "io.h"
Include dependency graph for ioReadEdif.c:

Go to the source code of this file.

Functions

static Abc_Ntk_tIo_ReadEdifNetwork (Extra_FileReader_t *p)
Abc_Ntk_tIo_ReadEdif (char *pFileName, int fCheck)

Function Documentation

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_ReadEdifNetwork ( Extra_FileReader_t p  )  [static]

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

FileName [ioReadEdif.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedure to read ISCAS benchmarks in EDIF.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] DECLARATIONS ///

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file ioReadEdif.c.

00084 {
00085     ProgressBar * pProgress;
00086     Vec_Ptr_t * vTokens;
00087     Abc_Ntk_t * pNtk;
00088     Abc_Obj_t * pNet, * pObj, * pFanout;
00089     char * pGateName, * pNetName;
00090     int fTokensReady, iLine, i;
00091 
00092     // read the first line
00093     vTokens = Extra_FileReaderGetTokens(p);
00094     if ( strcmp( vTokens->pArray[0], "edif" ) != 0 )
00095     {
00096         printf( "%s: Wrong input file format.\n", Extra_FileReaderGetFileName(p) );
00097         return NULL;
00098     }
00099     
00100     // allocate the empty network
00101     pNtk = Abc_NtkStartRead( Extra_FileReaderGetFileName(p) );
00102 
00103     // go through the lines of the file
00104     fTokensReady = 0;
00105     pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
00106     for ( iLine = 1; fTokensReady || (vTokens = Extra_FileReaderGetTokens(p)); iLine++ )
00107     {
00108         Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
00109 
00110         // get the type of the line
00111         fTokensReady = 0;
00112         if ( strcmp( vTokens->pArray[0], "instance" ) == 0 )
00113         { 
00114             pNetName = vTokens->pArray[1];
00115             pNet = Abc_NtkFindOrCreateNet( pNtk, pNetName );
00116             vTokens = Extra_FileReaderGetTokens(p);
00117             vTokens = Extra_FileReaderGetTokens(p);
00118             pGateName = vTokens->pArray[1];
00119             if ( strncmp( pGateName, "Flip", 4 ) == 0 )
00120             {
00121                 pObj = Abc_NtkCreateLatch( pNtk );
00122                 Abc_LatchSetInit0( pObj );
00123             }
00124             else
00125             {
00126                 pObj = Abc_NtkCreateNode( pNtk );
00127 //                pObj->pData = Abc_NtkRegisterName( pNtk, pGateName );
00128                 pObj->pData = Extra_UtilStrsav( pGateName ); // memory leak!!!
00129             }
00130             Abc_ObjAddFanin( pNet, pObj );
00131         }
00132         else if ( strcmp( vTokens->pArray[0], "net" ) == 0 )
00133         {
00134             pNetName = vTokens->pArray[1];
00135             if ( strcmp( pNetName, "CK" ) == 0 || strcmp( pNetName, "RESET" ) == 0 )
00136                 continue;
00137             if ( strcmp( pNetName + strlen(pNetName) - 4, "_out" ) == 0 )
00138                 pNetName[strlen(pNetName) - 4] = 0;
00139             pNet = Abc_NtkFindNet( pNtk, pNetName );
00140             assert( pNet );
00141             vTokens = Extra_FileReaderGetTokens(p);
00142             vTokens = Extra_FileReaderGetTokens(p);
00143             vTokens = Extra_FileReaderGetTokens(p);
00144             while ( strcmp( vTokens->pArray[0], "portRef" ) == 0 )
00145             {
00146                 if ( strcmp( pNetName, vTokens->pArray[3] ) != 0 )
00147                 {
00148                     pFanout = Abc_NtkFindNet( pNtk, vTokens->pArray[3] );
00149                     Abc_ObjAddFanin( Abc_ObjFanin0(pFanout), pNet );
00150                 }
00151                 vTokens = Extra_FileReaderGetTokens(p);
00152             }
00153             fTokensReady = 1;
00154         }
00155         else if ( strcmp( vTokens->pArray[0], "library" ) == 0 )
00156         {
00157             vTokens = Extra_FileReaderGetTokens(p);
00158             vTokens = Extra_FileReaderGetTokens(p);
00159             vTokens = Extra_FileReaderGetTokens(p);
00160             vTokens = Extra_FileReaderGetTokens(p);
00161             vTokens = Extra_FileReaderGetTokens(p);
00162             while ( strcmp( vTokens->pArray[0], "port" ) == 0 )
00163             {
00164                 pNetName = vTokens->pArray[1];
00165                 if ( strcmp( pNetName, "CK" ) == 0 || strcmp( pNetName, "RESET" ) == 0 )
00166                 {
00167                     vTokens = Extra_FileReaderGetTokens(p);
00168                     continue;
00169                 }
00170                 if ( strcmp( pNetName + strlen(pNetName) - 3, "_PO" ) == 0 )
00171                     pNetName[strlen(pNetName) - 3] = 0;
00172                 if ( strcmp( vTokens->pArray[3], "INPUT" ) == 0 )
00173                     Io_ReadCreatePi( pNtk, vTokens->pArray[1] );
00174                 else if ( strcmp( vTokens->pArray[3], "OUTPUT" ) == 0 )
00175                     Io_ReadCreatePo( pNtk, vTokens->pArray[1] );
00176                 else
00177                 {
00178                     printf( "%s (line %d): Wrong interface specification.\n", Extra_FileReaderGetFileName(p), iLine );
00179                     Abc_NtkDelete( pNtk );
00180                     return NULL;
00181                 }
00182                 vTokens = Extra_FileReaderGetTokens(p);
00183             }
00184         }
00185         else if ( strcmp( vTokens->pArray[0], "design" ) == 0 )
00186         {
00187             free( pNtk->pName ); 
00188             pNtk->pName = Extra_UtilStrsav( vTokens->pArray[3] );
00189             break;
00190         }
00191     }
00192     Extra_ProgressBarStop( pProgress );
00193 
00194     // assign logic functions
00195     Abc_NtkForEachNode( pNtk, pObj, i )
00196     {
00197         if ( strncmp( pObj->pData, "And", 3 ) == 0 )
00198             Abc_ObjSetData( pObj, Abc_SopCreateAnd(pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
00199         else if ( strncmp( pObj->pData, "Or", 2 ) == 0 )
00200             Abc_ObjSetData( pObj, Abc_SopCreateOr(pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
00201         else if ( strncmp( pObj->pData, "Nand", 4 ) == 0 )
00202             Abc_ObjSetData( pObj, Abc_SopCreateNand(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
00203         else if ( strncmp( pObj->pData, "Nor", 3 ) == 0 )
00204             Abc_ObjSetData( pObj, Abc_SopCreateNor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
00205         else if ( strncmp( pObj->pData, "Exor", 4 ) == 0 )
00206             Abc_ObjSetData( pObj, Abc_SopCreateXor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
00207         else if ( strncmp( pObj->pData, "Exnor", 5 ) == 0 )
00208             Abc_ObjSetData( pObj, Abc_SopCreateNxor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
00209         else if ( strncmp( pObj->pData, "Inv", 3 ) == 0 )
00210             Abc_ObjSetData( pObj, Abc_SopCreateInv(pNtk->pManFunc) );
00211         else if ( strncmp( pObj->pData, "Buf", 3 ) == 0 )
00212             Abc_ObjSetData( pObj, Abc_SopCreateBuf(pNtk->pManFunc) );
00213         else
00214         {
00215             printf( "%s: Unknown gate type \"%s\".\n", Extra_FileReaderGetFileName(p), pObj->pData );
00216             Abc_NtkDelete( pNtk );
00217             return NULL;
00218         }
00219     }
00220     // check if constants have been added
00221 //    if ( pNet = Abc_NtkFindNet( pNtk, "VDD" ) )
00222 //        Io_ReadCreateConst( pNtk, "VDD", 1 );
00223 //    if ( pNet = Abc_NtkFindNet( pNtk, "GND" ) )
00224 //        Io_ReadCreateConst( pNtk, "GND", 0 );
00225 
00226     Abc_NtkFinalizeRead( pNtk );
00227     return pNtk;
00228 }


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