ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
aigUtil.c File Reference
#include "aig.h"
#include "proof/fra/fra.h"
#include "aig/saig/saig.h"
Include dependency graph for aigUtil.c:

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 ///.
 
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_ObjPrintVerboseCone (Aig_Man_t *p, Aig_Obj_t *pRoot, 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 ///.
 
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

◆ NUMBER1

#define NUMBER1   3716960521u

Definition at line 1156 of file aigUtil.c.

◆ NUMBER2

#define NUMBER2   2174103536u

Definition at line 1157 of file aigUtil.c.

Function Documentation

◆ Aig_FileNameGenericAppend()

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

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

Synopsis [Returns the composite name of the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 1083 of file aigUtil.c.

1084{
1085 static char Buffer[1000];
1086 char * pDot;
1087 strcpy( Buffer, pBase );
1088 if ( (pDot = strrchr( Buffer, '.' )) )
1089 *pDot = 0;
1090 strcat( Buffer, pSuffix );
1091 if ( (pDot = strrchr( Buffer, '\\' )) || (pDot = strrchr( Buffer, '/' )) )
1092 return pDot+1;
1093 return Buffer;
1094}
char * strrchr()
char * strcpy()
char * strcat()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManChoiceNum()

int Aig_ManChoiceNum ( Aig_Man_t * p)

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

Synopsis [Sets the PI/PO numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 1020 of file aigUtil.c.

1021{
1022 Aig_Obj_t * pObj;
1023 int i, Counter = 0;
1024 Aig_ManForEachNode( p, pObj, i )
1025 Counter += Aig_ObjIsChoice( p, pObj );
1026 return Counter;
1027}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
Cube * p
Definition exorList.c:222
Here is the caller graph for this function:

◆ Aig_ManCleanCioIds()

void Aig_ManCleanCioIds ( Aig_Man_t * p)

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

Synopsis [Sets the PI/PO numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 999 of file aigUtil.c.

1000{
1001 Aig_Obj_t * pObj;
1002 int i;
1003 Aig_ManForEachCi( p, pObj, i )
1004 pObj->pNext = NULL;
1005 Aig_ManForEachCo( p, pObj, i )
1006 pObj->pNext = NULL;
1007}
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
Aig_Obj_t * pNext
Definition aig.h:72
Here is the caller graph for this function:

◆ Aig_ManCleanData()

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}
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
void * pData
Definition aig.h:87

◆ Aig_ManCleanMarkA()

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}
unsigned int fMarkA
Definition aig.h:79
Here is the caller graph for this function:

◆ Aig_ManCleanMarkAB()

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}
unsigned int fMarkB
Definition aig.h:80
Here is the caller graph for this function:

◆ Aig_ManCleanMarkB()

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

◆ Aig_ManCleanNext()

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

◆ Aig_ManCounterExampleValueLookup()

int Aig_ManCounterExampleValueLookup ( Aig_Man_t * pAig,
int Id,
int iFrame )
extern

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 1410 of file aigUtil.c.

1411{
1412 assert( Id >= 0 && Id < Aig_ManObjNumMax(pAig) );
1413 return Abc_InfoHasBit( (unsigned *)pAig->pData2, Aig_ManObjNumMax(pAig) * iFrame + Id );
1414}
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Aig_ManCounterExampleValueStart()

void Aig_ManCounterExampleValueStart ( Aig_Man_t * pAig,
Abc_Cex_t * pCex )
extern

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 1331 of file aigUtil.c.

1332{
1333 Aig_Obj_t * pObj, * pObjRi, * pObjRo;
1334 int Val0, Val1, nObjs, i, k, iBit = 0;
1335 assert( Aig_ManRegNum(pAig) > 0 ); // makes sense only for sequential AIGs
1336 assert( pAig->pData2 == NULL ); // if this fail, there may be a memory leak
1337 // allocate memory to store simulation bits for internal nodes
1338 pAig->pData2 = ABC_CALLOC( unsigned, Abc_BitWordNum( (pCex->iFrame + 1) * Aig_ManObjNumMax(pAig) ) );
1339 // the register values in the counter-example should be zero
1340 Saig_ManForEachLo( pAig, pObj, k )
1341 assert( Abc_InfoHasBit(pCex->pData, iBit) == 0 ), iBit++;
1342 // iterate through the timeframes
1343 nObjs = Aig_ManObjNumMax(pAig);
1344 for ( i = 0; i <= pCex->iFrame; i++ )
1345 {
1346 // set constant 1 node
1347 Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + 0 );
1348 // set primary inputs according to the counter-example
1349 Saig_ManForEachPi( pAig, pObj, k )
1350 if ( Abc_InfoHasBit(pCex->pData, iBit++) )
1351 Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
1352 // compute values for each node
1353 Aig_ManForEachNode( pAig, pObj, k )
1354 {
1355 Val0 = Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
1356 Val1 = Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId1(pObj) );
1357 if ( (Val0 ^ Aig_ObjFaninC0(pObj)) & (Val1 ^ Aig_ObjFaninC1(pObj)) )
1358 Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
1359 }
1360 // derive values for combinational outputs
1361 Aig_ManForEachCo( pAig, pObj, k )
1362 {
1363 Val0 = Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
1364 if ( Val0 ^ Aig_ObjFaninC0(pObj) )
1365 Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
1366 }
1367 if ( i == pCex->iFrame )
1368 continue;
1369 // transfer values to the register output of the next frame
1370 Saig_ManForEachLiLo( pAig, pObjRi, pObjRo, k )
1371 if ( Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObjRi) ) )
1372 Abc_InfoSetBit( (unsigned *)pAig->pData2, nObjs * (i+1) + Aig_ObjId(pObjRo) );
1373 }
1374 assert( iBit == pCex->nBits );
1375 // check that the counter-example is correct, that is, the corresponding output is asserted
1376 assert( Abc_InfoHasBit( (unsigned *)pAig->pData2, nObjs * pCex->iFrame + Aig_ObjId(Aig_ManCo(pAig, pCex->iPo)) ) );
1377}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
Here is the caller graph for this function:

