#include "ioa.h"
Go to the source code of this file.
Functions | |
static unsigned | Ioa_ObjMakeLit (int Var, int fCompl) |
static unsigned | Ioa_ObjAigerNum (Aig_Obj_t *pObj) |
static void | Ioa_ObjSetAigerNum (Aig_Obj_t *pObj, unsigned Num) |
int | Ioa_WriteAigerEncode (char *pBuffer, int Pos, unsigned x) |
void | Ioa_WriteAiger (Aig_Man_t *pMan, char *pFileName, int fWriteSymbols) |
static unsigned Ioa_ObjAigerNum | ( | Aig_Obj_t * | pObj | ) | [static] |
Definition at line 129 of file ioaWriteAig.c.
00129 { return (unsigned)pObj->pData; }
static unsigned Ioa_ObjMakeLit | ( | int | Var, | |
int | fCompl | |||
) | [static] |
CFile****************************************************************
FileName [ioaWriteAiger.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedures to write binary AIGER format developed by Armin Biere, Johannes Kepler University (http://fmv.jku.at/)]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - December 16, 2006.]
Revision [
] DECLARATIONS ///
Definition at line 128 of file ioaWriteAig.c.
static void Ioa_ObjSetAigerNum | ( | Aig_Obj_t * | pObj, | |
unsigned | Num | |||
) | [static] |
Definition at line 130 of file ioaWriteAig.c.
00130 { pObj->pData = (void *)Num; }
void Ioa_WriteAiger | ( | Aig_Man_t * | pMan, | |
char * | pFileName, | |||
int | fWriteSymbols | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Writes the AIG in the binary AIGER format.]
Description []
SideEffects []
SeeAlso []
Definition at line 149 of file ioaWriteAig.c.
00150 { 00151 Bar_Progress_t * pProgress; 00152 FILE * pFile; 00153 Aig_Obj_t * pObj, * pDriver; 00154 int i, nNodes, Pos, nBufferSize; 00155 unsigned char * pBuffer; 00156 unsigned uLit0, uLit1, uLit; 00157 00158 // assert( Aig_ManIsStrash(pMan) ); 00159 // start the output stream 00160 pFile = fopen( pFileName, "wb" ); 00161 if ( pFile == NULL ) 00162 { 00163 fprintf( stdout, "Ioa_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName ); 00164 return; 00165 } 00166 /* 00167 Aig_ManForEachLatch( pMan, pObj, i ) 00168 if ( !Aig_LatchIsInit0(pObj) ) 00169 { 00170 fprintf( stdout, "Ioa_WriteAiger(): Cannot write AIGER format with non-0 latch init values. Run \"zero\".\n" ); 00171 return; 00172 } 00173 */ 00174 // set the node numbers to be used in the output file 00175 nNodes = 0; 00176 Ioa_ObjSetAigerNum( Aig_ManConst1(pMan), nNodes++ ); 00177 Aig_ManForEachPi( pMan, pObj, i ) 00178 Ioa_ObjSetAigerNum( pObj, nNodes++ ); 00179 Aig_ManForEachNode( pMan, pObj, i ) 00180 Ioa_ObjSetAigerNum( pObj, nNodes++ ); 00181 00182 // write the header "M I L O A" where M = I + L + A 00183 fprintf( pFile, "aig %u %u %u %u %u\n", 00184 Aig_ManPiNum(pMan) + Aig_ManNodeNum(pMan), 00185 Aig_ManPiNum(pMan) - Aig_ManRegNum(pMan), 00186 Aig_ManRegNum(pMan), 00187 Aig_ManPoNum(pMan) - Aig_ManRegNum(pMan), 00188 Aig_ManNodeNum(pMan) ); 00189 00190 // if the driver node is a constant, we need to complement the literal below 00191 // because, in the AIGER format, literal 0/1 is represented as number 0/1 00192 // while, in ABC, constant 1 node has number 0 and so literal 0/1 will be 1/0 00193 00194 // write latch drivers 00195 Aig_ManForEachLiSeq( pMan, pObj, i ) 00196 { 00197 pDriver = Aig_ObjFanin0(pObj); 00198 fprintf( pFile, "%u\n", Ioa_ObjMakeLit( Ioa_ObjAigerNum(pDriver), Aig_ObjFaninC0(pObj) ^ (Ioa_ObjAigerNum(pDriver) == 0) ) ); 00199 } 00200 00201 // write PO drivers 00202 Aig_ManForEachPoSeq( pMan, pObj, i ) 00203 { 00204 pDriver = Aig_ObjFanin0(pObj); 00205 fprintf( pFile, "%u\n", Ioa_ObjMakeLit( Ioa_ObjAigerNum(pDriver), Aig_ObjFaninC0(pObj) ^ (Ioa_ObjAigerNum(pDriver) == 0) ) ); 00206 } 00207 00208 // write the nodes into the buffer 00209 Pos = 0; 00210 nBufferSize = 6 * Aig_ManNodeNum(pMan) + 100; // skeptically assuming 3 chars per one AIG edge 00211 pBuffer = ALLOC( char, nBufferSize ); 00212 pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(pMan) ); 00213 Aig_ManForEachNode( pMan, pObj, i ) 00214 { 00215 Bar_ProgressUpdate( pProgress, i, NULL ); 00216 uLit = Ioa_ObjMakeLit( Ioa_ObjAigerNum(pObj), 0 ); 00217 uLit0 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj) ); 00218 uLit1 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj) ); 00219 assert( uLit0 < uLit1 ); 00220 Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 ); 00221 Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 ); 00222 if ( Pos > nBufferSize - 10 ) 00223 { 00224 printf( "Ioa_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" ); 00225 fclose( pFile ); 00226 return; 00227 } 00228 } 00229 assert( Pos < nBufferSize ); 00230 Bar_ProgressStop( pProgress ); 00231 00232 // write the buffer 00233 fwrite( pBuffer, 1, Pos, pFile ); 00234 free( pBuffer ); 00235 /* 00236 // write the symbol table 00237 if ( fWriteSymbols ) 00238 { 00239 // write PIs 00240 Aig_ManForEachPi( pMan, pObj, i ) 00241 fprintf( pFile, "i%d %s\n", i, Aig_ObjName(pObj) ); 00242 // write latches 00243 Aig_ManForEachLatch( pMan, pObj, i ) 00244 fprintf( pFile, "l%d %s\n", i, Aig_ObjName(Aig_ObjFanout0(pObj)) ); 00245 // write POs 00246 Aig_ManForEachPo( pMan, pObj, i ) 00247 fprintf( pFile, "o%d %s\n", i, Aig_ObjName(pObj) ); 00248 } 00249 */ 00250 // write the comment 00251 fprintf( pFile, "c\n" ); 00252 if ( pMan->pName ) 00253 fprintf( pFile, ".model %s\n", pMan->pName ); 00254 fprintf( pFile, "This file was produced by the AIG package in ABC on %s\n", Ioa_TimeStamp() ); 00255 fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" ); 00256 fclose( pFile ); 00257 }
int Ioa_WriteAigerEncode | ( | char * | pBuffer, | |
int | Pos, | |||
unsigned | x | |||
) |
Function*************************************************************
Synopsis [Adds one unsigned AIG edge to the output buffer.]
Description [This procedure is a slightly modified version of Armin Biere's procedure "void encode (FILE * file, unsigned x)" ]
SideEffects [Returns the current writing position.]
SeeAlso []
Definition at line 271 of file ioaWriteAig.c.