abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigUtil.c File Reference
#include "aig.h"
#include "proof/fra/fra.h"
#include "aig/saig/saig.h"

Go to the source code of this file.

Macros

#define NUMBER1   3716960521u
 
#define NUMBER2   2174103536u
 

Functions

ABC_NAMESPACE_IMPL_START void Aig_ManIncrementTravId (Aig_Man_t *p)
 DECLARATIONS ///. More...
 
char * Aig_TimeStamp ()
 
int Aig_ManHasNoGaps (Aig_Man_t *p)
 
int Aig_ManLevels (Aig_Man_t *p)
 
void Aig_ManResetRefs (Aig_Man_t *p)
 
void Aig_ManCleanMarkA (Aig_Man_t *p)
 
void Aig_ManCleanMarkB (Aig_Man_t *p)
 
void Aig_ManCleanMarkAB (Aig_Man_t *p)
 
void Aig_ManCleanData (Aig_Man_t *p)
 
void Aig_ManCleanNext (Aig_Man_t *p)
 
void Aig_ObjCleanData_rec (Aig_Obj_t *pObj)
 
void Aig_ObjCollectMulti_rec (Aig_Obj_t *pRoot, Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
 
void Aig_ObjCollectMulti (Aig_Obj_t *pRoot, Vec_Ptr_t *vSuper)
 
int Aig_ObjIsMuxType (Aig_Obj_t *pNode)
 
int Aig_ObjRecognizeExor (Aig_Obj_t *pObj, Aig_Obj_t **ppFan0, Aig_Obj_t **ppFan1)
 
Aig_Obj_tAig_ObjRecognizeMux (Aig_Obj_t *pNode, Aig_Obj_t **ppNodeT, Aig_Obj_t **ppNodeE)
 
Aig_Obj_tAig_ObjReal_rec (Aig_Obj_t *pObj)
 
int Aig_ObjCompareIdIncrease (Aig_Obj_t **pp1, Aig_Obj_t **pp2)
 
void Aig_ObjPrintEqn (FILE *pFile, Aig_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
 
void Aig_ObjPrintVerilog (FILE *pFile, Aig_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
 
void Aig_ObjPrintVerbose (Aig_Obj_t *pObj, int fHaig)
 
void Aig_ManPrintVerbose (Aig_Man_t *p, int fHaig)
 
void Aig_ManDump (Aig_Man_t *p)
 
void Aig_ManDumpBlif (Aig_Man_t *p, char *pFileName, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vPoNames)
 
void Aig_ManDumpVerilog (Aig_Man_t *p, char *pFileName)
 
void Aig_ManSetCioIds (Aig_Man_t *p)
 
void Aig_ManCleanCioIds (Aig_Man_t *p)
 
int Aig_ManChoiceNum (Aig_Man_t *p)
 
void Aig_ManPrintControlFanouts (Aig_Man_t *p)
 
char * Aig_FileNameGenericAppend (char *pBase, char *pSuffix)
 
void Aig_ManRandomTest2 ()
 
void Aig_ManRandomTest1 ()
 
unsigned Aig_ManRandom (int fReset)
 GLOBAL VARIABLES ///. More...
 
word Aig_ManRandom64 (int fReset)
 
void Aig_ManRandomInfo (Vec_Ptr_t *vInfo, int iInputStart, int iWordStart, int iWordStop)
 
void Aig_NodeUnionLists (Vec_Ptr_t *vArr1, Vec_Ptr_t *vArr2, Vec_Ptr_t *vArr)
 
void Aig_NodeIntersectLists (Vec_Ptr_t *vArr1, Vec_Ptr_t *vArr2, Vec_Ptr_t *vArr)
 
ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START void 
Aig_ManCounterExampleValueStart (Aig_Man_t *pAig, Abc_Cex_t *pCex)
 
void Aig_ManCounterExampleValueStop (Aig_Man_t *pAig)
 
int Aig_ManCounterExampleValueLookup (Aig_Man_t *pAig, int Id, int iFrame)
 
void Aig_ManCounterExampleValueTest (Aig_Man_t *pAig, Abc_Cex_t *pCex)
 
void Aig_ManSetPhase (Aig_Man_t *pAig)
 
Vec_Ptr_tAig_ManMuxesCollect (Aig_Man_t *pAig)
 
void Aig_ManMuxesDeref (Aig_Man_t *pAig, Vec_Ptr_t *vMuxes)
 
void Aig_ManMuxesRef (Aig_Man_t *pAig, Vec_Ptr_t *vMuxes)
 
void Aig_ManInvertConstraints (Aig_Man_t *pAig)
 

Macro Definition Documentation

#define NUMBER1   3716960521u

Definition at line 1143 of file aigUtil.c.

#define NUMBER2   2174103536u

Definition at line 1144 of file aigUtil.c.

Function Documentation

char* Aig_FileNameGenericAppend ( char *  pBase,
char *  pSuffix 
)

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

Synopsis [Returns the composite name of the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 1070 of file aigUtil.c.

1071 {
1072  static char Buffer[1000];
1073  char * pDot;
1074  strcpy( Buffer, pBase );
1075  if ( (pDot = strrchr( Buffer, '.' )) )
1076  *pDot = 0;
1077  strcat( Buffer, pSuffix );
1078  if ( (pDot = strrchr( Buffer, '\\' )) || (pDot = strrchr( Buffer, '/' )) )
1079  return pDot+1;
1080  return Buffer;
1081 }
char * strcpy()
char * strcat()
char * strrchr()
int Aig_ManChoiceNum ( Aig_Man_t p)

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

Synopsis [Sets the PI/PO numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 1007 of file aigUtil.c.

1008 {
1009  Aig_Obj_t * pObj;
1010  int i, Counter = 0;
1011  Aig_ManForEachNode( p, pObj, i )
1012  Counter += Aig_ObjIsChoice( p, pObj );
1013  return Counter;
1014 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Definition: aig.h:69
static int Counter
static int Aig_ObjIsChoice(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:283
void Aig_ManCleanCioIds ( Aig_Man_t p)

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

Synopsis [Sets the PI/PO numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 986 of file aigUtil.c.

987 {
988  Aig_Obj_t * pObj;
989  int i;
990  Aig_ManForEachCi( p, pObj, i )
991  pObj->pNext = NULL;
992  Aig_ManForEachCo( p, pObj, i )
993  pObj->pNext = NULL;
994 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
Definition: aig.h:69
void Aig_ManCleanData ( Aig_Man_t p)

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

Synopsis [Cleans the data pointers for the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file aigUtil.c.

206 {
207  Aig_Obj_t * pObj;
208  int i;
209  Aig_ManForEachObj( p, pObj, i )
210  pObj->pData = NULL;
211 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void Aig_ManCleanMarkA ( Aig_Man_t p)

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

Synopsis [Cleans fMarkA.]

Description []

SideEffects []

SeeAlso []

Definition at line 148 of file aigUtil.c.

149 {
150  Aig_Obj_t * pObj;
151  int i;
152  Aig_ManForEachObj( p, pObj, i )
153  pObj->fMarkA = 0;
154 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void Aig_ManCleanMarkAB ( Aig_Man_t p)

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

Synopsis [Cleans fMarkB.]

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file aigUtil.c.

187 {
188  Aig_Obj_t * pObj;
189  int i;
190  Aig_ManForEachObj( p, pObj, i )
191  pObj->fMarkA = pObj->fMarkB = 0;
192 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void Aig_ManCleanMarkB ( Aig_Man_t p)

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

Synopsis [Cleans fMarkB.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file aigUtil.c.

168 {
169  Aig_Obj_t * pObj;
170  int i;
171  Aig_ManForEachObj( p, pObj, i )
172  pObj->fMarkB = 0;
173 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void Aig_ManCleanNext ( Aig_Man_t p)

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

Synopsis [Cleans the data pointers for the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file aigUtil.c.

225 {
226  Aig_Obj_t * pObj;
227  int i;
228  Aig_ManForEachObj( p, pObj, i )
229  pObj->pNext = NULL;
230 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
int Aig_ManCounterExampleValueLookup ( Aig_Man_t pAig,
int  Id,
int  iFrame 
)

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

Synopsis [Returns the value of the given object in the given timeframe.]

Description [Should be called to probe the value of an object with the given ID (iFrame is a 0-based number of a time frame - should not exceed the number of timeframes in the original counter-example).]

SideEffects []

SeeAlso []

Definition at line 1392 of file aigUtil.c.

1393 {
1394  assert( Id >= 0 && Id < Aig_ManObjNumMax(pAig) );
1395  return Abc_InfoHasBit( (unsigned *)pAig->pData2, Aig_ManObjNumMax(pAig) * iFrame + Id );
1396 }
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
#define assert(ex)
Definition: util_old.h:213
void Aig_ManCounterExampleValueStart ( Aig_Man_t pAig,
Abc_Cex_t pCex 
)

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

Synopsis [Starts the process of retuning values for internal nodes.]

Description [Should be called when pCex is available, before probing any object for its value using Aig_ManCounterExampleValueLookup().]

SideEffects []

SeeAlso []

Definition at line 1313 of file aigUtil.c.

1314 {
1315  Aig_Obj_t * pObj, * pObjRi, * pObjRo;
1316  int Val0, Val1, nObjs, i, k, iBit = 0;
1317  assert( Aig_ManRegNum(pAig) > 0 ); // makes sense only for sequential AIGs
1318  assert( pAig->pData2 == NULL ); // if this fail, there may be a memory leak
1319  // allocate memory to store simulation bits for internal nodes
1320  pAig->pData2 = ABC_CALLOC( unsigned, Abc_BitWordNum( (pCex->iFrame + 1) * Aig_ManObjNumMax(pAig) ) );
1321  // the register values in the counter-example should be zero
1322  Saig_ManForEachLo( pAig, pObj, k )
1323  assert( Abc_InfoHasBit(pCex->pData, iBit++) == 0 );
1324  // iterate through the timeframes
1325  nObjs = Aig_ManObjNumMax(pAig);
1326  for ( i = 0; i <= pCex->iFrame; i++ )
1327  {
1328  // set constant 1 node
1329  Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + 0 );
1330  // set primary inputs according to the counter-example
1331  Saig_ManForEachPi( pAig, pObj, k )
1332  if ( Abc_InfoHasBit(pCex->pData, iBit++) )
1333  Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
1334  // compute values for each node
1335  Aig_ManForEachNode( pAig, pObj, k )
1336  {
1337  Val0 = Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
1338  Val1 = Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId1(pObj) );
1339  if ( (Val0 ^ Aig_ObjFaninC0(pObj)) & (Val1 ^ Aig_ObjFaninC1(pObj)) )
1340  Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
1341  }
1342  // derive values for combinational outputs
1343  Aig_ManForEachCo( pAig, pObj, k )
1344  {
1345  Val0 = Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
1346  if ( Val0 ^ Aig_ObjFaninC0(pObj) )
1347  Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
1348  }
1349  if ( i == pCex->iFrame )
1350  continue;
1351  // transfer values to the register output of the next frame
1352  Saig_ManForEachLiLo( pAig, pObjRi, pObjRo, k )
1353  if ( Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObjRi) ) )
1354  Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * (i+1) + Aig_ObjId(pObjRo) );
1355  }
1356  assert( iBit == pCex->nBits );
1357  // check that the counter-example is correct, that is, the corresponding output is asserted
1358  assert( Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * pCex->iFrame + Aig_ObjId(Aig_ManCo(pAig, pCex->iPo)) ) );
1359 }
static int Aig_ObjFaninId0(Aig_Obj_t *pObj)
Definition: aig.h:304
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static int Aig_ObjFaninId1(Aig_Obj_t *pObj)
Definition: aig.h:305
for(p=first;p->value< newval;p=p->next)
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
#define assert(ex)
Definition: util_old.h:213
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91
void Aig_ManCounterExampleValueStop ( Aig_Man_t pAig)

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

Synopsis [Stops the process of retuning values for internal nodes.]

Description [Should be called when probing is no longer needed]

SideEffects []

SeeAlso []

Definition at line 1372 of file aigUtil.c.

1373 {
1374  assert( pAig->pData2 != NULL ); // if this fail, we try to call this procedure more than once
1375  free( pAig->pData2 );
1376  pAig->pData2 = NULL;
1377 }
VOID_HACK free()
#define assert(ex)
Definition: util_old.h:213
void Aig_ManCounterExampleValueTest ( Aig_Man_t pAig,
Abc_Cex_t pCex 
)

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

Synopsis [Procedure to test the above code.]

Description []

SideEffects []

SeeAlso []

Definition at line 1409 of file aigUtil.c.

1410 {
1411  Aig_Obj_t * pObj = Aig_ManObj( pAig, Aig_ManObjNumMax(pAig)/2 );
1412  int iFrame = Abc_MaxInt( 0, pCex->iFrame - 1 );
1413  printf( "\nUsing counter-example, which asserts output %d in frame %d.\n", pCex->iPo, pCex->iFrame );
1414  Aig_ManCounterExampleValueStart( pAig, pCex );
1415  printf( "Value of object %d in frame %d is %d.\n", Aig_ObjId(pObj), iFrame,
1416  Aig_ManCounterExampleValueLookup(pAig, Aig_ObjId(pObj), iFrame) );
1418 }
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START void Aig_ManCounterExampleValueStart(Aig_Man_t *pAig, Abc_Cex_t *pCex)
Definition: aigUtil.c:1313
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
void Aig_ManCounterExampleValueStop(Aig_Man_t *pAig)
Definition: aigUtil.c:1372
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
int Aig_ManCounterExampleValueLookup(Aig_Man_t *pAig, int Id, int iFrame)
Definition: aigUtil.c:1392
void Aig_ManDump ( Aig_Man_t p)

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

Synopsis [Write speculative miter for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 712 of file aigUtil.c.

713 {
714  static int Counter = 0;
715  char FileName[20];
716  // dump the logic into a file
717  sprintf( FileName, "aigbug\\%03d.blif", ++Counter );
718  Aig_ManDumpBlif( p, FileName, NULL, NULL );
719  printf( "Intermediate AIG with %d nodes was written into file \"%s\".\n", Aig_ManNodeNum(p), FileName );
720 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManDumpBlif(Aig_Man_t *p, char *pFileName, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vPoNames)
Definition: aigUtil.c:733
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
char * sprintf()
static int Counter
void Aig_ManDumpBlif ( Aig_Man_t p,
char *  pFileName,
Vec_Ptr_t vPiNames,
Vec_Ptr_t vPoNames 
)

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

Synopsis [Writes the AIG into a BLIF file.]

Description []

SideEffects []

SeeAlso []

Definition at line 733 of file aigUtil.c.

734 {
735  FILE * pFile;
736  Vec_Ptr_t * vNodes;
737  Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pConst1 = NULL;
738  int i, nDigits, Counter = 0;
739  if ( Aig_ManCoNum(p) == 0 )
740  {
741  printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
742  return;
743  }
744  // check if constant is used
745  Aig_ManForEachCo( p, pObj, i )
746  if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
747  pConst1 = Aig_ManConst1(p);
748  // collect nodes in the DFS order
749  vNodes = Aig_ManDfs( p, 1 );
750  // assign IDs to objects
751  Aig_ManConst1(p)->iData = Counter++;
752  Aig_ManForEachCi( p, pObj, i )
753  pObj->iData = Counter++;
754  Aig_ManForEachCo( p, pObj, i )
755  pObj->iData = Counter++;
756  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
757  pObj->iData = Counter++;
758  nDigits = Abc_Base10Log( Counter );
759  // write the file
760  pFile = fopen( pFileName, "w" );
761  fprintf( pFile, "# BLIF file written by procedure Aig_ManDumpBlif()\n" );
762 // fprintf( pFile, "# http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
763  fprintf( pFile, ".model %s\n", p->pName );
764  // write PIs
765  fprintf( pFile, ".inputs" );
766  Aig_ManForEachPiSeq( p, pObj, i )
767  if ( vPiNames )
768  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, i) );
769  else
770  fprintf( pFile, " n%0*d", nDigits, pObj->iData );
771  fprintf( pFile, "\n" );
772  // write POs
773  fprintf( pFile, ".outputs" );
774  Aig_ManForEachPoSeq( p, pObj, i )
775  if ( vPoNames )
776  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPoNames, i) );
777  else
778  fprintf( pFile, " n%0*d", nDigits, pObj->iData );
779  fprintf( pFile, "\n" );
780  // write latches
781  if ( Aig_ManRegNum(p) )
782  {
783  fprintf( pFile, "\n" );
784  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
785  {
786  fprintf( pFile, ".latch" );
787  if ( vPoNames )
788  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPoNames, Aig_ManCoNum(p)-Aig_ManRegNum(p)+i) );
789  else
790  fprintf( pFile, " n%0*d", nDigits, pObjLi->iData );
791  if ( vPiNames )
792  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ManCiNum(p)-Aig_ManRegNum(p)+i) );
793  else
794  fprintf( pFile, " n%0*d", nDigits, pObjLo->iData );
795  fprintf( pFile, " 0\n" );
796  }
797  fprintf( pFile, "\n" );
798  }
799  // write nodes
800  if ( pConst1 )
801  fprintf( pFile, ".names n%0*d\n 1\n", nDigits, pConst1->iData );
802  Aig_ManSetCioIds( p );
803  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
804  {
805  fprintf( pFile, ".names" );
806  if ( vPiNames && Aig_ObjIsCi(Aig_ObjFanin0(pObj)) )
807  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ObjCioId(Aig_ObjFanin0(pObj))) );
808  else
809  fprintf( pFile, " n%0*d", nDigits, Aig_ObjFanin0(pObj)->iData );
810  if ( vPiNames && Aig_ObjIsCi(Aig_ObjFanin1(pObj)) )
811  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ObjCioId(Aig_ObjFanin1(pObj))) );
812  else
813  fprintf( pFile, " n%0*d", nDigits, Aig_ObjFanin1(pObj)->iData );
814  fprintf( pFile, " n%0*d\n", nDigits, pObj->iData );
815  fprintf( pFile, "%d%d 1\n", !Aig_ObjFaninC0(pObj), !Aig_ObjFaninC1(pObj) );
816  }
817  // write POs
818  Aig_ManForEachCo( p, pObj, i )
819  {
820  fprintf( pFile, ".names" );
821  if ( vPiNames && Aig_ObjIsCi(Aig_ObjFanin0(pObj)) )
822  fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ObjCioId(Aig_ObjFanin0(pObj))) );
823  else
824  fprintf( pFile, " n%0*d", nDigits, Aig_ObjFanin0(pObj)->iData );
825  if ( vPoNames )
826  fprintf( pFile, " %s\n", (char*)Vec_PtrEntry(vPoNames, Aig_ObjCioId(pObj)) );
827  else
828  fprintf( pFile, " n%0*d\n", nDigits, pObj->iData );
829  fprintf( pFile, "%d 1\n", !Aig_ObjFaninC0(pObj) );
830  }
831  Aig_ManCleanCioIds( p );
832  fprintf( pFile, ".end\n\n" );
833  fclose( pFile );
834  Vec_PtrFree( vNodes );
835 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition: aigUtil.c:965
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition: aig.h:450
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
if(last==0)
Definition: sparse_int.h:34
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
else
Definition: sparse_int.h:55
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition: aigDfs.c:145
Definition: aig.h:69
static int Counter
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int iData
Definition: aig.h:88
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition: aig.h:444
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
void Aig_ManCleanCioIds(Aig_Man_t *p)
Definition: aigUtil.c:986
static int Aig_ObjCioId(Aig_Obj_t *pObj)
Definition: aig.h:285
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Aig_ManDumpVerilog ( Aig_Man_t p,
char *  pFileName 
)

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

Synopsis [Writes the AIG into a Verilog file.]

Description []

SideEffects []

SeeAlso []

Definition at line 848 of file aigUtil.c.

849 {
850  FILE * pFile;
851  Vec_Ptr_t * vNodes;
852  Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pConst1 = NULL;
853  int i, nDigits, Counter = 0;
854  if ( Aig_ManCoNum(p) == 0 )
855  {
856  printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
857  return;
858  }
859  // check if constant is used
860  Aig_ManForEachCo( p, pObj, i )
861  if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
862  pConst1 = Aig_ManConst1(p);
863  // collect nodes in the DFS order
864  vNodes = Aig_ManDfs( p, 1 );
865  // assign IDs to objects
866  Aig_ManConst1(p)->iData = Counter++;
867  Aig_ManForEachCi( p, pObj, i )
868  pObj->iData = Counter++;
869  Aig_ManForEachCo( p, pObj, i )
870  pObj->iData = Counter++;
871  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
872  pObj->iData = Counter++;
873  nDigits = Abc_Base10Log( Counter );
874  // write the file
875  pFile = fopen( pFileName, "w" );
876  fprintf( pFile, "// Verilog file written by procedure Aig_ManDumpVerilog()\n" );
877 // fprintf( pFile, "// http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
878  if ( Aig_ManRegNum(p) )
879  fprintf( pFile, "module %s ( clock", p->pName? p->pName: "test" );
880  else
881  fprintf( pFile, "module %s (", p->pName? p->pName: "test" );
882  Aig_ManForEachPiSeq( p, pObj, i )
883  fprintf( pFile, "%s n%0*d", ((Aig_ManRegNum(p) || i)? ",":""), nDigits, pObj->iData );
884  Aig_ManForEachPoSeq( p, pObj, i )
885  fprintf( pFile, ", n%0*d", nDigits, pObj->iData );
886  fprintf( pFile, " );\n" );
887 
888  // write PIs
889  if ( Aig_ManRegNum(p) )
890  fprintf( pFile, "input clock;\n" );
891  Aig_ManForEachPiSeq( p, pObj, i )
892  fprintf( pFile, "input n%0*d;\n", nDigits, pObj->iData );
893  // write POs
894  Aig_ManForEachPoSeq( p, pObj, i )
895  fprintf( pFile, "output n%0*d;\n", nDigits, pObj->iData );
896  // write latches
897  if ( Aig_ManRegNum(p) )
898  {
899  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
900  fprintf( pFile, "reg n%0*d;\n", nDigits, pObjLo->iData );
901  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
902  fprintf( pFile, "wire n%0*d;\n", nDigits, pObjLi->iData );
903  }
904  // write nodes
905  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
906  fprintf( pFile, "wire n%0*d;\n", nDigits, pObj->iData );
907  if ( pConst1 )
908  fprintf( pFile, "wire n%0*d;\n", nDigits, pConst1->iData );
909  // write nodes
910  if ( pConst1 )
911  fprintf( pFile, "assign n%0*d = 1\'b1;\n", nDigits, pConst1->iData );
912  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
913  {
914  fprintf( pFile, "assign n%0*d = %sn%0*d & %sn%0*d;\n",
915  nDigits, pObj->iData,
916  !Aig_ObjFaninC0(pObj) ? " " : "~", nDigits, Aig_ObjFanin0(pObj)->iData,
917  !Aig_ObjFaninC1(pObj) ? " " : "~", nDigits, Aig_ObjFanin1(pObj)->iData
918  );
919  }
920  // write POs
921  Aig_ManForEachPoSeq( p, pObj, i )
922  {
923  fprintf( pFile, "assign n%0*d = %sn%0*d;\n",
924  nDigits, pObj->iData,
925  !Aig_ObjFaninC0(pObj) ? " " : "~", nDigits, Aig_ObjFanin0(pObj)->iData );
926  }
927  if ( Aig_ManRegNum(p) )
928  {
929  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
930  {
931  fprintf( pFile, "assign n%0*d = %sn%0*d;\n",
932  nDigits, pObjLi->iData,
933  !Aig_ObjFaninC0(pObjLi) ? " " : "~", nDigits, Aig_ObjFanin0(pObjLi)->iData );
934  }
935  }
936 
937  // write initial state
938  if ( Aig_ManRegNum(p) )
939  {
940  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
941  fprintf( pFile, "always @ (posedge clock) begin n%0*d <= n%0*d; end\n",
942  nDigits, pObjLo->iData,
943  nDigits, pObjLi->iData );
944  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
945  fprintf( pFile, "initial begin n%0*d <= 1\'b0; end\n",
946  nDigits, pObjLo->iData );
947  }
948 
949  fprintf( pFile, "endmodule\n\n" );
950  fclose( pFile );
951  Vec_PtrFree( vNodes );
952 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define b1
Definition: extraBdd.h:76
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition: aig.h:450
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
if(last==0)
Definition: sparse_int.h:34
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
else
Definition: sparse_int.h:55
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition: aigDfs.c:145
Definition: aig.h:69
static int Counter
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define b0
Definition: extraBdd.h:75
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition: aig.h:444
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Aig_ManHasNoGaps ( Aig_Man_t p)

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

Synopsis [Make sure AIG has not gaps in the numeric order.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file aigUtil.c.

87 {
88  return (int)(Aig_ManObjNum(p) == Aig_ManCiNum(p) + Aig_ManCoNum(p) + Aig_ManNodeNum(p) + 1);
89 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ManObjNum(Aig_Man_t *p)
Definition: aig.h:258
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
ABC_NAMESPACE_IMPL_START void Aig_ManIncrementTravId ( Aig_Man_t p)

DECLARATIONS ///.

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

FileName [aigUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Various procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigUtil.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

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

Synopsis [Increments the current traversal ID of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file aigUtil.c.

45 {
46  if ( p->nTravIds >= (1<<30)-1 )
48  p->nTravIds++;
49 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
void Aig_ManInvertConstraints ( Aig_Man_t pAig)

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

Synopsis [Complements the constraint outputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1543 of file aigUtil.c.

1544 {
1545  Aig_Obj_t * pObj;
1546  int i;
1547  if ( Aig_ManConstrNum(pAig) == 0 )
1548  return;
1549  Saig_ManForEachPo( pAig, pObj, i )
1550  {
1551  if ( i >= Saig_ManPoNum(pAig) - Aig_ManConstrNum(pAig) )
1552  Aig_ObjChild0Flip( pObj );
1553  }
1554 }
static int Aig_ManConstrNum(Aig_Man_t *p)
Definition: aig.h:261
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
Definition: aig.h:69
static void Aig_ObjChild0Flip(Aig_Obj_t *pObj)
Definition: aig.h:316
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
int Aig_ManLevels ( Aig_Man_t p)

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

Synopsis [Collect the latches.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file aigUtil.c.

103 {
104  Aig_Obj_t * pObj;
105  int i, LevelMax = 0;
106  Aig_ManForEachCo( p, pObj, i )
107  LevelMax = Abc_MaxInt( LevelMax, (int)Aig_ObjFanin0(pObj)->Level );
108  return LevelMax;
109 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Definition: aig.h:69
Vec_Ptr_t* Aig_ManMuxesCollect ( Aig_Man_t pAig)

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

Synopsis [Collects muxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1460 of file aigUtil.c.

1461 {
1462  Vec_Ptr_t * vMuxes;
1463  Aig_Obj_t * pObj;
1464  int i;
1465  vMuxes = Vec_PtrAlloc( 100 );
1466  Aig_ManForEachNode( pAig, pObj, i )
1467  if ( Aig_ObjIsMuxType(pObj) )
1468  Vec_PtrPush( vMuxes, pObj );
1469  return vMuxes;
1470 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
int Aig_ObjIsMuxType(Aig_Obj_t *pNode)
Definition: aigUtil.c:307
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Aig_ManMuxesDeref ( Aig_Man_t pAig,
Vec_Ptr_t vMuxes 
)

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

Synopsis [Dereferences muxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1483 of file aigUtil.c.

1484 {
1485  Aig_Obj_t * pObj, * pNodeT, * pNodeE, * pNodeC;
1486  int i;
1487  Vec_PtrForEachEntry( Aig_Obj_t *, vMuxes, pObj, i )
1488  {
1489  if ( Aig_ObjRecognizeExor( pObj, &pNodeT, &pNodeE ) )
1490  {
1491  pNodeT->nRefs--;
1492  pNodeE->nRefs--;
1493  }
1494  else
1495  {
1496  pNodeC = Aig_ObjRecognizeMux( pObj, &pNodeT, &pNodeE );
1497  pNodeC->nRefs--;
1498  }
1499  }
1500 }
int Aig_ObjRecognizeExor(Aig_Obj_t *pObj, Aig_Obj_t **ppFan0, Aig_Obj_t **ppFan1)
Definition: aigUtil.c:343
Definition: aig.h:69
Aig_Obj_t * Aig_ObjRecognizeMux(Aig_Obj_t *pNode, Aig_Obj_t **ppNodeT, Aig_Obj_t **ppNodeE)
Definition: aigUtil.c:387
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
unsigned int nRefs
Definition: aig.h:81
void Aig_ManMuxesRef ( Aig_Man_t pAig,
Vec_Ptr_t vMuxes 
)

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

Synopsis [References muxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1513 of file aigUtil.c.

1514 {
1515  Aig_Obj_t * pObj, * pNodeT, * pNodeE, * pNodeC;
1516  int i;
1517  Vec_PtrForEachEntry( Aig_Obj_t *, vMuxes, pObj, i )
1518  {
1519  if ( Aig_ObjRecognizeExor( pObj, &pNodeT, &pNodeE ) )
1520  {
1521  pNodeT->nRefs++;
1522  pNodeE->nRefs++;
1523  }
1524  else
1525  {
1526  pNodeC = Aig_ObjRecognizeMux( pObj, &pNodeT, &pNodeE );
1527  pNodeC->nRefs++;
1528  }
1529  }
1530 }
int Aig_ObjRecognizeExor(Aig_Obj_t *pObj, Aig_Obj_t **ppFan0, Aig_Obj_t **ppFan1)
Definition: aigUtil.c:343
Definition: aig.h:69
Aig_Obj_t * Aig_ObjRecognizeMux(Aig_Obj_t *pNode, Aig_Obj_t **ppNodeT, Aig_Obj_t **ppNodeE)
Definition: aigUtil.c:387
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
unsigned int nRefs
Definition: aig.h:81
void Aig_ManPrintControlFanouts ( Aig_Man_t p)

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

Synopsis [Prints the fanouts of the control register.]

Description [Useful only for Intel MC benchmarks.]

SideEffects []

SeeAlso []

Definition at line 1027 of file aigUtil.c.

1028 {
1029  Aig_Obj_t * pObj, * pFanin0, * pFanin1, * pCtrl;
1030  int i;
1031 
1032  pCtrl = Aig_ManCi( p, Aig_ManCiNum(p) - 1 );
1033 
1034  printf( "Control signal:\n" );
1035  Aig_ObjPrint( p, pCtrl ); printf( "\n\n" );
1036 
1037  Aig_ManForEachObj( p, pObj, i )
1038  {
1039  if ( !Aig_ObjIsNode(pObj) )
1040  continue;
1041  assert( pObj != pCtrl );
1042  pFanin0 = Aig_ObjFanin0(pObj);
1043  pFanin1 = Aig_ObjFanin1(pObj);
1044  if ( pFanin0 == pCtrl && Aig_ObjIsCi(pFanin1) )
1045  {
1046  Aig_ObjPrint( p, pObj ); printf( "\n" );
1047  Aig_ObjPrint( p, pFanin1 ); printf( "\n" );
1048  printf( "\n" );
1049  }
1050  if ( pFanin1 == pCtrl && Aig_ObjIsCi(pFanin0) )
1051  {
1052  Aig_ObjPrint( p, pObj ); printf( "\n" );
1053  Aig_ObjPrint( p, pFanin0 ); printf( "\n" );
1054  printf( "\n" );
1055  }
1056  }
1057 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
void Aig_ObjPrint(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:316
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
void Aig_ManPrintVerbose ( Aig_Man_t p,
int  fHaig 
)

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

Synopsis [Prints node in HAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 685 of file aigUtil.c.

686 {
687  Vec_Ptr_t * vNodes;
688  Aig_Obj_t * pObj;
689  int i;
690  printf( "PIs: " );
691  Aig_ManForEachCi( p, pObj, i )
692  printf( " %p", pObj );
693  printf( "\n" );
694  vNodes = Aig_ManDfs( p, 0 );
695  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
696  Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
697  printf( "\n" );
698  Vec_PtrFree( vNodes );
699 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
void Aig_ObjPrintVerbose(Aig_Obj_t *pObj, int fHaig)
Definition: aigUtil.c:653
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition: aigDfs.c:145
Definition: aig.h:69
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
unsigned Aig_ManRandom ( int  fReset)

GLOBAL VARIABLES ///.

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

SeeAlso [http://www.codeproject.com/KB/recipes/SimpleRNG.aspx]

Definition at line 1157 of file aigUtil.c.

1158 {
1159  static unsigned int m_z = NUMBER1;
1160  static unsigned int m_w = NUMBER2;
1161  if ( fReset )
1162  {
1163  m_z = NUMBER1;
1164  m_w = NUMBER2;
1165  }
1166  m_z = 36969 * (m_z & 65535) + (m_z >> 16);
1167  m_w = 18000 * (m_w & 65535) + (m_w >> 16);
1168  return (m_z << 16) + m_w;
1169 }
#define NUMBER1
Definition: aigUtil.c:1143
#define NUMBER2
Definition: aigUtil.c:1144
word Aig_ManRandom64 ( int  fReset)

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 1182 of file aigUtil.c.

1183 {
1184  word Res = (word)Aig_ManRandom(fReset);
1185  return Res | ((word)Aig_ManRandom(0) << 32);
1186 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
unsigned Aig_ManRandom(int fReset)
GLOBAL VARIABLES ///.
Definition: aigUtil.c:1157
void Aig_ManRandomInfo ( Vec_Ptr_t vInfo,
int  iInputStart,
int  iWordStart,
int  iWordStop 
)

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

Synopsis [Creates random info for the primary inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1200 of file aigUtil.c.

1201 {
1202  unsigned * pInfo;
1203  int i, w;
1204  Vec_PtrForEachEntryStart( unsigned *, vInfo, pInfo, i, iInputStart )
1205  for ( w = iWordStart; w < iWordStop; w++ )
1206  pInfo[w] = Aig_ManRandom(0);
1207 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
for(p=first;p->value< newval;p=p->next)
unsigned Aig_ManRandom(int fReset)
GLOBAL VARIABLES ///.
Definition: aigUtil.c:1157
void Aig_ManRandomTest1 ( )

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

SeeAlso [http://www.codeproject.com/KB/recipes/SimpleRNG.aspx]

Definition at line 1124 of file aigUtil.c.

1125 {
1126  FILE * pFile;
1127  unsigned int lfsr;
1128  unsigned int period = 0;
1129  pFile = fopen( "rand.txt", "w" );
1130  do {
1131  lfsr = Aig_ManRandom( 0 );
1132  ++period;
1133  fprintf( pFile, "%10d : %10d ", period, lfsr );
1134 // Extra_PrintBinary( pFile, &lfsr, 32 );
1135  fprintf( pFile, "\n" );
1136  if ( period == 20000 )
1137  break;
1138  } while(lfsr != 1u);
1139  fclose( pFile );
1140 }
unsigned Aig_ManRandom(int fReset)
GLOBAL VARIABLES ///.
Definition: aigUtil.c:1157
void Aig_ManRandomTest2 ( )

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

SeeAlso [http://en.wikipedia.org/wiki/LFSR]

Definition at line 1094 of file aigUtil.c.

1095 {
1096  FILE * pFile;
1097  unsigned int lfsr = 1;
1098  unsigned int period = 0;
1099  pFile = fopen( "rand.txt", "w" );
1100  do {
1101 // lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xd0000001u); // taps 32 31 29 1
1102  lfsr = 1; // to prevent the warning
1103  ++period;
1104  fprintf( pFile, "%10d : %10d ", period, lfsr );
1105 // Extra_PrintBinary( pFile, &lfsr, 32 );
1106  fprintf( pFile, "\n" );
1107  if ( period == 20000 )
1108  break;
1109  } while(lfsr != 1u);
1110  fclose( pFile );
1111 }
void Aig_ManResetRefs ( Aig_Man_t p)

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

Synopsis [Reset reference counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 122 of file aigUtil.c.

123 {
124  Aig_Obj_t * pObj;
125  int i;
126  Aig_ManForEachObj( p, pObj, i )
127  pObj->nRefs = 0;
128  Aig_ManForEachObj( p, pObj, i )
129  {
130  if ( Aig_ObjFanin0(pObj) )
131  Aig_ObjFanin0(pObj)->nRefs++;
132  if ( Aig_ObjFanin1(pObj) )
133  Aig_ObjFanin1(pObj)->nRefs++;
134  }
135 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
unsigned int nRefs
Definition: aig.h:81
void Aig_ManSetCioIds ( Aig_Man_t p)

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

Synopsis [Sets the PI/PO numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 965 of file aigUtil.c.

966 {
967  Aig_Obj_t * pObj;
968  int i;
969  Aig_ManForEachCi( p, pObj, i )
970  pObj->CioId = i;
971  Aig_ManForEachCo( p, pObj, i )
972  pObj->CioId = i;
973 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
Definition: aig.h:69
void Aig_ManSetPhase ( Aig_Man_t pAig)

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

Synopsis [Handle the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 1431 of file aigUtil.c.

1432 {
1433  Aig_Obj_t * pObj;
1434  int i;
1435  // set the PI simulation information
1436  Aig_ManConst1( pAig )->fPhase = 1;
1437  Aig_ManForEachCi( pAig, pObj, i )
1438  pObj->fPhase = 0;
1439  // simulate internal nodes
1440  Aig_ManForEachNode( pAig, pObj, i )
1441  pObj->fPhase = ( Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj) )
1442  & ( Aig_ObjFanin1(pObj)->fPhase ^ Aig_ObjFaninC1(pObj) );
1443  // simulate PO nodes
1444  Aig_ManForEachCo( pAig, pObj, i )
1445  pObj->fPhase = Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj);
1446 }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#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
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
unsigned int fPhase
Definition: aig.h:78
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
void Aig_NodeIntersectLists ( Vec_Ptr_t vArr1,
Vec_Ptr_t vArr2,
Vec_Ptr_t vArr 
)

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

Synopsis [Returns the result of intersecting the two vectors.]

Description [Assumes that the vectors are sorted in the increasing order.]

SideEffects []

SeeAlso []

Definition at line 1259 of file aigUtil.c.

1260 {
1261  Aig_Obj_t ** pBeg = (Aig_Obj_t **)vArr->pArray;
1262  Aig_Obj_t ** pBeg1 = (Aig_Obj_t **)vArr1->pArray;
1263  Aig_Obj_t ** pBeg2 = (Aig_Obj_t **)vArr2->pArray;
1264  Aig_Obj_t ** pEnd1 = (Aig_Obj_t **)vArr1->pArray + vArr1->nSize;
1265  Aig_Obj_t ** pEnd2 = (Aig_Obj_t **)vArr2->pArray + vArr2->nSize;
1266  Vec_PtrGrow( vArr, Abc_MaxInt( Vec_PtrSize(vArr1), Vec_PtrSize(vArr2) ) );
1267  pBeg = (Aig_Obj_t **)vArr->pArray;
1268  while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
1269  {
1270  if ( (*pBeg1)->Id == (*pBeg2)->Id )
1271  *pBeg++ = *pBeg1++, pBeg2++;
1272  else if ( (*pBeg1)->Id < (*pBeg2)->Id )
1273 // *pBeg++ = *pBeg1++;
1274  pBeg1++;
1275  else
1276 // *pBeg++ = *pBeg2++;
1277  pBeg2++;
1278  }
1279 // while ( pBeg1 < pEnd1 )
1280 // *pBeg++ = *pBeg1++;
1281 // while ( pBeg2 < pEnd2 )
1282 // *pBeg++ = *pBeg2++;
1283  vArr->nSize = pBeg - (Aig_Obj_t **)vArr->pArray;
1284  assert( vArr->nSize <= vArr->nCap );
1285  assert( vArr->nSize <= vArr1->nSize );
1286  assert( vArr->nSize <= vArr2->nSize );
1287 }
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
Definition: vecPtr.h:430
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
void Aig_NodeUnionLists ( Vec_Ptr_t vArr1,
Vec_Ptr_t vArr2,
Vec_Ptr_t vArr 
)

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

Synopsis [Returns the result of merging the two vectors.]

Description [Assumes that the vectors are sorted in the increasing order.]

SideEffects []

SeeAlso []

Definition at line 1220 of file aigUtil.c.

1221 {
1222  Aig_Obj_t ** pBeg = (Aig_Obj_t **)vArr->pArray;
1223  Aig_Obj_t ** pBeg1 = (Aig_Obj_t **)vArr1->pArray;
1224  Aig_Obj_t ** pBeg2 = (Aig_Obj_t **)vArr2->pArray;
1225  Aig_Obj_t ** pEnd1 = (Aig_Obj_t **)vArr1->pArray + vArr1->nSize;
1226  Aig_Obj_t ** pEnd2 = (Aig_Obj_t **)vArr2->pArray + vArr2->nSize;
1227  Vec_PtrGrow( vArr, Vec_PtrSize(vArr1) + Vec_PtrSize(vArr2) );
1228  pBeg = (Aig_Obj_t **)vArr->pArray;
1229  while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
1230  {
1231  if ( (*pBeg1)->Id == (*pBeg2)->Id )
1232  *pBeg++ = *pBeg1++, pBeg2++;
1233  else if ( (*pBeg1)->Id < (*pBeg2)->Id )
1234  *pBeg++ = *pBeg1++;
1235  else
1236  *pBeg++ = *pBeg2++;
1237  }
1238  while ( pBeg1 < pEnd1 )
1239  *pBeg++ = *pBeg1++;
1240  while ( pBeg2 < pEnd2 )
1241  *pBeg++ = *pBeg2++;
1242  vArr->nSize = pBeg - (Aig_Obj_t **)vArr->pArray;
1243  assert( vArr->nSize <= vArr->nCap );
1244  assert( vArr->nSize >= vArr1->nSize );
1245  assert( vArr->nSize >= vArr2->nSize );
1246 }
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
Definition: vecPtr.h:430
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjCleanData_rec ( Aig_Obj_t pObj)

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

Synopsis [Recursively cleans the data pointers in the cone of the node.]

Description [Applicable to small AIGs only because no caching is performed.]

SideEffects []

SeeAlso []

Definition at line 243 of file aigUtil.c.

244 {
245  assert( !Aig_IsComplement(pObj) );
246  assert( !Aig_ObjIsCo(pObj) );
247  if ( Aig_ObjIsAnd(pObj) )
248  {
251  }
252  pObj->pData = NULL;
253 }
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
void Aig_ObjCleanData_rec(Aig_Obj_t *pObj)
Definition: aigUtil.c:243
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
static int Aig_ObjIsAnd(Aig_Obj_t *pObj)
Definition: aig.h:278
void Aig_ObjCollectMulti ( Aig_Obj_t pRoot,
Vec_Ptr_t vSuper 
)

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

Synopsis [Detects multi-input gate rooted at this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file aigUtil.c.

290 {
291  assert( !Aig_IsComplement(pRoot) );
292  Vec_PtrClear( vSuper );
293  Aig_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
294 }
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
void Aig_ObjCollectMulti_rec(Aig_Obj_t *pRoot, Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
Definition: aigUtil.c:267
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Aig_ObjCollectMulti_rec ( Aig_Obj_t pRoot,
Aig_Obj_t pObj,
Vec_Ptr_t vSuper 
)

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

Synopsis [Detects multi-input gate rooted at this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 267 of file aigUtil.c.

268 {
269  if ( pRoot != pObj && (Aig_IsComplement(pObj) || Aig_ObjIsCi(pObj) || Aig_ObjType(pRoot) != Aig_ObjType(pObj)) )
270  {
271  Vec_PtrPushUnique(vSuper, pObj);
272  return;
273  }
274  Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
275  Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
276 }
static Aig_Type_t Aig_ObjType(Aig_Obj_t *pObj)
Definition: aig.h:272
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
void Aig_ObjCollectMulti_rec(Aig_Obj_t *pRoot, Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
Definition: aigUtil.c:267
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Aig_ObjCompareIdIncrease ( Aig_Obj_t **  pp1,
Aig_Obj_t **  pp2 
)

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

Synopsis [Procedure used for sorting the nodes in increasing order of IDs.]

Description []

SideEffects []

SeeAlso []

Definition at line 496 of file aigUtil.c.

497 {
498  int Diff = Aig_ObjId(*pp1) - Aig_ObjId(*pp2);
499  if ( Diff < 0 )
500  return -1;
501  if ( Diff > 0 )
502  return 1;
503  return 0;
504 }
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
int Aig_ObjIsMuxType ( Aig_Obj_t pNode)

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

Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file aigUtil.c.

308 {
309  Aig_Obj_t * pNode0, * pNode1;
310  // check that the node is regular
311  assert( !Aig_IsComplement(pNode) );
312  // if the node is not AND, this is not MUX
313  if ( !Aig_ObjIsAnd(pNode) )
314  return 0;
315  // if the children are not complemented, this is not MUX
316  if ( !Aig_ObjFaninC0(pNode) || !Aig_ObjFaninC1(pNode) )
317  return 0;
318  // get children
319  pNode0 = Aig_ObjFanin0(pNode);
320  pNode1 = Aig_ObjFanin1(pNode);
321  // if the children are not ANDs, this is not MUX
322  if ( !Aig_ObjIsAnd(pNode0) || !Aig_ObjIsAnd(pNode1) )
323  return 0;
324  // otherwise the node is MUX iff it has a pair of equal grandchildren
325  return (Aig_ObjFanin0(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC0(pNode1))) ||
326  (Aig_ObjFanin0(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC1(pNode1))) ||
327  (Aig_ObjFanin1(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC0(pNode1))) ||
328  (Aig_ObjFanin1(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC1(pNode1)));
329 }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsAnd(Aig_Obj_t *pObj)
Definition: aig.h:278
void Aig_ObjPrintEqn ( FILE *  pFile,
Aig_Obj_t pObj,
Vec_Vec_t vLevels,
int  Level 
)

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

Synopsis [Prints Eqn formula for the AIG rooted at this node.]

Description [The formula is in terms of PIs, which should have their names assigned in pObj->pData fields.]

SideEffects []

SeeAlso []

Definition at line 519 of file aigUtil.c.

520 {
521  Vec_Ptr_t * vSuper;
522  Aig_Obj_t * pFanin;
523  int fCompl, i;
524  // store the complemented attribute
525  fCompl = Aig_IsComplement(pObj);
526  pObj = Aig_Regular(pObj);
527  // constant case
528  if ( Aig_ObjIsConst1(pObj) )
529  {
530  fprintf( pFile, "%d", !fCompl );
531  return;
532  }
533  // PI case
534  if ( Aig_ObjIsCi(pObj) )
535  {
536  fprintf( pFile, "%s%s", fCompl? "!" : "", (char*)pObj->pData );
537  return;
538  }
539  // AND case
540  Vec_VecExpand( vLevels, Level );
541  vSuper = Vec_VecEntry(vLevels, Level);
542  Aig_ObjCollectMulti( pObj, vSuper );
543  fprintf( pFile, "%s", (Level==0? "" : "(") );
544  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
545  {
546  Aig_ObjPrintEqn( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
547  if ( i < Vec_PtrSize(vSuper) - 1 )
548  fprintf( pFile, " %s ", fCompl? "+" : "*" );
549  }
550  fprintf( pFile, "%s", (Level==0? "" : ")") );
551  return;
552 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void * pData
Definition: aig.h:87
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
static void Vec_VecExpand(Vec_Vec_t *p, int Level)
Definition: vecVec.h:190
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
Definition: vecVec.h:271
void Aig_ObjCollectMulti(Aig_Obj_t *pRoot, Vec_Ptr_t *vSuper)
Definition: aigUtil.c:289
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
void Aig_ObjPrintEqn(FILE *pFile, Aig_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
Definition: aigUtil.c:519
void Aig_ObjPrintVerbose ( Aig_Obj_t pObj,
int  fHaig 
)

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

Synopsis [Prints node in HAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 653 of file aigUtil.c.

654 {
655  assert( !Aig_IsComplement(pObj) );
656  printf( "Node %p : ", pObj );
657  if ( Aig_ObjIsConst1(pObj) )
658  printf( "constant 1" );
659  else if ( Aig_ObjIsCi(pObj) )
660  printf( "PI" );
661  else if ( Aig_ObjIsCo(pObj) )
662  {
663  printf( "PO" );
664  printf( "%p%s",
665  Aig_ObjFanin0(pObj), (Aig_ObjFaninC0(pObj)? "\'" : " ") );
666  }
667  else
668  printf( "AND( %p%s, %p%s )",
669  Aig_ObjFanin0(pObj), (Aig_ObjFaninC0(pObj)? "\'" : " "),
670  Aig_ObjFanin1(pObj), (Aig_ObjFaninC1(pObj)? "\'" : " ") );
671  printf( " (refs = %3d)", Aig_ObjRefs(pObj) );
672 }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
void Aig_ObjPrintVerilog ( FILE *  pFile,
Aig_Obj_t pObj,
Vec_Vec_t vLevels,
int  Level 
)

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

Synopsis [Prints Verilog formula for the AIG rooted at this node.]

Description [The formula is in terms of PIs, which should have their names assigned in pObj->pData fields.]

SideEffects []

SeeAlso []

Definition at line 566 of file aigUtil.c.

567 {
568  Vec_Ptr_t * vSuper;
569  Aig_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
570  int fCompl, i;
571  // store the complemented attribute
572  fCompl = Aig_IsComplement(pObj);
573  pObj = Aig_Regular(pObj);
574  // constant case
575  if ( Aig_ObjIsConst1(pObj) )
576  {
577  fprintf( pFile, "1\'b%d", !fCompl );
578  return;
579  }
580  // PI case
581  if ( Aig_ObjIsCi(pObj) )
582  {
583  fprintf( pFile, "%s%s", fCompl? "~" : "", (char*)pObj->pData );
584  return;
585  }
586  // EXOR case
587  if ( Aig_ObjIsExor(pObj) )
588  {
589  Vec_VecExpand( vLevels, Level );
590  vSuper = Vec_VecEntry( vLevels, Level );
591  Aig_ObjCollectMulti( pObj, vSuper );
592  fprintf( pFile, "%s", (Level==0? "" : "(") );
593  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
594  {
595  Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
596  if ( i < Vec_PtrSize(vSuper) - 1 )
597  fprintf( pFile, " ^ " );
598  }
599  fprintf( pFile, "%s", (Level==0? "" : ")") );
600  return;
601  }
602  // MUX case
603  if ( Aig_ObjIsMuxType(pObj) )
604  {
605  if ( Aig_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
606  {
607  fprintf( pFile, "%s", (Level==0? "" : "(") );
608  Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
609  fprintf( pFile, " ^ " );
610  Aig_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
611  fprintf( pFile, "%s", (Level==0? "" : ")") );
612  }
613  else
614  {
615  pFaninC = Aig_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
616  fprintf( pFile, "%s", (Level==0? "" : "(") );
617  Aig_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
618  fprintf( pFile, " ? " );
619  Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin1, fCompl), vLevels, Level+1 );
620  fprintf( pFile, " : " );
621  Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
622  fprintf( pFile, "%s", (Level==0? "" : ")") );
623  }
624  return;
625  }
626  // AND case
627  Vec_VecExpand( vLevels, Level );
628  vSuper = Vec_VecEntry(vLevels, Level);
629  Aig_ObjCollectMulti( pObj, vSuper );
630  fprintf( pFile, "%s", (Level==0? "" : "(") );
631  Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
632  {
633  Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
634  if ( i < Vec_PtrSize(vSuper) - 1 )
635  fprintf( pFile, " %s ", fCompl? "|" : "&" );
636  }
637  fprintf( pFile, "%s", (Level==0? "" : ")") );
638  return;
639 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int Aig_ObjRecognizeExor(Aig_Obj_t *pObj, Aig_Obj_t **ppFan0, Aig_Obj_t **ppFan1)
Definition: aigUtil.c:343
void * pData
Definition: aig.h:87
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
int Aig_ObjIsMuxType(Aig_Obj_t *pNode)
Definition: aigUtil.c:307
static int Aig_ObjIsExor(Aig_Obj_t *pObj)
Definition: aig.h:279
Aig_Obj_t * Aig_ObjRecognizeMux(Aig_Obj_t *pNode, Aig_Obj_t **ppNodeT, Aig_Obj_t **ppNodeE)
Definition: aigUtil.c:387
static void Vec_VecExpand(Vec_Vec_t *p, int Level)
Definition: vecVec.h:190
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
Definition: vecVec.h:271
void Aig_ObjCollectMulti(Aig_Obj_t *pRoot, Vec_Ptr_t *vSuper)
Definition: aigUtil.c:289
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
void Aig_ObjPrintVerilog(FILE *pFile, Aig_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
Definition: aigUtil.c:566
Aig_Obj_t* Aig_ObjReal_rec ( Aig_Obj_t pObj)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 476 of file aigUtil.c.

477 {
478  Aig_Obj_t * pObjNew, * pObjR = Aig_Regular(pObj);
479  if ( !Aig_ObjIsBuf(pObjR) )
480  return pObj;
481  pObjNew = Aig_ObjReal_rec( Aig_ObjChild0(pObjR) );
482  return Aig_NotCond( pObjNew, Aig_IsComplement(pObj) );
483 }
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
Aig_Obj_t * Aig_ObjReal_rec(Aig_Obj_t *pObj)
Definition: aigUtil.c:476
Definition: aig.h:69
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
int Aig_ObjRecognizeExor ( Aig_Obj_t pObj,
Aig_Obj_t **  ppFan0,
Aig_Obj_t **  ppFan1 
)

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

Synopsis [Recognizes what nodes are inputs of the EXOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 343 of file aigUtil.c.

344 {
345  Aig_Obj_t * p0, * p1;
346  assert( !Aig_IsComplement(pObj) );
347  if ( !Aig_ObjIsNode(pObj) )
348  return 0;
349  if ( Aig_ObjIsExor(pObj) )
350  {
351  *ppFan0 = Aig_ObjChild0(pObj);
352  *ppFan1 = Aig_ObjChild1(pObj);
353  return 1;
354  }
355  assert( Aig_ObjIsAnd(pObj) );
356  p0 = Aig_ObjChild0(pObj);
357  p1 = Aig_ObjChild1(pObj);
358  if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
359  return 0;
360  p0 = Aig_Regular(p0);
361  p1 = Aig_Regular(p1);
362  if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
363  return 0;
364  if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
365  return 0;
366  if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
367  return 0;
368  *ppFan0 = Aig_ObjChild0(p0);
369  *ppFan1 = Aig_ObjChild1(p0);
370  return 1;
371 }
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ObjIsExor(Aig_Obj_t *pObj)
Definition: aig.h:279
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsAnd(Aig_Obj_t *pObj)
Definition: aig.h:278
Aig_Obj_t* Aig_ObjRecognizeMux ( Aig_Obj_t pNode,
Aig_Obj_t **  ppNodeT,
Aig_Obj_t **  ppNodeE 
)

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

Synopsis [Recognizes what nodes are control and data inputs of a MUX.]

Description [If the node is a MUX, returns the control variable C. Assigns nodes T and E to be the then and else variables of the MUX. Node C is never complemented. Nodes T and E can be complemented. This function also recognizes EXOR/NEXOR gates as MUXes.]

SideEffects []

SeeAlso []

Definition at line 387 of file aigUtil.c.

388 {
389  Aig_Obj_t * pNode0, * pNode1;
390  assert( !Aig_IsComplement(pNode) );
391  assert( Aig_ObjIsMuxType(pNode) );
392  // get children
393  pNode0 = Aig_ObjFanin0(pNode);
394  pNode1 = Aig_ObjFanin1(pNode);
395 
396  // find the control variable
397  if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
398  {
399 // if ( Fraig_IsComplement(pNode1->p2) )
400  if ( Aig_ObjFaninC1(pNode0) )
401  { // pNode2->p2 is positive phase of C
402  *ppNodeT = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
403  *ppNodeE = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
404  return Aig_ObjChild1(pNode1);//pNode2->p2;
405  }
406  else
407  { // pNode1->p2 is positive phase of C
408  *ppNodeT = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
409  *ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
410  return Aig_ObjChild1(pNode0);//pNode1->p2;
411  }
412  }
413  else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
414  {
415 // if ( Fraig_IsComplement(pNode1->p1) )
416  if ( Aig_ObjFaninC0(pNode0) )
417  { // pNode2->p1 is positive phase of C
418  *ppNodeT = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
419  *ppNodeE = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
420  return Aig_ObjChild0(pNode1);//pNode2->p1;
421  }
422  else
423  { // pNode1->p1 is positive phase of C
424  *ppNodeT = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
425  *ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
426  return Aig_ObjChild0(pNode0);//pNode1->p1;
427  }
428  }
429  else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
430  {
431 // if ( Fraig_IsComplement(pNode1->p1) )
432  if ( Aig_ObjFaninC0(pNode0) )
433  { // pNode2->p2 is positive phase of C
434  *ppNodeT = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
435  *ppNodeE = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
436  return Aig_ObjChild1(pNode1);//pNode2->p2;
437  }
438  else
439  { // pNode1->p1 is positive phase of C
440  *ppNodeT = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
441  *ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
442  return Aig_ObjChild0(pNode0);//pNode1->p1;
443  }
444  }
445  else if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
446  {
447 // if ( Fraig_IsComplement(pNode1->p2) )
448  if ( Aig_ObjFaninC1(pNode0) )
449  { // pNode2->p1 is positive phase of C
450  *ppNodeT = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
451  *ppNodeE = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
452  return Aig_ObjChild0(pNode1);//pNode2->p1;
453  }
454  else
455  { // pNode1->p2 is positive phase of C
456  *ppNodeT = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
457  *ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
458  return Aig_ObjChild1(pNode0);//pNode1->p2;
459  }
460  }
461  assert( 0 ); // this is not MUX
462  return NULL;
463 }
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
int Aig_ObjIsMuxType(Aig_Obj_t *pNode)
Definition: aigUtil.c:307
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
char* Aig_TimeStamp ( )

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

Synopsis [Returns the time stamp.]

Description [The file should be closed.]

SideEffects []

SeeAlso []

Definition at line 62 of file aigUtil.c.

63 {
64  static char Buffer[100];
65  char * TimeStamp;
66  time_t ltime;
67  // get the current time
68  time( &ltime );
69  TimeStamp = asctime( localtime( &ltime ) );
70  TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
71  strcpy( Buffer, TimeStamp );
72  return Buffer;
73 }
char * strcpy()
int strlen()