◆ Aig_ManCounterExampleValueStop()

void Aig_ManCounterExampleValueStop ( Aig_Man_t * pAig)
extern

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 1390 of file aigUtil.c.

1391{
1392 assert( pAig->pData2 != NULL ); // if this fail, we try to call this procedure more than once
1393 free( pAig->pData2 );
1394 pAig->pData2 = NULL;
1395}
VOID_HACK free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManCounterExampleValueTest()

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 1427 of file aigUtil.c.

1428{
1429 Aig_Obj_t * pObj = Aig_ManObj( pAig, Aig_ManObjNumMax(pAig)/2 );
1430 int iFrame = Abc_MaxInt( 0, pCex->iFrame - 1 );
1431 printf( "\nUsing counter-example, which asserts output %d in frame %d.\n", pCex->iPo, pCex->iFrame );
1432 Aig_ManCounterExampleValueStart( pAig, pCex );
1433 printf( "Value of object %d in frame %d is %d.\n", Aig_ObjId(pObj), iFrame,
1434 Aig_ManCounterExampleValueLookup(pAig, Aig_ObjId(pObj), iFrame) );
1436}
int Aig_ManCounterExampleValueLookup(Aig_Man_t *pAig, int Id, int iFrame)
Definition aigUtil.c:1410
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START void Aig_ManCounterExampleValueStart(Aig_Man_t *pAig, Abc_Cex_t *pCex)
Definition aigUtil.c:1331
void Aig_ManCounterExampleValueStop(Aig_Man_t *pAig)
Definition aigUtil.c:1390
Here is the call graph for this function:

◆ Aig_ManDump()

void Aig_ManDump ( Aig_Man_t * p)

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

