abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioAbc.h File Reference
#include "base/abc/abc.h"
#include "misc/extra/extra.h"

Go to the source code of this file.

Macros

#define IO_WRITE_LINE_LENGTH   78
 MACRO DEFINITIONS ///. More...
 

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_LIST, IO_FILE_PLA, IO_FILE_SMV,
  IO_FILE_VERILOG, IO_FILE_UNKNOWN
}
 INCLUDES ///. More...
 

Functions

Abc_Ntk_tIo_ReadAiger (char *pFileName, int fCheck)
 FUNCTION DECLARATIONS ///. More...
 
Abc_Ntk_tIo_ReadBaf (char *pFileName, int fCheck)
 DECLARATIONS ///. More...
 
Abc_Ntk_tIo_ReadBblif (char *pFileName, int fCheck)
 
Abc_Ntk_tIo_ReadBlif (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tIo_ReadBlifMv (char *pFileName, int fBlifMv, int fCheck)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tIo_ReadBench (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///. More...
 
void Io_ReadBenchInit (Abc_Ntk_t *pNtk, char *pFileName)
 
Abc_Ntk_tIo_ReadEdif (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tIo_ReadEqn (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tIo_ReadPla (char *pFileName, int fZeros, int fCheck)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tIo_ReadVerilog (char *pFileName, int fCheck)
 DECLARATIONS ///. More...
 
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 ///. More...
 
void Io_WriteBblif (Abc_Ntk_t *pNtk, char *pFileName)
 
void Io_WriteBlifLogic (Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
 FUNCTION DEFINITIONS ///. More...
 
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 ///. More...
 
int Io_WriteBench (Abc_Ntk_t *pNtk, const char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
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 ///. More...
 
void Io_WriteDot (Abc_Ntk_t *pNtk, char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
void Io_WriteDotNtk (Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse)
 
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 ///. More...
 
void Io_WriteGml (Abc_Ntk_t *pNtk, char *pFileName)
 DECLARATIONS ///. More...
 
void Io_WriteList (Abc_Ntk_t *pNtk, char *pFileName, int fUseHost)
 FUNCTION DEFINITIONS ///. More...
 
int Io_WritePla (Abc_Ntk_t *pNtk, char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
int Io_WriteSmv (Abc_Ntk_t *pNtk, char *FileName)
 
void Io_WriteVerilog (Abc_Ntk_t *pNtk, char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
Io_FileType_t Io_ReadFileType (char *pFileName)
 DECLARATIONS ///. More...
 
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)
 

Macro Definition Documentation

#define IO_WRITE_LINE_LENGTH   78

MACRO DEFINITIONS ///.

Definition at line 71 of file ioAbc.h.

Enumeration Type Documentation

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_LIST 
IO_FILE_PLA 
IO_FILE_SMV 
IO_FILE_VERILOG 
IO_FILE_UNKNOWN 

Definition at line 46 of file ioAbc.h.

Function Documentation

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

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 819 of file ioUtil.c.

820 {
821  char * t = 0, * c = 0, * i;
822 
823  if ( PathVar == 0 )
824  {
825  return fopen( FileName, Mode );
826  }
827  else
828  {
829  if ( (c = Abc_FrameReadFlag( (char*)PathVar )) )
830  {
831  char ActualFileName[4096];
832  FILE * fp = 0;
833  t = Extra_UtilStrsav( c );
834  for (i = strtok( t, ":" ); i != 0; i = strtok( 0, ":") )
835  {
836 #ifdef WIN32
837  _snprintf ( ActualFileName, 4096, "%s/%s", i, FileName );
838 #else
839  snprintf ( ActualFileName, 4096, "%s/%s", i, FileName );
840 #endif
841  if ( ( fp = fopen ( ActualFileName, Mode ) ) )
842  {
843  if ( fVerbose )
844  fprintf ( stdout, "Using file %s\n", ActualFileName );
845  ABC_FREE( t );
846  return fp;
847  }
848  }
849  ABC_FREE( t );
850  return 0;
851  }
852  else
853  {
854  return fopen( FileName, Mode );
855  }
856  }
857 }
char * strtok()
char * Extra_UtilStrsav(const char *s)
#define ABC_FREE(obj)
Definition: abc_global.h:232
ABC_DLL char * Abc_FrameReadFlag(char *pFlag)
Definition: mainFrame.c:64
Abc_Ntk_t* Io_Read ( char *  pFileName,
Io_FileType_t  FileType,
int  fCheck,
int  fBarBufs 
)

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

Synopsis [Read the network from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file ioUtil.c.

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

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
345  pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
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  // unitialized 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 recongnized.\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  while ( pCur < pContents + nFileSize && *pCur != 'c' )
484  {
485  // get the terminal type
486  pType = pCur;
487  if ( *pCur == 'i' )
488  vTerms = pNtkNew->vPis;
489  else if ( *pCur == 'l' )
490  vTerms = pNtkNew->vBoxes;
491  else if ( *pCur == 'o' || *pCur == 'b' || *pCur == 'c' || *pCur == 'j' || *pCur == 'f' )
492  vTerms = pNtkNew->vPos;
493  else
494  {
495 // fprintf( stdout, "Wrong terminal type.\n" );
496  return NULL;
497  }
498  // get the terminal number
499  iTerm = atoi( ++pCur ); while ( *pCur++ != ' ' );
500  // get the node
501  if ( iTerm >= Vec_PtrSize(vTerms) )
502  {
503  fprintf( stdout, "The number of terminal is out of bound.\n" );
504  return NULL;
505  }
506  pObj = (Abc_Obj_t *)Vec_PtrEntry( vTerms, iTerm );
507  if ( *pType == 'l' )
508  pObj = Abc_ObjFanout0(pObj);
509  // assign the name
510  pName = pCur; while ( *pCur++ != '\n' );
511  // assign this name
512  *(pCur-1) = 0;
513  Abc_ObjAssignName( pObj, pName, NULL );
514  if ( *pType == 'l' )
515  {
516  Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
518  }
519  // mark the node as named
520  pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
521  }
522 
523  // assign the remaining names
524  Abc_NtkForEachPi( pNtkNew, pObj, i )
525  {
526  if ( pObj->pCopy ) continue;
527  Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
528  Counter++;
529  }
530  Abc_NtkForEachLatchOutput( pNtkNew, pObj, i )
531  {
532  if ( pObj->pCopy ) continue;
533  Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
534  Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
536  Counter++;
537  }
538  Abc_NtkForEachPo( pNtkNew, pObj, i )
539  {
540  if ( pObj->pCopy ) continue;
541  Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
542  Counter++;
543  }
544 // if ( Counter )
545 // printf( "Io_ReadAiger(): Added %d default names for nameless I/O/register objects.\n", Counter );
546  }
547  else
548  {
549 // printf( "Io_ReadAiger(): I/O/register names are not given. Generating short names.\n" );
550  Abc_NtkShortNames( pNtkNew );
551  }
552 
553  // read the name of the model if given
554  pCur = pSymbols;
555  if ( pCur + 1 < pContents + nFileSize && *pCur == 'c' )
556  {
557  pCur++;
558  if ( *pCur == 'n' )
559  {
560  pCur++;
561  // read model name
562  if ( strlen(pCur) > 0 )
563  {
564  ABC_FREE( pNtkNew->pName );
565  pNtkNew->pName = Extra_UtilStrsav( pCur );
566  }
567  }
568  }
569 
570  // skipping the comments
571  ABC_FREE( pContents );
572  Vec_PtrFree( vNodes );
573 
574  // remove the extra nodes
575  Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
576 
577  // update polarity of the additional outputs
578  if ( nBad || nConstr || nJust || nFair )
579  Abc_NtkInvertConstraints( pNtkNew );
580 
581  // check the result
582  if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
583  {
584  printf( "Io_ReadAiger: The network check has failed.\n" );
585  Abc_NtkDelete( pNtkNew );
586  return NULL;
587  }
588  return pNtkNew;
589 }
static char * Ioa_ReadLoadFileBz2Aig(char *pFileName, int *pFileSize)
Definition: ioReadAiger.c:118
ABC_DLL void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:2204
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Ptr_t * vBoxes
Definition: abc.h:168
#define Abc_NtkForEachLatchOutput(pNtk, pObj, i)
Definition: abc.h:503
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
ABC_DLL void Abc_NtkShortNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:490
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
Vec_Ptr_t * vPis
Definition: abc.h:163
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Abc_LatchSetInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:420
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
DECLARATIONS ///.
Abc_Obj_t * pCopy
Definition: abc.h:148
Vec_Ptr_t * vPos
Definition: abc.h:164
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition: abcAig.c:194
int Extra_FileSize(char *pFileName)
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
char * Extra_FileNameGeneric(char *FileName)
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
static int Counter
static ABC_NAMESPACE_IMPL_START unsigned Io_ReadAigerDecode(char **ppPos)
DECLARATIONS ///.
Definition: ioReadAiger.c:56
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
void Extra_ProgressBarStop(ProgressBar *p)
static Abc_Obj_t * Abc_NtkBox(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:319
static char * Ioa_ReadLoadFileGzAig(char *pFileName, int *pFileSize)
Definition: ioReadAiger.c:199
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void Abc_LatchSetInit1(Abc_Obj_t *pLatch)
Definition: abc.h:419
char * pSpec
Definition: abc.h:159
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
Definition: abc.h:500
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
int strncmp()
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
int strlen()
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
Vec_Int_t * Io_WriteDecodeLiterals(char **ppPos, int nEntries)
Definition: ioReadAiger.c:79
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int nConstrs
Definition: abc.h:173
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t* Io_ReadBaf ( char *  pFileName,
int  fCheck 
)

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
80  pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
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 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static void Abc_ObjSetData(Abc_Obj_t *pObj, void *pData)
Definition: abc.h:343
char * Extra_UtilStrsav(const char *s)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
DECLARATIONS ///.
int Extra_FileSize(char *pFileName)
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
void Extra_ProgressBarStop(ProgressBar *p)
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
char * pSpec
Definition: abc.h:159
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t* Io_ReadBblif ( char *  pFileName,
int  fCheck 
)

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
Bbl_Man_t * Bbl_ManReadBinaryBlif(char *pFileName)
Definition: bblif.c:712
Abc_Ntk_t * Bbl_ManToAig(Bbl_Man_t *p)
Definition: ioReadBblif.c:156
void Bbl_ManStop(Bbl_Man_t *p)
Definition: bblif.c:775
Abc_Ntk_t* Io_ReadBench ( char *  pFileName,
int  fCheck 
)

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 }
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Io_ReadBenchNetwork(Extra_FileReader_t *p)
DECLARATIONS ///.
Definition: ioReadBench.c:84
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_FileReaderFree(Extra_FileReader_t *p)
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
void Io_ReadBenchInit ( Abc_Ntk_t pNtk,
char *  pFileName 
)

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

Synopsis [Reads initial state in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file ioReadBench.c.

312 {
313  char pBuffer[1000];
314  FILE * pFile;
315  char * pToken;
316  Abc_Obj_t * pObj;
317  int Num;
318  pFile = fopen( pFileName, "r" );
319  if ( pFile == NULL )
320  {
321  printf( "Io_ReadBenchInit(): Failed to open file \"%s\".\n", pFileName );
322  return;
323  }
324  while ( fgets( pBuffer, 999, pFile ) )
325  {
326  pToken = strtok( pBuffer, " \n\t\r" );
327  // find the latch output
328  Num = Nm_ManFindIdByName( pNtk->pManName, pToken, ABC_OBJ_BO );
329  if ( Num < 0 )
330  {
331  printf( "Io_ReadBenchInit(): Cannot find register with output %s.\n", pToken );
332  continue;
333  }
334  pObj = Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
335  if ( !Abc_ObjIsLatch(pObj) )
336  {
337  printf( "Io_ReadBenchInit(): The signal is not a register output %s.\n", pToken );
338  continue;
339  }
340  // assign the new init state
341  pToken = strtok( NULL, " \n\t\r" );
342  if ( pToken[0] == '0' )
343  Abc_LatchSetInit0( pObj );
344  else if ( pToken[0] == '1' )
345  Abc_LatchSetInit1( pObj );
346  else if ( pToken[0] == '2' )
347  Abc_LatchSetInitDc( pObj );
348  else
349  {
350  printf( "Io_ReadBenchInit(): The signal %s has unknown initial value (%s).\n",
351  Abc_ObjName(Abc_ObjFanout0(pObj)), pToken );
352  continue;
353  }
354  }
355  fclose( pFile );
356 }
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
Definition: nmApi.c:219
Nm_Man_t * pManName
Definition: abc.h:160
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
char * strtok()
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static void Abc_LatchSetInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:420
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static void Abc_LatchSetInit1(Abc_Obj_t *pLatch)
Definition: abc.h:419
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
Definition: abc.h:92
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
Abc_Ntk_t* Io_ReadBlif ( char *  pFileName,
int  fCheck 
)

FUNCTION DEFINITIONS ///.

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file ioReadBlif.c.

93 {
94  Io_ReadBlif_t * p;
95  Abc_Ntk_t * pNtk;
96 
97  // start the file
98  p = Io_ReadBlifFile( pFileName );
99  if ( p == NULL )
100  return NULL;
101 
102  // read the hierarchical network
103  pNtk = Io_ReadBlifNetwork( p );
104  if ( pNtk == NULL )
105  {
106  Io_ReadBlifFree( p );
107  return NULL;
108  }
109  pNtk->pSpec = Extra_UtilStrsav( pFileName );
110  Abc_NtkTimeInitialize( pNtk, NULL );
111  Io_ReadBlifFree( p );
112 
113  // make sure that everything is okay with the network structure
114  if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
115  {
116  printf( "Io_ReadBlif: The network check has failed.\n" );
117  Abc_NtkDelete( pNtk );
118  return NULL;
119  }
120  return pNtk;
121 }
static Io_ReadBlif_t * Io_ReadBlifFile(char *pFileName)
Definition: ioReadBlif.c:1325
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
static void Io_ReadBlifFree(Io_ReadBlif_t *p)
Definition: ioReadBlif.c:1358
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
ABC_DLL void Abc_NtkTimeInitialize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkOld)
Definition: abcTiming.c:321
static Abc_Ntk_t * Io_ReadBlifNetwork(Io_ReadBlif_t *p)
Definition: ioReadBlif.c:134
typedefABC_NAMESPACE_IMPL_START struct Io_ReadBlif_t_ Io_ReadBlif_t
DECLARATIONS ///.
Definition: ioReadBlif.c:32
char * pSpec
Definition: abc.h:159
Abc_Ntk_t* Io_ReadBlifMv ( char *  pFileName,
int  fBlifMv,
int  fCheck 
)

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
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 );
255  return pNtk;
256 }
Abc_Des_t * pDesign
Definition: ioReadBlifMv.c:81
static Abc_Des_t * Io_MvParse(Io_MvMan_t *p)
Definition: ioReadBlifMv.c:903
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static Io_MvMan_t * Io_MvAlloc()
Definition: ioReadBlifMv.c:269
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Abc_Ntk_t * pExdc
Definition: abc.h:201
ABC_DLL Abc_Des_t * Abc_DesCreate(char *pName)
DECLARATIONS ///.
Definition: abcLib.c:45
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Io_MvReadInterfaces(Io_MvMan_t *p)
Definition: ioReadBlifMv.c:846
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL int Abc_DesFindTopLevelModels(Abc_Des_t *p)
Definition: abcLib.c:293
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
char * Extra_UtilStrsav(const char *s)
void Hop_ManStop(Hop_Man_t *p)
Definition: hopMan.c:84
int strcmp()
void * pManFunc
Definition: abc.h:221
char * pBuffer
Definition: ioReadBlifMv.c:78
ABC_DLL void Abc_DesFree(Abc_Des_t *p, Abc_Ntk_t *pNtk)
Definition: abcLib.c:94
static void Io_MvFree(Io_MvMan_t *p)
Definition: ioReadBlifMv.c:293
static char * Io_MvLoadFile(char *pFileName)
Definition: ioReadBlifMv.c:665
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
ABC_DLL int Abc_NtkIsAcyclicHierarchy(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:809
char * Extra_FileNameGeneric(char *FileName)
char * pFileName
Definition: ioReadBlifMv.c:77
if(last==0)
Definition: sparse_int.h:34
Vec_Ptr_t * vTops
Definition: abc.h:222
Vec_Ptr_t * vGlobalLtlArray
Definition: ioReadBlifMv.c:40
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void Io_MvReadPreparse(Io_MvMan_t *p)
Definition: ioReadBlifMv.c:716
char * pSpec
Definition: abc.h:159
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
char sError[512]
Definition: ioReadBlifMv.c:91
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
char * pName
Definition: abc.h:158
Abc_Obj_t* Io_ReadCreateBuf ( Abc_Ntk_t pNtk,
char *  pNameIn,
char *  pNameOut 
)

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

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

Description [Assumes that the nets already exist.]

SideEffects []

SeeAlso []

Definition at line 795 of file ioUtil.c.

796 {
797  Abc_Obj_t * pNet, * pNode;
798  pNet = Abc_NtkFindNet(pNtk, pNameIn); assert( pNet );
799  pNode = Abc_NtkCreateNodeBuf(pNtk, pNet);
800  pNet = Abc_NtkFindNet(pNtk, pNameOut); assert( pNet );
801  Abc_ObjAddFanin( pNet, pNode );
802  return pNet;
803 }
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:507
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:692
#define assert(ex)
Definition: util_old.h:213
Abc_Obj_t* Io_ReadCreateConst ( Abc_Ntk_t pNtk,
char *  pName,
int  fConst1 
)

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 754 of file ioUtil.c.

755 {
756  Abc_Obj_t * pNet, * pTerm;
757  pTerm = fConst1? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
758  pNet = Abc_NtkFindNet(pNtk, pName); assert( pNet );
759  Abc_ObjAddFanin( pNet, pTerm );
760  return pTerm;
761 }
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:507
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
#define assert(ex)
Definition: util_old.h:213
Abc_Obj_t* Io_ReadCreateInv ( Abc_Ntk_t pNtk,
char *  pNameIn,
char *  pNameOut 
)

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

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

Description [Assumes that the nets already exist.]

SideEffects []

SeeAlso []

Definition at line 774 of file ioUtil.c.

775 {
776  Abc_Obj_t * pNet, * pNode;
777  pNet = Abc_NtkFindNet(pNtk, pNameIn); assert( pNet );
778  pNode = Abc_NtkCreateNodeInv(pNtk, pNet);
779  pNet = Abc_NtkFindNet(pNtk, pNameOut); assert( pNet );
780  Abc_ObjAddFanin( pNet, pNode );
781  return pNode;
782 }
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:507
#define assert(ex)
Definition: util_old.h:213
Abc_Obj_t* Io_ReadCreateLatch ( Abc_Ntk_t pNtk,
char *  pNetLI,
char *  pNetLO 
)

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 660 of file ioUtil.c.

661 {
662  Abc_Obj_t * pLatch, * pTerm, * pNet;
663  // get the LI net
664  pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLI );
665  // add the BO terminal
666  pTerm = Abc_NtkCreateBi( pNtk );
667  Abc_ObjAddFanin( pTerm, pNet );
668  // add the latch box
669  pLatch = Abc_NtkCreateLatch( pNtk );
670  Abc_ObjAddFanin( pLatch, pTerm );
671  // add the BI terminal
672  pTerm = Abc_NtkCreateBo( pNtk );
673  Abc_ObjAddFanin( pTerm, pLatch );
674  // get the LO net
675  pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO );
676  Abc_ObjAddFanin( pNet, pTerm );
677  // set latch name
678  Abc_ObjAssignName( pLatch, pNetLO, "L" );
679  return pLatch;
680 }
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:579
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
Abc_Obj_t* Io_ReadCreateNode ( Abc_Ntk_t pNtk,
char *  pNameOut,
char *  pNamesIn[],
int  nInputs 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 725 of file ioUtil.c.

726 {
727  Abc_Obj_t * pNet, * pNode;
728  int i;
729  // create a new node
730  pNode = Abc_NtkCreateNode( pNtk );
731  // add the fanin nets
732  for ( i = 0; i < nInputs; i++ )
733  {
734  pNet = Abc_NtkFindOrCreateNet( pNtk, pNamesIn[i] );
735  Abc_ObjAddFanin( pNode, pNet );
736  }
737  // add the fanout net
738  pNet = Abc_NtkFindOrCreateNet( pNtk, pNameOut );
739  Abc_ObjAddFanin( pNet, pNode );
740  return pNode;
741 }
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:579
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
Abc_Obj_t* Io_ReadCreatePi ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Creates PI terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 610 of file ioUtil.c.

611 {
612  Abc_Obj_t * pNet, * pTerm;
613  // get the PI net
614  pNet = Abc_NtkFindNet( pNtk, pName );
615  if ( pNet )
616  printf( "Warning: PI \"%s\" appears twice in the list.\n", pName );
617  pNet = Abc_NtkFindOrCreateNet( pNtk, pName );
618  // add the PI node
619  pTerm = Abc_NtkCreatePi( pNtk );
620  Abc_ObjAddFanin( pNet, pTerm );
621  return pTerm;
622 }
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:507
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:579
Abc_Obj_t* Io_ReadCreatePo ( Abc_Ntk_t pNtk,
char *  pName 
)

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

Synopsis [Creates PO terminal and net.]

Description []

SideEffects []

SeeAlso []

Definition at line 635 of file ioUtil.c.

636 {
637  Abc_Obj_t * pNet, * pTerm;
638  // get the PO net
639  pNet = Abc_NtkFindNet( pNtk, pName );
640  if ( pNet && Abc_ObjFaninNum(pNet) == 0 )
641  printf( "Warning: PO \"%s\" appears twice in the list.\n", pName );
642  pNet = Abc_NtkFindOrCreateNet( pNtk, pName );
643  // add the PO node
644  pTerm = Abc_NtkCreatePo( pNtk );
645  Abc_ObjAddFanin( pTerm, pNet );
646  return pTerm;
647 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:507
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:579
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
Abc_Obj_t* Io_ReadCreateResetLatch ( Abc_Ntk_t pNtk,
int  fBlifMv 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 693 of file ioUtil.c.

694 {
695  Abc_Obj_t * pLatch, * pNode;
696  Abc_Obj_t * pNetLI, * pNetLO;
697  // create latch with 0 init value
698 // pLatch = Io_ReadCreateLatch( pNtk, "_resetLI_", "_resetLO_" );
699  pNetLI = Abc_NtkCreateNet( pNtk );
700  pNetLO = Abc_NtkCreateNet( pNtk );
701  Abc_ObjAssignName( pNetLI, Abc_ObjName(pNetLI), NULL );
702  Abc_ObjAssignName( pNetLO, Abc_ObjName(pNetLO), NULL );
703  pLatch = Io_ReadCreateLatch( pNtk, Abc_ObjName(pNetLI), Abc_ObjName(pNetLO) );
704  // set the initial value
705  Abc_LatchSetInit0( pLatch );
706  // feed the latch with constant1- node
707 // pNode = Abc_NtkCreateNode( pNtk );
708 // pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "2\n1\n" );
709  pNode = Abc_NtkCreateNodeConst1( pNtk );
710  Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pNode );
711  return pLatch;
712 }
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
Abc_Obj_t * Io_ReadCreateLatch(Abc_Ntk_t *pNtk, char *pNetLI, char *pNetLO)
Definition: ioUtil.c:660
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
static Abc_Obj_t * Abc_NtkCreateNet(Abc_Ntk_t *pNtk)
Definition: abc.h:307
Abc_Obj_t* Io_ReadCreateResetMux ( Abc_Ntk_t pNtk,
char *  pResetLO,
char *  pDataLI,
int  fBlifMv 
)
Abc_Ntk_t* Io_ReadEdif ( char *  pFileName,
int  fCheck 
)

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 }
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Io_ReadEdifNetwork(Extra_FileReader_t *p)
DECLARATIONS ///.
Definition: ioReadEdif.c:86
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_FileReaderFree(Extra_FileReader_t *p)
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
Abc_Ntk_t* Io_ReadEqn ( char *  pFileName,
int  fCheck 
)

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_FileReaderFree(Extra_FileReader_t *p)
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Io_ReadEqnNetwork(Extra_FileReader_t *p)
DECLARATIONS ///.
Definition: ioReadEqn.c:87
Io_FileType_t Io_ReadFileType ( char *  pFileName)

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 46 of file ioUtil.c.

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

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

Synopsis [Read the network from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file ioUtil.c.

99 {
100  FILE * pFile;
101  Abc_Ntk_t * pNtk;
102  if ( FileType == IO_FILE_NONE || FileType == IO_FILE_UNKNOWN )
103  {
104  fprintf( stdout, "Generic file reader requires a known file extension to open \"%s\".\n", pFileName );
105  return NULL;
106  }
107  // check if the file exists
108  pFile = fopen( pFileName, "r" );
109  if ( pFile == NULL )
110  {
111  fprintf( stdout, "Cannot open input file \"%s\". ", pFileName );
112  if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" )) )
113  fprintf( stdout, "Did you mean \"%s\"?", pFileName );
114  fprintf( stdout, "\n" );
115  return NULL;
116  }
117  fclose( pFile );
118  // read the AIG
119  if ( FileType == IO_FILE_AIGER || FileType == IO_FILE_BAF || FileType == IO_FILE_BBLIF )
120  {
121  if ( FileType == IO_FILE_AIGER )
122  pNtk = Io_ReadAiger( pFileName, fCheck );
123  else if ( FileType == IO_FILE_BAF )
124  pNtk = Io_ReadBaf( pFileName, fCheck );
125  else // if ( FileType == IO_FILE_BBLIF )
126  pNtk = Io_ReadBblif( pFileName, fCheck );
127  if ( pNtk == NULL )
128  {
129  fprintf( stdout, "Reading AIG from file has failed.\n" );
130  return NULL;
131  }
132  return pNtk;
133  }
134  // read the new netlist
135  if ( FileType == IO_FILE_BLIF )
136 // pNtk = Io_ReadBlif( pFileName, fCheck );
137  pNtk = Io_ReadBlifMv( pFileName, 0, fCheck );
138  else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
139  pNtk = Io_ReadBlifMv( pFileName, 1, fCheck );
140  else if ( FileType == IO_FILE_BENCH )
141  pNtk = Io_ReadBench( pFileName, fCheck );
142  else if ( FileType == IO_FILE_EDIF )
143  pNtk = Io_ReadEdif( pFileName, fCheck );
144  else if ( FileType == IO_FILE_EQN )
145  pNtk = Io_ReadEqn( pFileName, fCheck );
146  else if ( FileType == IO_FILE_PLA )
147  pNtk = Io_ReadPla( pFileName, 0, fCheck );
148  else if ( FileType == IO_FILE_VERILOG )
149  pNtk = Io_ReadVerilog( pFileName, fCheck );
150  else
151  {
152  fprintf( stderr, "Unknown file format.\n" );
153  return NULL;
154  }
155  if ( pNtk == NULL )
156  {
157  fprintf( stdout, "Reading network from file has failed.\n" );
158  return NULL;
159  }
160  if ( fCheck && (Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk)) )
161  {
162  int i, fCycle = 0;
163  Abc_Ntk_t * pModel;
164  fprintf( stdout, "Warning: The network contains hierarchy.\n" );
165  Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
166  if ( !Abc_NtkIsAcyclicWithBoxes( pModel ) )
167  fCycle = 1;
168  if ( fCycle )
169  {
170  Abc_NtkDelete( pNtk );
171  return NULL;
172  }
173  }
174  return pNtk;
175 }
Abc_Ntk_t * Io_ReadAiger(char *pFileName, int fCheck)
FUNCTION DECLARATIONS ///.
Definition: ioReadAiger.c:234
Abc_Ntk_t * Io_ReadBlifMv(char *pFileName, int fBlifMv, int fCheck)
FUNCTION DEFINITIONS ///.
Definition: ioReadBlifMv.c:142
Abc_Ntk_t * Io_ReadBblif(char *pFileName, int fCheck)
Definition: ioReadBblif.c:324
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Definition: extraUtilFile.c:71
Abc_Ntk_t * Io_ReadEdif(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Definition: ioReadEdif.c:47
ABC_NAMESPACE_IMPL_START Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition: ioUtil.c:46
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkIsAcyclicWithBoxes(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1510
Abc_Ntk_t * Io_ReadBench(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Definition: ioReadBench.c:47
if(last==0)
Definition: sparse_int.h:34
Abc_Ntk_t * Io_ReadEqn(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Definition: ioReadEqn.c:50
Abc_Ntk_t * Io_ReadVerilog(char *pFileName, int fCheck)
DECLARATIONS ///.
Definition: ioReadVerilog.c:48
Abc_Ntk_t * Io_ReadPla(char *pFileName, int fZeros, int fCheck)
FUNCTION DEFINITIONS ///.
Definition: ioReadPla.c:47
Vec_Ptr_t * vModules
Definition: abc.h:223
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Ntk_t * Io_ReadBaf(char *pFileName, int fCheck)
DECLARATIONS ///.
Definition: ioReadBaf.c:45
Abc_Des_t * pDesign
Definition: abc.h:180
Abc_Ntk_t* Io_ReadPla ( char *  pFileName,
int  fZeros,
int  fCheck 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the network from a PLA file.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioReadPla.c.

48 {
50  Abc_Ntk_t * pNtk;
51 
52  // start the file
53  p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t|" );
54 // p = Extra_FileReaderAlloc( pFileName, "", "\n\r", " \t|" );
55  if ( p == NULL )
56  return NULL;
57 
58  // read the network
59  pNtk = Io_ReadPlaNetwork( p, fZeros );
61  if ( pNtk == NULL )
62  return NULL;
63 
64  // make sure that everything is okay with the network structure
65  if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
66  {
67  printf( "Io_ReadPla: The network check has failed.\n" );
68  Abc_NtkDelete( pNtk );
69  return NULL;
70  }
71  return pNtk;
72 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_FileReaderFree(Extra_FileReader_t *p)
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:77
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Io_ReadPlaNetwork(Extra_FileReader_t *p, int fZeros)
DECLARATIONS ///.
Definition: ioReadPla.c:84
Abc_Ntk_t* Io_ReadVerilog ( char *  pFileName,
int  fCheck 
)

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 }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL int Abc_DesFindTopLevelModels(Abc_Des_t *p)
Definition: abcLib.c:293
char * Extra_UtilStrsav(const char *s)
ABC_DLL void Abc_DesFree(Abc_Des_t *p, Abc_Ntk_t *pNtk)
Definition: abcLib.c:94
static DdNode * one
Definition: cuddDecomp.c:112
ABC_DLL int Abc_NtkIsAcyclicHierarchy(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:809
if(last==0)
Definition: sparse_int.h:34
Vec_Ptr_t * vTops
Definition: abc.h:222
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
char * pSpec
Definition: abc.h:159
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
Abc_Des_t * Ver_ParseFile(char *pFileName, Abc_Des_t *pGateLib, int fCheck, int fUseMemMan)
MACRO DEFINITIONS ///.
Definition: verCore.c:165
void Io_Write ( Abc_Ntk_t pNtk,
char *  pFileName,
Io_FileType_t  FileType 
)

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

Synopsis [Write the network into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file ioUtil.c.

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

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, "Ioa_WriteBlif(): 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, "Ioa_WriteBlif(): 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 
723  Abc_NtkInvertConstraints( pNtk );
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  }
770  Abc_NtkInvertConstraints( pNtk );
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 }
char * memset()
ABC_DLL void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:2204
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
void BZ_API() BZ2_bzWrite(int *bzerror, BZFILE *b, void *buf, int len)
Definition: bzlib.c:976
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static ABC_NAMESPACE_IMPL_START unsigned Io_ObjMakeLit(int Var, int fCompl)
DECLARATIONS ///.
Definition: ioWriteAiger.c:146
static int Abc_LatchIsInitNone(Abc_Obj_t *pLatch)
Definition: abc.h:421
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
void BZ_API() BZ2_bzWriteClose(int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
Definition: bzlib.c:1021
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
ush Pos
Definition: deflate.h:88
Vec_Str_t * Io_WriteEncodeLiterals(Vec_Int_t *vLits)
Definition: ioWriteAiger.c:223
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int Io_WriteAigerEncode(unsigned char *pBuffer, int Pos, unsigned x)
FUNCTION DEFINITIONS ///.
Definition: ioWriteAiger.c:166
FILE * f
Definition: ioWriteAiger.c:581
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
BZFILE *BZ_API() BZ2_bzWriteOpen(int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
Definition: bzlib.c:928
static unsigned Io_ObjAigerNum(Abc_Obj_t *pObj)
Definition: ioWriteAiger.c:147
int nBytesMax
Definition: ioWriteAiger.c:585
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
BZFILE * b
Definition: ioWriteAiger.c:582
DECLARATIONS ///.
#define BZ_OK
Definition: bzlib.h:34
char * buf
Definition: ioWriteAiger.c:583
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Vec_Int_t * Io_WriteAigerLiterals(Abc_Ntk_t *pNtk)
Definition: ioWriteAiger.c:193
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
void Extra_ProgressBarStop(ProgressBar *p)
static int Abc_NtkConstrNum(Abc_Ntk_t *pNtk)
Definition: abc.h:299
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
char * Extra_TimeStamp()
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
int strncmp()
static void Io_ObjSetAigerNum(Abc_Obj_t *pObj, unsigned Num)
Definition: ioWriteAiger.c:148
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
int strlen()
void Io_WriteAigerGz(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols)
Definition: ioWriteAiger.c:436
#define BZ_IO_ERROR
Definition: bzlib.h:44
int fprintfBz2Aig(bz2file *b, char *fmt,...)
Definition: ioWriteAiger.c:588
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Io_WriteAigerCex ( Abc_Cex_t pCex,
Abc_Ntk_t pNtk,
void *  pG,
char *  pFileName 
)

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  for ( f = 0; f <= pCex->iFrame; f++ )
918  {
919  for ( k = 0; k < pCex->nPis; k++ )
920  {
921  fprintf( pFile, "%d", Abc_InfoHasBit(pCex->pData, b) );
922  Aig_ManCi( pAig, k )->fMarkA = Abc_InfoHasBit(pCex->pData, b++);
923  }
924  fprintf( pFile, " " );
925  Aig_ManForEachNode( pAig, pObj, k )
926  pObj->fMarkA = (Aig_ObjFanin0(pObj)->fMarkA ^ Aig_ObjFaninC0(pObj)) &
927  (Aig_ObjFanin1(pObj)->fMarkA ^ Aig_ObjFaninC1(pObj));
928  Aig_ManForEachCo( pAig, pObj, k )
929  pObj->fMarkA = (Aig_ObjFanin0(pObj)->fMarkA ^ Aig_ObjFaninC0(pObj));
930  Saig_ManForEachPo( pAig, pObj, k )
931  fprintf( pFile, "%d", pObj->fMarkA );
932  fprintf( pFile, " " );
933  Saig_ManForEachLi( pAig, pObj, k )
934  fprintf( pFile, "%d", pObj->fMarkA );
935  fprintf( pFile, "\n" );
936  if ( f == pCex->iFrame )
937  break;
938  Saig_ManForEachLi( pAig, pObj, k )
939  fprintf( pFile, "%d", pObj->fMarkA );
940  fprintf( pFile, " " );
941  Saig_ManForEachLiLo( pAig, pObj, pObj2, k )
942  pObj2->fMarkA = pObj->fMarkA;
943  }
944  assert( b == pCex->nBits );
945  fclose( pFile );
946  Aig_ManCleanMarkA( pAig );
947  Aig_ManStop( pAig );
948 }
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition: giaAig.c:367
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
unsigned int fMarkA
Definition: aig.h:79
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Definition: abcDar.c:233
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
Definition: gia.h:95
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
void Aig_ManCleanMarkA(Aig_Man_t *p)
Definition: aigUtil.c:148
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Io_WriteBaf ( Abc_Ntk_t pNtk,
char *  pFileName 
)

DECLARATIONS ///.

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

FileName [ioWriteBaf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

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

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Writes the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file ioWriteBaf.c.

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

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_NAMESPACE_IMPL_START Bbl_Man_t * Bbl_ManFromAbc(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteBblif.c:54
void Bbl_ManDumpBinaryBlif(Bbl_Man_t *p, char *pFileName)
Definition: bblif.c:691
void Bbl_ManStop(Bbl_Man_t *p)
Definition: bblif.c:775
int Io_WriteBench ( Abc_Ntk_t pNtk,
const char *  pFileName 
)

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 parantheses 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 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
static ABC_NAMESPACE_IMPL_START int Io_WriteBenchCheckNames(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteBench.c:322
static int Io_WriteBenchOne(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteBench.c:92
char * Extra_TimeStamp()
static int Abc_NtkIsSopNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:260
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: abc.h:158
int Io_WriteBenchLut ( Abc_Ntk_t pNtk,
char *  pFileName 
)

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 parantheses 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 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
static ABC_NAMESPACE_IMPL_START int Io_WriteBenchCheckNames(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteBench.c:322
static int Io_WriteBenchLutOne(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteBench.c:214
static int Abc_NtkIsAigNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:261
char * Extra_TimeStamp()
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: abc.h:158
void Io_WriteBlif ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches,
int  fBb2Wb,
int  fSeq 
)

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 }
static ABC_NAMESPACE_IMPL_START void Io_NtkWrite(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches, int fBb2Wb, int fSeq)
DECLARATIONS ///.
Definition: ioWriteBlif.c:127
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
char * Extra_TimeStamp()
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
char * pName
Definition: abc.h:158
void Io_WriteBlifLogic ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches 
)

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
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
void Io_WriteBlifMv ( Abc_Ntk_t pNtk,
char *  FileName 
)

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 }
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static ABC_NAMESPACE_IMPL_START void Io_NtkWriteBlifMv(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
static int Abc_NtkHasBlifMv(Abc_Ntk_t *pNtk)
Definition: abc.h:257
char * Extra_TimeStamp()
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
char * pName
Definition: abc.h:158
void Io_WriteBlifSpecial ( Abc_Ntk_t pNtk,
char *  FileName,
char *  pLutStruct,
int  fUseHie 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1378 of file ioWriteBlif.c.

1379 {
1380  Abc_Ntk_t * pNtkTemp;
1381  assert( Abc_NtkIsLogic(pNtk) );
1382  Abc_NtkToSop( pNtk, 0 );
1383  // derive the netlist
1384  pNtkTemp = Abc_NtkToNetlist(pNtk);
1385  if ( pNtkTemp == NULL )
1386  {
1387  fprintf( stdout, "Writing BLIF has failed.\n" );
1388  return;
1389  }
1390  if ( pLutStruct && fUseHie )
1391  Io_WriteBlifInt( pNtkTemp, FileName, pLutStruct, 1 );
1392  else
1393  Io_WriteBlifInt( pNtkTemp, FileName, pLutStruct, 0 );
1394  Abc_NtkDelete( pNtkTemp );
1395 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
void Io_WriteBlifInt(Abc_Ntk_t *pNtk, char *FileName, char *pLutStruct, int fUseHie)
Definition: ioWriteBlif.c:1305
#define assert(ex)
Definition: util_old.h:213
void Io_WriteBook ( Abc_Ntk_t pNtk,
char *  FileName 
)

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 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static unsigned Io_NtkWriteNodes(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteBook.c:184
static void Io_NtkBuildLayout(FILE *pFile1, FILE *pFile2, Abc_Ntk_t *pNtk, double aspectRatio, double whiteSpace, unsigned coreCellArea)
Definition: ioWriteBook.c:519
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
static void Io_NtkWriteNets(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteBook.c:403
char * strcpy()
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
char * strcat()
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
int strlen()
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
int Io_WriteCnf ( Abc_Ntk_t pNtk,
char *  pFileName,
int  fAllPrimes 
)

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 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
ABC_DLL void * Abc_NtkMiterSatCreate(Abc_Ntk_t *pNtk, int fAllPrimes)
Definition: abcSat.c:629
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_DLL int Abc_NtkToBdd(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1160
void Sat_SolverWriteDimacs(sat_solver *p, char *pFileName, lit *assumptionsBegin, lit *assumptionsEnd, int incrementVars)
Definition: satUtil.c:71
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * s_pNtk
DECLARATIONS ///.
Definition: ioWriteCnf.c:31
void Io_WriteDot ( Abc_Ntk_t pNtk,
char *  FileName 
)

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 );
56  Vec_PtrFree( vNodes );
57 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Vec_Ptr_t * Abc_NtkCollectObjects(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1725
void Io_WriteDotNtk(Abc_Ntk_t *pNtk, Vec_Ptr_t *vNodes, Vec_Ptr_t *vNodesShow, char *pFileName, int fGateNames, int fUseReverse)
Definition: ioWriteDot.c:71
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Io_WriteDotNtk ( Abc_Ntk_t pNtk,
Vec_Ptr_t vNodes,
Vec_Ptr_t vNodesShow,
char *  pFileName,
int  fGateNames,
int  fUseReverse 
)

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;
76  int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl, Prev;
77  int Limit = 300;
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, 0) )
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  pSopString = Abc_NtkPrintSop((char *)pNode->pData);
307  fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
308 // fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id,
309 // SuppSize,
310 // pSopString );
311 
312  fprintf( pFile, ", shape = ellipse" );
313  if ( pNode->fMarkB )
314  fprintf( pFile, ", style = filled" );
315  fprintf( pFile, "];\n" );
316  }
317  fprintf( pFile, "}" );
318  fprintf( pFile, "\n" );
319  fprintf( pFile, "\n" );
320  }
321 
322  // generate the PI nodes if any
323  if ( LevelMin == 0 )
324  {
325  fprintf( pFile, "{\n" );
326  fprintf( pFile, " rank = same;\n" );
327  // the labeling node of this level
328  fprintf( pFile, " Level%d;\n", LevelMin );
329  // generate the PO nodes
330  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
331  {
332  if ( !Abc_ObjIsCi(pNode) )
333  {
334  // check if the costant node is present
335  if ( Abc_ObjFaninNum(pNode) == 0 && Abc_ObjFanoutNum(pNode) > 0 )
336  {
337  fprintf( pFile, " Node%d [label = \"Const%d\"", pNode->Id, Abc_NtkIsStrash(pNode->pNtk) || Abc_NodeIsConst1(pNode) );
338  fprintf( pFile, ", shape = ellipse" );
339  if ( pNode->fMarkB )
340  fprintf( pFile, ", style = filled" );
341  fprintf( pFile, ", color = coral, fillcolor = coral" );
342  fprintf( pFile, "];\n" );
343  }
344  continue;
345  }
346  fprintf( pFile, " Node%d [label = \"%s\"",
347  pNode->Id,
348  (Abc_ObjIsBo(pNode)? Abc_ObjName(Abc_ObjFanin0(pNode)):Abc_ObjName(pNode)) );
349  fprintf( pFile, ", shape = %s", (Abc_ObjIsBo(pNode)? "box":"triangle") );
350  if ( pNode->fMarkB )
351  fprintf( pFile, ", style = filled" );
352  fprintf( pFile, ", color = coral, fillcolor = coral" );
353  fprintf( pFile, "];\n" );
354  }
355  fprintf( pFile, "}" );
356  fprintf( pFile, "\n" );
357  fprintf( pFile, "\n" );
358  }
359 
360  // generate invisible edges from the square down
361  fprintf( pFile, "title1 -> title2 [style = invis];\n" );
362  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
363  {
364  if ( (int)pNode->Level != LevelMax )
365  continue;
366  fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
367  }
368  // generate invisible edges among the COs
369  Prev = -1;
370  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
371  {
372  if ( (int)pNode->Level != LevelMax )
373  continue;
374  if ( !Abc_ObjIsPo(pNode) )
375  continue;
376  if ( Prev >= 0 )
377  fprintf( pFile, "Node%d -> Node%d [style = invis];\n", Prev, pNode->Id );
378  Prev = pNode->Id;
379  }
380 
381  // generate edges
382  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
383  {
384  if ( Abc_ObjIsLatch(pNode) )
385  continue;
386  Abc_ObjForEachFanin( pNode, pFanin, k )
387  {
388  if ( Abc_ObjIsLatch(pFanin) )
389  continue;
390  fCompl = 0;
391  if ( Abc_NtkIsStrash(pNtk) )
392  fCompl = Abc_ObjFaninC(pNode, k);
393  // generate the edge from this node to the next
394  fprintf( pFile, "Node%d", pNode->Id );
395  fprintf( pFile, " -> " );
396  fprintf( pFile, "Node%d", pFanin->Id );
397  fprintf( pFile, " [style = %s", fCompl? "dotted" : "bold" );
398 // fprintf( pFile, ", label = \"%c\"", 'a' + k );
399  fprintf( pFile, "]" );
400  fprintf( pFile, ";\n" );
401  }
402  }
403 
404  fprintf( pFile, "}" );
405  fprintf( pFile, "\n" );
406  fprintf( pFile, "\n" );
407  fclose( pFile );
408 
409  // unmark the nodes from the set
410  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
411  pNode->fMarkC = 0;
412  if ( vNodesShow )
413  Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
414  pNode->fMarkB = 0;
415 
416  // convert the network back into BDDs if this is how it was
417  if ( fHasBdds )
418  Abc_NtkSopToBdd(pNtk);
419 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL int Abc_NtkLevelReverse(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1315
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static ABC_NAMESPACE_IMPL_START char * Abc_NtkPrintSop(char *pSop)
DECLARATIONS ///.
Definition: ioWriteDot.c:803
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_DLL int Abc_NtkSopToBdd(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:113
if(last==0)
Definition: sparse_int.h:34
static int Abc_ObjFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:379
static int Abc_ObjIsBi(Abc_Obj_t *pObj)
Definition: abc.h:349
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:359
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:265
int Id
Definition: abc.h:132
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
char * Extra_TimeStamp()
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
Definition: abcObj.c:890
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkCountLogicNodes(Vec_Ptr_t *vNodes)
Definition: ioWriteDot.c:833
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Abc_NtkObjNum(Abc_Ntk_t *pNtk)
Definition: abc.h:283
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition: mioApi.c:153
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Io_WriteDotSeq ( Abc_Ntk_t pNtk,
Vec_Ptr_t vNodes,
Vec_Ptr_t vNodesShow,
char *  pFileName,
int  fGateNames,
int  fUseReverse 
)

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 434 of file ioWriteDot.c.

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

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 }
static ABC_NAMESPACE_IMPL_START void Io_NtkWriteEqnOne(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteEqn.c:88
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_NtkIsAigNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:261
char * Extra_TimeStamp()
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: abc.h:158
static int Io_NtkWriteEqnCheck(Abc_Ntk_t *pNtk)
Definition: ioWriteEqn.c:215
void Io_WriteGml ( Abc_Ntk_t pNtk,
char *  pFileName 
)

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 the POs
65  fprintf( pFile, "\n" );
66  Abc_NtkForEachPo( pNtk, pObj, i )
67  {
68  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
69  fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" ); // blue
70  fprintf( pFile, " ]\n" );
71  }
72  // output the PIs
73  fprintf( pFile, "\n" );
74  Abc_NtkForEachPi( pNtk, pObj, i )
75  {
76  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
77  fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FF00\" ]\n" ); // green
78  fprintf( pFile, " ]\n" );
79  }
80  // output the latches
81  fprintf( pFile, "\n" );
82  Abc_NtkForEachLatch( pNtk, pObj, i )
83  {
84  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
85  fprintf( pFile, " graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" ); // red
86  fprintf( pFile, " ]\n" );
87  }
88  // output the nodes
89  fprintf( pFile, "\n" );
90  Abc_NtkForEachNode( pNtk, pObj, i )
91  {
92  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
93  fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
94  fprintf( pFile, " ]\n" );
95  }
96 
97  // output the edges
98  fprintf( pFile, "\n" );
99  Abc_NtkForEachObj( pNtk, pObj, i )
100  {
101  Abc_ObjForEachFanin( pObj, pFanin, k )
102  {
103  fprintf( pFile, " edge [ source %5d target %5d\n", pObj->Id, pFanin->Id );
104  fprintf( pFile, " graphics [ type \"line\" arrow \"first\" ]\n" );
105  fprintf( pFile, " ]\n" );
106  }
107  }
108 
109  fprintf( pFile, "]\n" );
110  fprintf( pFile, "\n" );
111  fclose( pFile );
112 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Id
Definition: abc.h:132
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
char * Extra_TimeStamp()
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
char * pName
Definition: abc.h:158
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Io_WriteHie ( Abc_Ntk_t pNtk,
char *  pBaseName,
char *  pFileName 
)

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

Synopsis [Write the network into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 477 of file ioUtil.c.

478 {
479  Abc_Ntk_t * pNtkTemp, * pNtkResult, * pNtkBase = NULL;
480  int i;
481  // check if the current network is available
482  if ( pNtk == NULL )
483  {
484  fprintf( stdout, "Empty network.\n" );
485  return;
486  }
487 
488  // read the base network
489  assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
490  if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIF )
491  pNtkBase = Io_ReadBlifMv( pBaseName, 0, 1 );
492  else if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV )
493  pNtkBase = Io_ReadBlifMv( pBaseName, 1, 1 );
494  else if ( Io_ReadFileType(pBaseName) == IO_FILE_VERILOG )
495  pNtkBase = Io_ReadVerilog( pBaseName, 1 );
496  else
497  fprintf( stderr, "Unknown input file format.\n" );
498  if ( pNtkBase == NULL )
499  return;
500 
501  // flatten logic hierarchy if present
502  if ( Abc_NtkWhiteboxNum(pNtkBase) > 0 && pNtk->nBarBufs == 0 )
503  {
504  pNtkBase = Abc_NtkFlattenLogicHierarchy( pNtkTemp = pNtkBase );
505  Abc_NtkDelete( pNtkTemp );
506  if ( pNtkBase == NULL )
507  return;
508  }
509 
510  // reintroduce the boxes into the netlist
511  if ( pNtk->nBarBufs > 0 )
512  {
513  // derive the netlist
514  pNtkResult = Abc_NtkToNetlist( pNtk );
515  pNtkResult = Abc_NtkFromBarBufs( pNtkBase, pNtkTemp = pNtkResult );
516  Abc_NtkDelete( pNtkTemp );
517  if ( pNtkResult )
518  printf( "Hierarchy writer replaced %d barbufs by hierarchy boundaries.\n", pNtk->nBarBufs );
519  }
520  else if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV )
521  {
522  if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
523  {
524  printf( "Hierarchy writer does not support BLIF-MV with blackboxes.\n" );
525  Abc_NtkDelete( pNtkBase );
526  return;
527  }
528  // convert the current network to BLIF-MV
529  assert( !Abc_NtkIsNetlist(pNtk) );
530  pNtkResult = Abc_NtkToNetlist( pNtk );
531  if ( !Abc_NtkConvertToBlifMv( pNtkResult ) )
532  {
533  Abc_NtkDelete( pNtkBase );
534  return;
535  }
536  // reintroduce the network
537  pNtkResult = Abc_NtkInsertBlifMv( pNtkBase, pNtkTemp = pNtkResult );
538  Abc_NtkDelete( pNtkTemp );
539  }
540  else if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
541  {
542  // derive the netlist
543  pNtkResult = Abc_NtkToNetlist( pNtk );
544  pNtkResult = Abc_NtkInsertNewLogic( pNtkBase, pNtkTemp = pNtkResult );
545  Abc_NtkDelete( pNtkTemp );
546  if ( pNtkResult )
547  printf( "Hierarchy writer reintroduced %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtkBase) );
548  }
549  else
550  {
551  printf( "Warning: The output network does not contain blackboxes.\n" );
552  pNtkResult = Abc_NtkToNetlist( pNtk );
553  }
554  Abc_NtkDelete( pNtkBase );
555  if ( pNtkResult == NULL )
556  return;
557 
558  // write the resulting network
559  if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF )
560  {
561  if ( pNtkResult->pDesign )
562  {
563  Vec_PtrForEachEntry( Abc_Ntk_t *, pNtkResult->pDesign->vModules, pNtkTemp, i )
564  if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
565  Abc_NtkToSop( pNtkTemp, 0 );
566  }
567  else
568  {
569  if ( !Abc_NtkHasSop(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
570  Abc_NtkToSop( pNtkResult, 0 );
571  }
572  Io_WriteBlif( pNtkResult, pFileName, 1, 0, 0 );
573  }
574  else if ( Io_ReadFileType(pFileName) == IO_FILE_VERILOG )
575  {
576  if ( pNtkResult->pDesign )
577  {
578  Vec_PtrForEachEntry( Abc_Ntk_t *, pNtkResult->pDesign->vModules, pNtkTemp, i )
579  if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
580  Abc_NtkToAig( pNtkTemp );
581  }
582  else
583  {
584  if ( !Abc_NtkHasAig(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
585  Abc_NtkToAig( pNtkResult );
586  }
587  Io_WriteVerilog( pNtkResult, pFileName );
588  }
589  else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
590  {
591  Io_WriteBlifMv( pNtkResult, pFileName );
592  }
593  else
594  fprintf( stderr, "Unknown output file format.\n" );
595 
596  Abc_NtkDelete( pNtkResult );
597 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Abc_Ntk_t * Io_ReadBlifMv(char *pFileName, int fBlifMv, int fCheck)
FUNCTION DEFINITIONS ///.
Definition: ioReadBlifMv.c:142
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
void Io_WriteVerilog(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
ABC_NAMESPACE_IMPL_START Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition: ioUtil.c:46
ABC_DLL Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy(Abc_Ntk_t *pNtk)
Definition: abcHie.c:514
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:84
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
ABC_DLL int Abc_NtkConvertToBlifMv(Abc_Ntk_t *pNtk)
Definition: abcBlifMv.c:954
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL Abc_Ntk_t * Abc_NtkInsertBlifMv(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtkLogic)
Definition: abcBlifMv.c:909
ABC_DLL Abc_Ntk_t * Abc_NtkFromBarBufs(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtk)
Definition: abcBarBuf.c:263
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Abc_Ntk_t * Io_ReadVerilog(char *pFileName, int fCheck)
DECLARATIONS ///.
Definition: ioReadVerilog.c:48
int nBarBufs
Definition: abc.h:174
void Io_WriteBlifMv(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
Definition: ioWriteBlifMv.c:58
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1192
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkHasAig(Abc_Ntk_t *pNtk)
Definition: abc.h:255
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
ABC_DLL Abc_Ntk_t * Abc_NtkInsertNewLogic(Abc_Ntk_t *pNtkH, Abc_Ntk_t *pNtkL)
Definition: abcHie.c:691
void Io_WriteList ( Abc_Ntk_t pNtk,
char *  pFileName,
int  fUseHost 
)

FUNCTION DEFINITIONS ///.

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file ioWriteList.c.

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

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes the network in PLA format.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioWritePla.c.

48 {
49  Abc_Ntk_t * pExdc;
50  FILE * pFile;
51 
52  assert( Abc_NtkIsSopNetlist(pNtk) );
53  assert( Abc_NtkLevel(pNtk) == 1 );
54 
55  pFile = fopen( pFileName, "w" );
56  if ( pFile == NULL )
57  {
58  fprintf( stdout, "Io_WritePla(): Cannot open the output file.\n" );
59  return 0;
60  }
61  fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
62  // write the network
63  Io_WritePlaOne( pFile, pNtk );
64  // write EXDC network if it exists
65  pExdc = Abc_NtkExdc( pNtk );
66  if ( pExdc )
67  printf( "Io_WritePla: EXDC is not written (warning).\n" );
68  // finalize the file
69  fclose( pFile );
70  return 1;
71 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
char * Extra_TimeStamp()
static int Abc_NtkIsSopNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:260
#define assert(ex)
Definition: util_old.h:213
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
char * pName
Definition: abc.h:158
static ABC_NAMESPACE_IMPL_START int Io_WritePlaOne(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWritePla.c:84
int Io_WriteSmv ( Abc_Ntk_t pNtk,
char *  pFileName 
)

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 parantheses 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 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
static int Io_WriteSmvOne(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteSmv.c:110
char * Extra_TimeStamp()
static int Abc_NtkIsSopNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:260
static ABC_NAMESPACE_IMPL_START int Io_WriteSmvCheckNames(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteSmv.c:247
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: abc.h:158
void Io_WriteTimingInfo ( FILE *  pFile,
Abc_Ntk_t pNtk 
)

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

Synopsis [Writes the timing info.]

Description []

SideEffects []

SeeAlso []

Definition at line 665 of file ioWriteBlif.c.

666 {
667  Abc_Obj_t * pNode;
668  Abc_Time_t * pTime, * pTimeDef;
669  int i;
670 
671  if ( pNtk->pManTime == NULL )
672  return;
673 
674  fprintf( pFile, "\n" );
675 
676  if ( pNtk->AndGateDelay != 0.0 )
677  fprintf( pFile, ".and_gate_delay %g\n", pNtk->AndGateDelay );
678 
679  pTimeDef = Abc_NtkReadDefaultArrival( pNtk );
680  if ( pTimeDef->Rise != 0.0 || pTimeDef->Fall != 0.0 )
681  fprintf( pFile, ".default_input_arrival %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
682  Abc_NtkForEachPi( pNtk, pNode, i )
683  {
684  pTime = Abc_NodeReadArrival(pNode);
685  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
686  continue;
687  fprintf( pFile, ".input_arrival %s %g %g\n", Abc_ObjName(Abc_ObjFanout0(pNode)), pTime->Rise, pTime->Fall );
688  }
689 
690  pTimeDef = Abc_NtkReadDefaultRequired( pNtk );
691  if ( pTimeDef->Rise != ABC_INFINITY || pTimeDef->Fall != ABC_INFINITY )
692  fprintf( pFile, ".default_output_required %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
693  Abc_NtkForEachPo( pNtk, pNode, i )
694  {
695  pTime = Abc_NodeReadRequired(pNode);
696  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
697  continue;
698  fprintf( pFile, ".output_required %s %g %g\n", Abc_ObjName(Abc_ObjFanin0(pNode)), pTime->Rise, pTime->Fall );
699  }
700 
701  fprintf( pFile, "\n" );
702 
703  pTimeDef = Abc_NtkReadDefaultInputDrive( pNtk );
704  if ( pTimeDef->Rise != 0.0 || pTimeDef->Fall != 0.0 )
705  fprintf( pFile, ".default_input_drive %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
706  if ( Abc_NodeReadInputDrive( pNtk, 0 ) )
707  Abc_NtkForEachPi( pNtk, pNode, i )
708  {
709  pTime = Abc_NodeReadInputDrive( pNtk, i );
710  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
711  continue;
712  fprintf( pFile, ".input_drive %s %g %g\n", Abc_ObjName(Abc_ObjFanout0(pNode)), pTime->Rise, pTime->Fall );
713  }
714 
715  pTimeDef = Abc_NtkReadDefaultOutputLoad( pNtk );
716  if ( pTimeDef->Rise != 0.0 || pTimeDef->Fall != 0.0 )
717  fprintf( pFile, ".default_output_load %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
718  if ( Abc_NodeReadOutputLoad( pNtk, 0 ) )
719  Abc_NtkForEachPo( pNtk, pNode, i )
720  {
721  pTime = Abc_NodeReadOutputLoad( pNtk, i );
722  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
723  continue;
724  fprintf( pFile, ".output_load %s %g %g\n", Abc_ObjName(Abc_ObjFanin0(pNode)), pTime->Rise, pTime->Fall );
725  }
726 
727  fprintf( pFile, "\n" );
728 }
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultArrival(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcTiming.c:67
float AndGateDelay
Definition: abc.h:194
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultRequired(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:72
ABC_DLL Abc_Time_t * Abc_NodeReadRequired(Abc_Obj_t *pNode)
Definition: abcTiming.c:82
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL Abc_Time_t * Abc_NodeReadArrival(Abc_Obj_t *pNode)
Definition: abcTiming.c:77
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultInputDrive(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:115
float Fall
Definition: abc.h:125
Abc_ManTime_t * pManTime
Definition: abc.h:192
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultOutputLoad(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:120
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
ABC_DLL Abc_Time_t * Abc_NodeReadInputDrive(Abc_Ntk_t *pNtk, int iPi)
Definition: abcTiming.c:125
float Rise
Definition: abc.h:124
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
ABC_DLL Abc_Time_t * Abc_NodeReadOutputLoad(Abc_Ntk_t *pNtk, int iPo)
Definition: abcTiming.c:130
void Io_WriteVerilog ( Abc_Ntk_t pNtk,
char *  pFileName 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Write verilog.]

Description []

SideEffects []

SeeAlso []

Definition at line 57 of file ioWriteVerilog.c.

58 {
59  Abc_Ntk_t * pNetlist;
60  FILE * pFile;
61  int i;
62  // can only write nodes represented using local AIGs
63  if ( !Abc_NtkIsAigNetlist(pNtk) && !Abc_NtkIsMappedNetlist(pNtk) )
64  {
65  printf( "Io_WriteVerilog(): Can produce Verilog for mapped or AIG netlists only.\n" );
66  return;
67  }
68  // start the output stream
69  pFile = fopen( pFileName, "w" );
70  if ( pFile == NULL )
71  {
72  fprintf( stdout, "Io_WriteVerilog(): Cannot open the output file \"%s\".\n", pFileName );
73  return;
74  }
75 
76  // write the equations for the network
77  fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
78  fprintf( pFile, "\n" );
79 
80  // write modules
81  if ( pNtk->pDesign )
82  {
83  // write the network first
84  Io_WriteVerilogInt( pFile, pNtk );
85  // write other things
86  Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNetlist, i )
87  {
88  assert( Abc_NtkIsNetlist(pNetlist) );
89  if ( pNetlist == pNtk )
90  continue;
91  fprintf( pFile, "\n" );
92  Io_WriteVerilogInt( pFile, pNetlist );
93  }
94  }
95  else
96  {
97  Io_WriteVerilogInt( pFile, pNtk );
98  }
99 
100  fprintf( pFile, "\n" );
101  fclose( pFile );
102 }
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static ABC_NAMESPACE_IMPL_START void Io_WriteVerilogInt(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
static int Abc_NtkIsAigNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:261
static int Abc_NtkIsMappedNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:262
char * Extra_TimeStamp()
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
char * pName
Definition: abc.h:158