ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifMap.c File Reference
#include "if.h"
#include "misc/extra/extra.h"
Include dependency graph for ifMap.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START char * Dau_DsdMerge (char *pDsd0i, int *pPerm0, char *pDsd1i, int *pPerm1, int fCompl0, int fCompl1, int nVars)
 DECLARATIONS ///.
 
int If_CutDelayRecCost3 (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj)
 
int Abc_ExactDelayCost (word *pTruth, int nVars, int *pArrTimeProfile, char *pPerm, int *Cost, int AigLevel)
 
int If_ManCutAigDelay_rec (If_Man_t *p, If_Obj_t *pObj, Vec_Ptr_t *vVisited)
 FUNCTION DEFINITIONS ///.
 
int If_ManCutAigDelay (If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
 
float If_CutDelaySpecial (If_Man_t *p, If_Cut_t *pCut, int fCarry)
 
int * If_CutArrTimeProfile (If_Man_t *p, If_Cut_t *pCut)
 
void If_ObjPerformMappingAnd (If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
 
void If_ObjPerformMappingChoice (If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
 
int If_ManPerformMappingRound (If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
 

Function Documentation

◆ Abc_ExactDelayCost()

int Abc_ExactDelayCost ( word * pTruth,
int nVars,
int * pArrTimeProfile,
char * pPerm,
int * Cost,
int AigLevel )
extern

Definition at line 2716 of file abcExact.c.

2717{
2718 int i, nMaxArrival, nDelta, l;
2719 Ses_Man_t * pSes = NULL;
2720 char * pSol = NULL, * pSol2 = NULL, * p;
2721 int pNormalArrTime[8];
2722 int Delay = ABC_INFINITY, nMaxDepth, fResLimit;
2723 abctime timeStart = Abc_Clock(), timeStartExact;
2724
2725 /* some checks */
2726 if ( nVars < 0 || nVars > 8 )
2727 {
2728 printf( "invalid truth table size %d\n", nVars );
2729 assert( 0 );
2730 }
2731
2732 /* statistics */
2733 s_pSesStore->nCutCount++;
2734 s_pSesStore->pCutCount[nVars]++;
2735
2736 if ( nVars == 0 )
2737 {
2738 s_pSesStore->nSynthesizedTrivial++;
2739 s_pSesStore->pSynthesizedTrivial[0]++;
2740
2741 *Cost = 0;
2742 s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
2743 return 0;
2744 }
2745
2746 if ( nVars == 1 )
2747 {
2748 s_pSesStore->nSynthesizedTrivial++;
2749 s_pSesStore->pSynthesizedTrivial[1]++;
2750
2751 *Cost = 0;
2752 pPerm[0] = (char)0;
2753 s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
2754 return pArrTimeProfile[0];
2755 }
2756
2757 for ( l = 0; l < nVars; ++l )
2758 pNormalArrTime[l] = pArrTimeProfile[l];
2759
2760 nDelta = Abc_NormalizeArrivalTimes( pNormalArrTime, nVars, &nMaxArrival );
2761
2762 *Cost = ABC_INFINITY;
2763
2764 if ( Ses_StoreGetEntry( s_pSesStore, pTruth, nVars, pNormalArrTime, &pSol ) )
2765 {
2766 s_pSesStore->nCacheHits++;
2767 s_pSesStore->pCacheHits[nVars]++;
2768 }
2769 else
2770 {
2771 if ( s_pSesStore->fVeryVerbose )
2772 {
2773 printf( ANSI_COLOR_CYAN );
2774 Abc_TtPrintHexRev( stdout, pTruth, nVars );
2775 printf( ANSI_COLOR_RESET );
2776 printf( " [%d", pNormalArrTime[0] );
2777 for ( l = 1; l < nVars; ++l )
2778 printf( " %d", pNormalArrTime[l] );
2779 printf( "]@%d:", AigLevel );
2780 fflush( stdout );
2781 }
2782
2783 nMaxDepth = pNormalArrTime[0];
2784 for ( i = 1; i < nVars; ++i )
2785 nMaxDepth = Abc_MaxInt( nMaxDepth, pNormalArrTime[i] );
2786 nMaxDepth += nVars + 1;
2787 if ( AigLevel != -1 )
2788 nMaxDepth = Abc_MinInt( AigLevel - nDelta, nMaxDepth + nVars + 1 );
2789
2790 timeStartExact = Abc_Clock();
2791
2792 pSes = Ses_ManAlloc( pTruth, nVars, 1 /* nSpecFunc */, nMaxDepth, pNormalArrTime, s_pSesStore->fMakeAIG, s_pSesStore->nBTLimit, s_pSesStore->fVerbose );
2793 pSes->fVeryVerbose = s_pSesStore->fVeryVerbose;
2794 pSes->pSat = s_pSesStore->pSat;
2795 pSes->nStartGates = nVars - 2;
2796
2797 while ( pSes->nMaxDepth ) /* there is improvement */
2798 {
2799 if ( s_pSesStore->fVeryVerbose )
2800 {
2801 printf( " %d", pSes->nMaxDepth );
2802 fflush( stdout );
2803 }
2804
2805 if ( ( pSol2 = Ses_ManFindMinimumSize( pSes ) ) != NULL )
2806 {
2807 if ( s_pSesStore->fVeryVerbose )
2808 {
2809 if ( pSes->nMaxDepth >= 10 ) printf( "\b" );
2810 printf( "\b" ANSI_COLOR_GREEN "%d" ANSI_COLOR_RESET, pSes->nMaxDepth );
2811 }
2812 if ( pSol )
2813 ABC_FREE( pSol );
2814 pSol = pSol2;
2815 pSes->nMaxDepth--;
2816 }
2817 else
2818 {
2819 if ( s_pSesStore->fVeryVerbose )
2820 {
2821 if ( pSes->nMaxDepth >= 10 ) printf( "\b" );
2822 printf( "\b%s%d" ANSI_COLOR_RESET, pSes->fHitResLimit ? ANSI_COLOR_RED : ANSI_COLOR_YELLOW, pSes->nMaxDepth );
2823 }
2824 break;
2825 }
2826 }
2827
2828 if ( s_pSesStore->fVeryVerbose )
2829 printf( " \n" );
2830
2831 /* log unsuccessful case for debugging */
2832 if ( s_pSesStore->pDebugEntries && pSes->fHitResLimit )
2833 Ses_StorePrintDebugEntry( s_pSesStore, pTruth, nVars, pNormalArrTime, pSes->nMaxDepth, pSol, nVars - 2 );
2834
2835 pSes->timeTotal = Abc_Clock() - timeStartExact;
2836
2837 /* statistics */
2838 s_pSesStore->nSatCalls += pSes->nSatCalls;
2839 s_pSesStore->nUnsatCalls += pSes->nUnsatCalls;
2840 s_pSesStore->nUndefCalls += pSes->nUndefCalls;
2841
2842 s_pSesStore->timeSat += pSes->timeSat;
2843 s_pSesStore->timeSatSat += pSes->timeSatSat;
2844 s_pSesStore->timeSatUnsat += pSes->timeSatUnsat;
2845 s_pSesStore->timeSatUndef += pSes->timeSatUndef;
2846 s_pSesStore->timeInstance += pSes->timeInstance;
2847 s_pSesStore->timeExact += pSes->timeTotal;
2848
2849 /* cleanup (we need to clean before adding since pTruth may have been modified by pSes) */
2850 fResLimit = pSes->fHitResLimit;
2851 Ses_ManCleanLight( pSes );
2852
2853 /* store solution */
2854 Ses_StoreAddEntry( s_pSesStore, pTruth, nVars, pNormalArrTime, pSol, fResLimit );
2855 }
2856
2857 if ( pSol )
2858 {
2859 *Cost = pSol[ABC_EXACT_SOL_NGATES];
2860 p = pSol + 3 + 4 * pSol[ABC_EXACT_SOL_NGATES] + 1;
2861 Delay = *p++;
2862 for ( l = 0; l < nVars; ++l )
2863 pPerm[l] = *p++;
2864 }
2865
2866 if ( pSol )
2867 {
2868 int Delay2 = 0;
2869 for ( l = 0; l < nVars; ++l )
2870 {
2871 //printf( "%d ", pPerm[l] );
2872 Delay2 = Abc_MaxInt( Delay2, pArrTimeProfile[l] + pPerm[l] );
2873 }
2874 //printf( " output arrival = %d recomputed = %d\n", Delay, Delay2 );
2875 //if ( Delay != Delay2 )
2876 //{
2877 // printf( "^--- BUG!\n" );
2878 // assert( 0 );
2879 //}
2880
2881 s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
2882 return Delay2;
2883 }
2884 else
2885 {
2886 assert( *Cost == ABC_INFINITY );
2887
2888 s_pSesStore->timeTotal += ( Abc_Clock() - timeStart );
2889 return ABC_INFINITY;
2890 }
2891}
#define ABC_EXACT_SOL_NGATES
Definition abcExact.c:205
#define ANSI_COLOR_RED
Definition abcExact.c:207
#define ANSI_COLOR_YELLOW
Definition abcExact.c:209
#define ANSI_COLOR_CYAN
Definition abcExact.c:212
#define ANSI_COLOR_RESET
Definition abcExact.c:213
#define ANSI_COLOR_GREEN
Definition abcExact.c:208
int Ses_StoreGetEntry(Ses_Store_t *pStore, word *pTruth, int nVars, int *pArrTimeProfile, char **pSol)
Definition abcExact.c:768
int Ses_StoreAddEntry(Ses_Store_t *pStore, word *pTruth, int nVars, int *pArrTimeProfile, char *pSol, int fResLimit)
Definition abcExact.c:629
struct Ses_Man_t_ Ses_Man_t
Definition abcExact.c:215
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_FREE(obj)
Definition abc_global.h:267
Cube * p
Definition exorList.c:222
int nMaxDepth
Definition abcExact.c:226
int nSatCalls
Definition abcExact.c:275
abctime timeSatUnsat
Definition abcExact.c:270
int fHitResLimit
Definition abcExact.c:266
abctime timeSatSat
Definition abcExact.c:269
abctime timeSat
Definition abcExact.c:268
int nUndefCalls
Definition abcExact.c:277
abctime timeSatUndef
Definition abcExact.c:271
sat_solver * pSat
Definition abcExact.c:218
int nStartGates
Definition abcExact.c:246
int fVeryVerbose
Definition abcExact.c:235
abctime timeInstance
Definition abcExact.c:272
abctime timeTotal
Definition abcExact.c:273
int nUnsatCalls
Definition abcExact.c:276
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdMerge()

ABC_NAMESPACE_IMPL_START char * Dau_DsdMerge ( char * pDsd0i,
int * pPerm0,
char * pDsd1i,
int * pPerm1,
int fCompl0,
int fCompl1,
int nVars )
extern

DECLARATIONS ///.

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

FileName [ifMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [Mapping procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id
ifMap.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

]

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

Synopsis [Performs merging of two DSD formulas.]

Description []

SideEffects []

SeeAlso []

Definition at line 587 of file dauMerge.c.

588{
589 int fVerbose = 0;
590 int fCheck = 0;
591 static int Counter = 0;
592 static char pRes[2*DAU_MAX_STR+10];
593 char pDsd0[DAU_MAX_STR];
594 char pDsd1[DAU_MAX_STR];
595 int pMatches0[DAU_MAX_STR];
596 int pMatches1[DAU_MAX_STR];
597 int pVarPres[DAU_MAX_VAR];
598 int pOld2New[DAU_MAX_VAR];
599 int pNew2Old[DAU_MAX_VAR];
600 int pStatus0[DAU_MAX_STR];
601 int pStatus1[DAU_MAX_STR];
602 int pMatches[DAU_MAX_STR];
603 int nVarsShared, nVarsTotal;
604 Dau_Sto_t S, * pS = &S;
605 word * pTruth, * pt = NULL, * pt0 = NULL, * pt1 = NULL;
606 word pParts[3][DAU_MAX_WORD];
607 int Status;
608 abctime clk = Abc_Clock();
609 Counter++;
610 // create local copies
611 Dau_DsdMergeCopy( pDsd0i, fCompl0, pDsd0 );
612 Dau_DsdMergeCopy( pDsd1i, fCompl1, pDsd1 );
613if ( fVerbose )
614printf( "\nAfter copying:\n" );
615if ( fVerbose )
616printf( "%s\n", pDsd0 );
617if ( fVerbose )
618printf( "%s\n", pDsd1 );
619 // handle constants
620 if ( Dau_DsdIsConst(pDsd0) || Dau_DsdIsConst(pDsd1) )
621 {
622 if ( Dau_DsdIsConst0(pDsd0) )
623 strcpy( pRes, pDsd0 );
624 else if ( Dau_DsdIsConst1(pDsd0) )
625 strcpy( pRes, pDsd1 );
626 else if ( Dau_DsdIsConst0(pDsd1) )
627 strcpy( pRes, pDsd1 );
628 else if ( Dau_DsdIsConst1(pDsd1) )
629 strcpy( pRes, pDsd0 );
630 else assert( 0 );
631 return pRes;
632 }
633
634 // compute matches
635 Dau_DsdMergeMatches( pDsd0, pMatches0 );
636 Dau_DsdMergeMatches( pDsd1, pMatches1 );
637 // implement permutation
638 Dau_DsdMergeReplace( pDsd0, pMatches0, pPerm0 );
639 Dau_DsdMergeReplace( pDsd1, pMatches1, pPerm1 );
640if ( fVerbose )
641printf( "After replacement:\n" );
642if ( fVerbose )
643printf( "%s\n", pDsd0 );
644if ( fVerbose )
645printf( "%s\n", pDsd1 );
646
647
648 if ( fCheck )
649 {
650 pt0 = Dau_DsdToTruth( pDsd0, nVars );
651 Abc_TtCopy( pParts[0], pt0, Abc_TtWordNum(nVars), 0 );
652 }
653 if ( fCheck )
654 {
655 pt1 = Dau_DsdToTruth( pDsd1, nVars );
656 Abc_TtCopy( pParts[1], pt1, Abc_TtWordNum(nVars), 0 );
657 Abc_TtAnd( pParts[2], pParts[0], pParts[1], Abc_TtWordNum(nVars), 0 );
658 }
659
660 // find shared varaiables
661 nVarsShared = Dau_DsdMergeFindShared(pDsd0, pDsd1, pMatches0, pMatches1, pVarPres);
662 if ( nVarsShared == 0 )
663 {
664 sprintf( pRes, "(%s%s)", pDsd0, pDsd1 );
665if ( fVerbose )
666printf( "Disjoint:\n" );
667if ( fVerbose )
668printf( "%s\n", pRes );
669
670 Dau_DsdMergeMatches( pRes, pMatches );
671 Dau_DsdRemoveBraces( pRes, pMatches );
672 Dau_DsdNormalize( pRes );
673if ( fVerbose )
674printf( "Normalized:\n" );
675if ( fVerbose )
676printf( "%s\n", pRes );
677
678 s_TimeComp[0] += Abc_Clock() - clk;
679 return pRes;
680 }
681s_TimeComp[3] += Abc_Clock() - clk;
682 // create variable mapping
683 nVarsTotal = Dau_DsdMergeCreateMaps( pVarPres, nVarsShared, pOld2New, pNew2Old );
684 // perform variable replacement
685 Dau_DsdMergeReplace( pDsd0, pMatches0, pOld2New );
686 Dau_DsdMergeReplace( pDsd1, pMatches1, pOld2New );
687 // find uniqueness status
688 Dau_DsdMergeStatus( pDsd0, pMatches0, nVarsShared, pStatus0 );
689 Dau_DsdMergeStatus( pDsd1, pMatches1, nVarsShared, pStatus1 );
690if ( fVerbose )
691printf( "Individual status:\n" );
692if ( fVerbose )
693Dau_DsdMergePrintWithStatus( pDsd0, pStatus0 );
694if ( fVerbose )
695Dau_DsdMergePrintWithStatus( pDsd1, pStatus1 );
696 // prepare storage
697 Dau_DsdMergeStoreClean( pS, nVarsShared );
698 // perform substitutions
699 Dau_DsdMergeStoreCleanOutput( pS );
700 Dau_DsdMergeSubstitute( pS, pDsd0, pMatches0, pStatus0 );
701 strcpy( pDsd0, pS->pOutput );
702if ( fVerbose )
703printf( "Substitutions:\n" );
704if ( fVerbose )
705printf( "%s\n", pDsd0 );
706
707 // perform substitutions
708 Dau_DsdMergeStoreCleanOutput( pS );
709 Dau_DsdMergeSubstitute( pS, pDsd1, pMatches1, pStatus1 );
710 strcpy( pDsd1, pS->pOutput );
711if ( fVerbose )
712printf( "%s\n", pDsd1 );
713if ( fVerbose )
714Dau_DsdMergeStorePrintDefs( pS );
715
716 // create new function
717// assert( nVarsTotal <= 6 );
718 sprintf( pS->pOutput, "(%s%s)", pDsd0, pDsd1 );
719 pTruth = Dau_DsdToTruth( pS->pOutput, nVarsTotal );
720 Status = Dau_DsdDecompose( pTruth, nVarsTotal, 0, 1, pS->pOutput );
721//printf( "%d ", Status );
722 if ( Status == -1 ) // did not find 1-step DSD
723 return NULL;
724// if ( Status > 6 ) // non-DSD part is too large
725// return NULL;
726 if ( Dau_DsdIsConst(pS->pOutput) )
727 {
728 strcpy( pRes, pS->pOutput );
729 return pRes;
730 }
731if ( fVerbose )
732printf( "Decomposition:\n" );
733if ( fVerbose )
734printf( "%s\n", pS->pOutput );
735 // substitute definitions
736 Dau_DsdMergeMatches( pS->pOutput, pMatches );
737 Dau_DsdMergeInlineDefinitions( pS->pOutput, pMatches, pS, pRes, nVarsShared );
738if ( fVerbose )
739printf( "Inlining:\n" );
740if ( fVerbose )
741printf( "%s\n", pRes );
742 // perform variable replacement
743 Dau_DsdMergeMatches( pRes, pMatches );
744 Dau_DsdMergeReplace( pRes, pMatches, pNew2Old );
745 Dau_DsdRemoveBraces( pRes, pMatches );
746if ( fVerbose )
747printf( "Replaced:\n" );
748if ( fVerbose )
749printf( "%s\n", pRes );
750 Dau_DsdNormalize( pRes );
751if ( fVerbose )
752printf( "Normalized:\n" );
753if ( fVerbose )
754printf( "%s\n", pRes );
755
756 if ( fCheck )
757 {
758 pt = Dau_DsdToTruth( pRes, nVars );
759 if ( !Abc_TtEqual( pParts[2], pt, Abc_TtWordNum(nVars) ) )
760 printf( "Dau_DsdMerge(): Verification failed!\n" );
761 }
762
763 if ( Status == 0 )
764 s_TimeComp[1] += Abc_Clock() - clk;
765 else
766 s_TimeComp[2] += Abc_Clock() - clk;
767 return pRes;
768}
abctime s_TimeComp[4]
Definition dauMerge.c:574
typedefABC_NAMESPACE_IMPL_START struct Dau_Sto_t_ Dau_Sto_t
DECLARATIONS ///.
Definition dauMerge.c:47
void Dau_DsdRemoveBraces(char *pDsd, int *pMatches)
Definition dauMerge.c:554
word * Dau_DsdToTruth(char *p, int nVars)
Definition dauDsd.c:609
#define DAU_MAX_WORD
Definition dau.h:44
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition dauDsd.c:1912
void Dau_DsdNormalize(char *p)
Definition dauDsd.c:260
#define DAU_MAX_STR
Definition dau.h:43
#define DAU_MAX_VAR
INCLUDES ///.
Definition dau.h:42
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
char * sprintf()
char * strcpy()
Here is the call graph for this function:

◆ If_CutArrTimeProfile()

int * If_CutArrTimeProfile ( If_Man_t * p,
If_Cut_t * pCut )

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

Synopsis [Returns arrival time profile of the cut.]

Description [The procedure returns static storage, which should not be deallocated and is only valid until before the procedure is called again.]

SideEffects []

SeeAlso []

Definition at line 143 of file ifMap.c.

144{
145 int i;
146 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
147 p->pArrTimeProfile[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
148 return p->pArrTimeProfile;
149}
Here is the caller graph for this function:

◆ If_CutDelayRecCost3()

int If_CutDelayRecCost3 ( If_Man_t * p,
If_Cut_t * pCut,
If_Obj_t * pObj )
extern

Definition at line 1004 of file abcRec3.c.

1005{
1006 Lms_Man_t * p = s_pMan3;
1007 char pCanonPerm[LMS_VAR_MAX];
1008 unsigned uCanonPhase = 0;
1009 // make sure the cut functions match the library
1010 assert( p->nVars == (int)pCut->nLimit );
1011 // if this assertion fires, it means that LMS manager was used for library construction
1012 // in this case, GIA has to be written out and the manager restarted as described above
1013 assert( !p->fLibConstr );
1014 if ( p->vTruthPo == NULL )
1015 Lms_ManPrepare( p );
1016 // return the delay of the best structure
1017 return If_CutFindBestStruct( pIfMan, pCut, pCanonPerm, &uCanonPhase, NULL );
1018}
struct Lms_Man_t_ Lms_Man_t
DECLARATIONS ///.
Definition abcRec3.c:48
#define LMS_VAR_MAX
Definition abcRec3.c:31
void Lms_ManPrepare(Lms_Man_t *p)
Definition abcRec3.c:384
unsigned nLimit
Definition if.h:315
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_CutDelaySpecial()

float If_CutDelaySpecial ( If_Man_t * p,
If_Cut_t * pCut,
int fCarry )

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

Synopsis [Counts the number of 1s in the signature.]

Description []

SideEffects []

SeeAlso []

Definition at line 116 of file ifMap.c.

117{
118 static float Pin2Pin[2][3] = { {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0} };
119 If_Obj_t * pLeaf;
120 float DelayCur, Delay = -IF_FLOAT_LARGE;
121 int i;
122 assert( pCut->nLeaves <= 3 );
123 If_CutForEachLeaf( p, pCut, pLeaf, i )
124 {
125 DelayCur = If_ObjCutBest(pLeaf)->Delay;
126 Delay = IF_MAX( Delay, Pin2Pin[fCarry][i] + DelayCur );
127 }
128 return Delay;
129}
#define IF_FLOAT_LARGE
Definition if.h:469
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition if.h:503
#define IF_MAX(a, b)
Definition if.h:466
struct If_Obj_t_ If_Obj_t
Definition if.h:79
unsigned nLeaves
Definition if.h:316

◆ If_ManCutAigDelay()

int If_ManCutAigDelay ( If_Man_t * p,
If_Obj_t * pObj,
If_Cut_t * pCut )

Definition at line 66 of file ifMap.c.

67{
68 If_Obj_t * pLeaf;
69 int i, Delay;
70 Vec_PtrClear( p->vVisited );
71 If_CutForEachLeaf( p, pCut, pLeaf, i )
72 {
73 assert( pLeaf->fVisit == 0 );
74 pLeaf->fVisit = 1;
75 Vec_PtrPush( p->vVisited, pLeaf );
76 pLeaf->iCopy = If_ObjCutBest(pLeaf)->Delay;
77 }
78 Delay = If_ManCutAigDelay_rec( p, pObj, p->vVisited );
79 Vec_PtrForEachEntry( If_Obj_t *, p->vVisited, pLeaf, i )
80 pLeaf->fVisit = 0;
81// assert( Delay <= (int)pObj->Level );
82 return Delay;
83}
int If_ManCutAigDelay_rec(If_Man_t *p, If_Obj_t *pObj, Vec_Ptr_t *vVisited)
FUNCTION DEFINITIONS ///.
Definition ifMap.c:50
int iCopy
Definition if.h:357
unsigned fVisit
Definition if.h:339
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManCutAigDelay_rec()

int If_ManCutAigDelay_rec ( If_Man_t * p,
If_Obj_t * pObj,
Vec_Ptr_t * vVisited )

FUNCTION DEFINITIONS ///.

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

Synopsis [Compute delay of the cut's output in terms of logic levels.]

Description [Uses the best arrival time of the fanins of the cut to compute the arrival times of the output of the cut.]

SideEffects []

SeeAlso []

Definition at line 50 of file ifMap.c.

51{
52 int Delay0, Delay1;
53 if ( pObj->fVisit )
54 return pObj->iCopy;
55 if ( If_ObjIsCi(pObj) || If_ObjIsConst1(pObj) )
56 return -1;
57 // store the node in the structure by level
58 assert( If_ObjIsAnd(pObj) );
59 pObj->fVisit = 1;
60 Vec_PtrPush( vVisited, pObj );
61 Delay0 = If_ManCutAigDelay_rec( p, pObj->pFanin0, vVisited );
62 Delay1 = If_ManCutAigDelay_rec( p, pObj->pFanin1, vVisited );
63 pObj->iCopy = (Delay0 >= 0 && Delay1 >= 0) ? 1 + Abc_MaxInt(Delay0, Delay1) : -1;
64 return pObj->iCopy;
65}
If_Obj_t * pFanin1
Definition if.h:350
If_Obj_t * pFanin0
Definition if.h:349
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManPerformMappingRound()

int If_ManPerformMappingRound ( If_Man_t * p,
int nCutsUsed,
int Mode,
int fPreprocess,
int fFirst,
char * pLabel )

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

Synopsis [Performs one mapping pass over all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 606 of file ifMap.c.

607{
608 ProgressBar * pProgress = NULL;
609 If_Obj_t * pObj;
610 int i;
611 abctime clk = Abc_Clock();
612 float arrTime;
613 assert( Mode >= 0 && Mode <= 2 );
614 p->nBestCutSmall[0] = p->nBestCutSmall[1] = 0;
615 // set the sorting function
616 if ( Mode || p->pPars->fArea ) // area
617 p->SortMode = 1;
618 else if ( p->pPars->fFancy )
619 p->SortMode = 2;
620 else
621 p->SortMode = 0;
622 // set the cut number
623 p->nCutsUsed = nCutsUsed;
624 p->nCutsMerged = 0;
625 // make sure the visit counters are all zero
626 If_ManForEachNode( p, pObj, i )
627 assert( pObj->nVisits == pObj->nVisitsCopy );
628 // map the internal nodes
629 if ( p->pManTim != NULL )
630 {
631 Tim_ManIncrementTravId( p->pManTim );
632 If_ManForEachObj( p, pObj, i )
633 {
634 if ( If_ObjIsAnd(pObj) )
635 {
636 If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
637 if ( pObj->fRepr )
638 If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
639 }
640 else if ( If_ObjIsCi(pObj) )
641 {
642//Abc_Print( 1, "processing CI %d\n", pObj->Id );
643 arrTime = Tim_ManGetCiArrival( p->pManTim, pObj->IdPio );
644 If_ObjSetArrTime( pObj, arrTime );
645 }
646 else if ( If_ObjIsCo(pObj) )
647 {
648 arrTime = If_ObjArrTime( If_ObjFanin0(pObj) );
649 Tim_ManSetCoArrival( p->pManTim, pObj->IdPio, arrTime );
650 }
651 else if ( If_ObjIsConst1(pObj) )
652 {
653 arrTime = -IF_INFINITY;
654 If_ObjSetArrTime( pObj, arrTime );
655 }
656 else
657 assert( 0 );
658 }
659// Tim_ManPrint( p->pManTim );
660 }
661 else
662 {
663 pProgress = Extra_ProgressBarStart( stdout, If_ManObjNum(p) );
664 If_ManForEachNode( p, pObj, i )
665 {
666 Extra_ProgressBarUpdate( pProgress, i, pLabel );
667 If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
668 if ( pObj->fRepr )
669 If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
670 }
671 }
672 Extra_ProgressBarStop( pProgress );
673 // make sure the visit counters are all zero
674 If_ManForEachNode( p, pObj, i )
675 assert( pObj->nVisits == 0 );
676 // compute required times and stats
678// Tim_ManPrint( p->pManTim );
679 if ( p->pPars->fVerbose )
680 {
681 char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
682 Abc_Print( 1, "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. ",
683 Symb, p->RequiredGlo, p->AreaGlo, p->nNets );
684 if ( p->dPower )
685 Abc_Print( 1, "Switch = %7.2f. ", p->dPower );
686 Abc_Print( 1, "Cut = %8d. ", p->nCutsMerged );
687 Abc_PrintTime( 1, "T", Abc_Clock() - clk );
688// Abc_Print( 1, "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
689// p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
690 }
691 return 1;
692}
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
void If_ObjPerformMappingAnd(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
Definition ifMap.c:162
void If_ObjPerformMappingChoice(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
Definition ifMap.c:521
#define If_ManForEachObj(p, pObj, i)
Definition if.h:491
void If_ManComputeRequired(If_Man_t *p)
Definition ifTime.c:313
#define If_ManForEachNode(p, pObj, i)
Definition if.h:497
#define IF_INFINITY
Definition if.h:57
int IdPio
Definition if.h:345
int nVisits
Definition if.h:347
unsigned fRepr
Definition if.h:337
int nVisitsCopy
Definition if.h:348
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition timTime.c:116
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition timTrav.c:44
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition timTime.c:174
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ObjPerformMappingAnd()

void If_ObjPerformMappingAnd ( If_Man_t * p,
If_Obj_t * pObj,
int Mode,
int fPreprocess,
int fFirst )

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

Synopsis [Finds the best cut for the given node.]

Description [Mapping modes: delay (0), area flow (1), area (2).]

SideEffects []

SeeAlso []

Definition at line 162 of file ifMap.c.

163{
164 If_Set_t * pCutSet;
165 If_Cut_t * pCut0, * pCut1, * pCut;
166 If_Cut_t * pCut0R, * pCut1R;
167 int fFunc0R, fFunc1R;
168 int i, k, v, iCutDsd, fChange;
169 int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUserSesLib || p->pPars->fUserLutDec || p->pPars->fUserLut2D ||
170 p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->fUse34Spec || p->pPars->pLutStruct || p->pPars->pFuncCell2 || p->pPars->fUseCheck1 || p->pPars->fUseCheck2;
171 int fUseAndCut = (p->pPars->nAndDelay > 0) || (p->pPars->nAndArea > 0);
172 assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
173 assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
174
175 // prepare
176 if ( Mode == 0 )
177 pObj->EstRefs = (float)pObj->nRefs;
178 else if ( Mode == 1 )
179 pObj->EstRefs = (float)((2.0 * pObj->EstRefs + pObj->nRefs) / 3.0);
180 // deref the selected cut
181 if ( Mode && pObj->nRefs > 0 )
182 If_CutAreaDeref( p, If_ObjCutBest(pObj) );
183
184 // prepare the cutset
185 pCutSet = If_ManSetupNodeCutSet( p, pObj );
186
187 // get the current assigned best cut
188 pCut = If_ObjCutBest(pObj);
189 if ( !fFirst )
190 {
191 // recompute the parameters of the best cut
192 if ( p->pPars->fDelayOpt )
193 pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
194 else if ( p->pPars->fDsdBalance )
195 pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
196 else if ( p->pPars->fUserRecLib )
197 pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
198 else if ( p->pPars->fUserSesLib )
199 {
200 int Cost = 0;
201 pCut->fUser = 1;
202 pCut->Delay = (float)Abc_ExactDelayCost( If_CutTruthW(p, pCut), If_CutLeaveNum(pCut), If_CutArrTimeProfile(p, pCut), If_CutPerm(pCut), &Cost, If_ManCutAigDelay(p, pObj, pCut) );
203 if ( Cost == ABC_INFINITY )
204 {
205 for ( v = 0; v < If_CutLeaveNum(pCut); v++ )
206 If_CutPerm(pCut)[v] = IF_BIG_CHAR;
207 pCut->Cost = IF_COST_MAX;
208 pCut->fUseless = 1;
209 }
210 }
211 else if ( p->pPars->fUserLutDec || p->pPars->fUserLut2D )
212 {
213 pCut->Delay = If_LutDecReEval( p, pCut );
214 }
215 else if ( p->pPars->fDelayOptLut )
216 pCut->Delay = If_CutLutBalanceEval( p, pCut );
217 else if( p->pPars->nGateSize > 0 )
218 pCut->Delay = If_CutDelaySop( p, pCut );
219 else
220 pCut->Delay = If_CutDelay( p, pObj, pCut );
221 assert( pCut->Delay != -1 );
222// assert( pCut->Delay <= pObj->Required + p->fEpsilon );
223 if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
224 Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Node with ID %d has delay (%f) exceeding the required times (%f).\n",
225 pObj->Id, pCut->Delay, pObj->Required + p->fEpsilon );
226 pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
227 if ( p->pPars->fEdge )
228 pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
229 if ( p->pPars->fPower )
230 pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
231 // save the best cut from the previous iteration
232 if ( !fPreprocess || pCut->nLeaves <= 1 )
233 If_CutCopy( p, pCutSet->ppCuts[pCutSet->nCuts++], pCut );
234 }
235
236 // generate cuts
237 If_ObjForEachCut( pObj->pFanin0, pCut0, i )
238 If_ObjForEachCut( pObj->pFanin1, pCut1, k )
239 {
240 // get the next free cut
241 assert( pCutSet->nCuts <= pCutSet->nCutsMax );
242 pCut = pCutSet->ppCuts[pCutSet->nCuts];
243 // make sure K-feasible cut exists
244 if ( If_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->pPars->nLutSize )
245 continue;
246
247 pCut0R = pCut0;
248 pCut1R = pCut1;
249 fFunc0R = pCut0->iCutFunc ^ pCut0->fCompl ^ pObj->fCompl0;
250 fFunc1R = pCut1->iCutFunc ^ pCut1->fCompl ^ pObj->fCompl1;
251 if ( !p->pPars->fUseTtPerm || pCut0->nLeaves > pCut1->nLeaves || (pCut0->nLeaves == pCut1->nLeaves && fFunc0R > fFunc1R) )
252 {
253 }
254 else
255 {
256 ABC_SWAP( If_Cut_t *, pCut0R, pCut1R );
257 ABC_SWAP( int, fFunc0R, fFunc1R );
258 }
259
260 // merge the cuts
261 if ( p->pPars->fUseTtPerm )
262 {
263 if ( !If_CutMerge( p, pCut0R, pCut1R, pCut ) )
264 continue;
265 }
266 else
267 {
268 if ( !If_CutMergeOrdered( p, pCut0, pCut1, pCut ) )
269 continue;
270 }
271 if ( p->pPars->fUserLutDec && !fFirst && pCut->nLeaves > p->pPars->nLutDecSize )
272 continue;
273 if ( pObj->fSpec && pCut->nLeaves == (unsigned)p->pPars->nLutSize )
274 continue;
275 p->nCutsMerged++;
276 p->nCutsTotal++;
277 // check if this cut is contained in any of the available cuts
278 if ( !p->pPars->fSkipCutFilter && If_CutFilter( pCutSet, pCut, fSave0 ) )
279 continue;
280 // check if the cut is a special AND-gate cut
281 pCut->fAndCut = fUseAndCut && pCut->nLeaves == 2 && pCut->pLeaves[0] == pObj->pFanin0->Id && pCut->pLeaves[1] == pObj->pFanin1->Id;
282 //assert( pCut->nLeaves != 2 || pCut->pLeaves[0] < pCut->pLeaves[1] );
283 //assert( pCut->nLeaves != 2 || pObj->pFanin0->Id < pObj->pFanin1->Id );
284 // compute the truth table
285 pCut->iCutFunc = -1;
286 pCut->fCompl = 0;
287 if ( p->pPars->fTruth )
288 {
289// int nShared = pCut0->nLeaves + pCut1->nLeaves - pCut->nLeaves;
290 abctime clk = 0;
291 if ( p->pPars->fVerbose )
292 clk = Abc_Clock();
293 if ( p->pPars->fUseTtPerm )
294 fChange = If_CutComputeTruthPerm( p, pCut, pCut0R, pCut1R, fFunc0R, fFunc1R );
295 else
296 fChange = If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
297 if ( p->pPars->fVerbose )
298 p->timeCache[4] += Abc_Clock() - clk;
299 if ( !p->pPars->fSkipCutFilter && fChange && If_CutFilter( pCutSet, pCut, fSave0 ) )
300 continue;
301 if ( p->pPars->fLut6Filter && pCut->nLeaves == 6 && !If_CutCheckTruth6(p, pCut) )
302 continue;
303 if ( p->pPars->fUseDsd )
304 {
305 extern void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd );
306 int truthId = Abc_Lit2Var(pCut->iCutFunc);
307 if ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) || Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId) == -1 )
308 {
309 while ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) )
310 {
311 Vec_IntPush( p->vTtDsds[pCut->nLeaves], -1 );
312 for ( v = 0; v < Abc_MaxInt(6, pCut->nLeaves); v++ )
313 Vec_StrPush( p->vTtPerms[pCut->nLeaves], IF_BIG_CHAR );
314 }
315 iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthWR(p, pCut), pCut->nLeaves, (unsigned char *)If_CutDsdPerm(p, pCut), p->pPars->pLutStruct );
316 Vec_IntWriteEntry( p->vTtDsds[pCut->nLeaves], truthId, iCutDsd );
317 }
318 assert( If_DsdManSuppSize(p->pIfDsdMan, If_CutDsdLit(p, pCut)) == (int)pCut->nLeaves );
319 //If_ManCacheRecord( p, If_CutDsdLit(p, pCut0), If_CutDsdLit(p, pCut1), nShared, If_CutDsdLit(p, pCut) );
320 }
321 // run user functions
322 pCut->fUseless = 0;
323 if ( p->pPars->pFuncCell || p->pPars->pFuncCell2 )
324 {
325 assert( p->pPars->fUseTtPerm == 0 );
326 assert( pCut->nLimit >= 4 && pCut->nLimit <= 16 );
327 if ( p->pPars->fUseDsd )
328 pCut->fUseless = If_DsdManCheckDec( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
329 else if ( p->pPars->pFuncCell2 )
330 pCut->fUseless = !p->pPars->pFuncCell2( p, (word *)If_CutTruthW(p, pCut), pCut->nLeaves, NULL, NULL );
331 else
332 pCut->fUseless = !p->pPars->pFuncCell( p, If_CutTruth(p, pCut), Abc_MaxInt(6, pCut->nLeaves), pCut->nLeaves, p->pPars->pLutStruct );
333 p->nCutsUselessAll += pCut->fUseless;
334 p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
335 p->nCutsCountAll++;
336 p->nCutsCount[pCut->nLeaves]++;
337 // skip 5-input cuts, which cannot be decomposed
338 if ( (p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u) && pCut->nLeaves == 5 && pCut->nLimit == 5 )
339 {
340 extern int If_CluCheckDecInAny( word t, int nVars );
341 extern int If_CluCheckDecOut( word t, int nVars );
342 unsigned TruthU = *If_CutTruth(p, pCut);
343 word Truth = (((word)TruthU << 32) | (word)TruthU);
344 p->nCuts5++;
345 if ( If_CluCheckDecInAny( Truth, 5 ) )
346 p->nCuts5a++;
347 else
348 continue;
349 }
350 else if ( p->pPars->fVerbose && pCut->nLeaves == 5 )
351 {
352 extern int If_CluCheckDecInAny( word t, int nVars );
353 extern int If_CluCheckDecOut( word t, int nVars );
354 unsigned TruthU = *If_CutTruth(p, pCut);
355 word Truth = (((word)TruthU << 32) | (word)TruthU);
356 p->nCuts5++;
357 if ( If_CluCheckDecInAny( Truth, 5 ) || If_CluCheckDecOut( Truth, 5 ) )
358 p->nCuts5a++;
359 }
360 }
361 else if ( p->pPars->fUseDsdTune )
362 {
363 pCut->fUseless = If_DsdManReadMark( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
364 p->nCutsUselessAll += pCut->fUseless;
365 p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
366 p->nCutsCountAll++;
367 p->nCutsCount[pCut->nLeaves]++;
368 }
369 else if ( p->pPars->fUse34Spec )
370 {
371 assert( pCut->nLeaves <= 4 );
372 if ( pCut->nLeaves == 4 && !Abc_Tt4Check( (int)(0xFFFF & *If_CutTruth(p, pCut)) ) )
373 pCut->fUseless = 1;
374 }
375 else
376 {
377 if ( p->pPars->fUseAndVars )
378 {
379 int iDecMask = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
380 assert( p->pPars->nLutSize <= 13 );
381 if ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) || Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId) == -1 )
382 {
383 while ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) )
384 Vec_IntPush( p->vTtDecs[pCut->nLeaves], -1 );
385 if ( (int)pCut->nLeaves > p->pPars->nLutSize / 2 && (int)pCut->nLeaves <= 2 * (p->pPars->nLutSize / 2) )
386 iDecMask = Abc_TtProcessBiDec( If_CutTruthWR(p, pCut), (int)pCut->nLeaves, p->pPars->nLutSize / 2 );
387 else
388 iDecMask = 0;
389 Vec_IntWriteEntry( p->vTtDecs[pCut->nLeaves], truthId, iDecMask );
390 }
391 iDecMask = Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId);
392 assert( iDecMask >= 0 );
393 pCut->fUseless = (int)(iDecMask == 0 && (int)pCut->nLeaves > p->pPars->nLutSize / 2);
394 p->nCutsUselessAll += pCut->fUseless;
395 p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
396 p->nCutsCountAll++;
397 p->nCutsCount[pCut->nLeaves]++;
398 }
399 if ( p->pPars->fUseCofVars && (!p->pPars->fUseAndVars || pCut->fUseless) )
400 {
401 int iCofVar = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
402 if ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) || Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId) == (char)-1 )
403 {
404 while ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) )
405 Vec_StrPush( p->vTtVars[pCut->nLeaves], (char)-1 );
406 iCofVar = Abc_TtCheckCondDep( If_CutTruthWR(p, pCut), pCut->nLeaves, p->pPars->nLutSize / 2 );
407 Vec_StrWriteEntry( p->vTtVars[pCut->nLeaves], truthId, (char)iCofVar );
408 }
409 iCofVar = Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId);
410 assert( iCofVar >= 0 && iCofVar <= (int)pCut->nLeaves );
411 pCut->fUseless = (int)(iCofVar == (int)pCut->nLeaves && pCut->nLeaves > 0);
412 p->nCutsUselessAll += pCut->fUseless;
413 p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
414 p->nCutsCountAll++;
415 p->nCutsCount[pCut->nLeaves]++;
416 }
417 }
418 }
419
420 // compute the application-specific cost and depth
421 pCut->fUser = (p->pPars->pFuncCost != NULL);
422 pCut->Cost = p->pPars->pFuncCost? p->pPars->pFuncCost(p, pCut) : 0;
423 if ( pCut->Cost == IF_COST_MAX )
424 continue;
425 // check if the cut satisfies the required times
426 if ( p->pPars->fDelayOpt )
427 pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
428 else if ( p->pPars->fDsdBalance )
429 pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
430 else if ( p->pPars->fUserRecLib )
431 pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
432 else if ( p->pPars->fUserLutDec )
433 {
434 pCut->Delay = If_LutDecEval( p, pCut, pObj, Mode == 0, fFirst );
435 pCut->fUseless = pCut->Delay == ABC_INFINITY;
436 }
437 else if ( p->pPars->fUserLut2D )
438 {
439 pCut->Delay = If_Lut2DecEval( p, pCut, pObj, Mode == 0, fFirst );
440 pCut->fUseless = pCut->Delay == ABC_INFINITY;
441 }
442 else if ( p->pPars->fUserSesLib )
443 {
444 int Cost = 0;
445 pCut->fUser = 1;
446 pCut->Delay = (float)Abc_ExactDelayCost( If_CutTruthW(p, pCut), If_CutLeaveNum(pCut), If_CutArrTimeProfile(p, pCut), If_CutPerm(pCut), &Cost, If_ManCutAigDelay(p, pObj, pCut) );
447 if ( Cost == ABC_INFINITY )
448 {
449 for ( v = 0; v < If_CutLeaveNum(pCut); v++ )
450 If_CutPerm(pCut)[v] = IF_BIG_CHAR;
451 pCut->Cost = IF_COST_MAX;
452 pCut->fUseless = 1;
453 }
454 }
455 else if ( p->pPars->fDelayOptLut )
456 pCut->Delay = If_CutLutBalanceEval( p, pCut );
457 else if( p->pPars->nGateSize > 0 )
458 pCut->Delay = If_CutDelaySop( p, pCut );
459 else
460 pCut->Delay = If_CutDelay( p, pObj, pCut );
461 if ( pCut->Delay == -1 )
462 continue;
463 if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon && pCutSet->nCuts > 0 )
464 continue;
465 // compute area of the cut (this area may depend on the application specific cost)
466 pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
467 if ( p->pPars->fEdge )
468 pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
469 if ( p->pPars->fPower )
470 pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
471// pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
472 // insert the cut into storage
473 If_CutSort( p, pCutSet, pCut );
474// If_CutTraverse( p, pObj, pCut );
475 }
476 assert( pCutSet->nCuts > 0 );
477// If_CutVerifyCuts( pCutSet, !p->pPars->fUseTtPerm );
478
479 // update the best cut
480 if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
481 {
482 If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
483 if ( p->pPars->fUserRecLib || p->pPars->fUserSesLib )
484 assert(If_ObjCutBest(pObj)->Cost < IF_COST_MAX && If_ObjCutBest(pObj)->Delay < ABC_INFINITY);
485 }
486 // add the trivial cut to the set
487 if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
488 {
489 If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
490 assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
491 }
492// if ( If_ObjCutBest(pObj)->nLeaves == 0 )
493// p->nBestCutSmall[0]++;
494// else if ( If_ObjCutBest(pObj)->nLeaves == 1 )
495// p->nBestCutSmall[1]++;
496
497 // ref the selected cut
498 if ( Mode && pObj->nRefs > 0 )
499 If_CutAreaRef( p, If_ObjCutBest(pObj) );
500 if ( If_ObjCutBest(pObj)->fUseless )
501 Abc_Print( 1, "The best cut is useless.\n" );
502 // call the user specified function for each cut
503 if ( p->pPars->pFuncUser )
504 If_ObjForEachCut( pObj, pCut, i )
505 p->pPars->pFuncUser( p, pObj, pCut );
506 // free the cuts
507 If_ManDerefNodeCutSet( p, pObj );
508}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
ABC_NAMESPACE_IMPL_START void If_ManCacheRecord(If_Man_t *p, int iDsd0, int iDsd1, int nShared, int iDsd)
DECLARATIONS ///.
Definition ifCache.c:45
int If_CluCheckDecInAny(word t, int nVars)
Definition ifDec16.c:1767
int If_CluCheckDecOut(word t, int nVars)
Definition ifDec16.c:1840
int Abc_ExactDelayCost(word *pTruth, int nVars, int *pArrTimeProfile, char *pPerm, int *Cost, int AigLevel)
Definition abcExact.c:2716
int * If_CutArrTimeProfile(If_Man_t *p, If_Cut_t *pCut)
Definition ifMap.c:143
int If_ManCutAigDelay(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition ifMap.c:66
int If_CutDelayRecCost3(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj)
Definition abcRec3.c:1004
int If_CutMerge(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition ifCut.c:364
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition ifCut.c:1056
int If_CutComputeTruthPerm(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition ifTruth.c:269
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition ifMan.c:517
float If_CutPowerFlow(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition ifCut.c:1003
float If_CutEdgeDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition ifCut.c:1211
float If_CutDelay(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition ifTime.c:91
float If_CutEdgeFlow(If_Man_t *p, If_Cut_t *pCut)
Definition ifCut.c:965
int If_CutFilter(If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
Definition ifCut.c:146
struct If_Cut_t_ If_Cut_t
Definition if.h:80
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition ifCut.c:1083
If_Set_t * If_ManSetupNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:597
int If_DsdManSuppSize(If_DsdMan_t *p, int iDsd)
Definition ifDsd.c:197
float If_CutAreaFlow(If_Man_t *p, If_Cut_t *pCut)
Definition ifCut.c:927
#define IF_COST_MAX
Definition if.h:59
int If_CutLutBalanceEval(If_Man_t *p, If_Cut_t *pCut)
Definition ifDelay.c:369
int If_DsdManCompute(If_DsdMan_t *p, word *pTruth, int nLeaves, unsigned char *pPerm, char *pLutStruct)
Definition ifDsd.c:2063
int If_CutDsdBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition ifDsd.c:2322
int If_CutDelaySop(If_Man_t *p, If_Cut_t *pCut)
Definition ifDelay.c:64
#define IF_BIG_CHAR
Definition if.h:61
int If_LutDecReEval(If_Man_t *p, If_Cut_t *pCut)
Definition ifDelay.c:597
struct If_Set_t_ If_Set_t
Definition if.h:81
int If_DsdManReadMark(If_DsdMan_t *p, int iDsd)
Definition ifDsd.c:205
int If_Lut2DecEval(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj, int optDelay, int fFirst)
Definition ifDelay.c:508
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition ifCut.c:746
int If_CutCheckTruth6(If_Man_t *p, If_Cut_t *pCut)
Definition ifTruth.c:396
#define If_ObjForEachCut(pObj, pCut, i)
Definition if.h:500
struct If_Man_t_ If_Man_t
BASIC TYPES ///.
Definition if.h:77
void If_ManDerefNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:620
float If_CutAreaDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition ifCut.c:1110
int If_CutSopBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition ifDelay.c:248
int If_CutMergeOrdered(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition ifCut.c:290
float If_CutPowerDerefed(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition ifCut.c:1314
int If_CutComputeTruth(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition ifTruth.c:99
int If_LutDecEval(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj, int optDelay, int fFirst)
Definition ifDelay.c:415
int If_DsdManCheckDec(If_DsdMan_t *p, int iDsd)
Definition ifDsd.c:201
float Power
Definition if.h:305
unsigned Cost
Definition if.h:310
int pLeaves[0]
Definition if.h:318
float Delay
Definition if.h:306
unsigned fAndCut
Definition if.h:314
unsigned fUseless
Definition if.h:313
unsigned fCompl
Definition if.h:311
unsigned uSign
Definition if.h:309
float Area
Definition if.h:303
int iCutFunc
Definition if.h:307
unsigned fUser
Definition if.h:312
float Edge
Definition if.h:304
int nRefs
Definition if.h:346
float EstRefs
Definition if.h:352
unsigned fCompl1
Definition if.h:335
unsigned fSkipCut
Definition if.h:342
unsigned fSpec
Definition if.h:340
If_Set_t * pCutSet
Definition if.h:360
unsigned fCompl0
Definition if.h:334
float Required
Definition if.h:353
int Id
Definition if.h:344
If_Cut_t ** ppCuts
Definition if.h:327
short nCutsMax
Definition if.h:324
short nCuts
Definition if.h:325
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ObjPerformMappingChoice()

void If_ObjPerformMappingChoice ( If_Man_t * p,
If_Obj_t * pObj,
int Mode,
int fPreprocess )

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

Synopsis [Finds the best cut for the choice node.]

Description []

SideEffects []

SeeAlso []

Definition at line 521 of file ifMap.c.

522{
523 If_Set_t * pCutSet;
524 If_Obj_t * pTemp;
525 If_Cut_t * pCutTemp, * pCut;
526 int i, fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUserSesLib || p->pPars->fUse34Spec || p->pPars->fUserLutDec || p->pPars->fUserLut2D;
527 assert( pObj->pEquiv != NULL );
528
529 // prepare
530 if ( Mode && pObj->nRefs > 0 )
531 If_CutAreaDeref( p, If_ObjCutBest(pObj) );
532
533 // remove elementary cuts
534 for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
535 if ( pTemp != pObj || pTemp->pCutSet->nCuts > 1 )
536 pTemp->pCutSet->nCuts--;
537
538 // update the cutset of the node
539 pCutSet = pObj->pCutSet;
540
541 // generate cuts
542 for ( pTemp = pObj->pEquiv; pTemp; pTemp = pTemp->pEquiv )
543 {
544 if ( pTemp->pCutSet->nCuts == 0 )
545 continue;
546 // go through the cuts of this node
547 If_ObjForEachCut( pTemp, pCutTemp, i )
548 {
549 if ( pCutTemp->fUseless )
550 continue;
551 // get the next free cut
552 assert( pCutSet->nCuts <= pCutSet->nCutsMax );
553 pCut = pCutSet->ppCuts[pCutSet->nCuts];
554 // copy the cut into storage
555 If_CutCopy( p, pCut, pCutTemp );
556 // check if this cut is contained in any of the available cuts
557 if ( If_CutFilter( pCutSet, pCut, fSave0 ) )
558 continue;
559 // check if the cut satisfies the required times
560// assert( pCut->Delay == If_CutDelay( p, pTemp, pCut ) );
561 if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon && pCutSet->nCuts > 0 )
562 continue;
563 // set the phase attribute
564 pCut->fCompl = pObj->fPhase ^ pTemp->fPhase;
565 // compute area of the cut (this area may depend on the application specific cost)
566 pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
567 if ( p->pPars->fEdge )
568 pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
569 if ( p->pPars->fPower )
570 pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
571// pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
572 // insert the cut into storage
573 If_CutSort( p, pCutSet, pCut );
574 }
575 }
576 assert( pCutSet->nCuts > 0 );
577
578 // update the best cut
579 if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
580 If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
581 // add the trivial cut to the set
582 if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
583 {
584 If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
585 assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
586 }
587
588 // ref the selected cut
589 if ( Mode && pObj->nRefs > 0 )
590 If_CutAreaRef( p, If_ObjCutBest(pObj) );
591 // free the cuts
592 If_ManDerefChoiceCutSet( p, pObj );
593}
void If_ManDerefChoiceCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:663
unsigned fPhase
Definition if.h:336
If_Obj_t * pEquiv
Definition if.h:351
Here is the call graph for this function:
Here is the caller graph for this function: