abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ifMap.c File Reference
#include "if.h"

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 ///. More...
 
int If_CutDelayRecCost3 (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj)
 
static int If_WordCountOnes (unsigned uWord)
 FUNCTION DEFINITIONS ///. More...
 
float If_CutDelaySpecial (If_Man_t *p, If_Cut_t *pCut, int fCarry)
 
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_NAMESPACE_IMPL_START char* Dau_DsdMerge ( char *  pDsd0i,
int *  pPerm0,
char *  pDsd1i,
int *  pPerm1,
int  fCompl0,
int  fCompl1,
int  nVars 
)

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[DAU_MAX_STR];
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 );
613 if ( fVerbose )
614 printf( "\nAfter copying:\n" );
615 if ( fVerbose )
616 printf( "%s\n", pDsd0 );
617 if ( fVerbose )
618 printf( "%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 );
640 if ( fVerbose )
641 printf( "After replacement:\n" );
642 if ( fVerbose )
643 printf( "%s\n", pDsd0 );
644 if ( fVerbose )
645 printf( "%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 );
665 if ( fVerbose )
666 printf( "Disjoint:\n" );
667 if ( fVerbose )
668 printf( "%s\n", pRes );
669 
670  Dau_DsdMergeMatches( pRes, pMatches );
671  Dau_DsdRemoveBraces( pRes, pMatches );
672  Dau_DsdNormalize( pRes );
673 if ( fVerbose )
674 printf( "Normalized:\n" );
675 if ( fVerbose )
676 printf( "%s\n", pRes );
677 
678  s_TimeComp[0] += Abc_Clock() - clk;
679  return pRes;
680  }
681 s_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 );
690 if ( fVerbose )
691 printf( "Individual status:\n" );
692 if ( fVerbose )
693 Dau_DsdMergePrintWithStatus( pDsd0, pStatus0 );
694 if ( fVerbose )
695 Dau_DsdMergePrintWithStatus( pDsd1, pStatus1 );
696  // prepare storage
697  Dau_DsdMergeStoreClean( pS, nVarsShared );
698  // perform substitutions
700  Dau_DsdMergeSubstitute( pS, pDsd0, pMatches0, pStatus0 );
701  strcpy( pDsd0, pS->pOutput );
702 if ( fVerbose )
703 printf( "Substitutions:\n" );
704 if ( fVerbose )
705 printf( "%s\n", pDsd0 );
706 
707  // perform substitutions
709  Dau_DsdMergeSubstitute( pS, pDsd1, pMatches1, pStatus1 );
710  strcpy( pDsd1, pS->pOutput );
711 if ( fVerbose )
712 printf( "%s\n", pDsd1 );
713 if ( fVerbose )
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  }
731 if ( fVerbose )
732 printf( "Decomposition:\n" );
733 if ( fVerbose )
734 printf( "%s\n", pS->pOutput );
735  // substitute definitions
736  Dau_DsdMergeMatches( pS->pOutput, pMatches );
737  Dau_DsdMergeInlineDefinitions( pS->pOutput, pMatches, pS, pRes, nVarsShared );
738 if ( fVerbose )
739 printf( "Inlining:\n" );
740 if ( fVerbose )
741 printf( "%s\n", pRes );
742  // perform variable replacement
743  Dau_DsdMergeMatches( pRes, pMatches );
744  Dau_DsdMergeReplace( pRes, pMatches, pNew2Old );
745  Dau_DsdRemoveBraces( pRes, pMatches );
746 if ( fVerbose )
747 printf( "Replaced:\n" );
748 if ( fVerbose )
749 printf( "%s\n", pRes );
750  Dau_DsdNormalize( pRes );
751 if ( fVerbose )
752 printf( "Normalized:\n" );
753 if ( fVerbose )
754 printf( "%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 }
static int Dau_DsdMergeFindShared(char *pDsd0, char *pDsd1, int *pMatches0, int *pMatches1, int *pVarPres)
Definition: dauMerge.c:204
static void Dau_DsdMergeStoreClean(Dau_Sto_t *pS, int nShared)
Definition: dauMerge.c:57
void Dau_DsdRemoveBraces(char *pDsd, int *pMatches)
Definition: dauMerge.c:554
static void Dau_DsdMergeSubstitute(Dau_Sto_t *pS, char *pDsd, int *pMatches, int *pStatus)
Definition: dauMerge.c:494
static void Dau_DsdMergePrintWithStatus(char *p, int *pStatus)
Definition: dauMerge.c:276
typedefABC_NAMESPACE_IMPL_START struct Dau_Sto_t_ Dau_Sto_t
DECLARATIONS ///.
Definition: dauMerge.c:47
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition: dauDsd.c:1912
word * Dau_DsdToTruth(char *p, int nVars)
Definition: dauDsd.c:609
static void Dau_DsdMergeStorePrintDefs(Dau_Sto_t *pS)
Definition: dauMerge.c:107
static int Dau_DsdIsConst(char *p)
MACRO DEFINITIONS ///.
Definition: dau.h:67
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Dau_DsdMergeInlineDefinitions(char *pDsd, int *pMatches, Dau_Sto_t *pS, char *pRes, int nShared)
Definition: dauMerge.c:232
static void Dau_DsdMergeStoreCleanOutput(Dau_Sto_t *pS)
Definition: dauMerge.c:65
static int Dau_DsdMergeCreateMaps(int *pVarPres, int nShared, int *pOld2New, int *pNew2Old)
Definition: dauMerge.c:211
#define DAU_MAX_STR
Definition: dau.h:43
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
void Dau_DsdNormalize(char *p)
Definition: dauDsd.c:260
#define DAU_MAX_VAR
INCLUDES ///.
Definition: dau.h:42
static void Dau_DsdMergeReplace(char *pDsd, int *pMatches, int *pMap)
Definition: dauMerge.c:147
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
char * sprintf()
static int Counter
char * strcpy()
#define DAU_MAX_WORD
Definition: dau.h:44
static int Dau_DsdIsConst1(char *p)
Definition: dau.h:69
static int Abc_TtWordNum(int nVars)
Definition: utilTruth.h:169
static void Dau_DsdMergeMatches(char *pDsd, int *pMatches)
Definition: dauMerge.c:163
static int Abc_TtEqual(word *pIn1, word *pIn2, int nWords)
Definition: utilTruth.h:269
static void Dau_DsdMergeCopy(char *pDsd, int fCompl, char *pRes)
Definition: dauMerge.c:126
abctime s_TimeComp[4]
Definition: dauMerge.c:574
#define assert(ex)
Definition: util_old.h:213
static int Dau_DsdMergeStatus(char *pDsd, int *pMatches, int nShared, int *pStatus)
Definition: dauMerge.c:346
static int Dau_DsdIsConst0(char *p)
Definition: dau.h:68
static void Abc_TtAnd(word *pOut, word *pIn1, word *pIn2, int nWords, int fCompl)
Definition: utilTruth.h:231
ABC_INT64_T abctime
Definition: abc_global.h:278
static shot S[256]
Definition: kitPerm.c:40
int If_CutDelayRecCost3 ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pObj 
)

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;
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 }
unsigned nLimit
Definition: if.h:288
#define LMS_VAR_MAX
Definition: abcRec3.c:31
Vec_Int_t * vTruthPo
Definition: abcRec3.c:63
static int If_CutFindBestStruct(If_Man_t *pIfMan, If_Cut_t *pCut, char *pCanonPerm, unsigned *puCanonPhase, int *pBestPo)
Definition: abcRec3.c:903
void Lms_ManPrepare(Lms_Man_t *p)
Definition: abcRec3.c:384
static Lms_Man_t * s_pMan3
Definition: abcRec3.c:96
#define assert(ex)
Definition: util_old.h:213
int fLibConstr
Definition: abcRec3.c:56
int nVars
Definition: abcRec3.c:52
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 68 of file ifMap.c.

