ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioWritePla.c File Reference
#include "ioAbc.h"
Include dependency graph for ioWritePla.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Io_WritePlaOne (FILE *pFile, Abc_Ntk_t *pNtk)
 DECLARATIONS ///.
 
int Io_WritePla (Abc_Ntk_t *pNtk, char *pFileName)
 
int Io_WriteMoPla (Abc_Ntk_t *pNtk, char *pFileName)
 
int Io_WriteMoPlaM (Abc_Ntk_t *pNtk, char *pFileName, int nMints)
 

Function Documentation

◆ Io_WriteMoPla()

int Io_WriteMoPla ( Abc_Ntk_t * pNtk,
char * pFileName )

Definition at line 576 of file ioWritePla.c.

576{ return 1; }
Here is the caller graph for this function:

◆ Io_WriteMoPlaM()

int Io_WriteMoPlaM ( Abc_Ntk_t * pNtk,
char * pFileName,
int nMints )

Definition at line 577 of file ioWritePla.c.

577{ return 1; }

◆ Io_WritePla()

int Io_WritePla ( Abc_Ntk_t * pNtk,
char * pFileName )

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

Synopsis [Writes the network in PLA format.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file ioWritePla.c.

172{
173 Abc_Ntk_t * pExdc;
174 FILE * pFile;
175
176 assert( Abc_NtkIsSopNetlist(pNtk) );
177 assert( Abc_NtkLevel(pNtk) == 1 );
178
179 pFile = fopen( pFileName, "w" );
180 if ( pFile == NULL )
181 {
182 fprintf( stdout, "Io_WritePla(): Cannot open the output file.\n" );
183 return 0;
184 }
185 fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
186 // write the network
187 Io_WritePlaOne( pFile, pNtk );
188 // write EXDC network if it exists
189 pExdc = Abc_NtkExdc( pNtk );
190 if ( pExdc )
191 printf( "Io_WritePla: EXDC is not written (warning).\n" );
192 // finalize the file
193 fclose( pFile );
194 return 1;
195}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1449
char * Extra_TimeStamp()
ABC_NAMESPACE_IMPL_START int Io_WritePlaOne(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition ioWritePla.c:49
char * pName
Definition abc.h:158
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WritePlaOne()

ABC_NAMESPACE_IMPL_START int Io_WritePlaOne ( FILE * pFile,
Abc_Ntk_t * pNtk )

DECLARATIONS ///.

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

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

Synopsis [Writes the network in PLA format.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file ioWritePla.c.

50{
51 ProgressBar * pProgress;
52 Abc_Obj_t * pNode, * pFanin, * pDriver;
53 char * pCubeIn, * pCubeOut, * pCube;
54 int i, k, nProducts, nInputs, nOutputs, nFanins;
55
56 nProducts = 0;
57 Abc_NtkForEachCo( pNtk, pNode, i )
58 {
59 pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pNode) );
60 if ( !Abc_ObjIsNode(pDriver) )
61 {
62 nProducts++;
63 continue;
64 }
65 if ( Abc_NodeIsConst(pDriver) )
66 {
67 if ( Abc_NodeIsConst1(pDriver) )
68 nProducts++;
69 continue;
70 }
71 nProducts += Abc_SopGetCubeNum((char *)pDriver->pData);
72 }
73
74 // collect the parameters
75 nInputs = Abc_NtkCiNum(pNtk);
76 nOutputs = Abc_NtkCoNum(pNtk);
77 pCubeIn = ABC_ALLOC( char, nInputs + 1 );
78 pCubeOut = ABC_ALLOC( char, nOutputs + 1 );
79 memset( pCubeIn, '-', (size_t)nInputs ); pCubeIn[nInputs] = 0;
80 memset( pCubeOut, '0', (size_t)nOutputs ); pCubeOut[nOutputs] = 0;
81
82 // write the header
83 fprintf( pFile, ".i %d\n", nInputs );
84 fprintf( pFile, ".o %d\n", nOutputs );
85 fprintf( pFile, ".ilb" );
86 Abc_NtkForEachCi( pNtk, pNode, i )
87 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanout0(pNode)) );
88 fprintf( pFile, "\n" );
89 fprintf( pFile, ".ob" );
90 Abc_NtkForEachCo( pNtk, pNode, i )
91 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin0(pNode)) );
92 fprintf( pFile, "\n" );
93 fprintf( pFile, ".p %d\n", nProducts );
94
95 // mark the CI nodes
96 Abc_NtkForEachCi( pNtk, pNode, i )
97 pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)i;
98
99 // write the cubes
100 pProgress = Extra_ProgressBarStart( stdout, nOutputs );
101 Abc_NtkForEachCo( pNtk, pNode, i )
102 {
103 // prepare the output cube
104 if ( i - 1 >= 0 )
105 pCubeOut[i-1] = '0';
106 pCubeOut[i] = '1';
107
108 // consider special cases of nodes
109 pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pNode) );
110 if ( !Abc_ObjIsNode(pDriver) )
111 {
112 assert( Abc_ObjIsCi(pDriver) );
113 pCubeIn[(int)(ABC_PTRUINT_T)pDriver->pCopy] = '1' - Abc_ObjFaninC0(pNode);
114 fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut );
115 pCubeIn[(int)(ABC_PTRUINT_T)pDriver->pCopy] = '-';
116 continue;
117 }
118 if ( Abc_NodeIsConst(pDriver) )
119 {
120 if ( Abc_NodeIsConst1(pDriver) )
121 fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut );
122 continue;
123 }
124
125 // make sure the cover is not complemented
126 assert( !Abc_SopIsComplement( (char *)pDriver->pData ) );
127
128 // write the cubes
129 nFanins = Abc_ObjFaninNum(pDriver);
130 Abc_SopForEachCube( (char *)pDriver->pData, nFanins, pCube )
131 {
132 Abc_ObjForEachFanin( pDriver, pFanin, k )
133 {
134 pFanin = Abc_ObjFanin0Ntk(pFanin);
135 assert( (int)(ABC_PTRUINT_T)pFanin->pCopy < nInputs );
136 pCubeIn[(int)(ABC_PTRUINT_T)pFanin->pCopy] = pCube[k];
137 }
138 fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut );
139 }
140 // clean the cube for future writing
141 Abc_ObjForEachFanin( pDriver, pFanin, k )
142 {
143 pFanin = Abc_ObjFanin0Ntk(pFanin);
144 assert( Abc_ObjIsCi(pFanin) );
145 pCubeIn[(int)(ABC_PTRUINT_T)pFanin->pCopy] = '-';
146 }
147 Extra_ProgressBarUpdate( pProgress, i, NULL );
148 }
149 Extra_ProgressBarStop( pProgress );
150 fprintf( pFile, ".e\n" );
151
152 // clean the CI nodes
153 Abc_NtkForEachCi( pNtk, pNode, i )
154 pNode->pCopy = NULL;
155 ABC_FREE( pCubeIn );
156 ABC_FREE( pCubeOut );
157 return 1;
158}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition abcObj.c:867
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition abcSop.c:703
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
Definition abcObj.c:916
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
void * pData
Definition abc.h:145
Abc_Obj_t * pCopy
Definition abc.h:148
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function: