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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Io_WriteBaf (Abc_Ntk_t *pNtk, char *pFileName)
 DECLARATIONS ///.
 

Function Documentation

◆ Io_WriteBaf()

ABC_NAMESPACE_IMPL_START void Io_WriteBaf ( Abc_Ntk_t * pNtk,
char * pFileName )

DECLARATIONS ///.

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

FileName [ioWriteBaf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write AIG in the binary format.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Writes the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file ioWriteBaf.c.

85{
86 ProgressBar * pProgress;
87 FILE * pFile;
88 Abc_Obj_t * pObj;
89 int i, nNodes, nAnds, nBufferSize;
90 unsigned * pBufferNode;
91 assert( Abc_NtkIsStrash(pNtk) );
92 // start the output stream
93 pFile = fopen( pFileName, "wb" );
94 if ( pFile == NULL )
95 {
96 fprintf( stdout, "Io_WriteBaf(): Cannot open the output file \"%s\".\n", pFileName );
97 return;
98 }
99
100 // write the comment
101 fprintf( pFile, "# BAF (Binary Aig Format) for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
102
103 // write the network name
104 fprintf( pFile, "%s%c", pNtk->pName, 0 );
105 // write the number of PIs
106 fprintf( pFile, "%d%c", Abc_NtkPiNum(pNtk), 0 );
107 // write the number of POs
108 fprintf( pFile, "%d%c", Abc_NtkPoNum(pNtk), 0 );
109 // write the number of latches
110 fprintf( pFile, "%d%c", Abc_NtkLatchNum(pNtk), 0 );
111 // write the number of internal nodes
112 fprintf( pFile, "%d%c", Abc_NtkNodeNum(pNtk), 0 );
113
114 // write PIs
115 Abc_NtkForEachPi( pNtk, pObj, i )
116 fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
117 // write POs
118 Abc_NtkForEachPo( pNtk, pObj, i )
119 fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
120 // write latches
121 Abc_NtkForEachLatch( pNtk, pObj, i )
122 {
123 fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
124 fprintf( pFile, "%s%c", Abc_ObjName(Abc_ObjFanin0(pObj)), 0 );
125 fprintf( pFile, "%s%c", Abc_ObjName(Abc_ObjFanout0(pObj)), 0 );
126 }
127
128 // set the node numbers to be used in the output file
129 Abc_NtkCleanCopy( pNtk );
130 nNodes = 1;
131 Abc_NtkForEachCi( pNtk, pObj, i )
132 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)nNodes++;
133 Abc_AigForEachAnd( pNtk, pObj, i )
134 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)nNodes++;
135
136 // write the nodes into the buffer
137 nAnds = 0;
138 nBufferSize = Abc_NtkNodeNum(pNtk) * 2 + Abc_NtkCoNum(pNtk);
139 pBufferNode = ABC_ALLOC( unsigned, nBufferSize );
140 pProgress = Extra_ProgressBarStart( stdout, nBufferSize );
141 Abc_AigForEachAnd( pNtk, pObj, i )
142 {
143 Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
144 pBufferNode[nAnds++] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | (int)Abc_ObjFaninC0(pObj);
145 pBufferNode[nAnds++] = (((int)(ABC_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy) << 1) | (int)Abc_ObjFaninC1(pObj);
146 }
147
148 // write the COs into the buffer
149 Abc_NtkForEachCo( pNtk, pObj, i )
150 {
151 Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
152 pBufferNode[nAnds] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | (int)Abc_ObjFaninC0(pObj);
153 if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
154 pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((int)(ABC_PTRINT_T)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3);
155 nAnds++;
156 }
157 Extra_ProgressBarStop( pProgress );
158 assert( nBufferSize == nAnds );
159
160 // write the buffer
161 fwrite( pBufferNode, 1, sizeof(int) * nBufferSize, pFile );
162 fclose( pFile );
163 ABC_FREE( pBufferNode );
164}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
#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)
char * Extra_TimeStamp()
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
char * pName
Definition abc.h:158
Abc_Obj_t * pCopy
Definition abc.h:148
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function: