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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int If_CutVerifyCut (If_Cut_t *pBase, If_Cut_t *pCut)
 DECLARATIONS ///. More...
 
int If_CutVerifyCuts (If_Set_t *pCutSet, int fOrdered)
 
static int If_CutCheckDominance (If_Cut_t *pDom, If_Cut_t *pCut)
 
int If_CutFilter (If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
 
int If_CutMergeOrdered_ (If_Man_t *p, If_Cut_t *pC0, If_Cut_t *pC1, If_Cut_t *pC)
 
int If_CutMergeOrdered (If_Man_t *p, If_Cut_t *pC0, If_Cut_t *pC1, If_Cut_t *pC)
 
int If_CutMerge (If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
 
int If_CutCompareDelay (If_Man_t *p, If_Cut_t **ppC0, If_Cut_t **ppC1)
 
int If_CutCompareDelayOld (If_Man_t *p, If_Cut_t **ppC0, If_Cut_t **ppC1)
 
int If_CutCompareArea (If_Man_t *p, If_Cut_t **ppC0, If_Cut_t **ppC1)
 
static int If_ManSortCompare (If_Man_t *p, If_Cut_t *pC0, If_Cut_t *pC1)
 
static int If_ManSortCompare_old (If_Man_t *p, If_Cut_t *pC0, If_Cut_t *pC1)
 
void If_CutSort (If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
 
void If_CutOrder (If_Cut_t *pCut)
 
int If_CutCheck (If_Cut_t *pCut)
 
void If_CutPrint (If_Cut_t *pCut)
 
void If_CutPrintTiming (If_Man_t *p, If_Cut_t *pCut)
 
void If_CutLift (If_Cut_t *pCut)
 
float If_CutAreaFlow (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeFlow (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutPowerFlow (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutAverageRefs (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaDeref (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaRef (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaDerefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaRefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeDeref (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeRef (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeDerefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeRefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutPowerDeref (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutPowerRef (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutPowerDerefed (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutPowerRefed (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
int If_CutGetCutMinLevel (If_Man_t *p, If_Cut_t *pCut)
 
int If_CutGetCone_rec (If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
 
int If_CutGetCones (If_Man_t *p)
 
void If_CutFoundFanins_rec (If_Obj_t *pObj, Vec_Int_t *vLeaves)
 
int If_CutCountTotalFanins (If_Man_t *p)
 

Function Documentation

float If_CutAreaDeref ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1032 of file ifCut.c.

1033 {
1034  If_Obj_t * pLeaf;
1035  float Area;
1036  int i;
1037  Area = If_CutLutArea(p, pCut);
1038  If_CutForEachLeaf( p, pCut, pLeaf, i )
1039  {
1040  assert( pLeaf->nRefs > 0 );
1041  if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) )
1042  continue;
1043  Area += If_CutAreaDeref( p, If_ObjCutBest(pLeaf) );
1044  }
1045  return Area;
1046 }
static float If_CutLutArea(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:428
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#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
int nRefs
Definition: if.h:318
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
#define assert(ex)
Definition: util_old.h:213
float If_CutAreaDerefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1086 of file ifCut.c.

1087 {
1088  float aResult, aResult2;
1089  if ( pCut->nLeaves < 2 )
1090  return 0;
1091  aResult2 = If_CutAreaRef( p, pCut );
1092  aResult = If_CutAreaDeref( p, pCut );
1093  assert( aResult > aResult2 - p->fEpsilon );
1094  assert( aResult < aResult2 + p->fEpsilon );
1095  return aResult;
1096 }
unsigned nLeaves
Definition: if.h:289
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float fEpsilon
Definition: if.h:195
#define assert(ex)
Definition: util_old.h:213
float If_CutAreaFlow ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area flow.]

Description []

SideEffects []

SeeAlso []

Definition at line 919 of file ifCut.c.

920 {
921  If_Obj_t * pLeaf;
922  float Flow;
923  int i;
924  Flow = If_CutLutArea(p, pCut);
925  If_CutForEachLeaf( p, pCut, pLeaf, i )
926  {
927  if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
928  Flow += If_ObjCutBest(pLeaf)->Area;
929  else
930  {
931  assert( pLeaf->EstRefs > p->fEpsilon );
932  Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs;
933  }
934  }
935  return Flow;
936 }
static float If_CutLutArea(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:428
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
int nRefs
Definition: if.h:318
float fEpsilon
Definition: if.h:195
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
float Area
Definition: if.h:277
float If_CutAreaRef ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1059 of file ifCut.c.

1060 {
1061  If_Obj_t * pLeaf;
1062  float Area;
1063  int i;
1064  Area = If_CutLutArea(p, pCut);
1065  If_CutForEachLeaf( p, pCut, pLeaf, i )
1066  {
1067  assert( pLeaf->nRefs >= 0 );
1068  if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) )
1069  continue;
1070  Area += If_CutAreaRef( p, If_ObjCutBest(pLeaf) );
1071  }
1072  return Area;
1073 }
static float If_CutLutArea(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:428
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#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
int nRefs
Definition: if.h:318
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
#define assert(ex)
Definition: util_old.h:213
float If_CutAreaRefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1109 of file ifCut.c.

1110 {
1111  float aResult, aResult2;
1112  if ( pCut->nLeaves < 2 )
1113  return 0;
1114  aResult2 = If_CutAreaDeref( p, pCut );
1115  aResult = If_CutAreaRef( p, pCut );
1116  assert( aResult > aResult2 - p->fEpsilon );
1117  assert( aResult < aResult2 + p->fEpsilon );
1118  return aResult;
1119 }
unsigned nLeaves
Definition: if.h:289
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float fEpsilon
Definition: if.h:195
#define assert(ex)
Definition: util_old.h:213
float If_CutAverageRefs ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Average number of references of the leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 1010 of file ifCut.c.

1011 {
1012  If_Obj_t * pLeaf;
1013  int nRefsTotal, i;
1014  nRefsTotal = 0;
1015  If_CutForEachLeaf( p, pCut, pLeaf, i )
1016  nRefsTotal += pLeaf->nRefs;
1017  return ((float)nRefsTotal)/pCut->nLeaves;
1018 }
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
int If_CutCheck ( If_Cut_t pCut)

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

Synopsis [Checks correctness of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 826 of file ifCut.c.

827 {
828  int i;
829  assert( pCut->nLeaves <= pCut->nLimit );
830  if ( pCut->nLeaves < 2 )
831  return 1;
832  for ( i = 1; i < (int)pCut->nLeaves; i++ )
833  {
834  if ( pCut->pLeaves[i-1] >= pCut->pLeaves[i] )
835  {
836  Abc_Print( -1, "If_CutCheck(): Cut has wrong ordering of inputs.\n" );
837  return 0;
838  }
839  assert( pCut->pLeaves[i-1] < pCut->pLeaves[i] );
840  }
841  return 1;
842 }
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pLeaves[0]
Definition: if.h:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define assert(ex)
Definition: util_old.h:213
static int If_CutCheckDominance ( If_Cut_t pDom,
If_Cut_t pCut 
)
inlinestatic

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

Synopsis [Returns 1 if pDom is contained in pCut.]

Description []

SideEffects []

SeeAlso []

Definition at line 119 of file ifCut.c.

120 {
121  int i, k;
122  assert( pDom->nLeaves <= pCut->nLeaves );
123  for ( i = 0; i < (int)pDom->nLeaves; i++ )
124  {
125  for ( k = 0; k < (int)pCut->nLeaves; k++ )
126  if ( pDom->pLeaves[i] == pCut->pLeaves[k] )
127  break;
128  if ( k == (int)pCut->nLeaves ) // node i in pDom is not contained in pCut
129  return 0;
130  }
131  // every node in pDom is contained in pCut
132  return 1;
133 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
#define assert(ex)
Definition: util_old.h:213
int If_CutCompareArea ( If_Man_t p,
If_Cut_t **  ppC0,
If_Cut_t **  ppC1 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 468 of file ifCut.c.

469 {
470  If_Cut_t * pC0 = *ppC0;
471  If_Cut_t * pC1 = *ppC1;
472  if ( pC0->Area < pC1->Area - p->fEpsilon )
473  return -1;
474  if ( pC0->Area > pC1->Area + p->fEpsilon )
475  return 1;
476 // if ( pC0->AveRefs > pC1->AveRefs )
477 // return -1;
478 // if ( pC0->AveRefs < pC1->AveRefs )
479 // return 1;
480  if ( pC0->nLeaves < pC1->nLeaves )
481  return -1;
482  if ( pC0->nLeaves > pC1->nLeaves )
483  return 1;
484  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
485  return -1;
486  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
487  return 1;
488  return 0;
489 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
float fEpsilon
Definition: if.h:195
float Delay
Definition: if.h:280
float Area
Definition: if.h:277
int If_CutCompareDelay ( If_Man_t p,
If_Cut_t **  ppC0,
If_Cut_t **  ppC1 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 408 of file ifCut.c.

409 {
410  If_Cut_t * pC0 = *ppC0;
411  If_Cut_t * pC1 = *ppC1;
412  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
413  return -1;
414  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
415  return 1;
416  if ( pC0->nLeaves < pC1->nLeaves )
417  return -1;
418  if ( pC0->nLeaves > pC1->nLeaves )
419  return 1;
420  if ( pC0->Area < pC1->Area - p->fEpsilon )
421  return -1;
422  if ( pC0->Area > pC1->Area + p->fEpsilon )
423  return 1;
424  return 0;
425 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
float fEpsilon
Definition: if.h:195
float Delay
Definition: if.h:280
float Area
Definition: if.h:277
int If_CutCompareDelayOld ( If_Man_t p,
If_Cut_t **  ppC0,
If_Cut_t **  ppC1 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 438 of file ifCut.c.

439 {
440  If_Cut_t * pC0 = *ppC0;
441  If_Cut_t * pC1 = *ppC1;
442  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
443  return -1;
444  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
445  return 1;
446  if ( pC0->Area < pC1->Area - p->fEpsilon )
447  return -1;
448  if ( pC0->Area > pC1->Area + p->fEpsilon )
449  return 1;
450  if ( pC0->nLeaves < pC1->nLeaves )
451  return -1;
452  if ( pC0->nLeaves > pC1->nLeaves )
453  return 1;
454  return 0;
455 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
float fEpsilon
Definition: if.h:195
float Delay
Definition: if.h:280
float Area
Definition: if.h:277
int If_CutCountTotalFanins ( If_Man_t p)

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

Synopsis [Computes the cone of the cut in AIG with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 1445 of file ifCut.c.

1446 {
1447  If_Obj_t * pObj;
1448  Vec_Int_t * vLeaves;
1449  int i, nFaninsTotal = 0, Counter = 0;
1450  abctime clk = Abc_Clock();
1451  vLeaves = Vec_IntAlloc( 100 );
1452  If_ManForEachObj( p, pObj, i )
1453  {
1454  if ( If_ObjIsAnd(pObj) && pObj->nRefs )
1455  {
1456  nFaninsTotal += If_ObjCutBest(pObj)->nLeaves;
1457  Vec_IntClear( vLeaves );
1458  If_CutFoundFanins_rec( If_ObjFanin0(pObj), vLeaves );
1459  If_CutFoundFanins_rec( If_ObjFanin1(pObj), vLeaves );
1460  Counter += Vec_IntSize(vLeaves);
1461  }
1462  }
1463  Abc_Print( 1, "Total cut inputs = %d. Total fanins incremental = %d.\n", nFaninsTotal, Counter );
1464  Abc_PrintTime( 1, "Fanins", Abc_Clock() - clk );
1465  Vec_IntFree( vLeaves );
1466  return 1;
1467 }
unsigned nLeaves
Definition: if.h:289
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static abctime Abc_Clock()
Definition: abc_global.h:279
int nRefs
Definition: if.h:318
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
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
static int Counter
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void If_CutFoundFanins_rec(If_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition: ifCut.c:1423
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
float If_CutEdgeDeref ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1133 of file ifCut.c.

1134 {
1135  If_Obj_t * pLeaf;
1136  float Edge;
1137  int i;
1138  Edge = pCut->nLeaves;
1139  If_CutForEachLeaf( p, pCut, pLeaf, i )
1140  {
1141  assert( pLeaf->nRefs > 0 );
1142  if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) )
1143  continue;
1144  Edge += If_CutEdgeDeref( p, If_ObjCutBest(pLeaf) );
1145  }
1146  return Edge;
1147 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#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
int nRefs
Definition: if.h:318
float If_CutEdgeDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1133
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeDerefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes edge of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1187 of file ifCut.c.

1188 {
1189  float aResult, aResult2;
1190  if ( pCut->nLeaves < 2 )
1191  return pCut->nLeaves;
1192  aResult2 = If_CutEdgeRef( p, pCut );
1193  aResult = If_CutEdgeDeref( p, pCut );
1194  assert( aResult > aResult2 - p->fEpsilon );
1195  assert( aResult < aResult2 + p->fEpsilon );
1196  return aResult;
1197 }
unsigned nLeaves
Definition: if.h:289
float If_CutEdgeRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1160
float fEpsilon
Definition: if.h:195
float If_CutEdgeDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1133
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeFlow ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area flow.]

Description []

SideEffects []

SeeAlso []

Definition at line 949 of file ifCut.c.

950 {
951  If_Obj_t * pLeaf;
952  float Flow;
953  int i;
954  Flow = pCut->nLeaves;
955  If_CutForEachLeaf( p, pCut, pLeaf, i )
956  {
957  if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
958  Flow += If_ObjCutBest(pLeaf)->Edge;
959  else
960  {
961  assert( pLeaf->EstRefs > p->fEpsilon );
962  Flow += If_ObjCutBest(pLeaf)->Edge / pLeaf->EstRefs;
963  }
964  }
965  return Flow;
966 }
unsigned nLeaves
Definition: if.h:289
float Edge
Definition: if.h:278
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
int nRefs
Definition: if.h:318
float fEpsilon
Definition: if.h:195
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeRef ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1160 of file ifCut.c.

1161 {
1162  If_Obj_t * pLeaf;
1163  float Edge;
1164  int i;
1165  Edge = pCut->nLeaves;
1166  If_CutForEachLeaf( p, pCut, pLeaf, i )
1167  {
1168  assert( pLeaf->nRefs >= 0 );
1169  if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) )
1170  continue;
1171  Edge += If_CutEdgeRef( p, If_ObjCutBest(pLeaf) );
1172  }
1173  return Edge;
1174 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#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
float If_CutEdgeRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1160
int nRefs
Definition: if.h:318
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeRefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1210 of file ifCut.c.

1211 {
1212  float aResult, aResult2;
1213  if ( pCut->nLeaves < 2 )
1214  return pCut->nLeaves;
1215  aResult2 = If_CutEdgeDeref( p, pCut );
1216  aResult = If_CutEdgeRef( p, pCut );
1217  assert( aResult > aResult2 - p->fEpsilon );
1218  assert( aResult < aResult2 + p->fEpsilon );
1219  return aResult;
1220 }
unsigned nLeaves
Definition: if.h:289
float If_CutEdgeRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1160
float fEpsilon
Definition: if.h:195
float If_CutEdgeDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1133
#define assert(ex)
Definition: util_old.h:213
int If_CutFilter ( If_Set_t pCutSet,
If_Cut_t pCut,
int  fSaveCut0 
)

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

Synopsis [Returns 1 if the cut is contained.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file ifCut.c.

147 {
148  If_Cut_t * pTemp;
149  int i, k;
150  assert( pCutSet->ppCuts[pCutSet->nCuts] == pCut );
151  for ( i = 0; i < pCutSet->nCuts; i++ )
152  {
153  pTemp = pCutSet->ppCuts[i];
154  if ( pTemp->nLeaves > pCut->nLeaves )
155  {
156  // do not fiter the first cut
157  if ( i == 0 && ((pCutSet->nCuts > 1 && pCutSet->ppCuts[1]->fUseless) || (fSaveCut0 && pCutSet->nCuts == 1)) )
158  continue;
159  // skip the non-contained cuts
160  if ( (pTemp->uSign & pCut->uSign) != pCut->uSign )
161  continue;
162  // check containment seriously
163  if ( If_CutCheckDominance( pCut, pTemp ) )
164  {
165 // p->ppCuts[i] = p->ppCuts[p->nCuts-1];
166 // p->ppCuts[p->nCuts-1] = pTemp;
167 // p->nCuts--;
168 // i--;
169  // remove contained cut
170  for ( k = i; k < pCutSet->nCuts; k++ )
171  pCutSet->ppCuts[k] = pCutSet->ppCuts[k+1];
172  pCutSet->ppCuts[pCutSet->nCuts] = pTemp;
173  pCutSet->nCuts--;
174  i--;
175  }
176  }
177  else
178  {
179  // skip the non-contained cuts
180  if ( (pTemp->uSign & pCut->uSign) != pTemp->uSign )
181  continue;
182  // check containment seriously
183  if ( If_CutCheckDominance( pTemp, pCut ) )
184  return 1;
185  }
186  }
187  return 0;
188 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
unsigned fUseless
Definition: if.h:287
short nCuts
Definition: if.h:297
unsigned uSign
Definition: if.h:283
static int If_CutCheckDominance(If_Cut_t *pDom, If_Cut_t *pCut)
Definition: ifCut.c:119
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
void If_CutFoundFanins_rec ( If_Obj_t pObj,
Vec_Int_t vLeaves 
)

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

Synopsis [Computes the cone of the cut in AIG with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 1423 of file ifCut.c.

1424 {
1425  if ( pObj->nRefs || If_ObjIsCi(pObj) )
1426  {
1427  Vec_IntPushUnique( vLeaves, pObj->Id );
1428  return;
1429  }
1430  If_CutFoundFanins_rec( If_ObjFanin0(pObj), vLeaves );
1431  If_CutFoundFanins_rec( If_ObjFanin1(pObj), vLeaves );
1432 }
int Id
Definition: if.h:316
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
int nRefs
Definition: if.h:318
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
void If_CutFoundFanins_rec(If_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition: ifCut.c:1423
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
int If_CutGetCone_rec ( If_Man_t p,
If_Obj_t pObj,
If_Cut_t pCut 
)

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

Synopsis [Computes the cone of the cut in AIG with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 1356 of file ifCut.c.

1357 {
1358  If_Obj_t * pTemp;
1359  int i, RetValue;
1360  // check if the node is in the cut
1361  for ( i = 0; i < (int)pCut->nLeaves; i++ )
1362  if ( pCut->pLeaves[i] == pObj->Id )
1363  return 1;
1364  else if ( pCut->pLeaves[i] > pObj->Id )
1365  break;
1366  // return if we reached the boundary
1367  if ( If_ObjIsCi(pObj) )
1368  return 0;
1369  // check the choice node
1370  for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
1371  {
1372  // check if the node itself is bound
1373  RetValue = If_CutGetCone_rec( p, If_ObjFanin0(pTemp), pCut );
1374  if ( RetValue )
1375  RetValue &= If_CutGetCone_rec( p, If_ObjFanin1(pTemp), pCut );
1376  if ( RetValue )
1377  return 1;
1378  }
1379  return 0;
1380 }
unsigned nLeaves
Definition: if.h:289
int Id
Definition: if.h:316
Definition: if.h:303
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
int If_CutGetCone_rec(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition: ifCut.c:1356
int pLeaves[0]
Definition: if.h:290
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
If_Obj_t * pEquiv
Definition: if.h:323
int If_CutGetCones ( If_Man_t p)

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

Synopsis [Computes the cone of the cut in AIG with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 1393 of file ifCut.c.

1394 {
1395  If_Obj_t * pObj;
1396  int i, Counter = 0;
1397  abctime clk = Abc_Clock();
1398  If_ManForEachObj( p, pObj, i )
1399  {
1400  if ( If_ObjIsAnd(pObj) && pObj->nRefs )
1401  {
1402  Counter += !If_CutGetCone_rec( p, pObj, If_ObjCutBest(pObj) );
1403 // Abc_Print( 1, "%d ", If_CutGetCutMinLevel( p, If_ObjCutBest(pObj) ) );
1404  }
1405  }
1406  Abc_Print( 1, "Cound not find boundary for %d nodes.\n", Counter );
1407  Abc_PrintTime( 1, "Cones", Abc_Clock() - clk );
1408  return 1;
1409 }
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static abctime Abc_Clock()
Definition: abc_global.h:279
int If_CutGetCone_rec(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition: ifCut.c:1356
int nRefs
Definition: if.h:318
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
static int Counter
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
ABC_INT64_T abctime
Definition: abc_global.h:278
int If_CutGetCutMinLevel ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes the cone of the cut in AIG with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 1336 of file ifCut.c.

1337 {
1338  If_Obj_t * pLeaf;
1339  int i, nMinLevel = IF_INFINITY;
1340  If_CutForEachLeaf( p, pCut, pLeaf, i )
1341  nMinLevel = IF_MIN( nMinLevel, (int)pLeaf->Level );
1342  return nMinLevel;
1343 }
#define IF_INFINITY
Definition: if.h:56
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
#define IF_MIN(a, b)
MACRO DEFINITIONS ///.
Definition: if.h:436
void If_CutLift ( If_Cut_t pCut)

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

Synopsis [Moves the cut over the latch.]

Description []

SideEffects []

SeeAlso []

Definition at line 897 of file ifCut.c.

898 {
899  unsigned i;
900  for ( i = 0; i < pCut->nLeaves; i++ )
901  {
902  assert( (pCut->pLeaves[i] & 255) < 255 );
903  pCut->pLeaves[i]++;
904  }
905 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
#define assert(ex)
Definition: util_old.h:213
int If_CutMerge ( If_Man_t p,
If_Cut_t pCut0,
If_Cut_t pCut1,
If_Cut_t pCut 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 364 of file ifCut.c.

365 {
366  int nLutSize = pCut0->nLimit;
367  int nSize0 = pCut0->nLeaves;
368  int nSize1 = pCut1->nLeaves;
369  int * pC0 = pCut0->pLeaves;
370  int * pC1 = pCut1->pLeaves;
371  int * pC = pCut->pLeaves;
372  int i, k, c;
373  // compare two cuts with different numbers
374  c = nSize0;
375  for ( i = 0; i < nSize1; i++ )
376  {
377  for ( k = 0; k < nSize0; k++ )
378  if ( pC1[i] == pC0[k] )
379  break;
380  if ( k < nSize0 )
381  {
382  p->pPerm[1][i] = k;
383  continue;
384  }
385  if ( c == nLutSize )
386  return 0;
387  p->pPerm[1][i] = c;
388  pC[c++] = pC1[i];
389  }
390  for ( i = 0; i < nSize0; i++ )
391  pC[i] = pC0[i];
392  pCut->nLeaves = c;
393  pCut->uSign = pCut0->uSign | pCut1->uSign;
394  return 1;
395 }
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pPerm[3][IF_MAX_LUTSIZE]
Definition: if.h:209
int pLeaves[0]
Definition: if.h:290
unsigned uSign
Definition: if.h:283
int If_CutMergeOrdered ( If_Man_t p,
If_Cut_t pC0,
If_Cut_t pC1,
If_Cut_t pC 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 290 of file ifCut.c.

291 {
292  int nSizeC0 = pC0->nLeaves;
293  int nSizeC1 = pC1->nLeaves;
294  int nLimit = pC0->nLimit;
295  int i, k, c, s;
296 
297  // both cuts are the largest
298  if ( nSizeC0 == nLimit && nSizeC1 == nLimit )
299  {
300  for ( i = 0; i < nSizeC0; i++ )
301  {
302  if ( pC0->pLeaves[i] != pC1->pLeaves[i] )
303  return 0;
304  pC->pLeaves[i] = pC0->pLeaves[i];
305  }
306  pC->nLeaves = nLimit;
307  pC->uSign = pC0->uSign | pC1->uSign;
308  return 1;
309  }
310 
311  // compare two cuts with different numbers
312  i = k = c = s = 0;
313  if ( nSizeC0 == 0 ) goto FlushCut1;
314  if ( nSizeC1 == 0 ) goto FlushCut0;
315  while ( 1 )
316  {
317  if ( c == nLimit ) return 0;
318  if ( pC0->pLeaves[i] < pC1->pLeaves[k] )
319  {
320  pC->pLeaves[c++] = pC0->pLeaves[i++];
321  if ( i == nSizeC0 ) goto FlushCut1;
322  }
323  else if ( pC0->pLeaves[i] > pC1->pLeaves[k] )
324  {
325  pC->pLeaves[c++] = pC1->pLeaves[k++];
326  if ( k == nSizeC1 ) goto FlushCut0;
327  }
328  else
329  {
330  pC->pLeaves[c++] = pC0->pLeaves[i++]; k++;
331  if ( i == nSizeC0 ) goto FlushCut1;
332  if ( k == nSizeC1 ) goto FlushCut0;
333  }
334  }
335 
336 FlushCut0:
337  if ( c + nSizeC0 > nLimit + i ) return 0;
338  while ( i < nSizeC0 )
339  pC->pLeaves[c++] = pC0->pLeaves[i++];
340  pC->nLeaves = c;
341  pC->uSign = pC0->uSign | pC1->uSign;
342  return 1;
343 
344 FlushCut1:
345  if ( c + nSizeC1 > nLimit + k ) return 0;
346  while ( k < nSizeC1 )
347  pC->pLeaves[c++] = pC1->pLeaves[k++];
348  pC->nLeaves = c;
349  pC->uSign = pC0->uSign | pC1->uSign;
350  return 1;
351 }
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pLeaves[0]
Definition: if.h:290
unsigned uSign
Definition: if.h:283
int If_CutMergeOrdered_ ( If_Man_t p,
If_Cut_t pC0,
If_Cut_t pC1,
If_Cut_t pC 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file ifCut.c.

202 {
203  int nSizeC0 = pC0->nLeaves;
204  int nSizeC1 = pC1->nLeaves;
205  int nLimit = pC0->nLimit;
206  int i, k, c, s;
207 
208  // both cuts are the largest
209  if ( nSizeC0 == nLimit && nSizeC1 == nLimit )
210  {
211  for ( i = 0; i < nSizeC0; i++ )
212  {
213  if ( pC0->pLeaves[i] != pC1->pLeaves[i] )
214  return 0;
215  p->pPerm[0][i] = p->pPerm[1][i] = p->pPerm[2][i] = i;
216  pC->pLeaves[i] = pC0->pLeaves[i];
217  }
218  pC->nLeaves = nLimit;
219  pC->uSign = pC0->uSign | pC1->uSign;
220  p->uSharedMask = Abc_InfoMask( nLimit );
221  return 1;
222  }
223 
224  // compare two cuts with different numbers
225  i = k = c = s = 0;
226  p->uSharedMask = 0;
227  if ( nSizeC0 == 0 ) goto FlushCut1;
228  if ( nSizeC1 == 0 ) goto FlushCut0;
229  while ( 1 )
230  {
231  if ( c == nLimit ) return 0;
232  if ( pC0->pLeaves[i] < pC1->pLeaves[k] )
233  {
234  p->pPerm[0][i] = c;
235  pC->pLeaves[c++] = pC0->pLeaves[i++];
236  if ( i == nSizeC0 ) goto FlushCut1;
237  }
238  else if ( pC0->pLeaves[i] > pC1->pLeaves[k] )
239  {
240  p->pPerm[1][k] = c;
241  pC->pLeaves[c++] = pC1->pLeaves[k++];
242  if ( k == nSizeC1 ) goto FlushCut0;
243  }
244  else
245  {
246  p->uSharedMask |= (1 << c);
247  p->pPerm[0][i] = p->pPerm[1][k] = p->pPerm[2][s++] = c;
248  pC->pLeaves[c++] = pC0->pLeaves[i++]; k++;
249  if ( i == nSizeC0 ) goto FlushCut1;
250  if ( k == nSizeC1 ) goto FlushCut0;
251  }
252  }
253 
254 FlushCut0:
255  if ( c + nSizeC0 > nLimit + i ) return 0;
256  while ( i < nSizeC0 )
257  {
258  p->pPerm[0][i] = c;
259  pC->pLeaves[c++] = pC0->pLeaves[i++];
260  }
261  pC->nLeaves = c;
262  pC->uSign = pC0->uSign | pC1->uSign;
263  assert( c > 0 );
264  return 1;
265 
266 FlushCut1:
267  if ( c + nSizeC1 > nLimit + k ) return 0;
268  while ( k < nSizeC1 )
269  {
270  p->pPerm[1][k] = c;
271  pC->pLeaves[c++] = pC1->pLeaves[k++];
272  }
273  pC->nLeaves = c;
274  pC->uSign = pC0->uSign | pC1->uSign;
275  assert( c > 0 );
276  return 1;
277 }
unsigned uSharedMask
Definition: if.h:210
static unsigned Abc_InfoMask(int nVar)
Definition: abc_global.h:261
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pPerm[3][IF_MAX_LUTSIZE]
Definition: if.h:209
int pLeaves[0]
Definition: if.h:290
unsigned uSign
Definition: if.h:283
#define assert(ex)
Definition: util_old.h:213
void If_CutOrder ( If_Cut_t pCut)

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

Synopsis [Orders the leaves of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 797 of file ifCut.c.

798 {
799  int i, Temp, fChanges;
800  do {
801  fChanges = 0;
802  for ( i = 0; i < (int)pCut->nLeaves - 1; i++ )
803  {
804  assert( pCut->pLeaves[i] != pCut->pLeaves[i+1] );
805  if ( pCut->pLeaves[i] <= pCut->pLeaves[i+1] )
806  continue;
807  Temp = pCut->pLeaves[i];
808  pCut->pLeaves[i] = pCut->pLeaves[i+1];
809  pCut->pLeaves[i+1] = Temp;
810  fChanges = 1;
811  }
812  } while ( fChanges );
813 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerDeref ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1234 of file ifCut.c.

1235 {
1236  If_Obj_t * pLeaf;
1237  float * pSwitching = (float *)p->vSwitching->pArray;
1238  float Power = 0;
1239  int i;
1240  If_CutForEachLeaf( p, pCut, pLeaf, i )
1241  {
1242  Power += pSwitching[pLeaf->Id];
1243  assert( pLeaf->nRefs > 0 );
1244  if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) )
1245  continue;
1246  Power += If_CutPowerDeref( p, If_ObjCutBest(pLeaf), pRoot );
1247  }
1248  return Power;
1249 }
int Id
Definition: if.h:316
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#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
Vec_Int_t * vSwitching
Definition: if.h:208
int nRefs
Definition: if.h:318
float If_CutPowerDeref(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1234
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerDerefed ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes Power of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1290 of file ifCut.c.

1291 {
1292  float aResult, aResult2;
1293  if ( pCut->nLeaves < 2 )
1294  return 0;
1295  aResult2 = If_CutPowerRef( p, pCut, pRoot );
1296  aResult = If_CutPowerDeref( p, pCut, pRoot );
1297  assert( aResult > aResult2 - p->fEpsilon );
1298  assert( aResult < aResult2 + p->fEpsilon );
1299  return aResult;
1300 }
unsigned nLeaves
Definition: if.h:289
float If_CutPowerDeref(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1234
float fEpsilon
Definition: if.h:195
float If_CutPowerRef(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1262
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerFlow ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area flow.]

Description []

SideEffects []

SeeAlso []

Definition at line 979 of file ifCut.c.

980 {
981  If_Obj_t * pLeaf;
982  float * pSwitching = (float *)p->vSwitching->pArray;
983  float Power = 0;
984  int i;
985  If_CutForEachLeaf( p, pCut, pLeaf, i )
986  {
987  Power += pSwitching[pLeaf->Id];
988  if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
989  Power += If_ObjCutBest(pLeaf)->Power;
990  else
991  {
992  assert( pLeaf->EstRefs > p->fEpsilon );
993  Power += If_ObjCutBest(pLeaf)->Power / pLeaf->EstRefs;
994  }
995  }
996  return Power;
997 }
int Id
Definition: if.h:316
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
Vec_Int_t * vSwitching
Definition: if.h:208
int nRefs
Definition: if.h:318
float Power
Definition: if.h:279
float fEpsilon
Definition: if.h:195
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerRef ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1262 of file ifCut.c.

1263 {
1264  If_Obj_t * pLeaf;
1265  float * pSwitching = (float *)p->vSwitching->pArray;
1266  float Power = 0;
1267  int i;
1268  If_CutForEachLeaf( p, pCut, pLeaf, i )
1269  {
1270  Power += pSwitching[pLeaf->Id];
1271  assert( pLeaf->nRefs >= 0 );
1272  if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) )
1273  continue;
1274  Power += If_CutPowerRef( p, If_ObjCutBest(pLeaf), pRoot );
1275  }
1276  return Power;
1277 }
int Id
Definition: if.h:316
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#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
Vec_Int_t * vSwitching
Definition: if.h:208
int nRefs
Definition: if.h:318
float If_CutPowerRef(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1262
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerRefed ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1313 of file ifCut.c.

1314 {
1315  float aResult, aResult2;
1316  if ( pCut->nLeaves < 2 )
1317  return 0;
1318  aResult2 = If_CutPowerDeref( p, pCut, pRoot );
1319  aResult = If_CutPowerRef( p, pCut, pRoot );
1320  assert( aResult > aResult2 - p->fEpsilon );
1321  assert( aResult < aResult2 + p->fEpsilon );
1322  return aResult;
1323 }
unsigned nLeaves
Definition: if.h:289
float If_CutPowerDeref(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1234
float fEpsilon
Definition: if.h:195
float If_CutPowerRef(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1262
#define assert(ex)
Definition: util_old.h:213
void If_CutPrint ( If_Cut_t pCut)

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

Synopsis [Prints one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 856 of file ifCut.c.

857 {
858  unsigned i;
859  Abc_Print( 1, "{" );
860  for ( i = 0; i < pCut->nLeaves; i++ )
861  Abc_Print( 1, " %s%d", If_CutLeafBit(pCut, i) ? "!":"", pCut->pLeaves[i] );
862  Abc_Print( 1, " }\n" );
863 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int If_CutLeafBit(If_Cut_t *pCut, int i)
Definition: if.h:396
void If_CutPrintTiming ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Prints one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 876 of file ifCut.c.

877 {
878  If_Obj_t * pLeaf;
879  unsigned i;
880  Abc_Print( 1, "{" );
881  If_CutForEachLeaf( p, pCut, pLeaf, i )
882  Abc_Print( 1, " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required );
883  Abc_Print( 1, " }\n" );
884 }
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
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void If_CutSort ( If_Man_t p,
If_Set_t pCutSet,
If_Cut_t pCut 
)

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

Synopsis [Performs incremental sorting of cuts.]

Description [Currently only the trivial sorting is implemented.]

SideEffects []

SeeAlso []

Definition at line 738 of file ifCut.c.

739 {
740 // int Counter = 0;
741  int i;
742 
743  // the new cut is the last one
744  assert( pCutSet->ppCuts[pCutSet->nCuts] == pCut );
745  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
746 
747  // cut structure is empty
748  if ( pCutSet->nCuts == 0 )
749  {
750  pCutSet->nCuts++;
751  return;
752  }
753 
754  if ( !pCut->fUseless &&
755  (p->pPars->fUseDsd || p->pPars->fUseBat ||
756  p->pPars->pLutStruct || p->pPars->fUserRecLib ||
757  p->pPars->fEnableCheck07 || p->pPars->fUseCofVars || p->pPars->fUseAndVars ||
759  {
760  If_Cut_t * pFirst = pCutSet->ppCuts[0];
761  if ( pFirst->fUseless || If_ManSortCompare(p, pFirst, pCut) == 1 )
762  {
763  pCutSet->ppCuts[0] = pCut;
764  pCutSet->ppCuts[pCutSet->nCuts] = pFirst;
765  If_CutSort( p, pCutSet, pFirst );
766  return;
767  }
768  }
769 
770  // the cut will be added - find its place
771  for ( i = pCutSet->nCuts-1; i >= 0; i-- )
772  {
773 // Counter++;
774  if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 || (i == 0 && !pCutSet->ppCuts[0]->fUseless && pCut->fUseless) )
775  break;
776  pCutSet->ppCuts[i+1] = pCutSet->ppCuts[i];
777  pCutSet->ppCuts[i] = pCut;
778  }
779 // Abc_Print( 1, "%d ", Counter );
780 
781  // update the number of cuts
782  if ( pCutSet->nCuts < pCutSet->nCutsMax )
783  pCutSet->nCuts++;
784 }
Definition: if.h:275
char * pLutStruct
Definition: if.h:141
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
int fUseCofVars
Definition: if.h:135
int fEnableCheck75u
Definition: if.h:132
int fEnableCheck75
Definition: if.h:131
int fEnableCheck07
Definition: if.h:128
int fUseAndVars
Definition: if.h:136
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
int fUseDsd
Definition: if.h:133
If_Par_t * pPars
Definition: if.h:184
short nCuts
Definition: if.h:297
int fUseDsdTune
Definition: if.h:134
int fUserRecLib
Definition: if.h:124
static int If_ManSortCompare(If_Man_t *p, If_Cut_t *pC0, If_Cut_t *pC1)
Definition: ifCut.c:502
int fUseBat
Definition: if.h:126
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
static ABC_NAMESPACE_IMPL_START int If_CutVerifyCut ( If_Cut_t pBase,
If_Cut_t pCut 
)
inlinestatic

DECLARATIONS ///.

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

FileName [ifCut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [Cut computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Check correctness of cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ifCut.c.

46 {
47  int nSizeB = pBase->nLeaves;
48  int nSizeC = pCut->nLeaves;
49  int * pB = pBase->pLeaves;
50  int * pC = pCut->pLeaves;
51  int i, k;
52  for ( i = 0; i < nSizeC; i++ )
53  {
54  for ( k = 0; k < nSizeB; k++ )
55  if ( pC[i] == pB[k] )
56  break;
57  if ( k == nSizeB )
58  return 0;
59  }
60  return 1;
61 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
int If_CutVerifyCuts ( If_Set_t pCutSet,
int  fOrdered 
)

Definition at line 62 of file ifCut.c.

63 {
64  static int Count = 0;
65  If_Cut_t * pCut0, * pCut1;
66  int i, k, m, n, Value;
67  assert( pCutSet->nCuts > 0 );
68  for ( i = 0; i < pCutSet->nCuts; i++ )
69  {
70  pCut0 = pCutSet->ppCuts[i];
71  assert( pCut0->uSign == If_ObjCutSignCompute(pCut0) );
72  if ( fOrdered )
73  {
74  // check duplicates
75  for ( m = 1; m < (int)pCut0->nLeaves; m++ )
76  assert( pCut0->pLeaves[m-1] < pCut0->pLeaves[m] );
77  }
78  else
79  {
80  // check duplicates
81  for ( m = 0; m < (int)pCut0->nLeaves; m++ )
82  for ( n = m+1; n < (int)pCut0->nLeaves; n++ )
83  assert( pCut0->pLeaves[m] != pCut0->pLeaves[n] );
84  }
85  // check pairs
86  for ( k = 0; k < pCutSet->nCuts; k++ )
87  {
88  pCut1 = pCutSet->ppCuts[k];
89  if ( pCut0 == pCut1 )
90  continue;
91  Count++;
92  // check containments
93  Value = If_CutVerifyCut( pCut0, pCut1 );
94 // assert( Value == 0 );
95  if ( Value )
96  {
97  assert( pCut0->uSign == If_ObjCutSignCompute(pCut0) );
98  assert( pCut1->uSign == If_ObjCutSignCompute(pCut1) );
99  If_CutPrint( pCut0 );
100  If_CutPrint( pCut1 );
101  assert( 0 );
102  }
103  }
104  }
105  return 1;
106 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
int pLeaves[0]
Definition: if.h:290
static ABC_NAMESPACE_IMPL_START int If_CutVerifyCut(If_Cut_t *pBase, If_Cut_t *pCut)
DECLARATIONS ///.
Definition: ifCut.c:45
static unsigned If_ObjCutSignCompute(If_Cut_t *p)
Definition: if.h:403
short nCuts
Definition: if.h:297
void If_CutPrint(If_Cut_t *pCut)
Definition: ifCut.c:856
unsigned uSign
Definition: if.h:283
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
static int If_ManSortCompare ( If_Man_t p,
If_Cut_t pC0,
If_Cut_t pC1 
)
inlinestatic

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

Synopsis [Comparison function for two cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 502 of file ifCut.c.

503 {
504  if ( p->pPars->fPower )
505  {
506  if ( p->SortMode == 1 ) // area flow
507  {
508  if ( pC0->Area < pC1->Area - p->fEpsilon )
509  return -1;
510  if ( pC0->Area > pC1->Area + p->fEpsilon )
511  return 1;
512  //Abc_Print( 1,"area(%.2f, %.2f), power(%.2f, %.2f), edge(%.2f, %.2f)\n",
513  // pC0->Area, pC1->Area, pC0->Power, pC1->Power, pC0->Edge, pC1->Edge);
514  if ( pC0->Power < pC1->Power - p->fEpsilon )
515  return -1;
516  if ( pC0->Power > pC1->Power + p->fEpsilon )
517  return 1;
518  if ( pC0->Edge < pC1->Edge - p->fEpsilon )
519  return -1;
520  if ( pC0->Edge > pC1->Edge + p->fEpsilon )
521  return 1;
522 // if ( pC0->AveRefs > pC1->AveRefs )
523 // return -1;
524 // if ( pC0->AveRefs < pC1->AveRefs )
525 // return 1;
526  if ( pC0->nLeaves < pC1->nLeaves )
527  return -1;
528  if ( pC0->nLeaves > pC1->nLeaves )
529  return 1;
530  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
531  return -1;
532  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
533  return 1;
534  return 0;
535  }
536  if ( p->SortMode == 0 ) // delay
537  {
538  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
539  return -1;
540  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
541  return 1;
542  if ( pC0->nLeaves < pC1->nLeaves )
543  return -1;
544  if ( pC0->nLeaves > pC1->nLeaves )
545  return 1;
546  if ( pC0->Area < pC1->Area - p->fEpsilon )
547  return -1;
548  if ( pC0->Area > pC1->Area + p->fEpsilon )
549  return 1;
550  if ( pC0->Power < pC1->Power - p->fEpsilon )
551  return -1;
552  if ( pC0->Power > pC1->Power + p->fEpsilon )
553  return 1;
554  if ( pC0->Edge < pC1->Edge - p->fEpsilon )
555  return -1;
556  if ( pC0->Edge > pC1->Edge + p->fEpsilon )
557  return 1;
558  return 0;
559  }
560  assert( p->SortMode == 2 ); // delay old, exact area
561  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
562  return -1;
563  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
564  return 1;
565  if ( pC0->Power < pC1->Power - p->fEpsilon )
566  return -1;
567  if ( pC0->Power > pC1->Power + p->fEpsilon )
568  return 1;
569  if ( pC0->Edge < pC1->Edge - p->fEpsilon )
570  return -1;
571  if ( pC0->Edge > pC1->Edge + p->fEpsilon )
572  return 1;
573  if ( pC0->Area < pC1->Area - p->fEpsilon )
574  return -1;
575  if ( pC0->Area > pC1->Area + p->fEpsilon )
576  return 1;
577  if ( pC0->nLeaves < pC1->nLeaves )
578  return -1;
579  if ( pC0->nLeaves > pC1->nLeaves )
580  return 1;
581  return 0;
582  }
583  else // regular
584  {
585  if ( p->SortMode == 1 ) // area
586  {
587  if ( pC0->Area < pC1->Area - p->fEpsilon )
588  return -1;
589  if ( pC0->Area > pC1->Area + p->fEpsilon )
590  return 1;
591  if ( pC0->Edge < pC1->Edge - p->fEpsilon )
592  return -1;
593  if ( pC0->Edge > pC1->Edge + p->fEpsilon )
594  return 1;
595  if ( pC0->Power < pC1->Power - p->fEpsilon )
596  return -1;
597  if ( pC0->Power > pC1->Power + p->fEpsilon )
598  return 1;
599 // if ( pC0->AveRefs > pC1->AveRefs )
600 // return -1;
601 // if ( pC0->AveRefs < pC1->AveRefs )
602 // return 1;
603  if ( pC0->nLeaves < pC1->nLeaves )
604  return -1;
605  if ( pC0->nLeaves > pC1->nLeaves )
606  return 1;
607  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
608  return -1;
609  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
610  return 1;
611  return 0;
612  }
613  if ( p->SortMode == 0 ) // delay
614  {
615  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
616  return -1;
617  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
618  return 1;
619  if ( pC0->nLeaves < pC1->nLeaves )
620  return -1;
621  if ( pC0->nLeaves > pC1->nLeaves )
622  return 1;
623  if ( pC0->Area < pC1->Area - p->fEpsilon )
624  return -1;
625  if ( pC0->Area > pC1->Area + p->fEpsilon )
626  return 1;
627  if ( pC0->Edge < pC1->Edge - p->fEpsilon )
628  return -1;
629  if ( pC0->Edge > pC1->Edge + p->fEpsilon )
630  return 1;
631  if ( pC0->Power < pC1->Power - p->fEpsilon )
632  return -1;
633  if ( pC0->Power > pC1->Power + p->fEpsilon )
634  return 1;
635  return 0;
636  }
637  assert( p->SortMode == 2 ); // delay old
638  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
639  return -1;
640  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
641  return 1;
642  if ( pC0->Area < pC1->Area - p->fEpsilon )
643  return -1;
644  if ( pC0->Area > pC1->Area + p->fEpsilon )
645  return 1;
646  if ( pC0->Edge < pC1->Edge - p->fEpsilon )
647  return -1;
648  if ( pC0->Edge > pC1->Edge + p->fEpsilon )
649  return 1;
650  if ( pC0->Power < pC1->Power - p->fEpsilon )
651  return -1;
652  if ( pC0->Power > pC1->Power + p->fEpsilon )
653  return 1;
654  if ( pC0->nLeaves < pC1->nLeaves )
655  return -1;
656  if ( pC0->nLeaves > pC1->nLeaves )
657  return 1;
658  return 0;
659  }
660 }
unsigned nLeaves
Definition: if.h:289
float Edge
Definition: if.h:278
float Power
Definition: if.h:279
float fEpsilon
Definition: if.h:195
If_Par_t * pPars
Definition: if.h:184
int fPower
Definition: if.h:119
#define assert(ex)
Definition: util_old.h:213
int SortMode
Definition: if.h:205
float Delay
Definition: if.h:280
float Area
Definition: if.h:277
static int If_ManSortCompare_old ( If_Man_t p,
If_Cut_t pC0,
If_Cut_t pC1 
)
inlinestatic

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

Synopsis [Comparison function for two cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 673 of file ifCut.c.

674 {
675  if ( p->SortMode == 1 ) // area
676  {
677  if ( pC0->Area < pC1->Area - p->fEpsilon )
678  return -1;
679  if ( pC0->Area > pC1->Area + p->fEpsilon )
680  return 1;
681 // if ( pC0->AveRefs > pC1->AveRefs )
682 // return -1;
683 // if ( pC0->AveRefs < pC1->AveRefs )
684 // return 1;
685  if ( pC0->nLeaves < pC1->nLeaves )
686  return -1;
687  if ( pC0->nLeaves > pC1->nLeaves )
688  return 1;
689  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
690  return -1;
691  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
692  return 1;
693  return 0;
694  }
695  if ( p->SortMode == 0 ) // delay
696  {
697  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
698  return -1;
699  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
700  return 1;
701  if ( pC0->nLeaves < pC1->nLeaves )
702  return -1;
703  if ( pC0->nLeaves > pC1->nLeaves )
704  return 1;
705  if ( pC0->Area < pC1->Area - p->fEpsilon )
706  return -1;
707  if ( pC0->Area > pC1->Area + p->fEpsilon )
708  return 1;
709  return 0;
710  }
711  assert( p->SortMode == 2 ); // delay old
712  if ( pC0->Delay < pC1->Delay - p->fEpsilon )
713  return -1;
714  if ( pC0->Delay > pC1->Delay + p->fEpsilon )
715  return 1;
716  if ( pC0->Area < pC1->Area - p->fEpsilon )
717  return -1;
718  if ( pC0->Area > pC1->Area + p->fEpsilon )
719  return 1;
720  if ( pC0->nLeaves < pC1->nLeaves )
721  return -1;
722  if ( pC0->nLeaves > pC1->nLeaves )
723  return 1;
724  return 0;
725 }
unsigned nLeaves
Definition: if.h:289
float fEpsilon
Definition: if.h:195
#define assert(ex)
Definition: util_old.h:213
int SortMode
Definition: if.h:205
float Delay
Definition: if.h:280
float Area
Definition: if.h:277