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

Go to the source code of this file.

Functions

void Io_WriteList (Abc_Ntk_t *pNtk, char *pFileName, int fUseHost)
 FUNCTION DEFINITIONS ///.
 
void Io_WriteCellNet (Abc_Ntk_t *pNtk, char *pFileName)
 

Function Documentation

◆ Io_WriteCellNet()

void Io_WriteCellNet ( Abc_Ntk_t * pNtk,
char * pFileName )

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

Synopsis [Writes the adjacency list for a sequential AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file ioWriteList.c.

222{
223 FILE * pFile;
224 Abc_Obj_t * pObj, * pFanout;
225 int i, k;
226
227 assert( Abc_NtkIsLogic(pNtk) );
228
229 // start the output stream
230 pFile = fopen( pFileName, "w" );
231 if ( pFile == NULL )
232 {
233 fprintf( stdout, "Io_WriteCellNet(): Cannot open the output file \"%s\".\n", pFileName );
234 return;
235 }
236
237 fprintf( pFile, "# CellNet file for network \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
238
239 // the only tricky part with writing is handling latches:
240 // each latch comes with (a) single-input latch-input node, (b) latch proper, (c) single-input latch-output node
241 // we arbitrarily decide to use the interger ID of the latch-input node to represent the latch in the file
242 // (this ID is used for both the cell and the net driven by that cell)
243
244 // write the PIs
245 Abc_NtkForEachPi( pNtk, pObj, i )
246 fprintf( pFile, "cell %d is 0\n", pObj->Id );
247 // write the POs
248 Abc_NtkForEachPo( pNtk, pObj, i )
249 fprintf( pFile, "cell %d is 1\n", pObj->Id );
250 // write the latches (use the ID of latch input)
251 Abc_NtkForEachLatch( pNtk, pObj, i )
252 fprintf( pFile, "cell %d is 2\n", Abc_ObjFanin0(pObj)->Id );
253 // write the logic nodes
254 Abc_NtkForEachNode( pNtk, pObj, i )
255 fprintf( pFile, "cell %d is %d\n", pObj->Id, 3+Abc_ObjFaninNum(pObj) );
256
257 // write the nets driven by PIs
258 Abc_NtkForEachPi( pNtk, pObj, i )
259 {
260 fprintf( pFile, "net %d %d 0", pObj->Id, pObj->Id );
261 Abc_ObjForEachFanout( pObj, pFanout, k )
262 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
263 fprintf( pFile, "\n" );
264 }
265 // write the nets driven by latches
266 Abc_NtkForEachLatch( pNtk, pObj, i )
267 {
268 fprintf( pFile, "net %d %d 0", Abc_ObjFanin0(pObj)->Id, Abc_ObjFanin0(pObj)->Id );
269 pObj = Abc_ObjFanout0(pObj);
270 Abc_ObjForEachFanout( pObj, pFanout, k )
271 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
272 fprintf( pFile, "\n" );
273 }
274 // write the nets driven by nodes
275 Abc_NtkForEachNode( pNtk, pObj, i )
276 {
277 fprintf( pFile, "net %d %d 0", pObj->Id, pObj->Id );
278 Abc_ObjForEachFanout( pObj, pFanout, k )
279 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
280 fprintf( pFile, "\n" );
281 }
282
283 fprintf( pFile, "\n" );
284 fclose( pFile );
285}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
ABC_DLL int Abc_ObjFanoutFaninNum(Abc_Obj_t *pFanout, Abc_Obj_t *pFanin)
Definition abcFanio.c:373
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
char * Extra_TimeStamp()
char * pName
Definition abc.h:158
int Id
Definition abc.h:132
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Io_WriteList()

void Io_WriteList ( Abc_Ntk_t * pNtk,
char * pFileName,
int fUseHost )

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes the adjacency list for a sequential AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file ioWriteList.c.

103{
104 FILE * pFile;
105 Abc_Obj_t * pObj;
106 int i;
107
108// assert( Abc_NtkIsSeq(pNtk) );
109
110 // start the output stream
111 pFile = fopen( pFileName, "w" );
112 if ( pFile == NULL )
113 {
114 fprintf( stdout, "Io_WriteList(): Cannot open the output file \"%s\".\n", pFileName );
115 return;
116 }
117
118 fprintf( pFile, "# Adjacency list for sequential AIG \"%s\"\n", pNtk->pName );
119 fprintf( pFile, "# written by ABC on %s\n", Extra_TimeStamp() );
120
121 // write the constant node
122 if ( Abc_ObjFanoutNum( Abc_AigConst1(pNtk) ) > 0 )
123 Io_WriteListEdge( pFile, Abc_AigConst1(pNtk) );
124
125 // write the PI edges
126 Abc_NtkForEachPi( pNtk, pObj, i )
127 Io_WriteListEdge( pFile, pObj );
128
129 // write the internal nodes
130 Abc_AigForEachAnd( pNtk, pObj, i )
131 Io_WriteListEdge( pFile, pObj );
132
133 // write the host node
134 if ( fUseHost )
135 Io_WriteListHost( pFile, pNtk );
136 else
137 Abc_NtkForEachPo( pNtk, pObj, i )
138 Io_WriteListEdge( pFile, pObj );
139
140 fprintf( pFile, "\n" );
141 fclose( pFile );
142}
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
Here is the call graph for this function: