abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioWriteList.c File Reference
#include "ioAbc.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Io_WriteListEdge (FILE *pFile, Abc_Obj_t *pObj)
 DECLARATIONS ///. More...
 
static void Io_WriteListHost (FILE *pFile, Abc_Ntk_t *pNtk)
 
void Io_WriteList (Abc_Ntk_t *pNtk, char *pFileName, int fUseHost)
 FUNCTION DEFINITIONS ///. More...
 
void Io_WriteCellNet (Abc_Ntk_t *pNtk, char *pFileName)
 

Function Documentation

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 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
char * Extra_TimeStamp()
ABC_DLL int Abc_ObjFanoutFaninNum(Abc_Obj_t *pFanout, Abc_Obj_t *pFanin)
Definition: abcFanio.c:321
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
char * pName
Definition: abc.h:158
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
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 }
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
static ABC_NAMESPACE_IMPL_START void Io_WriteListEdge(FILE *pFile, Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: ioWriteList.c:155
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
char * Extra_TimeStamp()
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static void Io_WriteListHost(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteList.c:184
char * pName
Definition: abc.h:158
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Io_WriteListEdge ( FILE *  pFile,
Abc_Obj_t pObj 
)
static

DECLARATIONS ///.

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

FileName [ioWriteList.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write the graph structure of sequential AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file ioWriteList.c.

156 {
157  Abc_Obj_t * pFanout;
158  int i;
159  fprintf( pFile, "%-10s > ", Abc_ObjName(pObj) );
160  Abc_ObjForEachFanout( pObj, pFanout, i )
161  {
162  fprintf( pFile, " %s", Abc_ObjName(pFanout) );
163  fprintf( pFile, " ([%s_to_", Abc_ObjName(pObj) );
164 // fprintf( pFile, "%s] = %d)", Abc_ObjName(pFanout), Seq_ObjFanoutL(pObj, pFanout) );
165  fprintf( pFile, "%s] = %d)", Abc_ObjName(pFanout), 0 );
166  if ( i != Abc_ObjFanoutNum(pObj) - 1 )
167  fprintf( pFile, "," );
168  }
169  fprintf( pFile, "." );
170  fprintf( pFile, "\n" );
171 }
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
void Io_WriteListHost ( FILE *  pFile,
Abc_Ntk_t pNtk 
)
static

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 184 of file ioWriteList.c.

185 {
186  Abc_Obj_t * pObj;
187  int i;
188 
189  Abc_NtkForEachPo( pNtk, pObj, i )
190  {
191  fprintf( pFile, "%-10s > ", Abc_ObjName(pObj) );
192  fprintf( pFile, " %s ([%s_to_%s] = %d)", "HOST", Abc_ObjName(pObj), "HOST", 0 );
193  fprintf( pFile, "." );
194  fprintf( pFile, "\n" );
195  }
196 
197  fprintf( pFile, "%-10s > ", "HOST" );
198  Abc_NtkForEachPi( pNtk, pObj, i )
199  {
200  fprintf( pFile, " %s", Abc_ObjName(pObj) );
201  fprintf( pFile, " ([%s_to_%s] = %d)", "HOST", Abc_ObjName(pObj), 0 );
202  if ( i != Abc_NtkPiNum(pNtk) - 1 )
203  fprintf( pFile, "," );
204  }
205  fprintf( pFile, "." );
206  fprintf( pFile, "\n" );
207 }
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513