ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sfmLib.c File Reference
#include "sfmInt.h"
#include "misc/st/st.h"
#include "map/mio/mio.h"
#include "misc/vec/vecMem.h"
#include "misc/util/utilTruth.h"
#include "misc/extra/extra.h"
#include "map/mio/exp.h"
#include "opt/dau/dau.h"
#include "base/main/main.h"
Include dependency graph for sfmLib.c:

Go to the source code of this file.

Classes

struct  Sfm_Fun_t_
 DECLARATIONS ///. More...
 
struct  Sfm_Lib_t_
 

Macros

#define Sfm_LibForEachSuper(p, pObj, Func)
 

Functions

void Sfm_DecCreateCnf (Vec_Int_t *vGateSizes, Vec_Wrd_t *vGateFuncs, Vec_Wec_t *vGateCnfs)
 FUNCTION DEFINITIONS ///.
 
void Sfm_LibPreprocess (Mio_Library_t *pLib, Vec_Int_t *vGateSizes, Vec_Wrd_t *vGateFuncs, Vec_Wec_t *vGateCnfs, Vec_Ptr_t *vGateHands)
 
int Sfm_LibFindComplInputGate (Vec_Wrd_t *vFuncs, int iGate, int nFanins, int iFanin, int *piFaninNew)
 
Sfm_Lib_tSfm_LibStart (int nVars, int fDelay, int fVerbose)
 
void Sfm_LibStop (Sfm_Lib_t *p)
 
word Sfm_LibTruth6Two (Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop)
 
void Sfm_LibTruth8Two (Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop, word *pRes)
 
void Sfm_LibCellProfile (Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop, int nFanins, int *Perm, int *pProf)
 
void Sfm_LibPrepareAdd (Sfm_Lib_t *p, word *pTruth, int *Perm, int nFanins, Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop)
 
Sfm_Lib_tSfm_LibPrepare (int nVars, int fTwo, int fDelay, int fVerbose, int fLibVerbose)
 
void Sfm_LibPrintGate (Mio_Cell2_t *pCell, char *pFanins, Mio_Cell2_t *pCell2, char *pFanins2)
 
void Sfm_LibPrintObj (Sfm_Lib_t *p, Sfm_Fun_t *pObj)
 
void Sfm_LibPrint (Sfm_Lib_t *p)
 
void Sfm_LibTest ()
 
int Sfm_LibFindAreaMatch (Sfm_Lib_t *p, word *pTruth, int nFanins, int *piObj)
 
int Sfm_LibFindDelayMatches (Sfm_Lib_t *p, word *pTruth, int *pFanins, int nFanins, Vec_Ptr_t *vGates, Vec_Ptr_t *vFans)
 
int Sfm_LibImplementSimple (Sfm_Lib_t *p, word *pTruth, int *pFanins, int nFanins, Vec_Int_t *vGates, Vec_Wec_t *vFanins)
 
int Sfm_LibImplementGatesArea (Sfm_Lib_t *p, int *pFanins, int nFanins, int iObj, Vec_Int_t *vGates, Vec_Wec_t *vFanins)
 
int Sfm_LibImplementGatesDelay (Sfm_Lib_t *p, int *pFanins, Mio_Gate_t *pGateB, Mio_Gate_t *pGateT, char *pFansB, char *pFansT, Vec_Int_t *vGates, Vec_Wec_t *vFanins)
 

Macro Definition Documentation

◆ Sfm_LibForEachSuper

#define Sfm_LibForEachSuper ( p,
pObj,
Func )
Value:
for ( pObj = Sfm_LibFun(p, Vec_IntEntry(&p->vLists, Func)); pObj; pObj = Sfm_LibFun(p, pObj->Next) )
Cube * p
Definition exorList.c:222

Definition at line 70 of file sfmLib.c.

70#define Sfm_LibForEachSuper( p, pObj, Func ) \
71 for ( pObj = Sfm_LibFun(p, Vec_IntEntry(&p->vLists, Func)); pObj; pObj = Sfm_LibFun(p, pObj->Next) )

Function Documentation

◆ Sfm_DecCreateCnf()

void Sfm_DecCreateCnf ( Vec_Int_t * vGateSizes,
Vec_Wrd_t * vGateFuncs,
Vec_Wec_t * vGateCnfs )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file sfmLib.c.

101{
102 Vec_Str_t * vCnf, * vCnfBase;
103 Vec_Int_t * vCover;
104 word uTruth;
105 int i, nCubes;
106 vCnf = Vec_StrAlloc( 100 );
107 vCover = Vec_IntAlloc( 100 );
108 Vec_WrdForEachEntry( vGateFuncs, uTruth, i )
109 {
110 nCubes = Sfm_TruthToCnf( uTruth, NULL, Vec_IntEntry(vGateSizes, i), vCover, vCnf );
111 vCnfBase = (Vec_Str_t *)Vec_WecEntry( vGateCnfs, i );
112 Vec_StrGrow( vCnfBase, Vec_StrSize(vCnf) );
113 memcpy( Vec_StrArray(vCnfBase), Vec_StrArray(vCnf), (size_t)Vec_StrSize(vCnf) );
114 vCnfBase->nSize = Vec_StrSize(vCnf);
115 }
116 Vec_IntFree( vCover );
117 Vec_StrFree( vCnf );
118}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int Sfm_TruthToCnf(word Truth, word *pTruth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Definition sfmCnf.c:71
int nSize
Definition bblif.c:50
char * memcpy()
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecWrd.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibCellProfile()

void Sfm_LibCellProfile ( Mio_Cell2_t * pCellBot,
Mio_Cell2_t * pCellTop,
int InTop,
int nFanins,
int * Perm,
int * pProf )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 304 of file sfmLib.c.

305{
306 int i, DelayAdd = pCellTop ? 1 : 0;
307 for ( i = 0; i < nFanins; i++ )
308 if ( Perm[i] < (int)pCellBot->nFanins )
309 pProf[i] = 1 + DelayAdd;
310 else if ( Perm[i] < (int)pCellBot->nFanins + InTop )
311 pProf[i] = 1;
312 else // if ( Perm[i] >= (int)pCellBot->nFanins + InTop )
313 pProf[i] = 1;
314}
unsigned nFanins
Definition mio.h:64
Here is the caller graph for this function:

◆ Sfm_LibFindAreaMatch()

int Sfm_LibFindAreaMatch ( Sfm_Lib_t * p,
word * pTruth,
int nFanins,
int * piObj )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 613 of file sfmLib.c.

614{
615 Sfm_Fun_t * pObj = NULL;
616 int iFunc = *Vec_MemHashLookup( p->vTtMem, pTruth );
617 if ( iFunc == -1 )
618 return -1;
619 Sfm_LibForEachSuper( p, pObj, iFunc )
620 break;
621 if ( piObj )
622 *piObj = pObj - p->pObjs;
623 return pObj->Area;
624}
struct Sfm_Fun_t_ Sfm_Fun_t
BASIC TYPES ///.
Definition sfmInt.h:66
#define Sfm_LibForEachSuper(p, pObj, Func)
Definition sfmLib.c:70
int Area
Definition sfmLib.c:41
Here is the caller graph for this function:

◆ Sfm_LibFindComplInputGate()

int Sfm_LibFindComplInputGate ( Vec_Wrd_t * vFuncs,
int iGate,
int nFanins,
int iFanin,
int * piFaninNew )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file sfmLib.c.

162{
163 word uTruthGate = Vec_WrdEntry( vFuncs, iGate );
164 word uTruthFlip = Abc_Tt6Flip( uTruthGate, iFanin );
165 word uTruth, uTruthSwap; int i;
166 assert( iFanin >= 0 && iFanin < nFanins );
167 if ( piFaninNew ) *piFaninNew = iFanin;
168 Vec_WrdForEachEntry( vFuncs, uTruth, i )
169 if ( uTruth == uTruthFlip )
170 return i;
171 if ( iFanin-1 >= 0 )
172 {
173 if ( piFaninNew ) *piFaninNew = iFanin-1;
174 uTruthSwap = Abc_Tt6SwapAdjacent( uTruthFlip, iFanin-1 );
175 Vec_WrdForEachEntry( vFuncs, uTruth, i )
176 if ( uTruth == uTruthSwap )
177 return i;
178 }
179 if ( iFanin+1 < nFanins )
180 {
181 if ( piFaninNew ) *piFaninNew = iFanin+1;
182 uTruthSwap = Abc_Tt6SwapAdjacent( uTruthFlip, iFanin );
183 Vec_WrdForEachEntry( vFuncs, uTruth, i )
184 if ( uTruth == uTruthSwap )
185 return i;
186 }
187 // add checking for complemeting control input of a MUX
188 if ( piFaninNew ) *piFaninNew = -1;
189 return -1;
190}
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Sfm_LibFindDelayMatches()

int Sfm_LibFindDelayMatches ( Sfm_Lib_t * p,
word * pTruth,
int * pFanins,
int nFanins,
Vec_Ptr_t * vGates,
Vec_Ptr_t * vFans )

Definition at line 625 of file sfmLib.c.

626{
627 Sfm_Fun_t * pObj;
628 Mio_Cell2_t * pCellB, * pCellT;
629 int iFunc;
630 if ( nFanins > 6 )
631 {
632 word pCopy[4];
633 Abc_TtCopy( pCopy, pTruth, 4, 0 );
634 Dau_DsdPrintFromTruth( pCopy, p->nVars );
635 }
636 Vec_PtrClear( vGates );
637 Vec_PtrClear( vFans );
638 // look for gate
639 assert( !Abc_TtIsConst0(pTruth, p->nWords) &&
640 !Abc_TtIsConst1(pTruth, p->nWords) &&
641 !Abc_TtEqual(pTruth, s_Truth8[0], p->nWords) &&
642 !Abc_TtOpposite(pTruth, s_Truth8[0], p->nWords) );
643 iFunc = *Vec_MemHashLookup( p->vTtMem, pTruth );
644 if ( iFunc == -1 )
645 {
646 // print functions not found in the library
647 if ( p->fVerbose || nFanins > 6 )
648 {
649 printf( "Not found in the precomputed library: " );
650 Dau_DsdPrintFromTruth( pTruth, nFanins );
651 }
652 return 0;
653 }
654 Vec_IntAddToEntry( &p->vHits, iFunc, 1 );
655 // collect matches
656 Sfm_LibForEachSuper( p, pObj, iFunc )
657 {
658 pCellB = p->pCells + (int)pObj->pFansB[0];
659 pCellT = p->pCells + (int)pObj->pFansT[0];
660 Vec_PtrPush( vGates, pCellB->pMioGate );
661 Vec_PtrPush( vGates, pCellT == p->pCells ? NULL : pCellT->pMioGate );
662 Vec_PtrPush( vFans, pObj->pFansB + 1 );
663 Vec_PtrPush( vFans, pCellT == p->pCells ? NULL : pObj->pFansT + 1 );
664 }
665 return Vec_PtrSize(vGates) / 2;
666}
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition dauDsd.c:1968
struct Mio_Cell2_t_ Mio_Cell2_t
Definition mio.h:57
void * pMioGate
Definition mio.h:70
char pFansB[SFM_SUPP_MAX+1]
Definition sfmLib.c:43
char pFansT[SFM_SUPP_MAX+1]
Definition sfmLib.c:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibImplementGatesArea()

int Sfm_LibImplementGatesArea ( Sfm_Lib_t * p,
int * pFanins,
int nFanins,
int iObj,
Vec_Int_t * vGates,
Vec_Wec_t * vFanins )

Definition at line 704 of file sfmLib.c.

705{
707 Sfm_Fun_t * pObjMin = p->pObjs + iObj;
708 Mio_Cell2_t * pCellB, * pCellT;
709 Mio_Gate_t * pGate;
710 Vec_Int_t * vLevel;
711 int i;
712 // get the gates
713 pCellB = p->pCells + (int)pObjMin->pFansB[0];
714 pCellT = p->pCells + (int)pObjMin->pFansT[0];
715 // create bottom gate
716 pGate = Mio_LibraryReadGateByName( pLib, pCellB->pName, NULL );
717 assert( pGate == pCellB->pMioGate );
718 Vec_IntPush( vGates, Mio_GateReadValue(pGate) );
719 vLevel = Vec_WecPushLevel( vFanins );
720 for ( i = 0; i < (int)pCellB->nFanins; i++ )
721 Vec_IntPush( vLevel, pFanins[(int)pObjMin->pFansB[i+1]] );
722 if ( pCellT == p->pCells )
723 return 1;
724 // create top gate
725 pGate = Mio_LibraryReadGateByName( pLib, pCellT->pName, NULL );
726 assert( pGate == pCellT->pMioGate );
727 Vec_IntPush( vGates, Mio_GateReadValue(pGate) );
728 vLevel = Vec_WecPushLevel( vFanins );
729 for ( i = 0; i < (int)pCellT->nFanins; i++ )
730 if ( pObjMin->pFansT[i+1] == (char)16 )
731 Vec_IntPush( vLevel, Vec_WecSize(vFanins)-2 );
732 else
733 Vec_IntPush( vLevel, pFanins[(int)pObjMin->pFansT[i+1]] );
734 return 2;
735}
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition mioApi.c:105
int Mio_GateReadValue(Mio_Gate_t *pGate)
Definition mioApi.c:183
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibImplementGatesDelay()

int Sfm_LibImplementGatesDelay ( Sfm_Lib_t * p,
int * pFanins,
Mio_Gate_t * pGateB,
Mio_Gate_t * pGateT,
char * pFansB,
char * pFansT,
Vec_Int_t * vGates,
Vec_Wec_t * vFanins )

Definition at line 736 of file sfmLib.c.

737{
738 Vec_Int_t * vLevel;
739 int i, nFanins;
740 // create bottom gate
741 Vec_IntPush( vGates, Mio_GateReadValue(pGateB) );
742 vLevel = Vec_WecPushLevel( vFanins );
743 nFanins = Mio_GateReadPinNum( pGateB );
744 for ( i = 0; i < nFanins; i++ )
745 Vec_IntPush( vLevel, pFanins[(int)pFansB[i]] );
746 if ( pGateT == NULL )
747 return 1;
748 // create top gate
749 Vec_IntPush( vGates, Mio_GateReadValue(pGateT) );
750 vLevel = Vec_WecPushLevel( vFanins );
751 nFanins = Mio_GateReadPinNum( pGateT );
752 for ( i = 0; i < nFanins; i++ )
753 if ( pFansT[i] == (char)16 )
754 Vec_IntPush( vLevel, Vec_WecSize(vFanins)-2 );
755 else
756 Vec_IntPush( vLevel, pFanins[(int)pFansT[i]] );
757 return 2;
758}
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition mioApi.c:177
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibImplementSimple()

int Sfm_LibImplementSimple ( Sfm_Lib_t * p,
word * pTruth,
int * pFanins,
int nFanins,
Vec_Int_t * vGates,
Vec_Wec_t * vFanins )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 679 of file sfmLib.c.

680{
682 Mio_Gate_t * pGate;
683 Vec_Int_t * vLevel;
684 if ( Abc_TtIsConst0(pTruth, p->nWords) || Abc_TtIsConst1(pTruth, p->nWords) )
685 {
686 assert( nFanins == 0 );
687 pGate = Abc_TtIsConst1(pTruth, p->nWords) ? Mio_LibraryReadConst1(pLib) : Mio_LibraryReadConst0(pLib);
688 Vec_IntPush( vGates, Mio_GateReadValue(pGate) );
689 vLevel = Vec_WecPushLevel( vFanins );
690 return 1;
691 }
692 if ( Abc_TtEqual(pTruth, s_Truth8[0], p->nWords) || Abc_TtOpposite(pTruth, s_Truth8[0], p->nWords) )
693 {
694 assert( nFanins == 1 );
695 pGate = Abc_TtEqual(pTruth, s_Truth8[0], p->nWords) ? Mio_LibraryReadBuf(pLib) : Mio_LibraryReadInv(pLib);
696 Vec_IntPush( vGates, Mio_GateReadValue(pGate) );
697 vLevel = Vec_WecPushLevel( vFanins );
698 Vec_IntPush( vLevel, pFanins[0] );
699 return 1;
700 }
701 assert( 0 );
702 return -1;
703}
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
Definition mioApi.c:51
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
Definition mioApi.c:52
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition mioApi.c:50
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition mioApi.c:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibPrepare()

Sfm_Lib_t * Sfm_LibPrepare ( int nVars,
int fTwo,
int fDelay,
int fVerbose,
int fLibVerbose )

Definition at line 438 of file sfmLib.c.

439{
440 abctime clk = Abc_Clock();
441 Sfm_Lib_t * p = Sfm_LibStart( nVars, fDelay, fLibVerbose );
442 Mio_Cell2_t * pCell1, * pCell2, * pLimit;
443 int * pPerm[SFM_SUPP_MAX+1], * Perm1, * Perm2, Perm[SFM_SUPP_MAX];
444 int nPerms[SFM_SUPP_MAX+1], i, f, n;
445 word tTemp1[4], tCur[4];
446 char pRes[1000];
447 assert( nVars <= SFM_SUPP_MAX );
448 // precompute gates
449 p->pCells = Mio_CollectRootsNewDefault2( Abc_MinInt(6, nVars), &p->nCells, 0 );
450 pLimit = p->pCells + p->nCells;
451 // find useful ones
452 for ( pCell1 = p->pCells + 4; pCell1 < pLimit; pCell1++ )
453 {
454 word uTruth = pCell1->uTruth;
455 pCell1->Type = 0;
456 if ( Abc_Tt6IsAndType(uTruth, pCell1->nFanins) || Abc_Tt6IsOrType(uTruth, pCell1->nFanins) )
457 pCell1->Type = 1;
458 else if ( Dau_DsdDecompose(&uTruth, pCell1->nFanins, 0, 0, pRes) <= 3 )
459 pCell1->Type = 2;
460 else if ( fLibVerbose )
461 printf( "Skipping gate \"%s\" with non-DSD function %s\n", pCell1->pName, pRes );
462 }
463 // generate permutations
464 for ( i = 2; i <= nVars; i++ )
465 pPerm[i] = Extra_PermSchedule( i );
466 for ( i = 2; i <= nVars; i++ )
467 nPerms[i] = Extra_Factorial( i );
468 // add single cells
469 for ( pCell1 = p->pCells + 4; pCell1 < pLimit; pCell1++ )
470 {
471 int nFanins = pCell1->nFanins;
472 assert( nFanins >= 2 && nFanins <= nVars );
473 for ( i = 0; i < nFanins; i++ )
474 Perm[i] = i;
475 // permute truth table
476 tCur[0] = tTemp1[0] = pCell1->uTruth;
477 if ( p->nVars > 6 )
478 tTemp1[1] = tTemp1[2] = tTemp1[3] = tCur[1] = tCur[2] = tCur[3] = tCur[0];
479 for ( n = 0; n < nPerms[nFanins]; n++ )
480 {
481 Sfm_LibPrepareAdd( p, tCur, Perm, nFanins, pCell1, NULL, -1 );
482 // update
483 Abc_TtSwapAdjacent( tCur, p->nWords, pPerm[nFanins][n] );
484 Perm1 = Perm + pPerm[nFanins][n];
485 Perm2 = Perm1 + 1;
486 ABC_SWAP( int, *Perm1, *Perm2 );
487 }
488 assert( Abc_TtEqual(tTemp1, tCur, p->nWords) );
489 }
490 // add double cells
491 if ( fTwo )
492 for ( pCell1 = p->pCells + 4; pCell1 < pLimit; pCell1++ ) // Bot
493 if ( pCell1->Type > 0 )
494 for ( pCell2 = p->pCells + 4; pCell2 < pLimit; pCell2++ ) // Top
495 if ( pCell2->Type > 0 )//&& pCell1->Type + pCell2->Type <= 2 )
496 if ( (int)pCell1->nFanins + (int)pCell2->nFanins <= nVars + 1 )
497 for ( f = 0; f < (int)pCell2->nFanins; f++ )
498 {
499 int nFanins = pCell1->nFanins + pCell2->nFanins - 1;
500 assert( nFanins >= 2 && nFanins <= nVars );
501 for ( i = 0; i < nFanins; i++ )
502 Perm[i] = i;
503 // permute truth table
504 if ( p->nVars > 6 )
505 {
506 Sfm_LibTruth8Two( pCell1, pCell2, f, tCur );
507 Abc_TtCopy( tTemp1, tCur, p->nWords, 0 );
508 }
509 else
510 tCur[0] = tTemp1[0] = Sfm_LibTruth6Two( pCell1, pCell2, f );
511 for ( n = 0; n < nPerms[nFanins]; n++ )
512 {
513 Sfm_LibPrepareAdd( p, tCur, Perm, nFanins, pCell1, pCell2, f );
514 if ( nFanins > 5 )
515 break;
516 // update
517 Abc_TtSwapAdjacent( tCur, p->nWords, pPerm[nFanins][n] );
518 Perm1 = Perm + pPerm[nFanins][n];
519 Perm2 = Perm1 + 1;
520 ABC_SWAP( int, *Perm1, *Perm2 );
521 }
522 assert( Abc_TtEqual(tTemp1, tCur, p->nWords) );
523 }
524 // cleanup
525 for ( i = 2; i <= nVars; i++ )
526 ABC_FREE( pPerm[i] );
527 if ( fVerbose )
528 {
529 printf( "Library processing: Var = %d. Cell = %d. Fun = %d. Obj = %d. Ave = %.2f. Skip = %d. Rem = %d. ",
530 nVars, p->nCells, Vec_MemEntryNum(p->vTtMem)-2,
531 p->nObjs-p->nObjRemoved, 1.0*(p->nObjs-p->nObjRemoved)/(Vec_MemEntryNum(p->vTtMem)-2),
532 p->nObjSkipped, p->nObjRemoved );
533 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
534 }
535 return p;
536}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FREE(obj)
Definition abc_global.h:267
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition dauDsd.c:1912
int * Extra_PermSchedule(int n)
int Extra_Factorial(int n)
Mio_Cell2_t * Mio_CollectRootsNewDefault2(int nInputs, int *pnGates, int fVerbose)
Definition mioUtils.c:877
#define SFM_SUPP_MAX
Definition sfmInt.h:56
struct Sfm_Lib_t_ Sfm_Lib_t
Definition sfmInt.h:67
void Sfm_LibPrepareAdd(Sfm_Lib_t *p, word *pTruth, int *Perm, int nFanins, Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop)
Definition sfmLib.c:335
word Sfm_LibTruth6Two(Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop)
Definition sfmLib.c:252
Sfm_Lib_t * Sfm_LibStart(int nVars, int fDelay, int fVerbose)
Definition sfmLib.c:204
void Sfm_LibTruth8Two(Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop, word *pRes)
Definition sfmLib.c:266
unsigned Type
Definition mio.h:63
word uTruth
Definition mio.h:67
char * pName
Definition mio.h:60
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibPrepareAdd()

void Sfm_LibPrepareAdd ( Sfm_Lib_t * p,
word * pTruth,
int * Perm,
int nFanins,
Mio_Cell2_t * pCellBot,
Mio_Cell2_t * pCellTop,
int InTop )

Definition at line 335 of file sfmLib.c.

336{
337 Sfm_Fun_t * pObj;
338 int InvPerm[SFM_SUPP_MAX], Profile[SFM_SUPP_MAX];
339 int Area = (int)pCellBot->AreaW + (pCellTop ? (int)pCellTop->AreaW : 0);
340 int i, k, Id, Prev, Offset, * pProf, iFunc = Vec_MemHashInsert( p->vTtMem, pTruth );
341 if ( iFunc == Vec_IntSize(&p->vLists) )
342 {
343 Vec_IntPush( &p->vLists, -1 );
344 Vec_IntPush( &p->vCounts, 0 );
345 Vec_IntPush( &p->vHits, 0 );
346 }
347 assert( pCellBot != NULL );
348 // iterate through the supergates of this truth table
349 if ( p->fDelay )
350 {
351 assert( Vec_IntSize(&p->vProfs) == p->nObjs );
352 Sfm_LibCellProfile( pCellBot, pCellTop, InTop, nFanins, Perm, Profile );
353 // check if new one is contained in old ones
354 Vec_IntClear( &p->vTemp );
355 Sfm_LibForEachSuper( p, pObj, iFunc )
356 {
357 Vec_IntPush( &p->vTemp, Sfm_LibFunId(p, pObj) );
358 Offset = Vec_IntEntry( &p->vProfs, Sfm_LibFunId(p, pObj) );
359 pProf = Vec_IntEntryP( &p->vStore, Offset );
360 if ( Sfm_LibNewIsContained(pObj, pProf, Area, Profile, nFanins) )
361 {
362 p->nObjSkipped++;
363 return;
364 }
365 }
366 // check if old ones are contained in new one
367 k = 0;
368 Vec_IntForEachEntry( &p->vTemp, Id, i )
369 {
370 Offset = Vec_IntEntry( &p->vProfs, Id );
371 pProf = Vec_IntEntryP( &p->vStore, Offset );
372 if ( !Sfm_LibNewContains(Sfm_LibFun(p, Id), pProf, Area, Profile, nFanins) )
373 Vec_IntWriteEntry( &p->vTemp, k++, Id );
374 else
375 p->nObjRemoved++;
376 }
377 if ( k < i ) // change
378 {
379 if ( k == 0 )
380 Vec_IntWriteEntry( &p->vLists, iFunc, -1 );
381 else
382 {
383 Vec_IntShrink( &p->vTemp, k );
384 Prev = Vec_IntEntry(&p->vTemp, 0);
385 Vec_IntWriteEntry( &p->vLists, iFunc, Prev );
386 Vec_IntForEachEntryStart( &p->vTemp, Id, i, 1 )
387 {
388 Sfm_LibFun(p, Prev)->Next = Id;
389 Prev = Id;
390 }
391 Sfm_LibFun(p, Prev)->Next = -1;
392 }
393 }
394 }
395 else
396 {
397 Sfm_LibForEachSuper( p, pObj, iFunc )
398 {
399 if ( Area >= pObj->Area )
400 return;
401 }
402 }
403 for ( k = 0; k < nFanins; k++ )
404 InvPerm[Perm[k]] = k;
405 // create delay profile
406 if ( p->fDelay )
407 {
408 Vec_IntPush( &p->vProfs, Vec_IntSize(&p->vStore) );
409 for ( k = 0; k < nFanins; k++ )
410 Vec_IntPush( &p->vStore, Profile[k] );
411 }
412 // create new object
413 if ( p->nObjs == p->nObjsAlloc )
414 {
415 int nObjsAlloc = 2 * p->nObjsAlloc;
416 p->pObjs = ABC_REALLOC( Sfm_Fun_t, p->pObjs, nObjsAlloc );
417 memset( p->pObjs + p->nObjsAlloc, 0, sizeof(Sfm_Fun_t) * p->nObjsAlloc );
418 p->nObjsAlloc = nObjsAlloc;
419 }
420 pObj = p->pObjs + p->nObjs;
421 pObj->Area = Area;
422 pObj->Next = Vec_IntEntry(&p->vLists, iFunc);
423 Vec_IntWriteEntry( &p->vLists, iFunc, p->nObjs++ );
424 Vec_IntAddToEntry( &p->vCounts, iFunc, 1 );
425 // create gate
426 assert( pCellBot->Id < 128 );
427 pObj->pFansB[0] = (char)pCellBot->Id;
428 for ( k = 0; k < (int)pCellBot->nFanins; k++ )
429 pObj->pFansB[k+1] = InvPerm[k];
430 if ( pCellTop == NULL )
431 return;
432 assert( pCellTop->Id < 128 );
433 pObj->pFansT[0] = (char)pCellTop->Id;
434 for ( i = 0; i < (int)pCellTop->nFanins; i++ )
435 pObj->pFansT[i+1] = (char)(i == InTop ? 16 : InvPerm[k++]);
436 assert( k == nFanins );
437}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
void Sfm_LibCellProfile(Mio_Cell2_t *pCellBot, Mio_Cell2_t *pCellTop, int InTop, int nFanins, int *Perm, int *pProf)
Definition sfmLib.c:304
word AreaW
Definition mio.h:66
unsigned Id
Definition mio.h:62
int Next
Definition sfmLib.c:40
char * memset()
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibPreprocess()

void Sfm_LibPreprocess ( Mio_Library_t * pLib,
Vec_Int_t * vGateSizes,
Vec_Wrd_t * vGateFuncs,
Vec_Wec_t * vGateCnfs,
Vec_Ptr_t * vGateHands )

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

Synopsis [Preprocess the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file sfmLib.c.

132{
133 Mio_Gate_t * pGate;
134 int nGates = Mio_LibraryReadGateNum(pLib);
135 Vec_IntGrow( vGateSizes, nGates );
136 Vec_WrdGrow( vGateFuncs, nGates );
137 Vec_WecInit( vGateCnfs, nGates );
138 Vec_PtrGrow( vGateHands, nGates );
139 Mio_LibraryForEachGate( pLib, pGate )
140 {
141 Vec_IntPush( vGateSizes, Mio_GateReadPinNum(pGate) );
142 Vec_WrdPush( vGateFuncs, Mio_GateReadTruth(pGate) );
143 Mio_GateSetValue( pGate, Vec_PtrSize(vGateHands) );
144 Vec_PtrPush( vGateHands, pGate );
145 }
146 Sfm_DecCreateCnf( vGateSizes, vGateFuncs, vGateCnfs );
147}
word Mio_GateReadTruth(Mio_Gate_t *pGate)
Definition mioApi.c:181
void Mio_GateSetValue(Mio_Gate_t *pGate, int Value)
Definition mioApi.c:187
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition mio.h:81
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition mioApi.c:45
void Sfm_DecCreateCnf(Vec_Int_t *vGateSizes, Vec_Wrd_t *vGateFuncs, Vec_Wec_t *vGateCnfs)
FUNCTION DEFINITIONS ///.
Definition sfmLib.c:100
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibPrint()

void Sfm_LibPrint ( Sfm_Lib_t * p)

Definition at line 567 of file sfmLib.c.

568{
569 Sfm_Fun_t * pObj; word * pTruth; int i, nFanins;
570 Vec_MemForEachEntry( p->vTtMem, pTruth, i )
571 {
572 if ( i < 2 || Vec_IntEntry(&p->vHits, i) == 0 )
573 continue;
574 nFanins = Abc_TtSupportSize(pTruth, p->nVars);
575 printf( "%8d : ", i );
576 printf( "Num =%5d ", Vec_IntEntry(&p->vCounts, i) );
577 printf( "Hit =%4d ", Vec_IntEntry(&p->vHits, i) );
578 Sfm_LibForEachSuper( p, pObj, i )
579 {
580 Sfm_LibPrintObj( p, pObj );
581 break;
582 }
583 printf( " " );
584 Dau_DsdPrintFromTruth( pTruth, nFanins );
585 }
586}
void Sfm_LibPrintObj(Sfm_Lib_t *p, Sfm_Fun_t *pObj)
Definition sfmLib.c:548
#define Vec_MemForEachEntry(p, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecMem.h:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibPrintGate()

void Sfm_LibPrintGate ( Mio_Cell2_t * pCell,
char * pFanins,
Mio_Cell2_t * pCell2,
char * pFanins2 )

Definition at line 537 of file sfmLib.c.

538{
539 int k;
540 printf( " %-20s(", pCell->pName );
541 for ( k = 0; k < (int)pCell->nFanins; k++ )
542 if ( pFanins[k] == (char)16 )
543 Sfm_LibPrintGate( pCell2, pFanins2, NULL, NULL );
544 else
545 printf( " %c", 'a' + pFanins[k] );
546 printf( " )" );
547}
void Sfm_LibPrintGate(Mio_Cell2_t *pCell, char *pFanins, Mio_Cell2_t *pCell2, char *pFanins2)
Definition sfmLib.c:537
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibPrintObj()

void Sfm_LibPrintObj ( Sfm_Lib_t * p,
Sfm_Fun_t * pObj )

Definition at line 548 of file sfmLib.c.

549{
550 Mio_Cell2_t * pCellB = p->pCells + (int)pObj->pFansB[0];
551 Mio_Cell2_t * pCellT = p->pCells + (int)pObj->pFansT[0];
552 int i, nFanins = pCellB->nFanins + (pCellT == p->pCells ? 0 : pCellT->nFanins - 1);
553 printf( "F = %d A =%6.2f ", nFanins, Scl_Int2Flt(pObj->Area) );
554 if ( pCellT == p->pCells )
555 Sfm_LibPrintGate( pCellB, pObj->pFansB + 1, NULL, NULL );
556 else
557 Sfm_LibPrintGate( pCellT, pObj->pFansT + 1, pCellB, pObj->pFansB + 1 );
558 // get hold of delay info
559 if ( p->fDelay )
560 {
561 int Offset = Vec_IntEntry( &p->vProfs, Sfm_LibFunId(p, pObj) );
562 int * pProf = Vec_IntEntryP( &p->vStore, Offset );
563 for ( i = 0; i < nFanins; i++ )
564 printf( "%6.2f ", Scl_Int2Flt(pProf[i]) );
565 }
566}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_LibStart()

Sfm_Lib_t * Sfm_LibStart ( int nVars,
int fDelay,
int fVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 204 of file sfmLib.c.

205{
207 assert( nVars <= SFM_SUPP_MAX );
208 p->vTtMem = Vec_MemAllocForTT( nVars, 0 );
209 Vec_IntGrow( &p->vLists, (1 << 16) );
210 Vec_IntGrow( &p->vCounts, (1 << 16) );
211 Vec_IntGrow( &p->vHits, (1 << 16) );
212 Vec_IntFill( &p->vLists, 2, -1 );
213 Vec_IntFill( &p->vCounts, 2, -1 );
214 Vec_IntFill( &p->vHits, 2, -1 );
215 p->nObjsAlloc = (1 << 16);
216 p->pObjs = ABC_CALLOC( Sfm_Fun_t, p->nObjsAlloc );
217 p->fDelay = fDelay;
218 if ( fDelay ) Vec_IntGrow( &p->vProfs, (1 << 16) );
219 if ( fDelay ) Vec_IntGrow( &p->vStore, (1 << 18) );
220 Vec_IntGrow( &p->vTemp, 16 );
221 p->nVars = nVars;
222 p->nWords = Abc_TtWordNum( nVars );
223 p->fVerbose = fVerbose;
224 return p;
225}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Here is the caller graph for this function:

◆ Sfm_LibStop()

void Sfm_LibStop ( Sfm_Lib_t * p)

Definition at line 226 of file sfmLib.c.

227{
228 Vec_MemHashFree( p->vTtMem );
229 Vec_MemFree( p->vTtMem );
230 Vec_IntErase( &p->vLists );
231 Vec_IntErase( &p->vCounts );
232 Vec_IntErase( &p->vHits );
233 Vec_IntErase( &p->vProfs );
234 Vec_IntErase( &p->vStore );
235 Vec_IntErase( &p->vTemp );
236 ABC_FREE( p->pCells );
237 ABC_FREE( p->pObjs );
238 ABC_FREE( p );
239}
Here is the caller graph for this function:

◆ Sfm_LibTest()

void Sfm_LibTest ( )

Definition at line 587 of file sfmLib.c.

588{
589 Sfm_Lib_t * p;
590 int fVerbose = 1;
591 if ( Abc_FrameReadLibGen() == NULL )
592 {
593 printf( "There is no current library.\n" );
594 return;
595 }
596 p = Sfm_LibPrepare( 7, 1, 1, 1, fVerbose );
597 if ( fVerbose )
598 Sfm_LibPrint( p );
599 Sfm_LibStop( p );
600}
void Sfm_LibPrint(Sfm_Lib_t *p)
Definition sfmLib.c:567
Sfm_Lib_t * Sfm_LibPrepare(int nVars, int fTwo, int fDelay, int fVerbose, int fLibVerbose)
Definition sfmLib.c:438
void Sfm_LibStop(Sfm_Lib_t *p)
Definition sfmLib.c:226
Here is the call graph for this function:

◆ Sfm_LibTruth6Two()

word Sfm_LibTruth6Two ( Mio_Cell2_t * pCellBot,
Mio_Cell2_t * pCellTop,
int InTop )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file sfmLib.c.

253{
254 word uFanins[SFM_SUPP_MAX]; int i, k;
255 word uTruthBot = Exp_Truth6( pCellBot->nFanins, pCellBot->vExpr, NULL );
256 assert( InTop >= 0 && InTop < (int)pCellTop->nFanins );
257 for ( i = 0, k = pCellBot->nFanins; i < (int)pCellTop->nFanins; i++ )
258 if ( i == InTop )
259 uFanins[i] = uTruthBot;
260 else
261 uFanins[i] = s_Truths6[k++];
262 assert( (int)pCellBot->nFanins + (int)pCellTop->nFanins == k + 1 );
263 uTruthBot = Exp_Truth6( pCellTop->nFanins, pCellTop->vExpr, uFanins );
264 return uTruthBot;
265}
Vec_Int_t * vExpr
Definition mio.h:61
Here is the caller graph for this function:

◆ Sfm_LibTruth8Two()

void Sfm_LibTruth8Two ( Mio_Cell2_t * pCellBot,
Mio_Cell2_t * pCellTop,
int InTop,
word * pRes )

Definition at line 266 of file sfmLib.c.

267{
268 word uTruthBot[4], * puFanins[SFM_SUPP_MAX]; int i, k;
269 Exp_Truth8( pCellBot->nFanins, pCellBot->vExpr, NULL, uTruthBot );
270 assert( InTop >= 0 && InTop < (int)pCellTop->nFanins );
271 for ( i = 0, k = pCellBot->nFanins; i < (int)pCellTop->nFanins; i++ )
272 if ( i == InTop )
273 puFanins[i] = uTruthBot;
274 else
275 puFanins[i] = s_Truth8[k++];
276 assert( (int)pCellBot->nFanins + (int)pCellTop->nFanins == k + 1 );
277 Exp_Truth8( pCellTop->nFanins, pCellTop->vExpr, puFanins, pRes );
278}
Here is the caller graph for this function: