src/base/io/ioWritePla.c File Reference

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

Go to the source code of this file.

Functions

static int Io_WritePlaOne (FILE *pFile, Abc_Ntk_t *pNtk)
int Io_WritePla (Abc_Ntk_t *pNtk, char *pFileName)

Function Documentation

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 }

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

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

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

] DECLARATIONS ///

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

Synopsis [Writes the network in PLA format.]

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file ioWritePla.c.

00082 {
00083     ProgressBar * pProgress;
00084     Abc_Obj_t * pNode, * pFanin, * pDriver;
00085     char * pCubeIn, * pCubeOut, * pCube;
00086     int i, k, nProducts, nInputs, nOutputs, nFanins;
00087 
00088     nProducts = 0;
00089     Abc_NtkForEachCo( pNtk, pNode, i )
00090     {
00091         pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pNode) );
00092         if ( !Abc_ObjIsNode(pDriver) )
00093         {
00094             nProducts++;
00095             continue;
00096         }
00097         if ( Abc_NodeIsConst(pDriver) )
00098         {
00099             if ( Abc_NodeIsConst1(pDriver) )
00100                 nProducts++;
00101             continue;
00102         }
00103         nProducts += Abc_SopGetCubeNum(pDriver->pData);
00104     }
00105 
00106     // collect the parameters
00107     nInputs  = Abc_NtkCiNum(pNtk);
00108     nOutputs = Abc_NtkCoNum(pNtk);
00109     pCubeIn  = ALLOC( char, nInputs + 1 );
00110     pCubeOut = ALLOC( char, nOutputs + 1 );
00111     memset( pCubeIn,  '-', nInputs );     pCubeIn[nInputs]   = 0;
00112     memset( pCubeOut, '0', nOutputs );    pCubeOut[nOutputs] = 0;
00113 
00114     // write the header
00115     fprintf( pFile, ".i %d\n", nInputs );
00116     fprintf( pFile, ".o %d\n", nOutputs );
00117     fprintf( pFile, ".ilb" );
00118     Abc_NtkForEachCi( pNtk, pNode, i )
00119         fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanout0(pNode)) );
00120     fprintf( pFile, "\n" );
00121     fprintf( pFile, ".ob" );
00122     Abc_NtkForEachCo( pNtk, pNode, i )
00123         fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin0(pNode)) );
00124     fprintf( pFile, "\n" );
00125     fprintf( pFile, ".p %d\n", nProducts );
00126 
00127     // mark the CI nodes
00128     Abc_NtkForEachCi( pNtk, pNode, i )
00129         pNode->pCopy = (Abc_Obj_t *)i;
00130 
00131     // write the cubes
00132     pProgress = Extra_ProgressBarStart( stdout, nOutputs );
00133     Abc_NtkForEachCo( pNtk, pNode, i )
00134     {
00135         // prepare the output cube
00136         if ( i - 1 >= 0 )
00137             pCubeOut[i-1] = '0';
00138         pCubeOut[i] = '1';
00139 
00140         // consider special cases of nodes
00141         pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pNode) );
00142         if ( !Abc_ObjIsNode(pDriver) )
00143         {
00144             assert( Abc_ObjIsCi(pDriver) );
00145             pCubeIn[(int)pDriver->pCopy] = '1' - Abc_ObjFaninC0(pNode);
00146             fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut );
00147             pCubeIn[(int)pDriver->pCopy] = '-';
00148             continue;
00149         }
00150         if ( Abc_NodeIsConst(pDriver) )
00151         {
00152             if ( Abc_NodeIsConst1(pDriver) )
00153                 fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut );
00154             continue;
00155         }
00156 
00157         // make sure the cover is not complemented
00158         assert( !Abc_SopIsComplement( pDriver->pData ) );
00159 
00160         // write the cubes
00161         nFanins = Abc_ObjFaninNum(pDriver);
00162         Abc_SopForEachCube( pDriver->pData, nFanins, pCube )
00163         {
00164             Abc_ObjForEachFanin( pDriver, pFanin, k )
00165             {
00166                 pFanin = Abc_ObjFanin0Ntk(pFanin);
00167                 assert( (int)pFanin->pCopy < nInputs );
00168                 pCubeIn[(int)pFanin->pCopy] = pCube[k];
00169             }
00170             fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut );
00171         }
00172         // clean the cube for future writing
00173         Abc_ObjForEachFanin( pDriver, pFanin, k )
00174         {
00175             pFanin = Abc_ObjFanin0Ntk(pFanin);
00176             assert( Abc_ObjIsCi(pFanin) );
00177             pCubeIn[(int)pFanin->pCopy] = '-';
00178         }
00179         Extra_ProgressBarUpdate( pProgress, i, NULL );
00180     }
00181     Extra_ProgressBarStop( pProgress );
00182     fprintf( pFile, ".e\n" );
00183 
00184     // clean the CI nodes
00185     Abc_NtkForEachCi( pNtk, pNode, i )
00186         pNode->pCopy = NULL;
00187     free( pCubeIn );
00188     free( pCubeOut );
00189     return 1;
00190 }


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