Synopsis [Write speculative miter for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 725 of file aigUtil.c.

726{
727 static int Counter = 0;
728 char FileName[200];
729 // dump the logic into a file
730 sprintf( FileName, "aigbug\\%03d.blif", ++Counter );
731 Aig_ManDumpBlif( p, FileName, NULL, NULL );
732 printf( "Intermediate AIG with %d nodes was written into file \"%s\".\n", Aig_ManNodeNum(p), FileName );
733}
void Aig_ManDumpBlif(Aig_Man_t *p, char *pFileName, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vPoNames)
Definition aigUtil.c:746
char * sprintf()
Here is the call graph for this function:

◆ Aig_ManDumpBlif()

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 746 of file aigUtil.c.

747{
748 FILE * pFile;
749 Vec_Ptr_t * vNodes;
750 Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pConst1 = NULL;
751 int i, nDigits, Counter = 0;
752 if ( Aig_ManCoNum(p) == 0 )
753 {
754 printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
755 return;
756 }
757 // check if constant is used
758 Aig_ManForEachCo( p, pObj, i )
759 if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
760 pConst1 = Aig_ManConst1(p);
761 // collect nodes in the DFS order
762 vNodes = Aig_ManDfs( p, 1 );
763 // assign IDs to objects
764 Aig_ManConst1(p)->iData = Counter++;
765 Aig_ManForEachCi( p, pObj, i )
766 pObj->iData = Counter++;
767 Aig_ManForEachCo( p, pObj, i )
768 pObj->iData = Counter++;
769 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
770 pObj->iData = Counter++;
771 nDigits = Abc_Base10Log( Counter );
772 // write the file
773 pFile = fopen( pFileName, "w" );
774 fprintf( pFile, "# BLIF file written by procedure Aig_ManDumpBlif()\n" );
775// fprintf( pFile, "# http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
776 fprintf( pFile, ".model %s\n", p->pName );
777 // write PIs
778 fprintf( pFile, ".inputs" );
779 Aig_ManForEachPiSeq( p, pObj, i )
780 if ( vPiNames )
781 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, i) );
782 else
783 fprintf( pFile, " n%0*d", nDigits, pObj->iData );
784 fprintf( pFile, "\n" );
785 // write POs
786 fprintf( pFile, ".outputs" );
787 Aig_ManForEachPoSeq( p, pObj, i )
788 if ( vPoNames )
789 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPoNames, i) );
790 else
791 fprintf( pFile, " n%0*d", nDigits, pObj->iData );
792 fprintf( pFile, "\n" );
793 // write latches
794 if ( Aig_ManRegNum(p) )
795 {
796 fprintf( pFile, "\n" );
797 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
798 {
799 fprintf( pFile, ".latch" );
800 if ( vPoNames )
801 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPoNames, Aig_ManCoNum(p)-Aig_ManRegNum(p)+i) );
802 else
803 fprintf( pFile, " n%0*d", nDigits, pObjLi->iData );
804 if ( vPiNames )
805 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ManCiNum(p)-Aig_ManRegNum(p)+i) );
806 else
807 fprintf( pFile, " n%0*d", nDigits, pObjLo->iData );
808 fprintf( pFile, " 0\n" );
809 }
810 fprintf( pFile, "\n" );
811 }
812 // write nodes
813 if ( pConst1 )
814 fprintf( pFile, ".names n%0*d\n 1\n", nDigits, pConst1->iData );
816 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
817 {
818 fprintf( pFile, ".names" );
819 if ( vPiNames && Aig_ObjIsCi(Aig_ObjFanin0(pObj)) )
820 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ObjCioId(Aig_ObjFanin0(pObj))) );
821 else
822 fprintf( pFile, " n%0*d", nDigits, Aig_ObjFanin0(pObj)->iData );
823 if ( vPiNames && Aig_ObjIsCi(Aig_ObjFanin1(pObj)) )
824 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ObjCioId(Aig_ObjFanin1(pObj))) );
825 else
826 fprintf( pFile, " n%0*d", nDigits, Aig_ObjFanin1(pObj)->iData );
827 fprintf( pFile, " n%0*d\n", nDigits, pObj->iData );
828 fprintf( pFile, "%d%d 1\n", !Aig_ObjFaninC0(pObj), !Aig_ObjFaninC1(pObj) );
829 }
830 // write POs
831 Aig_ManForEachCo( p, pObj, i )
832 {
833 fprintf( pFile, ".names" );
834 if ( vPiNames && Aig_ObjIsCi(Aig_ObjFanin0(pObj)) )
835 fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Aig_ObjCioId(Aig_ObjFanin0(pObj))) );
836 else
837 fprintf( pFile, " n%0*d", nDigits, Aig_ObjFanin0(pObj)->iData );
838 if ( vPoNames )
839 fprintf( pFile, " %s\n", (char*)Vec_PtrEntry(vPoNames, Aig_ObjCioId(pObj)) );
840 else
841 fprintf( pFile, " n%0*d\n", nDigits, pObj->iData );
842 fprintf( pFile, "%d 1\n", !Aig_ObjFaninC0(pObj) );
843 }
845 fprintf( pFile, ".end\n\n" );
846 fclose( pFile );
847 Vec_PtrFree( vNodes );
848}
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition aigUtil.c:978
void Aig_ManCleanCioIds(Aig_Man_t *p)
Definition aigUtil.c:999
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition aig.h:438
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition aigDfs.c:145
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition aig.h:444
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition aig.h:450
int iData
Definition aig.h:88
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManDumpVerilog()

void Aig_ManDumpVerilog ( Aig_Man_t * p,
char * pFileName )

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

Synopsis [Writes the AIG into a Verilog file.]

Description []

SideEffects []

SeeAlso []

Definition at line 861 of file aigUtil.c.

