ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioAbc.h File Reference
#include "base/abc/abc.h"
#include "misc/extra/extra.h"
#include "misc/util/utilNam.h"
Include dependency graph for ioAbc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IO_WRITE_LINE_LENGTH   78
 MACRO DEFINITIONS ///.
 

Enumerations

enum  Io_FileType_t {
  IO_FILE_NONE = 0 , IO_FILE_AIGER , IO_FILE_BAF , IO_FILE_BBLIF ,
  IO_FILE_BLIF , IO_FILE_BLIFMV , IO_FILE_BENCH , IO_FILE_BOOK ,
  IO_FILE_CNF , IO_FILE_DOT , IO_FILE_EDIF , IO_FILE_EQN ,
  IO_FILE_GML , IO_FILE_HMETIS , IO_FILE_JSON , IO_FILE_LIST ,
  IO_FILE_PLA , IO_FILE_MOPLA , IO_FILE_SMV , IO_FILE_VERILOG ,
  IO_FILE_UNKNOWN
}
 INCLUDES ///. More...
 

Functions

Abc_Ntk_tIo_ReadAiger (char *pFileName, int fCheck)
 FUNCTION DECLARATIONS ///.
 
Abc_Ntk_tIo_ReadBaf (char *pFileName, int fCheck)
 DECLARATIONS ///.
 
Abc_Ntk_tIo_ReadBblif (char *pFileName, int fCheck)
 
Abc_Ntk_tIo_ReadBlif (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///.
 
Abc_Ntk_tIo_ReadBlifMv (char *pFileName, int fBlifMv, int fCheck)
 FUNCTION DEFINITIONS ///.
 
Abc_Ntk_tIo_ReadBench (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///.
 
void Io_ReadBenchInit (Abc_Ntk_t *pNtk, char *pFileName)
 
Abc_Ntk_tIo_ReadEdif (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///.
 
Abc_Ntk_tIo_ReadEqn (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///.
 
Abc_Ntk_tIo_ReadPla (char *pFileName, int fZeros, int fBoth, int fOnDc, int fSkipPrepro, int fCheck)
 
Abc_Ntk_tIo_ReadVerilog (char *pFileName, int fCheck)
 DECLARATIONS ///.
 
void Io_WriteAiger (Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols, int fCompact, int fUnique)
 
void Io_WriteAigerCex (Abc_Cex_t *pCex, Abc_Ntk_t *pNtk, void *pG, char *pFileName)
 
void Io_WriteBaf (Abc_Ntk_t *pNtk, char *pFileName)
 DECLARATIONS ///.
 
void Io_WriteBblif (Abc_Ntk_t *pNtk, char *pFileName)
 
void Io_WriteBlifLogic (Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
 FUNCTION DEFINITIONS ///.
 
void Io_WriteBlif (Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
 
void Io_WriteTimingInfo (FILE *pFile, Abc_Ntk_t *pNtk)
 
void Io_WriteBlifSpecial (Abc_Ntk_t *pNtk, char *FileName, char *pLutStruct, int fUseHie)
 
void Io_WriteBlifMv (Abc_Ntk_t *pNtk, char *FileName)
 FUNCTION DEFINITIONS ///.
 
int Io_WriteBench (Abc_Ntk_t *pNtk, const char *FileName)
 FUNCTION DEFINITIONS ///.
 
int Io_WriteBenchLut (Abc_Ntk_t *pNtk, char *FileName)
 
void Io_WriteBook (Abc_Ntk_t *pNtk, char *FileName)
 
int Io_WriteCnf (Abc_Ntk_t *pNtk, char *FileName, int fAllPrimes)
 FUNCTION DEFINITIONS ///.
 
void Io_WriteDot (Abc_Ntk_t *pNtk, char *FileName)
 FUNCTION DEFINITIONS ///.
 
void Io_WriteDotNtk (Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse, int fAigIds)
 
void Io_WriteDotSeq (Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse)
 
void Io_WriteEqn (Abc_Ntk_t *pNtk, char *pFileName)
 FUNCTION DEFINITIONS ///.
 
void Io_WriteEdgelist (Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq, int fName)
 FUNCTION DEFINITIONS ///.
 
void Io_WriteGml (Abc_Ntk_t *pNtk, char *pFileName)
 DECLARATIONS ///.
 
void Io_WriteHMetis (Abc_Ntk_t *pNtk, char *pFileName, int fSkipPo, int fWeightEdges, int fVerbose)
 
void Io_WriteList (Abc_Ntk_t *pNtk, char *pFileName, int fUseHost)
 FUNCTION DEFINITIONS ///.
 
int Io_WritePla (Abc_Ntk_t *pNtk, char *FileName)
 
int Io_WriteMoPla (Abc_Ntk_t *pNtk, char *FileName)
 
int Io_WriteSmv (Abc_Ntk_t *pNtk, char *FileName)
 
void Io_WriteVerilog (Abc_Ntk_t *pNtk, char *FileName, int fOnlyAnds, int fNewInterface)
 FUNCTION DEFINITIONS ///.
 
Io_FileType_t Io_ReadFileType (char *pFileName)
 DECLARATIONS ///.
 
Io_FileType_t Io_ReadLibType (char *pFileName)
 
Abc_Ntk_tIo_ReadNetlist (char *pFileName, Io_FileType_t FileType, int fCheck)
 
Abc_Ntk_tIo_Read (char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
 
void Io_Write (Abc_Ntk_t *pNtk, char *pFileName, Io_FileType_t FileType)
 
void Io_WriteHie (Abc_Ntk_t *pNtk, char *pBaseName, char *pFileName)
 
Abc_Obj_tIo_ReadCreatePi (Abc_Ntk_t *pNtk, char *pName)
 
Abc_Obj_tIo_ReadCreatePo (Abc_Ntk_t *pNtk, char *pName)
 
Abc_Obj_tIo_ReadCreateLatch (Abc_Ntk_t *pNtk, char *pNetLI, char *pNetLO)
 
Abc_Obj_tIo_ReadCreateResetLatch (Abc_Ntk_t *pNtk, int fBlifMv)
 
Abc_Obj_tIo_ReadCreateResetMux (Abc_Ntk_t *pNtk, char *pResetLO, char *pDataLI, int fBlifMv)
 
Abc_Obj_tIo_ReadCreateNode (Abc_Ntk_t *pNtk, char *pNameOut, char *pNamesIn[], int nInputs)
 
Abc_Obj_tIo_ReadCreateConst (Abc_Ntk_t *pNtk, char *pName, int fConst1)
 
Abc_Obj_tIo_ReadCreateInv (Abc_Ntk_t *pNtk, char *pNameIn, char *pNameOut)
 
Abc_Obj_tIo_ReadCreateBuf (Abc_Ntk_t *pNtk, char *pNameIn, char *pNameOut)
 
FILE * Io_FileOpen (const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
 
void Io_ReadJson (char *pFileName)
 
void Io_WriteJson (char *pFileName)
 

Macro Definition Documentation

◆ IO_WRITE_LINE_LENGTH

#define IO_WRITE_LINE_LENGTH   78

MACRO DEFINITIONS ///.

Definition at line 75 of file ioAbc.h.

Enumeration Type Documentation

◆ Io_FileType_t

INCLUDES ///.

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

FileName [ioAbc.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
ioAbc.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS /// BASIC TYPES ///

Enumerator
IO_FILE_NONE 
IO_FILE_AIGER 
IO_FILE_BAF 
IO_FILE_BBLIF 
IO_FILE_BLIF 
IO_FILE_BLIFMV 
IO_FILE_BENCH 
IO_FILE_BOOK 
IO_FILE_CNF 
IO_FILE_DOT 
IO_FILE_EDIF 
IO_FILE_EQN 
IO_FILE_GML 
IO_FILE_HMETIS 
IO_FILE_JSON 
IO_FILE_LIST 
IO_FILE_PLA 
IO_FILE_MOPLA 
IO_FILE_SMV 
IO_FILE_VERILOG 
IO_FILE_UNKNOWN 

Definition at line 47 of file ioAbc.h.

47 {
48 IO_FILE_NONE = 0,
Io_FileType_t
INCLUDES ///.
Definition ioAbc.h:47
@ IO_FILE_SMV
Definition ioAbc.h:66
@ IO_FILE_HMETIS
Definition ioAbc.h:61
@ IO_FILE_DOT
Definition ioAbc.h:57
@ IO_FILE_UNKNOWN
Definition ioAbc.h:68
@ IO_FILE_JSON
Definition ioAbc.h:62
@ IO_FILE_EQN
Definition ioAbc.h:59
@ IO_FILE_VERILOG
Definition ioAbc.h:67
@ IO_FILE_BBLIF
Definition ioAbc.h:51
@ IO_FILE_BLIFMV
Definition ioAbc.h:53
@ IO_FILE_NONE
Definition ioAbc.h:48
@ IO_FILE_GML
Definition ioAbc.h:60
@ IO_FILE_PLA
Definition ioAbc.h:64
@ IO_FILE_BENCH
Definition ioAbc.h:54
@ IO_FILE_BLIF
Definition ioAbc.h:52
@ IO_FILE_BOOK
Definition ioAbc.h:55
@ IO_FILE_EDIF
Definition ioAbc.h:58
@ IO_FILE_MOPLA
Definition ioAbc.h:65
@ IO_FILE_BAF
Definition ioAbc.h:50
@ IO_FILE_CNF
Definition ioAbc.h:56
@ IO_FILE_AIGER
Definition ioAbc.h:49
@ IO_FILE_LIST
Definition ioAbc.h:63

Function Documentation

◆ Io_FileOpen()

FILE * Io_FileOpen ( const char * FileName,
const char * PathVar,
const char * Mode,
int fVerbose )
extern

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

Synopsis [Provide an fopen replacement with path lookup]

Description [Provide an fopen replacement where the path stored in pathvar MVSIS variable is used to look up the path for name. Returns NULL if file cannot be opened.]

SideEffects []

SeeAlso []

Definition at line 828 of file ioUtil.c.

829{
830 char * t = 0, * c = 0, * i;
831
832 if ( PathVar == 0 )
833 {
834 return fopen( FileName, Mode );
835 }
836 else
837 {
838 if ( (c = Abc_FrameReadFlag( (char*)PathVar )) )
839 {
840 char ActualFileName[4096];
841 FILE * fp = 0;
842 t = Extra_UtilStrsav( c );
843 for (i = strtok( t, ":" ); i != 0; i = strtok( 0, ":") )
844 {
845#ifdef WIN32
846 _snprintf ( ActualFileName, 4096, "%s/%s", i, FileName );
847#else
848 snprintf ( ActualFileName, 4096, "%s/%s", i, FileName );
849#endif
850 if ( ( fp = fopen ( ActualFileName, Mode ) ) )
851 {
852 if ( fVerbose )
853 fprintf ( stdout, "Using file %s\n", ActualFileName );
854 ABC_FREE( t );
855 return fp;
856 }
857 }
858 ABC_FREE( t );
859 return 0;
860 }
861 else
862 {
863 return fopen( FileName, Mode );
864 }
865 }
866}
#define ABC_FREE(obj)
Definition abc_global.h:267
ABC_DLL char * Abc_FrameReadFlag(char *pFlag)
Definition mainFrame.c:69
char * Extra_UtilStrsav(const char *s)
char * strtok()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_Read()

Abc_Ntk_t * Io_Read ( char * pFileName,
Io_FileType_t FileType,
int fCheck,
int fBarBufs )
extern

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

Synopsis [Read the network from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file ioUtil.c.

242{
243 Abc_Ntk_t * pNtk, * pTemp;
244 Vec_Ptr_t * vLtl;
245 // get the netlist
246 pNtk = Io_ReadNetlist( pFileName, FileType, fCheck );
247 if ( pNtk == NULL )
248 return NULL;
249 vLtl = temporaryLtlStore( pNtk );
250 if ( !Abc_NtkIsNetlist(pNtk) )
251 return pNtk;
252 // derive barbufs
253 if ( fBarBufs )
254 {
255 pNtk = Abc_NtkToBarBufs( pTemp = pNtk );
256 Abc_NtkDelete( pTemp );
257 assert( Abc_NtkIsLogic(pNtk) );
258 return pNtk;
259 }
260 // flatten logic hierarchy
261 assert( Abc_NtkIsNetlist(pNtk) );
262 if ( Abc_NtkWhiteboxNum(pNtk) > 0 )
263 {
264 pNtk = Abc_NtkFlattenLogicHierarchy( pTemp = pNtk );
265 Abc_NtkDelete( pTemp );
266 if ( pNtk == NULL )
267 {
268 fprintf( stdout, "Flattening logic hierarchy has failed.\n" );
269 return NULL;
270 }
271 }
272 // convert blackboxes
273 if ( Abc_NtkBlackboxNum(pNtk) > 0 )
274 {
275 printf( "Hierarchy reader converted %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtk) );
276 pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk );
277 Abc_NtkDelete( pTemp );
278 if ( pNtk == NULL )
279 {
280 fprintf( stdout, "Converting blackboxes has failed.\n" );
281 return NULL;
282 }
283 }
284 // consider the case of BLIF-MV
285 if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
286 {
287 pNtk = Abc_NtkStrashBlifMv( pTemp = pNtk );
288 Abc_NtkDelete( pTemp );
289 if ( pNtk == NULL )
290 {
291 fprintf( stdout, "Converting BLIF-MV to AIG has failed.\n" );
292 return NULL;
293 }
294 return pNtk;
295 }
296 // convert the netlist into the logic network
297 pNtk = Abc_NtkToLogic( pTemp = pNtk );
298 if( vLtl )
299 updateLtlStoreOfNtk( pNtk, vLtl );
300 Abc_NtkDelete( pTemp );
301 if ( pNtk == NULL )
302 {
303 fprintf( stdout, "Converting netlist to logic network after reading has failed.\n" );
304 return NULL;
305 }
306 return pNtk;
307}
ABC_DLL Abc_Ntk_t * Abc_NtkToBarBufs(Abc_Ntk_t *pNtk)
Definition abcBarBuf.c:180
ABC_DLL Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcNetlist.c:52
ABC_DLL Abc_Ntk_t * Abc_NtkStrashBlifMv(Abc_Ntk_t *pNtk)
Definition abcBlifMv.c:383
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy(Abc_Ntk_t *pNtk)
Definition abcHie.c:514
ABC_DLL Abc_Ntk_t * Abc_NtkConvertBlackboxes(Abc_Ntk_t *pNtk)
Definition abcHie.c:598
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
void updateLtlStoreOfNtk(Abc_Ntk_t *pNtk, Vec_Ptr_t *tempLtlStore)
Definition ioUtil.c:220
Abc_Ntk_t * Io_ReadNetlist(char *pFileName, Io_FileType_t FileType, int fCheck)
Definition ioUtil.c:99
ABC_NAMESPACE_IMPL_START Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition ioUtil.c:47
Vec_Ptr_t * temporaryLtlStore(Abc_Ntk_t *pNtk)
Definition ioUtil.c:191
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadAiger()

Abc_Ntk_t * Io_ReadAiger ( char * pFileName,
int fCheck )
extern

FUNCTION DECLARATIONS ///.

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

Synopsis [Reads the AIG in the binary AIGER format.]

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file ioReadAiger.c.

235{
236 ProgressBar * pProgress;
237 FILE * pFile;
238 Vec_Ptr_t * vNodes, * vTerms;
239 Vec_Int_t * vLits = NULL;
240 Abc_Obj_t * pObj, * pNode0, * pNode1;
241 Abc_Ntk_t * pNtkNew;
242 int nTotal, nInputs, nOutputs, nLatches, nAnds;
243 int nBad = 0, nConstr = 0, nJust = 0, nFair = 0;
244 int nFileSize = -1, iTerm, nDigits, i;
245 char * pContents, * pDrivers = NULL, * pSymbols, * pCur, * pName, * pType;
246 unsigned uLit0, uLit1, uLit;
247 int RetValue;
248
249 // read the file into the buffer
250 if ( !strncmp(pFileName+strlen(pFileName)-4,".bz2",4) )
251 pContents = Ioa_ReadLoadFileBz2Aig( pFileName, &nFileSize );
252 else if ( !strncmp(pFileName+strlen(pFileName)-3,".gz",3) )
253 pContents = Ioa_ReadLoadFileGzAig( pFileName, &nFileSize );
254 else
255 {
256// pContents = Ioa_ReadLoadFile( pFileName );
257 nFileSize = Extra_FileSize( pFileName );
258 pFile = fopen( pFileName, "rb" );
259 pContents = ABC_ALLOC( char, nFileSize );
260 RetValue = fread( pContents, nFileSize, 1, pFile );
261 fclose( pFile );
262 }
263
264
265 // check if the input file format is correct
266 if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') )
267 {
268 fprintf( stdout, "Wrong input file format.\n" );
269 ABC_FREE( pContents );
270 return NULL;
271 }
272
273 // read the parameters (M I L O A + B C J F)
274 pCur = pContents; while ( *pCur != ' ' ) pCur++; pCur++;
275 // read the number of objects
276 nTotal = atoi( pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
277 // read the number of inputs
278 nInputs = atoi( pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
279 // read the number of latches
280 nLatches = atoi( pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
281 // read the number of outputs
282 nOutputs = atoi( pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
283 // read the number of nodes
284 nAnds = atoi( pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
285 if ( *pCur == ' ' )
286 {
287// assert( nOutputs == 0 );
288 // read the number of properties
289 pCur++;
290 nBad = atoi( pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
291 nOutputs += nBad;
292 }
293 if ( *pCur == ' ' )
294 {
295 // read the number of properties
296 pCur++;
297 nConstr = atoi( pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
298 nOutputs += nConstr;
299 }
300 if ( *pCur == ' ' )
301 {
302 // read the number of properties
303 pCur++;
304 nJust = atoi( pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
305 nOutputs += nJust;
306 }
307 if ( *pCur == ' ' )
308 {
309 // read the number of properties
310 pCur++;
311 nFair = atoi( pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
312 nOutputs += nFair;
313 }
314 if ( *pCur != '\n' )
315 {
316 fprintf( stdout, "The parameter line is in a wrong format.\n" );
317 ABC_FREE( pContents );
318 return NULL;
319 }
320 pCur++;
321
322 // check the parameters
323 if ( nTotal != nInputs + nLatches + nAnds )
324 {
325 fprintf( stdout, "The number of objects does not match.\n" );
326 ABC_FREE( pContents );
327 return NULL;
328 }
329 if ( nJust || nFair )
330 {
331 fprintf( stdout, "Reading AIGER files with liveness properties is currently not supported.\n" );
332 ABC_FREE( pContents );
333 return NULL;
334 }
335
336 if ( nConstr )
337 {
338 if ( nConstr == 1 )
339 fprintf( stdout, "Warning: The last output is interpreted as a constraint.\n" );
340 else
341 fprintf( stdout, "Warning: The last %d outputs are interpreted as constraints.\n", nConstr );
342 }
343
344 // allocate the empty AIG
346 pName = Extra_FileNameGeneric( pFileName );
347 pNtkNew->pName = Extra_UtilStrsav( pName );
348 pNtkNew->pSpec = Extra_UtilStrsav( pFileName );
349 ABC_FREE( pName );
350 pNtkNew->nConstrs = nConstr;
351
352 // prepare the array of nodes
353 vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
354 Vec_PtrPush( vNodes, Abc_ObjNot( Abc_AigConst1(pNtkNew) ) );
355
356 // create the PIs
357 for ( i = 0; i < nInputs; i++ )
358 {
359 pObj = Abc_NtkCreatePi(pNtkNew);
360 Vec_PtrPush( vNodes, pObj );
361 }
362 // create the POs
363 for ( i = 0; i < nOutputs; i++ )
364 {
365 pObj = Abc_NtkCreatePo(pNtkNew);
366 }
367 // create the latches
368 nDigits = Abc_Base10Log( nLatches );
369 for ( i = 0; i < nLatches; i++ )
370 {
371 pObj = Abc_NtkCreateLatch(pNtkNew);
372 Abc_LatchSetInit0( pObj );
373 pNode0 = Abc_NtkCreateBi(pNtkNew);
374 pNode1 = Abc_NtkCreateBo(pNtkNew);
375 Abc_ObjAddFanin( pObj, pNode0 );
376 Abc_ObjAddFanin( pNode1, pObj );
377 Vec_PtrPush( vNodes, pNode1 );
378 // assign names to latch and its input
379// Abc_ObjAssignName( pObj, Abc_ObjNameDummy("_L", i, nDigits), NULL );
380// printf( "Creating latch %s with input %d and output %d.\n", Abc_ObjName(pObj), pNode0->Id, pNode1->Id );
381 }
382
383
384 if ( pContents[3] == ' ' ) // standard AIGER
385 {
386 // remember the beginning of latch/PO literals
387 pDrivers = pCur;
388 // scroll to the beginning of the binary data
389 for ( i = 0; i < nLatches + nOutputs; )
390 if ( *pCur++ == '\n' )
391 i++;
392 }
393 else // modified AIGER
394 {
395 vLits = Io_WriteDecodeLiterals( &pCur, nLatches + nOutputs );
396 }
397
398 // create the AND gates
399 pProgress = Extra_ProgressBarStart( stdout, nAnds );
400 for ( i = 0; i < nAnds; i++ )
401 {
402 Extra_ProgressBarUpdate( pProgress, i, NULL );
403 uLit = ((i + 1 + nInputs + nLatches) << 1);
404 uLit1 = uLit - Io_ReadAigerDecode( &pCur );
405 uLit0 = uLit1 - Io_ReadAigerDecode( &pCur );
406// assert( uLit1 > uLit0 );
407 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
408 pNode1 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
409 assert( Vec_PtrSize(vNodes) == i + 1 + nInputs + nLatches );
410 Vec_PtrPush( vNodes, Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pNode0, pNode1) );
411 }
412 Extra_ProgressBarStop( pProgress );
413
414 // remember the place where symbols begin
415 pSymbols = pCur;
416
417 // read the latch driver literals
418 pCur = pDrivers;
419 if ( pContents[3] == ' ' ) // standard AIGER
420 {
421 Abc_NtkForEachLatchInput( pNtkNew, pObj, i )
422 {
423 uLit0 = atoi( pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
424 if ( *pCur == ' ' ) // read initial value
425 {
426 int Init;
427 pCur++;
428 Init = atoi( pCur );
429 if ( Init == 0 )
430 Abc_LatchSetInit0( Abc_NtkBox(pNtkNew, i) );
431 else if ( Init == 1 )
432 Abc_LatchSetInit1( Abc_NtkBox(pNtkNew, i) );
433 else
434 {
435 assert( Init == Abc_Var2Lit(1+Abc_NtkPiNum(pNtkNew)+i, 0) );
436 // uninitialized value of the latch is the latch literal according to http://fmv.jku.at/hwmcc11/beyond1.pdf
437 Abc_LatchSetInitDc( Abc_NtkBox(pNtkNew, i) );
438 }
439 while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
440 }
441 if ( *pCur != '\n' )
442 {
443 fprintf( stdout, "The initial value of latch number %d is not recognized.\n", i );
444 return NULL;
445 }
446 pCur++;
447
448 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
449 Abc_ObjAddFanin( pObj, pNode0 );
450 }
451 // read the PO driver literals
452 Abc_NtkForEachPo( pNtkNew, pObj, i )
453 {
454 uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
455 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
456 Abc_ObjAddFanin( pObj, pNode0 );
457 }
458 }
459 else
460 {
461 // read the latch driver literals
462 Abc_NtkForEachLatchInput( pNtkNew, pObj, i )
463 {
464 uLit0 = Vec_IntEntry( vLits, i );
465 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
466 Abc_ObjAddFanin( pObj, pNode0 );
467 }
468 // read the PO driver literals
469 Abc_NtkForEachPo( pNtkNew, pObj, i )
470 {
471 uLit0 = Vec_IntEntry( vLits, i+Abc_NtkLatchNum(pNtkNew) );
472 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
473 Abc_ObjAddFanin( pObj, pNode0 );
474 }
475 Vec_IntFree( vLits );
476 }
477
478 // read the names if present
479 pCur = pSymbols;
480 if ( pCur < pContents + nFileSize && *pCur != 'c' )
481 {
482 int Counter = 0;
483 int fNodeNames = 0;
484 while ( pCur < pContents + nFileSize && *pCur != 'c' )
485 {
486 // get the terminal type
487 pType = pCur;
488 if ( *pCur == 'i' )
489 vTerms = pNtkNew->vPis;
490 else if ( *pCur == 'l' )
491 vTerms = pNtkNew->vBoxes;
492 else if ( *pCur == 'o' || *pCur == 'b' || *pCur == 'c' || *pCur == 'j' || *pCur == 'f' )
493 vTerms = pNtkNew->vPos;
494 else if ( *pCur == 'n' )
495 {
496 fNodeNames++;
497 while ( *pCur++ != '\n' );
498 continue;
499 }
500 else
501 {
502// fprintf( stdout, "Wrong terminal type.\n" );
503 return NULL;
504 }
505 // get the terminal number
506 iTerm = atoi( ++pCur ); while ( *pCur++ != ' ' );
507 // get the node
508 if ( iTerm >= Vec_PtrSize(vTerms) )
509 {
510 fprintf( stdout, "The number of terminal is out of bound.\n" );
511 return NULL;
512 }
513 pObj = (Abc_Obj_t *)Vec_PtrEntry( vTerms, iTerm );
514 if ( *pType == 'l' )
515 pObj = Abc_ObjFanout0(pObj);
516 // assign the name
517 pName = pCur; while ( *pCur++ != '\n' );
518 // assign this name
519 *(pCur-1) = 0;
520 Abc_ObjAssignName( pObj, pName, NULL );
521 if ( *pType == 'l' )
522 {
523 Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
524 Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "_in" );
525 }
526 // mark the node as named
527 pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
528 }
529
530 // assign the remaining names
531 Abc_NtkForEachPi( pNtkNew, pObj, i )
532 {
533 if ( pObj->pCopy ) continue;
534 Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
535 Counter++;
536 }
537 Abc_NtkForEachLatchOutput( pNtkNew, pObj, i )
538 {
539 if ( pObj->pCopy ) continue;
540 Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
541 Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
542 Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "_in" );
543 Counter++;
544 }
545 Abc_NtkForEachPo( pNtkNew, pObj, i )
546 {
547 if ( pObj->pCopy ) continue;
548 Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
549 Counter++;
550 }
551// if ( Counter )
552// printf( "Io_ReadAiger(): Added %d default names for nameless I/O/register objects.\n", Counter );
553 if ( fNodeNames )
554 printf( "Io_ReadAiger(): The names of internal nodes are not supported. Ignoring %d node names.\n", fNodeNames );
555 }
556 else
557 {
558// printf( "Io_ReadAiger(): I/O/register names are not given. Generating short names.\n" );
559 Abc_NtkShortNames( pNtkNew );
560 }
561
562 // read the name of the model if given
563 pCur = pSymbols;
564 if ( pCur + 1 < pContents + nFileSize && *pCur == 'c' )
565 {
566 pCur++;
567 if ( *pCur == 'n' )
568 {
569 pCur++;
570 // read model name
571 if ( strlen(pCur) > 0 )
572 {
573 ABC_FREE( pNtkNew->pName );
574 pNtkNew->pName = Extra_UtilStrsav( pCur );
575 }
576 }
577 }
578
579 // skipping the comments
580 ABC_FREE( pContents );
581 Vec_PtrFree( vNodes );
582
583 // remove the extra nodes
584 Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
585
586 // update polarity of the additional outputs
587 if ( nBad || nConstr || nJust || nFair )
588 Abc_NtkInvertConstraints( pNtkNew );
589
590 // check the result
591 if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
592 {
593 printf( "Io_ReadAiger: The network check has failed.\n" );
594 Abc_NtkDelete( pNtkNew );
595 return NULL;
596 }
597 return pNtkNew;
598}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition abcCheck.c:80
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
@ ABC_NTK_STRASH
Definition abc.h:58
#define Abc_NtkForEachLatchOutput(pNtk, pObj, i)
Definition abc.h:506
ABC_DLL void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2244
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition abcAig.c:194
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
Definition abc.h:503
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
@ ABC_FUNC_AIG
Definition abc.h:67
ABC_DLL void Abc_NtkShortNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:619
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
int Extra_FileSize(char *pFileName)
void Extra_ProgressBarStop(ProgressBar *p)
char * Extra_FileNameGeneric(char *FileName)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Vec_Int_t * Io_WriteDecodeLiterals(char **ppPos, int nEntries)
Definition ioReadAiger.c:79
char * pName
Definition abc.h:158
int nConstrs
Definition abc.h:173
Vec_Ptr_t * vPos
Definition abc.h:164
Vec_Ptr_t * vBoxes
Definition abc.h:168
void * pManFunc
Definition abc.h:191
char * pSpec
Definition abc.h:159
Vec_Ptr_t * vPis
Definition abc.h:163
Abc_Obj_t * pCopy
Definition abc.h:148
int strncmp()
int strlen()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadBaf()

Abc_Ntk_t * Io_ReadBaf ( char * pFileName,
int fCheck )
extern

DECLARATIONS ///.

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

FileName [ioReadBaf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

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

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Reads the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ioReadBaf.c.

46{
47 ProgressBar * pProgress;
48 FILE * pFile;
49 Vec_Ptr_t * vNodes;
50 Abc_Obj_t * pObj, * pNode0, * pNode1;
51 Abc_Ntk_t * pNtkNew;
52 int nInputs, nOutputs, nLatches, nAnds, nFileSize, Num, i;
53 char * pContents, * pName, * pCur;
54 unsigned * pBufferNode;
55 int RetValue;
56
57 // read the file into the buffer
58 nFileSize = Extra_FileSize( pFileName );
59 pFile = fopen( pFileName, "rb" );
60 pContents = ABC_ALLOC( char, nFileSize );
61 RetValue = fread( pContents, nFileSize, 1, pFile );
62 fclose( pFile );
63
64 // skip the comments (comment lines begin with '#' and end with '\n')
65 for ( pCur = pContents; *pCur == '#'; )
66 while ( *pCur++ != '\n' );
67
68 // read the name
69 pName = pCur; while ( *pCur++ );
70 // read the number of inputs
71 nInputs = atoi( pCur ); while ( *pCur++ );
72 // read the number of outputs
73 nOutputs = atoi( pCur ); while ( *pCur++ );
74 // read the number of latches
75 nLatches = atoi( pCur ); while ( *pCur++ );
76 // read the number of nodes
77 nAnds = atoi( pCur ); while ( *pCur++ );
78
79 // allocate the empty AIG
81 pNtkNew->pName = Extra_UtilStrsav( pName );
82 pNtkNew->pSpec = Extra_UtilStrsav( pFileName );
83
84 // prepare the array of nodes
85 vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
86 Vec_PtrPush( vNodes, Abc_AigConst1(pNtkNew) );
87
88 // create the PIs
89 for ( i = 0; i < nInputs; i++ )
90 {
91 pObj = Abc_NtkCreatePi(pNtkNew);
92 Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
93 Vec_PtrPush( vNodes, pObj );
94 }
95 // create the POs
96 for ( i = 0; i < nOutputs; i++ )
97 {
98 pObj = Abc_NtkCreatePo(pNtkNew);
99 Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
100 }
101 // create the latches
102 for ( i = 0; i < nLatches; i++ )
103 {
104 pObj = Abc_NtkCreateLatch(pNtkNew);
105 Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
106
107 pNode0 = Abc_NtkCreateBi(pNtkNew);
108 Abc_ObjAssignName( pNode0, pCur, NULL ); while ( *pCur++ );
109
110 pNode1 = Abc_NtkCreateBo(pNtkNew);
111 Abc_ObjAssignName( pNode1, pCur, NULL ); while ( *pCur++ );
112 Vec_PtrPush( vNodes, pNode1 );
113
114 Abc_ObjAddFanin( pObj, pNode0 );
115 Abc_ObjAddFanin( pNode1, pObj );
116 }
117
118 // get the pointer to the beginning of the node array
119 pBufferNode = (unsigned *)(pContents + (nFileSize - (2 * nAnds + nOutputs + nLatches) * sizeof(int)) );
120 // make sure we are at the place where the nodes begin
121 if ( pBufferNode != (unsigned *)pCur )
122 {
123 ABC_FREE( pContents );
124 Vec_PtrFree( vNodes );
125 Abc_NtkDelete( pNtkNew );
126 printf( "Warning: Internal reader error.\n" );
127 return NULL;
128 }
129
130 // create the AND gates
131 pProgress = Extra_ProgressBarStart( stdout, nAnds );
132 for ( i = 0; i < nAnds; i++ )
133 {
134 Extra_ProgressBarUpdate( pProgress, i, NULL );
135 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, pBufferNode[2*i+0] >> 1), pBufferNode[2*i+0] & 1 );
136 pNode1 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, pBufferNode[2*i+1] >> 1), pBufferNode[2*i+1] & 1 );
137 Vec_PtrPush( vNodes, Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pNode0, pNode1) );
138 }
139 Extra_ProgressBarStop( pProgress );
140
141 // read the POs
142 Abc_NtkForEachCo( pNtkNew, pObj, i )
143 {
144 Num = pBufferNode[2*nAnds+i];
145 if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
146 {
147 Abc_ObjSetData( Abc_ObjFanout0(pObj), (void *)(ABC_PTRINT_T)(Num & 3) );
148 Num >>= 2;
149 }
150 pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, Num >> 1), Num & 1 );
151 Abc_ObjAddFanin( pObj, pNode0 );
152 }
153 ABC_FREE( pContents );
154 Vec_PtrFree( vNodes );
155
156 // remove the extra nodes
157// Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
158
159 // check the result
160 if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
161 {
162 printf( "Io_ReadBaf: The network check has failed.\n" );
163 Abc_NtkDelete( pNtkNew );
164 return NULL;
165 }
166 return pNtkNew;
167
168}
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadBblif()

Abc_Ntk_t * Io_ReadBblif ( char * pFileName,
int fCheck )
extern

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

Synopsis [Reads the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 324 of file ioReadBblif.c.

325{
326 Bbl_Man_t * p;
327 Abc_Ntk_t * pNtkNew;
328 // read the file
329 p = Bbl_ManReadBinaryBlif( pFileName );
330 pNtkNew = Bbl_ManToAig( p );
331 Bbl_ManStop( p );
332 // check the result
333 if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
334 {
335 printf( "Io_ReadBaf: The network check has failed.\n" );
336 Abc_NtkDelete( pNtkNew );
337 return NULL;
338 }
339 return pNtkNew;
340}
Bbl_Man_t * Bbl_ManReadBinaryBlif(char *pFileName)
Definition bblif.c:712
void Bbl_ManStop(Bbl_Man_t *p)
Definition bblif.c:775
struct Bbl_Man_t_ Bbl_Man_t
Definition bblif.h:213
Cube * p
Definition exorList.c:222
Abc_Ntk_t * Bbl_ManToAig(Bbl_Man_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadBench()

Abc_Ntk_t * Io_ReadBench ( char * pFileName,
int fCheck )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the network from a BENCH file.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioReadBench.c.

48{
50 Abc_Ntk_t * pNtk;
51
52 // start the file
53 p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t,()=" );
54 if ( p == NULL )
55 return NULL;
56
57 // read the network
58 pNtk = Io_ReadBenchNetwork( p );
60 if ( pNtk == NULL )
61 return NULL;
62
63 // make sure that everything is okay with the network structure
64 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
65 {
66 printf( "Io_ReadBench: The network check has failed.\n" );
67 Abc_NtkDelete( pNtk );
68 return NULL;
69 }
70 return pNtk;
71}
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
struct Extra_FileReader_t_ Extra_FileReader_t
Definition extra.h:135
void Extra_FileReaderFree(Extra_FileReader_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadBenchInit()

void Io_ReadBenchInit ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

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

Synopsis [Reads initial state in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 336 of file ioReadBench.c.

337{
338 char pBuffer[1000];
339 FILE * pFile;
340 char * pToken;
341 Abc_Obj_t * pObj;
342 int Num;
343 pFile = fopen( pFileName, "r" );
344 if ( pFile == NULL )
345 {
346 printf( "Io_ReadBenchInit(): Failed to open file \"%s\".\n", pFileName );
347 return;
348 }
349 while ( fgets( pBuffer, 999, pFile ) )
350 {
351 pToken = strtok( pBuffer, " \n\t\r" );
352 // find the latch output
353 Num = Nm_ManFindIdByName( pNtk->pManName, pToken, ABC_OBJ_BO );
354 if ( Num < 0 )
355 {
356 printf( "Io_ReadBenchInit(): Cannot find register with output %s.\n", pToken );
357 continue;
358 }
359 pObj = Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
360 if ( !Abc_ObjIsLatch(pObj) )
361 {
362 printf( "Io_ReadBenchInit(): The signal is not a register output %s.\n", pToken );
363 continue;
364 }
365 // assign the new init state
366 pToken = strtok( NULL, " \n\t\r" );
367 if ( pToken[0] == '0' )
368 Abc_LatchSetInit0( pObj );
369 else if ( pToken[0] == '1' )
370 Abc_LatchSetInit1( pObj );
371 else if ( pToken[0] == '2' )
372 Abc_LatchSetInitDc( pObj );
373 else
374 {
375 printf( "Io_ReadBenchInit(): The signal %s has unknown initial value (%s).\n",
376 Abc_ObjName(Abc_ObjFanout0(pObj)), pToken );
377 continue;
378 }
379 }
380 fclose( pFile );
381}
@ ABC_OBJ_BO
Definition abc.h:92
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
Definition nmApi.c:219
Nm_Man_t * pManName
Definition abc.h:160
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadBlif()

Abc_Ntk_t * Io_ReadBlif ( char * pFileName,
int fCheck )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the (hierarchical) network from the BLIF file.]

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file ioReadBlif.c.

114{
116 Abc_Ntk_t * pNtk;
117
118 // start the file
119 p = Io_ReadBlifFile( pFileName );
120 if ( p == NULL )
121 return NULL;
122
123 // read the hierarchical network
124 pNtk = Io_ReadBlifNetwork( p );
125 if ( pNtk == NULL )
126 {
127 Io_ReadBlifFree( p );
128 return NULL;
129 }
130 pNtk->pSpec = Extra_UtilStrsav( pFileName );
131 Io_ReadBlifCreateTiming( p, pNtk );
132 Io_ReadBlifFree( p );
133
134 // make sure that everything is okay with the network structure
135 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
136 {
137 printf( "Io_ReadBlif: The network check has failed.\n" );
138 Abc_NtkDelete( pNtk );
139 return NULL;
140 }
141 return pNtk;
142}
typedefABC_NAMESPACE_IMPL_START struct Io_ReadBlif_t_ Io_ReadBlif_t
DECLARATIONS ///.
Definition ioReadBlif.c:35
Here is the call graph for this function:

◆ Io_ReadBlifMv()

Abc_Ntk_t * Io_ReadBlifMv ( char * pFileName,
int fBlifMv,
int fCheck )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the network from the BLIF or BLIF-MV file.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file ioReadBlifMv.c.

143{
144 FILE * pFile;
145 Io_MvMan_t * p;
146 Abc_Ntk_t * pNtk, * pExdc;
147 Abc_Des_t * pDesign = NULL;
148 char * pDesignName;
149 int RetValue, i;
150 char * pLtlProp;
151
152 // check that the file is available
153 pFile = fopen( pFileName, "rb" );
154 if ( pFile == NULL )
155 {
156 printf( "Io_ReadBlifMv(): The file is unavailable (absent or open).\n" );
157 return 0;
158 }
159 fclose( pFile );
160
161 // start the file reader
162 p = Io_MvAlloc();
163 p->fBlifMv = fBlifMv;
164 p->fUseReset = 1;
165 p->pFileName = pFileName;
166 p->pBuffer = Io_MvLoadFile( pFileName );
167 if ( p->pBuffer == NULL )
168 {
169 Io_MvFree( p );
170 return NULL;
171 }
172 // set the design name
173 pDesignName = Extra_FileNameGeneric( pFileName );
174 p->pDesign = Abc_DesCreate( pDesignName );
175 ABC_FREE( pDesignName );
176 // free the HOP manager
177 Hop_ManStop( (Hop_Man_t *)p->pDesign->pManFunc );
178 p->pDesign->pManFunc = NULL;
179 // prepare the file for parsing
180 Io_MvReadPreparse( p );
181 // parse interfaces of each network and construct the network
182 if ( Io_MvReadInterfaces( p ) )
183 pDesign = Io_MvParse( p );
184 if ( p->sError[0] )
185 fprintf( stdout, "%s\n", p->sError );
186 Io_MvFree( p );
187 if ( pDesign == NULL )
188 return NULL;
189// pDesign should be linked to all models of the design
190
191 // make sure that everything is okay with the network structure
192 if ( fCheck )
193 {
194 Vec_PtrForEachEntry( Abc_Ntk_t *, pDesign->vModules, pNtk, i )
195 {
196 if ( !Abc_NtkCheckRead( pNtk ) )
197 {
198 printf( "Io_ReadBlifMv: The network check has failed for model %s.\n", pNtk->pName );
199 Abc_DesFree( pDesign, NULL );
200 return NULL;
201 }
202 }
203 }
204
205//Abc_DesPrint( pDesign );
206
207 // check if there is an EXDC network
208 if ( Vec_PtrSize(pDesign->vModules) > 1 )
209 {
210 pNtk = (Abc_Ntk_t *)Vec_PtrEntry(pDesign->vModules, 0);
211 Vec_PtrForEachEntryStart( Abc_Ntk_t *, pDesign->vModules, pExdc, i, 1 )
212 if ( !strcmp(pExdc->pName, "EXDC") )
213 {
214 assert( pNtk->pExdc == NULL );
215 pNtk->pExdc = pExdc;
216 Vec_PtrRemove(pDesign->vModules, pExdc);
217 pExdc->pDesign = NULL;
218 i--;
219 }
220 else
221 pNtk = pExdc;
222 }
223
224 // detect top-level model
225 RetValue = Abc_DesFindTopLevelModels( pDesign );
226 pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pDesign->vTops, 0 );
227 if ( RetValue > 1 )
228 printf( "Warning: The design has %d root-level modules. The first one (%s) will be used.\n",
229 Vec_PtrSize(pDesign->vTops), pNtk->pName );
230
231 // extract the master network
232 pNtk->pDesign = pDesign;
233 pDesign->pManFunc = NULL;
234
235 // verify the design for cyclic dependence
236 assert( Vec_PtrSize(pDesign->vModules) > 0 );
237 if ( Vec_PtrSize(pDesign->vModules) == 1 )
238 {
239// printf( "Warning: The design is not hierarchical.\n" );
240 Abc_DesFree( pDesign, pNtk );
241 pNtk->pDesign = NULL;
242 pNtk->pSpec = Extra_UtilStrsav( pFileName );
243 }
244 else
246
247//Io_WriteBlifMv( pNtk, "_temp_.mv" );
248 if ( pNtk->pSpec == NULL )
249 pNtk->pSpec = Extra_UtilStrsav( pFileName );
250
251 vGlobalLtlArray = Vec_PtrAlloc( 100 );
252 Vec_PtrForEachEntry( char *, vGlobalLtlArray, pLtlProp, i )
253 Vec_PtrPush( pNtk->vLtlProperties, pLtlProp );
254 Vec_PtrFreeP( &vGlobalLtlArray );
255 return pNtk;
256}
ABC_DLL int Abc_DesFindTopLevelModels(Abc_Des_t *p)
Definition abcLib.c:293
ABC_DLL void Abc_DesFree(Abc_Des_t *p, Abc_Ntk_t *pNtk)
Definition abcLib.c:94
ABC_DLL Abc_Des_t * Abc_DesCreate(char *pName)
DECLARATIONS ///.
Definition abcLib.c:45
struct Abc_Des_t_ Abc_Des_t
BASIC TYPES ///.
Definition abc.h:114
ABC_DLL int Abc_NtkIsAcyclicHierarchy(Abc_Ntk_t *pNtk)
Definition abcCheck.c:817
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
void Hop_ManStop(Hop_Man_t *p)
Definition hopMan.c:84
Vec_Ptr_t * vGlobalLtlArray
struct Io_MvMan_t_ Io_MvMan_t
if(last==0)
Definition sparse_int.h:34
Vec_Ptr_t * vModules
Definition abc.h:225
Vec_Ptr_t * vTops
Definition abc.h:224
void * pManFunc
Definition abc.h:223
Abc_Des_t * pDesign
Definition abc.h:180
Abc_Ntk_t * pExdc
Definition abc.h:201
Vec_Ptr_t * vLtlProperties
Definition abc.h:169
int strcmp()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadCreateBuf()

Abc_Obj_t * Io_ReadCreateBuf ( Abc_Ntk_t * pNtk,
char * pNameIn,
char * pNameOut )
extern

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

Synopsis [Create an inverter or buffer for the given net.]

Description [Assumes that the nets already exist.]

SideEffects []

SeeAlso []

Definition at line 804 of file ioUtil.c.

805{
806 Abc_Obj_t * pNet, * pNode;
807 pNet = Abc_NtkFindNet(pNtk, pNameIn); assert( pNet );
808 pNode = Abc_NtkCreateNodeBuf(pNtk, pNet);
809 pNet = Abc_NtkFindNet(pNtk, pNameOut); assert( pNet );
810 Abc_ObjAddFanin( pNet, pNode );
811 return pNet;
812}
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:706
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:515
Here is the call graph for this function:

◆ Io_ReadCreateConst()

Abc_Obj_t * Io_ReadCreateConst ( Abc_Ntk_t * pNtk,
char * pName,
int fConst1 )
extern

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

Synopsis [Create a constant 0 node driving the net with this name.]

Description [Assumes that the net already exists.]

SideEffects []

SeeAlso []

Definition at line 763 of file ioUtil.c.

764{
765 Abc_Obj_t * pNet, * pTerm;
766 pTerm = fConst1? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
767 pNet = Abc_NtkFindNet(pNtk, pName); assert( pNet );
768 Abc_ObjAddFanin( pNet, pTerm );
769 return pTerm;
770}
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
Here is the call graph for this function:

◆ Io_ReadCreateInv()

Abc_Obj_t * Io_ReadCreateInv ( Abc_Ntk_t * pNtk,
char * pNameIn,
char * pNameOut )
extern

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

Synopsis [Create an inverter or buffer for the given net.]

Description [Assumes that the nets already exist.]

SideEffects []

SeeAlso []

Definition at line 783 of file ioUtil.c.

784{
785 Abc_Obj_t * pNet, * pNode;
786 pNet = Abc_NtkFindNet(pNtk, pNameIn); assert( pNet );
787 pNode = Abc_NtkCreateNodeInv(pNtk, pNet);
788 pNet = Abc_NtkFindNet(pNtk, pNameOut); assert( pNet );
789 Abc_ObjAddFanin( pNet, pNode );
790 return pNode;
791}
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:674
Here is the call graph for this function:

◆ Io_ReadCreateLatch()

Abc_Obj_t * Io_ReadCreateLatch ( Abc_Ntk_t * pNtk,
char * pNetLI,
char * pNetLO )
extern

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

Synopsis [Create a latch with the given input/output.]

Description [By default, the latch value is unknown (ABC_INIT_NONE).]

SideEffects []

SeeAlso []

Definition at line 669 of file ioUtil.c.

670{
671 Abc_Obj_t * pLatch, * pTerm, * pNet;
672 // get the LI net
673 pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLI );
674 // add the BO terminal
675 pTerm = Abc_NtkCreateBi( pNtk );
676 Abc_ObjAddFanin( pTerm, pNet );
677 // add the latch box
678 pLatch = Abc_NtkCreateLatch( pNtk );
679 Abc_ObjAddFanin( pLatch, pTerm );
680 // add the BI terminal
681 pTerm = Abc_NtkCreateBo( pNtk );
682 Abc_ObjAddFanin( pTerm, pLatch );
683 // get the LO net
684 pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO );
685 Abc_ObjAddFanin( pNet, pTerm );
686 // set latch name
687 Abc_ObjAssignName( pLatch, pNetLO, "L" );
688 return pLatch;
689}
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:587
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadCreateNode()

Abc_Obj_t * Io_ReadCreateNode ( Abc_Ntk_t * pNtk,
char * pNameOut,
char * pNamesIn[],
int nInputs )
extern

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

Synopsis [Create node and the net driven by it.]

Description []

SideEffects []

SeeAlso []

Definition at line 734 of file ioUtil.c.

735{
736 Abc_Obj_t * pNet, * pNode;
737 int i;
738 // create a new node
739 pNode = Abc_NtkCreateNode( pNtk );
740 // add the fanin nets
741 for ( i = 0; i < nInputs; i++ )
742 {
743 pNet = Abc_NtkFindOrCreateNet( pNtk, pNamesIn[i] );
744 Abc_ObjAddFanin( pNode, pNet );
745 }
746 // add the fanout net
747 pNet = Abc_NtkFindOrCreateNet( pNtk, pNameOut );
748 Abc_ObjAddFanin( pNet, pNode );
749 return pNode;
750}
Here is the call graph for this function:

◆ Io_ReadCreatePi()

Abc_Obj_t * Io_ReadCreatePi ( Abc_Ntk_t * pNtk,
char * pName )
extern

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

Synopsis [Creates PI terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 619 of file ioUtil.c.

620{
621 Abc_Obj_t * pNet, * pTerm;
622 // get the PI net
623 pNet = Abc_NtkFindNet( pNtk, pName );
624 if ( pNet )
625 printf( "Warning: PI \"%s\" appears twice in the list.\n", pName );
626 pNet = Abc_NtkFindOrCreateNet( pNtk, pName );
627 // add the PI node
628 pTerm = Abc_NtkCreatePi( pNtk );
629 Abc_ObjAddFanin( pNet, pTerm );
630 return pTerm;
631}
Here is the call graph for this function:

◆ Io_ReadCreatePo()

Abc_Obj_t * Io_ReadCreatePo ( Abc_Ntk_t * pNtk,
char * pName )
extern

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

Synopsis [Creates PO terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 644 of file ioUtil.c.

645{
646 Abc_Obj_t * pNet, * pTerm;
647 // get the PO net
648 pNet = Abc_NtkFindNet( pNtk, pName );
649 if ( pNet && Abc_ObjFaninNum(pNet) == 0 )
650 printf( "Warning: PO \"%s\" appears twice in the list.\n", pName );
651 pNet = Abc_NtkFindOrCreateNet( pNtk, pName );
652 // add the PO node
653 pTerm = Abc_NtkCreatePo( pNtk );
654 Abc_ObjAddFanin( pTerm, pNet );
655 return pTerm;
656}
Here is the call graph for this function:

◆ Io_ReadCreateResetLatch()

Abc_Obj_t * Io_ReadCreateResetLatch ( Abc_Ntk_t * pNtk,
int fBlifMv )
extern

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

Synopsis [Create the reset latch with data=1 and init=0.]

Description []

SideEffects []

SeeAlso []

Definition at line 702 of file ioUtil.c.

703{
704 Abc_Obj_t * pLatch, * pNode;
705 Abc_Obj_t * pNetLI, * pNetLO;
706 // create latch with 0 init value
707// pLatch = Io_ReadCreateLatch( pNtk, "_resetLI_", "_resetLO_" );
708 pNetLI = Abc_NtkCreateNet( pNtk );
709 pNetLO = Abc_NtkCreateNet( pNtk );
710 Abc_ObjAssignName( pNetLI, Abc_ObjName(pNetLI), NULL );
711 Abc_ObjAssignName( pNetLO, Abc_ObjName(pNetLO), NULL );
712 pLatch = Io_ReadCreateLatch( pNtk, Abc_ObjName(pNetLI), Abc_ObjName(pNetLO) );
713 // set the initial value
714 Abc_LatchSetInit0( pLatch );
715 // feed the latch with constant1- node
716// pNode = Abc_NtkCreateNode( pNtk );
717// pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "2\n1\n" );
718 pNode = Abc_NtkCreateNodeConst1( pNtk );
719 Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pNode );
720 return pLatch;
721}
Abc_Obj_t * Io_ReadCreateLatch(Abc_Ntk_t *pNtk, char *pNetLI, char *pNetLO)
Definition ioUtil.c:669
Here is the call graph for this function:

◆ Io_ReadCreateResetMux()

Abc_Obj_t * Io_ReadCreateResetMux ( Abc_Ntk_t * pNtk,
char * pResetLO,
char * pDataLI,
int fBlifMv )
extern

◆ Io_ReadEdif()

Abc_Ntk_t * Io_ReadEdif ( char * pFileName,
int fCheck )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the network from an EDIF file.]

Description [Works only for the ISCAS benchmarks.]

SideEffects []

SeeAlso []

Definition at line 47 of file ioReadEdif.c.

48{
50 Abc_Ntk_t * pNtk;
51
52 printf( "Currently this parser does not work!\n" );
53 return NULL;
54
55 // start the file
56 p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t()" );
57 if ( p == NULL )
58 return NULL;
59
60 // read the network
61 pNtk = Io_ReadEdifNetwork( p );
63 if ( pNtk == NULL )
64 return NULL;
65
66 // make sure that everything is okay with the network structure
67 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
68 {
69 printf( "Io_ReadEdif: The network check has failed.\n" );
70 Abc_NtkDelete( pNtk );
71 return NULL;
72 }
73 return pNtk;
74}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadEqn()

Abc_Ntk_t * Io_ReadEqn ( char * pFileName,
int fCheck )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the network from a BENCH file.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file ioReadEqn.c.

51{
53 Abc_Ntk_t * pNtk;
54
55 // start the file
56 p = Extra_FileReaderAlloc( pFileName, "#", ";", "=" );
57 if ( p == NULL )
58 return NULL;
59
60 // read the network
61 pNtk = Io_ReadEqnNetwork( p );
63 if ( pNtk == NULL )
64 return NULL;
65
66 // make sure that everything is okay with the network structure
67 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
68 {
69 printf( "Io_ReadEqn: The network check has failed.\n" );
70 Abc_NtkDelete( pNtk );
71 return NULL;
72 }
73 return pNtk;
74}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadFileType()

Io_FileType_t Io_ReadFileType ( char * pFileName)
extern

DECLARATIONS ///.

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

FileName [ioUtil.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
ioUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

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

Synopsis [Returns the file type.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioUtil.c.

48{
49 char * pExt;
50 if ( pFileName == NULL )
51 return IO_FILE_NONE;
52 pExt = Extra_FileNameExtension( pFileName );
53 if ( pExt == NULL )
54 return IO_FILE_NONE;
55 if ( !strcmp( pExt, "aig" ) )
56 return IO_FILE_AIGER;
57 if ( !strcmp( pExt, "baf" ) )
58 return IO_FILE_BAF;
59 if ( !strcmp( pExt, "bblif" ) )
60 return IO_FILE_BBLIF;
61 if ( !strcmp( pExt, "blif" ) )
62 return IO_FILE_BLIF;
63 if ( !strcmp( pExt, "bench" ) )
64 return IO_FILE_BENCH;
65 if ( !strcmp( pExt, "cnf" ) )
66 return IO_FILE_CNF;
67 if ( !strcmp( pExt, "dot" ) )
68 return IO_FILE_DOT;
69 if ( !strcmp( pExt, "edif" ) )
70 return IO_FILE_EDIF;
71 if ( !strcmp( pExt, "eqn" ) )
72 return IO_FILE_EQN;
73 if ( !strcmp( pExt, "gml" ) )
74 return IO_FILE_GML;
75 if ( !strcmp( pExt, "list" ) )
76 return IO_FILE_LIST;
77 if ( !strcmp( pExt, "mv" ) )
78 return IO_FILE_BLIFMV;
79 if ( !strcmp( pExt, "pla" ) )
80 return IO_FILE_PLA;
81 if ( !strcmp( pExt, "smv" ) )
82 return IO_FILE_SMV;
83 if ( !strcmp( pExt, "v" ) )
84 return IO_FILE_VERILOG;
85 return IO_FILE_UNKNOWN;
86}
char * Extra_FileNameExtension(char *FileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadJson()

void Io_ReadJson ( char * pFileName)
extern

◆ Io_ReadLibType()

Io_FileType_t Io_ReadLibType ( char * pFileName)
extern

◆ Io_ReadNetlist()

Abc_Ntk_t * Io_ReadNetlist ( char * pFileName,
Io_FileType_t FileType,
int fCheck )
extern

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

Synopsis [Read the network from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file ioUtil.c.

100{
101 FILE * pFile;
102 Abc_Ntk_t * pNtk;
103 if ( FileType == IO_FILE_NONE || FileType == IO_FILE_UNKNOWN )
104 {
105 fprintf( stdout, "Generic file reader requires a known file extension to open \"%s\".\n", pFileName );
106 return NULL;
107 }
108 // check if the file exists
109 pFile = fopen( pFileName, "r" );
110 if ( pFile == NULL )
111 {
112 fprintf( stdout, "Cannot open input file \"%s\". ", pFileName );
113 if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" )) )
114 fprintf( stdout, "Did you mean \"%s\"?", pFileName );
115 fprintf( stdout, "\n" );
116 return NULL;
117 }
118 fclose( pFile );
119 // read the AIG
120 if ( FileType == IO_FILE_AIGER || FileType == IO_FILE_BAF || FileType == IO_FILE_BBLIF )
121 {
122 if ( FileType == IO_FILE_AIGER )
123 pNtk = Io_ReadAiger( pFileName, fCheck );
124 else if ( FileType == IO_FILE_BAF )
125 pNtk = Io_ReadBaf( pFileName, fCheck );
126 else // if ( FileType == IO_FILE_BBLIF )
127 pNtk = Io_ReadBblif( pFileName, fCheck );
128 if ( pNtk == NULL )
129 {
130 fprintf( stdout, "Reading AIG from file has failed.\n" );
131 return NULL;
132 }
133 return pNtk;
134 }
135 // read the new netlist
136 if ( FileType == IO_FILE_BLIF )
137// pNtk = Io_ReadBlif( pFileName, fCheck );
138 pNtk = Io_ReadBlifMv( pFileName, 0, fCheck );
139 else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
140 pNtk = Io_ReadBlifMv( pFileName, 1, fCheck );
141 else if ( FileType == IO_FILE_BENCH )
142 pNtk = Io_ReadBench( pFileName, fCheck );
143 else if ( FileType == IO_FILE_EDIF )
144 pNtk = Io_ReadEdif( pFileName, fCheck );
145 else if ( FileType == IO_FILE_EQN )
146 pNtk = Io_ReadEqn( pFileName, fCheck );
147 else if ( FileType == IO_FILE_PLA )
148 pNtk = Io_ReadPla( pFileName, 0, 0, 0, 0, fCheck );
149 else if ( FileType == IO_FILE_VERILOG )
150 pNtk = Io_ReadVerilog( pFileName, fCheck );
151 else
152 {
153 fprintf( stderr, "Unknown file format.\n" );
154 return NULL;
155 }
156 if ( pNtk == NULL )
157 {
158 fprintf( stdout, "Reading network from file has failed.\n" );
159 return NULL;
160 }
161
162 if ( fCheck && (Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk)) && pNtk->pDesign )
163 {
164
165 int i, fCycle = 0;
166 Abc_Ntk_t * pModel;
167// fprintf( stdout, "Warning: The network contains hierarchy.\n" );
168 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
169 if ( !Abc_NtkIsAcyclicWithBoxes( pModel ) )
170 fCycle = 1;
171 if ( fCycle )
172 {
173 Abc_NtkDelete( pNtk );
174 return NULL;
175 }
176 }
177 return pNtk;
178}
ABC_DLL int Abc_NtkIsAcyclicWithBoxes(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1702
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Abc_Ntk_t * Io_ReadBlifMv(char *pFileName, int fBlifMv, int fCheck)
FUNCTION DEFINITIONS ///.
Abc_Ntk_t * Io_ReadBaf(char *pFileName, int fCheck)
DECLARATIONS ///.
Definition ioReadBaf.c:45
Abc_Ntk_t * Io_ReadEqn(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Definition ioReadEqn.c:50
Abc_Ntk_t * Io_ReadAiger(char *pFileName, int fCheck)
FUNCTION DECLARATIONS ///.
Abc_Ntk_t * Io_ReadVerilog(char *pFileName, int fCheck)
DECLARATIONS ///.
Abc_Ntk_t * Io_ReadBblif(char *pFileName, int fCheck)
Abc_Ntk_t * Io_ReadBench(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Definition ioReadBench.c:47
Abc_Ntk_t * Io_ReadPla(char *pFileName, int fZeros, int fBoth, int fOnDc, int fSkipPrepro, int fCheck)
Definition ioReadPla.c:329
Abc_Ntk_t * Io_ReadEdif(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Definition ioReadEdif.c:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadPla()

Abc_Ntk_t * Io_ReadPla ( char * pFileName,
int fZeros,
int fBoth,
int fOnDc,
int fSkipPrepro,
int fCheck )
extern

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

Synopsis [Reads the network from a PLA file.]

Description []

SideEffects []

SeeAlso []

Definition at line 329 of file ioReadPla.c.

330{
332 Abc_Ntk_t * pNtk;
333
334 // start the file
335 p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t|" );
336// p = Extra_FileReaderAlloc( pFileName, "", "\n\r", " \t|" );
337 if ( p == NULL )
338 return NULL;
339
340 // read the network
341 pNtk = Io_ReadPlaNetwork( p, fZeros, fBoth, fOnDc, fSkipPrepro );
343 if ( pNtk == NULL )
344 return NULL;
345
346 // make sure that everything is okay with the network structure
347 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
348 {
349 printf( "Io_ReadPla: The network check has failed.\n" );
350 Abc_NtkDelete( pNtk );
351 return NULL;
352 }
353 return pNtk;
354}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadVerilog()

Abc_Ntk_t * Io_ReadVerilog ( char * pFileName,
int fCheck )
extern

DECLARATIONS ///.

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

FileName [ioReadVerilog.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedure to read network from file.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Reads hierarchical design from the Verilog file.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file ioReadVerilog.c.

49{
50 Abc_Ntk_t * pNtk, * pTemp;
51 Abc_Des_t * pDesign;
52 int i, RetValue;
53
54 // parse the verilog file
55 pDesign = Ver_ParseFile( pFileName, NULL, fCheck, 1 );
56 if ( pDesign == NULL )
57 return NULL;
58
59 // detect top-level model
60 RetValue = Abc_DesFindTopLevelModels( pDesign );
61 pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pDesign->vTops, 0 );
62 if ( RetValue > 1 )
63 {
64 printf( "Warning: The design has %d root-level modules: ", Vec_PtrSize(pDesign->vTops) );
65 Vec_PtrForEachEntry( Abc_Ntk_t *, pDesign->vTops, pTemp, i )
66 printf( " %s", Abc_NtkName(pTemp) );
67 printf( "\n" );
68 printf( "The first one (%s) will be used.\n", pNtk->pName );
69 }
70
71 // extract the master network
72 pNtk->pDesign = pDesign;
73 pDesign->pManFunc = NULL;
74
75 // verify the design for cyclic dependence
76 assert( Vec_PtrSize(pDesign->vModules) > 0 );
77 if ( Vec_PtrSize(pDesign->vModules) == 1 )
78 {
79// printf( "Warning: The design is not hierarchical.\n" );
80 Abc_DesFree( pDesign, pNtk );
81 pNtk->pDesign = NULL;
82 pNtk->pSpec = Extra_UtilStrsav( pFileName );
83 }
84 else
85 {
86 // check that there is no cyclic dependency
88 }
89
90//Io_WriteVerilog( pNtk, "_temp.v" );
91// Abc_NtkPrintBoxInfo( pNtk );
92 return pNtk;
93}
Abc_Des_t * Ver_ParseFile(char *pFileName, Abc_Des_t *pGateLib, int fCheck, int fUseMemMan)
MACRO DEFINITIONS ///.
Definition verCore.c:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_Write()

void Io_Write ( Abc_Ntk_t * pNtk,
char * pFileName,
Io_FileType_t FileType )
extern

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

Synopsis [Write the network into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file ioUtil.c.

321{
322 Abc_Ntk_t * pNtkTemp, * pNtkCopy;
323 // check if the current network is available
324 if ( pNtk == NULL )
325 {
326 fprintf( stdout, "Empty network.\n" );
327 return;
328 }
329 // check if the file extension if given
330 if ( FileType == IO_FILE_NONE || FileType == IO_FILE_UNKNOWN )
331 {
332 fprintf( stdout, "The generic file writer requires a known file extension.\n" );
333 return;
334 }
335 // write the AIG formats
336 if ( FileType == IO_FILE_AIGER || FileType == IO_FILE_BAF )
337 {
338 if ( !Abc_NtkIsStrash(pNtk) )
339 {
340 fprintf( stdout, "Writing this format is only possible for structurally hashed AIGs.\n" );
341 return;
342 }
343 if ( FileType == IO_FILE_AIGER )
344 Io_WriteAiger( pNtk, pFileName, 1, 0, 0 );
345 else //if ( FileType == IO_FILE_BAF )
346 Io_WriteBaf( pNtk, pFileName );
347 return;
348 }
349 // write non-netlist types
350 if ( FileType == IO_FILE_CNF )
351 {
352 Io_WriteCnf( pNtk, pFileName, 0 );
353 return;
354 }
355 if ( FileType == IO_FILE_DOT )
356 {
357 Io_WriteDot( pNtk, pFileName );
358 return;
359 }
360 if ( FileType == IO_FILE_GML )
361 {
362 Io_WriteGml( pNtk, pFileName );
363 return;
364 }
365 if ( FileType == IO_FILE_BBLIF )
366 {
367 if ( !Abc_NtkIsLogic(pNtk) )
368 {
369 fprintf( stdout, "Writing Binary BLIF is only possible for logic networks.\n" );
370 return;
371 }
372 if ( !Abc_NtkHasSop(pNtk) )
373 Abc_NtkToSop( pNtk, -1, ABC_INFINITY );
374 Io_WriteBblif( pNtk, pFileName );
375 return;
376 }
377/*
378 if ( FileType == IO_FILE_BLIFMV )
379 {
380 Io_WriteBlifMv( pNtk, pFileName );
381 return;
382 }
383*/
384 // convert logic network into netlist
385 if ( FileType == IO_FILE_PLA )
386 {
387 if ( Abc_NtkLevel(pNtk) > 1 )
388 {
389 fprintf( stdout, "PLA writing is available for collapsed networks.\n" );
390 return;
391 }
392 if ( Abc_NtkIsComb(pNtk) )
393 pNtkTemp = Abc_NtkToNetlist( pNtk );
394 else
395 {
396 fprintf( stdout, "Latches are written into the PLA file at PI/PO pairs.\n" );
397 pNtkCopy = Abc_NtkDup( pNtk );
398 Abc_NtkMakeComb( pNtkCopy, 0 );
399 pNtkTemp = Abc_NtkToNetlist( pNtk );
400 Abc_NtkDelete( pNtkCopy );
401 }
402 if ( !Abc_NtkToSop( pNtkTemp, 1, ABC_INFINITY ) )
403 return;
404 }
405 else if ( FileType == IO_FILE_MOPLA )
406 {
407 pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
408 }
409 else if ( FileType == IO_FILE_BENCH )
410 {
411 if ( !Abc_NtkIsStrash(pNtk) )
412 {
413 fprintf( stdout, "Writing traditional BENCH is available for AIGs only (use \"write_bench\").\n" );
414 return;
415 }
416 pNtkTemp = Abc_NtkToNetlistBench( pNtk );
417 }
418 else if ( FileType == IO_FILE_SMV )
419 {
420 if ( !Abc_NtkIsStrash(pNtk) )
421 {
422 fprintf( stdout, "Writing traditional SMV is available for AIGs only.\n" );
423 return;
424 }
425 pNtkTemp = Abc_NtkToNetlistBench( pNtk );
426 }
427 else
428 pNtkTemp = Abc_NtkToNetlist( pNtk );
429
430 if ( pNtkTemp == NULL )
431 {
432 fprintf( stdout, "Converting to netlist has failed.\n" );
433 return;
434 }
435
436 if ( FileType == IO_FILE_BLIF )
437 {
438 if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
439 Abc_NtkToSop( pNtkTemp, -1, ABC_INFINITY );
440 Io_WriteBlif( pNtkTemp, pFileName, 1, 0, 0 );
441 }
442 else if ( FileType == IO_FILE_BLIFMV )
443 {
444 if ( !Abc_NtkConvertToBlifMv( pNtkTemp ) )
445 return;
446 Io_WriteBlifMv( pNtkTemp, pFileName );
447 }
448 else if ( FileType == IO_FILE_BENCH )
449 Io_WriteBench( pNtkTemp, pFileName );
450 else if ( FileType == IO_FILE_BOOK )
451 Io_WriteBook( pNtkTemp, pFileName );
452 else if ( FileType == IO_FILE_PLA )
453 Io_WritePla( pNtkTemp, pFileName );
454 else if ( FileType == IO_FILE_MOPLA )
455 Io_WriteMoPla( pNtkTemp, pFileName );
456 else if ( FileType == IO_FILE_EQN )
457 {
458 if ( !Abc_NtkHasAig(pNtkTemp) )
459 Abc_NtkToAig( pNtkTemp );
460 Io_WriteEqn( pNtkTemp, pFileName );
461 }
462 else if ( FileType == IO_FILE_SMV )
463 Io_WriteSmv( pNtkTemp, pFileName );
464 else if ( FileType == IO_FILE_VERILOG )
465 {
466 if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
467 Abc_NtkToAig( pNtkTemp );
468 Io_WriteVerilog( pNtkTemp, pFileName, 0, 0 );
469 }
470 else
471 fprintf( stderr, "Unknown file format.\n" );
472 Abc_NtkDelete( pNtkTemp );
473}
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlistBench(Abc_Ntk_t *pNtk)
Definition abcNetlist.c:125
ABC_DLL int Abc_NtkConvertToBlifMv(Abc_Ntk_t *pNtk)
Definition abcBlifMv.c:957
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1449
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition abcNetlist.c:100
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1333
ABC_DLL void Abc_NtkMakeComb(Abc_Ntk_t *pNtk, int fRemoveLatches)
Definition abcNtk.c:1637
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
Definition abcFunc.c:1261
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition abcStrash.c:265
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
void Io_WriteBblif(Abc_Ntk_t *pNtk, char *pFileName)
void Io_WriteDot(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
Definition ioWriteDot.c:51
int Io_WritePla(Abc_Ntk_t *pNtk, char *FileName)
Definition ioWritePla.c:171
void Io_WriteEqn(Abc_Ntk_t *pNtk, char *pFileName)
FUNCTION DEFINITIONS ///.
Definition ioWriteEqn.c:50
void Io_WriteVerilog(Abc_Ntk_t *pNtk, char *FileName, int fOnlyAnds, int fNewInterface)
FUNCTION DEFINITIONS ///.
void Io_WriteAiger(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols, int fCompact, int fUnique)
int Io_WriteBench(Abc_Ntk_t *pNtk, const char *FileName)
FUNCTION DEFINITIONS ///.
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition ioWriteBlif.c:84
int Io_WriteMoPla(Abc_Ntk_t *pNtk, char *FileName)
Definition ioWritePla.c:576
void Io_WriteBlifMv(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
int Io_WriteSmv(Abc_Ntk_t *pNtk, char *FileName)
Definition ioWriteSmv.c:71
void Io_WriteGml(Abc_Ntk_t *pNtk, char *pFileName)
DECLARATIONS ///.
Definition ioWriteGml.c:46
void Io_WriteBook(Abc_Ntk_t *pNtk, char *FileName)
void Io_WriteBaf(Abc_Ntk_t *pNtk, char *pFileName)
DECLARATIONS ///.
Definition ioWriteBaf.c:84
int Io_WriteCnf(Abc_Ntk_t *pNtk, char *FileName, int fAllPrimes)
FUNCTION DEFINITIONS ///.
Definition ioWriteCnf.c:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteAiger()

void Io_WriteAiger ( Abc_Ntk_t * pNtk,
char * pFileName,
int fWriteSymbols,
int fCompact,
int fUnique )
extern

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

Synopsis [Writes the AIG in the binary AIGER format.]

Description []

SideEffects []

SeeAlso []

Definition at line 635 of file ioWriteAiger.c.

636{
637 ProgressBar * pProgress;
638// FILE * pFile;
639 Abc_Obj_t * pObj, * pDriver, * pLatch;
640 int i, nNodes, nBufferSize, bzError, Pos, fExtended;
641 unsigned char * pBuffer;
642 unsigned uLit0, uLit1, uLit;
643 bz2file b;
644
645 // define unique writing
646 if ( fUnique )
647 {
648 fWriteSymbols = 0;
649 fCompact = 0;
650 }
651
652 fExtended = Abc_NtkConstrNum(pNtk);
653
654 // check that the network is valid
655 assert( Abc_NtkIsStrash(pNtk) );
656 Abc_NtkForEachLatch( pNtk, pObj, i )
657 if ( !Abc_LatchIsInit0(pObj) )
658 {
659 if ( !fCompact )
660 {
661 fExtended = 1;
662 break;
663 }
664 fprintf( stdout, "Io_WriteAiger(): Cannot write AIGER format with non-0 latch init values. Run \"zero\".\n" );
665 return;
666 }
667
668 // write the GZ file
669 if (!strncmp(pFileName+strlen(pFileName)-3,".gz",3))
670 {
671 Io_WriteAigerGz( pNtk, pFileName, fWriteSymbols );
672 return;
673 }
674
675 memset(&b,0,sizeof(b));
676 b.nBytesMax = (1<<12);
677 b.buf = ABC_ALLOC( char,b.nBytesMax );
678
679 // start the output stream
680 b.f = fopen( pFileName, "wb" );
681 if ( b.f == NULL )
682 {
683 fprintf( stdout, "Io_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
684 ABC_FREE(b.buf);
685 return;
686 }
687 if (!strncmp(pFileName+strlen(pFileName)-4,".bz2",4)) {
688 b.b = BZ2_bzWriteOpen( &bzError, b.f, 9, 0, 0 );
689 if ( bzError != BZ_OK ) {
690 BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL );
691 fprintf( stdout, "Io_WriteAiger(): Cannot start compressed stream.\n" );
692 fclose( b.f );
693 ABC_FREE(b.buf);
694 return;
695 }
696 }
697
698 // set the node numbers to be used in the output file
699 nNodes = 0;
700 Io_ObjSetAigerNum( Abc_AigConst1(pNtk), nNodes++ );
701 Abc_NtkForEachCi( pNtk, pObj, i )
702 Io_ObjSetAigerNum( pObj, nNodes++ );
703 Abc_AigForEachAnd( pNtk, pObj, i )
704 Io_ObjSetAigerNum( pObj, nNodes++ );
705
706 // write the header "M I L O A" where M = I + L + A
707 fprintfBz2Aig( &b, "aig%s %u %u %u %u %u",
708 fCompact? "2" : "",
709 Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) + Abc_NtkNodeNum(pNtk),
710 Abc_NtkPiNum(pNtk),
711 Abc_NtkLatchNum(pNtk),
712 fExtended ? 0 : Abc_NtkPoNum(pNtk),
713 Abc_NtkNodeNum(pNtk) );
714 // write the extended header "B C J F"
715 if ( fExtended )
716 fprintfBz2Aig( &b, " %u %u", Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk), Abc_NtkConstrNum(pNtk) );
717 fprintfBz2Aig( &b, "\n" );
718
719 // if the driver node is a constant, we need to complement the literal below
720 // because, in the AIGER format, literal 0/1 is represented as number 0/1
721 // while, in ABC, constant 1 node has number 0 and so literal 0/1 will be 1/0
722
724 if ( !fCompact )
725 {
726 // write latch drivers
727 Abc_NtkForEachLatch( pNtk, pLatch, i )
728 {
729 pObj = Abc_ObjFanin0(pLatch);
730 pDriver = Abc_ObjFanin0(pObj);
731 uLit = Io_ObjMakeLit( Io_ObjAigerNum(pDriver), Abc_ObjFaninC0(pObj) ^ (Io_ObjAigerNum(pDriver) == 0) );
732 if ( Abc_LatchIsInit0(pLatch) )
733 fprintfBz2Aig( &b, "%u\n", uLit );
734 else if ( Abc_LatchIsInit1(pLatch) )
735 fprintfBz2Aig( &b, "%u 1\n", uLit );
736 else
737 {
738 // Both None and DC are written as 'uninitialized' e.g. a free boolean value
739 assert( Abc_LatchIsInitNone(pLatch) || Abc_LatchIsInitDc(pLatch) );
740 fprintfBz2Aig( &b, "%u %u\n", uLit, Io_ObjMakeLit( Io_ObjAigerNum(Abc_ObjFanout0(pLatch)), 0 ) );
741 }
742 }
743 // write PO drivers
744 Abc_NtkForEachPo( pNtk, pObj, i )
745 {
746 pDriver = Abc_ObjFanin0(pObj);
747 fprintfBz2Aig( &b, "%u\n", Io_ObjMakeLit( Io_ObjAigerNum(pDriver), Abc_ObjFaninC0(pObj) ^ (Io_ObjAigerNum(pDriver) == 0) ) );
748 }
749 }
750 else
751 {
752 Vec_Int_t * vLits = Io_WriteAigerLiterals( pNtk );
753 Vec_Str_t * vBinary = Io_WriteEncodeLiterals( vLits );
754 if ( !b.b )
755 fwrite( Vec_StrArray(vBinary), 1, Vec_StrSize(vBinary), b.f );
756 else
757 {
758 BZ2_bzWrite( &bzError, b.b, Vec_StrArray(vBinary), Vec_StrSize(vBinary) );
759 if (bzError == BZ_IO_ERROR) {
760 fprintf( stdout, "Io_WriteAiger(): I/O error writing to compressed stream.\n" );
761 fclose( b.f );
762 ABC_FREE(b.buf);
763 Vec_StrFree( vBinary );
764 return;
765 }
766 }
767 Vec_StrFree( vBinary );
768 Vec_IntFree( vLits );
769 }
771
772 // write the nodes into the buffer
773 Pos = 0;
774 nBufferSize = 6 * Abc_NtkNodeNum(pNtk) + 100; // skeptically assuming 3 chars per one AIG edge
775 pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
776 pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
777 Abc_AigForEachAnd( pNtk, pObj, i )
778 {
779 Extra_ProgressBarUpdate( pProgress, i, NULL );
780 uLit = Io_ObjMakeLit( Io_ObjAigerNum(pObj), 0 );
781 uLit0 = Io_ObjMakeLit( Io_ObjAigerNum(Abc_ObjFanin0(pObj)), Abc_ObjFaninC0(pObj) );
782 uLit1 = Io_ObjMakeLit( Io_ObjAigerNum(Abc_ObjFanin1(pObj)), Abc_ObjFaninC1(pObj) );
783 if ( uLit0 > uLit1 )
784 {
785 unsigned Temp = uLit0;
786 uLit0 = uLit1;
787 uLit1 = Temp;
788 }
789 assert( uLit1 < uLit );
790 Pos = Io_WriteAigerEncode( pBuffer, Pos, (unsigned)(uLit - uLit1) );
791 Pos = Io_WriteAigerEncode( pBuffer, Pos, (unsigned)(uLit1 - uLit0) );
792 if ( Pos > nBufferSize - 10 )
793 {
794 printf( "Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
795 fclose( b.f );
796 ABC_FREE(b.buf);
797 Extra_ProgressBarStop( pProgress );
798 return;
799 }
800 }
801 assert( Pos < nBufferSize );
802 Extra_ProgressBarStop( pProgress );
803
804 // write the buffer
805 if ( !b.b )
806 fwrite( pBuffer, 1, Pos, b.f );
807 else
808 {
809 BZ2_bzWrite( &bzError, b.b, pBuffer, Pos );
810 if (bzError == BZ_IO_ERROR) {
811 fprintf( stdout, "Io_WriteAiger(): I/O error writing to compressed stream.\n" );
812 fclose( b.f );
813 ABC_FREE(b.buf);
814 return;
815 }
816 }
817 ABC_FREE( pBuffer );
818
819 // write the symbol table
820 if ( fWriteSymbols )
821 {
822 // write PIs
823 Abc_NtkForEachPi( pNtk, pObj, i )
824 fprintfBz2Aig( &b, "i%d %s\n", i, Abc_ObjName(pObj) );
825 // write latches
826 Abc_NtkForEachLatch( pNtk, pObj, i )
827 fprintfBz2Aig( &b, "l%d %s\n", i, Abc_ObjName(Abc_ObjFanout0(pObj)) );
828 // write POs
829 Abc_NtkForEachPo( pNtk, pObj, i )
830 if ( !fExtended )
831 fprintfBz2Aig( &b, "o%d %s\n", i, Abc_ObjName(pObj) );
832 else if ( i < Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk) )
833 fprintfBz2Aig( &b, "b%d %s\n", i, Abc_ObjName(pObj) );
834 else
835 fprintfBz2Aig( &b, "c%d %s\n", i - (Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk)), Abc_ObjName(pObj) );
836 }
837
838 // write the comment
839 fprintfBz2Aig( &b, "c" );
840 if ( !fUnique )
841 {
842 if ( pNtk->pName && strlen(pNtk->pName) > 0 )
843 fprintfBz2Aig( &b, "\n%s%c", pNtk->pName, '\0' );
844 fprintfBz2Aig( &b, "\nThis file was written by ABC on %s\n", Extra_TimeStamp() );
845 fprintfBz2Aig( &b, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
846 }
847
848 // close the file
849 if (b.b) {
850 BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL );
851 if (bzError == BZ_IO_ERROR) {
852 fprintf( stdout, "Io_WriteAiger(): I/O error closing compressed stream.\n" );
853 fclose( b.f );
854 ABC_FREE(b.buf);
855 return;
856 }
857 }
858 fclose( b.f );
859 ABC_FREE(b.buf);
860}
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
BZFILE *BZ_API BZ2_bzWriteOpen(int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
Definition bzlib.c:928
void BZ_API BZ2_bzWrite(int *bzerror, BZFILE *b, void *buf, int len)
Definition bzlib.c:976
void BZ_API BZ2_bzWriteClose(int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
Definition bzlib.c:1021
#define BZ_IO_ERROR
Definition bzlib.h:44
#define BZ_OK
Definition bzlib.h:34
ush Pos
Definition deflate.h:88
char * Extra_TimeStamp()
Vec_Str_t * Io_WriteEncodeLiterals(Vec_Int_t *vLits)
int Io_WriteAigerEncode(unsigned char *pBuffer, int Pos, unsigned x)
FUNCTION DEFINITIONS ///.
int fprintfBz2Aig(bz2file *b, char *fmt,...)
Vec_Int_t * Io_WriteAigerLiterals(Abc_Ntk_t *pNtk)
void Io_WriteAigerGz(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols)
int nBytesMax
FILE * f
BZFILE * b
char * buf
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteAigerCex()

void Io_WriteAigerCex ( Abc_Cex_t * pCex,
Abc_Ntk_t * pNtk,
void * pG,
char * pFileName )
extern

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

Synopsis [Writes the AIG in the binary AIGER format.]

Description []

SideEffects []

SeeAlso []

Definition at line 880 of file ioWriteAiger.c.

881{
882 extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
883 FILE * pFile;
884 Aig_Man_t * pAig;
885 Aig_Obj_t * pObj, * pObj2;
886 Gia_Man_t * pGia = (Gia_Man_t *)pG;
887 int k, f, b;
888 assert( pCex != NULL );
889
890 // derive AIG
891 if ( pNtk != NULL &&
892 Abc_NtkPiNum(pNtk) == pCex->nPis &&
893 Abc_NtkLatchNum(pNtk) == pCex->nRegs )
894 {
895 pAig = Abc_NtkToDar( pNtk, 0, 1 );
896 }
897 else if ( pGia != NULL &&
898 Gia_ManPiNum(pGia) == pCex->nPis &&
899 Gia_ManRegNum(pGia) == pCex->nRegs )
900 {
901 pAig = Gia_ManToAigSimple( pGia );
902 }
903 else
904 {
905 printf( "AIG parameters do not match those of the CEX.\n" );
906 return;
907 }
908
909 // create output file
910 pFile = fopen( pFileName, "wb" );
911 fprintf( pFile, "1\n" );
912 b = pCex->nRegs;
913 for ( k = 0; k < pCex->nRegs; k++ )
914 fprintf( pFile, "0" );
915 fprintf( pFile, " " );
916 Aig_ManCleanMarkA( pAig );
917 Aig_ManConst1(pAig)->fMarkA = 1;
918 for ( f = 0; f <= pCex->iFrame; f++ )
919 {
920 for ( k = 0; k < pCex->nPis; k++ )
921 {
922 fprintf( pFile, "%d", Abc_InfoHasBit(pCex->pData, b) );
923 Aig_ManCi( pAig, k )->fMarkA = Abc_InfoHasBit(pCex->pData, b++);
924 }
925 fprintf( pFile, " " );
926 Aig_ManForEachNode( pAig, pObj, k )
927 pObj->fMarkA = (Aig_ObjFanin0(pObj)->fMarkA ^ Aig_ObjFaninC0(pObj)) &
928 (Aig_ObjFanin1(pObj)->fMarkA ^ Aig_ObjFaninC1(pObj));
929 Aig_ManForEachCo( pAig, pObj, k )
930 pObj->fMarkA = (Aig_ObjFanin0(pObj)->fMarkA ^ Aig_ObjFaninC0(pObj));
931 Saig_ManForEachPo( pAig, pObj, k )
932 fprintf( pFile, "%d", pObj->fMarkA );
933 fprintf( pFile, " " );
934 Saig_ManForEachLi( pAig, pObj, k )
935 fprintf( pFile, "%d", pObj->fMarkA );
936 fprintf( pFile, "\n" );
937 if ( f == pCex->iFrame )
938 break;
939 Saig_ManForEachLi( pAig, pObj, k )
940 fprintf( pFile, "%d", pObj->fMarkA );
941 fprintf( pFile, " " );
942 Saig_ManForEachLiLo( pAig, pObj, pObj2, k )
943 pObj2->fMarkA = pObj->fMarkA;
944 }
945 assert( b == pCex->nBits );
946 fclose( pFile );
947 Aig_ManCleanMarkA( pAig );
948 Aig_ManStop( pAig );
949}
void Aig_ManCleanMarkA(Aig_Man_t *p)
Definition aigUtil.c:148
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition giaAig.c:408
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Definition abcDar.c:237
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
#define Saig_ManForEachLi(p, pObj, i)
Definition saig.h:98
#define Saig_ManForEachPo(p, pObj, i)
Definition saig.h:93
unsigned int fMarkA
Definition aig.h:79
Here is the call graph for this function:

◆ Io_WriteBaf()

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

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}
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteBblif()

void Io_WriteBblif ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

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

Synopsis [Writes the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file ioWriteBblif.c.

100{
101 Bbl_Man_t * p;
102 p = Bbl_ManFromAbc( pNtk );
103//Bbl_ManPrintStats( p );
104//Bbl_ManDumpBlif( p, "test_bbl.blif" );
105 Bbl_ManDumpBinaryBlif( p, pFileName );
106 Bbl_ManStop( p );
107}
void Bbl_ManDumpBinaryBlif(Bbl_Man_t *p, char *pFileName)
Definition bblif.c:691
ABC_NAMESPACE_IMPL_START Bbl_Man_t * Bbl_ManFromAbc(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteBench()

int Io_WriteBench ( Abc_Ntk_t * pNtk,
const char * pFileName )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 53 of file ioWriteBench.c.

54{
55 Abc_Ntk_t * pExdc;
56 FILE * pFile;
57 assert( Abc_NtkIsSopNetlist(pNtk) );
58 if ( !Io_WriteBenchCheckNames(pNtk) )
59 {
60 fprintf( stdout, "Io_WriteBench(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
61 return 0;
62 }
63 pFile = fopen( pFileName, "w" );
64 if ( pFile == NULL )
65 {
66 fprintf( stdout, "Io_WriteBench(): Cannot open the output file.\n" );
67 return 0;
68 }
69 fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
70 // write the network
71 Io_WriteBenchOne( pFile, pNtk );
72 // write EXDC network if it exists
73 pExdc = Abc_NtkExdc( pNtk );
74 if ( pExdc )
75 printf( "Io_WriteBench: EXDC is not written (warning).\n" );
76 // finalize the file
77 fclose( pFile );
78 return 1;
79}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteBenchLut()

int Io_WriteBenchLut ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

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

Synopsis [Writes the network in BENCH format with LUTs and DFFRSE.]

Description []

SideEffects []

SeeAlso []

Definition at line 175 of file ioWriteBench.c.

176{
177 Abc_Ntk_t * pExdc;
178 FILE * pFile;
179 assert( Abc_NtkIsAigNetlist(pNtk) );
180 if ( !Io_WriteBenchCheckNames(pNtk) )
181 {
182 fprintf( stdout, "Io_WriteBenchLut(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
183 return 0;
184 }
185 pFile = fopen( pFileName, "w" );
186 if ( pFile == NULL )
187 {
188 fprintf( stdout, "Io_WriteBench(): Cannot open the output file.\n" );
189 return 0;
190 }
191 fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
192 // write the network
193 Io_WriteBenchLutOne( pFile, pNtk );
194 // write EXDC network if it exists
195 pExdc = Abc_NtkExdc( pNtk );
196 if ( pExdc )
197 printf( "Io_WriteBench: EXDC is not written (warning).\n" );
198 // finalize the file
199 fclose( pFile );
200 return 1;
201}
Here is the call graph for this function:

◆ Io_WriteBlif()

void Io_WriteBlif ( Abc_Ntk_t * pNtk,
char * FileName,
int fWriteLatches,
int fBb2Wb,
int fSeq )
extern

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

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file ioWriteBlif.c.

85{
86 FILE * pFile;
87 Abc_Ntk_t * pNtkTemp;
88 int i;
89 assert( Abc_NtkIsNetlist(pNtk) );
90 // start writing the file
91 pFile = fopen( FileName, "w" );
92 if ( pFile == NULL )
93 {
94 fprintf( stdout, "Io_WriteBlif(): Cannot open the output file.\n" );
95 return;
96 }
97 fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
98 // write the master network
99 Io_NtkWrite( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq );
100 // make sure there is no logic hierarchy
101// assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
102 // write the hierarchy if present
103 if ( Abc_NtkBlackboxNum(pNtk) > 0 || Abc_NtkWhiteboxNum(pNtk) > 0 )
104 {
105 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
106 {
107 if ( pNtkTemp == pNtk )
108 continue;
109 fprintf( pFile, "\n\n" );
110 Io_NtkWrite( pFile, pNtkTemp, fWriteLatches, fBb2Wb, fSeq );
111 }
112 }
113 fclose( pFile );
114}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteBlifLogic()

void Io_WriteBlifLogic ( Abc_Ntk_t * pNtk,
char * FileName,
int fWriteLatches )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file ioWriteBlif.c.

60{
61 Abc_Ntk_t * pNtkTemp;
62 // derive the netlist
63 pNtkTemp = Abc_NtkToNetlist(pNtk);
64 if ( pNtkTemp == NULL )
65 {
66 fprintf( stdout, "Writing BLIF has failed.\n" );
67 return;
68 }
69 Io_WriteBlif( pNtkTemp, FileName, fWriteLatches, 0, 0 );
70 Abc_NtkDelete( pNtkTemp );
71}
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition ioWriteBlif.c:84
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteBlifMv()

void Io_WriteBlifMv ( Abc_Ntk_t * pNtk,
char * FileName )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file ioWriteBlifMv.c.

59{
60 FILE * pFile;
61 Abc_Ntk_t * pNtkTemp;
62 int i;
63 assert( Abc_NtkIsNetlist(pNtk) );
64 assert( Abc_NtkHasBlifMv(pNtk) );
65 // start writing the file
66 pFile = fopen( FileName, "w" );
67 if ( pFile == NULL )
68 {
69 fprintf( stdout, "Io_WriteBlifMv(): Cannot open the output file.\n" );
70 return;
71 }
72 fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
73 // write the master network
74 Io_NtkWriteBlifMv( pFile, pNtk );
75 // write the remaining networks
76 if ( pNtk->pDesign )
77 {
78 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
79 {
80 if ( pNtkTemp == pNtk )
81 continue;
82 fprintf( pFile, "\n\n" );
83 Io_NtkWriteBlifMv( pFile, pNtkTemp );
84 }
85 }
86 fclose( pFile );
87}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteBlifSpecial()

void Io_WriteBlifSpecial ( Abc_Ntk_t * pNtk,
char * FileName,
char * pLutStruct,
int fUseHie )
extern

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

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 1385 of file ioWriteBlif.c.

1386{
1387 Abc_Ntk_t * pNtkTemp;
1388 assert( Abc_NtkIsLogic(pNtk) );
1389 Abc_NtkToSop( pNtk, -1, ABC_INFINITY );
1390 // derive the netlist
1391 pNtkTemp = Abc_NtkToNetlist(pNtk);
1392 if ( pNtkTemp == NULL )
1393 {
1394 fprintf( stdout, "Writing BLIF has failed.\n" );
1395 return;
1396 }
1397 if ( pLutStruct && fUseHie )
1398 Io_WriteBlifInt( pNtkTemp, FileName, pLutStruct, 1 );
1399 else
1400 Io_WriteBlifInt( pNtkTemp, FileName, pLutStruct, 0 );
1401 Abc_NtkDelete( pNtkTemp );
1402}
void Io_WriteBlifInt(Abc_Ntk_t *pNtk, char *FileName, char *pLutStruct, int fUseHie)
Here is the call graph for this function:

◆ Io_WriteBook()

void Io_WriteBook ( Abc_Ntk_t * pNtk,
char * FileName )
extern

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

Synopsis [Write the network into a BOOK file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file ioWriteBook.c.

101{
102
103 FILE * pFileNodes, * pFileNets, * pFileAux;
104 FILE * pFileScl, * pFilePl, * pFileWts;
105 char * FileExt = ABC_CALLOC( char, strlen(FileName)+7 );
106 unsigned coreCellArea=0;
107 Abc_Ntk_t * pExdc, * pNtkTemp;
108 int i;
109
110 assert( Abc_NtkIsNetlist(pNtk) );
111 // start writing the files
112 strcpy(FileExt, FileName);
113 pFileNodes = fopen( strcat(FileExt,".nodes"), "w" );
114 strcpy(FileExt, FileName);
115 pFileNets = fopen( strcat(FileExt,".nets"), "w" );
116 strcpy(FileExt, FileName);
117 pFileAux = fopen( strcat(FileExt,".aux"), "w" );
118
119 // write the aux file
120 if ( (pFileNodes == NULL) || (pFileNets == NULL) || (pFileAux == NULL) )
121 {
122 fclose( pFileAux );
123 fprintf( stdout, "Io_WriteBook(): Cannot open the output files.\n" );
124 return;
125 }
126 fprintf( pFileAux, "RowBasedPlacement : %s.nodes %s.nets %s.scl %s.pl %s.wts",
127 FileName, FileName, FileName, FileName, FileName );
128 fclose( pFileAux );
129
130 // write the master network
131 coreCellArea+=Io_NtkWriteNodes( pFileNodes, pNtk );
132 Io_NtkWriteNets( pFileNets, pNtk );
133
134 // write EXDC network if it exists
135 pExdc = Abc_NtkExdc( pNtk );
136 if ( pExdc )
137 {
138 coreCellArea+=Io_NtkWriteNodes( pFileNodes, pNtk );
139 Io_NtkWriteNets( pFileNets, pNtk );
140 }
141
142 // make sure there is no logic hierarchy
143 assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
144
145 // write the hierarchy if present
146 if ( Abc_NtkBlackboxNum(pNtk) > 0 )
147 {
148 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
149 {
150 if ( pNtkTemp == pNtk )
151 continue;
152 coreCellArea+=Io_NtkWriteNodes( pFileNodes, pNtkTemp );
153 Io_NtkWriteNets( pFileNets, pNtkTemp );
154 }
155 }
156 fclose( pFileNodes );
157 fclose( pFileNets );
158
159 strcpy(FileExt, FileName);
160 pFileScl = fopen( strcat(FileExt,".scl"), "w" );
161 strcpy(FileExt, FileName);
162 pFilePl = fopen( strcat(FileExt,".pl"), "w" );
163 strcpy(FileExt, FileName);
164 pFileWts = fopen( strcat(FileExt,".wts"), "w" );
165 ABC_FREE(FileExt);
166
167 Io_NtkBuildLayout( pFileScl, pFilePl, pNtk, 1.0, 10, coreCellArea );
168 fclose( pFileScl );
169 fclose( pFilePl );
170 fclose( pFileWts );
171}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
char * strcpy()
char * strcat()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteCnf()

int Io_WriteCnf ( Abc_Ntk_t * pNtk,
char * pFileName,
int fAllPrimes )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Write the miter cone into a CNF file for the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file ioWriteCnf.c.

49{
50 sat_solver * pSat;
51 if ( Abc_NtkIsStrash(pNtk) )
52 printf( "Io_WriteCnf() warning: Generating CNF by applying heuristic AIG to CNF conversion.\n" );
53 else
54 printf( "Io_WriteCnf() warning: Generating CNF by convering logic nodes into CNF clauses.\n" );
55 if ( Abc_NtkPoNum(pNtk) != 1 )
56 {
57 fprintf( stdout, "Io_WriteCnf(): Currently can only process the miter (the network with one PO).\n" );
58 return 0;
59 }
60 if ( Abc_NtkLatchNum(pNtk) != 0 )
61 {
62 fprintf( stdout, "Io_WriteCnf(): Currently can only process the miter for combinational circuits.\n" );
63 return 0;
64 }
65 if ( Abc_NtkNodeNum(pNtk) == 0 )
66 {
67 fprintf( stdout, "The network has no logic nodes. No CNF file is generaled.\n" );
68 return 0;
69 }
70 // convert to logic BDD network
71 if ( Abc_NtkIsLogic(pNtk) )
72 Abc_NtkToBdd( pNtk );
73 // create solver with clauses
74 pSat = (sat_solver *)Abc_NtkMiterSatCreate( pNtk, fAllPrimes );
75 if ( pSat == NULL )
76 {
77 fprintf( stdout, "The problem is trivially UNSAT. No CNF file is generated.\n" );
78 return 1;
79 }
80 // write the clauses
81 s_pNtk = pNtk;
82 Sat_SolverWriteDimacs( pSat, pFileName, 0, 0, 1 );
83 s_pNtk = NULL;
84 // free the solver
85 sat_solver_delete( pSat );
86 return 1;
87}
ABC_DLL void * Abc_NtkMiterSatCreate(Abc_Ntk_t *pNtk, int fAllPrimes)
Definition abcSat.c:664
ABC_DLL int Abc_NtkToBdd(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1299
#define sat_solver
Definition cecSatG2.c:34
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
void Sat_SolverWriteDimacs(sat_solver *p, char *pFileName, lit *assumptionsBegin, lit *assumptionsEnd, int incrementVars)
Definition satUtil.c:74
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteDot()

void Io_WriteDot ( Abc_Ntk_t * pNtk,
char * FileName )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes the graph structure of network for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 51 of file ioWriteDot.c.

52{
53 Vec_Ptr_t * vNodes;
54 vNodes = Abc_NtkCollectObjects( pNtk );
55 Io_WriteDotNtk( pNtk, vNodes, NULL, FileName, 0, 0, 0 );
56 Vec_PtrFree( vNodes );
57}
ABC_DLL Vec_Ptr_t * Abc_NtkCollectObjects(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1765
void Io_WriteDotNtk(Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse, int fAigIds)
Definition ioWriteDot.c:71
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteDotNtk()

void Io_WriteDotNtk ( Abc_Ntk_t * pNtk,
Vec_Ptr_t * vNodes,
Vec_Ptr_t * vNodesShow,
char * pFileName,
int fGateNames,
int fUseReverse,
int fAigIds )
extern

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

Synopsis [Writes the graph structure of network for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 71 of file ioWriteDot.c.

72{
73 FILE * pFile;
74 Abc_Obj_t * pNode, * pFanin;
75 char * pSopString, SopString[32];
76 int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl, Prev, AigNodeId;
77 int Limit = 500;
78
79 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
80
81 if ( vNodes->nSize < 1 )
82 {
83 printf( "The set has no nodes. DOT file is not written.\n" );
84 return;
85 }
86
87 if ( vNodes->nSize > Limit )
88 {
89 printf( "The set has more than %d nodes. DOT file is not written.\n", Limit );
90 return;
91 }
92
93 // start the stream
94 if ( (pFile = fopen( pFileName, "w" )) == NULL )
95 {
96 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", pFileName );
97 return;
98 }
99
100 // transform logic functions from BDD to SOP
101 if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) )
102 {
103 if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
104 {
105 printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" );
106 return;
107 }
108 }
109
110 // mark the nodes from the set
111 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
112 pNode->fMarkC = 1;
113 if ( vNodesShow )
114 Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
115 pNode->fMarkB = 1;
116
117 // get the levels of nodes
118 LevelMax = Abc_NtkLevel( pNtk );
119 if ( fUseReverse )
120 {
121 LevelMin = Abc_NtkLevelReverse( pNtk );
122 assert( LevelMax == LevelMin );
123 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
124 if ( Abc_ObjIsNode(pNode) )
125 pNode->Level = LevelMax - pNode->Level + 1;
126 }
127
128 // find the largest and the smallest levels
129 LevelMin = 10000;
130 LevelMax = -1;
131 fHasCos = 0;
132 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
133 {
134 if ( Abc_ObjIsCo(pNode) )
135 {
136 fHasCos = 1;
137 continue;
138 }
139 if ( LevelMin > (int)pNode->Level )
140 LevelMin = pNode->Level;
141 if ( LevelMax < (int)pNode->Level )
142 LevelMax = pNode->Level;
143 }
144
145 // set the level of the CO nodes
146 if ( fHasCos )
147 {
148 LevelMax++;
149 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
150 {
151 if ( Abc_ObjIsCo(pNode) )
152 pNode->Level = LevelMax;
153 }
154 }
155
156 // write the DOT header
157 fprintf( pFile, "# %s\n", "Network structure generated by ABC" );
158 fprintf( pFile, "\n" );
159 fprintf( pFile, "digraph network {\n" );
160 fprintf( pFile, "size = \"7.5,10\";\n" );
161// fprintf( pFile, "size = \"10,8.5\";\n" );
162// fprintf( pFile, "size = \"14,11\";\n" );
163// fprintf( pFile, "page = \"8,11\";\n" );
164// fprintf( pFile, "ranksep = 0.5;\n" );
165// fprintf( pFile, "nodesep = 0.5;\n" );
166 fprintf( pFile, "center = true;\n" );
167// fprintf( pFile, "orientation = landscape;\n" );
168// fprintf( pFile, "edge [fontsize = 10];\n" );
169// fprintf( pFile, "edge [dir = none];\n" );
170 fprintf( pFile, "edge [dir = back];\n" );
171 fprintf( pFile, "\n" );
172
173 // labels on the left of the picture
174 fprintf( pFile, "{\n" );
175 fprintf( pFile, " node [shape = plaintext];\n" );
176 fprintf( pFile, " edge [style = invis];\n" );
177 fprintf( pFile, " LevelTitle1 [label=\"\"];\n" );
178 fprintf( pFile, " LevelTitle2 [label=\"\"];\n" );
179 // generate node names with labels
180 for ( Level = LevelMax; Level >= LevelMin; Level-- )
181 {
182 // the visible node name
183 fprintf( pFile, " Level%d", Level );
184 fprintf( pFile, " [label = " );
185 // label name
186 fprintf( pFile, "\"" );
187 fprintf( pFile, "\"" );
188 fprintf( pFile, "];\n" );
189 }
190
191 // genetate the sequence of visible/invisible nodes to mark levels
192 fprintf( pFile, " LevelTitle1 -> LevelTitle2 ->" );
193 for ( Level = LevelMax; Level >= LevelMin; Level-- )
194 {
195 // the visible node name
196 fprintf( pFile, " Level%d", Level );
197 // the connector
198 if ( Level != LevelMin )
199 fprintf( pFile, " ->" );
200 else
201 fprintf( pFile, ";" );
202 }
203 fprintf( pFile, "\n" );
204 fprintf( pFile, "}" );
205 fprintf( pFile, "\n" );
206 fprintf( pFile, "\n" );
207
208 // generate title box on top
209 fprintf( pFile, "{\n" );
210 fprintf( pFile, " rank = same;\n" );
211 fprintf( pFile, " LevelTitle1;\n" );
212 fprintf( pFile, " title1 [shape=plaintext,\n" );
213 fprintf( pFile, " fontsize=20,\n" );
214 fprintf( pFile, " fontname = \"Times-Roman\",\n" );
215 fprintf( pFile, " label=\"" );
216 fprintf( pFile, "%s", "Network structure visualized by ABC" );
217 fprintf( pFile, "\\n" );
218 fprintf( pFile, "Benchmark \\\"%s\\\". ", pNtk->pName );
219 fprintf( pFile, "Time was %s. ", Extra_TimeStamp() );
220 fprintf( pFile, "\"\n" );
221 fprintf( pFile, " ];\n" );
222 fprintf( pFile, "}" );
223 fprintf( pFile, "\n" );
224 fprintf( pFile, "\n" );
225
226 // generate statistics box
227 fprintf( pFile, "{\n" );
228 fprintf( pFile, " rank = same;\n" );
229 fprintf( pFile, " LevelTitle2;\n" );
230 fprintf( pFile, " title2 [shape=plaintext,\n" );
231 fprintf( pFile, " fontsize=18,\n" );
232 fprintf( pFile, " fontname = \"Times-Roman\",\n" );
233 fprintf( pFile, " label=\"" );
234 if ( Abc_NtkObjNum(pNtk) == Vec_PtrSize(vNodes) )
235 fprintf( pFile, "The network contains %d logic nodes and %d latches.", Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk) );
236 else
237 fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
238 fprintf( pFile, "\\n" );
239 fprintf( pFile, "\"\n" );
240 fprintf( pFile, " ];\n" );
241 fprintf( pFile, "}" );
242 fprintf( pFile, "\n" );
243 fprintf( pFile, "\n" );
244
245 // generate the POs
246 if ( fHasCos )
247 {
248 fprintf( pFile, "{\n" );
249 fprintf( pFile, " rank = same;\n" );
250 // the labeling node of this level
251 fprintf( pFile, " Level%d;\n", LevelMax );
252 // generate the PO nodes
253 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
254 {
255 if ( !Abc_ObjIsCo(pNode) )
256 continue;
257 fprintf( pFile, " Node%d [label = \"%s%s\"",
258 pNode->Id,
259 (Abc_ObjIsBi(pNode)? Abc_ObjName(Abc_ObjFanout0(pNode)):Abc_ObjName(pNode)),
260 (Abc_ObjIsBi(pNode)? "_in":"") );
261 fprintf( pFile, ", shape = %s", (Abc_ObjIsBi(pNode)? "box":"invtriangle") );
262 if ( pNode->fMarkB )
263 fprintf( pFile, ", style = filled" );
264 fprintf( pFile, ", color = coral, fillcolor = coral" );
265 fprintf( pFile, "];\n" );
266 }
267 fprintf( pFile, "}" );
268 fprintf( pFile, "\n" );
269 fprintf( pFile, "\n" );
270 }
271
272 // generate nodes of each rank
273 for ( Level = LevelMax - fHasCos; Level >= LevelMin && Level > 0; Level-- )
274 {
275 fprintf( pFile, "{\n" );
276 fprintf( pFile, " rank = same;\n" );
277 // the labeling node of this level
278 fprintf( pFile, " Level%d;\n", Level );
279 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
280 {
281 if ( (int)pNode->Level != Level )
282 continue;
283 if ( Abc_ObjFaninNum(pNode) == 0 )
284 continue;
285
286/*
287 int SuppSize;
288 Vec_Ptr_t * vSupp;
289 if ( (int)pNode->Level != Level )
290 continue;
291 if ( Abc_ObjFaninNum(pNode) == 0 )
292 continue;
293 vSupp = Abc_NtkNodeSupport( pNtk, &pNode, 1 );
294 SuppSize = Vec_PtrSize( vSupp );
295 Vec_PtrFree( vSupp );
296*/
297
298// fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
299 if ( Abc_NtkIsStrash(pNtk) )
300 pSopString = "";
301 else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
302 pSopString = Mio_GateReadName((Mio_Gate_t *)pNode->pData);
303 else if ( Abc_NtkHasMapping(pNtk) )
304 pSopString = Abc_NtkPrintSop(Mio_GateReadSop((Mio_Gate_t *)pNode->pData));
305 else {
306 int nCubes = Abc_SopGetCubeNum((char *)pNode->pData);
307 if ( nCubes <= 16 )
308 pSopString = Abc_NtkPrintSop((char *)pNode->pData);
309 else {
310 sprintf( SopString, "%d cubes", nCubes );
311 pSopString = SopString;
312 }
313 }
314 //if ( pNtk->vOrigNodeIds )
315 // printf( "%d = %d \n", pNode->Id, Vec_IntEntry(pNtk->vOrigNodeIds, pNode->Id) )
316 AigNodeId = (fAigIds && pNtk->vOrigNodeIds) ? Vec_IntEntry(pNtk->vOrigNodeIds, pNode->Id) : -1;
317 if ( AigNodeId > 0 )
318 fprintf( pFile, " Node%d [label = \"%s%d\\n%s\"", pNode->Id, Abc_LitIsCompl(AigNodeId) ? "-":"+", Abc_Lit2Var(AigNodeId), pSopString );
319 else
320 fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id+1, pSopString );
321// fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id,
322// SuppSize,
323// pSopString );
324
325 fprintf( pFile, ", shape = ellipse" );
326 if ( pNode->fMarkB )
327 fprintf( pFile, ", style = filled" );
328 fprintf( pFile, "];\n" );
329 }
330 fprintf( pFile, "}" );
331 fprintf( pFile, "\n" );
332 fprintf( pFile, "\n" );
333 }
334
335 // generate the PI nodes if any
336 if ( LevelMin == 0 )
337 {
338 fprintf( pFile, "{\n" );
339 fprintf( pFile, " rank = same;\n" );
340 // the labeling node of this level
341 fprintf( pFile, " Level%d;\n", LevelMin );
342 // generate the PO nodes
343 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
344 {
345 if ( !Abc_ObjIsCi(pNode) )
346 {
347 // check if the costant node is present
348 if ( Abc_ObjFaninNum(pNode) == 0 && Abc_ObjFanoutNum(pNode) > 0 )
349 {
350 fprintf( pFile, " Node%d [label = \"Const%d\"", pNode->Id, Abc_NtkIsStrash(pNode->pNtk) || Abc_NodeIsConst1(pNode) );
351 fprintf( pFile, ", shape = ellipse" );
352 if ( pNode->fMarkB )
353 fprintf( pFile, ", style = filled" );
354 fprintf( pFile, ", color = coral, fillcolor = coral" );
355 fprintf( pFile, "];\n" );
356 }
357 continue;
358 }
359 fprintf( pFile, " Node%d [label = \"%s\"",
360 pNode->Id,
361 (Abc_ObjIsBo(pNode)? Abc_ObjName(Abc_ObjFanin0(pNode)):Abc_ObjName(pNode)) );
362 fprintf( pFile, ", shape = %s", (Abc_ObjIsBo(pNode)? "box":"triangle") );
363 if ( pNode->fMarkB )
364 fprintf( pFile, ", style = filled" );
365 fprintf( pFile, ", color = coral, fillcolor = coral" );
366 fprintf( pFile, "];\n" );
367 }
368 fprintf( pFile, "}" );
369 fprintf( pFile, "\n" );
370 fprintf( pFile, "\n" );
371 }
372
373 // generate invisible edges from the square down
374 fprintf( pFile, "title1 -> title2 [style = invis];\n" );
375 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
376 {
377 if ( (int)pNode->Level != LevelMax )
378 continue;
379 fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
380 }
381 // generate invisible edges among the COs
382 Prev = -1;
383 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
384 {
385 if ( (int)pNode->Level != LevelMax )
386 continue;
387 if ( !Abc_ObjIsPo(pNode) )
388 continue;
389 if ( Prev >= 0 )
390 fprintf( pFile, "Node%d -> Node%d [style = invis];\n", Prev, pNode->Id );
391 Prev = pNode->Id;
392 }
393
394 // generate edges
395 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
396 {
397 if ( Abc_ObjIsLatch(pNode) )
398 continue;
399 Abc_ObjForEachFanin( pNode, pFanin, k )
400 {
401 if ( Abc_ObjIsLatch(pFanin) )
402 continue;
403 fCompl = 0;
404 if ( Abc_NtkIsStrash(pNtk) )
405 fCompl = Abc_ObjFaninC(pNode, k);
406 // generate the edge from this node to the next
407 fprintf( pFile, "Node%d", pNode->Id );
408 fprintf( pFile, " -> " );
409 fprintf( pFile, "Node%d", pFanin->Id );
410 fprintf( pFile, " [style = %s", fCompl? "dotted" : "solid" );
411// fprintf( pFile, ", label = \"%c\"", 'a' + k );
412 fprintf( pFile, "]" );
413 fprintf( pFile, ";\n" );
414 }
415 }
416
417 fprintf( pFile, "}" );
418 fprintf( pFile, "\n" );
419 fprintf( pFile, "\n" );
420 fclose( pFile );
421
422 // unmark the nodes from the set
423 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
424 pNode->fMarkC = 0;
425 if ( vNodesShow )
426 Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
427 pNode->fMarkB = 0;
428
429 // convert the network back into BDDs if this is how it was
430 if ( fHasBdds )
431 Abc_NtkSopToBdd(pNtk);
432}
void Abc_NtkPrintSop(FILE *pFile, Abc_Ntk_t *pNtk, int fUseRealNames)
Definition abcPrint.c:1200
ABC_DLL int Abc_NtkSopToBdd(Abc_Ntk_t *pNtk)
Definition abcFunc.c:865
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL int Abc_NtkLevelReverse(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1499
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit, int fCubeSort)
Definition abcFunc.c:866
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
Definition abcObj.c:916
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition mioApi.c:179
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition mioApi.c:169
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
Vec_Int_t * vOrigNodeIds
Definition abc.h:217
void * pData
Definition abc.h:145
unsigned fMarkC
Definition abc.h:136
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
unsigned fMarkB
Definition abc.h:135
unsigned Level
Definition abc.h:142
char * sprintf()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteDotSeq()

void Io_WriteDotSeq ( Abc_Ntk_t * pNtk,
Vec_Ptr_t * vNodes,
Vec_Ptr_t * vNodesShow,
char * pFileName,
int fGateNames,
int fUseReverse )
extern

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

Synopsis [Writes the graph structure of network for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 447 of file ioWriteDot.c.

448{
449 FILE * pFile;
450 Abc_Obj_t * pNode, * pFanin;
451 char * pSopString;
452 int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl, Prev;
453 int Limit = 300;
454
455 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
456
457 if ( vNodes->nSize < 1 )
458 {
459 printf( "The set has no nodes. DOT file is not written.\n" );
460 return;
461 }
462
463 if ( vNodes->nSize > Limit )
464 {
465 printf( "The set has more than %d nodes. DOT file is not written.\n", Limit );
466 return;
467 }
468
469 // start the stream
470 if ( (pFile = fopen( pFileName, "w" )) == NULL )
471 {
472 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", pFileName );
473 return;
474 }
475
476 // transform logic functions from BDD to SOP
477 if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) )
478 {
479 if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
480 {
481 printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" );
482 return;
483 }
484 }
485
486 // mark the nodes from the set
487 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
488 pNode->fMarkC = 1;
489 if ( vNodesShow )
490 Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
491 pNode->fMarkB = 1;
492
493 // get the levels of nodes
494 LevelMax = Abc_NtkLevel( pNtk );
495 if ( fUseReverse )
496 {
497 LevelMin = Abc_NtkLevelReverse( pNtk );
498 assert( LevelMax == LevelMin );
499 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
500 if ( Abc_ObjIsNode(pNode) )
501 pNode->Level = LevelMax - pNode->Level + 1;
502 }
503
504 // find the largest and the smallest levels
505 LevelMin = 10000;
506 LevelMax = -1;
507 fHasCos = 0;
508 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
509 {
510 if ( Abc_ObjIsCo(pNode) )
511 {
512 fHasCos = 1;
513 continue;
514 }
515 if ( LevelMin > (int)pNode->Level )
516 LevelMin = pNode->Level;
517 if ( LevelMax < (int)pNode->Level )
518 LevelMax = pNode->Level;
519 }
520
521 // set the level of the CO nodes
522 if ( fHasCos )
523 {
524 LevelMax++;
525 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
526 {
527 if ( Abc_ObjIsCo(pNode) )
528 pNode->Level = LevelMax;
529 }
530 }
531
532 // write the DOT header
533 fprintf( pFile, "# %s\n", "Network structure generated by ABC" );
534 fprintf( pFile, "\n" );
535 fprintf( pFile, "digraph network {\n" );
536 fprintf( pFile, "size = \"7.5,10\";\n" );
537// fprintf( pFile, "size = \"10,8.5\";\n" );
538// fprintf( pFile, "size = \"14,11\";\n" );
539// fprintf( pFile, "page = \"8,11\";\n" );
540// fprintf( pFile, "ranksep = 0.5;\n" );
541// fprintf( pFile, "nodesep = 0.5;\n" );
542 fprintf( pFile, "center = true;\n" );
543// fprintf( pFile, "orientation = landscape;\n" );
544// fprintf( pFile, "edge [fontsize = 10];\n" );
545// fprintf( pFile, "edge [dir = none];\n" );
546 fprintf( pFile, "edge [dir = back];\n" );
547 fprintf( pFile, "\n" );
548
549 // labels on the left of the picture
550 fprintf( pFile, "{\n" );
551 fprintf( pFile, " node [shape = plaintext];\n" );
552 fprintf( pFile, " edge [style = invis];\n" );
553 fprintf( pFile, " LevelTitle1 [label=\"\"];\n" );
554 fprintf( pFile, " LevelTitle2 [label=\"\"];\n" );
555 // generate node names with labels
556 for ( Level = LevelMax; Level >= LevelMin; Level-- )
557 {
558 // the visible node name
559 fprintf( pFile, " Level%d", Level );
560 fprintf( pFile, " [label = " );
561 // label name
562 fprintf( pFile, "\"" );
563 fprintf( pFile, "\"" );
564 fprintf( pFile, "];\n" );
565 }
566
567 // genetate the sequence of visible/invisible nodes to mark levels
568 fprintf( pFile, " LevelTitle1 -> LevelTitle2 ->" );
569 for ( Level = LevelMax; Level >= LevelMin; Level-- )
570 {
571 // the visible node name
572 fprintf( pFile, " Level%d", Level );
573 // the connector
574 if ( Level != LevelMin )
575 fprintf( pFile, " ->" );
576 else
577 fprintf( pFile, ";" );
578 }
579 fprintf( pFile, "\n" );
580 fprintf( pFile, "}" );
581 fprintf( pFile, "\n" );
582 fprintf( pFile, "\n" );
583
584 // generate title box on top
585 fprintf( pFile, "{\n" );
586 fprintf( pFile, " rank = same;\n" );
587 fprintf( pFile, " LevelTitle1;\n" );
588 fprintf( pFile, " title1 [shape=plaintext,\n" );
589 fprintf( pFile, " fontsize=20,\n" );
590 fprintf( pFile, " fontname = \"Times-Roman\",\n" );
591 fprintf( pFile, " label=\"" );
592 fprintf( pFile, "%s", "Network structure visualized by ABC" );
593 fprintf( pFile, "\\n" );
594 fprintf( pFile, "Benchmark \\\"%s\\\". ", pNtk->pName );
595 fprintf( pFile, "Time was %s. ", Extra_TimeStamp() );
596 fprintf( pFile, "\"\n" );
597 fprintf( pFile, " ];\n" );
598 fprintf( pFile, "}" );
599 fprintf( pFile, "\n" );
600 fprintf( pFile, "\n" );
601
602 // generate statistics box
603 fprintf( pFile, "{\n" );
604 fprintf( pFile, " rank = same;\n" );
605 fprintf( pFile, " LevelTitle2;\n" );
606 fprintf( pFile, " title2 [shape=plaintext,\n" );
607 fprintf( pFile, " fontsize=18,\n" );
608 fprintf( pFile, " fontname = \"Times-Roman\",\n" );
609 fprintf( pFile, " label=\"" );
610 if ( Abc_NtkObjNum(pNtk) == Vec_PtrSize(vNodes) )
611 fprintf( pFile, "The network contains %d logic nodes and %d latches.", Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk) );
612 else
613 fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
614 fprintf( pFile, "\\n" );
615 fprintf( pFile, "\"\n" );
616 fprintf( pFile, " ];\n" );
617 fprintf( pFile, "}" );
618 fprintf( pFile, "\n" );
619 fprintf( pFile, "\n" );
620
621 // generate the POs
622 if ( fHasCos )
623 {
624 fprintf( pFile, "{\n" );
625 fprintf( pFile, " rank = same;\n" );
626 // the labeling node of this level
627 fprintf( pFile, " Level%d;\n", LevelMax );
628 // generate the PO nodes
629 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
630 {
631 if ( !Abc_ObjIsPo(pNode) )
632 continue;
633 fprintf( pFile, " Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
634 fprintf( pFile, ", shape = %s", "invtriangle" );
635 if ( pNode->fMarkB )
636 fprintf( pFile, ", style = filled" );
637 fprintf( pFile, ", color = coral, fillcolor = coral" );
638 fprintf( pFile, "];\n" );
639 }
640 fprintf( pFile, "}" );
641 fprintf( pFile, "\n" );
642 fprintf( pFile, "\n" );
643 }
644
645 // generate nodes of each rank
646 for ( Level = LevelMax - fHasCos; Level >= LevelMin && Level > 0; Level-- )
647 {
648 fprintf( pFile, "{\n" );
649 fprintf( pFile, " rank = same;\n" );
650 // the labeling node of this level
651 fprintf( pFile, " Level%d;\n", Level );
652 Abc_NtkForEachNode( pNtk, pNode, i )
653 {
654 if ( (int)pNode->Level != Level )
655 continue;
656// fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
657 if ( Abc_NtkIsStrash(pNtk) )
658 pSopString = "";
659 else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
660 pSopString = Mio_GateReadName((Mio_Gate_t *)pNode->pData);
661 else if ( Abc_NtkHasMapping(pNtk) )
662 pSopString = Abc_NtkPrintSop(Mio_GateReadSop((Mio_Gate_t *)pNode->pData));
663 else
664 pSopString = Abc_NtkPrintSop((char *)pNode->pData);
665 fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
666
667 fprintf( pFile, ", shape = ellipse" );
668 if ( pNode->fMarkB )
669 fprintf( pFile, ", style = filled" );
670 fprintf( pFile, "];\n" );
671 }
672 fprintf( pFile, "}" );
673 fprintf( pFile, "\n" );
674 fprintf( pFile, "\n" );
675 }
676
677 // generate the PI nodes if any
678 if ( LevelMin == 0 )
679 {
680 fprintf( pFile, "{\n" );
681 fprintf( pFile, " rank = same;\n" );
682 // the labeling node of this level
683 fprintf( pFile, " Level%d;\n", LevelMin );
684 // generate the PO nodes
685 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
686 {
687 if ( pNode->Level > 0 )
688 continue;
689 if ( !Abc_ObjIsPi(pNode) )
690 {
691 // check if the costant node is present
692 if ( Abc_ObjFaninNum(pNode) == 0 && Abc_ObjFanoutNum(pNode) > 0 )
693 {
694 fprintf( pFile, " Node%d [label = \"Const1\"", pNode->Id );
695 fprintf( pFile, ", shape = ellipse" );
696 if ( pNode->fMarkB )
697 fprintf( pFile, ", style = filled" );
698 fprintf( pFile, ", color = coral, fillcolor = coral" );
699 fprintf( pFile, "];\n" );
700 }
701 continue;
702 }
703 fprintf( pFile, " Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
704 fprintf( pFile, ", shape = %s", "triangle" );
705 if ( pNode->fMarkB )
706 fprintf( pFile, ", style = filled" );
707 fprintf( pFile, ", color = coral, fillcolor = coral" );
708 fprintf( pFile, "];\n" );
709 }
710 fprintf( pFile, "}" );
711 fprintf( pFile, "\n" );
712 fprintf( pFile, "\n" );
713 }
714
715// fprintf( pFile, "{\n" );
716 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
717 {
718 if ( !Abc_ObjIsLatch(pNode) )
719 continue;
720 fprintf( pFile, "Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
721 fprintf( pFile, ", shape = box" );
722 if ( pNode->fMarkB )
723 fprintf( pFile, ", style = filled" );
724 fprintf( pFile, ", color = coral, fillcolor = coral" );
725 fprintf( pFile, "];\n" );
726 }
727// fprintf( pFile, "}" );
728// fprintf( pFile, "\n" );
729 fprintf( pFile, "\n" );
730
731 // generate invisible edges from the square down
732 fprintf( pFile, "title1 -> title2 [style = invis];\n" );
733 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
734 {
735 if ( (int)pNode->Level != LevelMax )
736 continue;
737 if ( !Abc_ObjIsPo(pNode) )
738 continue;
739 fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
740 }
741 // generate invisible edges among the COs
742 Prev = -1;
743 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
744 {
745 if ( (int)pNode->Level != LevelMax )
746 continue;
747 if ( !Abc_ObjIsPo(pNode) )
748 continue;
749 if ( Prev >= 0 )
750 fprintf( pFile, "Node%d -> Node%d [style = invis];\n", Prev, pNode->Id );
751 Prev = pNode->Id;
752 }
753
754 // generate edges
755 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
756 {
757 if ( Abc_ObjIsBi(pNode) || Abc_ObjIsBo(pNode) )
758 continue;
759 Abc_ObjForEachFanin( pNode, pFanin, k )
760 {
761 fCompl = 0;
762 if ( Abc_NtkIsStrash(pNtk) )
763 {
764 if ( Abc_ObjIsBi(pFanin) )
765 fCompl = Abc_ObjFaninC(pFanin, k);
766 else
767 fCompl = Abc_ObjFaninC(pNode, k);
768 }
769 if ( Abc_ObjIsBi(pFanin) || Abc_ObjIsBo(pFanin) )
770 pFanin = Abc_ObjFanin0(pFanin);
771 if ( Abc_ObjIsBi(pFanin) || Abc_ObjIsBo(pFanin) )
772 pFanin = Abc_ObjFanin0(pFanin);
773 if ( !pFanin->fMarkC )
774 continue;
775
776 // generate the edge from this node to the next
777 fprintf( pFile, "Node%d", pNode->Id );
778 fprintf( pFile, " -> " );
779 fprintf( pFile, "Node%d", pFanin->Id );
780 fprintf( pFile, " [style = %s", fCompl? "dotted" : "solid" );
781// fprintf( pFile, ", label = \"%c\"", 'a' + k );
782 fprintf( pFile, "]" );
783 fprintf( pFile, ";\n" );
784 }
785 }
786
787 fprintf( pFile, "}" );
788 fprintf( pFile, "\n" );
789 fprintf( pFile, "\n" );
790 fclose( pFile );
791
792 // unmark the nodes from the set
793 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
794 pNode->fMarkC = 0;
795 if ( vNodesShow )
796 Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
797 pNode->fMarkB = 0;
798
799 // convert the network back into BDDs if this is how it was
800 if ( fHasBdds )
801 Abc_NtkSopToBdd(pNtk);
802}
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteEdgelist()

void Io_WriteEdgelist ( Abc_Ntk_t * pNtk,
char * FileName,
int fWriteLatches,
int fBb2Wb,
int fSeq,
int fName )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Write the network into a Edgelist file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file ioWriteEdgelist.c.

60{
61 FILE * pFile; int i;
62 // start writing the file
63 pFile = fopen( FileName, "w" );
64 if ( pFile == NULL )
65 {
66 fprintf( stdout, "Io_WriteEdgelist(): Cannot open the output file.\n" );
67 return;
68 }
69 fprintf( stdout, "WriteEdgelist (Verilog-to-PyG @ https://github.com/ycunxi/Verilog-to-PyG) starts writing to %s.\n", FileName );
70 fprintf( pFile, "# Benchmark Edgelist Dumping (beta) \"%s\" written by ABC on %s (more at https://github.com/ycunxi/Verilog-to-PyG)\n", pNtk->pName, Extra_TimeStamp() );
71 // write the master network
72 Io_NtkEdgelistWrite( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq , fName);
73 // make sure there is no logic hierarchy
74// assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
75 // write the hierarchy if present
76 if ( Abc_NtkBlackboxNum(pNtk) > 0 || Abc_NtkWhiteboxNum(pNtk) > 0 )
77 {
78 Abc_Ntk_t * pNtkTemp;
79 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
80 {
81 if ( pNtkTemp == pNtk )
82 continue;
83 fprintf( pFile, "\n\n" );
84 Io_NtkEdgelistWrite( pFile, pNtkTemp, fWriteLatches, fBb2Wb, fSeq, fName);
85 }
86 }
87 fclose( pFile );
88}
Here is the call graph for this function:

◆ Io_WriteEqn()

void Io_WriteEqn ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes the logic network in the equation format.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file ioWriteEqn.c.

51{
52 FILE * pFile;
53
54 assert( Abc_NtkIsAigNetlist(pNtk) );
55 if ( Abc_NtkLatchNum(pNtk) > 0 )
56 printf( "Warning: only combinational portion is being written.\n" );
57
58 // check that the names are fine for the EQN format
59 if ( !Io_NtkWriteEqnCheck(pNtk) )
60 return;
61
62 // start the output stream
63 pFile = fopen( pFileName, "w" );
64 if ( pFile == NULL )
65 {
66 fprintf( stdout, "Io_WriteEqn(): Cannot open the output file \"%s\".\n", pFileName );
67 return;
68 }
69 fprintf( pFile, "# Equations for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
70
71 // write the equations for the network
72 Io_NtkWriteEqnOne( pFile, pNtk );
73 fprintf( pFile, "\n" );
74 fclose( pFile );
75}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteGml()

void Io_WriteGml ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

DECLARATIONS ///.

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

FileName [ioWriteGml.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

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

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Writes the graph structure of AIG in GML.]

Description [Useful for graph visualization using tools such as yEd: http://www.yworks.com/]

SideEffects []

SeeAlso []

Definition at line 46 of file ioWriteGml.c.

47{
48 FILE * pFile;
49 Abc_Obj_t * pObj, * pFanin;
50 int i, k;
51
52 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
53
54 // start the output stream
55 pFile = fopen( pFileName, "w" );
56 if ( pFile == NULL )
57 {
58 fprintf( stdout, "Io_WriteGml(): Cannot open the output file \"%s\".\n", pFileName );
59 return;
60 }
61 fprintf( pFile, "# GML for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
62 fprintf( pFile, "graph [\n" );
63
64 // output constant node in the AIG if it has fanouts
65 if ( Abc_NtkIsStrash(pNtk) )
66 {
67 pObj = Abc_AigConst1( pNtk );
68 if ( Abc_ObjFanoutNum(pObj) > 0 )
69 {
70 fprintf( pFile, "\n" );
71 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
72 fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
73 fprintf( pFile, " ]\n" );
74 }
75 }
76 // output the POs
77 fprintf( pFile, "\n" );
78 Abc_NtkForEachPo( pNtk, pObj, i )
79 {
80 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
81 fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" ); // blue
82 fprintf( pFile, " ]\n" );
83 }
84 // output the PIs
85 fprintf( pFile, "\n" );
86 Abc_NtkForEachPi( pNtk, pObj, i )
87 {
88 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
89 fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FF00\" ]\n" ); // green
90 fprintf( pFile, " ]\n" );
91 }
92 // output the latches
93 fprintf( pFile, "\n" );
94 Abc_NtkForEachLatch( pNtk, pObj, i )
95 {
96 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
97 fprintf( pFile, " graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" ); // red
98 fprintf( pFile, " ]\n" );
99 }
100 // output the nodes
101 fprintf( pFile, "\n" );
102 Abc_NtkForEachNode( pNtk, pObj, i )
103 {
104 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
105 fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
106 fprintf( pFile, " ]\n" );
107 }
108
109 // output the edges
110 fprintf( pFile, "\n" );
111 Abc_NtkForEachObj( pNtk, pObj, i )
112 {
113 Abc_ObjForEachFanin( pObj, pFanin, k )
114 {
115 fprintf( pFile, " edge [ source %5d target %5d\n", pObj->Id, pFanin->Id );
116 fprintf( pFile, " graphics [ type \"line\" arrow \"first\" ]\n" );
117 fprintf( pFile, " ]\n" );
118 }
119 }
120
121 fprintf( pFile, "]\n" );
122 fprintf( pFile, "\n" );
123 fclose( pFile );
124}
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteHie()

void Io_WriteHie ( Abc_Ntk_t * pNtk,
char * pBaseName,
char * pFileName )
extern

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

Synopsis [Write the network into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 486 of file ioUtil.c.

487{
488 Abc_Ntk_t * pNtkTemp, * pNtkResult, * pNtkBase = NULL;
489 int i;
490 // check if the current network is available
491 if ( pNtk == NULL )
492 {
493 fprintf( stdout, "Empty network.\n" );
494 return;
495 }
496
497 // read the base network
498 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
499 if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIF )
500 pNtkBase = Io_ReadBlifMv( pBaseName, 0, 1 );
501 else if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV )
502 pNtkBase = Io_ReadBlifMv( pBaseName, 1, 1 );
503 else if ( Io_ReadFileType(pBaseName) == IO_FILE_VERILOG )
504 pNtkBase = Io_ReadVerilog( pBaseName, 1 );
505 else
506 fprintf( stderr, "Unknown input file format.\n" );
507 if ( pNtkBase == NULL )
508 return;
509
510 // flatten logic hierarchy if present
511 if ( Abc_NtkWhiteboxNum(pNtkBase) > 0 && pNtk->nBarBufs == 0 )
512 {
513 pNtkBase = Abc_NtkFlattenLogicHierarchy( pNtkTemp = pNtkBase );
514 Abc_NtkDelete( pNtkTemp );
515 if ( pNtkBase == NULL )
516 return;
517 }
518
519 // reintroduce the boxes into the netlist
520 if ( pNtk->nBarBufs > 0 )
521 {
522 // derive the netlist
523 pNtkResult = Abc_NtkToNetlist( pNtk );
524 pNtkResult = Abc_NtkFromBarBufs( pNtkBase, pNtkTemp = pNtkResult );
525 Abc_NtkDelete( pNtkTemp );
526 if ( pNtkResult )
527 printf( "Hierarchy writer replaced %d barbufs by hierarchy boundaries.\n", pNtk->nBarBufs );
528 }
529 else if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV )
530 {
531 if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
532 {
533 printf( "Hierarchy writer does not support BLIF-MV with blackboxes.\n" );
534 Abc_NtkDelete( pNtkBase );
535 return;
536 }
537 // convert the current network to BLIF-MV
538 assert( !Abc_NtkIsNetlist(pNtk) );
539 pNtkResult = Abc_NtkToNetlist( pNtk );
540 if ( !Abc_NtkConvertToBlifMv( pNtkResult ) )
541 {
542 Abc_NtkDelete( pNtkBase );
543 return;
544 }
545 // reintroduce the network
546 pNtkResult = Abc_NtkInsertBlifMv( pNtkBase, pNtkTemp = pNtkResult );
547 Abc_NtkDelete( pNtkTemp );
548 }
549 else if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
550 {
551 // derive the netlist
552 pNtkResult = Abc_NtkToNetlist( pNtk );
553 pNtkResult = Abc_NtkInsertNewLogic( pNtkBase, pNtkTemp = pNtkResult );
554 Abc_NtkDelete( pNtkTemp );
555 if ( pNtkResult )
556 printf( "Hierarchy writer reintroduced %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtkBase) );
557 }
558 else
559 {
560 printf( "Warning: The output network does not contain blackboxes.\n" );
561 pNtkResult = Abc_NtkToNetlist( pNtk );
562 }
563 Abc_NtkDelete( pNtkBase );
564 if ( pNtkResult == NULL )
565 return;
566
567 // write the resulting network
568 if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF )
569 {
570 if ( pNtkResult->pDesign )
571 {
572 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtkResult->pDesign->vModules, pNtkTemp, i )
573 if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
574 Abc_NtkToSop( pNtkTemp, -1, ABC_INFINITY );
575 }
576 else
577 {
578 if ( !Abc_NtkHasSop(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
579 Abc_NtkToSop( pNtkResult, -1, ABC_INFINITY );
580 }
581 Io_WriteBlif( pNtkResult, pFileName, 1, 0, 0 );
582 }
583 else if ( Io_ReadFileType(pFileName) == IO_FILE_VERILOG )
584 {
585 if ( pNtkResult->pDesign )
586 {
587 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtkResult->pDesign->vModules, pNtkTemp, i )
588 if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
589 Abc_NtkToAig( pNtkTemp );
590 }
591 else
592 {
593 if ( !Abc_NtkHasAig(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
594 Abc_NtkToAig( pNtkResult );
595 }
596 Io_WriteVerilog( pNtkResult, pFileName, 0, 0 );
597 }
598 else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
599 {
600 Io_WriteBlifMv( pNtkResult, pFileName );
601 }
602 else
603 fprintf( stderr, "Unknown output file format.\n" );
604
605 Abc_NtkDelete( pNtkResult );
606}
ABC_DLL Abc_Ntk_t * Abc_NtkFromBarBufs(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtk)
Definition abcBarBuf.c:263
ABC_DLL Abc_Ntk_t * Abc_NtkInsertNewLogic(Abc_Ntk_t *pNtkH, Abc_Ntk_t *pNtkL)
Definition abcHie.c:691
ABC_DLL Abc_Ntk_t * Abc_NtkInsertBlifMv(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtkLogic)
Definition abcBlifMv.c:912
int nBarBufs
Definition abc.h:174
Here is the call graph for this function:

◆ Io_WriteHMetis()

void Io_WriteHMetis ( Abc_Ntk_t * pNtk,
char * pFileName,
int fSkipPo,
int fWeightEdges,
int fVerbose )
extern

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

FileName [ioWriteHMetis.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write hMetis format developed by George Karypis and Vipin Kumar from the University of Minnesota (https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf)]

Author [Jingren Wang]

Affiliation []

Date [Ver. 1.0. Started - December 16, 2006.]

Revision []

Definition at line 26 of file ioWriteHMetis.c.

27{
28 Abc_Obj_t *pObj;
29 Abc_Obj_t *pFanout;
30 int i, j;
31 Vec_Int_t *vHyperEdgeEachWrite;
32 int iEntry;
33 int nHyperNodesNum = 0;
34 // check that the network is valid
35 assert( Abc_NtkIsStrash( pNtk ) && Abc_NtkIsComb( pNtk ) );
36
37 FILE *pFHMetis = fopen( pFileName, "wb" );
38 Vec_Ptr_t *vHyperEdges = Vec_PtrAlloc( 1000 );
39 if ( pFHMetis == NULL )
40 {
41 fprintf( stdout, "Io_WriteHMetis(): Cannot open the output file \"%s\".\n", pFileName );
42 fclose( pFHMetis );
43 return;
44 }
45
46 // show pi/po/and number
47 if ( fVerbose )
48 {
49 Abc_Print( 1, "Writing hMetis file \"%s\" with %d nodes (%d pi, %d po, %d and nodes).\n", pFileName, Abc_NtkObjNum( pNtk ), Abc_NtkPiNum( pNtk ), Abc_NtkPoNum( pNtk ), Abc_NtkNodeNum( pNtk ) );
50 }
51
52 Abc_NtkForEachObj( pNtk, pObj, i )
53 {
54 Vec_Int_t *vHyperEdgeEach = Vec_IntAlloc( 20 );
55 // push the node itself, which is a source node
56 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( pObj ) );
57 // iterate through all the fanouts(sink) of the node
58 if ( !Abc_ObjIsCo( pObj ) )
59 {
60 Abc_ObjForEachFanout( pObj, pFanout, j )
61 {
62 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( pFanout ) );
63 }
64 } else
65 {
66 if ( fSkipPo )
67 {
68 continue;
69 }
70 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( Abc_ObjFanin0( pObj ) ) );
71 }
72 Vec_PtrPush( vHyperEdges, vHyperEdgeEach );
73 }
74
75 nHyperNodesNum = Abc_NtkObjNum( pNtk );
76
77 // write the number of hyperedges and the number of vertices
78 if ( fWeightEdges )
79 {
80 fprintf( pFHMetis, "%d %d 1\n", Vec_PtrSize( vHyperEdges ), nHyperNodesNum );
81 } else
82 {
83 fprintf( pFHMetis, "%d %d\n", Vec_PtrSize( vHyperEdges ), nHyperNodesNum );
84 }
85 // write the hyperedges
86 Vec_PtrForEachEntry( Vec_Int_t *, vHyperEdges, vHyperEdgeEachWrite, i )
87 {
88 if ( fWeightEdges )
89 {
90 fprintf( pFHMetis, "%d ", Vec_IntSize( vHyperEdgeEachWrite ) );
91 }
92
93 Vec_IntForEachEntry( vHyperEdgeEachWrite, iEntry, j )
94 {
95 if ( j == Vec_IntSize( vHyperEdgeEachWrite ) - 1 )
96 {
97 fprintf( pFHMetis, "%d", iEntry );
98 } else
99 {
100 fprintf( pFHMetis, "%d ", iEntry );
101 }
102 }
103 fprintf( pFHMetis, "\n" );
104 }
105 // comments should be started with "%" in hMetis format
106 fprintf( pFHMetis, "%%This file was written by ABC on %s\n", Extra_TimeStamp() );
107 fprintf( pFHMetis, "%%For information about hMetis format, refer to %s\n", "https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf" );
108 Vec_PtrFreeFree( vHyperEdges );
109 fclose( pFHMetis );
110}
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:

◆ Io_WriteJson()

void Io_WriteJson ( char * pFileName)
extern

◆ Io_WriteList()

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

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}
Here is the call graph for this function:

◆ Io_WriteMoPla()

int Io_WriteMoPla ( Abc_Ntk_t * pNtk,
char * FileName )
extern

Definition at line 576 of file ioWritePla.c.

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

◆ Io_WritePla()

int Io_WritePla ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

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}
ABC_NAMESPACE_IMPL_START int Io_WritePlaOne(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition ioWritePla.c:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteSmv()

int Io_WriteSmv ( Abc_Ntk_t * pNtk,
char * pFileName )
extern

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

Synopsis [Writes the network in SMV format.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file ioWriteSmv.c.

72{
73 Abc_Ntk_t * pExdc;
74 FILE * pFile;
75 assert( Abc_NtkIsSopNetlist(pNtk) );
76 if ( !Io_WriteSmvCheckNames(pNtk) )
77 {
78 fprintf( stdout, "Io_WriteSmv(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the SMV format. Use \"short_names\".\n" );
79 return 0;
80 }
81 pFile = fopen( pFileName, "w" );
82 if ( pFile == NULL )
83 {
84 fprintf( stdout, "Io_WriteSmv(): Cannot open the output file.\n" );
85 return 0;
86 }
87 fprintf( pFile, "-- benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
88 // write the network
89 Io_WriteSmvOne( pFile, pNtk );
90 // write EXDC network if it exists
91 pExdc = Abc_NtkExdc( pNtk );
92 if ( pExdc )
93 printf( "Io_WriteSmv: EXDC is not written (warning).\n" );
94 // finalize the file
95 fclose( pFile );
96 return 1;
97}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteTimingInfo()

void Io_WriteTimingInfo ( FILE * pFile,
Abc_Ntk_t * pNtk )
extern

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

Synopsis [Writes the timing info.]

Description []

SideEffects []

SeeAlso []

Definition at line 674 of file ioWriteBlif.c.

675{
676 Abc_Obj_t * pNode;
677 Abc_Time_t * pTime, * pTimeDefIn, * pTimeDefOut;
678 int i;
679
680 if ( pNtk->pManTime == NULL )
681 return;
682
683 fprintf( pFile, "\n" );
684 if ( pNtk->AndGateDelay != 0.0 )
685 fprintf( pFile, ".and_gate_delay %g\n", pNtk->AndGateDelay );
686 pTimeDefIn = Abc_NtkReadDefaultArrival( pNtk );
687 //if ( pTimeDefIn->Rise != 0.0 || pTimeDefIn->Fall != 0.0 )
688 fprintf( pFile, ".default_input_arrival %g %g\n", pTimeDefIn->Rise, pTimeDefIn->Fall );
689 pTimeDefOut = Abc_NtkReadDefaultRequired( pNtk );
690 //if ( pTimeDefOut->Rise != ABC_INFINITY || pTimeDefOut->Fall != ABC_INFINITY )
691 fprintf( pFile, ".default_output_required %g %g\n", pTimeDefOut->Rise, pTimeDefOut->Fall );
692
693 fprintf( pFile, "\n" );
694 Abc_NtkForEachPi( pNtk, pNode, i )
695 {
696 pTime = Abc_NodeReadArrival(pNode);
697 if ( pTime->Rise == pTimeDefIn->Rise && pTime->Fall == pTimeDefIn->Fall )
698 continue;
699 fprintf( pFile, ".input_arrival %s %g %g\n", Abc_ObjName(Abc_ObjFanout0(pNode)), pTime->Rise, pTime->Fall );
700 }
701 Abc_NtkForEachPo( pNtk, pNode, i )
702 {
703 pTime = Abc_NodeReadRequired(pNode);
704 if ( pTime->Rise == pTimeDefOut->Rise && pTime->Fall == pTimeDefOut->Fall )
705 continue;
706 fprintf( pFile, ".output_required %s %g %g\n", Abc_ObjName(Abc_ObjFanin0(pNode)), pTime->Rise, pTime->Fall );
707 }
708
709 fprintf( pFile, "\n" );
710 pTimeDefIn = Abc_NtkReadDefaultInputDrive( pNtk );
711 if ( pTimeDefIn->Rise != 0.0 || pTimeDefIn->Fall != 0.0 )
712 fprintf( pFile, ".default_input_drive %g %g\n", pTimeDefIn->Rise, pTimeDefIn->Fall );
713 if ( Abc_NodeReadInputDrive( pNtk, 0 ) )
714 Abc_NtkForEachPi( pNtk, pNode, i )
715 {
716 pTime = Abc_NodeReadInputDrive( pNtk, i );
717 if ( pTime->Rise == pTimeDefIn->Rise && pTime->Fall == pTimeDefIn->Fall )
718 continue;
719 fprintf( pFile, ".input_drive %s %g %g\n", Abc_ObjName(Abc_ObjFanout0(pNode)), pTime->Rise, pTime->Fall );
720 }
721
722 pTimeDefOut = Abc_NtkReadDefaultOutputLoad( pNtk );
723 if ( pTimeDefOut->Rise != 0.0 || pTimeDefOut->Fall != 0.0 )
724 fprintf( pFile, ".default_output_load %g %g\n", pTimeDefOut->Rise, pTimeDefOut->Fall );
725 if ( Abc_NodeReadOutputLoad( pNtk, 0 ) )
726 Abc_NtkForEachPo( pNtk, pNode, i )
727 {
728 pTime = Abc_NodeReadOutputLoad( pNtk, i );
729 if ( pTime->Rise == pTimeDefOut->Rise && pTime->Fall == pTimeDefOut->Fall )
730 continue;
731 fprintf( pFile, ".output_load %s %g %g\n", Abc_ObjName(Abc_ObjFanin0(pNode)), pTime->Rise, pTime->Fall );
732 }
733
734 fprintf( pFile, "\n" );
735}
ABC_DLL Abc_Time_t * Abc_NodeReadArrival(Abc_Obj_t *pNode)
Definition abcTiming.c:85
ABC_DLL Abc_Time_t * Abc_NodeReadOutputLoad(Abc_Ntk_t *pNtk, int iPo)
Definition abcTiming.c:146
ABC_DLL Abc_Time_t * Abc_NodeReadInputDrive(Abc_Ntk_t *pNtk, int iPi)
Definition abcTiming.c:141
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultOutputLoad(Abc_Ntk_t *pNtk)
Definition abcTiming.c:136
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultArrival(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcTiming.c:75
ABC_DLL Abc_Time_t * Abc_NodeReadRequired(Abc_Obj_t *pNode)
Definition abcTiming.c:90
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultRequired(Abc_Ntk_t *pNtk)
Definition abcTiming.c:80
struct Abc_Time_t_ Abc_Time_t
Definition abc.h:120
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultInputDrive(Abc_Ntk_t *pNtk)
Definition abcTiming.c:131
float AndGateDelay
Definition abc.h:194
Abc_ManTime_t * pManTime
Definition abc.h:192
float Rise
Definition abc.h:124
float Fall
Definition abc.h:125
Here is the call graph for this function:

◆ Io_WriteVerilog()

void Io_WriteVerilog ( Abc_Ntk_t * pNtk,
char * pFileName,
int fOnlyAnds,
int fNewInterface )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Write verilog.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file ioWriteVerilog.c.

59{
60 Abc_Ntk_t * pNetlist;
61 FILE * pFile;
62 int i;
63
64 // can only write nodes represented using local AIGs
65 if ( !Abc_NtkIsAigNetlist(pNtk) && !Abc_NtkIsMappedNetlist(pNtk) )
66 {
67 printf( "Io_WriteVerilog(): Can produce Verilog for mapped or AIG netlists only.\n" );
68 return;
69 }
70 // start the output stream
71 pFile = fopen( pFileName, "w" );
72 if ( pFile == NULL )
73 {
74 fprintf( stdout, "Io_WriteVerilog(): Cannot open the output file \"%s\".\n", pFileName );
75 return;
76 }
77
78 // write the equations for the network
79 fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
80 fprintf( pFile, "\n" );
81
82 // write modules
83 if ( pNtk->pDesign )
84 {
85 // write the network first
86 Io_WriteVerilogInt( pFile, pNtk, fOnlyAnds, fNewInterface );
87 // write other things
88 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNetlist, i )
89 {
90 assert( Abc_NtkIsNetlist(pNetlist) );
91 if ( pNetlist == pNtk )
92 continue;
93 fprintf( pFile, "\n" );
94 Io_WriteVerilogInt( pFile, pNetlist, fOnlyAnds, fNewInterface );
95 }
96 }
97 else
98 {
99 Io_WriteVerilogInt( pFile, pNtk, fOnlyAnds, fNewInterface );
100 }
101
102 fprintf( pFile, "\n" );
103 fclose( pFile );
104}
Here is the call graph for this function:
Here is the caller graph for this function: