ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
utilBSet.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "misc/extra/extra.h"
#include "misc/util/utilTruth.h"
Include dependency graph for utilBSet.c:

Go to the source code of this file.

Classes

struct  Abc_BSEval_t_
 

Macros

#define MAX_TT_SIZE   24
 DECLARATIONS ///.
 

Functions

int Abc_TtGetCM1 (word *p, int nVars)
 FUNCTION DEFINITIONS ///.
 
int Abc_TtGetCM2 (word *p, int nVars)
 
int Abc_TtGetCM3 (word *p, int nVars, int *pCounts, Vec_Int_t *vUsed)
 
int Abc_TtGetCM4 (word *p, int nVars, int *pCounts, Vec_Int_t *vUsed)
 
int Abc_TtGetKey (unsigned char *p, int nSize, int nTableSize)
 
int Abc_TtHashLookup5 (int Entry, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
 
int Abc_TtGetCM5 (word *p, int nVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
 
int Abc_TtHashLookup6 (word *pEntry, int nWords, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
 
int Abc_TtGetCM6 (word *p, int nVars, int nFVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
 
int Abc_TtGetCMCount (word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
 
int Abc_TtGetCM1Pat (word *p, int nVars, word *pPat)
 
int Abc_TtGetCM2Pat (word *p, int nVars, word *pPat)
 
int Abc_TtGetCM3Pat (word *p, int nVars, int *pMap, Vec_Int_t *vUsed, word *pPat)
 
int Abc_TtGetCM4Pat (word *p, int nVars, int *pMap, Vec_Int_t *vUsed, word *pPat)
 
int Abc_TtGetCM5Pat (word *p, int nVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, word *pPat)
 
int Abc_TtGetCM6Pat (word *p, int nVars, int nFVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, word *pPat)
 
void Abc_TtPrintPat (word *pPat, int nVars, int nMyu)
 
int Abc_TtCheck1Shared (word *pPat, int nVars, int nFVars, int nMyu)
 
int Abc_TtGetCMInt (word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, word *pPat)
 
int Abc_TtGetCMPat (word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
 
int Abc_TtGetCM (word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, int fShared)
 
void Abc_TtPermGenTest ()
 
void Abc_GenChaseNext (int a[], int w[], int *r)
 
Vec_Int_tAbc_GenChasePairs (int N, int T)
 
void Abc_GenChasePrint (int Count, int *pPerm, int nVars, int nFVars, int Var0, int Var1)
 
void Abc_GenChaseTest ()
 
Abc_BSEval_tAbc_BSEvalAlloc ()
 
void Abc_BSEvalFree (Abc_BSEval_t *p)
 
void Abc_BSEvalOneTest (word *pT, int nVars, int nLVars, int fVerbose)
 
int Abc_BSEvalBest (Abc_BSEval_t *p, word *pIn, word *pBest, word *pBest2, int nVars, int nCVars, int nFVars, int fVerbose, int *pPermBest, int *pPermBest2, int fShared, int nJRatio)
 
void Abc_BSEvalBestTest (word *pIn, int nVars, int nLVars, int fShared, int fVerbose)
 
void Abc_BSEvalBestGen (int nVars, int nLVars, int nFuncs, int nMints, int fTryAll, int fShared, int fVerbose)
 
void Abc_BSEvalCreateCofs (int iSet, int nVars, Vec_Wrd_t *vCofs, Vec_Wrd_t *vElems)
 
Vec_Wrd_tAbc_BSEvalCreateCofactorSets (int nVars, Vec_Wec_t **pvSets)
 
int Abc_SharedEvalBest (Abc_BSEval_t *p, word *pTruth, int nVars, int nCVars, int nFVars, int MyuMin, int nRails, int fVerbose, int *pSetShared, int *pnSetSize, word *pPat)
 
word Abc_TtFindBVarsSVars (word *pTruth, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int *pMyu, int nJRatio)
 
word Abc_BSEvalEncode (int *pPermBest, int nVars, int nLutSize, int Shared, int MyuMin, int SharedSize)
 
Vec_Wrd_tAbc_TtFindBVarsSVars2 (Abc_BSEval_t *p, word *pTruth, int nVars, int nCVars, int nRails, int nLutSize, int fVerbose, int *pMyu, int nMyuIncrease)
 

Macro Definition Documentation

◆ MAX_TT_SIZE

#define MAX_TT_SIZE   24

DECLARATIONS ///.

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

FileName [utilBSet.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Bound set evaluation.]

Synopsis [Bound set evaluation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - December 25, 2024.]

Revision [

Id
utilBSet.c,v 1.00 2024/12/25 00:00:00 alanmi Exp

]

Definition at line 41 of file utilBSet.c.

Function Documentation

◆ Abc_BSEvalAlloc()

Abc_BSEval_t * Abc_BSEvalAlloc ( )

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

Synopsis [Bound-set evalution for one function.]

Description []

SideEffects []

SeeAlso []

Definition at line 556 of file utilBSet.c.

557{
559 p->vCounts = Vec_IntStartFull( 1 << 16 );
560 p->vTable = Vec_IntStartFull( 997 );
561 p->vUsed = Vec_IntAlloc(100);
562 p->vStore = Vec_WrdAlloc(1000);
563 return p;
564}
struct Abc_BSEval_t_ Abc_BSEval_t
Definition abcCas.c:741
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Cube * p
Definition exorList.c:222
Here is the caller graph for this function:

◆ Abc_BSEvalBest()

int Abc_BSEvalBest ( Abc_BSEval_t * p,
word * pIn,
word * pBest,
word * pBest2,
int nVars,
int nCVars,
int nFVars,
int fVerbose,
int * pPermBest,
int * pPermBest2,
int fShared,
int nJRatio )

Definition at line 596 of file utilBSet.c.

597{
598 int i, k, Var0, Var1, Pla2Var[32], Var2Pla[32];
599 int nPermVars = nVars-nCVars, Count = 0;
600 assert( p->nVars == nPermVars && p->nLVars == nVars-nFVars );
601 for ( i = 0; i < nVars; i++ )
602 Pla2Var[i] = Var2Pla[i] = i;
603 if ( pPermBest )
604 for ( i = 0; i < nVars; i++ )
605 pPermBest[i] = i;
606 int CostBest = 1 << nVars;
607 int CostBest2 = 1 << nVars;
608 int iSave = nJRatio ? (Abc_Random(0) % Vec_IntSize(p->vPairs[p->nVars][p->nLVars])/2) : -1;
609 //printf( "The number of pairs = %d.\n", Vec_IntSize(p->vPairs[p->nVars][p->nLVars])/2 );
610 //int Count = 0;
611 Vec_IntForEachEntryDouble( p->vPairs[p->nVars][p->nLVars], Var0, Var1, i ) {
612 //Abc_GenChasePrint( Count++, Pla2Var, nVars, nFVars, Var0, Var1 );
613 int CostThis = Abc_TtGetCM( pIn, nVars, nFVars, p->vCounts, p->vTable, p->vStore, p->vUsed, fShared );
614 if ( iSave == i/2 ) {
615 CostBest2 = CostThis;
616 if ( pBest2 ) Abc_TtCopy( pBest2, pIn, Abc_Truth6WordNum(nVars), 0 );
617 if ( pPermBest2 ) memcpy( pPermBest2, Pla2Var, sizeof(int)*nVars );
618 }
619 if ( CostBest > CostThis ) {
620 CostBest = CostThis;
621 if ( pBest ) Abc_TtCopy( pBest, pIn, Abc_Truth6WordNum(nVars), 0 );
622 if ( pPermBest ) memcpy( pPermBest, Pla2Var, sizeof(int)*nVars );
623 Count = 1;
624 }
625 else if ( CostBest == CostThis && (Abc_Random(0) % ++Count) == 0 ) {
626 if ( pBest ) Abc_TtCopy( pBest, pIn, Abc_Truth6WordNum(nVars), 0 );
627 if ( pPermBest ) memcpy( pPermBest, Pla2Var, sizeof(int)*nVars );
628 }
629 if ( fVerbose )
630 {
631 printf( "%3d : ", i/2 );
632 for ( k = nCVars-1; k >= 0; k-- )
633 printf( " %d", nVars-nCVars+k );
634 printf( " " );
635 for ( k = nPermVars-1; k >= nFVars; k-- )
636 printf( " %d", Pla2Var[k] );
637 printf( " " );
638 for ( k = nFVars-1; k >= 0; k-- )
639 printf( " %d", Pla2Var[k] );
640 printf( " : Myu = %3d", CostThis );
641 //printf( "\n" );
642 }
643 if ( 0 ) {
644 //word pPat[MAX_PAT_WORD_SIZE];
645 int nRails = 1, Shared = 0, nSetSize = 0;
646 if ( CostThis > (1 << nRails) ) {
647 extern int Abc_SharedEvalBest( Abc_BSEval_t * p, word * pTruth, int nVars, int nCVars, int nFVars, int MyuMin, int nRails, int fVerbose, int * pSetShared, int * pSetSize, word * pPat );
648 int nRailsMin = Abc_SharedEvalBest( p, pIn, nVars, nCVars, nFVars, CostThis, nRails, 0, &Shared, &nSetSize, p->pPat );
649 printf( " RailMin = %d. Shared = %2d. ", nRailsMin, Shared );
650 }
651 }
652 if ( fVerbose )
653 printf( "\n" );
654
655 int iPlace0 = Var2Pla[Var0];
656 int iPlace1 = Var2Pla[Var1];
657 if ( iPlace0 == iPlace1 )
658 continue;
659 Abc_TtSwapVars( pIn, nVars, iPlace0, iPlace1 );
660 Var2Pla[Pla2Var[iPlace0]] = iPlace1;
661 Var2Pla[Pla2Var[iPlace1]] = iPlace0;
662 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
663 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
664 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
665 }
666 for ( i = 0; i < nPermVars; i++ )
667 {
668 int iPlace0 = i;
669 int iPlace1 = Var2Pla[i];
670 if ( iPlace0 == iPlace1 )
671 continue;
672 Abc_TtSwapVars( pIn, nVars, iPlace0, iPlace1 );
673 Var2Pla[Pla2Var[iPlace0]] = iPlace1;
674 Var2Pla[Pla2Var[iPlace1]] = iPlace0;
675 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
676 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
677 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
678 }
679 if ( nJRatio && Abc_Random(0) % nJRatio == 0 ) {
680 CostBest = CostBest2;
681 if ( pBest2 ) Abc_TtCopy( pBest, pBest2, Abc_Truth6WordNum(nVars), 0 );
682 if ( pPermBest2 ) memcpy( pPermBest, pPermBest2, sizeof(int)*nVars );
683 }
684 return CostBest;
685}
unsigned Abc_Random(int fReset)
Definition utilSort.c:1004
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int Abc_TtGetCM(word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, int fShared)
Definition utilBSet.c:380
int Abc_SharedEvalBest(Abc_BSEval_t *p, word *pTruth, int nVars, int nCVars, int nFVars, int MyuMin, int nRails, int fVerbose, int *pSetShared, int *pnSetSize, word *pPat)
Definition utilBSet.c:883
#define assert(ex)
Definition util_old.h:213
char * memcpy()
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
@ Var1
Definition xsatSolver.h:56
@ Var0
Definition xsatSolver.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_BSEvalBestGen()

void Abc_BSEvalBestGen ( int nVars,
int nLVars,
int nFuncs,
int nMints,
int fTryAll,
int fShared,
int fVerbose )

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

Synopsis [Testing on random functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 723 of file utilBSet.c.

724{
725 assert( nVars > nLVars );
726 abctime clkTotal = Abc_Clock();
728 Vec_Int_t * vCounts[2] = { Vec_IntStart(1 << nVars), Vec_IntStart(1 << nVars) };
729 int i, k, Count, nWords = Abc_TtWordNum(nVars);
730 word * pFun = ABC_ALLOC( word, nWords );
731 word * pFun2 = ABC_ALLOC( word, nWords );
732 if ( p->nVars != nVars || p->nLVars != nLVars ) {
733 p->nVars = nVars;
734 p->nLVars = nLVars;
735 if ( p->vPairs[p->nVars][p->nLVars] == NULL )
736 p->vPairs[p->nVars][p->nLVars] = Abc_GenChasePairs( nVars, nLVars );
737 }
738 Abc_Random(1);
739 for ( i = 0; i < nFuncs; i++ ) {
740 if ( nMints == 0 )
741 for ( k = 0; k < nWords; k++ )
742 pFun[k] = Abc_RandomW(0);
743 else {
744 Abc_TtClear( pFun, nWords );
745 for ( k = 0; k < nMints; k++ ) {
746 int iMint = 0;
747 do iMint = Abc_Random(0) % (1 << nVars);
748 while ( Abc_TtGetBit(pFun, iMint) );
749 Abc_TtSetBit( pFun, iMint );
750 }
751 }
752 if ( fVerbose ) {
753 printf( "Function %5d ", i );
754 if ( nMints )
755 printf( "with %d positive minterms ", nMints );
756 if ( nVars <= 8 ) {
757 printf( "has truth table: " );
758 Extra_PrintHex( stdout, (unsigned *)pFun, nVars );
759 }
760 if ( fTryAll )
761 printf( "\n" );
762 else
763 printf( " " );
764 }
765
766 if ( fTryAll )
767 Count = Abc_BSEvalBest( p, pFun, pFun2, NULL, nVars, 0, nVars-nLVars, fVerbose, NULL, NULL, fShared, 0 );
768 else
769 Count = Abc_TtGetCM( pFun, nVars, nVars-nLVars, p->vCounts, p->vTable, p->vStore, p->vUsed, fShared );
770 if ( fVerbose )
771 printf( "Myu = %d\n", Count );
772 Vec_IntAddToEntry( vCounts[0], Count, 1 );
773 Vec_IntAddToEntry( vCounts[1], Abc_Base2Log(Count), 1 );
774 }
775 ABC_FREE( pFun );
776 ABC_FREE( pFun2 );
778 if ( nMints )
779 printf( "Generated %d random %d-var functions with %d positive minterms.\n", nFuncs, nVars, nMints );
780 else
781 printf( "Generated %d random %d-var functions.\n", nFuncs, nVars );
782 if ( fShared ) {
783 printf( "Distribution of the %s number of rails for bound set size %d with one shared variable:\n", fTryAll ? "MINIMUM": "ORIGINAL", nLVars );
784 assert( Vec_IntSum(vCounts[0]) == nFuncs );
785 Vec_IntForEachEntry( vCounts[0], Count, i )
786 if ( Count ) printf( "%d=%d (%.2f %%) ", i, Count, 100.0*Count/nFuncs );
787 printf( "\n" );
788 }
789 else {
790 printf( "Distribution of the %s column multiplicity for bound set size %d with no shared variables:\n", fTryAll ? "MINIMUM": "ORIGINAL", nLVars );
791 assert( Vec_IntSum(vCounts[0]) == nFuncs );
792 Vec_IntForEachEntry( vCounts[0], Count, i )
793 if ( Count ) printf( "%d=%d (%.2f %%) ", i, Count, 100.0*Count/nFuncs );
794 printf( "\n" );
795 printf( "Distribution of the %s number of rails for bound set size %d with no shared variables:\n", fTryAll ? "MINIMUM": "ORIGINAL", nLVars );
796 assert( Vec_IntSum(vCounts[1]) == nFuncs );
797 Vec_IntForEachEntry( vCounts[1], Count, i )
798 if ( Count ) printf( "%d=%d (%.2f %%) ", i, Count, 100.0*Count/nFuncs );
799 printf( "\n" );
800 }
801 Vec_IntFree( vCounts[0] );
802 Vec_IntFree( vCounts[1] );
803 Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
804}
int nWords
Definition abcNpn.c:127
word Abc_RandomW(int fReset)
Definition utilSort.c:1022
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
void Abc_BSEvalFree(Abc_BSEval_t *p)
Definition utilBSet.c:565
Abc_BSEval_t * Abc_BSEvalAlloc()
Definition utilBSet.c:556
int Abc_BSEvalBest(Abc_BSEval_t *p, word *pIn, word *pBest, word *pBest2, int nVars, int nCVars, int nFVars, int fVerbose, int *pPermBest, int *pPermBest2, int fShared, int nJRatio)
Definition utilBSet.c:596
Vec_Int_t * Abc_GenChasePairs(int N, int T)
Definition utilBSet.c:481
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:

◆ Abc_BSEvalBestTest()

void Abc_BSEvalBestTest ( word * pIn,
int nVars,
int nLVars,
int fShared,
int fVerbose )

Definition at line 686 of file utilBSet.c.

687{
688 assert( nVars > nLVars );
689 Abc_BSEval_t * p = Abc_BSEvalAlloc(); int i, pPerm[32] = {0}, pPerm2[32] = {0};
690 if ( p->nVars != nVars || p->nLVars != nLVars ) {
691 p->nVars = nVars;
692 p->nLVars = nLVars;
693 if ( p->vPairs[p->nVars][p->nLVars] == NULL )
694 p->vPairs[p->nVars][p->nLVars] = Abc_GenChasePairs( nVars, nLVars );
695 }
696 word * pFun = ABC_ALLOC( word, Abc_TtWordNum(nVars) );
697 word * pFun2 = ABC_ALLOC( word, Abc_TtWordNum(nVars) );
698 int Best = Abc_BSEvalBest( p, pIn, pFun, pFun2, nVars, 0, nVars-nLVars, fVerbose, pPerm, pPerm2, fShared, 0 );
699 printf( "The minimum %s of the %d-var function with bound-sets of size %d is %d.\n",
700 fShared ? "number of rails" : "column multiplicity", nVars, nLVars, Best );
701 printf( "Original: " ); Extra_PrintHex( stdout, (unsigned *)pIn, nVars ); printf( "\n" );
702 printf( "Permuted: " ); Extra_PrintHex( stdout, (unsigned *)pFun, nVars ); printf( "\n" );
703 printf( "Permutation is " );
704 for ( i = 0; i < nVars; i++ )
705 printf( "%d ", pPerm[i] );
706 printf( "\n" );
707 ABC_FREE( pFun );
708 ABC_FREE( pFun2 );
710}
Here is the call graph for this function:

◆ Abc_BSEvalCreateCofactorSets()

Vec_Wrd_t * Abc_BSEvalCreateCofactorSets ( int nVars,
Vec_Wec_t ** pvSets )

Definition at line 833 of file utilBSet.c.

834{
835 Vec_Wrd_t * vElems = Vec_WrdStartTruthTables6( nVars );
836 Vec_Wrd_t * vCofs = Vec_WrdAlloc( 1000 );
837 Vec_Wec_t * vSets = Vec_WecStart( nVars+1 );
838 int m, nMints = 1 << nVars;
839 for ( m = 0; m < nMints; m++ )
840 {
841 int nOnes = __builtin_popcount(m);
842 Vec_WecPushTwo( vSets, nOnes, m, Vec_WrdSize(vCofs) );
843 Abc_BSEvalCreateCofs( m, nVars, vCofs, vElems );
844 }
845 Vec_WrdFree( vElems );
846 *pvSets = vSets;
847 return vCofs;
848}
void Abc_BSEvalCreateCofs(int iSet, int nVars, Vec_Wrd_t *vCofs, Vec_Wrd_t *vElems)
Definition utilBSet.c:818
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_BSEvalCreateCofs()

void Abc_BSEvalCreateCofs ( int iSet,
int nVars,
Vec_Wrd_t * vCofs,
Vec_Wrd_t * vElems )

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

Synopsis [Finds shared variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 818 of file utilBSet.c.

819{
820 int nWords = Abc_Truth6WordNum(nVars);
821 int m, i, nUsed = 0, pUsed[32], Start = Vec_WrdSize(vCofs);
822 for ( i = 0; i < nVars; i++ )
823 if ( (iSet >> i) & 1 )
824 pUsed[nUsed++] = i;
825 Vec_WrdFillExtra( vCofs, Start + nWords*(1 << nUsed), ~(word)0 );
826 for ( m = 0; m < (1 << nUsed); m++ )
827 {
828 word * pCof = Vec_WrdEntryP(vCofs, Start + m*nWords);
829 for ( i = 0; i < nUsed; i++ )
830 Abc_TtAndSharp( pCof, pCof, Vec_WrdEntryP(vElems, nWords*pUsed[i]), nWords, ((m >> i) & 1) == 0 );
831 }
832}
Here is the caller graph for this function:

◆ Abc_BSEvalEncode()

word Abc_BSEvalEncode ( int * pPermBest,
int nVars,
int nLutSize,
int Shared,
int MyuMin,
int SharedSize )

Definition at line 997 of file utilBSet.c.

998{
999 int v;
1000 word mBVars = 0;
1001 for ( v = 0; v < nLutSize; v++ )
1002 mBVars |= (word)1 << pPermBest[nVars-nLutSize+v];
1003 word mSVars = 0;
1004 for ( v = 0; v < nLutSize; v++ )
1005 if ( (Shared >> v) & 1 )
1006 mSVars |= (word)1 << (nVars-nLutSize+v);
1007 return ((word)MyuMin << 48) | (mSVars << 24) | mBVars;
1008}
Here is the caller graph for this function:

◆ Abc_BSEvalFree()

void Abc_BSEvalFree ( Abc_BSEval_t * p)

Definition at line 565 of file utilBSet.c.

566{
567 for ( int i = 0; i < MAX_TT_SIZE; i++ )
568 for ( int k = 0; k < MAX_TT_SIZE; k++ )
569 Vec_IntFreeP( &p->vPairs[i][k] );
570 Vec_IntFree( p->vCounts );
571 Vec_IntFree( p->vTable );
572 Vec_IntFree( p->vUsed );
573 Vec_WrdFree( p->vStore );
574 for ( int i = 0; i < MAX_TT_SIZE; i++ )
575 Vec_WecFreeP( &p->vSets[i] );
576 for ( int i = 0; i < MAX_TT_SIZE; i++ )
577 Vec_WrdFreeP( &p->vCofs[i] );
578 ABC_FREE( p->pPat );
579 ABC_FREE( p );
580}
#define MAX_TT_SIZE
DECLARATIONS ///.
Definition utilBSet.c:41
Here is the caller graph for this function:

◆ Abc_BSEvalOneTest()

void Abc_BSEvalOneTest ( word * pT,
int nVars,
int nLVars,
int fVerbose )

Definition at line 581 of file utilBSet.c.

582{
583 assert( nVars > nLVars );
585 if ( p->nVars != nVars || p->nLVars != nLVars ) {
586 p->nVars = nVars;
587 p->nLVars = nLVars;
588 if ( p->vPairs[p->nVars][p->nLVars] == NULL )
589 p->vPairs[p->nVars][p->nLVars] = Abc_GenChasePairs( nVars, nLVars );
590 }
591 int Best = Abc_TtGetCM( pT, nVars, nVars-nLVars, p->vCounts, p->vTable, p->vStore, p->vUsed, 0 );
592 printf( "Function: " ); Extra_PrintHex( stdout, (unsigned *)pT, nVars ); printf( "\n" );
593 printf( "The column multiplicity of the %d-var function with bound-sets of size %d is %d.\n", nVars, nLVars, Best );
595}
Here is the call graph for this function:

◆ Abc_GenChaseNext()

void Abc_GenChaseNext ( int a[],
int w[],
int * r )

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

Synopsis [Combination generation.]

Description [https://stackoverflow.com/questions/22650522/how-to-generate-chases-sequence]

SideEffects []

SeeAlso []

Definition at line 456 of file utilBSet.c.

457{
458 int found_r = 0;
459 int j;
460 for (j = *r; !w[j]; j++) {
461 int b = a[j] + 1;
462 int n = a[j + 1];
463 if (b < (w[j + 1] ? n - (2 - (n & 1)) : n)) {
464 if ((b & 1) == 0 && b + 1 < n) b++;
465 a[j] = b;
466 if (!found_r) *r = j > 1 ? j - 1 : 0;
467 return;
468 }
469 w[j] = a[j] - 1 >= j;
470 if (w[j] && !found_r) {
471 *r = j;
472 found_r = 1;
473 }
474 }
475 int b = a[j] - 1;
476 if ((b & 1) != 0 && b - 1 >= j) b--;
477 a[j] = b;
478 w[j] = b - 1 >= j;
479 if (!found_r) *r = j;
480}
Here is the caller graph for this function:

◆ Abc_GenChasePairs()

Vec_Int_t * Abc_GenChasePairs ( int N,
int T )

Definition at line 481 of file utilBSet.c.

482{
483 Vec_Int_t * vPairs = Vec_IntAlloc( 100 );
484 int j, z, r = 0, Count = 0, a[32], b[32], w[32];
485 for ( j = 0; j < T + 1; j++ ) {
486 a[j] = N - (T - j);
487 w[j] = 1;
488 }
489 do {
490 for ( z = 0; z <= T; z++ )
491 b[z] = a[z];
492 Abc_GenChaseNext( a, w, &r );
493 for ( z = 0; z < T; z++ ) {
494 if ( a[z] == b[z] )
495 continue;
496 Vec_IntPushTwo( vPairs, b[z], a[z] );
497 if ( 0 ) {
498 printf( "%3d : ", Count++ );
499 for (j = T - 1; j > -1; j--) printf("%x", b[j]);
500 printf( " %d <-> %d ", b[z], a[z] );
501 for (j = T - 1; j > -1; j--) printf("%x", a[j]);
502 printf( "\n" );
503 }
504 break;
505 }
506 } while (a[T] == N);
507 Vec_IntPushTwo( vPairs, 0, 0 );
508 return vPairs;
509}
void Abc_GenChaseNext(int a[], int w[], int *r)
Definition utilBSet.c:456
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GenChasePrint()

void Abc_GenChasePrint ( int Count,
int * pPerm,
int nVars,
int nFVars,
int Var0,
int Var1 )

Definition at line 510 of file utilBSet.c.

511{
512 int k;
513 printf( "%3d : ", Count++ );
514 for ( k = nVars-1; k >= nFVars; k-- )
515 printf( "%d", pPerm[k] );
516 printf( " " );
517 for ( k = nFVars-1; k >= 0; k-- )
518 printf( "%d", pPerm[k] );
519 printf( " %d <-> %d\n", Var0, Var1 );
520}
Here is the caller graph for this function:

◆ Abc_GenChaseTest()

void Abc_GenChaseTest ( )

Definition at line 521 of file utilBSet.c.

522{
523 int nVars = 4;
524 int nFVars = 2;
525 Vec_Int_t * vPairs = Abc_GenChasePairs( nVars, nVars-nFVars );
526 int i, Var0, Var1, Pla2Var[32], Var2Pla[32];
527 for ( i = 0; i < nVars; i++ )
528 Pla2Var[i] = Var2Pla[i] = i;
529 int Count = 0;
530 Vec_IntForEachEntryDouble( vPairs, Var0, Var1, i ) {
531 Abc_GenChasePrint( Count++, Pla2Var, nVars, nFVars, Var0, Var1 );
532 int iPlace0 = Var2Pla[Var0];
533 int iPlace1 = Var2Pla[Var1];
534 //Abc_TtSwapVars( pTruth, nVars, iPlace0, iPlace1 );
535 Var2Pla[Pla2Var[iPlace0]] = iPlace1;
536 Var2Pla[Pla2Var[iPlace1]] = iPlace0;
537 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
538 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
539 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
540 }
541 Vec_IntFree( vPairs );
542}
void Abc_GenChasePrint(int Count, int *pPerm, int nVars, int nFVars, int Var0, int Var1)
Definition utilBSet.c:510
Here is the call graph for this function:

◆ Abc_SharedEvalBest()

int Abc_SharedEvalBest ( Abc_BSEval_t * p,
word * pTruth,
int nVars,
int nCVars,
int nFVars,
int MyuMin,
int nRails,
int fVerbose,
int * pSetShared,
int * pnSetSize,
word * pPat )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 883 of file utilBSet.c.

884{
885 int nBSWords = Abc_Truth6WordNum( nVars - nFVars ), CVarMask = nCVars ? Abc_InfoMask(nCVars) << (nVars - nCVars - nFVars) : 0;
886 int MyuCur, Myu = Abc_TtGetCMInt( pTruth, nVars, nFVars, p->vCounts, p->vTable, p->vStore, p->vUsed, pPat );
887 int nRailsCur = Abc_Base2Log( Myu ); Vec_Int_t * vLevel;
888 assert( Myu == MyuMin && nRailsCur >= nRails );
889 int i, k, iSet, iStart, nSharedMax = nVars - nFVars - nRails, nRailsMin = 100;
890 Vec_WecForEachLevelStartStop( p->vSets[p->nBVars], vLevel, i, 1, nSharedMax ) {
891 Vec_IntForEachEntryDouble( vLevel, iSet, iStart, k ) {
892 if ( iSet & CVarMask )
893 continue;
894 //printf( "\nTrying set " ); Extra_PrintBinary( stdout, &iSet, nVars-nFVars ); printf( "\n" );
895 MyuCur = Abc_BSEvalCountUniqueMax( pPat, Myu, nBSWords, Vec_WrdEntryP(p->vCofs[p->nBVars], iStart), i, 1 << nRails );
896 //printf( " Res = %d", MyuCur );
897 if ( MyuCur == 0 || MyuCur > (1 << nRails) )
898 continue;
899 nRailsCur = Abc_Base2Log(MyuCur);
900 if ( nRailsCur > nRails )
901 continue;
902 if ( nRailsMin > nRailsCur ) {
903 nRailsMin = nRailsCur;
904 *pSetShared = iSet;
905 *pnSetSize = i;
906 }
907 }
908 if ( nRailsMin <= nRails )
909 break;
910 }
911 return nRailsMin;
912}
int Abc_TtGetCMInt(word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, word *pPat)
Definition utilBSet.c:348
#define Vec_WecForEachLevelStartStop(vGlob, vVec, i, LevelStart, LevelStop)
Definition vecWec.h:63
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCheck1Shared()

int Abc_TtCheck1Shared ( word * pPat,
int nVars,
int nFVars,
int nMyu )

Definition at line 322 of file utilBSet.c.

323{
324 int fVerbose = 0;
325 if ( fVerbose ) Abc_TtPrintPat( pPat, nVars-nFVars, nMyu );
326 assert( nMyu > 2 );
327 int nRails = Abc_Base2Log(nMyu);
328 int nMyuMax = 1 << (nRails - 1);
329 for ( int v = 0; v < nVars - nFVars; v++ ) {
330 int m, n, Counts[2] = {0};
331 for ( n = 0; n < 2; n++ ) {
332 for ( m = 0; m < nMyu; m++ )
333 if ( (Counts[n] += ((s_Truth26[n][v] & pPat[m]) != 0)) > nMyuMax )
334 break;
335 if ( m < nMyu )
336 break;
337 }
338 if ( fVerbose ) printf( "%d : %2d %2d %2d\n", v, Counts[0], Counts[1], nMyuMax );
339 if ( n == 2 ) {
340 //Abc_TtPrintPat( pPat, nVars-nFVars, nMyu );
341 //printf( "%d : %2d %2d %2d\n", v, Counts[0], Counts[1], nMyuMax );
342 return nRails - 1;
343 }
344 }
345 if ( fVerbose ) printf( "Not found\n" );
346 return nRails;
347}
void Abc_TtPrintPat(word *pPat, int nVars, int nMyu)
Definition utilBSet.c:316
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtFindBVarsSVars()

word Abc_TtFindBVarsSVars ( word * pTruth,
int nVars,
int nRVars,
int nRails,
int nLutSize,
int fVerbose,
int * pMyu,
int nJRatio )

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

Synopsis [Computes bound set and shared set of the next stage.]

Description []

SideEffects []

SeeAlso []

Definition at line 925 of file utilBSet.c.

926{
928 int nPermVars = nVars-nRVars;
929 if ( p->nVars != nPermVars ) {
930 p->nVars = nPermVars;
931 p->nLVars = nLutSize-nRVars;
932 if ( p->vPairs[p->nVars][p->nLVars] == NULL )
933 p->vPairs[p->nVars][p->nLVars] = Abc_GenChasePairs( p->nVars, p->nLVars );
934 }
935 if ( p->nBVars != nLutSize ) {
936 if ( p->vCofs[nLutSize] == NULL )
937 p->vCofs[nLutSize] = Abc_BSEvalCreateCofactorSets( nLutSize, &p->vSets[nLutSize] );
938 if ( p->nBVars < nLutSize ) {
939 ABC_FREE( p->pPat );
940 p->pPat = ABC_ALLOC( word, (1 << nLutSize)*Abc_TtWordNum(nLutSize) );
941 }
942 p->nBVars = nLutSize;
943 }
944
945 int v, r, nWords = Abc_TtWordNum(nVars);
946 word * pCopy = ABC_ALLOC( word, nWords );
947 Abc_TtCopy( pCopy, pTruth, nWords, 0 );
948 //word pPat[MAX_PAT_WORD_SIZE];
949
950 int pPermBest[32] = {0};
951 int pPermBest2[32] = {0};
952 word * pBest = ABC_ALLOC( word, nWords );
953 word * pBest2 = ABC_ALLOC( word, nWords );
954 //printf("Function before: "); Abc_TtPrintHexRev( stdout, pCopy, nVars ); printf( "\n" );
955 int MyuMin = Abc_BSEvalBest( p, pCopy, pBest, pBest2, nVars, nRVars, nVars-nLutSize, 0, pPermBest, pPermBest2, 0, nJRatio );
956 //printf("Function before: "); Abc_TtPrintHexRev( stdout, pCopy, nVars ); printf( "\n" );
957 if ( pMyu ) *pMyu = MyuMin;
958
959 if ( fVerbose ) {
960 printf( "Best perm: " );
961 for ( v = 0; v < nVars; v++ )
962 printf( "%d ", pPermBest[v] );
963 printf( " Myu = %d. ", MyuMin );
964 }
965
966 int Shared = 0, nSetSize = 0, nRailsMin = Abc_Base2Log( MyuMin );
967 for ( r = 1; r <= nRails && nRailsMin > r; r++ ) {
968 int nRailsMinNew = Abc_SharedEvalBest( p, pBest, nVars, nRVars, nVars-nLutSize, MyuMin, r, 0, &Shared, &nSetSize, p->pPat );
969 if ( nRailsMinNew < 100 )
970 nRailsMin = nRailsMinNew;
971 }
972 MyuMin = 1 << nRailsMin;
973
974 ABC_FREE( pCopy );
975 ABC_FREE( pBest );
976 ABC_FREE( pBest2 );
978
979 if ( fVerbose )
980 printf( "Myu min = %d. Rail min = %d. Shared = %x.\n", MyuMin, nRailsMin, Shared );
981
982 if ( nRailsMin > nRails )
983 return 0;
984
985 word mBVars = 0;
986 for ( v = 0; v < nLutSize; v++ )
987 mBVars |= (word)1 << pPermBest[nVars-nLutSize+v];
988
989 word mSVars = 0;
990 for ( v = 0; v < nLutSize; v++ )
991 if ( (Shared >> v) & 1 )
992 mSVars |= (word)1 << (nVars-nLutSize+v);
993
994 return ((word)MyuMin << 48) | (mSVars << 24) | mBVars;
995}
Vec_Wrd_t * Abc_BSEvalCreateCofactorSets(int nVars, Vec_Wec_t **pvSets)
Definition utilBSet.c:833
Here is the call graph for this function:

◆ Abc_TtFindBVarsSVars2()

Vec_Wrd_t * Abc_TtFindBVarsSVars2 ( Abc_BSEval_t * p,
word * pTruth,
int nVars,
int nCVars,
int nRails,
int nLutSize,
int fVerbose,
int * pMyu,
int nMyuIncrease )

Definition at line 1009 of file utilBSet.c.

1010{
1011// Abc_BSEval_t * p = Abc_BSEvalAlloc();
1012 int nFVars = nVars-nLutSize;
1013 int nPermVars = nVars-nCVars;
1014
1015 if ( p->nVars != nPermVars ) {
1016 p->nVars = nPermVars;
1017 p->nLVars = nLutSize-nCVars;
1018 if ( p->vPairs[p->nVars][p->nLVars] == NULL )
1019 p->vPairs[p->nVars][p->nLVars] = Abc_GenChasePairs( p->nVars, p->nLVars );
1020 }
1021 if ( p->nBVars != nLutSize ) {
1022 if ( p->vCofs[nLutSize] == NULL )
1023 p->vCofs[nLutSize] = Abc_BSEvalCreateCofactorSets( nLutSize, &p->vSets[nLutSize] );
1024 if ( p->nBVars < nLutSize ) {
1025 ABC_FREE( p->pPat );
1026 p->pPat = ABC_ALLOC( word, (1 << nLutSize)*Abc_TtWordNum(nLutSize) );
1027 }
1028 p->nBVars = nLutSize;
1029 }
1030
1031 int nWords = Abc_TtWordNum(nVars);
1032 word * pCopy = ABC_ALLOC( word, nWords );
1033 Abc_TtCopy( pCopy, pTruth, nWords, 0 );
1034
1035 Vec_Wrd_t * vRes = Vec_WrdAlloc( 10 );
1036 int i, k, Var0, Var1, Pla2Var[32], Var2Pla[32];
1037 for ( i = 0; i < nVars; i++ )
1038 Pla2Var[i] = Var2Pla[i] = i;
1039 int MyuOrigBest = 1 << nVars;
1040 int MyuBest = 1 << nVars;
1041 int nSetSizeBest = nVars;
1042
1043 if ( pMyu ) *pMyu = 1 << nVars;
1044 Vec_IntForEachEntryDouble( p->vPairs[p->nVars][p->nLVars], Var0, Var1, i ) {
1045 int MyuThis = Abc_TtGetCM( pCopy, nVars, nFVars, p->vCounts, p->vTable, p->vStore, p->vUsed, 0 );
1046 MyuOrigBest = Abc_MinInt( MyuOrigBest, MyuThis );
1047 if ( pMyu ) *pMyu = Abc_MinInt( *pMyu, MyuThis );
1048 if ( fVerbose )
1049 {
1050 printf( "%3d : ", i/2 );
1051 for ( k = nCVars-1; k >= 0; k-- )
1052 printf( " %d", nVars-nCVars+k );
1053 printf( " " );
1054 for ( k = nPermVars-1; k >= nFVars; k-- )
1055 printf( " %d", Pla2Var[k] );
1056 printf( " " );
1057 for ( k = nFVars-1; k >= 0; k-- )
1058 printf( " %d", Pla2Var[k] );
1059 printf( " : Myu = %3d", MyuThis );
1060 }
1061 if ( MyuThis <= MyuOrigBest + nMyuIncrease ) {
1062 int Shared = 0, nSetSize = 0;
1063 if ( MyuThis > 2 ) {
1064 int SharedThis = 0, nSetSizeThis = 0;
1065 int nRailsMin = 100;
1066 for ( int r = 1; r <= nRails && nRailsMin > r; r++ ) {
1067 int nRailsMinNew = Abc_SharedEvalBest( p, pCopy, nVars, nCVars, nFVars, MyuThis, r, 0, &SharedThis, &nSetSizeThis, p->pPat );
1068 if ( nRailsMinNew < 100 )
1069 nRailsMin = nRailsMinNew;
1070 }
1071 if ( fVerbose )
1072 printf( " RailsMyu = %3d. RailsMin = %3d. Shared = %2d. SetSize = %d.", Abc_Base2Log(MyuThis), nRailsMin, SharedThis, nSetSizeThis );
1073 if ( nRailsMin <= nRails ) {
1074 MyuThis = 1 << nRailsMin;
1075 Shared = SharedThis;
1076 nSetSize = nSetSizeThis;
1077 }
1078 }
1079 if ( MyuBest > MyuThis || (MyuBest == MyuThis && nSetSizeBest >= nSetSize) ) {
1080 int fSave = (MyuBest == MyuThis && nSetSizeBest == nSetSize);
1081 MyuBest = MyuThis;
1082 nSetSizeBest = nSetSize;
1083 word Result = Abc_BSEvalEncode( Pla2Var, nVars, nLutSize, Shared, MyuBest, nSetSize );
1084 if ( fSave )
1085 Vec_WrdPush( vRes, Result );
1086 else
1087 Vec_WrdFill( vRes, 1, Result );
1088 if ( fVerbose )
1089 printf( " <== best" );
1090 }
1091 }
1092 if ( fVerbose )
1093 printf( "\n" );
1094 int iPlace0 = Var2Pla[Var0];
1095 int iPlace1 = Var2Pla[Var1];
1096 if ( iPlace0 == iPlace1 )
1097 continue;
1098 Abc_TtSwapVars( pCopy, nVars, iPlace0, iPlace1 );
1099 Var2Pla[Pla2Var[iPlace0]] = iPlace1;
1100 Var2Pla[Pla2Var[iPlace1]] = iPlace0;
1101 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
1102 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
1103 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
1104 }
1105 for ( i = 0; i < nPermVars; i++ )
1106 {
1107 int iPlace0 = i;
1108 int iPlace1 = Var2Pla[i];
1109 if ( iPlace0 == iPlace1 )
1110 continue;
1111 Abc_TtSwapVars( pCopy, nVars, iPlace0, iPlace1 );
1112 Var2Pla[Pla2Var[iPlace0]] = iPlace1;
1113 Var2Pla[Pla2Var[iPlace1]] = iPlace0;
1114 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
1115 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
1116 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
1117 }
1118 if ( !Abc_TtEqual(pCopy, pTruth, nWords) )
1119 printf( "Internal truth table check failed.\n" );
1120
1121// Abc_BSEvalFree(p);
1122 if ( MyuBest > (1 << nRails) ) {
1123 Vec_WrdFree(vRes);
1124 return NULL;
1125 }
1126 if ( fVerbose )
1127 printf( "COllected %d solutions with MyuMin = %d and SharedSize = %d.\n", Vec_WrdSize(vRes), MyuBest, nSetSizeBest );
1128 return vRes;
1129}
word Abc_BSEvalEncode(int *pPermBest, int nVars, int nLutSize, int Shared, int MyuMin, int SharedSize)
Definition utilBSet.c:997
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM()

int Abc_TtGetCM ( word * p,
int nVars,
int nFVars,
Vec_Int_t * vCounts,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed,
int fShared )

Definition at line 380 of file utilBSet.c.

381{
382 if ( fShared )
383 return Abc_TtGetCMPat( p, nVars, nFVars, vCounts, vTable, vStore, vUsed );
384 return Abc_TtGetCMCount( p, nVars, nFVars, vCounts, vTable, vStore, vUsed );
385}
int Abc_TtGetCMPat(word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
Definition utilBSet.c:371
int Abc_TtGetCMCount(word *p, int nVars, int nFVars, Vec_Int_t *vCounts, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
Definition utilBSet.c:192
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM1()

int Abc_TtGetCM1 ( word * p,
int nVars )

FUNCTION DEFINITIONS ///.

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

Synopsis [Bound-set evalution.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file utilBSet.c.

75{
76 int Counts[4] = {0};
77 int i, Res = 0, nDigits = 1 << (nVars - 1);
78 for ( i = 0; i < nDigits; i++ )
79 Counts[Abc_TtGetQua(p, i)]++;
80 for ( i = 0; i < 4; i++ )
81 Res += Counts[i] > 0;
82 return Res;
83}
Here is the caller graph for this function:

◆ Abc_TtGetCM1Pat()

int Abc_TtGetCM1Pat ( word * p,
int nVars,
word * pPat )

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

Synopsis [Bound-set evalution.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file utilBSet.c.

222{
223 int nUsed = 0, pUsed[4], pMap[4];
224 int i, nDigits = 1 << (nVars - 1), nWordsBS = Abc_TtWordNum(nVars - 1);
225 memset( pMap, 0xFF, 16 );
226 for ( i = 0; i < nDigits; i++ ) {
227 int Digit = Abc_TtGetQua(p, i);
228 if ( pMap[Digit] == -1 ) {
229 pMap[Digit] = nUsed;
230 pUsed[nUsed++] = Digit;
231 }
232 if ( pPat ) Abc_TtSetBit( pPat + nWordsBS*pMap[Digit], i );
233 }
234 return nUsed;
235}
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM2()

int Abc_TtGetCM2 ( word * p,
int nVars )

Definition at line 84 of file utilBSet.c.

85{
86 int Counts[16] = {0};
87 int i, Res = 0, nDigits = 1 << (nVars - 2);
88 for ( i = 0; i < nDigits; i++ )
89 Counts[Abc_TtGetHex(p, i)]++;
90 for ( i = 0; i < 16; i++ )
91 Res += Counts[i] > 0;
92 return Res;
93}
Here is the caller graph for this function:

◆ Abc_TtGetCM2Pat()

int Abc_TtGetCM2Pat ( word * p,
int nVars,
word * pPat )

Definition at line 236 of file utilBSet.c.

237{
238 int nUsed = 0, pUsed[16], pMap[16];
239 int i, nDigits = 1 << (nVars - 2), nWordsBS = Abc_TtWordNum(nVars - 2);
240 memset( pMap, 0xFF, 64 );
241 for ( i = 0; i < nDigits; i++ ) {
242 int Digit = Abc_TtGetHex(p, i);
243 if ( pMap[Digit] == -1 ) {
244 pMap[Digit] = nUsed;
245 pUsed[nUsed++] = Digit;
246 }
247 if ( pPat ) Abc_TtSetBit( pPat + nWordsBS*pMap[Digit], i );
248 }
249 return nUsed;
250}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM3()

int Abc_TtGetCM3 ( word * p,
int nVars,
int * pCounts,
Vec_Int_t * vUsed )

Definition at line 94 of file utilBSet.c.

95{
96 unsigned char * q = (unsigned char *)p;
97 int i, Digit, nDigits = 1 << (nVars - 3);
98 Vec_IntClear( vUsed );
99 for ( i = 0; i < nDigits; i++ ) {
100 if ( pCounts[q[i]] == 1 )
101 continue;
102 pCounts[q[i]] = 1;
103 Vec_IntPush(vUsed, q[i]);
104 }
105 Vec_IntForEachEntry( vUsed, Digit, i )
106 pCounts[Digit] = -1;
107 return Vec_IntSize(vUsed);
108}
Here is the caller graph for this function:

◆ Abc_TtGetCM3Pat()

int Abc_TtGetCM3Pat ( word * p,
int nVars,
int * pMap,
Vec_Int_t * vUsed,
word * pPat )

Definition at line 251 of file utilBSet.c.

252{
253 unsigned char * q = (unsigned char *)p;
254 int i, Digit, nDigits = 1 << (nVars - 3), nWordsBS = Abc_TtWordNum(nVars - 3);
255 Vec_IntClear( vUsed );
256 for ( i = 0; i < nDigits; i++ ) {
257 if ( pMap[q[i]] == -1 ) {
258 pMap[q[i]] = Vec_IntSize(vUsed);
259 Vec_IntPush(vUsed, q[i]);
260 }
261 if ( pPat ) Abc_TtSetBit( pPat + nWordsBS*pMap[q[i]], i );
262 }
263 Vec_IntForEachEntry( vUsed, Digit, i )
264 pMap[Digit] = -1;
265 return Vec_IntSize(vUsed);
266}
Here is the caller graph for this function:

◆ Abc_TtGetCM4()

int Abc_TtGetCM4 ( word * p,
int nVars,
int * pCounts,
Vec_Int_t * vUsed )

Definition at line 109 of file utilBSet.c.

110{
111 unsigned short * q = (unsigned short *)p;
112 int i, Digit, nDigits = 1 << (nVars - 4);
113 Vec_IntClear( vUsed );
114 for ( i = 0; i < nDigits; i++ ) {
115 if ( pCounts[q[i]] == 1 )
116 continue;
117 pCounts[q[i]] = 1;
118 Vec_IntPush(vUsed, q[i]);
119 }
120 Vec_IntForEachEntry( vUsed, Digit, i )
121 pCounts[Digit] = -1;
122 return Vec_IntSize(vUsed);
123}
Here is the caller graph for this function:

◆ Abc_TtGetCM4Pat()

int Abc_TtGetCM4Pat ( word * p,
int nVars,
int * pMap,
Vec_Int_t * vUsed,
word * pPat )

Definition at line 267 of file utilBSet.c.

268{
269 unsigned short * q = (unsigned short *)p;
270 int i, Digit, nDigits = 1 << (nVars - 4), nWordsBS = Abc_TtWordNum(nVars - 4);
271 Vec_IntClear( vUsed );
272 for ( i = 0; i < nDigits; i++ ) {
273 if ( pMap[q[i]] == -1 ) {
274 pMap[q[i]] = Vec_IntSize(vUsed);
275 Vec_IntPush(vUsed, q[i]);
276 }
277 if ( pPat ) Abc_TtSetBit( pPat + nWordsBS*pMap[q[i]], i );
278 }
279 Vec_IntForEachEntry( vUsed, Digit, i )
280 pMap[Digit] = -1;
281 return Vec_IntSize(vUsed);
282}
Here is the caller graph for this function:

◆ Abc_TtGetCM5()

int Abc_TtGetCM5 ( word * p,
int nVars,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed )

Definition at line 153 of file utilBSet.c.

154{
155 unsigned * q = (unsigned *)p;
156 int i, Item, nDigits = 1 << (nVars - 5);
157 Vec_WrdClear( vStore );
158 Vec_IntClear( vUsed );
159 for ( i = 0; i < nDigits; i++ )
160 Abc_TtHashLookup5( q[i], vTable, vStore, vUsed );
161 Vec_IntForEachEntry( vUsed, Item, i )
162 Vec_IntWriteEntry( vTable, Item, -1 );
163 return Vec_IntSize(vUsed);
164}
int Abc_TtHashLookup5(int Entry, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
Definition utilBSet.c:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM5Pat()

int Abc_TtGetCM5Pat ( word * p,
int nVars,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed,
word * pPat )

Definition at line 283 of file utilBSet.c.

284{
285 unsigned * q = (unsigned *)p;
286 int i, Item, nDigits = 1 << (nVars - 5), nWordsBS = Abc_TtWordNum(nVars - 5);
287 Vec_WrdClear( vStore );
288 Vec_IntClear( vUsed );
289 if ( pPat )
290 for ( i = 0; i < nDigits; i++ )
291 Abc_TtSetBit( pPat + nWordsBS*Abc_TtHashLookup5(q[i], vTable, vStore, vUsed), i );
292 else
293 for ( i = 0; i < nDigits; i++ )
294 Abc_TtHashLookup5( q[i], vTable, vStore, vUsed );
295 Vec_IntForEachEntry( vUsed, Item, i )
296 Vec_IntWriteEntry( vTable, Item, -1 );
297 return Vec_IntSize(vUsed);
298}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM6()

int Abc_TtGetCM6 ( word * p,
int nVars,
int nFVars,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed )

Definition at line 179 of file utilBSet.c.

180{
181 assert( nFVars >= 6 && nFVars < nVars );
182 int i, Item, nDigits = 1 << (nVars - nFVars), nWords = 1 << (nFVars - 6);
183 Vec_WrdClear( vStore );
184 Vec_IntClear( vUsed );
185 //assert( Vec_IntSum(vTable) == -Vec_IntSize(vTable) );
186 for ( i = 0; i < nDigits; i++ )
187 Abc_TtHashLookup6( p + i*nWords, nWords, vTable, vStore, vUsed );
188 Vec_IntForEachEntry( vUsed, Item, i )
189 Vec_IntWriteEntry( vTable, Item, -1 );
190 return Vec_IntSize(vUsed);
191}
int Abc_TtHashLookup6(word *pEntry, int nWords, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
Definition utilBSet.c:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCM6Pat()

int Abc_TtGetCM6Pat ( word * p,
int nVars,
int nFVars,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed,
word * pPat )

Definition at line 299 of file utilBSet.c.

300{
301 assert( nFVars >= 6 && nFVars < nVars );
302 int i, Item, nDigits = 1 << (nVars - nFVars), nWords = 1 << (nFVars - 6), nWordsBS = Abc_TtWordNum(nVars - nFVars);
303 Vec_WrdClear( vStore );
304 Vec_IntClear( vUsed );
305 if ( pPat )
306 for ( i = 0; i < nDigits; i++ )
307 Abc_TtSetBit( pPat + nWordsBS*Abc_TtHashLookup6(p + i*nWords, nWords, vTable, vStore, vUsed), i );
308 else
309 for ( i = 0; i < nDigits; i++ )
310 Abc_TtHashLookup6( p + i*nWords, nWords, vTable, vStore, vUsed );
311 Vec_IntForEachEntry( vUsed, Item, i )
312 Vec_IntWriteEntry( vTable, Item, -1 );
313 return Vec_IntSize(vUsed);
314}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCMCount()

int Abc_TtGetCMCount ( word * p,
int nVars,
int nFVars,
Vec_Int_t * vCounts,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed )

Definition at line 192 of file utilBSet.c.

193{
194 if ( nFVars == 1 )
195 return Abc_TtGetCM1( p, nVars );
196 if ( nFVars == 2 )
197 return Abc_TtGetCM2( p, nVars );
198 if ( nFVars == 3 )
199 return Abc_TtGetCM3( p, nVars, Vec_IntArray(vCounts), vUsed );
200 if ( nFVars == 4 )
201 return Abc_TtGetCM4( p, nVars, Vec_IntArray(vCounts), vUsed );
202 if ( nFVars == 5 )
203 return Abc_TtGetCM5( p, nVars, vTable, vStore, vUsed );
204 if ( nFVars >= 6 )
205 return Abc_TtGetCM6( p, nVars, nFVars, vTable, vStore, vUsed );
206 assert( 0 );
207 return 0;
208}
int Abc_TtGetCM4(word *p, int nVars, int *pCounts, Vec_Int_t *vUsed)
Definition utilBSet.c:109
int Abc_TtGetCM2(word *p, int nVars)
Definition utilBSet.c:84
int Abc_TtGetCM1(word *p, int nVars)
FUNCTION DEFINITIONS ///.
Definition utilBSet.c:74
int Abc_TtGetCM5(word *p, int nVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
Definition utilBSet.c:153
int Abc_TtGetCM6(word *p, int nVars, int nFVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed)
Definition utilBSet.c:179
int Abc_TtGetCM3(word *p, int nVars, int *pCounts, Vec_Int_t *vUsed)
Definition utilBSet.c:94
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCMInt()

int Abc_TtGetCMInt ( word * p,
int nVars,
int nFVars,
Vec_Int_t * vCounts,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed,
word * pPat )

Definition at line 348 of file utilBSet.c.

349{
350 int nMintsBS = 1 << (nVars - nFVars);
351 int nWordsBS = Abc_TtWordNum(nVars - nFVars);
352 //assert( nMintsBS * nWordsBS <= MAX_PAT_WORD_SIZE );
353 memset( pPat, 0, 8 * nMintsBS * nWordsBS );
354 int nMyu = 0;
355 if ( nFVars == 1 )
356 nMyu = Abc_TtGetCM1Pat( p, nVars, pPat );
357 else if ( nFVars == 2 )
358 nMyu = Abc_TtGetCM2Pat( p, nVars, pPat );
359 else if ( nFVars == 3 )
360 nMyu = Abc_TtGetCM3Pat( p, nVars, Vec_IntArray(vCounts), vUsed, pPat );
361 else if ( nFVars == 4 )
362 nMyu = Abc_TtGetCM4Pat( p, nVars, Vec_IntArray(vCounts), vUsed, pPat );
363 else if ( nFVars == 5 )
364 nMyu = Abc_TtGetCM5Pat( p, nVars, vTable, vStore, vUsed, pPat );
365 else if ( nFVars >= 6 )
366 nMyu = Abc_TtGetCM6Pat( p, nVars, nFVars, vTable, vStore, vUsed, pPat );
367 else assert( 0 );
368 return nMyu;
369}
int Abc_TtGetCM2Pat(word *p, int nVars, word *pPat)
Definition utilBSet.c:236
int Abc_TtGetCM4Pat(word *p, int nVars, int *pMap, Vec_Int_t *vUsed, word *pPat)
Definition utilBSet.c:267
int Abc_TtGetCM6Pat(word *p, int nVars, int nFVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, word *pPat)
Definition utilBSet.c:299
int Abc_TtGetCM3Pat(word *p, int nVars, int *pMap, Vec_Int_t *vUsed, word *pPat)
Definition utilBSet.c:251
int Abc_TtGetCM1Pat(word *p, int nVars, word *pPat)
Definition utilBSet.c:221
int Abc_TtGetCM5Pat(word *p, int nVars, Vec_Int_t *vTable, Vec_Wrd_t *vStore, Vec_Int_t *vUsed, word *pPat)
Definition utilBSet.c:283
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetCMPat()

int Abc_TtGetCMPat ( word * p,
int nVars,
int nFVars,
Vec_Int_t * vCounts,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed )

Definition at line 371 of file utilBSet.c.

372{
373 int nRails, nMyu = Abc_TtGetCMInt( p, nVars, nFVars, vCounts, vTable, vStore, vUsed, NULL );
374 if ( nMyu <= 2 )
375 nRails = 1;
376 else
377 nRails = Abc_TtCheck1Shared( NULL, nVars, nFVars, nMyu );
378 return nRails;
379}
int Abc_TtCheck1Shared(word *pPat, int nVars, int nFVars, int nMyu)
Definition utilBSet.c:322
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtGetKey()

int Abc_TtGetKey ( unsigned char * p,
int nSize,
int nTableSize )

Definition at line 126 of file utilBSet.c.

127{
128 int i = 0; unsigned hash = 0;
129 while ( i != nSize )
130 {
131 hash += p[i++];
132 hash += hash << 10;
133 hash ^= hash >> 6;
134 }
135 hash += hash << 3;
136 hash ^= hash >> 11;
137 hash += hash << 15;
138 return (int)(hash % nTableSize);
139}
Here is the caller graph for this function:

◆ Abc_TtHashLookup5()

int Abc_TtHashLookup5 ( int Entry,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed )

Definition at line 140 of file utilBSet.c.

141{
142 int Key = Abc_TtGetKey( (unsigned char*)&Entry, 4, Vec_IntSize(vTable) );
143 int * pTable = Vec_IntArray(vTable);
144 for ( ; pTable[Key] >= 0; Key = (Key + 1) % Vec_IntSize(vTable) )
145 if ( Entry == (int)Vec_WrdEntry(vStore, pTable[Key]) )
146 return pTable[Key];
147 assert( pTable[Key] == -1 );
148 pTable[Key] = Vec_WrdSize(vStore);
149 Vec_WrdPush( vStore, (word)Entry );
150 Vec_IntPush( vUsed, Key );
151 return pTable[Key];
152}
int Abc_TtGetKey(unsigned char *p, int nSize, int nTableSize)
Definition utilBSet.c:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtHashLookup6()

int Abc_TtHashLookup6 ( word * pEntry,
int nWords,
Vec_Int_t * vTable,
Vec_Wrd_t * vStore,
Vec_Int_t * vUsed )

Definition at line 165 of file utilBSet.c.

166{
167 int i, Key = Abc_TtGetKey( (unsigned char*)pEntry, 8*nWords, Vec_IntSize(vTable) );
168 int * pTable = Vec_IntArray(vTable);
169 for ( ; pTable[Key] >= 0; Key = (Key + 1) % Vec_IntSize(vTable) )
170 if ( !memcmp(pEntry, Vec_WrdEntryP(vStore, nWords*pTable[Key]), 8*nWords) )
171 return pTable[Key];
172 assert( pTable[Key] == -1 );
173 pTable[Key] = Vec_WrdSize(vStore)/nWords;
174 for ( i = 0; i < nWords; i++ )
175 Vec_WrdPush( vStore, pEntry[i] );
176 Vec_IntPush( vUsed, Key );
177 return pTable[Key];
178}
int memcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtPermGenTest()

void Abc_TtPermGenTest ( )

Definition at line 429 of file utilBSet.c.

430{
431 int i, k, nVars = 5, currPerm[5] = {0};
432 for ( i = 0; i < nVars; i++ )
433 currPerm[i] = i;
434 int fact = Abc_TtFactorial( nVars );
435 for ( i = 0; i < fact; i++ )
436 {
437 printf( "%3d :", i );
438 for ( k = 0; k < nVars; k++ )
439 printf( " %d", currPerm[k] );
440 printf( "\n" );
441 Abc_TtPermGen( currPerm, nVars, NULL, 0 );
442 }
443}

◆ Abc_TtPrintPat()

void Abc_TtPrintPat ( word * pPat,
int nVars,
int nMyu )

Definition at line 316 of file utilBSet.c.

317{
318 printf( "ACD i-sets with %d variables and column multiplicity %d:\n", nVars, nMyu );
319 for ( int m = 0; m < nMyu; m++ )
320 Extra_PrintBinary( stdout, (unsigned *)&pPat[m], (1 << nVars) ), printf("\n");
321}
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
Here is the call graph for this function:
Here is the caller graph for this function: