ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaHash.c File Reference
#include "gia.h"
Include dependency graph for giaHash.c:

Go to the source code of this file.

Functions

int Gia_ManHashLookupInt (Gia_Man_t *p, int iLit0, int iLit1)
 
int Gia_ManHashLookup (Gia_Man_t *p, Gia_Obj_t *p0, Gia_Obj_t *p1)
 
void Gia_ManHashAlloc (Gia_Man_t *p)
 
void Gia_ManHashStart (Gia_Man_t *p)
 
void Gia_ManHashStop (Gia_Man_t *p)
 
void Gia_ManHashResize (Gia_Man_t *p)
 
void Gia_ManHashProfile (Gia_Man_t *p)
 
int Gia_ManHashXorReal (Gia_Man_t *p, int iLit0, int iLit1)
 
int Gia_ManHashMuxReal (Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
 
int Gia_ManHashAnd (Gia_Man_t *p, int iLit0, int iLit1)
 
int Gia_ManHashOr (Gia_Man_t *p, int iLit0, int iLit1)
 
int Gia_ManHashAndTry (Gia_Man_t *p, int iLit0, int iLit1)
 
int Gia_ManHashXor (Gia_Man_t *p, int iLit0, int iLit1)
 
int Gia_ManHashMux (Gia_Man_t *p, int iCtrl, int iData1, int iData0)
 
int Gia_ManHashMaj (Gia_Man_t *p, int iData0, int iData1, int iData2)
 
Gia_Man_tGia_ManRehash (Gia_Man_t *p, int fAddStrash)
 
int Gia_ManHashAndMulti (Gia_Man_t *p, Vec_Int_t *vLits)
 
int Gia_ManHashAndMulti2 (Gia_Man_t *p, Vec_Int_t *vLits)
 
int Gia_ManHashDualMiter (Gia_Man_t *p, Vec_Int_t *vOuts)
 
int * Gia_ManCollectLiterals (int nVars)
 
int * Gia_ManGenZero (int nBits)
 
int * Gia_ManGenPerm (int nBits)
 
int * Gia_ManGenPerm2 (int nBits)
 
int Gia_ManMultiCheck (int *pPerm, int nPerm)
 
int Gia_ManMultiInputPerm (Gia_Man_t *pNew, int *pVars, int nVars, int *pPerm, int fOr, int fXor)
 
Gia_Man_tGia_ManMultiInputTest (int nBits)
 
int Gia_ManCube (Gia_Man_t *pNew, int Vars, int nVars, int *pLits)
 
int Gia_ManMuxTree_rec (Gia_Man_t *pNew, int *pCtrl, int nCtrl, int *pData)
 
void Gia_ManUsePerm (int *pTree, int nBits, int *pPerm)
 
int Gia_ManFindCond (int *pLits, int nBits, int iLate1, int iLate2)
 
int Gia_ManLatest (int *pPerm, int nVars, int iPrev1, int iPrev2, int iPrev3)
 
int Gia_ManEarliest (int *pPerm, int nVars)
 
int Gia_ManDecompOne (Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm, int iLate)
 
int Gia_ManDecompTwo (Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm, int iLate1, int iLate2)
 
int Gia_ManDecompThree (Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm, int iLate1, int iLate2, int iLate3)
 
int Gia_ManDecomp (Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm)
 
Gia_Man_tGia_ManMuxTreeTest (int nBits)
 

Function Documentation

◆ Gia_ManCollectLiterals()

int * Gia_ManCollectLiterals ( int nVars)

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

Synopsis [Create multi-input tree.]

Description []

SideEffects []

SeeAlso []

Definition at line 830 of file giaHash.c.

831{
832 int i, * pRes = ABC_CALLOC( int, nVars );
833 for ( i = 0; i < nVars; i++ )
834 pRes[i] = Abc_Var2Lit( i+1, 0 );
835 return pRes;
836}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Here is the caller graph for this function:

◆ Gia_ManCube()

int Gia_ManCube ( Gia_Man_t * pNew,
int Vars,
int nVars,
int * pLits )

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

Synopsis [Create MUX tree.]

Description []

SideEffects []

SeeAlso []

Definition at line 958 of file giaHash.c.

959{
960 int i, iLit = 1;
961 for ( i = 0; i < nVars; i++ )
962 iLit = Gia_ManHashAnd( pNew, iLit, Abc_LitNotCond(pLits[i], !((Vars >> i) & 1)) );
963 return iLit;
964}
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDecomp()

int Gia_ManDecomp ( Gia_Man_t * pNew,
int * pTree,
int nBits,
int * pPerm )

Definition at line 1089 of file giaHash.c.

1090{
1091 if ( nBits == 2 )
1092 return Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
1093 else
1094 {
1095 int iBase = Gia_ManEarliest( pPerm+nBits, 1<<nBits ), BaseValue = pPerm[nBits+iBase];
1096 int iLate1 = Gia_ManLatest( pPerm+nBits, 1<<nBits, -1, -1, -1 );
1097 int iLate2 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, -1, -1 );
1098 int iLate3 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, iLate2, -1 );
1099 int iLate4 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, iLate2, iLate3 );
1100 if ( 0 )
1101 {
1102 int i;
1103 for ( i = 0; i < (1<<nBits); i++ )
1104 printf( "%d ", pPerm[nBits+i] );
1105 printf( "\n" );
1106 }
1107 if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] > BaseValue && pPerm[nBits+iLate3] > BaseValue && pPerm[nBits+iLate4] == BaseValue )
1108 return Gia_ManDecompThree( pNew, pTree, nBits, pPerm, iLate1, iLate2, iLate3 );
1109 if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] > BaseValue && pPerm[nBits+iLate3] == BaseValue )
1110 return Gia_ManDecompTwo( pNew, pTree, nBits, pPerm, iLate1, iLate2 );
1111 if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] == BaseValue )
1112 return Gia_ManDecompOne( pNew, pTree, nBits, pPerm, iLate1 );
1113 return Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
1114 }
1115}
int Gia_ManEarliest(int *pPerm, int nVars)
Definition giaHash.c:1028
int Gia_ManDecompOne(Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm, int iLate)
Definition giaHash.c:1039
int Gia_ManDecompThree(Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm, int iLate1, int iLate2, int iLate3)
Definition giaHash.c:1064
int Gia_ManDecompTwo(Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm, int iLate1, int iLate2)
Definition giaHash.c:1048
int Gia_ManLatest(int *pPerm, int nVars, int iPrev1, int iPrev2, int iPrev3)
Definition giaHash.c:1017
int Gia_ManMuxTree_rec(Gia_Man_t *pNew, int *pCtrl, int nCtrl, int *pData)
Definition giaHash.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDecompOne()