69 {
70  static float Pin2Pin[2][3] = { {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0} };
71  If_Obj_t * pLeaf;
72  float DelayCur, Delay = -IF_FLOAT_LARGE;
73  int i;
74  assert( pCut->nLeaves <= 3 );
75  If_CutForEachLeaf( p, pCut, pLeaf, i )
76  {
77  DelayCur = If_ObjCutBest(pLeaf)->Delay;
78  Delay = IF_MAX( Delay, Pin2Pin[fCarry][i] + DelayCur );
79  }
80  return Delay;
81 }
#define IF_MAX(a, b)
Definition: if.h:437
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
#define IF_FLOAT_LARGE
Definition: if.h:440
#define assert(ex)
Definition: util_old.h:213
float Delay
Definition: if.h:280
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 491 of file ifMap.c.

492 {
493 // ProgressBar * pProgress;
494  If_Obj_t * pObj;
495  int i;
496  abctime clk = Abc_Clock();
497  float arrTime;
498  assert( Mode >= 0 && Mode <= 2 );
499  p->nBestCutSmall[0] = p->nBestCutSmall[1] = 0;
500  // set the sorting function
501  if ( Mode || p->pPars->fArea ) // area
502  p->SortMode = 1;
503  else if ( p->pPars->fFancy )
504  p->SortMode = 2;
505  else
506  p->SortMode = 0;
507  // set the cut number
508  p->nCutsUsed = nCutsUsed;
509  p->nCutsMerged = 0;
510  // make sure the visit counters are all zero
511  If_ManForEachNode( p, pObj, i )
512  assert( pObj->nVisits == pObj->nVisitsCopy );
513  // map the internal nodes
514  if ( p->pManTim != NULL )
515  {
517  If_ManForEachObj( p, pObj, i )
518  {
519  if ( If_ObjIsAnd(pObj) )
520  {
521  If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
522  if ( pObj->fRepr )
523  If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
524  }
525  else if ( If_ObjIsCi(pObj) )
526  {
527 //Abc_Print( 1, "processing CI %d\n", pObj->Id );
528  arrTime = Tim_ManGetCiArrival( p->pManTim, pObj->IdPio );
529  If_ObjSetArrTime( pObj, arrTime );
530  }
531  else if ( If_ObjIsCo(pObj) )
532  {
533  arrTime = If_ObjArrTime( If_ObjFanin0(pObj) );
534  Tim_ManSetCoArrival( p->pManTim, pObj->IdPio, arrTime );
535  }
536  else if ( If_ObjIsConst1(pObj) )
537  {
538  }
539  else
540  assert( 0 );
541  }
542 // Tim_ManPrint( p->pManTim );
543  }
544  else
545  {
546  // pProgress = Extra_ProgressBarStart( stdout, If_ManObjNum(p) );
547  If_ManForEachNode( p, pObj, i )
548  {
549  // Extra_ProgressBarUpdate( pProgress, i, pLabel );
550  If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
551  if ( pObj->fRepr )
552  If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
553  }
554  }
555 // Extra_ProgressBarStop( pProgress );
556  // make sure the visit counters are all zero
557  If_ManForEachNode( p, pObj, i )
558  assert( pObj->nVisits == 0 );
559  // compute required times and stats
561 // Tim_ManPrint( p->pManTim );
562  if ( p->pPars->fVerbose )
563  {
564  char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
565  Abc_Print( 1, "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. ",
566  Symb, p->RequiredGlo, p->AreaGlo, p->nNets );
567  if ( p->dPower )
568  Abc_Print( 1, "Switch = %7.2f. ", p->dPower );
569  Abc_Print( 1, "Cut = %8d. ", p->nCutsMerged );
570  Abc_PrintTime( 1, "T", Abc_Clock() - clk );
571 // Abc_Print( 1, "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
572 // p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
573  }
574  return 1;
575 }
int nBestCutSmall[2]
Definition: if.h:258
int nCutsUsed
Definition: if.h:201
#define If_ManForEachNode(p, pObj, i)
Definition: if.h:468
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition: timTrav.c:44
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
unsigned fRepr
Definition: if.h:309
void If_ManComputeRequired(If_Man_t *p)
Definition: ifTime.c:294
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:116
int nCutsMerged
Definition: if.h:202
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static abctime Abc_Clock()
Definition: abc_global.h:279
void If_ObjPerformMappingAnd(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
Definition: ifMap.c:95
Tim_Man_t * pManTim
Definition: if.h:263
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
if(last==0)
Definition: sparse_int.h:34
static void If_ObjSetArrTime(If_Obj_t *pObj, float ArrTime)
Definition: if.h:406
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static float If_ObjArrTime(If_Obj_t *pObj)
Definition: if.h:405
int fFancy
Definition: if.h:115
If_Par_t * pPars
Definition: if.h:184
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
#define assert(ex)
Definition: util_old.h:213
int SortMode
Definition: if.h:205
int fArea
Definition: if.h:114
ABC_INT64_T abctime
Definition: abc_global.h:278
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition: timTime.c:174
int IdPio
Definition: if.h:317
void If_ObjPerformMappingChoice(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
Definition: ifMap.c:407
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 95 of file ifMap.c.

96 {
97  If_Set_t * pCutSet;
98  If_Cut_t * pCut0, * pCut1, * pCut;
99  If_Cut_t * pCut0R, * pCut1R;
100  int fFunc0R, fFunc1R;
101  int i, k, v, iCutDsd, fChange;
102  int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->pLutStruct != NULL;
103  assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
104  assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
105 
106  // prepare
107  if ( Mode == 0 )
108  pObj->EstRefs = (float)pObj->nRefs;
109  else if ( Mode == 1 )
110  pObj->EstRefs = (float)((2.0 * pObj->EstRefs + pObj->nRefs) / 3.0);
111  // deref the selected cut
112  if ( Mode && pObj->nRefs > 0 )
113  If_CutAreaDeref( p, If_ObjCutBest(pObj) );
114 
115  // prepare the cutset
116  pCutSet = If_ManSetupNodeCutSet( p, pObj );
117 
118  // get the current assigned best cut
119  pCut = If_ObjCutBest(pObj);
120  if ( !fFirst )
121  {
122  // recompute the parameters of the best cut
123  if ( p->pPars->fDelayOpt )
124  pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
125  else if ( p->pPars->fDsdBalance )
126  pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
127  else if ( p->pPars->fUserRecLib )
128  pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
129  else if ( p->pPars->fDelayOptLut )
130  pCut->Delay = If_CutLutBalanceEval( p, pCut );
131  else if( p->pPars->nGateSize > 0 )
132  pCut->Delay = If_CutDelaySop( p, pCut );
133  else
134  pCut->Delay = If_CutDelay( p, pObj, pCut );
135  assert( pCut->Delay != -1 );
136 // assert( pCut->Delay <= pObj->Required + p->fEpsilon );
137  if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
138  Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
139  pObj->Id, pCut->Delay, pObj->Required + p->fEpsilon );
140  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
141  if ( p->pPars->fEdge )
142  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
143  if ( p->pPars->fPower )
144  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
145  // save the best cut from the previous iteration
146  if ( !fPreprocess )
147  If_CutCopy( p, pCutSet->ppCuts[pCutSet->nCuts++], pCut );
148  }
149 
150  // generate cuts
151  If_ObjForEachCut( pObj->pFanin0, pCut0, i )
152  If_ObjForEachCut( pObj->pFanin1, pCut1, k )
153  {
154  // get the next free cut
155  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
156  pCut = pCutSet->ppCuts[pCutSet->nCuts];
157  // make sure K-feasible cut exists
158  if ( If_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->pPars->nLutSize )
159  continue;
160 
161  pCut0R = pCut0;
162  pCut1R = pCut1;
163  fFunc0R = pCut0->iCutFunc ^ pCut0->fCompl ^ pObj->fCompl0;
164  fFunc1R = pCut1->iCutFunc ^ pCut1->fCompl ^ pObj->fCompl1;
165  if ( !p->pPars->fUseTtPerm || pCut0->nLeaves > pCut1->nLeaves || (pCut0->nLeaves == pCut1->nLeaves && fFunc0R > fFunc1R) )
166  {
167  }
168  else
169  {
170  ABC_SWAP( If_Cut_t *, pCut0R, pCut1R );
171  ABC_SWAP( int, fFunc0R, fFunc1R );
172  }
173 
174  // merge the cuts
175  if ( p->pPars->fUseTtPerm )
176  {
177  if ( !If_CutMerge( p, pCut0R, pCut1R, pCut ) )
178  continue;
179  }
180  else
181  {
182  if ( !If_CutMergeOrdered( p, pCut0, pCut1, pCut ) )
183  continue;
184  }
185  if ( pObj->fSpec && pCut->nLeaves == (unsigned)p->pPars->nLutSize )
186  continue;
187  p->nCutsMerged++;
188  p->nCutsTotal++;
189  // check if this cut is contained in any of the available cuts
190  if ( !p->pPars->fSkipCutFilter && If_CutFilter( pCutSet, pCut, fSave0 ) )
191  continue;
192  // compute the truth table
193  pCut->iCutFunc = -1;
194  pCut->fCompl = 0;
195  if ( p->pPars->fTruth )
196  {
197 // int nShared = pCut0->nLeaves + pCut1->nLeaves - pCut->nLeaves;
198  abctime clk = 0;
199  if ( p->pPars->fVerbose )
200  clk = Abc_Clock();
201  if ( p->pPars->fUseTtPerm )
202  fChange = If_CutComputeTruthPerm( p, pCut, pCut0R, pCut1R, fFunc0R, fFunc1R );
203  else
204  fChange = If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
205  if ( p->pPars->fVerbose )
206  p->timeCache[4] += Abc_Clock() - clk;
207  if ( !p->pPars->fSkipCutFilter && fChange && If_CutFilter( pCutSet, pCut, fSave0 ) )
208  continue;
209  if ( p->pPars->fUseDsd )
210  {
211  extern void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd );
212  int truthId = Abc_Lit2Var(pCut->iCutFunc);
213  if ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) || Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId) == -1 )
214  {
215  while ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) )
216  {
217  Vec_IntPush( p->vTtDsds[pCut->nLeaves], -1 );
218  for ( v = 0; v < Abc_MaxInt(6, pCut->nLeaves); v++ )
219  Vec_StrPush( p->vTtPerms[pCut->nLeaves], IF_BIG_CHAR );
220  }
221  iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthWR(p, pCut), pCut->nLeaves, (unsigned char *)If_CutDsdPerm(p, pCut), p->pPars->pLutStruct );
222  Vec_IntWriteEntry( p->vTtDsds[pCut->nLeaves], truthId, iCutDsd );
223  }
224  assert( If_DsdManSuppSize(p->pIfDsdMan, If_CutDsdLit(p, pCut)) == (int)pCut->nLeaves );
225  //If_ManCacheRecord( p, If_CutDsdLit(p, pCut0), If_CutDsdLit(p, pCut1), nShared, If_CutDsdLit(p, pCut) );
226  }
227  // run user functions
228  pCut->fUseless = 0;
229  if ( p->pPars->pFuncCell )
230  {
231  assert( p->pPars->fUseTtPerm == 0 );
232  assert( pCut->nLimit >= 4 && pCut->nLimit <= 16 );
233  if ( p->pPars->fUseDsd )
234  pCut->fUseless = If_DsdManCheckDec( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
235  else
236  pCut->fUseless = !p->pPars->pFuncCell( p, If_CutTruth(p, pCut), Abc_MaxInt(6, pCut->nLeaves), pCut->nLeaves, p->pPars->pLutStruct );
237  p->nCutsUselessAll += pCut->fUseless;
238  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
239  p->nCutsCountAll++;
240  p->nCutsCount[pCut->nLeaves]++;
241  // skip 5-input cuts, which cannot be decomposed
242  if ( (p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u) && pCut->nLeaves == 5 && pCut->nLimit == 5 )
243  {
244  extern int If_CluCheckDecInAny( word t, int nVars );
245  extern int If_CluCheckDecOut( word t, int nVars );
246  unsigned TruthU = *If_CutTruth(p, pCut);
247  word Truth = (((word)TruthU << 32) | (word)TruthU);
248  p->nCuts5++;
249  if ( If_CluCheckDecInAny( Truth, 5 ) )
250  p->nCuts5a++;
251  else
252  continue;
253  }
254  else if ( p->pPars->fVerbose && pCut->nLeaves == 5 )
255  {
256  extern int If_CluCheckDecInAny( word t, int nVars );
257  extern int If_CluCheckDecOut( word t, int nVars );
258  unsigned TruthU = *If_CutTruth(p, pCut);
259  word Truth = (((word)TruthU << 32) | (word)TruthU);
260  p->nCuts5++;
261  if ( If_CluCheckDecInAny( Truth, 5 ) || If_CluCheckDecOut( Truth, 5 ) )
262  p->nCuts5a++;
263  }
264  }
265  else if ( p->pPars->fUseDsdTune )
266  {
267  pCut->fUseless = If_DsdManReadMark( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
268  p->nCutsUselessAll += pCut->fUseless;
269  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
270  p->nCutsCountAll++;
271  p->nCutsCount[pCut->nLeaves]++;
272  }
273  else
274  {
275  if ( p->pPars->fUseAndVars )
276  {
277  int iDecMask = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
278  if ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) || Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId) == -1 )
279  {
280  while ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) )
281  Vec_IntPush( p->vTtDecs[pCut->nLeaves], -1 );
282  if ( (int)pCut->nLeaves > p->pPars->nLutSize / 2 )
283  iDecMask = Abc_TtProcessBiDec( If_CutTruthW(p, pCut), (int)pCut->nLeaves, p->pPars->nLutSize / 2 );
284  else
285  iDecMask = 0;
286  Vec_IntWriteEntry( p->vTtDecs[pCut->nLeaves], truthId, iDecMask );
287  }
288  iDecMask = Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId);
289  assert( iDecMask >= 0 );
290  pCut->fUseless = (int)(iDecMask == 0 && (int)pCut->nLeaves > p->pPars->nLutSize / 2);
291  p->nCutsUselessAll += pCut->fUseless;
292  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
293  p->nCutsCountAll++;
294  p->nCutsCount[pCut->nLeaves]++;
295  }
296  if ( p->pPars->fUseCofVars && (!p->pPars->fUseAndVars || pCut->fUseless) )
297  {
298  int iCofVar = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
299  if ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) || Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId) == (char)-1 )
300  {
301  while ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) )
302  Vec_StrPush( p->vTtVars[pCut->nLeaves], (char)-1 );
303  iCofVar = Abc_TtCheckCondDep( If_CutTruthWR(p, pCut), pCut->nLeaves, p->pPars->nLutSize / 2 );
304  Vec_StrWriteEntry( p->vTtVars[pCut->nLeaves], truthId, (char)iCofVar );
305  }
306  iCofVar = Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId);
307  assert( iCofVar >= 0 && iCofVar <= (int)pCut->nLeaves );
308  pCut->fUseless = (int)(iCofVar == (int)pCut->nLeaves && pCut->nLeaves > 0);
309  p->nCutsUselessAll += pCut->fUseless;
310  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
311  p->nCutsCountAll++;
312  p->nCutsCount[pCut->nLeaves]++;
313  }
314  }
315  }
316 
317  // compute the application-specific cost and depth
318  pCut->fUser = (p->pPars->pFuncCost != NULL);
319  pCut->Cost = p->pPars->pFuncCost? p->pPars->pFuncCost(p, pCut) : 0;
320  if ( pCut->Cost == IF_COST_MAX )
321  continue;
322  // check if the cut satisfies the required times
323  if ( p->pPars->fDelayOpt )
324  {
325  pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
326 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
327 // pCut->Delay += 1;
328  }
329  else if ( p->pPars->fDsdBalance )
330  {
331  pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
332 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
333 // pCut->Delay += 1;
334  }
335  else if ( p->pPars->fUserRecLib )
336  {
337  pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
338 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
339 // pCut->Delay += 1;
340  }
341  else if ( p->pPars->fDelayOptLut )
342  pCut->Delay = If_CutLutBalanceEval( p, pCut );
343  else if( p->pPars->nGateSize > 0 )
344  pCut->Delay = If_CutDelaySop( p, pCut );
345  else
346  pCut->Delay = If_CutDelay( p, pObj, pCut );
347  if ( pCut->Delay == -1 )
348  continue;
349  if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
350  continue;
351  // compute area of the cut (this area may depend on the application specific cost)
352  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
353  if ( p->pPars->fEdge )
354  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
355  if ( p->pPars->fPower )
356  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
357 // pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
358  // insert the cut into storage
359  If_CutSort( p, pCutSet, pCut );
360 // If_CutTraverse( p, pObj, pCut );
361  }
362  assert( pCutSet->nCuts > 0 );
363 // If_CutVerifyCuts( pCutSet, !p->pPars->fUseTtPerm );
364 
365  // update the best cut
366  if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
367  {
368  If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
369  if(p->pPars->fUserRecLib)
370  assert(If_ObjCutBest(pObj)->Cost < IF_COST_MAX && If_ObjCutBest(pObj)->Delay < ABC_INFINITY);
371  }
372  // add the trivial cut to the set
373  if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
374  {
375  If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
376  assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
377  }
378 // if ( If_ObjCutBest(pObj)->nLeaves == 0 )
379 // p->nBestCutSmall[0]++;
380 // else if ( If_ObjCutBest(pObj)->nLeaves == 1 )
381 // p->nBestCutSmall[1]++;
382 
383  // ref the selected cut
384  if ( Mode && pObj->nRefs > 0 )
385  If_CutAreaRef( p, If_ObjCutBest(pObj) );
386  if ( If_ObjCutBest(pObj)->fUseless )
387  Abc_Print( 1, "The best cut is useless.\n" );
388  // call the user specified function for each cut
389  if ( p->pPars->pFuncUser )
390  If_ObjForEachCut( pObj, pCut, i )
391  p->pPars->pFuncUser( p, pObj, pCut );
392  // free the cuts
393  If_ManDerefNodeCutSet( p, pObj );
394 }
If_Obj_t * pFanin0
Definition: if.h:321
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
int If_DsdManCheckDec(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:185
If_Set_t * pCutSet
Definition: if.h:332
unsigned nLeaves
Definition: if.h:289
int Id
Definition: if.h:316
float If_CutPowerFlow(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:979
int If_DsdManCompute(If_DsdMan_t *p, word *pTruth, int nLeaves, unsigned char *pPerm, char *pLutStruct)
Definition: ifDsd.c:2032
int If_CutMerge(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition: ifCut.c:364
unsigned nLimit
Definition: if.h:288
Vec_Str_t * vTtVars[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:248
int nLutSize
Definition: if.h:103
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float Edge
Definition: if.h:278
float If_CutAreaFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:919
Vec_Int_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:249
int If_CluCheckDecOut(word t, int nVars)
Definition: ifDec16.c:1840
#define IF_BIG_CHAR
Definition: if.h:60
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
Definition: if.h:275
float Required
Definition: if.h:325
int fDelayOptLut
Definition: if.h:122
int fVerbose
Definition: if.h:140
int fSkipCutFilter
Definition: if.h:144
int nCutsCountAll
Definition: if.h:240
static void If_CutCopy(If_Man_t *p, If_Cut_t *pDst, If_Cut_t *pSrc)
Definition: if.h:398
char * pLutStruct
Definition: if.h:141
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
int nCutsMerged
Definition: if.h:202
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:247
int nCutsTotal
Definition: if.h:237
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
Definition: if.h:163
static int Abc_TtProcessBiDec(word *pTruth, int nVars, int nSuppLim)
Definition: utilTruth.h:2431
static int If_WordCountOnes(unsigned uWord)
FUNCTION DEFINITIONS ///.
Definition: ifMap.c:48
unsigned fUser
Definition: if.h:286
float If_CutEdgeDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1187
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int(* pFuncUser)(If_Man_t *, If_Obj_t *, If_Cut_t *)
Definition: if.h:164
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 nRefs
Definition: if.h:318
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
int fUseCofVars
Definition: if.h:135
int fEnableCheck75u
Definition: if.h:132
#define If_ObjForEachCut(pObj, pCut, i)
Definition: if.h:471
int nCuts5a
Definition: if.h:242
int nCuts5
Definition: if.h:242
int nGateSize
Definition: if.h:107
unsigned Cost
Definition: if.h:284
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
If_Set_t * If_ManSetupNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:579
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
int fEnableCheck75
Definition: if.h:131
int fEdge
Definition: if.h:118
int nCutsUseless[32]
Definition: if.h:238
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
int If_CutDelayRecCost3(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj)
Definition: abcRec3.c:1004
float Power
Definition: if.h:279
int fDsdBalance
Definition: if.h:123
int fTruth
Definition: if.h:146
static word * If_CutTruthWR(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:419
Definition: if.h:180
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition: ifMan.c:499
float If_CutAreaDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1086
if(last==0)
Definition: sparse_int.h:34
unsigned fSkipCut
Definition: if.h:314
int nCutsUselessAll
Definition: if.h:241
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
int If_CluCheckDecInAny(word t, int nVars)
Definition: ifDec16.c:1767
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
If_Obj_t * pFanin1
Definition: if.h:322
int If_CutMergeOrdered(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition: ifCut.c:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int fUseAndVars
Definition: if.h:136
int If_CutSopBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDelay.c:248
float fEpsilon
Definition: if.h:195
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:98
int If_DsdManSuppSize(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:181
abctime timeCache[6]
Definition: if.h:257
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
int fUseDsd
Definition: if.h:133
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
If_Par_t * pPars
Definition: if.h:184
#define IF_COST_MAX
Definition: if.h:58
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:246
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
short nCuts
Definition: if.h:297
float If_CutDelay(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition: ifTime.c:91
int(* pFuncCell)(If_Man_t *, unsigned *, int, int, char *)
Definition: if.h:165
int If_CutFilter(If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
Definition: ifCut.c:146
int fUseDsdTune
Definition: if.h:134
static int Abc_TtCheckCondDep(word *pTruth, int nVars, int nSuppLim)
Definition: utilTruth.h:1055
int fUserRecLib
Definition: if.h:124
int fPower
Definition: if.h:119
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int fDelayOpt
Definition: if.h:121
Definition: if.h:294
unsigned uSign
Definition: if.h:283
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
int fUseTtPerm
Definition: if.h:137
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
int nCutsCount[32]
Definition: if.h:239
If_Cut_t ** ppCuts
Definition: if.h:299
int If_CutDsdBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDsd.c:2288
unsigned fCompl
Definition: if.h:285
unsigned fSpec
Definition: if.h:312
int If_CutLutBalanceEval(If_Man_t *p, If_Cut_t *pCut)
Definition: ifDelay.c:369
ABC_INT64_T abctime
Definition: abc_global.h:278
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutEdgeFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:949
unsigned fCompl1
Definition: if.h:307
int If_DsdManReadMark(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:189
unsigned fCompl0
Definition: if.h:306
int iCutFunc
Definition: if.h:281
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
float Delay
Definition: if.h:280
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:263
float If_CutPowerDerefed(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1290
int If_CutDelaySop(If_Man_t *p, If_Cut_t *pCut)
Definition: ifDelay.c:64
void If_ManDerefNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:602
float Area
Definition: if.h:277
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 407 of file ifMap.c.

408 {
409  If_Set_t * pCutSet;
410  If_Obj_t * pTemp;
411  If_Cut_t * pCutTemp, * pCut;
412  int i, fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib;
413  assert( pObj->pEquiv != NULL );
414 
415  // prepare
416  if ( Mode && pObj->nRefs > 0 )
417  If_CutAreaDeref( p, If_ObjCutBest(pObj) );
418 
419  // remove elementary cuts
420  for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
421  pTemp->pCutSet->nCuts--;
422 
423  // update the cutset of the node
424  pCutSet = pObj->pCutSet;
425 
426  // generate cuts
427  for ( pTemp = pObj->pEquiv; pTemp; pTemp = pTemp->pEquiv )
428  {
429  if ( pTemp->pCutSet->nCuts == 0 )
430  continue;
431  // go through the cuts of this node
432  If_ObjForEachCut( pTemp, pCutTemp, i )
433  {
434  if ( pCutTemp->fUseless )
435  continue;
436  // get the next free cut
437  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
438  pCut = pCutSet->ppCuts[pCutSet->nCuts];
439  // copy the cut into storage
440  If_CutCopy( p, pCut, pCutTemp );
441  // check if this cut is contained in any of the available cuts
442  if ( If_CutFilter( pCutSet, pCut, fSave0 ) )
443  continue;
444  // check if the cut satisfies the required times
445 // assert( pCut->Delay == If_CutDelay( p, pTemp, pCut ) );
446  if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
447  continue;
448  // set the phase attribute
449  pCut->fCompl = pObj->fPhase ^ pTemp->fPhase;
450  // compute area of the cut (this area may depend on the application specific cost)
451  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
452  if ( p->pPars->fEdge )
453  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
454  if ( p->pPars->fPower )
455  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
456 // pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
457  // insert the cut into storage
458  If_CutSort( p, pCutSet, pCut );
459  }
460  }
461  assert( pCutSet->nCuts > 0 );
462 
463  // update the best cut
464  if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
465  If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
466  // add the trivial cut to the set
467  if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
468  {
469  If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
470  assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
471  }
472 
473  // ref the selected cut
474  if ( Mode && pObj->nRefs > 0 )
475  If_CutAreaRef( p, If_ObjCutBest(pObj) );
476  // free the cuts
477  If_ManDerefChoiceCutSet( p, pObj );
478 }
If_Set_t * pCutSet
Definition: if.h:332
int Id
Definition: if.h:316
float If_CutPowerFlow(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:979
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float Edge
Definition: if.h:278
float If_CutAreaFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:919
Definition: if.h:303
Definition: if.h:275
float Required
Definition: if.h:325
int fDelayOptLut
Definition: if.h:122
static void If_CutCopy(If_Man_t *p, If_Cut_t *pDst, If_Cut_t *pSrc)
Definition: if.h:398
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
float If_CutEdgeDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1187
for(p=first;p->value< newval;p=p->next)
int nRefs
Definition: if.h:318
#define If_ObjForEachCut(pObj, pCut, i)
Definition: if.h:471
int fEdge
Definition: if.h:118
float Power
Definition: if.h:279
int fDsdBalance
Definition: if.h:123
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition: ifMan.c:499
float If_CutAreaDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1086
unsigned fSkipCut
Definition: if.h:314
If_Obj_t * pEquiv
Definition: if.h:323
float fEpsilon
Definition: if.h:195
If_Par_t * pPars
Definition: if.h:184
short nCuts
Definition: if.h:297
int If_CutFilter(If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
Definition: ifCut.c:146
int fUserRecLib
Definition: if.h:124
int fPower
Definition: if.h:119
int fDelayOpt
Definition: if.h:121
Definition: if.h:294
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
unsigned fCompl
Definition: if.h:285
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutEdgeFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:949
unsigned fPhase
Definition: if.h:308
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
float Delay
Definition: if.h:280
float If_CutPowerDerefed(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1290
void If_ManDerefChoiceCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:645
float Area
Definition: if.h:277
static int If_WordCountOnes ( unsigned  uWord)
inlinestatic

FUNCTION DEFINITIONS ///.

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file ifMap.c.

49 {
50  uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
51  uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
52  uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
53  uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
54  return (uWord & 0x0000FFFF) + (uWord>>16);
55 }