862{
863 FILE * pFile;
864 Vec_Ptr_t * vNodes;
865 Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pConst1 = NULL;
866 int i, nDigits, Counter = 0;
867 if ( Aig_ManCoNum(p) == 0 )
868 {
869 printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
870 return;
871 }
872 // check if constant is used
873 Aig_ManForEachCo( p, pObj, i )
874 if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
875 pConst1 = Aig_ManConst1(p);
876 // collect nodes in the DFS order
877 vNodes = Aig_ManDfs( p, 1 );
878 // assign IDs to objects
879 Aig_ManConst1(p)->iData = Counter++;
880 Aig_ManForEachCi( p, pObj, i )
881 pObj->iData = Counter++;
882 Aig_ManForEachCo( p, pObj, i )
883 pObj->iData = Counter++;
884 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
885 pObj->iData = Counter++;
886 nDigits = Abc_Base10Log( Counter );
887 // write the file
888 pFile = fopen( pFileName, "w" );
889 fprintf( pFile, "// Verilog file written by procedure Aig_ManDumpVerilog()\n" );
890// fprintf( pFile, "// http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
891 if ( Aig_ManRegNum(p) )
892 fprintf( pFile, "module %s ( clock", p->pName? p->pName: "test" );
893 else
894 fprintf( pFile, "module %s (", p->pName? p->pName: "test" );
895 Aig_ManForEachPiSeq( p, pObj, i )
896 fprintf( pFile, "%s n%0*d", ((Aig_ManRegNum(p) || i)? ",":""), nDigits, pObj->iData );
897 Aig_ManForEachPoSeq( p, pObj, i )
898 fprintf( pFile, ", n%0*d", nDigits, pObj->iData );
899 fprintf( pFile, " );\n" );
900
901 // write PIs
902 if ( Aig_ManRegNum(p) )
903 fprintf( pFile, "input clock;\n" );
904 Aig_ManForEachPiSeq( p, pObj, i )
905 fprintf( pFile, "input n%0*d;\n", nDigits, pObj->iData );
906 // write POs
907 Aig_ManForEachPoSeq( p, pObj, i )
908 fprintf( pFile, "output n%0*d;\n", nDigits, pObj->iData );
909 // write latches
910 if ( Aig_ManRegNum(p) )
911 {
912 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
913 fprintf( pFile, "reg n%0*d;\n", nDigits, pObjLo->iData );
914 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
915 fprintf( pFile, "wire n%0*d;\n", nDigits, pObjLi->iData );
916 }
917 // write nodes
918 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
919 fprintf( pFile, "wire n%0*d;\n", nDigits, pObj->iData );
920 if ( pConst1 )
921 fprintf( pFile, "wire n%0*d;\n", nDigits, pConst1->iData );
922 // write nodes
923 if ( pConst1 )
924 fprintf( pFile, "assign n%0*d = 1\'b1;\n", nDigits, pConst1->iData );
925 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
926 {
927 fprintf( pFile, "assign n%0*d = %sn%0*d & %sn%0*d;\n",
928 nDigits, pObj->iData,
929 !Aig_ObjFaninC0(pObj) ? " " : "~", nDigits, Aig_ObjFanin0(pObj)->iData,
930 !Aig_ObjFaninC1(pObj) ? " " : "~", nDigits, Aig_ObjFanin1(pObj)->iData
931 );
932 }
933 // write POs
934 Aig_ManForEachPoSeq( p, pObj, i )
935 {
936 fprintf( pFile, "assign n%0*d = %sn%0*d;\n",
937 nDigits, pObj->iData,
938 !Aig_ObjFaninC0(pObj) ? " " : "~", nDigits, Aig_ObjFanin0(pObj)->iData );
939 }
940 if ( Aig_ManRegNum(p) )
941 {
942 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
943 {
944 fprintf( pFile, "assign n%0*d = %sn%0*d;\n",
945 nDigits, pObjLi->iData,
946 !Aig_ObjFaninC0(pObjLi) ? " " : "~", nDigits, Aig_ObjFanin0(pObjLi)->iData );
947 }
948 }
949
950 // write initial state
951 if ( Aig_ManRegNum(p) )
952 {
953 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
954 fprintf( pFile, "always @ (posedge clock) begin n%0*d <= n%0*d; end\n",
955 nDigits, pObjLo->iData,
956 nDigits, pObjLi->iData );
957 Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
958 fprintf( pFile, "initial begin n%0*d <= 1\'b0; end\n",
959 nDigits, pObjLo->iData );
960 }
961
962 fprintf( pFile, "endmodule\n\n" );
963 fclose( pFile );
964 Vec_PtrFree( vNodes );
965}
Here is the call graph for this function:

