Skip to content

Commit 9b0786f

Browse files
committed
Experiments with multipliers.
1 parent 53edce3 commit 9b0786f

File tree

7 files changed

+338
-16
lines changed

7 files changed

+338
-16
lines changed

src/aig/gia/gia.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,8 @@ typedef struct Gia_ChMan_t_ Gia_ChMan_t;
14191419
extern Gia_ChMan_t * Gia_ManDupChoicesStart( Gia_Man_t * pGia );
14201420
extern void Gia_ManDupChoicesAdd( Gia_ChMan_t * pMan, Gia_Man_t * pGia );
14211421
extern Gia_Man_t * Gia_ManDupChoicesFinish( Gia_ChMan_t * pMan );
1422+
extern Vec_Int_t * Gia_ManComputeMffc( Gia_Man_t * p, Vec_Int_t * vLits, Vec_Int_t * vOuts );
1423+
extern Gia_Man_t * Gia_ManDupExtractMffc( Gia_Man_t * p, Vec_Int_t * vLits, Vec_Int_t * vAnds, Vec_Int_t * vCos );
14221424
/*=== giaEdge.c ==========================================================*/
14231425
extern void Gia_ManEdgeFromArray( Gia_Man_t * p, Vec_Int_t * vArray );
14241426
extern Vec_Int_t * Gia_ManEdgeToArray( Gia_Man_t * p );