int Gia_ManDecompOne ( Gia_Man_t * pNew,
int * pTree,
int nBits,
int * pPerm,
int iLate )

Definition at line 1039 of file giaHash.c.

1040{
1041 int iRes, iData;
1042 assert( iLate >= 0 && iLate < (1<<nBits) );
1043 iData = pTree[nBits+iLate];
1044 pTree[nBits+iLate] = pTree[nBits+(iLate^1)];
1045 iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
1046 return Gia_ManHashMux( pNew, Gia_ManCube(pNew, iLate, nBits, pTree), iData, iRes );
1047}
int Gia_ManCube(Gia_Man_t *pNew, int Vars, int nVars, int *pLits)
Definition giaHash.c:958
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition giaHash.c:692
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDecompThree()

int Gia_ManDecompThree ( Gia_Man_t * pNew,
int * pTree,
int nBits,
int * pPerm,
int iLate1,
int iLate2,
int iLate3 )

Definition at line 1064 of file giaHash.c.

1065{
1066 int iRes, iData1, iData2, iData3, iCube1, iCube2, iCube3, iCtrl0, iCtrl1, iMux10, iMux11;
1067 assert( iLate1 != iLate2 );
1068 assert( iLate1 != iLate3 );
1069 assert( iLate2 != iLate3 );
1070 assert( iLate1 >= 0 && iLate1 < (1<<nBits) );
1071 assert( iLate2 >= 0 && iLate2 < (1<<nBits) );
1072 assert( iLate3 >= 0 && iLate3 < (1<<nBits) );
1073 iData1 = pTree[nBits+iLate1];
1074 iData2 = pTree[nBits+iLate2];
1075 iData3 = pTree[nBits+iLate3];
1076 pTree[nBits+iLate1] = pTree[nBits+(iLate1^1)];
1077 pTree[nBits+iLate2] = pTree[nBits+(iLate2^1)];
1078 pTree[nBits+iLate3] = pTree[nBits+(iLate3^1)];
1079 iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
1080 iCube1 = Gia_ManCube( pNew, iLate1, nBits, pTree );
1081 iCube2 = Gia_ManCube( pNew, iLate2, nBits, pTree );
1082 iCube3 = Gia_ManCube( pNew, iLate3, nBits, pTree );
1083 iCtrl0 = Gia_ManHashOr( pNew, iCube1, iCube3 );
1084 iCtrl1 = Gia_ManHashOr( pNew, iCube2, iCube3 );
1085 iMux10 = Gia_ManHashMux( pNew, iCtrl0, iData1, iRes );
1086 iMux11 = Gia_ManHashMux( pNew, iCtrl0, iData3, iData2 );
1087 return Gia_ManHashMux( pNew, iCtrl1, iMux11, iMux10 );
1088}
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDecompTwo()

int Gia_ManDecompTwo ( Gia_Man_t * pNew,
int * pTree,
int nBits,
int * pPerm,
int iLate1,
int iLate2 )

Definition at line 1048 of file giaHash.c.

1049{
1050 int iRes, iData1, iData2, iData, iCond, iCond2;
1051 assert( iLate1 != iLate2 );
1052 assert( iLate1 >= 0 && iLate1 < (1<<nBits) );
1053 assert( iLate2 >= 0 && iLate2 < (1<<nBits) );
1054 iData1 = pTree[nBits+iLate1];
1055 iData2 = pTree[nBits+iLate2];
1056 pTree[nBits+iLate1] = pTree[nBits+(iLate1^1)];
1057 pTree[nBits+iLate2] = pTree[nBits+(iLate2^1)];
1058 iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
1059 iCond = Gia_ManHashOr( pNew, Gia_ManCube(pNew, iLate1, nBits, pTree), Gia_ManCube(pNew, iLate2, nBits, pTree) );
1060 iCond2 = Gia_ManFindCond( pTree, nBits, iLate1, iLate2 );
1061 iData = Gia_ManHashMux( pNew, iCond2, iData2, iData1 );
1062 return Gia_ManHashMux( pNew, iCond, iData, iRes );
1063}
int Gia_ManFindCond(int *pLits, int nBits, int iLate1, int iLate2)
Definition giaHash.c:1008
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManEarliest()