◆ Aig_ManHasNoGaps()

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}

◆ Aig_ManIncrementTravId()

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}
void Aig_ManCleanData(Aig_Man_t *p)
Definition aigUtil.c:205
Here is the call graph for this function:

◆ Aig_ManInvertConstraints()

void Aig_ManInvertConstraints ( Aig_Man_t * pAig)

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

Synopsis [Complements the constraint outputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1561 of file aigUtil.c.

1562{
1563 Aig_Obj_t * pObj;
1564 int i;
1565 if ( Aig_ManConstrNum(pAig) == 0 )
1566 return;
1567 Saig_ManForEachPo( pAig, pObj, i )
1568 {
1569 if ( i >= Saig_ManPoNum(pAig) - Aig_ManConstrNum(pAig) )
1570 Aig_ObjChild0Flip( pObj );
1571 }
1572}
#define Saig_ManForEachPo(p, pObj, i)
Definition saig.h:93
Here is the caller graph for this function:

◆ Aig_ManLevels()

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

◆ Aig_ManMuxesCollect()

Vec_Ptr_t * Aig_ManMuxesCollect ( Aig_Man_t * pAig)

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

Synopsis [Collects muxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1478 of file aigUtil.c.

1479{
1480 Vec_Ptr_t * vMuxes;
1481 Aig_Obj_t * pObj;
1482 int i;
1483 vMuxes = Vec_PtrAlloc( 100 );
1484 Aig_ManForEachNode( pAig, pObj, i )
1485 if ( Aig_ObjIsMuxType(pObj) )
1486 Vec_PtrPush( vMuxes, pObj );
1487 return vMuxes;
1488}
int Aig_ObjIsMuxType(Aig_Obj_t *pNode)
Definition aigUtil.c:307
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManMuxesDeref()

void Aig_ManMuxesDeref ( Aig_Man_t * pAig,
Vec_Ptr_t * vMuxes )

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

Synopsis [Dereferences muxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1501 of file aigUtil.c.

1502{
1503 Aig_Obj_t * pObj, * pNodeT, * pNodeE, * pNodeC;
1504 int i;
1505 Vec_PtrForEachEntry( Aig_Obj_t *, vMuxes, pObj, i )
1506 {
1507 if ( Aig_ObjRecognizeExor( pObj, &pNodeT, &pNodeE ) )
1508 {
1509 pNodeT->nRefs--;
1510 pNodeE->nRefs--;
1511 }
1512 else
1513 {
1514 pNodeC = Aig_ObjRecognizeMux( pObj, &pNodeT, &pNodeE );
1515 pNodeC->nRefs--;
1516 }
1517 }
1518}
int Aig_ObjRecognizeExor(Aig_Obj_t *pObj, Aig_Obj_t **ppFan0, Aig_Obj_t **ppFan1)
Definition aigUtil.c:343
Aig_Obj_t * Aig_ObjRecognizeMux(Aig_Obj_t *pNode, Aig_Obj_t **ppNodeT, Aig_Obj_t **ppNodeE)
Definition aigUtil.c:387
unsigned int nRefs
Definition aig.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManMuxesRef()

void Aig_ManMuxesRef ( Aig_Man_t * pAig,
Vec_Ptr_t * vMuxes )

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

Synopsis [References muxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1531 of file aigUtil.c.

1532{
1533 Aig_Obj_t * pObj, * pNodeT, * pNodeE, * pNodeC;
1534 int i;
1535 Vec_PtrForEachEntry( Aig_Obj_t *, vMuxes, pObj, i )
1536 {
1537 if ( Aig_ObjRecognizeExor( pObj, &pNodeT, &pNodeE ) )
1538 {
1539 pNodeT->nRefs++;
1540 pNodeE->nRefs++;
1541 }
1542 else
1543 {
1544 pNodeC = Aig_ObjRecognizeMux( pObj, &pNodeT, &pNodeE );
1545 pNodeC->nRefs++;
1546 }
1547 }
1548}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPrintControlFanouts()

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 1040 of file aigUtil.c.

1041{
1042 Aig_Obj_t * pObj, * pFanin0, * pFanin1, * pCtrl;
1043 int i;
1044
1045 pCtrl = Aig_ManCi( p, Aig_ManCiNum(p) - 1 );
1046
1047 printf( "Control signal:\n" );
1048 Aig_ObjPrint( p, pCtrl ); printf( "\n\n" );
1049
1050 Aig_ManForEachObj( p, pObj, i )
1051 {
1052 if ( !Aig_ObjIsNode(pObj) )
1053 continue;
1054 assert( pObj != pCtrl );
1055 pFanin0 = Aig_ObjFanin0(pObj);
1056 pFanin1 = Aig_ObjFanin1(pObj);
1057 if ( pFanin0 == pCtrl && Aig_ObjIsCi(pFanin1) )
1058 {
1059 Aig_ObjPrint( p, pObj ); printf( "\n" );
1060 Aig_ObjPrint( p, pFanin1 ); printf( "\n" );
1061 printf( "\n" );
1062 }
1063 if ( pFanin1 == pCtrl && Aig_ObjIsCi(pFanin0) )
1064 {
1065 Aig_ObjPrint( p, pObj ); printf( "\n" );
1066 Aig_ObjPrint( p, pFanin0 ); printf( "\n" );
1067 printf( "\n" );
1068 }
1069 }
1070}
void Aig_ObjPrint(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition aigObj.c:316
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPrintVerbose()

void Aig_ManPrintVerbose ( Aig_Man_t * p,
int fHaig )

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

Synopsis [Prints node in HAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 698 of file aigUtil.c.

699{
700 Vec_Ptr_t * vNodes;
701 Aig_Obj_t * pObj;
702 int i;
703 printf( "PIs: " );
704 Aig_ManForEachCi( p, pObj, i )
705 printf( " %p", pObj );
706 printf( "\n" );
707 vNodes = Aig_ManDfs( p, 0 );
708 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
709 Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
710 printf( "\n" );
711 Vec_PtrFree( vNodes );
712}
void Aig_ObjPrintVerbose(Aig_Obj_t *pObj, int fHaig)
Definition aigUtil.c:653
Here is the call graph for this function:

◆ Aig_ManRandom()

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 1170 of file aigUtil.c.

1171{
1172#ifdef _MSC_VER
1173 static unsigned int m_z = NUMBER1;
1174 static unsigned int m_w = NUMBER2;
1175#else
1176 static __thread unsigned int m_z = NUMBER1;
1177 static __thread unsigned int m_w = NUMBER2;
1178#endif
1179 if ( fReset )
1180 {
1181 m_z = NUMBER1;
1182 m_w = NUMBER2;
1183 }
1184 m_z = 36969 * (m_z & 65535) + (m_z >> 16);
1185 m_w = 18000 * (m_w & 65535) + (m_w >> 16);
1186 return (m_z << 16) + m_w;
1187}
#define NUMBER2
Definition aigUtil.c:1157
#define NUMBER1
Definition aigUtil.c:1156
Here is the caller graph for this function:

◆ Aig_ManRandom64()

word Aig_ManRandom64 ( int fReset)

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 1200 of file aigUtil.c.

1201{
1202 word Res = (word)Aig_ManRandom(fReset);
1203 return Res | ((word)Aig_ManRandom(0) << 32);
1204}
unsigned Aig_ManRandom(int fReset)
GLOBAL VARIABLES ///.
Definition aigUtil.c:1170
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManRandomInfo()

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 1218 of file aigUtil.c.

1219{
1220 unsigned * pInfo;
1221 int i, w;
1222 Vec_PtrForEachEntryStart( unsigned *, vInfo, pInfo, i, iInputStart )
1223 for ( w = iWordStart; w < iWordStop; w++ )
1224 pInfo[w] = Aig_ManRandom(0);
1225}
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:

◆ Aig_ManRandomTest1()

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 1137 of file aigUtil.c.

1138{
1139 FILE * pFile;
1140 unsigned int lfsr;
1141 unsigned int period = 0;
1142 pFile = fopen( "rand.txt", "w" );
1143 do {
1144 lfsr = Aig_ManRandom( 0 );
1145 ++period;
1146 fprintf( pFile, "%10d : %10d ", period, lfsr );
1147// Extra_PrintBinary( pFile, &lfsr, 32 );
1148 fprintf( pFile, "\n" );
1149 if ( period == 20000 )
1150 break;
1151 } while(lfsr != 1u);
1152 fclose( pFile );
1153}
Here is the call graph for this function:

◆ Aig_ManRandomTest2()

void Aig_ManRandomTest2 ( )

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

Synopsis [Creates a sequence of random numbers.]

Description []

SideEffects []

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

Definition at line 1107 of file aigUtil.c.

1108{
1109 FILE * pFile;
1110 unsigned int lfsr = 1;
1111 unsigned int period = 0;
1112 pFile = fopen( "rand.txt", "w" );
1113 do {
1114// lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xd0000001u); // taps 32 31 29 1
1115 lfsr = 1; // to prevent the warning
1116 ++period;
1117 fprintf( pFile, "%10d : %10d ", period, lfsr );
1118// Extra_PrintBinary( pFile, &lfsr, 32 );
1119 fprintf( pFile, "\n" );
1120 if ( period == 20000 )
1121 break;
1122 } while(lfsr != 1u);
1123 fclose( pFile );
1124}

◆ Aig_ManResetRefs()

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

◆ Aig_ManSetCioIds()

void Aig_ManSetCioIds ( Aig_Man_t * p)

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

Synopsis [Sets the PI/PO numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 978 of file aigUtil.c.

979{
980 Aig_Obj_t * pObj;
981 int i;
982 Aig_ManForEachCi( p, pObj, i )
983 pObj->CioId = i;
984 Aig_ManForEachCo( p, pObj, i )
985 pObj->CioId = i;
986}
int CioId
Definition aig.h:73
Here is the caller graph for this function:

◆ Aig_ManSetPhase()

void Aig_ManSetPhase ( Aig_Man_t * pAig)

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

Synopsis [Handle the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 1449 of file aigUtil.c.

1450{
1451 Aig_Obj_t * pObj;
1452 int i;
1453 // set the PI simulation information
1454 Aig_ManConst1( pAig )->fPhase = 1;
1455 Aig_ManForEachCi( pAig, pObj, i )
1456 pObj->fPhase = 0;
1457 // simulate internal nodes
1458 Aig_ManForEachNode( pAig, pObj, i )
1459 pObj->fPhase = ( Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj) )
1460 & ( Aig_ObjFanin1(pObj)->fPhase ^ Aig_ObjFaninC1(pObj) );
1461 // simulate PO nodes
1462 Aig_ManForEachCo( pAig, pObj, i )
1463 pObj->fPhase = Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj);
1464}
unsigned int fPhase
Definition aig.h:78
Here is the caller graph for this function:

◆ Aig_NodeIntersectLists()

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 1277 of file aigUtil.c.

1278{
1279 Aig_Obj_t ** pBeg = (Aig_Obj_t **)vArr->pArray;
1280 Aig_Obj_t ** pBeg1 = (Aig_Obj_t **)vArr1->pArray;
1281 Aig_Obj_t ** pBeg2 = (Aig_Obj_t **)vArr2->pArray;
1282 Aig_Obj_t ** pEnd1 = (Aig_Obj_t **)vArr1->pArray + vArr1->nSize;
1283 Aig_Obj_t ** pEnd2 = (Aig_Obj_t **)vArr2->pArray + vArr2->nSize;
1284 Vec_PtrGrow( vArr, Abc_MaxInt( Vec_PtrSize(vArr1), Vec_PtrSize(vArr2) ) );
1285 pBeg = (Aig_Obj_t **)vArr->pArray;
1286 while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
1287 {
1288 if ( (*pBeg1)->Id == (*pBeg2)->Id )
1289 *pBeg++ = *pBeg1++, pBeg2++;
1290 else if ( (*pBeg1)->Id < (*pBeg2)->Id )
1291// *pBeg++ = *pBeg1++;
1292 pBeg1++;
1293 else
1294// *pBeg++ = *pBeg2++;
1295 pBeg2++;
1296 }
1297// while ( pBeg1 < pEnd1 )
1298// *pBeg++ = *pBeg1++;
1299// while ( pBeg2 < pEnd2 )
1300// *pBeg++ = *pBeg2++;
1301 vArr->nSize = pBeg - (Aig_Obj_t **)vArr->pArray;
1302 assert( vArr->nSize <= vArr->nCap );
1303 assert( vArr->nSize <= vArr1->nSize );
1304 assert( vArr->nSize <= vArr2->nSize );
1305}

◆ Aig_NodeUnionLists()

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 1238 of file aigUtil.c.

1239{
1240 Aig_Obj_t ** pBeg = (Aig_Obj_t **)vArr->pArray;
1241 Aig_Obj_t ** pBeg1 = (Aig_Obj_t **)vArr1->pArray;
1242 Aig_Obj_t ** pBeg2 = (Aig_Obj_t **)vArr2->pArray;
1243 Aig_Obj_t ** pEnd1 = (Aig_Obj_t **)vArr1->pArray + vArr1->nSize;
1244 Aig_Obj_t ** pEnd2 = (Aig_Obj_t **)vArr2->pArray + vArr2->nSize;
1245 Vec_PtrGrow( vArr, Vec_PtrSize(vArr1) + Vec_PtrSize(vArr2) );
1246 pBeg = (Aig_Obj_t **)vArr->pArray;
1247 while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
1248 {
1249 if ( (*pBeg1)->Id == (*pBeg2)->Id )
1250 *pBeg++ = *pBeg1++, pBeg2++;
1251 else if ( (*pBeg1)->Id < (*pBeg2)->Id )
1252 *pBeg++ = *pBeg1++;
1253 else
1254 *pBeg++ = *pBeg2++;
1255 }
1256 while ( pBeg1 < pEnd1 )
1257 *pBeg++ = *pBeg1++;
1258 while ( pBeg2 < pEnd2 )
1259 *pBeg++ = *pBeg2++;
1260 vArr->nSize = pBeg - (Aig_Obj_t **)vArr->pArray;
1261 assert( vArr->nSize <= vArr->nCap );
1262 assert( vArr->nSize >= vArr1->nSize );
1263 assert( vArr->nSize >= vArr2->nSize );
1264}

◆ Aig_ObjCleanData_rec()

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 {
249 Aig_ObjCleanData_rec( Aig_ObjFanin0(pObj) );
250 Aig_ObjCleanData_rec( Aig_ObjFanin1(pObj) );
251 }
252 pObj->pData = NULL;
253}
void Aig_ObjCleanData_rec(Aig_Obj_t *pObj)
Definition aigUtil.c:243
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ObjCollectMulti()

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}
void Aig_ObjCollectMulti_rec(Aig_Obj_t *pRoot, Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
Definition aigUtil.c:267
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ObjCollectMulti_rec()

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

◆ Aig_ObjCompareIdIncrease()

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

◆ Aig_ObjIsMuxType()

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

◆ Aig_ObjPrintEqn()

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}
void Aig_ObjPrintEqn(FILE *pFile, Aig_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
Definition aigUtil.c:519
void Aig_ObjCollectMulti(Aig_Obj_t *pRoot, Vec_Ptr_t *vSuper)
Definition aigUtil.c:289
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ObjPrintVerbose()

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 %d : ", pObj->Id );
657 if ( Aig_ObjIsConst1(pObj) )
658 printf( "constant 1" );
659 else if ( Aig_ObjIsCi(pObj) )
660 printf( "CI" );
661 else if ( Aig_ObjIsCo(pObj) )
662 {
663 printf( "CO( " );
664 printf( "%d%s )",
665 Aig_ObjFanin0(pObj)->Id, (Aig_ObjFaninC0(pObj)? "\'" : " ") );
666 }
667 else
668 printf( "AND( %d%s, %d%s )",
669 Aig_ObjFanin0(pObj)->Id, (Aig_ObjFaninC0(pObj)? "\'" : " "),
670 Aig_ObjFanin1(pObj)->Id, (Aig_ObjFaninC1(pObj)? "\'" : " ") );
671 printf( " (refs = %3d)", Aig_ObjRefs(pObj) );
672}
int Id
Definition aig.h:85
Here is the caller graph for this function:

◆ Aig_ObjPrintVerboseCone()

void Aig_ObjPrintVerboseCone ( Aig_Man_t * p,
Aig_Obj_t * pRoot,
int fHaig )

Definition at line 673 of file aigUtil.c.

674{
675 extern Vec_Ptr_t * Aig_ManDfsArray( Aig_Man_t * p, Aig_Obj_t ** pNodes, int nNodes );
676 Vec_Ptr_t * vNodes;
677 Aig_Obj_t * pObj;
678 int i;
679 vNodes = Aig_ManDfsArray( p, &pRoot, 1 );
680 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
681 Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
682 printf( "\n" );
683 Vec_PtrFree( vNodes );
684
685}
Vec_Ptr_t * Aig_ManDfsArray(Aig_Man_t *p, Aig_Obj_t **pNodes, int nNodes)
Definition aigDfs.c:202
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Here is the call graph for this function:

◆ Aig_ObjPrintVerilog()

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}
void Aig_ObjPrintVerilog(FILE *pFile, Aig_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)
Definition aigUtil.c:566
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ObjReal_rec()

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}
Aig_Obj_t * Aig_ObjReal_rec(Aig_Obj_t *pObj)
Definition aigUtil.c:476
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ObjRecognizeExor()

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

◆ Aig_ObjRecognizeMux()

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

◆ Aig_TimeStamp()

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}
int strlen()
Here is the call graph for this function:
Here is the caller graph for this function: