src/base/io/ioWriteEqn.c File Reference

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

Go to the source code of this file.

Functions

static void Io_NtkWriteEqnOne (FILE *pFile, Abc_Ntk_t *pNtk)
static void Io_NtkWriteEqnCis (FILE *pFile, Abc_Ntk_t *pNtk)
static void Io_NtkWriteEqnCos (FILE *pFile, Abc_Ntk_t *pNtk)
static int Io_NtkWriteEqnCheck (Abc_Ntk_t *pNtk)
void Io_WriteEqn (Abc_Ntk_t *pNtk, char *pFileName)

Function Documentation

int Io_NtkWriteEqnCheck ( Abc_Ntk_t pNtk  )  [static]

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

Synopsis [Make sure the network does not have offending names.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file ioWriteEqn.c.

00213 {
00214     Abc_Obj_t * pObj;
00215     char * pName;
00216     int i, k, Length;
00217     int RetValue = 1;
00218 
00219     // make sure the network does not have proper names, such as "0" or "1" or containing parantheses
00220     Abc_NtkForEachObj( pNtk, pObj, i )
00221     {
00222         pName = Nm_ManFindNameById(pNtk->pManName, i);
00223         if ( pName == NULL )
00224             continue;
00225         Length = strlen(pName);
00226         if ( pName[0] == '0' || pName[0] == '1' )
00227         {
00228             RetValue = 0;
00229             break;
00230         }
00231         for ( k = 0; k < Length; k++ )
00232             if ( pName[k] == '(' || pName[k] == ')' || pName[k] == '!' || pName[k] == '*' || pName[k] == '+' )
00233             {
00234                 RetValue = 0;
00235                 break;
00236             }
00237         if ( k < Length )
00238             break;
00239     }
00240     if ( RetValue == 0 )
00241     {
00242         printf( "The network cannot be written in the EQN format because object %d has name \"%s\".\n", i, pName );
00243         printf( "Consider renaming the objects using command \"short_names\" and trying again.\n" );
00244     }
00245     return RetValue;
00246 }

void Io_NtkWriteEqnCis ( FILE *  pFile,
Abc_Ntk_t pNtk 
) [static]

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

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file ioWriteEqn.c.

00133 {
00134     Abc_Obj_t * pTerm, * pNet;
00135     int LineLength;
00136     int AddedLength;
00137     int NameCounter;
00138     int i;
00139 
00140     LineLength  = 9;
00141     NameCounter = 0;
00142 
00143     Abc_NtkForEachCi( pNtk, pTerm, i )
00144     {
00145         pNet = Abc_ObjFanout0(pTerm);
00146         // get the line length after this name is written
00147         AddedLength = strlen(Abc_ObjName(pNet)) + 1;
00148         if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
00149         { // write the line extender
00150             fprintf( pFile, " \n" );
00151             // reset the line length
00152             LineLength  = 0;
00153             NameCounter = 0;
00154         }
00155         fprintf( pFile, " %s", Abc_ObjName(pNet) );
00156         LineLength += AddedLength;
00157         NameCounter++;
00158     }
00159 }

void Io_NtkWriteEqnCos ( FILE *  pFile,
Abc_Ntk_t pNtk 
) [static]

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

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file ioWriteEqn.c.

00173 {
00174     Abc_Obj_t * pTerm, * pNet;
00175     int LineLength;
00176     int AddedLength;
00177     int NameCounter;
00178     int i;
00179 
00180     LineLength  = 10;
00181     NameCounter = 0;
00182 
00183     Abc_NtkForEachCo( pNtk, pTerm, i )
00184     {
00185         pNet = Abc_ObjFanin0(pTerm);
00186         // get the line length after this name is written
00187         AddedLength = strlen(Abc_ObjName(pNet)) + 1;
00188         if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
00189         { // write the line extender
00190             fprintf( pFile, " \n" );
00191             // reset the line length
00192             LineLength  = 0;
00193             NameCounter = 0;
00194         }
00195         fprintf( pFile, " %s", Abc_ObjName(pNet) );
00196         LineLength += AddedLength;
00197         NameCounter++;
00198     }
00199 }

void Io_NtkWriteEqnOne ( FILE *  pFile,
Abc_Ntk_t pNtk 
) [static]

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

FileName [ioWriteEqn.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write equation representation of the network.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] DECLARATIONS ///

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

Synopsis [Write one network.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file ioWriteEqn.c.

00086 {
00087     Vec_Vec_t * vLevels;
00088     ProgressBar * pProgress;
00089     Abc_Obj_t * pNode, * pFanin;
00090     int i, k;
00091 
00092     // write the PIs
00093     fprintf( pFile, "INORDER =" );
00094     Io_NtkWriteEqnCis( pFile, pNtk );
00095     fprintf( pFile, ";\n" );
00096 
00097     // write the POs
00098     fprintf( pFile, "OUTORDER =" );
00099     Io_NtkWriteEqnCos( pFile, pNtk );
00100     fprintf( pFile, ";\n" );
00101 
00102     // write each internal node
00103     vLevels = Vec_VecAlloc( 10 );
00104     pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
00105     Abc_NtkForEachNode( pNtk, pNode, i )
00106     {
00107         Extra_ProgressBarUpdate( pProgress, i, NULL );
00108         fprintf( pFile, "%s = ", Abc_ObjName(Abc_ObjFanout0(pNode)) );
00109         // set the input names
00110         Abc_ObjForEachFanin( pNode, pFanin, k )
00111             Hop_IthVar(pNtk->pManFunc, k)->pData = Abc_ObjName(pFanin);
00112         // write the formula
00113         Hop_ObjPrintEqn( pFile, pNode->pData, vLevels, 0 );
00114         fprintf( pFile, ";\n" );
00115     }
00116     Extra_ProgressBarStop( pProgress );
00117     Vec_VecFree( vLevels );
00118 }

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 }


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