abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaMf.c File Reference
#include "gia.h"
#include "misc/vec/vecMem.h"
#include "misc/util/utilTruth.h"
#include "misc/extra/extra.h"
#include "sat/cnf/cnf.h"
#include "opt/dau/dau.h"

Go to the source code of this file.

Data Structures

struct  Mf_Cut_t_
 
struct  Mf_Obj_t_
 
struct  Mf_Man_t_
 

Macros

#define MF_LEAF_MAX   10
 DECLARATIONS ///. More...
 
#define MF_CUT_MAX   16
 
#define MF_LOG_PAGE   12
 
#define MF_NO_LEAF   31
 
#define MF_TT_WORDS   ((MF_LEAF_MAX > 6) ? 1 << (MF_LEAF_MAX-6) : 1)
 
#define MF_NO_FUNC   134217727
 
#define Mf_SetForEachCut(pList, pCut, i)   for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Mf_CutSize(pCut) + 1 )
 
#define Mf_ObjForEachCut(pCuts, i, nCuts)   for ( i = 0, i < nCuts; i++ )
 

Typedefs

typedef struct Mf_Cut_t_ Mf_Cut_t
 
typedef struct Mf_Obj_t_ Mf_Obj_t
 
typedef struct Mf_Man_t_ Mf_Man_t
 

Functions

static Mf_Obj_tMf_ManObj (Mf_Man_t *p, int i)
 
static int * Mf_ManCutSet (Mf_Man_t *p, int i)
 
static int * Mf_ObjCutSet (Mf_Man_t *p, int i)
 
static int * Mf_ObjCutBest (Mf_Man_t *p, int i)
 
static int Mf_ObjMapRefNum (Mf_Man_t *p, int i)
 
static int Mf_ObjMapRefInc (Mf_Man_t *p, int i)
 
static int Mf_ObjMapRefDec (Mf_Man_t *p, int i)
 
static int Mf_CutSize (int *pCut)
 
static int Mf_CutFunc (int *pCut)
 
static int Mf_CutSetBoth (int n, int f)
 
static int Mf_CutIsTriv (int *pCut, int i)
 
