src/base/io/ioWriteBench.c File Reference

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

Go to the source code of this file.

Functions

static int Io_WriteBenchCheckNames (Abc_Ntk_t *pNtk)
static int Io_WriteBenchOne (FILE *pFile, Abc_Ntk_t *pNtk)
static int Io_WriteBenchOneNode (FILE *pFile, Abc_Obj_t *pNode)
static int Io_WriteBenchLutOne (FILE *pFile, Abc_Ntk_t *pNtk)
static int Io_WriteBenchLutOneNode (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vTruth)
int Io_WriteBench (Abc_Ntk_t *pNtk, char *pFileName)
int Io_WriteBenchLut (Abc_Ntk_t *pNtk, char *pFileName)

Function Documentation

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_WriteBenchCheckNames ( Abc_Ntk_t pNtk  )  [static]

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

FileName [ioWriteBench.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
ioWriteBench.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS ///

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

Synopsis [Returns 1 if the names cannot be written into the bench file.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file ioWriteBench.c.

00320 {
00321     Abc_Obj_t * pObj;
00322     char * pName;
00323     int i;
00324     Abc_NtkForEachObj( pNtk, pObj, i )
00325         for ( pName = Nm_ManFindNameById(pNtk->pManName, i); pName && *pName; pName++ )
00326             if ( *pName == '(' || *pName == ')' )
00327                 return 0;
00328     return 1;
00329 }

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 }

int Io_WriteBenchLutOne ( FILE *  pFile,
Abc_Ntk_t pNtk 
) [static]

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

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 211 of file ioWriteBench.c.

00212 {
00213     ProgressBar * pProgress;
00214     Abc_Obj_t * pNode;
00215     Vec_Int_t * vMemory;
00216     int i;
00217 
00218     // write the PIs/POs/latches
00219     Abc_NtkForEachPi( pNtk, pNode, i )
00220         fprintf( pFile, "INPUT(%s)\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
00221     Abc_NtkForEachPo( pNtk, pNode, i )
00222         fprintf( pFile, "OUTPUT(%s)\n", Abc_ObjName(Abc_ObjFanin0(pNode)) );
00223     Abc_NtkForEachLatch( pNtk, pNode, i )
00224         fprintf( pFile, "%-11s = DFFRSE( %s, gnd, gnd, gnd, gnd )\n", 
00225             Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode))), Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pNode))) );
00226 //Abc_NtkLevel(pNtk);
00227     // write internal nodes
00228     vMemory = Vec_IntAlloc( 10000 );
00229     pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
00230     Abc_NtkForEachNode( pNtk, pNode, i )
00231     {
00232         Extra_ProgressBarUpdate( pProgress, i, NULL );
00233         Io_WriteBenchLutOneNode( pFile, pNode, vMemory );
00234     }
00235     Extra_ProgressBarStop( pProgress );
00236     Vec_IntFree( vMemory );
00237     return 1;
00238 }

int Io_WriteBenchLutOneNode ( FILE *  pFile,
Abc_Obj_t pNode,
Vec_Int_t vTruth 
) [static]

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

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file ioWriteBench.c.

00253 {
00254     Abc_Obj_t * pFanin;
00255     unsigned * pTruth;
00256     int i, nFanins;
00257     assert( Abc_ObjIsNode(pNode) );
00258     nFanins = Abc_ObjFaninNum(pNode);
00259     assert( nFanins <= 8 );
00260     // compute the truth table
00261     pTruth = Abc_ConvertAigToTruth( pNode->pNtk->pManFunc, Hop_Regular(pNode->pData), nFanins, vTruth, 0 );
00262     if ( Hop_IsComplement(pNode->pData) )
00263         Extra_TruthNot( pTruth, pTruth, nFanins );
00264     // consider simple cases
00265     if ( Extra_TruthIsConst0(pTruth, nFanins) )
00266     {
00267         fprintf( pFile, "%-11s = gnd\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
00268         return 1;
00269     }
00270     if ( Extra_TruthIsConst1(pTruth, nFanins) )
00271     {
00272         fprintf( pFile, "%-11s = vdd\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
00273         return 1;
00274     }
00275     if ( nFanins == 1 )
00276     {
00277         fprintf( pFile, "%-11s = LUT 0x%d ( %s )\n",  
00278             Abc_ObjName(Abc_ObjFanout0(pNode)), 
00279             Abc_NodeIsBuf(pNode)? 2 : 1,
00280             Abc_ObjName(Abc_ObjFanin0(pNode)) );
00281         return 1;
00282     }
00283     // write it in the hexadecimal form
00284     fprintf( pFile, "%-11s = LUT 0x",  Abc_ObjName(Abc_ObjFanout0(pNode)) );
00285     Extra_PrintHexadecimal( pFile, pTruth, nFanins );
00286 /*
00287     {
00288 extern void Kit_DsdTest( unsigned * pTruth, int nVars );
00289 Abc_ObjForEachFanin( pNode, pFanin, i )
00290 printf( "%c%d ", 'a'+i, Abc_ObjFanin0(pFanin)->Level );
00291 printf( "\n" );
00292 Kit_DsdTest( pTruth, nFanins );
00293     }
00294     if ( pNode->Id % 1000 == 0 )
00295     {
00296         int x = 0;
00297     }
00298 */
00299     // write the fanins
00300     fprintf( pFile, " (" );
00301     Abc_ObjForEachFanin( pNode, pFanin, i )
00302         fprintf( pFile, " %s%s", Abc_ObjName(pFanin), ((i==nFanins-1)? "" : ",") );
00303     fprintf( pFile, " )\n" );
00304     return 1;
00305 }

int Io_WriteBenchOne ( FILE *  pFile,
Abc_Ntk_t pNtk 
) [static]

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

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file ioWriteBench.c.

00090 {
00091     ProgressBar * pProgress;
00092     Abc_Obj_t * pNode;
00093     int i;
00094 
00095     // write the PIs/POs/latches
00096     Abc_NtkForEachPi( pNtk, pNode, i )
00097         fprintf( pFile, "INPUT(%s)\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
00098     Abc_NtkForEachPo( pNtk, pNode, i )
00099         fprintf( pFile, "OUTPUT(%s)\n", Abc_ObjName(Abc_ObjFanin0(pNode)) );
00100     Abc_NtkForEachLatch( pNtk, pNode, i )
00101         fprintf( pFile, "%-11s = DFF(%s)\n", 
00102             Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode))), Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pNode))) );
00103 
00104     // write internal nodes
00105     pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
00106     Abc_NtkForEachNode( pNtk, pNode, i )
00107     {
00108         Extra_ProgressBarUpdate( pProgress, i, NULL );
00109         Io_WriteBenchOneNode( pFile, pNode );
00110     }
00111     Extra_ProgressBarStop( pProgress );
00112     return 1;
00113 }

int Io_WriteBenchOneNode ( FILE *  pFile,
Abc_Obj_t pNode 
) [static]

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

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 127 of file ioWriteBench.c.

00128 {
00129     int nFanins;
00130 
00131     assert( Abc_ObjIsNode(pNode) );
00132     nFanins = Abc_ObjFaninNum(pNode);
00133     if ( nFanins == 0 )
00134     {   // write the constant 1 node
00135         assert( Abc_NodeIsConst1(pNode) );
00136         fprintf( pFile, "%-11s",          Abc_ObjName(Abc_ObjFanout0(pNode)) );
00137         fprintf( pFile, " = vdd\n" );
00138     }
00139     else if ( nFanins == 1 )
00140     {   // write the interver/buffer
00141         if ( Abc_NodeIsBuf(pNode) )
00142         {
00143             fprintf( pFile, "%-11s = BUFF(",  Abc_ObjName(Abc_ObjFanout0(pNode)) );
00144             fprintf( pFile, "%s)\n",          Abc_ObjName(Abc_ObjFanin0(pNode)) );
00145         }
00146         else
00147         {
00148             fprintf( pFile, "%-11s = NOT(",   Abc_ObjName(Abc_ObjFanout0(pNode)) );
00149             fprintf( pFile, "%s)\n",          Abc_ObjName(Abc_ObjFanin0(pNode)) );
00150         }
00151     }
00152     else
00153     {   // write the AND gate
00154         fprintf( pFile, "%-11s",       Abc_ObjName(Abc_ObjFanout0(pNode)) );
00155         fprintf( pFile, " = AND(%s, ", Abc_ObjName(Abc_ObjFanin0(pNode)) );
00156         fprintf( pFile, "%s)\n",       Abc_ObjName(Abc_ObjFanin1(pNode)) );
00157     }
00158     return 1;
00159 }


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