int Gia_ManEarliest ( int * pPerm,
int nVars )

Definition at line 1028 of file giaHash.c.

1029{
1030 int i, Value = ABC_INFINITY, iLate = -1;
1031 for ( i = 0; i < nVars; i++ )
1032 if ( Value > pPerm[i] )
1033 {
1034 Value = pPerm[i];
1035 iLate = i;
1036 }
1037 return iLate;
1038}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
Here is the caller graph for this function:

◆ Gia_ManFindCond()

int Gia_ManFindCond ( int * pLits,
int nBits,
int iLate1,
int iLate2 )

Definition at line 1008 of file giaHash.c.

1009{
1010 int i;
1011 assert( iLate1 != iLate2 );
1012 for ( i = 0; i < nBits; i++ )
1013 if ( (((iLate1 ^ iLate2) >> i) & 1) )
1014 return Abc_LitNotCond( pLits[i], (iLate1 >> i) & 1 );
1015 return -1;
1016}
Here is the caller graph for this function:

◆ Gia_ManGenPerm()

int * Gia_ManGenPerm ( int nBits)

Definition at line 841 of file giaHash.c.

842{
843 int i, * pRes = ABC_CALLOC( int, nBits );
844 srand( time(NULL) );
845 for ( i = 0; i < nBits; i++ )
846 pRes[i] = i;
847 for ( i = 0; i < nBits; i++ )
848 {
849 int iPerm = rand() % nBits;
850 ABC_SWAP( int, pRes[i], pRes[iPerm] );
851 }
852 return pRes;
853}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
Here is the caller graph for this function:

◆ Gia_ManGenPerm2()

int * Gia_ManGenPerm2 ( int nBits)

Definition at line 854 of file giaHash.c.

855{
856 int i, * pRes = ABC_CALLOC( int, nBits );
857 srand( time(NULL) );
858 for ( i = 0; i < nBits; i++ )
859 pRes[i] = rand() % nBits;
860 return pRes;
861}
Here is the caller graph for this function:

◆ Gia_ManGenZero()

int * Gia_ManGenZero ( int nBits)

Definition at line 837 of file giaHash.c.

838{
839 return ABC_CALLOC( int, nBits );
840}

◆ Gia_ManHashAlloc()

void Gia_ManHashAlloc ( Gia_Man_t * p)

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