src/aig/gia/giaCut.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ static inline int Gia_CutCompare2( Gia_Cut_t * pCut0, Gia_Cut_t * pCut1 )
292292
}
293293
static inline int Gia_CutCompare( Gia_Cut_t * pCut0, Gia_Cut_t * pCut1 )
294294
{
295-
if ( pCut0->CostF > pCut1->CostF ) return -1;
296-
if ( pCut0->CostF < pCut1->CostF ) return 1;
295+
if ( pCut0->CostF > pCut1->CostF ) return -1;
296+
if ( pCut0->CostF < pCut1->CostF ) return 1;
297297
if ( pCut0->nLeaves < pCut1->nLeaves ) return -1;
298298
if ( pCut0->nLeaves > pCut1->nLeaves ) return 1;
299299
return 0;
@@ -1230,7 +1230,7 @@ void Gia_ManComputeCutsCore( Gia_Man_t * pGia, int nCutSize, int nCutNum, int fT
12301230

12311231
Vec_Wec_t * Gia_ManCompute54Cuts( Gia_Man_t * pGia, int fVerbose )
12321232
{
1233-
Gia_Sto_t * pSto = Gia_ManMatchCutsInt( pGia, 5, 16, 0, fVerbose );
1233+
Gia_Sto_t * pSto = Gia_ManMatchCutsInt( pGia, 5, 8, 0, fVerbose );
12341234
Vec_Wec_t * vRes = Vec_WecAlloc( 1000 );
12351235
Vec_Int_t * vLevel; int i, k, c, * pCut;
12361236
Vec_WecForEachLevel( pSto->vCuts, vLevel, i ) if ( Vec_IntSize(vLevel) ) {

src/aig/gia/giaDup.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6609,6 +6609,64 @@ Gia_Man_t * Gia_ManDupChoicesFinish( Gia_ChMan_t * p )
66096609
return pTemp;
66106610
}
66116611

6612+
/**Function*************************************************************
6613+
6614+
Synopsis [Extracting MFFC of the nodes supported by a set of literals.]
6615+
6616+
Description []
6617+
6618+
SideEffects []
6619+
6620+
SeeAlso []
6621+
6622+
***********************************************************************/
6623+
6624+
// collecting internal nodes and outputs in the MFF of a given set of literals
6625+
Vec_Int_t * Gia_ManComputeMffc( Gia_Man_t * p, Vec_Int_t * vLits, Vec_Int_t * vOuts )
6626+
{
6627+
Vec_Int_t * vTfo = Vec_IntAlloc( 100 );
6628+
Gia_Obj_t * pObj; int i, Lit;
6629+
Vec_IntClear( vOuts );
6630+
Gia_ManIncrementTravId( p );
6631+
Vec_IntForEachEntry( vLits, Lit, i )
6632+
Gia_ObjSetTravIdCurrentId( p, Abc_Lit2Var(Lit) );
6633+
Gia_ManForEachAnd( p, pObj, i ) {
6634+
if ( Gia_ObjIsTravIdCurrentId(p, i) )
6635+
continue;
6636+
if ( Gia_ObjIsTravIdCurrentId(p, Gia_ObjFaninId0(pObj, i)) && Gia_ObjIsTravIdCurrentId(p, Gia_ObjFaninId1(pObj, i)) )
6637+
Gia_ObjSetTravIdCurrentId( p, i ), Vec_IntPush( vTfo, i );
6638+
else if ( Gia_ObjIsTravIdCurrentId(p, Gia_ObjFaninId0(pObj, i)) )
6639+
Vec_IntPushUniqueOrder( vOuts, Gia_ObjFaninId0(pObj, i) );
6640+
else if ( Gia_ObjIsTravIdCurrentId(p, Gia_ObjFaninId1(pObj, i)) )
6641+
Vec_IntPushUniqueOrder( vOuts, Gia_ObjFaninId1(pObj, i) );
6642+
}
6643+
Gia_ManForEachCo( p, pObj, i )
6644+
if ( Gia_ObjIsTravIdCurrentId(p, Gia_ObjFaninId0p(p, pObj)) )
6645+
Vec_IntPushUniqueOrder( vOuts, Gia_ObjFaninId0p(p, pObj) );
6646+
Vec_IntTwoFilter( vOuts, vTfo );
6647+
return vTfo;
6648+
}
6649+
6650+
// extracting the AIG of the MFFC defined by a given set of literals
6651+
Gia_Man_t * Gia_ManDupExtractMffc( Gia_Man_t * p, Vec_Int_t * vLits, Vec_Int_t * vAnds, Vec_Int_t * vCos )
6652+
{
6653+
Gia_Man_t * pNew;
6654+
Gia_Obj_t * pObj;
6655+
int i, Lit;
6656+
pNew = Gia_ManStart( 5000 );
6657+
pNew->pName = Abc_UtilStrsav( p->pName );
6658+
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
6659+
pNew->fGiaSimple = 1;
6660+
Gia_ManConst0(p)->Value = 0;
6661+
Vec_IntForEachEntry( vLits, Lit, i )
6662+
Gia_ManObj(p, Abc_Lit2Var(Lit))->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), Abc_LitIsCompl(Lit) );
6663+
Gia_ManForEachObjVec( vAnds, p, pObj, i )
6664+
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
6665+
Gia_ManForEachObjVec( vCos, p, pObj, i )
6666+
pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
6667+
return pNew;
6668+
}
6669+
66126670
////////////////////////////////////////////////////////////////////////
66136671
/// END OF FILE ///
66146672
////////////////////////////////////////////////////////////////////////

src/aig/gia/giaMulFind.c

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -726,17 +726,25 @@ Vec_Wrd_t * Gia_ManMulFindSim( Vec_Wrd_t * vSim0, Vec_Wrd_t * vSim1, int fSigned
726726
}
727727
return vRes;
728728
}
729-
void Gia_ManMulFindOutputs( Gia_Man_t * p, Vec_Wec_t * vTerms, int fLits, int fVerbose )
729+
Vec_Wrd_t * Gia_ManMulFindSim2( Vec_Wrd_t * vSim0, Vec_Wrd_t * vSim1, int fSigned )
730730
{
731+
extern word * product_many(word *pInfo1, int nBits1, word *pInfo2, int nBits2, int fSigned );
732+
word * pRes = product_many( Vec_WrdArray(vSim0), Vec_WrdSize(vSim0), Vec_WrdArray(vSim1), Vec_WrdSize(vSim1), fSigned );
733+
return Vec_WrdAllocArray( pRes, Vec_WrdSize(vSim0) + Vec_WrdSize(vSim1) );
734+
}
735+
int Gia_ManMulFindOutputs( Gia_Man_t * p, Vec_Wec_t * vTerms, int fLits, int fVerbose )
736+
{
737+
//abctime clkTotal = Abc_Clock();
738+
int nDetected = 0;
731739
Abc_Random(1);
732740
for ( int m = 0; m < Vec_WecSize(vTerms)/3; m++ ) {
733741
Vec_Int_t * vIn0 = Vec_WecEntry(vTerms, 3*m+0);
734742
Vec_Int_t * vIn1 = Vec_WecEntry(vTerms, 3*m+1);
735743
Vec_Int_t * vOut = Vec_WecEntry(vTerms, 3*m+2);
736744
Vec_Wrd_t * vSim0 = Vec_WrdStartRandom( Vec_IntSize(vIn0) );
737745
Vec_Wrd_t * vSim1 = Vec_WrdStartRandom( Vec_IntSize(vIn1) );
738-
Vec_Wrd_t * vSimU = Gia_ManMulFindSim( vSim0, vSim1, 0 );
739-
Vec_Wrd_t * vSimS = Gia_ManMulFindSim( vSim0, vSim1, 1 );
746+
Vec_Wrd_t * vSimU = Gia_ManMulFindSim2( vSim0, vSim1, 0 );
747+
Vec_Wrd_t * vSimS = Gia_ManMulFindSim2( vSim0, vSim1, 1 );
740748
Vec_Int_t * vTfo = Gia_ManMulFindTfo( p, vIn0, vIn1, fLits );
741749
Vec_Wrd_t * vSims = Gia_ManMulFindSimCone( p, vIn0, vIn1, vSim0, vSim1, vTfo, fLits );
742750
Vec_Int_t * vOutU = Vec_IntAlloc( 100 );
@@ -762,10 +770,14 @@ void Gia_ManMulFindOutputs( Gia_Man_t * p, Vec_Wec_t * vTerms, int fLits, int fV
762770
if ( Vec_IntCountEntry(vOutU, -1) < Vec_IntSize(vOutU) ||
763771
Vec_IntCountEntry(vOutS, -1) < Vec_IntSize(vOutS) )
764772
{
765-
if ( Vec_IntCountEntry(vOutU, -1) < Vec_IntCountEntry(vOutS, -1) )
773+
if ( Vec_IntCountEntry(vOutU, -1) < Vec_IntCountEntry(vOutS, -1) ) {
766774
Vec_IntAppend( vOut, vOutU ), Vec_IntPush(vOut, 0);
767-
else
775+
nDetected = Vec_IntSize(vOutU) - Vec_IntCountEntry(vOutU, -1);
776+
}
777+
else {
768778
Vec_IntAppend( vOut, vOutS ), Vec_IntPush(vOut, 1);
779+
nDetected = Vec_IntSize(vOutS) - Vec_IntCountEntry(vOutS, -1);
780+
}
769781
}
770782
else
771783
{
@@ -782,6 +794,8 @@ void Gia_ManMulFindOutputs( Gia_Man_t * p, Vec_Wec_t * vTerms, int fLits, int fV
782794
Vec_IntFree( vOutS );
783795
}
784796
Vec_WecRemoveEmpty( vTerms );
797+
//Abc_PrintTime( 1, "Output detection time", Abc_Clock() - clkTotal );
798+
return nDetected;
785799
}
786800

787801
/**Function*************************************************************
@@ -831,11 +845,28 @@ void Gia_ManMulFindPrintSet( Vec_Int_t * vSet, int fLit, int fSkipLast )
831845
{
832846
int i, Temp, Limit = Vec_IntSize(vSet) - fSkipLast;
833847
printf( "{" );
834-
Vec_IntForEachEntryStop( vSet, Temp, i, Limit ) {
835-
if ( Temp == -1 )
836-
printf( "n/a%s", i < Limit-1 ? " ":"" );
837-
else
838-
printf( "%s%d%s", (fLit & Abc_LitIsCompl(Temp)) ? "~":"", fLit ? Abc_Lit2Var(Temp) : Temp, i < Limit-1 ? " ":"" );
848+
if ( Vec_IntSize(vSet) > 16 ) {
849+
Vec_IntForEachEntryStop( vSet, Temp, i, 4 ) {
850+
if ( Temp == -1 )
851+
printf( "n/a%s", i < Limit-1 ? " ":"" );
852+
else
853+
printf( "%s%d%s", (fLit & Abc_LitIsCompl(Temp)) ? "~":"", fLit ? Abc_Lit2Var(Temp) : Temp, i < Limit-1 ? " ":"" );
854+
}
855+
printf( "... " );
856+
Vec_IntForEachEntryStartStop( vSet, Temp, i, Limit-4, Limit ) {
857+
if ( Temp == -1 )
858+
printf( "n/a%s", i < Limit-1 ? " ":"" );
859+
else
860+
printf( "%s%d%s", (fLit & Abc_LitIsCompl(Temp)) ? "~":"", fLit ? Abc_Lit2Var(Temp) : Temp, i < Limit-1 ? " ":"" );
861+
}
862+
}
863+
else {
864+
Vec_IntForEachEntryStop( vSet, Temp, i, Limit ) {
865+
if ( Temp == -1 )
866+
printf( "n/a%s", i < Limit-1 ? " ":"" );
867+
else
868+
printf( "%s%d%s", (fLit & Abc_LitIsCompl(Temp)) ? "~":"", fLit ? Abc_Lit2Var(Temp) : Temp, i < Limit-1 ? " ":"" );
869+
}
839870
}
840871
printf( "}" );
841872
}

src/misc/util/module.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SRC += src/misc/util/utilBridge.c \
77
src/misc/util/utilIsop.c \
88
src/misc/util/utilLinear.c \
99
src/misc/util/utilMiniver.c \
10+
src/misc/util/utilMulSim.c \
1011
src/misc/util/utilNam.c \
1112
src/misc/util/utilPrefix.cpp \
1213
src/misc/util/utilPth.c \

0 commit comments

Comments
 (0)