int Kit_TruthToGia (Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
 DECLARATIONS ///. More...
 
int Mf_ManTruthCanonicize (word *t, int nVars)
 
void Mf_ManTruthQuit ()
 
Vec_Wrd_tMf_ManTruthCollect (int Limit)
 
int Mf_ManTruthCount ()
 
void Mf_ManProfileTruths (Mf_Man_t *p)
 
static int Mf_CubeLit (int Cube, int iVar)
 
static int Mf_ManCountLits (int *pCnf, int nCubes, int nVars)
 
Vec_Int_tMf_ManDeriveCnfs (Mf_Man_t *p, int *pnVars, int *pnClas, int *pnLits)
 
Cnf_Dat_tMf_ManDeriveCnf (Mf_Man_t *p, int fCnfObjIds, int fAddOrCla)
 
static int Mf_CutComputeTruth6 (Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, int fCompl0, int fCompl1, Mf_Cut_t *pCutR, int fIsXor)
 
static int Mf_CutComputeTruth (Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, int fCompl0, int fCompl1, Mf_Cut_t *pCutR, int fIsXor)
 
static int Mf_CutComputeTruthMux6 (Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, Mf_Cut_t *pCutR)
 
static int Mf_CutComputeTruthMux (Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, Mf_Cut_t *pCutR)
 
static int Mf_CutCountBits (word i)
 
static word Mf_CutGetSign (int *pLeaves, int nLeaves)
 
static int Mf_CutCreateUnit (Mf_Cut_t *p, int i)
 
static void Mf_CutPrint (Mf_Man_t *p, Mf_Cut_t *pCut)
 
static int Mf_ManPrepareCuts (Mf_Cut_t *pCuts, Mf_Man_t *p, int iObj, int fAddUnit)
 
static int Mf_ManSaveCuts (Mf_Man_t *p, Mf_Cut_t **pCuts, int nCuts)
 
static void Mf_ObjSetBestCut (int *pCuts, int *pCut)
 
static int Mf_CutCheck (Mf_Cut_t *pBase, Mf_Cut_t *pCut)
 
static int Mf_SetCheckArray (Mf_Cut_t **ppCuts, int nCuts)
 
static int Mf_CutMergeOrder (Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCut, int nLutSize)
 
static int Mf_CutMergeOrderMux (Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCut2, Mf_Cut_t *pCut, int nLutSize)
 
static int Mf_SetCutIsContainedOrder (Mf_Cut_t *pBase, Mf_Cut_t *pCut)
 
static int Mf_SetLastCutIsContained (Mf_Cut_t **pCuts, int nCuts)
 
static int Mf_SetLastCutContainsArea (Mf_Cut_t **pCuts, int nCuts)
 
static int Mf_CutCompareArea (Mf_Cut_t *pCut0, Mf_Cut_t *pCut1)
 
static void Mf_SetSortByArea (Mf_Cut_t **pCuts, int nCuts)
 
static int Mf_SetAddCut (Mf_Cut_t **pCuts, int nCuts, int nCutNum)
 
static int Mf_CutArea (Mf_Man_t *p, int nLeaves, int iFunc)
 
static void Mf_CutParams (Mf_Man_t *p, Mf_Cut_t *pCut, float FlowRefs)
 
void Mf_ObjMergeOrder (Mf_Man_t *p, int iObj)
 
void Mf_ManSetFlowRefs (Gia_Man_t *p, Vec_Int_t *vRefs)
 
int Mf_ManSetMapRefs (Mf_Man_t *p)
 
Gia_Man_tMf_ManDeriveMapping (Mf_Man_t *p)
 
Gia_Man_tMf_ManDeriveMappingCoarse (Mf_Man_t *p)
 
Gia_Man_tMf_ManDeriveMappingGia (Mf_Man_t *p)
 
Mf_Man_tMf_ManAlloc (Gia_Man_t *pGia, Jf_Par_t *pPars)
 
void Mf_ManFree (Mf_Man_t *p)
 
void Mf_ManSetDefaultPars (Jf_Par_t *pPars)
 
void Mf_ManPrintStats (Mf_Man_t *p, char *pTitle)
 
void Mf_ManPrintInit (Mf_Man_t *p)
 
void Mf_ManPrintQuit (Mf_Man_t *p, Gia_Man_t *pNew)
 
void Mf_ManComputeCuts (Mf_Man_t *p)
 
int Mf_CutRef_rec (Mf_Man_t *p, int *pCut)
 
int Mf_CutDeref_rec (Mf_Man_t *p, int *pCut)
 
static int Mf_CutAreaDerefed (Mf_Man_t *p, int *pCut)
 
static float Mf_CutFlow (Mf_Man_t *p, int *pCut, int *pTime)
 
static void Mf_ObjComputeBestCut (Mf_Man_t *p, int iObj)
 
void Mf_ManComputeMapping (Mf_Man_t *p)
 
Gia_Man_tMf_ManPerformMapping (Gia_Man_t *pGia, Jf_Par_t *pPars)
 
Cnf_Dat_tMf_ManGenerateCnf (Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose)
 
void Mf_ManDumpCnf (Gia_Man_t *p, char *pFileName, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose)
 

Variables

static int s_nCalls = 0
 FUNCTION DEFINITIONS ///. More...
 
static Vec_Mem_ts_vTtMem = NULL
 

Macro Definition Documentation

#define MF_CUT_MAX   16

Definition at line 35 of file giaMf.c.

#define MF_LEAF_MAX   10

DECLARATIONS ///.

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

FileName [giaMf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Cut computation.]

Author [Alan Mishchenko]`

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaMf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 34 of file giaMf.c.

#define MF_LOG_PAGE   12

Definition at line 36 of file giaMf.c.

#define MF_NO_FUNC   134217727

Definition at line 39 of file giaMf.c.

#define MF_NO_LEAF   31

Definition at line 37 of file giaMf.c.

#define Mf_ObjForEachCut (   pCuts,
  i,
  nCuts 
)    for ( i = 0, i < nCuts; i++ )

Definition at line 97 of file giaMf.c.

#define Mf_SetForEachCut (   pList,
  pCut,
 
)    for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Mf_CutSize(pCut) + 1 )

Definition at line 96 of file giaMf.c.

#define MF_TT_WORDS   ((MF_LEAF_MAX > 6) ? 1 << (MF_LEAF_MAX-6) : 1)

Definition at line 38 of file giaMf.c.

Typedef Documentation

typedef struct Mf_Cut_t_ Mf_Cut_t

Definition at line 41 of file giaMf.c.

typedef struct Mf_Man_t_ Mf_Man_t

Definition at line 60 of file giaMf.c.

typedef struct Mf_Obj_t_ Mf_Obj_t

Definition at line 51 of file giaMf.c.

Function Documentation

int Kit_TruthToGia ( Gia_Man_t pMan,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vMemory,
Vec_Int_t vLeaves,
int  fHash 
)

DECLARATIONS ///.

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

FileName [giaMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Manipulation of mapping associated with the AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaMap.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 80 of file kitHop.c.

81 {
82  int iLit;
83  Kit_Graph_t * pGraph;
84  // transform truth table into the decomposition tree
85  if ( vMemory == NULL )
86  {
87  vMemory = Vec_IntAlloc( 0 );
88  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
89  Vec_IntFree( vMemory );
90  }
91  else
92  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
93  if ( pGraph == NULL )
94  {
95  printf( "Kit_TruthToGia(): Converting truth table to AIG has failed for function:\n" );
96  Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
97  }
98  // derive the AIG for the decomposition tree
99  iLit = Kit_GraphToGia( pMan, pGraph, vLeaves, fHash );
100  Kit_GraphFree( pGraph );
101  return iLit;
102 }
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
int Kit_GraphToGia(Gia_Man_t *pMan, Kit_Graph_t *pGraph, Vec_Int_t *vLeaves, int fHash)
Definition: kitHop.c:70
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitGraph.c:355
static int Mf_CubeLit ( int  Cube,
int  iVar 
)
inlinestatic

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

Synopsis [Derives CNFs for each function used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file giaMf.c.

250 { return (Cube >> (iVar << 1)) & 3; }
static int Mf_CutArea ( Mf_Man_t p,
int  nLeaves,
int  iFunc 
)
inlinestatic

Definition at line 940 of file giaMf.c.

941 {
942  if ( nLeaves < 2 )
943  return 0;
944  if ( p->pPars->fGenCnf )
945  return Vec_IntEntry(&p->vCnfSizes, Abc_Lit2Var(iFunc));
946  if ( p->pPars->fOptEdge )
947  return nLeaves + p->pPars->nAreaTuner;
948  return 1;
949 }
Jf_Par_t * pPars
Definition: giaMf.c:66
int nAreaTuner
Definition: gia.h:274
int fOptEdge
Definition: gia.h:278
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int fGenCnf
Definition: gia.h:284
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
static int Mf_CutAreaDerefed ( Mf_Man_t p,
int *  pCut 
)
inlinestatic

Definition at line 1502 of file giaMf.c.

1503 {
1504  int Ela1 = Mf_CutRef_rec( p, pCut );
1505  int Ela2 = Mf_CutDeref_rec( p, pCut );
1506  assert( Ela1 == Ela2 );
1507  return Ela1;
1508 }
int Mf_CutDeref_rec(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1494
int Mf_CutRef_rec(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1486
#define assert(ex)
Definition: util_old.h:213
static int Mf_CutCheck ( Mf_Cut_t pBase,
Mf_Cut_t pCut 
)
inlinestatic

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

Synopsis [Check correctness of cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 717 of file giaMf.c.

718 {
719  int nSizeB = pBase->nLeaves;
720  int nSizeC = pCut->nLeaves;
721  int i, * pB = pBase->pLeaves;
722  int k, * pC = pCut->pLeaves;
723  for ( i = 0; i < nSizeC; i++ )
724  {
725  for ( k = 0; k < nSizeB; k++ )
726  if ( pC[i] == pB[k] )
727  break;
728  if ( k == nSizeB )
729  return 0;
730  }
731  return 1;
732 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
unsigned nLeaves
Definition: giaMf.c:48
static int Mf_CutCompareArea ( Mf_Cut_t pCut0,
Mf_Cut_t pCut1 
)
inlinestatic

Definition at line 912 of file giaMf.c.

913 {
914  if ( pCut0->Flow < pCut1->Flow ) return -1;
915  if ( pCut0->Flow > pCut1->Flow ) return 1;
916  if ( pCut0->Delay < pCut1->Delay ) return -1;
917  if ( pCut0->Delay > pCut1->Delay ) return 1;
918  if ( pCut0->nLeaves < pCut1->nLeaves ) return -1;
919  if ( pCut0->nLeaves > pCut1->nLeaves ) return 1;
920  return 0;
921 }
float Flow
Definition: giaMf.c:46
int Delay
Definition: giaMf.c:45
unsigned nLeaves
Definition: giaMf.c:48
static int Mf_CutComputeTruth ( Mf_Man_t p,
Mf_Cut_t pCut0,
Mf_Cut_t pCut1,
int  fCompl0,
int  fCompl1,
Mf_Cut_t pCutR,
int  fIsXor 
)
inlinestatic

Definition at line 510 of file giaMf.c.

511 {
512  if ( p->pPars->nLutSize <= 6 )
513  return Mf_CutComputeTruth6( p, pCut0, pCut1, fCompl0, fCompl1, pCutR, fIsXor );
514  {
515  word uTruth[MF_TT_WORDS], uTruth0[MF_TT_WORDS], uTruth1[MF_TT_WORDS];
516  int nOldSupp = pCutR->nLeaves, truthId;
517  int LutSize = p->pPars->nLutSize, fCompl;
518  int nWords = Abc_Truth6WordNum(LutSize);
519  word * pTruth0 = Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
520  word * pTruth1 = Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
521  Abc_TtCopy( uTruth0, pTruth0, nWords, Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 );
522  Abc_TtCopy( uTruth1, pTruth1, nWords, Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 );
523  Abc_TtExpand( uTruth0, LutSize, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
524  Abc_TtExpand( uTruth1, LutSize, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
525  if ( fIsXor )
526  Abc_TtXor( uTruth, uTruth0, uTruth1, nWords, (fCompl = (int)((uTruth0[0] ^ uTruth1[0]) & 1)) );
527  else
528  Abc_TtAnd( uTruth, uTruth0, uTruth1, nWords, (fCompl = (int)((uTruth0[0] & uTruth1[0]) & 1)) );
529  pCutR->nLeaves = Abc_TtMinBase( uTruth, pCutR->pLeaves, pCutR->nLeaves, LutSize );
530  assert( (uTruth[0] & 1) == 0 );
531 //Kit_DsdPrintFromTruth( uTruth, pCutR->nLeaves ), printf("\n" ), printf("\n" );
532  truthId = Vec_MemHashInsert(p->vTtMem, uTruth);
533  pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
534  if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) && LutSize <= 8 )
535  Vec_IntPush( &p->vCnfSizes, Abc_Tt8CnfSize(uTruth, pCutR->nLeaves) );
536  assert( (int)pCutR->nLeaves <= nOldSupp );
537  return (int)pCutR->nLeaves < nOldSupp;
538  }
539 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
int nLutSize
Definition: gia.h:267
static int Abc_TtMinBase(word *pTruth, int *pVars, int nVars, int nVarsAll)
Definition: utilTruth.h:1395
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
#define MF_TT_WORDS
Definition: giaMf.c:38
int nWords
Definition: abcNpn.c:127
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_Tt8CnfSize(word t[4], int nVars)
Definition: utilTruth.h:1817
unsigned iFunc
Definition: giaMf.c:47
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Abc_TtExpand(word *pTruth0, int nVars, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1360
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
unsigned nLeaves
Definition: giaMf.c:48
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
static void Abc_TtAnd(word *pOut, word *pIn1, word *pIn2, int nWords, int fCompl)
Definition: utilTruth.h:231
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
static void Abc_TtXor(word *pOut, word *pIn1, word *pIn2, int nWords, int fCompl)
Definition: utilTruth.h:253
static int Mf_CutComputeTruth6(Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, int fCompl0, int fCompl1, Mf_Cut_t *pCutR, int fIsXor)
Definition: giaMf.c:487
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
static int Mf_CutComputeTruth6 ( Mf_Man_t p,
Mf_Cut_t pCut0,
Mf_Cut_t pCut1,
int  fCompl0,
int  fCompl1,
Mf_Cut_t pCutR,
int  fIsXor 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 487 of file giaMf.c.

488 {
489 // extern int Mf_ManTruthCanonicize( word * t, int nVars );
490  int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
491  word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
492  word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
493  if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
494  if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
495  t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
496  t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
497  t = fIsXor ? t0 ^ t1 : t0 & t1;
498  if ( (fCompl = (int)(t & 1)) ) t = ~t;
499  pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
500  assert( (int)(t & 1) == 0 );
501  truthId = Vec_MemHashInsert(p->vTtMem, &t);
502  pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
503  if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) )
504  Vec_IntPush( &p->vCnfSizes, Abc_Tt6CnfSize(t, pCutR->nLeaves) );
505 // p->nCutMux += Mf_ManTtIsMux( t );
506  assert( (int)pCutR->nLeaves <= nOldSupp );
507 // Mf_ManTruthCanonicize( &t, pCutR->nLeaves );
508  return (int)pCutR->nLeaves < nOldSupp;
509 }
static word Abc_Tt6Expand(word t, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1345
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Abc_Tt6CnfSize(word t, int nVars)
Definition: utilTruth.h:1809
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Abc_Tt6MinBase(word *pTruth, int *pVars, int nVars)
Definition: utilTruth.h:1374
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
unsigned iFunc
Definition: giaMf.c:47
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
unsigned nLeaves
Definition: giaMf.c:48
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
static int Mf_CutComputeTruthMux ( Mf_Man_t p,
Mf_Cut_t pCut0,
Mf_Cut_t pCut1,
Mf_Cut_t pCutC,
int  fCompl0,
int  fCompl1,
int  fComplC,
Mf_Cut_t pCutR 
)
inlinestatic

Definition at line 563 of file giaMf.c.

564 {
565  if ( p->pPars->nLutSize <= 6 )
566  return Mf_CutComputeTruthMux6( p, pCut0, pCut1, pCutC, fCompl0, fCompl1, fComplC, pCutR );
567  {
568  word uTruth[MF_TT_WORDS], uTruth0[MF_TT_WORDS], uTruth1[MF_TT_WORDS], uTruthC[MF_TT_WORDS];
569  int nOldSupp = pCutR->nLeaves, truthId;
570  int LutSize = p->pPars->nLutSize, fCompl;
571  int nWords = Abc_Truth6WordNum(LutSize);
572  word * pTruth0 = Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
573  word * pTruth1 = Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
574  word * pTruthC = Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCutC->iFunc));
575  Abc_TtCopy( uTruth0, pTruth0, nWords, Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 );
576  Abc_TtCopy( uTruth1, pTruth1, nWords, Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 );
577  Abc_TtCopy( uTruthC, pTruthC, nWords, Abc_LitIsCompl(pCutC->iFunc) ^ fComplC );
578  Abc_TtExpand( uTruth0, LutSize, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
579  Abc_TtExpand( uTruth1, LutSize, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
580  Abc_TtExpand( uTruthC, LutSize, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
581  Abc_TtMux( uTruth, uTruthC, uTruth1, uTruth0, nWords );
582  fCompl = (int)(uTruth[0] & 1);
583  if ( fCompl ) Abc_TtNot( uTruth, nWords );
584  pCutR->nLeaves = Abc_TtMinBase( uTruth, pCutR->pLeaves, pCutR->nLeaves, LutSize );
585  assert( (uTruth[0] & 1) == 0 );
586  truthId = Vec_MemHashInsert(p->vTtMem, uTruth);
587  pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
588  if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) && LutSize <= 8 )
589  Vec_IntPush( &p->vCnfSizes, Abc_Tt8CnfSize(uTruth, pCutR->nLeaves) );
590  assert( (int)pCutR->nLeaves <= nOldSupp );
591  return (int)pCutR->nLeaves < nOldSupp;
592  }
593 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
int nLutSize
Definition: gia.h:267
static int Abc_TtMinBase(word *pTruth, int *pVars, int nVars, int nVarsAll)
Definition: utilTruth.h:1395
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Mf_CutComputeTruthMux6(Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, Mf_Cut_t *pCutR)
Definition: giaMf.c:540
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
#define MF_TT_WORDS
Definition: giaMf.c:38
int nWords
Definition: abcNpn.c:127
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_Tt8CnfSize(word t[4], int nVars)
Definition: utilTruth.h:1817
unsigned iFunc
Definition: giaMf.c:47
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Abc_TtExpand(word *pTruth0, int nVars, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1360
static void Abc_TtMux(word *pOut, word *pCtrl, word *pIn1, word *pIn0, int nWords)
Definition: utilTruth.h:263
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
unsigned nLeaves
Definition: giaMf.c:48
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
static void Abc_TtNot(word *pOut, int nWords)
Definition: utilTruth.h:215
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
static int Mf_CutComputeTruthMux6 ( Mf_Man_t p,
Mf_Cut_t pCut0,
Mf_Cut_t pCut1,
Mf_Cut_t pCutC,
int  fCompl0,
int  fCompl1,
int  fComplC,
Mf_Cut_t pCutR 
)
inlinestatic

Definition at line 540 of file giaMf.c.

541 {
542  int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
543  word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
544  word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
545  word tC = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCutC->iFunc));
546  if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
547  if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
548  if ( Abc_LitIsCompl(pCutC->iFunc) ^ fComplC ) tC = ~tC;
549  t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
550  t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
551  tC = Abc_Tt6Expand( tC, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
552  t = (tC & t1) | (~tC & t0);
553  if ( (fCompl = (int)(t & 1)) ) t = ~t;
554  pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
555  assert( (int)(t & 1) == 0 );
556  truthId = Vec_MemHashInsert(p->vTtMem, &t);
557  pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
558  if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) )
559  Vec_IntPush( &p->vCnfSizes, Abc_Tt6CnfSize(t, pCutR->nLeaves) );
560  assert( (int)pCutR->nLeaves <= nOldSupp );
561  return (int)pCutR->nLeaves < nOldSupp;
562 }
static word Abc_Tt6Expand(word t, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1345
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Abc_Tt6CnfSize(word t, int nVars)
Definition: utilTruth.h:1809
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Abc_Tt6MinBase(word *pTruth, int *pVars, int nVars)
Definition: utilTruth.h:1374
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
unsigned iFunc
Definition: giaMf.c:47
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
unsigned nLeaves
Definition: giaMf.c:48
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
static int Mf_CutCountBits ( word  i)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 607 of file giaMf.c.

608 {
609  i = i - ((i >> 1) & 0x5555555555555555);
610  i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
611  i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
612  return (i*(0x0101010101010101))>>56;
613 }
static int Mf_CutCreateUnit ( Mf_Cut_t p,
int  i 
)
inlinestatic

Definition at line 621 of file giaMf.c.

622 {
623  p->Delay = 0;
624  p->Flow = 0;
625  p->iFunc = 2;
626  p->nLeaves = 1;
627  p->pLeaves[0] = i;
628  p->Sign = ((word)1) << (i & 0x3F);
629  return 1;
630 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
float Flow
Definition: giaMf.c:46
word Sign
Definition: giaMf.c:44
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
unsigned iFunc
Definition: giaMf.c:47
int Delay
Definition: giaMf.c:45
unsigned nLeaves
Definition: giaMf.c:48
int Mf_CutDeref_rec ( Mf_Man_t p,
int *  pCut 
)

Definition at line 1494 of file giaMf.c.

1495 {
1496  int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1497  for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1498  if ( !Mf_ObjMapRefDec(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
1499  Count += Mf_CutDeref_rec( p, Mf_ObjCutBest(p, pCut[i]) );
1500  return Count;
1501 }
int Mf_CutDeref_rec(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1494
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
static int Mf_CutArea(Mf_Man_t *p, int nLeaves, int iFunc)
Definition: giaMf.c:940
static int Mf_ObjMapRefDec(Mf_Man_t *p, int i)
Definition: giaMf.c:89
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
int iCutSet
Definition: giaMf.c:54
static float Mf_CutFlow ( Mf_Man_t p,
int *  pCut,
int *  pTime 
)
inlinestatic

Definition at line 1509 of file giaMf.c.

1510 {
1511  Mf_Obj_t * pObj;
1512  float Flow = 0;
1513  int i, Time = 0;
1514  for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1515  {
1516  pObj = Mf_ManObj( p, pCut[i] );
1517  Time = Abc_MaxInt( Time, pObj->Delay );
1518  Flow += pObj->Flow;
1519  }
1520  *pTime = Time + 1;
1521  return Flow + Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1522 }
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
float Flow
Definition: giaMf.c:55
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Mf_CutArea(Mf_Man_t *p, int nLeaves, int iFunc)
Definition: giaMf.c:940
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
unsigned Delay
Definition: giaMf.c:57
static int Mf_CutFunc ( int *  pCut)
inlinestatic

Definition at line 92 of file giaMf.c.

92 { return ((unsigned)pCut[0] >> 5); }
static word Mf_CutGetSign ( int *  pLeaves,
int  nLeaves 
)
inlinestatic

Definition at line 614 of file giaMf.c.

615 {
616  word Sign = 0; int i;
617  for ( i = 0; i < nLeaves; i++ )
618  Sign |= ((word)1) << (pLeaves[i] & 0x3F);
619  return Sign;
620 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Mf_CutIsTriv ( int *  pCut,
int  i 
)
inlinestatic

Definition at line 94 of file giaMf.c.

94 { return Mf_CutSize(pCut) == 1 && pCut[1] == i; }
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
static int Mf_CutMergeOrder ( Mf_Cut_t pCut0,
Mf_Cut_t pCut1,
Mf_Cut_t pCut,
int  nLutSize 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 773 of file giaMf.c.

774 {
775  int nSize0 = pCut0->nLeaves;
776  int nSize1 = pCut1->nLeaves;
777  int i, * pC0 = pCut0->pLeaves;
778  int k, * pC1 = pCut1->pLeaves;
779  int c, * pC = pCut->pLeaves;
780  // the case of the largest cut sizes
781  if ( nSize0 == nLutSize && nSize1 == nLutSize )
782  {
783  for ( i = 0; i < nSize0; i++ )
784  {
785  if ( pC0[i] != pC1[i] ) return 0;
786  pC[i] = pC0[i];
787  }
788  pCut->nLeaves = nLutSize;
789  pCut->iFunc = MF_NO_FUNC;
790  pCut->Sign = pCut0->Sign | pCut1->Sign;
791  return 1;
792  }
793  // compare two cuts with different numbers
794  i = k = c = 0;
795  if ( nSize0 == 0 ) goto FlushCut1;
796  if ( nSize1 == 0 ) goto FlushCut0;
797  while ( 1 )
798  {
799  if ( c == nLutSize ) return 0;
800  if ( pC0[i] < pC1[k] )
801  {
802  pC[c++] = pC0[i++];
803  if ( i >= nSize0 ) goto FlushCut1;
804  }
805  else if ( pC0[i] > pC1[k] )
806  {
807  pC[c++] = pC1[k++];
808  if ( k >= nSize1 ) goto FlushCut0;
809  }
810  else
811  {
812  pC[c++] = pC0[i++]; k++;
813  if ( i >= nSize0 ) goto FlushCut1;
814  if ( k >= nSize1 ) goto FlushCut0;
815  }
816  }
817 
818 FlushCut0:
819  if ( c + nSize0 > nLutSize + i ) return 0;
820  while ( i < nSize0 )
821  pC[c++] = pC0[i++];
822  pCut->nLeaves = c;
823  pCut->iFunc = MF_NO_FUNC;
824  pCut->Sign = pCut0->Sign | pCut1->Sign;
825  return 1;
826 
827 FlushCut1:
828  if ( c + nSize1 > nLutSize + k ) return 0;
829  while ( k < nSize1 )
830  pC[c++] = pC1[k++];
831  pCut->nLeaves = c;
832  pCut->iFunc = MF_NO_FUNC;
833  pCut->Sign = pCut0->Sign | pCut1->Sign;
834  return 1;
835 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
word Sign
Definition: giaMf.c:44
unsigned iFunc
Definition: giaMf.c:47
#define MF_NO_FUNC
Definition: giaMf.c:39
unsigned nLeaves
Definition: giaMf.c:48
static int Mf_CutMergeOrderMux ( Mf_Cut_t pCut0,
Mf_Cut_t pCut1,
Mf_Cut_t pCut2,
Mf_Cut_t pCut,
int  nLutSize 
)
inlinestatic

Definition at line 836 of file giaMf.c.

837 {
838  int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
839  int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
840  int x2, i2 = 0, nSize2 = pCut2->nLeaves, * pC2 = pCut2->pLeaves;
841  int xMin, c = 0, * pC = pCut->pLeaves;
842  while ( 1 )
843  {
844  x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
845  x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
846  x2 = (i2 == nSize2) ? ABC_INFINITY : pC2[i2];
847  xMin = Abc_MinInt( Abc_MinInt(x0, x1), x2 );
848  if ( xMin == ABC_INFINITY ) break;
849  if ( c == nLutSize ) return 0;
850  pC[c++] = xMin;
851  if (x0 == xMin) i0++;
852  if (x1 == xMin) i1++;
853  if (x2 == xMin) i2++;
854  }
855  pCut->nLeaves = c;
856  pCut->iFunc = MF_NO_FUNC;
857  pCut->Sign = pCut0->Sign | pCut1->Sign | pCut2->Sign;
858  return 1;
859 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
word Sign
Definition: giaMf.c:44
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
unsigned iFunc
Definition: giaMf.c:47
#define MF_NO_FUNC
Definition: giaMf.c:39
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
unsigned nLeaves
Definition: giaMf.c:48
static void Mf_CutParams ( Mf_Man_t p,
Mf_Cut_t pCut,
float  FlowRefs 
)
inlinestatic

Definition at line 950 of file giaMf.c.

951 {
952  Mf_Obj_t * pBest;
953  int i, nLeaves = pCut->nLeaves;
954  assert( nLeaves <= p->pPars->nLutSize );
955  pCut->Delay = 0;
956  pCut->Flow = 0;
957  for ( i = 0; i < nLeaves; i++ )
958  {
959  pBest = Mf_ManObj(p, pCut->pLeaves[i]);
960  pCut->Delay = Abc_MaxInt( pCut->Delay, pBest->Delay );
961  pCut->Flow += pBest->Flow;
962  }
963  pCut->Delay += (int)(nLeaves > 1);
964  pCut->Flow = (pCut->Flow + Mf_CutArea(p, nLeaves, pCut->iFunc)) / FlowRefs;
965 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
float Flow
Definition: giaMf.c:46
float Flow
Definition: giaMf.c:55
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Mf_CutArea(Mf_Man_t *p, int nLeaves, int iFunc)
Definition: giaMf.c:940
unsigned iFunc
Definition: giaMf.c:47
int Delay
Definition: giaMf.c:45
unsigned nLeaves
Definition: giaMf.c:48
#define assert(ex)
Definition: util_old.h:213
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
unsigned Delay
Definition: giaMf.c:57
static void Mf_CutPrint ( Mf_Man_t p,
Mf_Cut_t pCut 
)
inlinestatic

Definition at line 631 of file giaMf.c.

632 {
633  int i, nDigits = Abc_Base10Log(Gia_ManObjNum(p->pGia));
634  printf( "%d {", pCut->nLeaves );
635  for ( i = 0; i < (int)pCut->nLeaves; i++ )
636  printf( " %*d", nDigits, pCut->pLeaves[i] );
637  for ( ; i < (int)p->pPars->nLutSize; i++ )
638  printf( " %*s", nDigits, " " );
639  printf( " } D = %4d A = %9.4f F = %6d ",
640  pCut->Delay, pCut->Flow, pCut->iFunc );
641  if ( p->vTtMem )
642  {
643  if ( p->pPars->fGenCnf )
644  printf( "CNF = %2d ", Vec_IntEntry(&p->vCnfSizes, Abc_Lit2Var(pCut->iFunc)) );
646  }
647  else
648  printf( "\n" );
649 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
int nLutSize
Definition: gia.h:267
float Flow
Definition: giaMf.c:46
Jf_Par_t * pPars
Definition: giaMf.c:66
Gia_Man_t * pGia
Definition: giaMf.c:65
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
unsigned iFunc
Definition: giaMf.c:47
int Delay
Definition: giaMf.c:45
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned nLeaves
Definition: giaMf.c:48
int fGenCnf
Definition: gia.h:284
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
int Mf_CutRef_rec ( Mf_Man_t p,
int *  pCut 
)

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

Synopsis [Flow and area.]

Description []

SideEffects []

SeeAlso []

Definition at line 1486 of file giaMf.c.

1487 {
1488  int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1489  for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1490  if ( !Mf_ObjMapRefInc(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
1491  Count += Mf_CutRef_rec( p, Mf_ObjCutBest(p, pCut[i]) );
1492  return Count;
1493 }
static int Mf_ObjMapRefInc(Mf_Man_t *p, int i)
Definition: giaMf.c:88
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
int Mf_CutRef_rec(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1486
static int Mf_CutArea(Mf_Man_t *p, int nLeaves, int iFunc)
Definition: giaMf.c:940
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
int iCutSet
Definition: giaMf.c:54
static int Mf_CutSetBoth ( int  n,
int  f 
)
inlinestatic

Definition at line 93 of file giaMf.c.

93 { return n | (f << 5); }
static int Mf_CutSize ( int *  pCut)
inlinestatic

Definition at line 91 of file giaMf.c.

91 { return pCut[0] & MF_NO_LEAF; }
#define MF_NO_LEAF
Definition: giaMf.c:37
Mf_Man_t* Mf_ManAlloc ( Gia_Man_t pGia,
Jf_Par_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1321 of file giaMf.c.

1322 {
1323  Mf_Man_t * p;
1324  Vec_Int_t * vFlowRefs;
1325  int i, Entry;
1326  assert( pPars->nCutNum > 1 && pPars->nCutNum <= MF_CUT_MAX );
1327  assert( pPars->nLutSize > 1 && pPars->nLutSize <= MF_LEAF_MAX );
1328  ABC_FREE( pGia->pRefs );
1329  Vec_IntFreeP( &pGia->vMapping );
1330  if ( Gia_ManHasChoices(pGia) )
1331  Gia_ManSetPhase(pGia);
1332  p = ABC_CALLOC( Mf_Man_t, 1 );
1333  p->clkStart = Abc_Clock();
1334  p->pGia = pGia;
1335  p->pPars = pPars;
1336  p->vTtMem = pPars->fCutMin ? Vec_MemAllocForTT( pPars->nLutSize, 0 ) : NULL;
1337  p->pLfObjs = ABC_CALLOC( Mf_Obj_t, Gia_ManObjNum(pGia) );
1338  p->iCur = 2;
1339  Vec_PtrGrow( &p->vPages, 256 );
1340  if ( pPars->fGenCnf )
1341  {
1342  Vec_IntGrow( &p->vCnfSizes, 10000 );
1343  Vec_IntPush( &p->vCnfSizes, 1 );
1344  Vec_IntPush( &p->vCnfSizes, 2 );
1345  Vec_IntGrow( &p->vCnfMem, 10000 );
1346  }
1347  vFlowRefs = Vec_IntAlloc(0);
1348  Mf_ManSetFlowRefs( pGia, vFlowRefs );
1349  Vec_IntForEachEntry( vFlowRefs, Entry, i )
1350  p->pLfObjs[i].nFlowRefs = Entry;
1351  Vec_IntFree(vFlowRefs);
1352  return p;
1353 }
int nCutNum
Definition: gia.h:268
int nLutSize
Definition: gia.h:267
Mf_Obj_t * pLfObjs
Definition: giaMf.c:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Jf_Par_t * pPars
Definition: giaMf.c:66
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaMf.c:65
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
Definition: vecPtr.h:430
static abctime Abc_Clock()
Definition: abc_global.h:279
int * pRefs
Definition: gia.h:114
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Int_t vCnfMem
Definition: giaMf.c:72
static Vec_Mem_t * Vec_MemAllocForTT(int nVars, int fCompl)
Definition: vecMem.h:378
abctime clkStart
Definition: giaMf.c:77
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define MF_CUT_MAX
Definition: giaMf.c:35
#define MF_LEAF_MAX
DECLARATIONS ///.
Definition: giaMf.c:34
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define ABC_FREE(obj)
Definition: abc_global.h:232
int fCutMin
Definition: gia.h:282
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int iCur
Definition: giaMf.c:73
Vec_Ptr_t vPages
Definition: giaMf.c:69
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
void Gia_ManSetPhase(Gia_Man_t *p)
Definition: giaUtil.c:379
void Mf_ManSetFlowRefs(Gia_Man_t *p, Vec_Int_t *vRefs)
Definition: giaMf.c:1077
Vec_Int_t * vMapping
Definition: gia.h:131
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
void Mf_ManComputeCuts ( Mf_Man_t p)

Definition at line 1466 of file giaMf.c.

1467 {
1468  int i;
1469  Gia_ManForEachAndId( p->pGia, i )
1470  Mf_ObjMergeOrder( p, i );
1471  Mf_ManSetMapRefs( p );
1472  Mf_ManPrintStats( p, p->fUseEla ? "Ela " : (p->Iter ? "Area " : "Delay") );
1473 }
Gia_Man_t * pGia
Definition: giaMf.c:65
void Mf_ManPrintStats(Mf_Man_t *p, char *pTitle)
Definition: giaMf.c:1404
int Mf_ManSetMapRefs(Mf_Man_t *p)
Definition: giaMf.c:1111
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
void Mf_ObjMergeOrder(Mf_Man_t *p, int iObj)
Definition: giaMf.c:966
void Mf_ManComputeMapping ( Mf_Man_t p)

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

Synopsis [Technology mappping.]

Description []

SideEffects []

SeeAlso []

Definition at line 1567 of file giaMf.c.

1568 {
1569  int i;
1570  Gia_ManForEachAndId( p->pGia, i )
1571  Mf_ObjComputeBestCut( p, i );
1572  Mf_ManSetMapRefs( p );
1573  Mf_ManPrintStats( p, p->fUseEla ? "Ela " : (p->Iter ? "Area " : "Delay") );
1574 }
Gia_Man_t * pGia
Definition: giaMf.c:65
static void Mf_ObjComputeBestCut(Mf_Man_t *p, int iObj)
Definition: giaMf.c:1523
void Mf_ManPrintStats(Mf_Man_t *p, char *pTitle)
Definition: giaMf.c:1404
int Mf_ManSetMapRefs(Mf_Man_t *p)
Definition: giaMf.c:1111
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
static int Mf_ManCountLits ( int *  pCnf,
int  nCubes,
int  nVars 
)
inlinestatic

Definition at line 251 of file giaMf.c.

252 {
253  int i, k, nLits = nCubes;
254  for ( i = 0; i < nCubes; i++ )
255  for ( k = 0; k < nVars; k++ )
256  if ( Mf_CubeLit(pCnf[i], k) )
257  nLits++;
258  return nLits;
259 }
static int Mf_CubeLit(int Cube, int iVar)
Definition: giaMf.c:250
static int* Mf_ManCutSet ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 83 of file giaMf.c.

83 { return (int *)Vec_PtrEntry(&p->vPages, i >> 16) + (i & 0xFFFF); }
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t vPages
Definition: giaMf.c:69
Cnf_Dat_t* Mf_ManDeriveCnf ( Mf_Man_t p,
int  fCnfObjIds,
int  fAddOrCla 
)

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

Synopsis [Derives CNF for the AIG using the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 325 of file giaMf.c.

326 {
327  Cnf_Dat_t * pCnf;
328  Gia_Obj_t * pObj;
329  int Id, DriId, nVars, nClas, nLits, iVar = 1, iCla = 0, iLit = 0;
330  Vec_Int_t * vCnfs = Mf_ManDeriveCnfs( p, &nVars, &nClas, &nLits );
331  Vec_Int_t * vCnfIds = Vec_IntStartFull( Gia_ManObjNum(p->pGia) );
332  int pFanins[16], * pCut, * pCnfIds = Vec_IntArray( vCnfIds );
333  int i, k, c, iFunc, nCubes, * pCubes, fComplLast;
334  nVars++; // zero-ID to remain unused
335  if ( fAddOrCla )
336  {
337  nClas++;
338  nLits += Gia_ManCoNum(p->pGia);
339  }
340  // create CNF IDs
341  if ( fCnfObjIds )
342  {
343  iVar += 1 + Gia_ManCiNum(p->pGia) + Gia_ManCoNum(p->pGia);
344  Gia_ManForEachCoId( p->pGia, Id, i )
345  Vec_IntWriteEntry( vCnfIds, Id, Id );
346  Gia_ManForEachAndReverseId( p->pGia, Id )
347  if ( Mf_ObjMapRefNum(p, Id) )
348  Vec_IntWriteEntry( vCnfIds, Id, Id ), iVar++;
349  Gia_ManForEachCiId( p->pGia, Id, i )
350  Vec_IntWriteEntry( vCnfIds, Id, Id );
351  Vec_IntWriteEntry( vCnfIds, 0, 0 );
352  assert( iVar == nVars );
353  }
354  else
355  {
356  Gia_ManForEachCoId( p->pGia, Id, i )
357  Vec_IntWriteEntry( vCnfIds, Id, iVar++ );
358  Gia_ManForEachAndReverseId( p->pGia, Id )
359  if ( Mf_ObjMapRefNum(p, Id) )
360  Vec_IntWriteEntry( vCnfIds, Id, iVar++ );
361  Gia_ManForEachCiId( p->pGia, Id, i )
362  Vec_IntWriteEntry( vCnfIds, Id, iVar++ );
363  Vec_IntWriteEntry( vCnfIds, 0, iVar++ );
364  assert( iVar == nVars );
365  }
366  // generate CNF
367  pCnf = ABC_CALLOC( Cnf_Dat_t, 1 );
368  pCnf->pMan = (Aig_Man_t *)p->pGia;
369  pCnf->nVars = nVars;
370  pCnf->nLiterals = nLits;
371  pCnf->nClauses = nClas;
372  pCnf->pClauses = ABC_ALLOC( int *, nClas+1 );
373  pCnf->pClauses[0] = ABC_ALLOC( int, nLits );
374  // add last clause
375  if ( fAddOrCla )
376  {
377  pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
378  Gia_ManForEachCoId( p->pGia, Id, i )
379  pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], 0);
380  }
381  // add clauses for the COs
382  Gia_ManForEachCo( p->pGia, pObj, i )
383  {
384  Id = Gia_ObjId( p->pGia, pObj );
385  DriId = Gia_ObjFaninId0( pObj, Id );
386 
387  pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
388  pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], 0);
389  pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[DriId], !Gia_ObjFaninC0(pObj));
390 
391  pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
392  pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], 1);
393  pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[DriId], Gia_ObjFaninC0(pObj));
394  }
395  // add clauses for the mapping
396  Gia_ManForEachAndReverseId( p->pGia, Id )
397  {
398  if ( !Mf_ObjMapRefNum(p, Id) )
399  continue;
400  pCut = Mf_ObjCutBest( p, Id );
401  iFunc = Abc_Lit2Var( Mf_CutFunc(pCut) );
402  //Dau_DsdPrintFromTruth( Vec_MemReadEntry(p->vTtMem, iFunc), 3 );
403  fComplLast = Abc_LitIsCompl( Mf_CutFunc(pCut) );
404  for ( k = 0; k < Mf_CutSize(pCut); k++ )
405  pFanins[k] = pCnfIds[pCut[k+1]];
406  pFanins[k++] = pCnfIds[Id];
407  // get clauses
408  pCubes = Vec_IntEntryP( vCnfs, Vec_IntEntry(vCnfs, iFunc) );
409  nCubes = *pCubes++;
410  for ( c = 0; c < nCubes; c++ )
411  {
412  pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
413  k = Mf_CutSize(pCut);
414  assert( Mf_CubeLit(pCubes[c], k) );
415  pCnf->pClauses[0][iLit++] = Abc_Var2Lit( pFanins[k], (Mf_CubeLit(pCubes[c], k) == 2) ^ fComplLast );
416  for ( k = 0; k < Mf_CutSize(pCut); k++ )
417  if ( Mf_CubeLit(pCubes[c], k) )
418  pCnf->pClauses[0][iLit++] = Abc_Var2Lit( pFanins[k], Mf_CubeLit(pCubes[c], k) == 2 );
419  }
420  }
421  // constant clause
422  pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
423  pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[0], 1);
424  assert( iCla == nClas );
425  assert( iLit == nLits );
426  // add closing pointer
427  pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
428  // cleanup
429  Vec_IntFree( vCnfs );
430  // create mapping of objects into their clauses
431  if ( fCnfObjIds )
432  {
433  pCnf->pObj2Clause = ABC_FALLOC( int, Gia_ManObjNum(p->pGia) );
434  pCnf->pObj2Count = ABC_FALLOC( int, Gia_ManObjNum(p->pGia) );
435  for ( i = 0; i < pCnf->nClauses; i++ )
436  {
437  Id = Abc_Lit2Var(pCnf->pClauses[i][0]);
438  if ( pCnf->pObj2Clause[Id] == -1 )
439  {
440  pCnf->pObj2Clause[Id] = i;
441  pCnf->pObj2Count[Id] = 1;
442  }
443  else
444  {
445  assert( pCnf->pObj2Count[Id] > 0 );
446  pCnf->pObj2Count[Id]++;
447  }
448  }
449  }
450  else
451  {
452  if ( p->pGia != p->pGia0 ) // diff managers - create map for CIs/COs
453  {
454  pCnf->pVarNums = ABC_FALLOC( int, Gia_ManObjNum(p->pGia0) );
455  Gia_ManForEachCiId( p->pGia0, Id, i )
456  pCnf->pVarNums[Id] = pCnfIds[Gia_ManCiIdToId(p->pGia, i)];
457  Gia_ManForEachCoId( p->pGia0, Id, i )
458  pCnf->pVarNums[Id] = pCnfIds[Gia_ManCoIdToId(p->pGia, i)];
459 /*
460  // transform polarity of the internal nodes
461  Gia_ManSetPhase( p->pGia );
462  Gia_ManForEachCo( p->pGia, pObj, i )
463  pObj->fPhase = 0;
464  for ( i = 0; i < pCnf->nLiterals; i++ )
465  if ( Gia_ManObj(p->pGia, Abc_Lit2Var(pCnf->pClauses[0][i]))->fPhase )
466  pCnf->pClauses[0][i] = Abc_LitNot( pCnf->pClauses[0][i] );
467 */
468  }
469  else
470  pCnf->pVarNums = Vec_IntReleaseArray(vCnfIds);
471  }
472  Vec_IntFree( vCnfIds );
473  return pCnf;
474 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaMf.c:65
int nClauses
Definition: cnf.h:61
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int * pVarNums
Definition: cnf.h:63
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Int_t * Mf_ManDeriveCnfs(Mf_Man_t *p, int *pnVars, int *pnClas, int *pnLits)
Definition: giaMf.c:260
Definition: cnf.h:56
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
Definition: gia.h:75
int * pObj2Clause
Definition: cnf.h:64
#define Gia_ManForEachAndReverseId(p, i)
Definition: gia.h:1012
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
int ** pClauses
Definition: cnf.h:62
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ManCoIdToId(Gia_Man_t *p, int CoId)
Definition: gia.h:439
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static int Mf_CubeLit(int Cube, int iVar)
Definition: giaMf.c:250
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Gia_ManForEachCoId(p, Id, i)
Definition: gia.h:1026
static int * Vec_IntReleaseArray(Vec_Int_t *p)
Definition: extraZddTrunc.c:89
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
static int Gia_ManCiIdToId(Gia_Man_t *p, int CiId)
Definition: gia.h:438
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
int * pObj2Count
Definition: cnf.h:65
Vec_Int_t* Mf_ManDeriveCnfs ( Mf_Man_t p,
int *  pnVars,
int *  pnClas,
int *  pnLits 
)

Definition at line 260 of file giaMf.c.

261 {
262  int i, k, iFunc, nCubes, nLits, * pCut, pCnf[512];
263  Vec_Int_t * vLits = Vec_IntStart( Vec_IntSize(&p->vCnfSizes) );
264  Vec_Int_t * vCnfs = Vec_IntAlloc( 3 * Vec_IntSize(&p->vCnfSizes) );
265  Vec_IntFill( vCnfs, Vec_IntSize(&p->vCnfSizes), -1 );
266  assert( p->pPars->nLutSize <= 8 );
267  // constant/buffer
268  for ( iFunc = 0; iFunc < 2; iFunc++ )
269  {
270  if ( p->pPars->nLutSize <= 6 )
271  nCubes = Abc_Tt6Cnf( *Vec_MemReadEntry(p->vTtMem, iFunc), iFunc, pCnf );
272  else
273  nCubes = Abc_Tt8Cnf( Vec_MemReadEntry(p->vTtMem, iFunc), iFunc, pCnf );
274  nLits = Mf_ManCountLits( pCnf, nCubes, iFunc );
275  Vec_IntWriteEntry( vLits, iFunc, nLits );
276  Vec_IntWriteEntry( vCnfs, iFunc, Vec_IntSize(vCnfs) );
277  Vec_IntPush( vCnfs, nCubes );
278  for ( k = 0; k < nCubes; k++ )
279  Vec_IntPush( vCnfs, pCnf[k] );
280  }
281  // other functions
282  *pnVars = 1 + Gia_ManCiNum(p->pGia) + Gia_ManCoNum(p->pGia);
283  *pnClas = 1 + 2 * Gia_ManCoNum(p->pGia);
284  *pnLits = 1 + 4 * Gia_ManCoNum(p->pGia);
285  Gia_ManForEachAndId( p->pGia, i )
286  {
287  if ( !Mf_ObjMapRefNum(p, i) )
288  continue;
289  pCut = Mf_ObjCutBest( p, i );
290  iFunc = Abc_Lit2Var( Mf_CutFunc(pCut) );
291  if ( Vec_IntEntry(vCnfs, iFunc) == -1 )
292  {
293  if ( p->pPars->nLutSize <= 6 )
294  nCubes = Abc_Tt6Cnf( *Vec_MemReadEntry(p->vTtMem, iFunc), Mf_CutSize(pCut), pCnf );
295  else
296  nCubes = Abc_Tt8Cnf( Vec_MemReadEntry(p->vTtMem, iFunc), Mf_CutSize(pCut), pCnf );
297  assert( nCubes == Vec_IntEntry(&p->vCnfSizes, iFunc) );
298  nLits = Mf_ManCountLits( pCnf, nCubes, Mf_CutSize(pCut) );
299  // save CNF
300  Vec_IntWriteEntry( vLits, iFunc, nLits );
301  Vec_IntWriteEntry( vCnfs, iFunc, Vec_IntSize(vCnfs) );
302  Vec_IntPush( vCnfs, nCubes );
303  for ( k = 0; k < nCubes; k++ )
304  Vec_IntPush( vCnfs, pCnf[k] );
305  }
306  *pnVars += 1;
307  *pnClas += Vec_IntEntry(&p->vCnfSizes, iFunc);
308  *pnLits += Vec_IntEntry(vLits, iFunc);
309  }
310  Vec_IntFree( vLits );
311  return vCnfs;
312 }
int nLutSize
Definition: gia.h:267
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Mf_ManCountLits(int *pCnf, int nCubes, int nVars)
Definition: giaMf.c:251
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaMf.c:65
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_Tt8Cnf(word t[4], int nVars, int *pCover)
Definition: utilTruth.h:1974
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Tt6Cnf(word t, int nVars, int *pCover)
Definition: utilTruth.h:1962
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
Gia_Man_t* Mf_ManDeriveMapping ( Mf_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1169 of file giaMf.c.

1170 {
1171  Vec_Int_t * vMapping;
1172  int i, k, * pCut;
1173  assert( !p->pPars->fCutMin && p->pGia->vMapping == NULL );
1174  vMapping = Vec_IntAlloc( Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
1175  Vec_IntFill( vMapping, Gia_ManObjNum(p->pGia), 0 );
1176  Gia_ManForEachAndId( p->pGia, i )
1177  {
1178  if ( !Mf_ObjMapRefNum(p, i) )
1179  continue;
1180  pCut = Mf_ObjCutBest( p, i );
1181  Vec_IntWriteEntry( vMapping, i, Vec_IntSize(vMapping) );
1182  Vec_IntPush( vMapping, Mf_CutSize(pCut) );
1183  for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1184  Vec_IntPush( vMapping, pCut[k] );
1185  Vec_IntPush( vMapping, i );
1186  }
1187  assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
1188  p->pGia->vMapping = vMapping;
1189  return p->pGia;
1190 }
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
word Edge
Definition: gia.h:299
Jf_Par_t * pPars
Definition: giaMf.c:66
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaMf.c:65
word Area
Definition: gia.h:298
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntCap(Vec_Int_t *p)
Definition: vecInt.h:368
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int fCutMin
Definition: gia.h:282
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
#define assert(ex)
Definition: util_old.h:213
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
Vec_Int_t * vMapping
Definition: gia.h:131
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Gia_Man_t* Mf_ManDeriveMappingCoarse ( Mf_Man_t p)

Definition at line 1191 of file giaMf.c.

1192 {
1193  Gia_Man_t * pNew, * pGia = p->pGia;
1194  Gia_Obj_t * pObj;
1195  int i, k, * pCut;
1196  assert( !p->pPars->fCutMin && pGia->pMuxes );
1197  // create new manager
1198  pNew = Gia_ManStart( Gia_ManObjNum(pGia) );
1199  pNew->pName = Abc_UtilStrsav( pGia->pName );
1200  pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
1201  // map primary inputs
1202  Gia_ManConst0(pGia)->Value = 0;
1203  Gia_ManForEachCi( pGia, pObj, i )
1204  pObj->Value = Gia_ManAppendCi( pNew );
1205  // start mapping
1206  pNew->vMapping = Vec_IntAlloc( Gia_ManObjNum(pGia) + 2*Gia_ManXorNum(pGia) + 2*Gia_ManMuxNum(pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
1207  Vec_IntFill( pNew->vMapping, Gia_ManObjNum(pGia) + 2*Gia_ManXorNum(pGia) + 2*Gia_ManMuxNum(pGia), 0 );
1208  // iterate through nodes used in the mapping
1209  Gia_ManForEachAnd( pGia, pObj, i )
1210  {
1211  if ( Gia_ObjIsMuxId(pGia, i) )
1212  pObj->Value = Gia_ManAppendMux( pNew, Gia_ObjFanin2Copy(pGia, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
1213  else if ( Gia_ObjIsXor(pObj) )
1214  pObj->Value = Gia_ManAppendXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1215  else
1216  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1217  if ( !Mf_ObjMapRefNum(p, i) )
1218  continue;
1219  pCut = Mf_ObjCutBest( p, i );
1220  Vec_IntWriteEntry( pNew->vMapping, Abc_Lit2Var(pObj->Value), Vec_IntSize(pNew->vMapping) );
1221  Vec_IntPush( pNew->vMapping, Mf_CutSize(pCut));
1222  for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1223  Vec_IntPush( pNew->vMapping, Abc_Lit2Var(Gia_ManObj(pGia, pCut[k])->Value) );
1224  Vec_IntPush( pNew->vMapping, Abc_Lit2Var(pObj->Value) );
1225  }
1226  Gia_ManForEachCo( pGia, pObj, i )
1227  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1228  Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia) );
1229  assert( Vec_IntCap(pNew->vMapping) == 16 || Vec_IntSize(pNew->vMapping) == Vec_IntCap(pNew->vMapping) );
1230  return pNew;
1231 }
static int Gia_ObjFanin2Copy(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:483
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
static int Gia_ManMuxNum(Gia_Man_t *p)
Definition: gia.h:391
static int Gia_ManAppendXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:735
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
Jf_Par_t * pPars
Definition: giaMf.c:66
Gia_Man_t * pGia
Definition: giaMf.c:65
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
unsigned * pMuxes
Definition: gia.h:104
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Gia_ManAppendMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: gia.h:722
static int Gia_ObjIsMuxId(Gia_Man_t *p, int iObj)
Definition: gia.h:424
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static int Gia_ObjIsXor(Gia_Obj_t *pObj)
Definition: gia.h:423
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ManXorNum(Gia_Man_t *p)
Definition: gia.h:390
static int Vec_IntCap(Vec_Int_t *p)
Definition: vecInt.h:368
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
int fCutMin
Definition: gia.h:282
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Mf_ManDeriveMappingGia ( Mf_Man_t p)

Definition at line 1232 of file giaMf.c.

1233 {
1234  Gia_Man_t * pNew;
1235  Gia_Obj_t * pObj;
1236  Vec_Int_t * vCopies = Vec_IntStartFull( Gia_ManObjNum(p->pGia) );
1237  Vec_Int_t * vMapping = Vec_IntStart( 2 * Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + 2 * (int)p->pPars->Area );
1238  Vec_Int_t * vMapping2 = Vec_IntStart( (int)p->pPars->Edge + 2 * (int)p->pPars->Area + 1000 );
1239  Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 );
1240  Vec_Int_t * vLeaves = Vec_IntAlloc( 16 );
1241  int i, k, Id, iLit, * pCut;
1242  word uTruth = 0, * pTruth = &uTruth;
1243  assert( p->pPars->fCutMin );
1244  // create new manager
1245  pNew = Gia_ManStart( Gia_ManObjNum(p->pGia) );
1246  pNew->pName = Abc_UtilStrsav( p->pGia->pName );
1247  pNew->pSpec = Abc_UtilStrsav( p->pGia->pSpec );
1248  // map primary inputs
1249  Vec_IntWriteEntry( vCopies, 0, 0 );
1250  Gia_ManForEachCiId( p->pGia, Id, i )
1251  Vec_IntWriteEntry( vCopies, Id, Gia_ManAppendCi(pNew) );
1252  // iterate through nodes used in the mapping
1253  Gia_ManForEachAnd( p->pGia, pObj, i )
1254  {
1255  if ( !Mf_ObjMapRefNum(p, i) )
1256  continue;
1257  pCut = Mf_ObjCutBest( p, i );
1258  if ( Mf_CutSize(pCut) == 0 )
1259  {
1260  assert( Abc_Lit2Var(Mf_CutFunc(pCut)) == 0 );
1261  Vec_IntWriteEntry( vCopies, i, Mf_CutFunc(pCut) );
1262  continue;
1263  }
1264  if ( Mf_CutSize(pCut) == 1 )
1265  {
1266  assert( Abc_Lit2Var(Mf_CutFunc(pCut)) == 1 );
1267  iLit = Vec_IntEntry( vCopies, pCut[1] );
1268  Vec_IntWriteEntry( vCopies, i, Abc_LitNotCond(iLit, Abc_LitIsCompl(Mf_CutFunc(pCut))) );
1269  continue;
1270  }
1271  Vec_IntClear( vLeaves );
1272  for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1273  Vec_IntPush( vLeaves, Vec_IntEntry(vCopies, pCut[k]) );
1274  pTruth = Vec_MemReadEntry( p->vTtMem, Abc_Lit2Var(Mf_CutFunc(pCut)) );
1275  iLit = Kit_TruthToGia( pNew, (unsigned *)pTruth, Vec_IntSize(vLeaves), vCover, vLeaves, 0 );
1276  Vec_IntWriteEntry( vCopies, i, Abc_LitNotCond(iLit, Abc_LitIsCompl(Mf_CutFunc(pCut))) );
1277  // create mapping
1278  Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLit), Vec_IntSize(vMapping2) );
1279  Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
1280  Vec_IntForEachEntry( vLeaves, iLit, k )
1281  Vec_IntPush( vMapping2, Abc_Lit2Var(iLit) );
1282  Vec_IntPush( vMapping2, Abc_Lit2Var(Vec_IntEntry(vCopies, i)) );
1283  }
1284  Gia_ManForEachCo( p->pGia, pObj, i )
1285  {
1286  iLit = Vec_IntEntry( vCopies, Gia_ObjFaninId0p(p->pGia, pObj) );
1287  iLit = Gia_ManAppendCo( pNew, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
1288  }
1289  Vec_IntFree( vCopies );
1290  Vec_IntFree( vCover );
1291  Vec_IntFree( vLeaves );
1292  // finish mapping
1293  if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
1294  Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
1295  else
1296  Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
1297  assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
1298  Vec_IntForEachEntry( vMapping, iLit, i )
1299  if ( iLit > 0 )
1300  Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
1301  Vec_IntAppend( vMapping, vMapping2 );
1302  Vec_IntFree( vMapping2 );
1303  // attach mapping and packing
1304  assert( pNew->vMapping == NULL );
1305  pNew->vMapping = vMapping;
1306  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p->pGia) );
1307  return pNew;
1308 }
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
word Edge
Definition: gia.h:299
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
Jf_Par_t * pPars
Definition: giaMf.c:66
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaMf.c:65
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:80
Definition: gia.h:75
word Area
Definition: gia.h:298
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
Definition: gia.h:95
int fCutMin
Definition: gia.h:282
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define assert(ex)
Definition: util_old.h:213
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Mf_ManDumpCnf ( Gia_Man_t p,
char *  pFileName,
int  nLutSize,
int  fCnfObjIds,
int  fAddOrCla,
int  fVerbose 
)

Definition at line 1646 of file giaMf.c.

1647 {
1648  abctime clk = Abc_Clock();
1649  Cnf_Dat_t * pCnf;
1650  pCnf = Mf_ManGenerateCnf( p, nLutSize, fCnfObjIds, fAddOrCla, fVerbose );
1651  Cnf_DataWriteIntoFile( pCnf, pFileName, 0, NULL, NULL );
1652 // if ( fVerbose )
1653  {
1654  printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
1655  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1656  }
1657  Cnf_DataFree(pCnf);
1658 }
void Cnf_DataWriteIntoFile(Cnf_Dat_t *p, char *pFileName, int fReadable, Vec_Int_t *vForAlls, Vec_Int_t *vExists)
Definition: cnfMan.c:318
int nClauses
Definition: cnf.h:61
int nVars
Definition: cnf.h:59
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: cnf.h:56
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
Cnf_Dat_t * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose)
Definition: giaMf.c:1629
ABC_INT64_T abctime
Definition: abc_global.h:278
int nLiterals
Definition: cnf.h:60
void Mf_ManFree ( Mf_Man_t p)

Definition at line 1354 of file giaMf.c.

1355 {
1357  if ( p->pPars->fCutMin )
1358  Vec_MemHashFree( p->vTtMem );
1359  if ( p->pPars->fCutMin )
1360  Vec_MemFree( p->vTtMem );
1361  Vec_PtrFreeData( &p->vPages );
1362  ABC_FREE( p->vCnfSizes.pArray );
1363  ABC_FREE( p->vCnfMem.pArray );
1364  ABC_FREE( p->vPages.pArray );
1365  ABC_FREE( p->pLfObjs );
1366  ABC_FREE( p );
1367 }
Mf_Obj_t * pLfObjs
Definition: giaMf.c:68
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
Vec_Int_t vCnfMem
Definition: giaMf.c:72
static void Vec_MemFree(Vec_Mem_t *p)
Definition: utilMem.c:93
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
int fCutMin
Definition: gia.h:282
Vec_Ptr_t vPages
Definition: giaMf.c:69
static void Vec_MemHashFree(Vec_Mem_t *p)
Definition: vecMem.h:311
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
static void Vec_PtrFreeData(Vec_Ptr_t *p)
Definition: vecPtr.h:561
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
Cnf_Dat_t* Mf_ManGenerateCnf ( Gia_Man_t pGia,
int  nLutSize,
int  fCnfObjIds,
int  fAddOrCla,
int  fVerbose 
)

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

Synopsis [CNF generation]

Description []

SideEffects []

SeeAlso []

Definition at line 1629 of file giaMf.c.

1630 {
1631  Gia_Man_t * pNew;
1632  Jf_Par_t Pars, * pPars = &Pars;
1633  assert( nLutSize >= 3 && nLutSize <= 8 );
1634  Mf_ManSetDefaultPars( pPars );
1635  pPars->fGenCnf = 1;
1636  pPars->fCoarsen = !fCnfObjIds;
1637  pPars->nLutSize = nLutSize;
1638  pPars->fCnfObjIds = fCnfObjIds;
1639  pPars->fAddOrCla = fAddOrCla;
1640  pPars->fVerbose = fVerbose;
1641  pNew = Mf_ManPerformMapping( pGia, pPars );
1642  Gia_ManStopP( &pNew );
1643 // Cnf_DataPrint( (Cnf_Dat_t *)pGia->pData, 1 );
1644  return pGia->pData;
1645 }
int nLutSize
Definition: gia.h:267
int fCnfObjIds
Definition: gia.h:285
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
Definition: gia.h:265
void * pData
Definition: gia.h:169
Gia_Man_t * Mf_ManPerformMapping(Gia_Man_t *pGia, Jf_Par_t *pPars)
Definition: giaMf.c:1575
void Mf_ManSetDefaultPars(Jf_Par_t *pPars)
Definition: giaMf.c:1380
Definition: gia.h:95
int fGenCnf
Definition: gia.h:284
#define assert(ex)
Definition: util_old.h:213
int fAddOrCla
Definition: gia.h:286
int fVerbose
Definition: gia.h:291
int fCoarsen
Definition: gia.h:281
static Mf_Obj_t* Mf_ManObj ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 82 of file giaMf.c.

82 { return p->pLfObjs + i; }
Mf_Obj_t * pLfObjs
Definition: giaMf.c:68
Gia_Man_t* Mf_ManPerformMapping ( Gia_Man_t pGia,
Jf_Par_t pPars 
)

Definition at line 1575 of file giaMf.c.

1576 {
1577  Mf_Man_t * p;
1578  Gia_Man_t * pNew, * pCls;
1579  if ( pPars->fGenCnf )
1580  pPars->fCutMin = 1;
1581  if ( Gia_ManHasChoices(pGia) )
1582  pPars->fCutMin = 1, pPars->fCoarsen = 0;
1583  pCls = pPars->fCoarsen ? Gia_ManDupMuxes(pGia, pPars->nCoarseLimit) : pGia;
1584  p = Mf_ManAlloc( pCls, pPars );
1585  p->pGia0 = pGia;
1586  if ( pPars->fVerbose && pPars->fCoarsen )
1587  {
1588  printf( "Initial " ); Gia_ManPrintMuxStats( pGia ); printf( "\n" );
1589  printf( "Derived " ); Gia_ManPrintMuxStats( pCls ); printf( "\n" );
1590  }
1591  Mf_ManPrintInit( p );
1592  Mf_ManComputeCuts( p );
1593  for ( p->Iter = 1; p->Iter < p->pPars->nRounds; p->Iter++ )
1594  Mf_ManComputeMapping( p );
1595  p->fUseEla = 1;
1596  for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
1597  Mf_ManComputeMapping( p );
1598  if ( pPars->fVeryVerbose && pPars->fCutMin )
1600  if ( pPars->fCutMin )
1601  pNew = Mf_ManDeriveMappingGia( p );
1602  else if ( pPars->fCoarsen )
1603  pNew = Mf_ManDeriveMappingCoarse( p );
1604  else
1605  pNew = Mf_ManDeriveMapping( p );
1606  if ( p->pPars->fGenCnf )
1607  pGia->pData = Mf_ManDeriveCnf( p, p->pPars->fCnfObjIds, p->pPars->fAddOrCla );
1608 // if ( p->pPars->fGenCnf )
1609 // Mf_ManProfileTruths( p );
1610  Gia_ManMappingVerify( pNew );
1611  Mf_ManPrintQuit( p, pNew );
1612  Mf_ManFree( p );
1613  if ( pCls != pGia )
1614  Gia_ManStop( pCls );
1615  return pNew;
1616 }
void Mf_ManComputeCuts(Mf_Man_t *p)
Definition: giaMf.c:1466
int nLutSize
Definition: gia.h:267
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Cnf_Dat_t * Mf_ManDeriveCnf(Mf_Man_t *p, int fCnfObjIds, int fAddOrCla)
Definition: giaMf.c:325
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Jf_Par_t * pPars
Definition: giaMf.c:66
Gia_Man_t * pGia
Definition: giaMf.c:65
static char * Gia_ManName(Gia_Man_t *p)
Definition: gia.h:382
Gia_Man_t * Mf_ManDeriveMappingCoarse(Mf_Man_t *p)
Definition: giaMf.c:1191
void Mf_ManFree(Mf_Man_t *p)
Definition: giaMf.c:1354
int fCnfObjIds
Definition: gia.h:285
Gia_Man_t * pGia0
Definition: giaMf.c:64
int fVeryVerbose
Definition: gia.h:292
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
void Mf_ManComputeMapping(Mf_Man_t *p)
Definition: giaMf.c:1567
Gia_Man_t * Mf_ManDeriveMappingGia(Mf_Man_t *p)
Definition: giaMf.c:1232
void * pData
Definition: gia.h:169
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
Definition: giaMuxes.c:96
void Gia_ManMappingVerify(Gia_Man_t *p)
Definition: giaIf.c:1807
static void Vec_MemDumpTruthTables(Vec_Mem_t *p, char *pName, int nLutSize)
Definition: vecMem.h:402
void Mf_ManPrintQuit(Mf_Man_t *p, Gia_Man_t *pNew)
Definition: giaMf.c:1432
void Gia_ManPrintMuxStats(Gia_Man_t *p)
Definition: giaMuxes.c:61
int fUseEla
Definition: giaMf.c:75
int nRounds
Definition: gia.h:270
Mf_Man_t * Mf_ManAlloc(Gia_Man_t *pGia, Jf_Par_t *pPars)
Definition: giaMf.c:1321
Gia_Man_t * Mf_ManDeriveMapping(Mf_Man_t *p)
Definition: giaMf.c:1169
Definition: gia.h:95
int fCutMin
Definition: gia.h:282
int fGenCnf
Definition: gia.h:284
int nRoundsEla
Definition: gia.h:271
void Mf_ManPrintInit(Mf_Man_t *p)
Definition: giaMf.c:1417
int nCoarseLimit
Definition: gia.h:273
int fAddOrCla
Definition: gia.h:286
int fVerbose
Definition: gia.h:291
int fCoarsen
Definition: gia.h:281
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
int Iter
Definition: giaMf.c:74
static int Mf_ManPrepareCuts ( Mf_Cut_t pCuts,
Mf_Man_t p,
int  iObj,
int  fAddUnit 
)
inlinestatic

Definition at line 650 of file giaMf.c.

651 {
652  if ( Mf_ManObj(p, iObj)->iCutSet )
653  {
654  Mf_Cut_t * pMfCut = pCuts;
655  int i, * pCut, * pList = Mf_ObjCutSet(p, iObj);
656  Mf_SetForEachCut( pList, pCut, i )
657  {
658  pMfCut->Delay = 0;
659  pMfCut->Flow = 0;
660  pMfCut->iFunc = Mf_CutFunc( pCut );
661  pMfCut->nLeaves = Mf_CutSize( pCut );
662  pMfCut->Sign = Mf_CutGetSign( pCut+1, Mf_CutSize(pCut) );
663  memcpy( pMfCut->pLeaves, pCut+1, sizeof(int) * Mf_CutSize(pCut) );
664  pMfCut++;
665  }
666  if ( fAddUnit && pCuts->nLeaves > 1 )
667  return pList[0] + Mf_CutCreateUnit( pMfCut, iObj );
668  return pList[0];
669  }
670  return Mf_CutCreateUnit( pCuts, iObj );
671 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
float Flow
Definition: giaMf.c:46
char * memcpy()
word Sign
Definition: giaMf.c:44
static int * Mf_ObjCutSet(Mf_Man_t *p, int i)
Definition: giaMf.c:84
unsigned iFunc
Definition: giaMf.c:47
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static word Mf_CutGetSign(int *pLeaves, int nLeaves)
Definition: giaMf.c:614
static int Mf_CutCreateUnit(Mf_Cut_t *p, int i)
Definition: giaMf.c:621
int Delay
Definition: giaMf.c:45
#define Mf_SetForEachCut(pList, pCut, i)
Definition: giaMf.c:96
unsigned nLeaves
Definition: giaMf.c:48
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
void Mf_ManPrintInit ( Mf_Man_t p)

Definition at line 1417 of file giaMf.c.

1418 {
1419  if ( !p->pPars->fVerbose )
1420  return;
1421  printf( "LutSize = %d ", p->pPars->nLutSize );
1422  printf( "CutNum = %d ", p->pPars->nCutNum );
1423  printf( "Iter = %d ", p->pPars->nRounds + p->pPars->nRoundsEla );
1424  printf( "Edge = %d ", p->pPars->fOptEdge );
1425  printf( "CutMin = %d ", p->pPars->fCutMin );
1426  printf( "Coarse = %d ", p->pPars->fCoarsen );
1427  printf( "CNF = %d ", p->pPars->fGenCnf );
1428  printf( "\n" );
1429  printf( "Computing cuts...\r" );
1430  fflush( stdout );
1431 }
int nCutNum
Definition: gia.h:268
int nLutSize
Definition: gia.h:267
Jf_Par_t * pPars
Definition: giaMf.c:66
int fOptEdge
Definition: gia.h:278
int nRounds
Definition: gia.h:270
int fCutMin
Definition: gia.h:282
int fGenCnf
Definition: gia.h:284
int nRoundsEla
Definition: gia.h:271
int fVerbose
Definition: gia.h:291
int fCoarsen
Definition: gia.h:281
void Mf_ManPrintQuit ( Mf_Man_t p,
Gia_Man_t pNew 
)

Definition at line 1432 of file giaMf.c.

1433 {
1434  float MemGia = Gia_ManMemory(p->pGia) / (1<<20);
1435  float MemMan = 1.0 * sizeof(Mf_Obj_t) * Gia_ManObjNum(p->pGia) / (1<<20);
1436  float MemCuts = 1.0 * sizeof(int) * (1 << 16) * Vec_PtrSize(&p->vPages) / (1<<20);
1437  float MemTt = p->vTtMem ? Vec_MemMemory(p->vTtMem) / (1<<20) : 0;
1438  float MemMap = Vec_IntMemory(pNew->vMapping) / (1<<20);
1439  if ( p->CutCount[0] == 0 )
1440  p->CutCount[0] = 1;
1441  if ( !p->pPars->fVerbose )
1442  return;
1443  printf( "CutPair = %.0f ", p->CutCount[0] );
1444  printf( "Merge = %.0f (%.2f %%) ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
1445  printf( "Eval = %.0f (%.2f %%) ", p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
1446  printf( "Cut = %.0f (%.2f %%) ", p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
1447  printf( "\n" );
1448  printf( "Gia = %.2f MB ", MemGia );
1449  printf( "Man = %.2f MB ", MemMan );
1450  printf( "Cut = %.2f MB ", MemCuts );
1451  printf( "Map = %.2f MB ", MemMap );
1452  printf( "TT = %.2f MB ", MemTt );
1453  printf( "Total = %.2f MB", MemGia + MemMan + MemCuts + MemMap + MemTt );
1454  printf( "\n" );
1455  if ( 1 )
1456  {
1457  int i;
1458  for ( i = 0; i <= p->pPars->nLutSize; i++ )
1459  printf( "%d = %d ", i, p->nCutCounts[i] );
1460  if ( p->vTtMem )
1461  printf( "TT = %d (%.2f %%) ", Vec_MemEntryNum(p->vTtMem), 100.0 * Vec_MemEntryNum(p->vTtMem) / p->CutCount[2] );
1462  Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
1463  }
1464  fflush( stdout );
1465 }
int nLutSize
Definition: gia.h:267
int nCutCounts[MF_LEAF_MAX+1]
Definition: giaMf.c:79
static double Vec_IntMemory(Vec_Int_t *p)
Definition: vecInt.h:384
Jf_Par_t * pPars
Definition: giaMf.c:66
Gia_Man_t * pGia
Definition: giaMf.c:65
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
double CutCount[4]
Definition: giaMf.c:78
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
struct Mf_Obj_t_ Mf_Obj_t
Definition: giaMf.c:51
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
abctime clkStart
Definition: giaMf.c:77
static double Vec_MemMemory(Vec_Mem_t *p)
Definition: vecMem.h:175
Vec_Ptr_t vPages
Definition: giaMf.c:69
double Gia_ManMemory(Gia_Man_t *p)
Definition: giaMan.c:156
Vec_Int_t * vMapping
Definition: gia.h:131
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int fVerbose
Definition: gia.h:291
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
void Mf_ManPrintStats ( Mf_Man_t p,
char *  pTitle 
)

Definition at line 1404 of file giaMf.c.

1405 {
1406  if ( !p->pPars->fVerbose )
1407  return;
1408  printf( "%s : ", pTitle );
1409  printf( "Level =%6lu ", p->pPars->Delay );
1410  printf( "Area =%9lu ", p->pPars->Area );
1411  printf( "Edge =%9lu ", p->pPars->Edge );
1412  if ( p->pPars->fGenCnf )
1413  printf( "CNF =%9lu ", p->pPars->Clause );
1414  Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
1415  fflush( stdout );
1416 }
word Edge
Definition: gia.h:299
Jf_Par_t * pPars
Definition: giaMf.c:66
word Clause
Definition: gia.h:300
static abctime Abc_Clock()
Definition: abc_global.h:279
word Delay
Definition: gia.h:297
word Area
Definition: gia.h:298
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
abctime clkStart
Definition: giaMf.c:77
int fGenCnf
Definition: gia.h:284
int fVerbose
Definition: gia.h:291
void Mf_ManProfileTruths ( Mf_Man_t p)

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

Synopsis [Collect truth tables used by the mapper.]

Description []

SideEffects []

SeeAlso []

Definition at line 214 of file giaMf.c.

215 {
216  Vec_Int_t * vCounts;
217  int i, Entry, * pCut, Counter = 0;
218  vCounts = Vec_IntStart( Vec_IntSize(&p->vCnfSizes) );
219  Gia_ManForEachAndId( p->pGia, i )
220  {
221  if ( !Mf_ObjMapRefNum(p, i) )
222  continue;
223  pCut = Mf_ObjCutBest( p, i );
224  Vec_IntAddToEntry( vCounts, Abc_Lit2Var(Mf_CutFunc(pCut)), 1 );
225  }
226  Vec_IntForEachEntry( vCounts, Entry, i )
227  {
228  if ( Entry == 0 )
229  continue;
230  printf( "%6d : ", Counter++ );
231  printf( "%6d : ", i );
232  printf( "Occur = %4d ", Entry );
233  printf( "CNF size = %2d ", Vec_IntEntry(&p->vCnfSizes, i) );
235  }
236  Vec_IntFree( vCounts );
237 }
int nLutSize
Definition: gia.h:267
Jf_Par_t * pPars
Definition: giaMf.c:66
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * pGia
Definition: giaMf.c:65
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Counter
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Int_t vCnfSizes
Definition: giaMf.c:71
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Vec_Mem_t * vTtMem
Definition: giaMf.c:70
static int Mf_ManSaveCuts ( Mf_Man_t p,
Mf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 672 of file giaMf.c.

673 {
674  int i, * pPlace, iCur, nInts = 1;
675  for ( i = 0; i < nCuts; i++ )
676  nInts += pCuts[i]->nLeaves + 1;
677  if ( (p->iCur & 0xFFFF) + nInts > 0xFFFF )
678  p->iCur = ((p->iCur >> 16) + 1) << 16;
679  if ( Vec_PtrSize(&p->vPages) == (p->iCur >> 16) )
680  Vec_PtrPush( &p->vPages, ABC_ALLOC(int, (1<<16)) );
681  iCur = p->iCur; p->iCur += nInts;
682  pPlace = Mf_ManCutSet( p, iCur );
683  *pPlace++ = nCuts;
684  for ( i = 0; i < nCuts; i++ )
685  {
686  *pPlace++ = Mf_CutSetBoth(pCuts[i]->nLeaves, pCuts[i]->iFunc);
687  memcpy( pPlace, pCuts[i]->pLeaves, sizeof(int) * pCuts[i]->nLeaves );
688  pPlace += pCuts[i]->nLeaves;
689  }
690  return iCur;
691 }
static int * Mf_ManCutSet(Mf_Man_t *p, int i)
Definition: giaMf.c:83
char * memcpy()
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Mf_CutSetBoth(int n, int f)
Definition: giaMf.c:93
int iCur
Definition: giaMf.c:73
Vec_Ptr_t vPages
Definition: giaMf.c:69
unsigned nLeaves
Definition: giaMf.c:48
void Mf_ManSetDefaultPars ( Jf_Par_t pPars)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1380 of file giaMf.c.

1381 {
1382  memset( pPars, 0, sizeof(Jf_Par_t) );
1383  pPars->nLutSize = 6;
1384  pPars->nCutNum = 8;
1385  pPars->nProcNum = 0;
1386  pPars->nRounds = 2;
1387  pPars->nRoundsEla = 1;
1388  pPars->nRelaxRatio = 0;
1389  pPars->nCoarseLimit = 3;
1390  pPars->nAreaTuner = 1;
1391  pPars->nVerbLimit = 5;
1392  pPars->DelayTarget = -1;
1393  pPars->fAreaOnly = 0;
1394  pPars->fOptEdge = 1;
1395  pPars->fCoarsen = 1;
1396  pPars->fCutMin = 0;
1397  pPars->fGenCnf = 0;
1398  pPars->fPureAig = 0;
1399  pPars->fVerbose = 0;
1400  pPars->fVeryVerbose = 0;
1401  pPars->nLutSizeMax = MF_LEAF_MAX;
1402  pPars->nCutNumMax = MF_CUT_MAX;
1403 }
char * memset()
int nCutNum
Definition: gia.h:268
int nLutSize
Definition: gia.h:267
int nProcNum
Definition: gia.h:269
int nAreaTuner
Definition: gia.h:274
int nCutNumMax
Definition: gia.h:294
int fAreaOnly
Definition: gia.h:277
int nVerbLimit
Definition: gia.h:275
int fVeryVerbose
Definition: gia.h:292
int nRelaxRatio
Definition: gia.h:272
int fOptEdge
Definition: gia.h:278
Definition: gia.h:265
#define MF_CUT_MAX
Definition: giaMf.c:35
#define MF_LEAF_MAX
DECLARATIONS ///.
Definition: giaMf.c:34
int nRounds
Definition: gia.h:270
int fPureAig
Definition: gia.h:287
int fCutMin
Definition: gia.h:282
int fGenCnf
Definition: gia.h:284
int nLutSizeMax
Definition: gia.h:293
int nRoundsEla
Definition: gia.h:271
int DelayTarget
Definition: gia.h:276
int nCoarseLimit
Definition: gia.h:273
int fVerbose
Definition: gia.h:291
int fCoarsen
Definition: gia.h:281
void Mf_ManSetFlowRefs ( Gia_Man_t p,
Vec_Int_t vRefs 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1077 of file giaMf.c.

1078 {
1079  int fDiscount = 1;
1080  Gia_Obj_t * pObj, * pCtrl, * pData0, * pData1;
1081  int i, Id;
1082  Vec_IntFill( vRefs, Gia_ManObjNum(p), 0 );
1083  Gia_ManForEachAnd( p, pObj, i )
1084  {
1085  if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
1086  Vec_IntAddToEntry( vRefs, Gia_ObjFaninId0(pObj, i), 1 );
1087  if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
1088  Vec_IntAddToEntry( vRefs, Gia_ObjFaninId1(pObj, i), 1 );
1089  if ( p->pMuxes )
1090  {
1091  if ( Gia_ObjIsMuxId(p, i) && Gia_ObjIsAnd(Gia_ObjFanin2(p, pObj)) )
1092  Vec_IntAddToEntry( vRefs, Gia_ObjFaninId2(p, i), 1 );
1093  }
1094  else if ( fDiscount && Gia_ObjIsMuxType(pObj) ) // discount XOR/MUX
1095  {
1096  pCtrl = Gia_Regular(Gia_ObjRecognizeMux(pObj, &pData1, &pData0));
1097  pData0 = Gia_Regular(pData0);
1098  pData1 = Gia_Regular(pData1);
1099  if ( Gia_ObjIsAnd(pCtrl) )
1100  Vec_IntAddToEntry( vRefs, Gia_ObjId(p, pCtrl), -1 );
1101  if ( pData0 == pData1 && Gia_ObjIsAnd(pData0) )
1102  Vec_IntAddToEntry( vRefs, Gia_ObjId(p, pData0), -1 );
1103  }
1104  }
1105  Gia_ManForEachCoDriverId( p, Id, i )
1106  if ( Gia_ObjIsAnd(Gia_ManObj(p, Id)) )
1107  Vec_IntAddToEntry( vRefs, Id, 1 );
1108  for ( i = 0; i < Vec_IntSize(vRefs); i++ )
1109  Vec_IntUpdateEntry( vRefs, i, 1 );
1110 }
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
unsigned * pMuxes
Definition: gia.h:104
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
for(p=first;p->value< newval;p=p->next)
Definition: gia.h:75
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition: gia.h:1032
static int Gia_ObjIsMuxId(Gia_Man_t *p, int iObj)
Definition: gia.h:424
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntUpdateEntry(Vec_Int_t *p, int i, int Value)
Definition: vecInt.h:468
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static Gia_Obj_t * Gia_ObjFanin2(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:456
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
static int Gia_ObjFaninId2(Gia_Man_t *p, int ObjId)
Definition: gia.h:462
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
int Mf_ManSetMapRefs ( Mf_Man_t p)

Definition at line 1111 of file giaMf.c.

1112 {
1113  float Coef = 1.0 / (1.0 + (p->Iter + 1) * (p->Iter + 1));
1114  int * pCut, i, k, Id;
1115  // compute delay
1116  int Delay = 0;
1117  Gia_ManForEachCoDriverId( p->pGia, Id, i )
1118  Delay = Abc_MaxInt( Delay, Mf_ManObj(p, Id)->Delay );
1119  // check delay target
1120  if ( p->pPars->DelayTarget == -1 && p->pPars->nRelaxRatio )
1121  p->pPars->DelayTarget = (int)((float)Delay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
1122  if ( p->pPars->DelayTarget != -1 )
1123  {
1124  if ( Delay < p->pPars->DelayTarget + 0.01 )
1125  Delay = p->pPars->DelayTarget;
1126  else if ( p->pPars->nRelaxRatio == 0 )
1127  Abc_Print( 0, "Relaxing user-specified delay target from %d to %d.\n", p->pPars->DelayTarget, Delay );
1128  }
1129  p->pPars->Delay = Delay;
1130  // check references
1131 // Gia_ManForEachAndId( p->pGia, i )
1132 // assert( Mf_ManObj(p, i)->nMapRefs == 0 );
1133  // compute area and edges
1134  if ( !p->fUseEla )
1135  Gia_ManForEachCoDriverId( p->pGia, Id, i )
1136  Mf_ObjMapRefInc( p, Id );
1137  p->pPars->Area = p->pPars->Edge = p->pPars->Clause = 0;
1138  Gia_ManForEachAndReverseId( p->pGia, i )
1139  {
1140  if ( !Mf_ObjMapRefNum(p, i) )
1141  continue;
1142  pCut = Mf_ObjCutBest( p, i );
1143  if ( !p->fUseEla )
1144  for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1145  Mf_ObjMapRefInc( p, pCut[k] );
1146  p->pPars->Edge += Mf_CutSize(pCut);
1147  p->pPars->Area++;
1148  if ( p->pPars->fGenCnf )
1149  p->pPars->Clause += Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1150  }
1151  // blend references
1152  for ( i = 0; i < Gia_ManObjNum(p->pGia); i++ )
1153  p->pLfObjs[i].nFlowRefs = Coef * p->pLfObjs[i].nFlowRefs + (1.0 - Coef) * Abc_MaxFloat(1, p->pLfObjs[i].nMapRefs);
1154 // p->pLfObjs[i]. = 0.2 * p->pLfObjs[i]. + 0.8 * Abc_MaxFloat(1, p->pLfObjs[i].nMapRefs);
1155  return p->pPars->Area;
1156 }
static int Mf_ObjMapRefInc(Mf_Man_t *p, int i)
Definition: giaMf.c:88
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
Gia_Man_t * pGia
Definition: giaMf.c:65
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
#define Gia_ManForEachAndReverseId(p, i)
Definition: gia.h:1012
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition: gia.h:1032
if(last==0)
Definition: sparse_int.h:34
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Mf_CutArea(Mf_Man_t *p, int nLeaves, int iFunc)
Definition: giaMf.c:940
static int Mf_CutFunc(int *pCut)
Definition: giaMf.c:92
static int Mf_ObjMapRefNum(Mf_Man_t *p, int i)
Definition: giaMf.c:87
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Iter
Definition: giaMf.c:74
int Mf_ManTruthCanonicize ( word t,
int  nVars 
)

Definition at line 118 of file giaMf.c.

119 {
120  word Temp, Best = *t;
121  int r, i, Config = 0;
122  for ( r = 0; r < 1; r++ )
123  {
124  if ( Best > (Temp = ~Best) )
125  Best = Temp, Config ^= (1 << nVars);
126  for ( i = 0; i < nVars; i++ )
127  if ( Best > (Temp = Abc_Tt6Flip(Best, i)) )
128  Best = Temp, Config ^= (1 << i);
129  }
130  *t = Best;
131  if ( s_vTtMem == NULL )
132  s_vTtMem = Vec_MemAllocForTT( 6, 0 );
134  s_nCalls++;
135  return Config;
136 }
static int s_nCalls
FUNCTION DEFINITIONS ///.
Definition: giaMf.c:116
static Vec_Mem_t * Vec_MemAllocForTT(int nVars, int fCompl)
Definition: vecMem.h:378
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word Abc_Tt6Flip(word Truth, int iVar)
Definition: utilTruth.h:1126
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
static Vec_Mem_t * s_vTtMem
Definition: giaMf.c:117
Vec_Wrd_t* Mf_ManTruthCollect ( int  Limit)

Definition at line 148 of file giaMf.c.

149 {
150  extern Vec_Wrd_t * Mpm_ManGetTruthWithCnf( int Limit );
151  int * pPerm = Extra_PermSchedule( 6 );
152  int * pComp = Extra_GreyCodeSchedule( 6 );
153  Vec_Wrd_t * vTruths = Mpm_ManGetTruthWithCnf( Limit );
154  Vec_Wrd_t * vResult = Vec_WrdAlloc( 1 << 20 );
155  word uTruth, tCur, tTemp1, tTemp2;
156  int i, p, c, k;
157  Vec_WrdForEachEntry( vTruths, uTruth, k )
158  {
159  for ( i = 0; i < 2; i++ )
160  {
161  tCur = i ? ~uTruth : uTruth;
162  tTemp1 = tCur;
163  for ( p = 0; p < 720; p++ )
164  {
165  tTemp2 = tCur;
166  for ( c = 0; c < 64; c++ )
167  {
168  tCur = Abc_Tt6Flip( tCur, pComp[c] );
169  Vec_WrdPush( vResult, tCur );
170  }
171  assert( tTemp2 == tCur );
172  tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[p] );
173  }
174  assert( tTemp1 == tCur );
175  }
176  }
177  ABC_FREE( pPerm );
178  ABC_FREE( pComp );
179  printf( "Original = %d. ", Vec_WrdSize(vTruths) );
180  Vec_WrdFree( vTruths );
181  printf( "Total = %d. ", Vec_WrdSize(vResult) );
182  vTruths = Vec_WrdUniqifyHash( vResult, 1 );
183  Vec_WrdFree( vResult );
184  printf( "Unique = %d. ", Vec_WrdSize(vTruths) );
185  Vec_WrdForEachEntry( vTruths, uTruth, k )
186  {
187  Mf_ManTruthCanonicize( &uTruth, 6 );
188  Vec_WrdWriteEntry( vTruths, k, uTruth );
189  }
190  vResult = Vec_WrdUniqifyHash( vTruths, 1 );
191  Vec_WrdFree( vTruths );
192  printf( "Unique = %d. \n", Vec_WrdSize(vResult) );
193  return vResult;
194 }
int * Extra_GreyCodeSchedule(int n)
int * Extra_PermSchedule(int n)
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
static word Abc_Tt6SwapAdjacent(word Truth, int iVar)
Definition: utilTruth.h:1186
static Vec_Wrd_t * Vec_WrdUniqifyHash(Vec_Wrd_t *vData, int nWordSize)
Definition: vecWrd.h:1098
Vec_Wrd_t * Mpm_ManGetTruthWithCnf(int Limit)
FUNCTION DEFINITIONS ///.
Definition: mpmDsd.c:644
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
static word Abc_Tt6Flip(word Truth, int iVar)
Definition: utilTruth.h:1126
static int pPerm[13719]
Definition: rwrTemp.c:32
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
int Mf_ManTruthCanonicize(word *t, int nVars)
Definition: giaMf.c:118
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
int Mf_ManTruthCount ( )

Definition at line 195 of file giaMf.c.

196 {
197  Vec_Wrd_t * vTruths = Mf_ManTruthCollect( 10 );
198  int RetValue = Vec_WrdSize( vTruths );
199  Vec_WrdFree( vTruths );
200  return RetValue;
201 }
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
Vec_Wrd_t * Mf_ManTruthCollect(int Limit)
Definition: giaMf.c:148
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
void Mf_ManTruthQuit ( )

Definition at line 137 of file giaMf.c.

138 {
139  if ( s_vTtMem == NULL )
140  return;
141  printf( "TT = %d (%.2f %%)\n", Vec_MemEntryNum(s_vTtMem), 100.0 * Vec_MemEntryNum(s_vTtMem) / s_nCalls );
144  s_vTtMem = NULL;
145  s_nCalls = 0;
146 }
static int s_nCalls
FUNCTION DEFINITIONS ///.
Definition: giaMf.c:116
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
static void Vec_MemFree(Vec_Mem_t *p)
Definition: utilMem.c:93
static void Vec_MemHashFree(Vec_Mem_t *p)
Definition: vecMem.h:311
static Vec_Mem_t * s_vTtMem
Definition: giaMf.c:117
static void Mf_ObjComputeBestCut ( Mf_Man_t p,
int  iObj 
)
inlinestatic

Definition at line 1523 of file giaMf.c.

1524 {
1525  Mf_Obj_t * pBest = Mf_ManObj(p, iObj);
1526  int * pCutSet = Mf_ObjCutSet( p, iObj );
1527  int * pCut, * pCutBest = NULL;
1528  int Value1 = -1, Value2 = -1;
1529  int i, Time = 0, TimeBest = ABC_INFINITY;
1530  float Flow, FlowBest = ABC_INFINITY;
1531  if ( p->fUseEla && pBest->nMapRefs )
1532  Value1 = Mf_CutDeref_rec( p, Mf_ObjCutBest(p, iObj) );
1533  Mf_SetForEachCut( pCutSet, pCut, i )
1534  {
1535  assert( !Mf_CutIsTriv(pCut, iObj) );
1536  assert( Mf_CutSize(pCut) <= p->pPars->nLutSize );
1537  Flow = p->fUseEla ? Mf_CutAreaDerefed(p, pCut) : Mf_CutFlow(p, pCut, &Time);
1538  if ( pCutBest == NULL || FlowBest > Flow || (FlowBest == Flow && TimeBest > Time) )
1539  pCutBest = pCut, FlowBest = Flow, TimeBest = Time;
1540  }
1541  assert( pCutBest != NULL );
1542  if ( p->fUseEla && pBest->nMapRefs )
1543  Value1 = Mf_CutRef_rec( p, pCutBest );
1544  else
1545  pBest->nMapRefs = 0;
1546  assert( Value1 >= Value2 );
1547  if ( p->fUseEla )
1548  Mf_CutFlow( p, pCutBest, &TimeBest );
1549  pBest->Delay = TimeBest;
1550  pBest->Flow = FlowBest / Mf_ManObj(p, iObj)->nFlowRefs;
1551  Mf_ObjSetBestCut( pCutSet, pCutBest );
1552 // Mf_CutPrint( Mf_ObjCutBest(p, iObj) ); printf( "\n" );
1553 }
float nFlowRefs
Definition: giaMf.c:56
int Mf_CutDeref_rec(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1494
int nLutSize
Definition: gia.h:267
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
Jf_Par_t * pPars
Definition: giaMf.c:66
static void Mf_ObjSetBestCut(int *pCuts, int *pCut)
Definition: giaMf.c:692
float Flow
Definition: giaMf.c:55
unsigned nMapRefs
Definition: giaMf.c:58
static int Mf_CutIsTriv(int *pCut, int i)
Definition: giaMf.c:94
static float Mf_CutFlow(Mf_Man_t *p, int *pCut, int *pTime)
Definition: giaMf.c:1509
int Mf_CutRef_rec(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1486
static int * Mf_ObjCutSet(Mf_Man_t *p, int i)
Definition: giaMf.c:84
int fUseEla
Definition: giaMf.c:75
#define Mf_SetForEachCut(pList, pCut, i)
Definition: giaMf.c:96
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int * Mf_ObjCutBest(Mf_Man_t *p, int i)
Definition: giaMf.c:85
static int Mf_CutAreaDerefed(Mf_Man_t *p, int *pCut)
Definition: giaMf.c:1502
unsigned Delay
Definition: giaMf.c:57
static int* Mf_ObjCutBest ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 85 of file giaMf.c.

85 { return Mf_ObjCutSet(p, i) + 1; }
static int * Mf_ObjCutSet(Mf_Man_t *p, int i)
Definition: giaMf.c:84
static int* Mf_ObjCutSet ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 84 of file giaMf.c.

84 { return Mf_ManCutSet(p, Mf_ManObj(p, i)->iCutSet); }
static int * Mf_ManCutSet(Mf_Man_t *p, int i)
Definition: giaMf.c:83
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int Mf_ObjMapRefDec ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 89 of file giaMf.c.

89 { return --Mf_ManObj(p, i)->nMapRefs; }
unsigned nMapRefs
Definition: giaMf.c:58
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int Mf_ObjMapRefInc ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 88 of file giaMf.c.

88 { return Mf_ManObj(p, i)->nMapRefs++; }
unsigned nMapRefs
Definition: giaMf.c:58
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int Mf_ObjMapRefNum ( Mf_Man_t p,
int  i 
)
inlinestatic

Definition at line 87 of file giaMf.c.

87 { return Mf_ManObj(p, i)->nMapRefs; }
unsigned nMapRefs
Definition: giaMf.c:58
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
void Mf_ObjMergeOrder ( Mf_Man_t p,
int  iObj 
)

Definition at line 966 of file giaMf.c.

967 {
968  Mf_Cut_t pCuts0[MF_CUT_MAX], pCuts1[MF_CUT_MAX], pCuts[MF_CUT_MAX], * pCutsR[MF_CUT_MAX];
969  Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
970  Mf_Obj_t * pBest = Mf_ManObj(p, iObj);
971  int nLutSize = p->pPars->nLutSize;
972  int nCutNum = p->pPars->nCutNum;
973  int nCuts0 = Mf_ManPrepareCuts(pCuts0, p, Gia_ObjFaninId0(pObj, iObj), 1);
974  int nCuts1 = Mf_ManPrepareCuts(pCuts1, p, Gia_ObjFaninId1(pObj, iObj), 1);
975  int fComp0 = Gia_ObjFaninC0(pObj);
976  int fComp1 = Gia_ObjFaninC1(pObj);
977  int iSibl = Gia_ObjSibl(p->pGia, iObj);
978  Mf_Cut_t * pCut0, * pCut1, * pCut0Lim = pCuts0 + nCuts0, * pCut1Lim = pCuts1 + nCuts1;
979  int i, nCutsR = 0;
980  for ( i = 0; i < nCutNum; i++ )
981  pCutsR[i] = pCuts + i;
982  if ( iSibl )
983  {
984  Mf_Cut_t pCuts2[MF_CUT_MAX];
985  Gia_Obj_t * pObjE = Gia_ObjSiblObj(p->pGia, iObj);
986  int fCompE = Gia_ObjPhase(pObj) ^ Gia_ObjPhase(pObjE);
987  int nCuts2 = Mf_ManPrepareCuts(pCuts2, p, iSibl, 0);
988  Mf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
989  for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
990  {
991  *pCutsR[nCutsR] = *pCut2;
992  if ( pCutsR[nCutsR]->iFunc >= 0 )
993  pCutsR[nCutsR]->iFunc = Abc_LitNotCond( pCutsR[nCutsR]->iFunc, fCompE );
994  Mf_CutParams( p, pCutsR[nCutsR], pBest->nFlowRefs );
995  nCutsR = Mf_SetAddCut( pCutsR, nCutsR, nCutNum );
996  }
997  }
998  if ( Gia_ObjIsMuxId(p->pGia, iObj) )
999  {
1000  Mf_Cut_t pCuts2[MF_CUT_MAX];
1001  int nCuts2 = Mf_ManPrepareCuts(pCuts2, p, Gia_ObjFaninId2(p->pGia, iObj), 1);
1002  int fComp2 = Gia_ObjFaninC2(p->pGia, pObj);
1003  Mf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
1004  p->CutCount[0] += nCuts0 * nCuts1 * nCuts2;
1005  for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
1006  for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
1007  for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
1008  {
1009  if ( Mf_CutCountBits(pCut0->Sign | pCut1->Sign | pCut2->Sign) > nLutSize )
1010  continue;
1011  p->CutCount[1]++;
1012  if ( !Mf_CutMergeOrderMux(pCut0, pCut1, pCut2, pCutsR[nCutsR], nLutSize) )
1013  continue;
1014  if ( Mf_SetLastCutIsContained(pCutsR, nCutsR) )
1015  continue;
1016  p->CutCount[2]++;
1017  if ( p->pPars->fCutMin && Mf_CutComputeTruthMux(p, pCut0, pCut1, pCut2, fComp0, fComp1, fComp2, pCutsR[nCutsR]) )
1018  pCutsR[nCutsR]->Sign = Mf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
1019  Mf_CutParams( p, pCutsR[nCutsR], pBest->nFlowRefs );
1020  nCutsR = Mf_SetAddCut( pCutsR, nCutsR, nCutNum );
1021  }
1022  }
1023  else
1024  {
1025  int fIsXor = Gia_ObjIsXor(pObj);
1026  p->CutCount[0] += nCuts0 * nCuts1;
1027  for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
1028  for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
1029  {
1030  if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nLutSize && Mf_CutCountBits(pCut0->Sign | pCut1->Sign) > nLutSize )
1031  continue;
1032  p->CutCount[1]++;
1033  if ( !Mf_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nLutSize) )
1034  continue;
1035  if ( Mf_SetLastCutIsContained(pCutsR, nCutsR) )
1036  continue;
1037  p->CutCount[2]++;
1038  if ( p->pPars->fCutMin && Mf_CutComputeTruth(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
1039  pCutsR[nCutsR]->Sign = Mf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
1040  Mf_CutParams( p, pCutsR[nCutsR], pBest->nFlowRefs );
1041  nCutsR = Mf_SetAddCut( pCutsR, nCutsR, nCutNum );
1042  }
1043  }
1044  // debug printout
1045  if ( 0 )
1046 // if ( iObj % 1000 == 0 )
1047 // if ( iObj == 474 )
1048  {
1049  printf( "*** Obj = %d FlowRefs = %.2f MapRefs = %2d\n", iObj, pBest->nFlowRefs, pBest->nMapRefs );
1050  for ( i = 0; i < nCutsR; i++ )
1051  Mf_CutPrint( p, pCutsR[i] );
1052  printf( "\n" );
1053  }
1054  // store the cutset
1055  pBest->Flow = pCutsR[0]->Flow;
1056  pBest->Delay = pCutsR[0]->Delay;
1057  pBest->iCutSet = Mf_ManSaveCuts( p, pCutsR, nCutsR );
1058  // verify
1059  assert( nCutsR > 0 && nCutsR < nCutNum );
1060 // assert( Mf_SetCheckArray(pCutsR, nCutsR) );
1061  p->nCutCounts[pCutsR[0]->nLeaves]++;
1062  p->CutCount[3] += nCutsR;
1063 }
float nFlowRefs
Definition: giaMf.c:56
static int Gia_ObjFaninC2(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:453
static int Gia_ObjPhase(Gia_Obj_t *pObj)
Definition: gia.h:415
static int Mf_CutComputeTruthMux(Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, Mf_Cut_t *pCutR)
Definition: giaMf.c:563
static Gia_Obj_t * Gia_ObjSiblObj(Gia_Man_t *p, int Id)
Definition: gia.h:894
int nCutNum
Definition: gia.h:268
int nLutSize
Definition: gia.h:267
int nCutCounts[MF_LEAF_MAX+1]
Definition: giaMf.c:79
static int Mf_CutComputeTruth(Mf_Man_t *p, Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, int fCompl0, int fCompl1, Mf_Cut_t *pCutR, int fIsXor)
Definition: giaMf.c:510
float Flow
Definition: giaMf.c:46
static int Mf_SetLastCutIsContained(Mf_Cut_t **pCuts, int nCuts)
Definition: giaMf.c:886
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
Jf_Par_t * pPars
Definition: giaMf.c:66
static int Mf_SetAddCut(Mf_Cut_t **pCuts, int nCuts, int nCutNum)
Definition: giaMf.c:932
Gia_Man_t * pGia
Definition: giaMf.c:65
static void Mf_CutPrint(Mf_Man_t *p, Mf_Cut_t *pCut)
Definition: giaMf.c:631
static int Mf_CutMergeOrder(Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCut, int nLutSize)
Definition: giaMf.c:773
float Flow
Definition: giaMf.c:55
double CutCount[4]
Definition: giaMf.c:78
unsigned nMapRefs
Definition: giaMf.c:58
static int Mf_ManPrepareCuts(Mf_Cut_t *pCuts, Mf_Man_t *p, int iObj, int fAddUnit)
Definition: giaMf.c:650
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
word Sign
Definition: giaMf.c:44
static int Mf_CutCountBits(word i)
Definition: giaMf.c:607
static int Mf_CutMergeOrderMux(Mf_Cut_t *pCut0, Mf_Cut_t *pCut1, Mf_Cut_t *pCut2, Mf_Cut_t *pCut, int nLutSize)
Definition: giaMf.c:836
static int Gia_ObjSibl(Gia_Man_t *p, int Id)
Definition: gia.h:893
static int Gia_ObjIsMuxId(Gia_Man_t *p, int iObj)
Definition: gia.h:424
static int Gia_ObjIsXor(Gia_Obj_t *pObj)
Definition: gia.h:423
#define MF_CUT_MAX
Definition: giaMf.c:35
unsigned iFunc
Definition: giaMf.c:47
static void Mf_CutParams(Mf_Man_t *p, Mf_Cut_t *pCut, float FlowRefs)
Definition: giaMf.c:950
static word Mf_CutGetSign(int *pLeaves, int nLeaves)
Definition: giaMf.c:614
int fCutMin
Definition: gia.h:282
int Delay
Definition: giaMf.c:45
unsigned nLeaves
Definition: giaMf.c:48
#define assert(ex)
Definition: util_old.h:213
static Mf_Obj_t * Mf_ManObj(Mf_Man_t *p, int i)
Definition: giaMf.c:82
static int Gia_ObjFaninId2(Gia_Man_t *p, int ObjId)
Definition: gia.h:462
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
int iCutSet
Definition: giaMf.c:54
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Mf_ManSaveCuts(Mf_Man_t *p, Mf_Cut_t **pCuts, int nCuts)
Definition: giaMf.c:672
unsigned Delay
Definition: giaMf.c:57
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static void Mf_ObjSetBestCut ( int *  pCuts,
int *  pCut 
)
inlinestatic

Definition at line 692 of file giaMf.c.

693 {
694  assert( pCuts < pCut );
695  if ( ++pCuts < pCut )
696  {
697  int pTemp[MF_CUT_MAX*(MF_LEAF_MAX+2)];
698  int nBlock = pCut - pCuts;
699  int nSize = Mf_CutSize(pCut) + 1;
700  memmove( pTemp, pCuts, sizeof(int) * nBlock );
701  memmove( pCuts, pCut, sizeof(int) * nSize );
702  memmove( pCuts + nSize, pTemp, sizeof(int) * nBlock );
703  }
704 }
static int Mf_CutSize(int *pCut)
Definition: giaMf.c:91
char * memmove()
#define MF_CUT_MAX
Definition: giaMf.c:35
#define MF_LEAF_MAX
DECLARATIONS ///.
Definition: giaMf.c:34
#define assert(ex)
Definition: util_old.h:213
static int Mf_SetAddCut ( Mf_Cut_t **  pCuts,
int  nCuts,
int  nCutNum 
)
inlinestatic

Definition at line 932 of file giaMf.c.

933 {
934  if ( nCuts == 0 )
935  return 1;
936  nCuts = Mf_SetLastCutContainsArea(pCuts, nCuts);
937  Mf_SetSortByArea( pCuts, nCuts );
938  return Abc_MinInt( nCuts + 1, nCutNum - 1 );
939 }
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static int Mf_SetLastCutContainsArea(Mf_Cut_t **pCuts, int nCuts)
Definition: giaMf.c:894
static void Mf_SetSortByArea(Mf_Cut_t **pCuts, int nCuts)
Definition: giaMf.c:922
static int Mf_SetCheckArray ( Mf_Cut_t **  ppCuts,
int  nCuts 
)
inlinestatic

Definition at line 733 of file giaMf.c.

734 {
735  Mf_Cut_t * pCut0, * pCut1;
736  int i, k, m, n, Value;
737  assert( nCuts > 0 );
738  for ( i = 0; i < nCuts; i++ )
739  {
740  pCut0 = ppCuts[i];
741  assert( pCut0->nLeaves <= MF_LEAF_MAX );
742  assert( pCut0->Sign == Mf_CutGetSign(pCut0->pLeaves, pCut0->nLeaves) );
743  // check duplicates
744  for ( m = 0; m < (int)pCut0->nLeaves; m++ )
745  for ( n = m + 1; n < (int)pCut0->nLeaves; n++ )
746  assert( pCut0->pLeaves[m] < pCut0->pLeaves[n] );
747  // check pairs
748  for ( k = 0; k < nCuts; k++ )
749  {
750  pCut1 = ppCuts[k];
751  if ( pCut0 == pCut1 )
752  continue;
753  // check containments
754  Value = Mf_CutCheck( pCut0, pCut1 );
755  assert( Value == 0 );
756  }
757  }
758  return 1;
759 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
word Sign
Definition: giaMf.c:44
static int Mf_CutCheck(Mf_Cut_t *pBase, Mf_Cut_t *pCut)
Definition: giaMf.c:717
#define MF_LEAF_MAX
DECLARATIONS ///.
Definition: giaMf.c:34
static word Mf_CutGetSign(int *pLeaves, int nLeaves)
Definition: giaMf.c:614
unsigned nLeaves
Definition: giaMf.c:48
#define assert(ex)
Definition: util_old.h:213
static int Mf_SetCutIsContainedOrder ( Mf_Cut_t pBase,
Mf_Cut_t pCut 
)
inlinestatic

Definition at line 860 of file giaMf.c.

861 {
862  int i, nSizeB = pBase->nLeaves;
863  int k, nSizeC = pCut->nLeaves;
864  if ( nSizeB == nSizeC )
865  {
866  for ( i = 0; i < nSizeB; i++ )
867  if ( pBase->pLeaves[i] != pCut->pLeaves[i] )
868  return 0;
869  return 1;
870  }
871  assert( nSizeB > nSizeC );
872  if ( nSizeC == 0 )
873  return 1;
874  for ( i = k = 0; i < nSizeB; i++ )
875  {
876  if ( pBase->pLeaves[i] > pCut->pLeaves[k] )
877  return 0;
878  if ( pBase->pLeaves[i] == pCut->pLeaves[k] )
879  {
880  if ( ++k == nSizeC )
881  return 1;
882  }
883  }
884  return 0;
885 }
int pLeaves[MF_LEAF_MAX+1]
Definition: giaMf.c:49
unsigned nLeaves
Definition: giaMf.c:48
#define assert(ex)
Definition: util_old.h:213
static int Mf_SetLastCutContainsArea ( Mf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 894 of file giaMf.c.

895 {
896  int i, k, fChanges = 0;
897  for ( i = 0; i < nCuts; i++ )
898  if ( pCuts[nCuts]->nLeaves < pCuts[i]->nLeaves && (pCuts[nCuts]->Sign & pCuts[i]->Sign) == pCuts[nCuts]->Sign && Mf_SetCutIsContainedOrder(pCuts[i], pCuts[nCuts]) )
899  pCuts[i]->nLeaves = MF_NO_LEAF, fChanges = 1;
900  if ( !fChanges )
901  return nCuts;
902  for ( i = k = 0; i <= nCuts; i++ )
903  {
904  if ( pCuts[i]->nLeaves == MF_NO_LEAF )
905  continue;
906  if ( k < i )
907  ABC_SWAP( Mf_Cut_t *, pCuts[k], pCuts[i] );
908  k++;
909  }
910  return k - 1;
911 }
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Mf_SetCutIsContainedOrder(Mf_Cut_t *pBase, Mf_Cut_t *pCut)
Definition: giaMf.c:860
#define MF_NO_LEAF
Definition: giaMf.c:37
unsigned nLeaves
Definition: giaMf.c:48
static int Mf_SetLastCutIsContained ( Mf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 886 of file giaMf.c.

887 {
888  int i;
889  for ( i = 0; i < nCuts; i++ )
890  if ( pCuts[i]->nLeaves <= pCuts[nCuts]->nLeaves && (pCuts[i]->Sign & pCuts[nCuts]->Sign) == pCuts[i]->Sign && Mf_SetCutIsContainedOrder(pCuts[nCuts], pCuts[i]) )
891  return 1;
892  return 0;
893 }
static int Mf_SetCutIsContainedOrder(Mf_Cut_t *pBase, Mf_Cut_t *pCut)
Definition: giaMf.c:860
static void Mf_SetSortByArea ( Mf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

= 1 )

Definition at line 922 of file giaMf.c.

923 {
924  int i;
925  for ( i = nCuts; i > 0; i-- )
926  {
927  if ( Mf_CutCompareArea(pCuts[i - 1], pCuts[i]) < 0 )//!= 1 )
928  return;
929  ABC_SWAP( Mf_Cut_t *, pCuts[i - 1], pCuts[i] );
930  }
931 }
static int Mf_CutCompareArea(Mf_Cut_t *pCut0, Mf_Cut_t *pCut1)
Definition: giaMf.c:912
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218

Variable Documentation

int s_nCalls = 0
static

FUNCTION DEFINITIONS ///.

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

Synopsis [Computing truth tables of useful DSD classes of 6-functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 116 of file giaMf.c.

Vec_Mem_t* s_vTtMem = NULL
static

Definition at line 117 of file giaMf.c.