Synopsis [Starts the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file giaHash.c.

106{
107 assert( Vec_IntSize(&p->vHTable) == 0 );
108 Vec_IntFill( &p->vHTable, Abc_PrimeCudd( Gia_ManAndNum(p) ? Gia_ManAndNum(p) + 1000 : p->nObjsAlloc ), 0 );
109 Vec_IntGrow( &p->vHash, Abc_MaxInt(Vec_IntSize(&p->vHTable), Gia_ManObjNum(p)) );
110 Vec_IntFill( &p->vHash, Gia_ManObjNum(p), 0 );
111//printf( "Alloced table with %d entries.\n", Vec_IntSize(&p->vHTable) );
112}
Cube * p
Definition exorList.c:222

◆ Gia_ManHashAnd()

int Gia_ManHashAnd ( Gia_Man_t * p,
int iLit0,
int iLit1 )

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

Synopsis [Hashes AND gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 576 of file giaHash.c.

577{
578 if ( iLit0 < 2 )
579 return iLit0 ? iLit1 : 0;
580 if ( iLit1 < 2 )
581 return iLit1 ? iLit0 : 0;
582 if ( iLit0 == iLit1 )
583 return iLit1;
584 if ( iLit0 == Abc_LitNot(iLit1) )
585 return 0;
586 if ( p->fGiaSimple )
587 {
588 assert( Vec_IntSize(&p->vHTable) == 0 );
589 return Gia_ManAppendAnd( p, iLit0, iLit1 );
590 }
591 if ( (p->nObjs & 0xFF) == 0 && 2 * Vec_IntSize(&p->vHTable) < Gia_ManAndNum(p) )
593 if ( p->fAddStrash )
594 {
595 Gia_Obj_t * pObj = Gia_ManAddStrash( p, Gia_ObjFromLit(p, iLit0), Gia_ObjFromLit(p, iLit1) );
596 if ( pObj != NULL )
597 return Gia_ObjToLit( p, pObj );
598 }
599 if ( iLit0 > iLit1 )
600 iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
601 {
602 int * pPlace = Gia_ManHashFind( p, iLit0, iLit1, -1 );
603 if ( *pPlace )
604 {
605 p->nHashHit++;
606 return Abc_Var2Lit( *pPlace, 0 );
607 }
608 p->nHashMiss++;
609 if ( Vec_IntSize(&p->vHash) < Vec_IntCap(&p->vHash) )
610 *pPlace = Abc_Lit2Var( Gia_ManAppendAnd( p, iLit0, iLit1 ) );
611 else
612 {
613 int iNode = Gia_ManAppendAnd( p, iLit0, iLit1 );
614 pPlace = Gia_ManHashFind( p, iLit0, iLit1, -1 );
615 assert( *pPlace == 0 );
616 *pPlace = Abc_Lit2Var( iNode );
617 }
618 return Abc_Var2Lit( *pPlace, 0 );
619 }
620}
void Gia_ManHashResize(Gia_Man_t *p)
Definition giaHash.c:166
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
Here is the call graph for this function:

◆ Gia_ManHashAndMulti()

int Gia_ManHashAndMulti ( Gia_Man_t * p,
Vec_Int_t * vLits )

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

Synopsis [Creates well-balanced AND gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 783 of file giaHash.c.

784{
785 if ( Vec_IntSize(vLits) == 0 )
786 return 0;
787 while ( Vec_IntSize(vLits) > 1 )
788 {
789 int i, k = 0, Lit1, Lit2, LitRes;
790 Vec_IntForEachEntryDouble( vLits, Lit1, Lit2, i )
791 {
792 LitRes = Gia_ManHashAnd( p, Lit1, Lit2 );
793 Vec_IntWriteEntry( vLits, k++, LitRes );
794 }
795 if ( Vec_IntSize(vLits) & 1 )
796 Vec_IntWriteEntry( vLits, k++, Vec_IntEntryLast(vLits) );
797 Vec_IntShrink( vLits, k );
798 }
799 assert( Vec_IntSize(vLits) == 1 );
800 return Vec_IntEntry(vLits, 0);
801}
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManHashAndMulti2()

int Gia_ManHashAndMulti2 ( Gia_Man_t * p,
Vec_Int_t * vLits )

Definition at line 802 of file giaHash.c.

803{
804 int i, iLit, iRes = 1;
805 Vec_IntForEachEntry( vLits, iLit, i )
806 iRes = Gia_ManHashAnd( p, iRes, iLit );
807 return iRes;
808}
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManHashAndTry()

int Gia_ManHashAndTry ( Gia_Man_t * p,
int iLit0,
int iLit1 )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 637 of file giaHash.c.

638{
639 if ( iLit0 < 2 )
640 return iLit0 ? iLit1 : 0;
641 if ( iLit1 < 2 )
642 return iLit1 ? iLit0 : 0;
643 if ( iLit0 == iLit1 )
644 return iLit1;
645 if ( iLit0 == Abc_LitNot(iLit1) )
646 return 0;
647 if ( iLit0 > iLit1 )
648 iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
649 {
650 int * pPlace = Gia_ManHashFind( p, iLit0, iLit1, -1 );
651 if ( *pPlace )
652 return Abc_Var2Lit( *pPlace, 0 );
653 return -1;
654 }
655}
Here is the caller graph for this function:

◆ Gia_ManHashDualMiter()

int Gia_ManHashDualMiter ( Gia_Man_t * p,
Vec_Int_t * vOuts )

Definition at line 809 of file giaHash.c.

810{
811 int i, iLit0, iLit1, iRes = 0;
812 Vec_IntForEachEntryDouble( vOuts, iLit0, iLit1, i )
813 iRes = Gia_ManHashOr( p, iRes, Gia_ManHashXor(p, iLit0, iLit1) );
814 return iRes;
815}
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:668
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManHashLookup()

int Gia_ManHashLookup ( Gia_Man_t * p,
Gia_Obj_t * p0,
Gia_Obj_t * p1 )

Definition at line 87 of file giaHash.c.

88{
89 int iLit0 = Gia_ObjToLit( p, p0 );
90 int iLit1 = Gia_ObjToLit( p, p1 );
91 return Gia_ManHashLookupInt( p, iLit0, iLit1 );
92}
int Gia_ManHashLookupInt(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManHashLookupInt()

int Gia_ManHashLookupInt ( Gia_Man_t * p,
int iLit0,
int iLit1 )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file giaHash.c.

82{
83 if ( iLit0 > iLit1 )
84 iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
85 return Abc_Var2Lit( *Gia_ManHashFind( p, iLit0, iLit1, -1 ), 0 );
86}
Here is the caller graph for this function:

◆ Gia_ManHashMaj()

int Gia_ManHashMaj ( Gia_Man_t * p,
int iData0,
int iData1,
int iData2 )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 720 of file giaHash.c.

721{
722 int iTemp0 = Gia_ManHashOr( p, iData1, iData2 );
723 int iTemp1 = Gia_ManHashAnd( p, iData0, iTemp0 );
724 int iTemp2 = Gia_ManHashAnd( p, iData1, iData2 );
725 return Gia_ManHashOr( p, iTemp1, iTemp2 );
726}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManHashMux()

int Gia_ManHashMux ( Gia_Man_t * p,
int iCtrl,
int iData1,
int iData0 )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 692 of file giaHash.c.

693{
694 if ( p->fGiaSimple )
695 return Gia_ManHashOr(p, Gia_ManHashAnd(p, iCtrl, iData1), Gia_ManHashAnd(p, Abc_LitNot(iCtrl), iData0) );
696 else
697 {
698 int iTemp0, iTemp1, fCompl = 0;
699 if ( iData0 > iData1 )
700 iData0 ^= iData1, iData1 ^= iData0, iData0 ^= iData1, iCtrl = Abc_LitNot(iCtrl);
701 if ( Abc_LitIsCompl(iData1) )
702 iData0 = Abc_LitNot(iData0), iData1 = Abc_LitNot(iData1), fCompl = 1;
703 iTemp0 = Gia_ManHashAnd( p, Abc_LitNot(iCtrl), iData0 );
704 iTemp1 = Gia_ManHashAnd( p, iCtrl, iData1 );
705 return Abc_LitNotCond( Gia_ManHashAnd( p, Abc_LitNot(iTemp0), Abc_LitNot(iTemp1) ), !fCompl );
706 }
707}
Here is the call graph for this function:

◆ Gia_ManHashMuxReal()

int Gia_ManHashMuxReal ( Gia_Man_t * p,
int iLitC,
int iLit1,
int iLit0 )

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

Synopsis [Hashes MUX gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 521 of file giaHash.c.

522{
523 int fCompl = 0;
524 assert( p->fAddStrash == 0 );
525 if ( iLitC < 2 )
526 return iLitC ? iLit1 : iLit0;
527 if ( iLit0 < 2 )
528 return iLit0 ? Gia_ManHashOr(p, Abc_LitNot(iLitC), iLit1) : Gia_ManHashAnd(p, iLitC, iLit1);
529 if ( iLit1 < 2 )
530 return iLit1 ? Gia_ManHashOr(p, iLitC, iLit0) : Gia_ManHashAnd(p, Abc_LitNot(iLitC), iLit0);
531 assert( iLit0 > 1 && iLit1 > 1 && iLitC > 1 );
532 if ( iLit0 == iLit1 )
533 return iLit0;
534 if ( iLitC == iLit0 || iLitC == Abc_LitNot(iLit1) )
535 return Gia_ManHashAnd(p, iLit0, iLit1);
536 if ( iLitC == iLit1 || iLitC == Abc_LitNot(iLit0) )
537 return Gia_ManHashOr(p, iLit0, iLit1);
538 if ( Abc_Lit2Var(iLit0) == Abc_Lit2Var(iLit1) )
539 return Gia_ManHashXorReal( p, iLitC, iLit0 );
540 if ( iLit0 > iLit1 )
541 iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1, iLitC = Abc_LitNot(iLitC);
542 if ( Abc_LitIsCompl(iLit1) )
543 iLit0 = Abc_LitNot(iLit0), iLit1 = Abc_LitNot(iLit1), fCompl = 1;
544 {
545 int *pPlace = Gia_ManHashFind( p, iLit0, iLit1, iLitC );
546 if ( *pPlace )
547 {
548 p->nHashHit++;
549 return Abc_Var2Lit( *pPlace, fCompl );
550 }
551 p->nHashMiss++;
552 if ( Vec_IntSize(&p->vHash) < Vec_IntCap(&p->vHash) )
553 *pPlace = Abc_Lit2Var( Gia_ManAppendMuxReal( p, iLitC, iLit1, iLit0 ) );
554 else
555 {
556 int iNode = Gia_ManAppendMuxReal( p, iLitC, iLit1, iLit0 );
557 pPlace = Gia_ManHashFind( p, iLit0, iLit1, iLitC );
558 assert( *pPlace == 0 );
559 *pPlace = Abc_Lit2Var( iNode );
560 }
561 return Abc_Var2Lit( *pPlace, fCompl );
562 }
563}
int Gia_ManHashXorReal(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:469
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManHashOr()

int Gia_ManHashOr ( Gia_Man_t * p,
int iLit0,
int iLit1 )

Definition at line 621 of file giaHash.c.

622{
623 return Abc_LitNot(Gia_ManHashAnd( p, Abc_LitNot(iLit0), Abc_LitNot(iLit1) ));
624}
Here is the call graph for this function:

◆ Gia_ManHashProfile()

void Gia_ManHashProfile ( Gia_Man_t * p)

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

Synopsis [Profiles the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 207 of file giaHash.c.

208{
209 int iEntry;
210 int i, Counter, Limit;
211 printf( "Table size = %d. Entries = %d. ", Vec_IntSize(&p->vHTable), Gia_ManAndNum(p) );
212 printf( "Hits = %d. Misses = %d.\n", (int)p->nHashHit, (int)p->nHashMiss );
213 Limit = Abc_MinInt( 1000, Vec_IntSize(&p->vHTable) );
214 for ( i = 0; i < Limit; i++ )
215 {
216 Counter = 0;
217 for ( iEntry = Vec_IntEntry(&p->vHTable, i);
218 iEntry;
219 iEntry = iEntry? Vec_IntEntry(&p->vHash, iEntry) : 0 )
220 Counter++;
221 if ( Counter )
222 printf( "%d ", Counter );
223 }
224 printf( "\n" );
225}

◆ Gia_ManHashResize()

void Gia_ManHashResize ( Gia_Man_t * p)

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

Synopsis [Resizes the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file giaHash.c.

167{
168 int i, iThis, iNext, Counter, Counter2, * pPlace;
169 Vec_Int_t vOld = p->vHTable;
170 assert( Vec_IntSize(&vOld) > 0 );
171 // replace the table
172 Vec_IntZero( &p->vHTable );
173 Vec_IntFill( &p->vHTable, Abc_PrimeCudd( 2 * Gia_ManAndNum(p) ), 0 );
174 // rehash the entries from the old table
175 Counter = 0;
176 Vec_IntForEachEntry( &vOld, iThis, i )
177 for ( iNext = Vec_IntEntry(&p->vHash, iThis);
178 iThis; iThis = iNext,
179 iNext = Vec_IntEntry(&p->vHash, iThis) )
180 {
181 Gia_Obj_t * pThis0 = Gia_ManObj( p, iThis );
182 Vec_IntWriteEntry( &p->vHash, iThis, 0 );
183 pPlace = Gia_ManHashFind( p, Gia_ObjFaninLit0(pThis0, iThis), Gia_ObjFaninLit1(pThis0, iThis), Gia_ObjFaninLit2p(p, pThis0) );
184 assert( *pPlace == 0 ); // should not be there
185 *pPlace = iThis;
186 assert( *pPlace != 0 );
187 Counter++;
188 }
189 Counter2 = Gia_ManAndNum(p) - Gia_ManBufNum(p);
190 assert( Counter == Counter2 );
191// if ( p->fVerbose )
192// printf( "Resizing GIA hash table: %d -> %d.\n", Vec_IntSize(&vOld), Vec_IntSize(&p->vHTable) );
193 Vec_IntErase( &vOld );
194}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Here is the caller graph for this function:

◆ Gia_ManHashStart()

void Gia_ManHashStart ( Gia_Man_t * p)

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

Synopsis [Starts the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file giaHash.c.

126{
127 Gia_Obj_t * pObj;
128 int * pPlace, i;
130 Gia_ManForEachAnd( p, pObj, i )
131 {
132 pPlace = Gia_ManHashFind( p, Gia_ObjFaninLit0(pObj, i), Gia_ObjFaninLit1(pObj, i), Gia_ObjFaninLit2(p, i) );
133 assert( *pPlace == 0 );
134 *pPlace = i;
135 }
136}
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
Here is the call graph for this function:

◆ Gia_ManHashStop()

void Gia_ManHashStop ( Gia_Man_t * p)

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

Synopsis [Stops the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file giaHash.c.

150{
151 Vec_IntErase( &p->vHTable );
152 Vec_IntErase( &p->vHash );
153}

◆ Gia_ManHashXor()

int Gia_ManHashXor ( Gia_Man_t * p,
int iLit0,
int iLit1 )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 668 of file giaHash.c.

669{
670 if ( p->fGiaSimple )
671 return Gia_ManHashOr(p, Gia_ManHashAnd(p, iLit0, Abc_LitNot(iLit1)), Gia_ManHashAnd(p, Abc_LitNot(iLit0), iLit1) );
672 else
673 {
674 int fCompl = Abc_LitIsCompl(iLit0) ^ Abc_LitIsCompl(iLit1);
675 int iTemp0 = Gia_ManHashAnd( p, Abc_LitRegular(iLit0), Abc_LitNot(Abc_LitRegular(iLit1)) );
676 int iTemp1 = Gia_ManHashAnd( p, Abc_LitRegular(iLit1), Abc_LitNot(Abc_LitRegular(iLit0)) );
677 return Abc_LitNotCond( Gia_ManHashAnd( p, Abc_LitNot(iTemp0), Abc_LitNot(iTemp1) ), !fCompl );
678 }
679}
Here is the call graph for this function:

◆ Gia_ManHashXorReal()

int Gia_ManHashXorReal ( Gia_Man_t * p,
int iLit0,
int iLit1 )

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

Synopsis [Hashes XOR gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 469 of file giaHash.c.

470{
471 int fCompl = 0;
472 assert( p->fAddStrash == 0 );
473 if ( iLit0 < 2 )
474 return iLit0 ? Abc_LitNot(iLit1) : iLit1;
475 if ( iLit1 < 2 )
476 return iLit1 ? Abc_LitNot(iLit0) : iLit0;
477 if ( iLit0 == iLit1 )
478 return 0;
479 if ( iLit0 == Abc_LitNot(iLit1) )
480 return 1;
481 if ( (p->nObjs & 0xFF) == 0 && 2 * Vec_IntSize(&p->vHTable) < Gia_ManAndNum(p) )
483 if ( iLit0 < iLit1 )
484 iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
485 if ( Abc_LitIsCompl(iLit0) )
486 iLit0 = Abc_LitNot(iLit0), fCompl ^= 1;
487 if ( Abc_LitIsCompl(iLit1) )
488 iLit1 = Abc_LitNot(iLit1), fCompl ^= 1;
489 {
490 int *pPlace = Gia_ManHashFind( p, iLit0, iLit1, -1 );
491 if ( *pPlace )
492 {
493 p->nHashHit++;
494 return Abc_Var2Lit( *pPlace, fCompl );
495 }
496 p->nHashMiss++;
497 if ( Vec_IntSize(&p->vHash) < Vec_IntCap(&p->vHash) )
498 *pPlace = Abc_Lit2Var( Gia_ManAppendXorReal( p, iLit0, iLit1 ) );
499 else
500 {
501 int iNode = Gia_ManAppendXorReal( p, iLit0, iLit1 );
502 pPlace = Gia_ManHashFind( p, iLit0, iLit1, -1 );
503 assert( *pPlace == 0 );
504 *pPlace = Abc_Lit2Var( iNode );
505 }
506 return Abc_Var2Lit( *pPlace, fCompl );
507 }
508}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManLatest()

int Gia_ManLatest ( int * pPerm,
int nVars,
int iPrev1,
int iPrev2,
int iPrev3 )

Definition at line 1017 of file giaHash.c.

1018{
1019 int i, Value = -1, iLate = -1;
1020 for ( i = 0; i < nVars; i++ )
1021 if ( Value < pPerm[i] && i != iPrev1 && i != iPrev2 && i != iPrev3 )
1022 {
1023 Value = pPerm[i];
1024 iLate = i;
1025 }
1026 return iLate;
1027}
Here is the caller graph for this function:

◆ Gia_ManMultiCheck()

int Gia_ManMultiCheck ( int * pPerm,
int nPerm )

Definition at line 862 of file giaHash.c.

863{
864 int i;
865 for ( i = 1; i < nPerm; i++ )
866 if ( pPerm[i-1] <= pPerm[i] )
867 return 0;
868 return 1;
869}

◆ Gia_ManMultiInputPerm()

int Gia_ManMultiInputPerm ( Gia_Man_t * pNew,
int * pVars,
int nVars,
int * pPerm,
int fOr,
int fXor )

Definition at line 870 of file giaHash.c.

871{
872 int fPrint = 1;
873 int i, iLit;
874 if ( fPrint )
875 {
876 for ( i = 0; i < nVars; i++ )
877 printf( "%d ", pPerm[i] );
878 printf( "\n" );
879 }
880 while ( 1 )
881 {
882 for ( i = 1; i < nVars; i++ )
883 if ( pPerm[i-1] >= pPerm[i] )
884 break;
885 if ( i == nVars )
886 break;
887 assert( pPerm[i-1] >= pPerm[i] );
888 if ( pPerm[i-1] > pPerm[i] )
889 {
890 ABC_SWAP( int, pPerm[i-1], pPerm[i] );
891 ABC_SWAP( int, pVars[i-1], pVars[i] );
892 }
893 else
894 {
895 assert( pPerm[i-1] == pPerm[i] );
896 pPerm[i-1]++;
897 if ( fXor )
898 pVars[i-1] = Gia_ManHashXor( pNew, pVars[i-1], pVars[i] );
899 else if ( fOr )
900 pVars[i-1] = Gia_ManHashOr( pNew, pVars[i-1], pVars[i] );
901 else
902 pVars[i-1] = Gia_ManHashAnd( pNew, pVars[i-1], pVars[i] );
903 for ( i = i+1; i < nVars; i++ )
904 {
905 pPerm[i-1] = pPerm[i];
906 pVars[i-1] = pVars[i];
907 }
908 nVars--;
909 }
910 if ( fPrint )
911 {
912 for ( i = 0; i < nVars; i++ )
913 printf( "%d ", pPerm[i] );
914 printf( "\n" );
915 }
916 }
917 iLit = pVars[0];
918 for ( i = 1; i < nVars; i++ )
919 if ( fXor )
920 iLit = Gia_ManHashXor( pNew, iLit, pVars[i] );
921 else if ( fOr )
922 iLit = Gia_ManHashOr( pNew, iLit, pVars[i] );
923 else
924 iLit = Gia_ManHashAnd( pNew, iLit, pVars[i] );
925 return iLit;
926}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManMultiInputTest()

Gia_Man_t * Gia_ManMultiInputTest ( int nBits)

Definition at line 927 of file giaHash.c.

928{
929 Gia_Man_t * pNew;
930 int i, iRes, * pPerm;
931 int * pMulti = Gia_ManCollectLiterals( nBits );
932 pNew = Gia_ManStart( 1000 );
933 pNew->pName = Abc_UtilStrsav( "multi" );
934 for ( i = 0; i < nBits; i++ )
935 Gia_ManAppendCi( pNew );
936 Gia_ManHashAlloc( pNew );
937 pPerm = Gia_ManGenPerm2( nBits );
938 //pPerm = Gia_ManGenZero( nBits );
939 iRes = Gia_ManMultiInputPerm( pNew, pMulti, nBits, pPerm, 0, 0 );
940 Gia_ManAppendCo( pNew, iRes );
941 ABC_FREE( pPerm );
942 ABC_FREE( pMulti );
943 return pNew;
944}
#define ABC_FREE(obj)
Definition abc_global.h:267
int * Gia_ManGenPerm2(int nBits)
Definition giaHash.c:854
int * Gia_ManCollectLiterals(int nVars)
Definition giaHash.c:830
int Gia_ManMultiInputPerm(Gia_Man_t *pNew, int *pVars, int nVars, int *pPerm, int fOr, int fXor)
Definition giaHash.c:870
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
char * pName
Definition gia.h:99
Here is the call graph for this function:

◆ Gia_ManMuxTree_rec()

int Gia_ManMuxTree_rec ( Gia_Man_t * pNew,
int * pCtrl,
int nCtrl,
int * pData )

Definition at line 965 of file giaHash.c.

966{
967 int iLit0, iLit1;
968 if ( nCtrl == 0 )
969 return pData[0];
970 iLit0 = Gia_ManMuxTree_rec( pNew, pCtrl, nCtrl-1, pData );
971 iLit1 = Gia_ManMuxTree_rec( pNew, pCtrl, nCtrl-1, pData + (1<<(nCtrl-1)) );
972 return Gia_ManHashMux( pNew, pCtrl[nCtrl-1], iLit1, iLit0 );
973}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManMuxTreeTest()

Gia_Man_t * Gia_ManMuxTreeTest ( int nBits)

Definition at line 1116 of file giaHash.c.

1117{
1118 Gia_Man_t * pNew;
1119 int i, iLit, nVars = nBits + (1 << nBits);
1120 int * pPerm, * pTree = Gia_ManCollectLiterals( nVars );
1121 pNew = Gia_ManStart( 1000 );
1122 pNew->pName = Abc_UtilStrsav( "mux_tree" );
1123 for ( i = 0; i < nVars; i++ )
1124 Gia_ManAppendCi( pNew );
1125 Gia_ManHashAlloc( pNew );
1126 pPerm = Gia_ManGenPerm( nVars );
1127 //pPerm = Gia_ManGenZero( nVars );
1128 pPerm[nBits+1] = 100;
1129 pPerm[nBits+5] = 100;
1130 pPerm[nBits+4] = 100;
1131 Gia_ManUsePerm( pTree, nBits, pPerm );
1132 iLit = Gia_ManDecomp( pNew, pTree, nBits, pPerm );
1133 Gia_ManAppendCo( pNew, iLit );
1134 ABC_FREE( pPerm );
1135 ABC_FREE( pTree );
1136 return pNew;
1137}
int * Gia_ManGenPerm(int nBits)
Definition giaHash.c:841
int Gia_ManDecomp(Gia_Man_t *pNew, int *pTree, int nBits, int *pPerm)
Definition giaHash.c:1089
void Gia_ManUsePerm(int *pTree, int nBits, int *pPerm)
Definition giaHash.c:974
Here is the call graph for this function:

◆ Gia_ManRehash()

Gia_Man_t * Gia_ManRehash ( Gia_Man_t * p,
int fAddStrash )

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

Synopsis [Rehashes AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 739 of file giaHash.c.

740{
741 Gia_Man_t * pNew, * pTemp;
742 Gia_Obj_t * pObj;
743 int i;
744 pNew = Gia_ManStart( Gia_ManObjNum(p) );
745 pNew->pName = Abc_UtilStrsav( p->pName );
746 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
747 pNew->fAddStrash = fAddStrash;
748 Gia_ManHashAlloc( pNew );
749 Gia_ManConst0(p)->Value = 0;
750 Gia_ManForEachObj( p, pObj, i )
751 {
752 //if ( Gia_ObjIsBuf(pObj) )
753 // pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
754 //else
755 if ( Gia_ObjIsAnd(pObj) )
756 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
757 else if ( Gia_ObjIsCi(pObj) )
758 pObj->Value = Gia_ManAppendCi( pNew );
759 else if ( Gia_ObjIsCo(pObj) )
760 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
761 }
762 Gia_ManHashStop( pNew );
763 pNew->fAddStrash = 0;
764 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
765// printf( "Top gate is %s\n", Gia_ObjFaninC0(Gia_ManCo(pNew, 0))? "OR" : "AND" );
766 pNew = Gia_ManCleanup( pTemp = pNew );
767 Gia_ManStop( pTemp );
768 return pNew;
769}
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
char * pSpec
Definition gia.h:100
int fAddStrash
Definition gia.h:114
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManUsePerm()

void Gia_ManUsePerm ( int * pTree,
int nBits,
int * pPerm )

Definition at line 974 of file giaHash.c.

975{
976 int fPrint = 0;
977 int i, k, m, nVars = nBits + (1 << nBits);
978 if ( fPrint )
979 {
980 for ( i = 0; i < nVars; i++ )
981 printf( "%d ", pPerm[i] );
982 printf( "\n" );
983 }
984 for ( i = 0; i < nBits; i++ )
985 {
986 for ( k = i+1; k < nBits; k++ )
987 if ( pPerm[i] > pPerm[k] )
988 break;
989 if ( k == nBits )
990 break;
991 assert( pPerm[i] > pPerm[k] );
992 ABC_SWAP( int, pPerm[i], pPerm[k] );
993 ABC_SWAP( int, pTree[i], pTree[k] );
994 for ( m = 0; m < (1 << nBits); m++ )
995 if ( ((m >> i) & 1) && !((m >> k) & 1) )
996 {
997 ABC_SWAP( int, pTree[nBits+m], pTree[nBits+(m^(1<<i)^(1<<k))] );
998 ABC_SWAP( int, pPerm[nBits+m], pPerm[nBits+(m^(1<<i)^(1<<k))] );
999 }
1000 }
1001 if ( fPrint )
1002 {
1003 for ( i = 0; i < nVars; i++ )
1004 printf( "%d ", pPerm[i] );
1005 printf( "\n" );
1006 }
1007}
Here is the caller graph for this function: