abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaNf.c File Reference
#include <float.h>
#include "gia.h"
#include "misc/st/st.h"
#include "map/mio/mio.h"
#include "misc/util/utilTruth.h"
#include "misc/extra/extra.h"
#include "base/main/main.h"
#include "misc/vec/vecMem.h"
#include "misc/vec/vecWec.h"
#include "opt/dau/dau.h"

Go to the source code of this file.

Data Structures

struct  Nf_Cut_t_
 
struct  Nf_Mat_t_
 
struct  Nf_Obj_t_
 
struct  Nf_Man_t_
 

Macros

#define NF_LEAF_MAX   6
 DECLARATIONS ///. More...
 
#define NF_CUT_MAX   32
 
#define NF_NO_LEAF   31
 
#define NF_INFINITY   FLT_MAX
 
#define Nf_SetForEachCut(pList, pCut, i)   for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Nf_CutSize(pCut) + 1 )
 
#define Nf_ObjForEachCut(pCuts, i, nCuts)   for ( i = 0, i < nCuts; i++ )
 
#define Nf_CutForEachLit(pCut, Conf, iLit, i)   for ( i = 0; i < Nf_CutSize(pCut) && (iLit = Abc_Lit2LitV(Nf_CutLeaves(pCut), Nf_CutConfLit(Conf, i))); i++ )
 
#define Nf_CutForEachVar(pCut, Conf, iVar, c, i)   for ( i = 0; i < Nf_CutSize(pCut) && (iVar = Nf_CutLeaves(pCut)[Nf_CutConfVar(Conf, i)]) && ((c = Nf_CutConfC(Conf, i)), 1); i++ )
 

Typedefs

typedef struct Nf_Cut_t_ Nf_Cut_t
 
typedef struct Nf_Mat_t_ Nf_Mat_t
 
typedef struct Nf_Obj_t_ Nf_Obj_t
 
typedef struct Nf_Man_t_ Nf_Man_t
 

Enumerations

enum  { NF_ANDOR = 1, NF_XOR = 2, NF_PRIME = 3 }
 

Functions

static Nf_Obj_tNf_ManObj (Nf_Man_t *p, int i)
 
static Mio_Cell_tNf_ManCell (Nf_Man_t *p, int i)
 
static int * Nf_ManCutSet (Nf_Man_t *p, int i)
 
static int Nf_ObjCutSetId (Nf_Man_t *p, int i)
 
static int * Nf_ObjCutSet (Nf_Man_t *p, int i)
 
static int Nf_ObjHasCuts (Nf_Man_t *p, int i)
 
static int * Nf_ObjCutBest (Nf_Man_t *p, int i)
 
static int Nf_ObjCutUseless (Nf_Man_t *p, int TruthId)
 
static float Nf_ObjCutFlow (Nf_Man_t *p, int i)
 
static int Nf_ObjCutDelay (Nf_Man_t *p, int i)
 
static void Nf_ObjSetCutFlow (Nf_Man_t *p, int i, float a)
 
static void Nf_ObjSetCutDelay (Nf_Man_t *p, int i, int d)
 
static int Nf_ObjMapRefNum (Nf_Man_t *p, int i, int c)
 
static int Nf_ObjMapRefInc (Nf_Man_t *p, int i, int c)
 
static int Nf_ObjMapRefDec (Nf_Man_t *p, int i, int c)
 
static float Nf_ObjFlowRefs (Nf_Man_t *p, int i, int c)
 
static float Nf_ObjRequired (Nf_Man_t *p, int i, int c)
 
static void Nf_ObjSetRequired (Nf_Man_t *p, int i, int c, float f)
 
static void Nf_ObjUpdateRequired (Nf_Man_t *p, int i, int c, float f)
 
static Nf_Mat_tNf_ObjMatchD (Nf_Man_t *p, int i, int c)
 
static Nf_Mat_tNf_ObjMatchA (Nf_Man_t *p, int i, int c)
 
static Nf_Mat_tNf_ObjMatchBest (Nf_Man_t *p, int i, int c)
 
static int Nf_CutSize (int *pCut)
 
static int Nf_CutFunc (int *pCut)
 
static int * Nf_CutLeaves (int *pCut)
 
static int Nf_CutSetBoth (int n, int f)
 
static int Nf_CutIsTriv (int *pCut, int i)
 
static int Nf_CutHandle (int *pCutSet, int *pCut)
 
static int * Nf_CutFromHandle (int *pCutSet, int h)
 
static int Nf_CutConfLit (int Conf, int i)
 
static int Nf_CutConfVar (int Conf, int i)
 
static int Nf_CutConfC (int Conf, int i)
 
static void Nf_StoSelectSort (int *pArray, int nSize, Mio_Cell_t *pCell)
 FUNCTION DEFINITIONS ///. More...
 
static void Nf_StoSelectSortLit (int *pArray, int nSize, Mio_Cell_t *pCell)
 
void Nf_StoCreateGateAdd (Nf_Man_t *pMan, word uTruth, int *pFans, int nFans, int CellId, int Type)
 
int Nf_StoBuildDsdAnd_rec (Nf_Man_t *pMan, Mio_Cell_t *pCell, char *pStr, char **p, int *pMatches, int pGroups[NF_LEAF_MAX][NF_LEAF_MAX], int *nGroupSizes, int *pnGroups)
 
int Nf_StoBuildDsdAnd (Nf_Man_t *pMan, Mio_Cell_t *pCell, char *p)
 
int Nf_StoCheckDsdAnd_rec (char *pStr, char **p, int *pMatches)
 
int Nf_StoCheckDsdAnd (char *p)
 
int Nf_StoCheckDsdXor_rec (char *pStr, char **p, int *pMatches)
 
int Nf_StoCheckDsdXor (char *p)
 
void Nf_StoCreateGateNonDsd (Nf_Man_t *pMan, Mio_Cell_t *pCell, int **pComp, int **pPerm, int *pnPerms)
 
void Nf_StoCreateGateDsd (Nf_Man_t *pMan, Mio_Cell_t *pCell, int **pComp, int **pPerm, int *pnPerms)
 
void Nf_StoDeriveMatches (Nf_Man_t *p, int fVerbose)
 
void Nf_StoPrintOne (Nf_Man_t *p, int Count, int t, int i, Mio_Cell_t *pC, int Type, int fCompl, char *pInfo)
 
void Nf_StoPrint (Nf_Man_t *p, int fVerbose)
 
Nf_Man_tNf_StoCreate (Gia_Man_t *pGia, Jf_Par_t *pPars)
 
void Nf_StoDelete (Nf_Man_t *p)
 
static int Nf_CutComputeTruth6 (Nf_Man_t *p, Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, int fCompl0, int fCompl1, Nf_Cut_t *pCutR, int fIsXor)
 
static int Nf_CutComputeTruthMux6 (Nf_Man_t *p, Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, Nf_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, Nf_Cut_t *pCutR)
 
static int Nf_CutCountBits (word i)
 
static word Nf_CutGetSign (int *pLeaves, int nLeaves)
 
static int Nf_CutCreateUnit (Nf_Cut_t *p, int i)
 
static void Nf_Cutprintf (Nf_Man_t *p, Nf_Cut_t *pCut)
 
static int Nf_ManPrepareCuts (Nf_Cut_t *pCuts, Nf_Man_t *p, int iObj, int fAddUnit)
 
static int Nf_ManSaveCuts (Nf_Man_t *p, Nf_Cut_t **pCuts, int nCuts, int fUseful)
 
static int Nf_ManCountUseful (Nf_Cut_t **pCuts, int nCuts)
 
static int Nf_ManCountMatches (Nf_Man_t *p, Nf_Cut_t **pCuts, int nCuts)
 
static int Nf_CutCheck (Nf_Cut_t *pBase, Nf_Cut_t *pCut)
 
static int Nf_SetCheckArray (Nf_Cut_t **ppCuts, int nCuts)
 
static int Nf_CutMergeOrder (Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, Nf_Cut_t *pCut, int nLutSize)
 
static int Nf_CutMergeOrderMux (Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, Nf_Cut_t *pCut2, Nf_Cut_t *pCut, int nLutSize)
 
static int Nf_SetCutIsContainedOrder (Nf_Cut_t *pBase, Nf_Cut_t *pCut)
 
static int Nf_SetLastCutIsContained (Nf_Cut_t **pCuts, int nCuts)
 
static int Nf_SetLastCutContainsArea (Nf_Cut_t **pCuts, int nCuts)
 
static int Nf_CutCompareArea (Nf_Cut_t *pCut0, Nf_Cut_t *pCut1)
 
static void Nf_SetSortByArea (Nf_Cut_t **pCuts, int nCuts)
 
static int Nf_SetAddCut (Nf_Cut_t **pCuts, int nCuts, int nCutNum)
 
static int Nf_CutArea (Nf_Man_t *p, int nLeaves)
 
static void Nf_CutParams (Nf_Man_t *p, Nf_Cut_t *pCut, float FlowRefs)
 
void Nf_ObjMergeOrder (Nf_Man_t *p, int iObj)
 
void Nf_ManComputeCuts (Nf_Man_t *p)
 
void Nf_ManPrintStats (Nf_Man_t *p, char *pTitle)
 
void Nf_ManPrintInit (Nf_Man_t *p)
 
void Nf_ManPrintQuit (Nf_Man_t *p)
 
float Nf_MatchDeref2_rec (Nf_Man_t *p, int i, int c, Nf_Mat_t *pM)
 
float Nf_MatchRef2_rec (Nf_Man_t *p, int i, int c, Nf_Mat_t *pM, Vec_Int_t *vBackup)
 
float Nf_MatchRef2Area (Nf_Man_t *p, int i, int c, Nf_Mat_t *pM)
 
void Nf_ManCutMatchprintf (Nf_Man_t *p, int iObj, int fCompl, Nf_Mat_t *pM)
 
void Nf_ManCutMatchOne (Nf_Man_t *p, int iObj, int *pCut, int *pCutSet)
 
static void Nf_ObjPrepareCi (Nf_Man_t *p, int iObj)
 
static void Nf_ObjPrepareBuf (Nf_Man_t *p, Gia_Obj_t *pObj)
 
static float Nf_CutRequired (Nf_Man_t *p, Nf_Mat_t *pM, int *pCutSet)
 
static void Nf_ObjComputeRequired (Nf_Man_t *p, int iObj)
 
void Nf_ManCutMatch (Nf_Man_t *p, int iObj)
 
void Nf_ManComputeMapping (Nf_Man_t *p)
 
void Nf_ManSetMapRefsGate (Nf_Man_t *p, int iObj, float Required, Nf_Mat_t *pM)
 
int Nf_ManSetMapRefs (Nf_Man_t *p)
 
Gia_Man_tNf_ManDeriveMapping (Nf_Man_t *p)
 
void Nf_ManUpdateStats (Nf_Man_t *p)
 
void Nf_ManSetDefaultPars (Jf_Par_t *pPars)
 
Gia_Man_tNf_ManPerformMapping (Gia_Man_t *pGia, Jf_Par_t *pPars)
 

Macro Definition Documentation

#define NF_CUT_MAX   32

Definition at line 39 of file giaNf.c.

#define Nf_CutForEachLit (   pCut,
  Conf,
  iLit,
 
)    for ( i = 0; i < Nf_CutSize(pCut) && (iLit = Abc_Lit2LitV(Nf_CutLeaves(pCut), Nf_CutConfLit(Conf, i))); i++ )

Definition at line 158 of file giaNf.c.

#define Nf_CutForEachVar (   pCut,
  Conf,
  iVar,
  c,
 
)    for ( i = 0; i < Nf_CutSize(pCut) && (iVar = Nf_CutLeaves(pCut)[Nf_CutConfVar(Conf, i)]) && ((c = Nf_CutConfC(Conf, i)), 1); i++ )

Definition at line 159 of file giaNf.c.

#define NF_INFINITY   FLT_MAX

Definition at line 41 of file giaNf.c.

#define NF_LEAF_MAX   6

DECLARATIONS ///.

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

FileName [giaNf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Standard-cell mapper.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 38 of file giaNf.c.

#define NF_NO_LEAF   31

Definition at line 40 of file giaNf.c.

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

Definition at line 157 of file giaNf.c.

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

Definition at line 156 of file giaNf.c.

Typedef Documentation

typedef struct Nf_Cut_t_ Nf_Cut_t

Definition at line 45 of file giaNf.c.

typedef struct Nf_Man_t_ Nf_Man_t

Definition at line 72 of file giaNf.c.

typedef struct Nf_Mat_t_ Nf_Mat_t

Definition at line 56 of file giaNf.c.

typedef struct Nf_Obj_t_ Nf_Obj_t

Definition at line 67 of file giaNf.c.

Enumeration Type Documentation

anonymous enum
Enumerator
NF_ANDOR 
NF_XOR 
NF_PRIME 

Definition at line 43 of file giaNf.c.

43 { NF_ANDOR = 1, NF_XOR = 2, NF_PRIME = 3 };
Definition: giaNf.c:43
Definition: giaNf.c:43
Definition: giaNf.c:43

Function Documentation

static int Nf_CutArea ( Nf_Man_t p,
int  nLeaves 
)
inlinestatic

Definition at line 1094 of file giaNf.c.

1095 {
1096  if ( nLeaves < 2 )
1097  return 0;
1098  return nLeaves + p->pPars->nAreaTuner;
1099 }
int nAreaTuner
Definition: gia.h:274
Jf_Par_t * pPars
Definition: giaNf.c:77
static int Nf_CutCheck ( Nf_Cut_t pBase,
Nf_Cut_t pCut 
)
inlinestatic

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

Synopsis [Check correctness of cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 869 of file giaNf.c.

870 {
871  int nSizeB = pBase->nLeaves;
872  int nSizeC = pCut->nLeaves;
873  int i, * pB = pBase->pLeaves;
874  int k, * pC = pCut->pLeaves;
875  for ( i = 0; i < nSizeC; i++ )
876  {
877  for ( k = 0; k < nSizeB; k++ )
878  if ( pC[i] == pB[k] )
879  break;
880  if ( k == nSizeB )
881  return 0;
882  }
883  return 1;
884 }
unsigned nLeaves
Definition: giaNf.c:53
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
static int Nf_CutCompareArea ( Nf_Cut_t pCut0,
Nf_Cut_t pCut1 
)
inlinestatic

Definition at line 1064 of file giaNf.c.

1065 {
1066  if ( pCut0->Useless < pCut1->Useless ) return -1;
1067  if ( pCut0->Useless > pCut1->Useless ) return 1;
1068  if ( pCut0->Flow < pCut1->Flow ) return -1;
1069  if ( pCut0->Flow > pCut1->Flow ) return 1;
1070  if ( pCut0->Delay < pCut1->Delay ) return -1;
1071  if ( pCut0->Delay > pCut1->Delay ) return 1;
1072  if ( pCut0->nLeaves < pCut1->nLeaves ) return -1;
1073  if ( pCut0->nLeaves > pCut1->nLeaves ) return 1;
1074  return 0;
1075 }
float Flow
Definition: giaNf.c:50
unsigned nLeaves
Definition: giaNf.c:53
int Delay
Definition: giaNf.c:49
unsigned Useless
Definition: giaNf.c:52
static int Nf_CutComputeTruth6 ( Nf_Man_t p,
Nf_Cut_t pCut0,
Nf_Cut_t pCut1,
int  fCompl0,
int  fCompl1,
Nf_Cut_t pCutR,
int  fIsXor 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 704 of file giaNf.c.

705 {
706 // extern int Nf_ManTruthCanonicize( word * t, int nVars );
707  int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
708  word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
709  word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
710  if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
711  if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
712  t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
713  t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
714  t = fIsXor ? t0 ^ t1 : t0 & t1;
715  if ( (fCompl = (int)(t & 1)) ) t = ~t;
716  pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
717  assert( (int)(t & 1) == 0 );
718  truthId = Vec_MemHashInsert(p->vTtMem, &t);
719  pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
720  pCutR->Useless = Nf_ObjCutUseless( p, truthId );
721  assert( (int)pCutR->nLeaves <= nOldSupp );
722  return (int)pCutR->nLeaves < nOldSupp;
723 }
static word Abc_Tt6Expand(word t, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1345
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
unsigned nLeaves
Definition: giaNf.c:53
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Nf_ObjCutUseless(Nf_Man_t *p, int TruthId)
Definition: giaNf.c:114
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned iFunc
Definition: giaNf.c:51
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
unsigned Useless
Definition: giaNf.c:52
static int Nf_CutComputeTruthMux6 ( Nf_Man_t p,
Nf_Cut_t pCut0,
Nf_Cut_t pCut1,
Nf_Cut_t pCutC,
int  fCompl0,
int  fCompl1,
int  fComplC,
Nf_Cut_t pCutR 
)
inlinestatic

Definition at line 724 of file giaNf.c.

725 {
726  int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
727  word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
728  word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
729  word tC = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCutC->iFunc));
730  if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
731  if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
732  if ( Abc_LitIsCompl(pCutC->iFunc) ^ fComplC ) tC = ~tC;
733  t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
734  t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
735  tC = Abc_Tt6Expand( tC, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
736  t = (tC & t1) | (~tC & t0);
737  if ( (fCompl = (int)(t & 1)) ) t = ~t;
738  pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
739  assert( (int)(t & 1) == 0 );
740  truthId = Vec_MemHashInsert(p->vTtMem, &t);
741  pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
742  pCutR->Useless = Nf_ObjCutUseless( p, truthId );
743  assert( (int)pCutR->nLeaves <= nOldSupp );
744  return (int)pCutR->nLeaves < nOldSupp;
745 }
static word Abc_Tt6Expand(word t, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1345
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
unsigned nLeaves
Definition: giaNf.c:53
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Nf_ObjCutUseless(Nf_Man_t *p, int TruthId)
Definition: giaNf.c:114
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned iFunc
Definition: giaNf.c:51
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
unsigned Useless
Definition: giaNf.c:52
static int Nf_CutConfC ( int  Conf,
int  i 
)
inlinestatic

Definition at line 154 of file giaNf.c.

154 { return Abc_LitIsCompl( Nf_CutConfLit(Conf, i) ); }
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Nf_CutConfLit(int Conf, int i)
Definition: giaNf.c:152
static int Nf_CutConfLit ( int  Conf,
int  i 
)
inlinestatic

Definition at line 152 of file giaNf.c.

152 { return 15 & (Conf >> (i << 2)); }
static int Nf_CutConfVar ( int  Conf,
int  i 
)
inlinestatic

Definition at line 153 of file giaNf.c.

153 { return Abc_Lit2Var( Nf_CutConfLit(Conf, i) ); }
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Nf_CutConfLit(int Conf, int i)
Definition: giaNf.c:152
static int Nf_CutCountBits ( word  i)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 759 of file giaNf.c.

760 {
761  i = i - ((i >> 1) & 0x5555555555555555);
762  i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
763  i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
764  return (i*(0x0101010101010101))>>56;
765 }
static int Nf_CutCreateUnit ( Nf_Cut_t p,
int  i 
)
inlinestatic

Definition at line 773 of file giaNf.c.

774 {
775  p->Delay = 0;
776  p->Flow = 0;
777  p->iFunc = 2;
778  p->nLeaves = 1;
779  p->pLeaves[0] = i;
780  p->Sign = ((word)1) << (i & 0x3F);
781  return 1;
782 }
float Flow
Definition: giaNf.c:50
unsigned nLeaves
Definition: giaNf.c:53
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int Delay
Definition: giaNf.c:49
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
unsigned iFunc
Definition: giaNf.c:51
word Sign
Definition: giaNf.c:48
static int* Nf_CutFromHandle ( int *  pCutSet,
int  h 
)
inlinestatic

Definition at line 151 of file giaNf.c.

151 { assert( h > 0 ); return pCutSet + h; }
#define assert(ex)
Definition: util_old.h:213
static int Nf_CutFunc ( int *  pCut)
inlinestatic

Definition at line 146 of file giaNf.c.

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

Definition at line 766 of file giaNf.c.

767 {
768  word Sign = 0; int i;
769  for ( i = 0; i < nLeaves; i++ )
770  Sign |= ((word)1) << (pLeaves[i] & 0x3F);
771  return Sign;
772 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Nf_CutHandle ( int *  pCutSet,
int *  pCut 
)
inlinestatic

Definition at line 150 of file giaNf.c.

150 { assert( pCut > pCutSet ); return pCut - pCutSet; }
#define assert(ex)
Definition: util_old.h:213
static int Nf_CutIsTriv ( int *  pCut,
int  i 
)
inlinestatic

Definition at line 149 of file giaNf.c.

149 { return Nf_CutSize(pCut) == 1 && pCut[1] == i; }
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
static int* Nf_CutLeaves ( int *  pCut)
inlinestatic

Definition at line 147 of file giaNf.c.

147 { return pCut + 1; }
static int Nf_CutMergeOrder ( Nf_Cut_t pCut0,
Nf_Cut_t pCut1,
Nf_Cut_t pCut,
int  nLutSize 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 925 of file giaNf.c.

926 {
927  int nSize0 = pCut0->nLeaves;
928  int nSize1 = pCut1->nLeaves;
929  int i, * pC0 = pCut0->pLeaves;
930  int k, * pC1 = pCut1->pLeaves;
931  int c, * pC = pCut->pLeaves;
932  // the case of the largest cut sizes
933  if ( nSize0 == nLutSize && nSize1 == nLutSize )
934  {
935  for ( i = 0; i < nSize0; i++ )
936  {
937  if ( pC0[i] != pC1[i] ) return 0;
938  pC[i] = pC0[i];
939  }
940  pCut->nLeaves = nLutSize;
941  pCut->iFunc = -1;
942  pCut->Sign = pCut0->Sign | pCut1->Sign;
943  return 1;
944  }
945  // compare two cuts with different numbers
946  i = k = c = 0;
947  if ( nSize0 == 0 ) goto FlushCut1;
948  if ( nSize1 == 0 ) goto FlushCut0;
949  while ( 1 )
950  {
951  if ( c == nLutSize ) return 0;
952  if ( pC0[i] < pC1[k] )
953  {
954  pC[c++] = pC0[i++];
955  if ( i >= nSize0 ) goto FlushCut1;
956  }
957  else if ( pC0[i] > pC1[k] )
958  {
959  pC[c++] = pC1[k++];
960  if ( k >= nSize1 ) goto FlushCut0;
961  }
962  else
963  {
964  pC[c++] = pC0[i++]; k++;
965  if ( i >= nSize0 ) goto FlushCut1;
966  if ( k >= nSize1 ) goto FlushCut0;
967  }
968  }
969 
970 FlushCut0:
971  if ( c + nSize0 > nLutSize + i ) return 0;
972  while ( i < nSize0 )
973  pC[c++] = pC0[i++];
974  pCut->nLeaves = c;
975  pCut->iFunc = -1;
976  pCut->Sign = pCut0->Sign | pCut1->Sign;
977  return 1;
978 
979 FlushCut1:
980  if ( c + nSize1 > nLutSize + k ) return 0;
981  while ( k < nSize1 )
982  pC[c++] = pC1[k++];
983  pCut->nLeaves = c;
984  pCut->iFunc = -1;
985  pCut->Sign = pCut0->Sign | pCut1->Sign;
986  return 1;
987 }
unsigned nLeaves
Definition: giaNf.c:53
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
unsigned iFunc
Definition: giaNf.c:51
word Sign
Definition: giaNf.c:48
static int Nf_CutMergeOrderMux ( Nf_Cut_t pCut0,
Nf_Cut_t pCut1,
Nf_Cut_t pCut2,
Nf_Cut_t pCut,
int  nLutSize 
)
inlinestatic

Definition at line 988 of file giaNf.c.

989 {
990  int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
991  int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
992  int x2, i2 = 0, nSize2 = pCut2->nLeaves, * pC2 = pCut2->pLeaves;
993  int xMin, c = 0, * pC = pCut->pLeaves;
994  while ( 1 )
995  {
996  x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
997  x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
998  x2 = (i2 == nSize2) ? ABC_INFINITY : pC2[i2];
999  xMin = Abc_MinInt( Abc_MinInt(x0, x1), x2 );
1000  if ( xMin == ABC_INFINITY ) break;
1001  if ( c == nLutSize ) return 0;
1002  pC[c++] = xMin;
1003  if (x0 == xMin) i0++;
1004  if (x1 == xMin) i1++;
1005  if (x2 == xMin) i2++;
1006  }
1007  pCut->nLeaves = c;
1008  pCut->iFunc = -1;
1009  pCut->Sign = pCut0->Sign | pCut1->Sign | pCut2->Sign;
1010  return 1;
1011 }
unsigned nLeaves
Definition: giaNf.c:53
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
unsigned iFunc
Definition: giaNf.c:51
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
word Sign
Definition: giaNf.c:48
static void Nf_CutParams ( Nf_Man_t p,
Nf_Cut_t pCut,
float  FlowRefs 
)
inlinestatic

Definition at line 1100 of file giaNf.c.

1101 {
1102  int i, nLeaves = pCut->nLeaves;
1103  assert( nLeaves <= p->pPars->nLutSize );
1104  pCut->Delay = 0;
1105  pCut->Flow = 0;
1106  for ( i = 0; i < nLeaves; i++ )
1107  {
1108  pCut->Delay = Abc_MaxInt( pCut->Delay, Nf_ObjCutDelay(p, pCut->pLeaves[i]) );
1109  pCut->Flow += Nf_ObjCutFlow(p, pCut->pLeaves[i]);
1110  }
1111  pCut->Delay += (int)(nLeaves > 1);
1112  pCut->Flow = (pCut->Flow + Nf_CutArea(p, nLeaves)) / FlowRefs;
1113 }
float Flow
Definition: giaNf.c:50
static int Nf_CutArea(Nf_Man_t *p, int nLeaves)
Definition: giaNf.c:1094
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
unsigned nLeaves
Definition: giaNf.c:53
static float Nf_ObjCutFlow(Nf_Man_t *p, int i)
Definition: giaNf.c:116
int Delay
Definition: giaNf.c:49
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
#define assert(ex)
Definition: util_old.h:213
static int Nf_ObjCutDelay(Nf_Man_t *p, int i)
Definition: giaNf.c:117
static void Nf_Cutprintf ( Nf_Man_t p,
Nf_Cut_t pCut 
)
inlinestatic

Definition at line 783 of file giaNf.c.

784 {
785  int i, nDigits = Abc_Base10Log(Gia_ManObjNum(p->pGia));
786  printf( "%d {", pCut->nLeaves );
787  for ( i = 0; i < (int)pCut->nLeaves; i++ )
788  printf( " %*d", nDigits, pCut->pLeaves[i] );
789  for ( ; i < (int)p->pPars->nLutSize; i++ )
790  printf( " %*s", nDigits, " " );
791  printf( " } Useless = %d. D = %4d A = %9.4f F = %6d ",
792  pCut->Useless, pCut->Delay, pCut->Flow, pCut->iFunc );
793  if ( p->vTtMem )
795  else
796  printf( "\n" );
797 }
int nLutSize
Definition: gia.h:267
float Flow
Definition: giaNf.c:50
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
unsigned nLeaves
Definition: giaNf.c:53
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
Jf_Par_t * pPars
Definition: giaNf.c:77
int Delay
Definition: giaNf.c:49
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned iFunc
Definition: giaNf.c:51
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
Gia_Man_t * pGia
Definition: giaNf.c:76
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
unsigned Useless
Definition: giaNf.c:52
static float Nf_CutRequired ( Nf_Man_t p,
Nf_Mat_t pM,
int *  pCutSet 
)
inlinestatic

Definition at line 1698 of file giaNf.c.

1699 {
1700  Mio_Cell_t * pCell = Nf_ManCell( p, pM->Gate );
1701  int * pCut = Nf_CutFromHandle( pCutSet, pM->CutH );
1702  int * pFans = Nf_CutLeaves(pCut);
1703  int i, nFans = Nf_CutSize(pCut);
1704  float Arrival = 0, Required = 0;
1705  for ( i = 0; i < nFans; i++ )
1706  {
1707  int iLit = Nf_CutConfLit( pM->Conf, i );
1708  int iFanin = pFans[ Abc_Lit2Var(iLit) ];
1709  int fCompl = Abc_LitIsCompl( iLit );
1710  float Arr = Nf_ManObj(p, iFanin)->M[fCompl][0].D + pCell->Delays[i];
1711  float Req = Nf_ObjRequired(p, iFanin, fCompl);
1712  Arrival = Abc_MaxInt( Arrival, Arr );
1713  if ( Req < NF_INFINITY )
1714  Required = Abc_MaxInt( Required, Req + pCell->Delays[i] );
1715  }
1716  return Abc_MaxFloat( Required + 2*p->InvDelay, Arrival );
1717 }
unsigned CutH
Definition: giaNf.c:60
Nf_Mat_t M[2][2]
Definition: giaNf.c:70
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
#define NF_INFINITY
Definition: giaNf.c:41
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned Gate
Definition: giaNf.c:59
int Conf
Definition: giaNf.c:63
float InvDelay
Definition: giaNf.c:99
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
static int * Nf_CutLeaves(int *pCut)
Definition: giaNf.c:147
static int Nf_CutConfLit(int Conf, int i)
Definition: giaNf.c:152
float Delays[6]
Definition: mio.h:54
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
static float Nf_ObjRequired(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:125
float D
Definition: giaNf.c:64
static int Nf_CutSetBoth ( int  n,
int  f 
)
inlinestatic

Definition at line 148 of file giaNf.c.

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

Definition at line 145 of file giaNf.c.

145 { return pCut[0] & NF_NO_LEAF; }
#define NF_NO_LEAF
Definition: giaNf.c:40
static Mio_Cell_t* Nf_ManCell ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 108 of file giaNf.c.

108 { return p->pCells + i; }
Mio_Cell_t * pCells
Definition: giaNf.c:82
void Nf_ManComputeCuts ( Nf_Man_t p)

Definition at line 1216 of file giaNf.c.

1217 {
1218  Gia_Obj_t * pObj; int i, iFanin;
1219  Gia_ManForEachAnd( p->pGia, pObj, i )
1220  if ( Gia_ObjIsBuf(pObj) )
1221  {
1222  iFanin = Gia_ObjFaninId0(pObj, i);
1223  Nf_ObjSetCutFlow( p, i, Nf_ObjCutFlow(p, iFanin) );
1224  Nf_ObjSetCutDelay( p, i, Nf_ObjCutDelay(p, iFanin) );
1225  }
1226  else
1227  Nf_ObjMergeOrder( p, i );
1228 }
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
static void Nf_ObjSetCutFlow(Nf_Man_t *p, int i, float a)
Definition: giaNf.c:118
Definition: gia.h:75
if(last==0)
Definition: sparse_int.h:34
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static float Nf_ObjCutFlow(Nf_Man_t *p, int i)
Definition: giaNf.c:116
static void Nf_ObjSetCutDelay(Nf_Man_t *p, int i, int d)
Definition: giaNf.c:119
void Nf_ObjMergeOrder(Nf_Man_t *p, int iObj)
Definition: giaNf.c:1114
Gia_Man_t * pGia
Definition: giaNf.c:76
static int Nf_ObjCutDelay(Nf_Man_t *p, int i)
Definition: giaNf.c:117
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
void Nf_ManComputeMapping ( Nf_Man_t p)

Definition at line 1877 of file giaNf.c.

1878 {
1879  Gia_Obj_t * pObj; int i;
1880  Gia_ManForEachAnd( p->pGia, pObj, i )
1881  if ( Gia_ObjIsBuf(pObj) )
1882  Nf_ObjPrepareBuf( p, pObj );
1883  else
1884  Nf_ManCutMatch( p, i );
1885 }
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
Definition: gia.h:75
static void Nf_ObjPrepareBuf(Nf_Man_t *p, Gia_Obj_t *pObj)
Definition: giaNf.c:1674
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
void Nf_ManCutMatch(Nf_Man_t *p, int iObj)
Definition: giaNf.c:1726
Gia_Man_t * pGia
Definition: giaNf.c:76
static int Nf_ManCountMatches ( Nf_Man_t p,
Nf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 849 of file giaNf.c.

850 {
851  int i, Count = 0;
852  for ( i = 0; i < nCuts; i++ )
853  if ( !pCuts[i]->Useless )
854  Count += Vec_IntSize(Vec_WecEntry(p->vTt2Match, Abc_Lit2Var(pCuts[i]->iFunc))) / 2;
855  return Count;
856 }
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
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 Nf_ManCountUseful ( Nf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 842 of file giaNf.c.

843 {
844  int i, Count = 0;
845  for ( i = 0; i < nCuts; i++ )
846  Count += !pCuts[i]->Useless;
847  return Count;
848 }
void Nf_ManCutMatch ( Nf_Man_t p,
int  iObj 
)

Definition at line 1726 of file giaNf.c.

1727 {
1728  Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
1729  Nf_Mat_t * pDp = &pBest->M[0][0];
1730  Nf_Mat_t * pDn = &pBest->M[1][0];
1731  Nf_Mat_t * pAp = &pBest->M[0][1];
1732  Nf_Mat_t * pAn = &pBest->M[1][1];
1733  float FlowRefP = Nf_ObjFlowRefs(p, iObj, 0);
1734  float FlowRefN = Nf_ObjFlowRefs(p, iObj, 1);
1735  float Epsilon = p->pPars->Epsilon;
1736  int i, Index, * pCut, * pCutSet = Nf_ObjCutSet( p, iObj );
1737  float ValueBeg[2] = {0}, ValueEnd[2] = {0}, Required[2] = {0};
1738  if ( p->Iter )
1739  {
1740  Nf_ObjComputeRequired( p, iObj );
1741  Required[0] = Nf_ObjRequired( p, iObj, 0 );
1742  Required[1] = Nf_ObjRequired( p, iObj, 1 );
1743  }
1744  if ( p->fUseEla && Nf_ObjMapRefNum(p, iObj, 0) > 0 )
1745  ValueBeg[0] = Nf_MatchDeref2_rec( p, iObj, 0, Nf_ObjMatchBest(p, iObj, 0) );
1746  if ( p->fUseEla && Nf_ObjMapRefNum(p, iObj, 1) > 0 )
1747  ValueBeg[1] = Nf_MatchDeref2_rec( p, iObj, 1, Nf_ObjMatchBest(p, iObj, 1) );
1748  memset( pBest, 0, sizeof(Nf_Obj_t) );
1749  pDp->D = pDp->A = NF_INFINITY;
1750  pDn->D = pDn->A = NF_INFINITY;
1751  pAp->D = pAp->A = NF_INFINITY;
1752  pAn->D = pAn->A = NF_INFINITY;
1753  Nf_SetForEachCut( pCutSet, pCut, i )
1754  {
1755  if ( Abc_Lit2Var(Nf_CutFunc(pCut)) >= Vec_WecSize(p->vTt2Match) )
1756  continue;
1757  assert( !Nf_CutIsTriv(pCut, iObj) );
1758  assert( Nf_CutSize(pCut) <= p->pPars->nLutSize );
1760  Nf_ManCutMatchOne( p, iObj, pCut, pCutSet );
1761  }
1762 
1763 /*
1764  if ( 18687 == iObj )
1765  {
1766  printf( "Obj %6d (%f %f):\n", iObj, Required[0], Required[1] );
1767  Nf_ManCutMatchprintf( p, iObj, 0, &pBest->M[0][0] );
1768  Nf_ManCutMatchprintf( p, iObj, 0, &pBest->M[0][1] );
1769  Nf_ManCutMatchprintf( p, iObj, 1, &pBest->M[1][0] );
1770  Nf_ManCutMatchprintf( p, iObj, 1, &pBest->M[1][1] );
1771  printf( "\n" );
1772  }
1773 */
1774 
1775  // divide by ref count
1776  pDp->A /= FlowRefP;
1777  pAp->A /= FlowRefP;
1778  pDn->A /= FlowRefN;
1779  pAn->A /= FlowRefN;
1780 
1781  // add the inverters
1782  //assert( pDp->D < NF_INFINITY || pDn->D < NF_INFINITY );
1783  if ( pDp->D > pDn->D + p->InvDelay + Epsilon )
1784  {
1785  *pDp = *pDn;
1786  pDp->D += p->InvDelay;
1787  pDp->A += p->InvArea;
1788  pDp->fCompl = 1;
1789  if ( pAp->D == NF_INFINITY )
1790  *pAp = *pDp;
1791  //printf( "Using inverter to improve delay at node %d in phase %d.\n", iObj, 1 );
1792  }
1793  else if ( pDn->D > pDp->D + p->InvDelay + Epsilon )
1794  {
1795  *pDn = *pDp;
1796  pDn->D += p->InvDelay;
1797  pDn->A += p->InvArea;
1798  pDn->fCompl = 1;
1799  if ( pAn->D == NF_INFINITY )
1800  *pAn = *pDn;
1801  //printf( "Using inverter to improve delay at node %d in phase %d.\n", iObj, 0 );
1802  }
1803  //assert( pAp->A < NF_INFINITY || pAn->A < NF_INFINITY );
1804  // try replacing pos with neg
1805  if ( pAp->D == NF_INFINITY || (pAp->A > pAn->A + p->InvArea + Epsilon && pAn->D + p->InvDelay + Epsilon < Required[1]) )
1806  {
1807  assert( p->Iter > 0 );
1808  *pAp = *pAn;
1809  pAp->D += p->InvDelay;
1810  pAp->A += p->InvArea;
1811  pAp->fCompl = 1;
1812  if ( pDp->D == NF_INFINITY )
1813  *pDp = *pAp;
1814  //printf( "Using inverter to improve area at node %d in phase %d.\n", iObj, 1 );
1815  }
1816  // try replacing neg with pos
1817  else if ( pAn->D == NF_INFINITY || (pAn->A > pAp->A + p->InvArea + Epsilon && pAp->D + p->InvDelay + Epsilon < Required[0]) )
1818  {
1819  assert( p->Iter > 0 );
1820  *pAn = *pAp;
1821  pAn->D += p->InvDelay;
1822  pAn->A += p->InvArea;
1823  pAn->fCompl = 1;
1824  if ( pDn->D == NF_INFINITY )
1825  *pDn = *pAn;
1826  //printf( "Using inverter to improve area at node %d in phase %d.\n", iObj, 0 );
1827  }
1828 
1829  if ( pDp->D == NF_INFINITY )
1830  printf( "Object %d has pDp unassigned.\n", iObj );
1831  if ( pDn->D == NF_INFINITY )
1832  printf( "Object %d has pDn unassigned.\n", iObj );
1833  if ( pAp->D == NF_INFINITY )
1834  printf( "Object %d has pAp unassigned.\n", iObj );
1835  if ( pAn->D == NF_INFINITY )
1836  printf( "Object %d has pAn unassigned.\n", iObj );
1837 
1838  pDp->A = Abc_MinFloat( pDp->A, NF_INFINITY/1000000 );
1839  pDn->A = Abc_MinFloat( pDn->A, NF_INFINITY/1000000 );
1840  pAp->A = Abc_MinFloat( pAp->A, NF_INFINITY/1000000 );
1841  pAn->A = Abc_MinFloat( pAn->A, NF_INFINITY/1000000 );
1842 
1843  assert( pDp->D < NF_INFINITY );
1844  assert( pDn->D < NF_INFINITY );
1845  assert( pAp->D < NF_INFINITY );
1846  assert( pAn->D < NF_INFINITY );
1847 
1848  assert( pDp->A < NF_INFINITY );
1849  assert( pDn->A < NF_INFINITY );
1850  assert( pAp->A < NF_INFINITY );
1851  assert( pAn->A < NF_INFINITY );
1852 
1853  //printf( "%16f %16f %16f %16f\n", pDp->A, pDn->A, pAp->A, pAn->A );
1854 // assert ( pDp->A < 1000 );
1855 
1856  if ( p->fUseEla )
1857  {
1858  // set the first good cut
1859  Index = (pAp->D != NF_INFINITY && pAp->D < Nf_ObjRequired(p, iObj, 0) + Epsilon);
1860  assert( !pDp->fBest && !pAp->fBest );
1861  pBest->M[0][Index].fBest = 1;
1862  assert( pDp->fBest != pAp->fBest );
1863  // set the second good cut
1864  Index = (pAn->D != NF_INFINITY && pAn->D < Nf_ObjRequired(p, iObj, 1) + Epsilon);
1865  assert( !pDn->fBest && !pAn->fBest );
1866  pBest->M[1][Index].fBest = 1;
1867  assert( pDn->fBest != pAn->fBest );
1868  // reference if needed
1869  if ( Nf_ObjMapRefNum(p, iObj, 0) > 0 )
1870  ValueEnd[0] = Nf_MatchRef2_rec( p, iObj, 0, Nf_ObjMatchBest(p, iObj, 0), NULL );
1871  if ( Nf_ObjMapRefNum(p, iObj, 1) > 0 )
1872  ValueEnd[1] = Nf_MatchRef2_rec( p, iObj, 1, Nf_ObjMatchBest(p, iObj, 1), NULL );
1873 // assert( ValueBeg[0] > ValueEnd[0] - Epsilon );
1874 // assert( ValueBeg[1] > ValueEnd[1] - Epsilon );
1875  }
1876 }
char * memset()
unsigned fBest
Definition: giaNf.c:62
#define Nf_SetForEachCut(pList, pCut, i)
Definition: giaNf.c:156
static float Abc_MinFloat(float a, float b)
Definition: abc_global.h:244
int nLutSize
Definition: gia.h:267
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
int Iter
Definition: giaNf.c:96
float A
Definition: giaNf.c:65
Nf_Mat_t M[2][2]
Definition: giaNf.c:70
static void Nf_ObjComputeRequired(Nf_Man_t *p, int iObj)
Definition: giaNf.c:1718
static float Nf_ObjFlowRefs(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:124
#define NF_INFINITY
Definition: giaNf.c:41
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
float Nf_MatchDeref2_rec(Nf_Man_t *p, int i, int c, Nf_Mat_t *pM)
Definition: giaNf.c:1316
float Epsilon
Definition: gia.h:305
unsigned fCompl
Definition: giaNf.c:61
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static int Nf_CutFunc(int *pCut)
Definition: giaNf.c:146
float InvDelay
Definition: giaNf.c:99
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
Jf_Par_t * pPars
Definition: giaNf.c:77
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
int fUseEla
Definition: giaNf.c:97
static int Nf_CutIsTriv(int *pCut, int i)
Definition: giaNf.c:149
static Nf_Mat_t * Nf_ObjMatchBest(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:132
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
#define assert(ex)
Definition: util_old.h:213
float InvArea
Definition: giaNf.c:100
float Nf_MatchRef2_rec(Nf_Man_t *p, int i, int c, Nf_Mat_t *pM, Vec_Int_t *vBackup)
Definition: giaNf.c:1338
void Nf_ManCutMatchOne(Nf_Man_t *p, int iObj, int *pCut, int *pCutSet)
Definition: giaNf.c:1425
static float Nf_ObjRequired(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:125
float D
Definition: giaNf.c:64
void Nf_ManCutMatchOne ( Nf_Man_t p,
int  iObj,
int *  pCut,
int *  pCutSet 
)

Definition at line 1425 of file giaNf.c.

1426 {
1427  Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
1428  int * pFans = Nf_CutLeaves(pCut);
1429  int nFans = Nf_CutSize(pCut);
1430  int iFuncLit = Nf_CutFunc(pCut);
1431  int fComplExt = Abc_LitIsCompl(iFuncLit);
1432  float Epsilon = p->pPars->Epsilon;
1433  Vec_Int_t * vArr = Vec_WecEntry( p->vTt2Match, Abc_Lit2Var(iFuncLit) );
1434  int i, k, c, Info, Offset, iFanin, fComplF;
1435  float ArrivalD, ArrivalA;
1436  Nf_Mat_t * pD, * pA;
1437  // assign fanins matches
1438  Nf_Obj_t * pBestF[NF_LEAF_MAX];
1439  for ( i = 0; i < nFans; i++ )
1440  pBestF[i] = Nf_ManObj( p, pFans[i] );
1441  // special cases
1442  if ( nFans == 0 )
1443  {
1444  int Const = (iFuncLit == 1);
1445  assert( iFuncLit == 0 || iFuncLit == 1 );
1446  for ( c = 0; c < 2; c++ )
1447  {
1448  pD = Nf_ObjMatchD( p, iObj, c );
1449  pA = Nf_ObjMatchA( p, iObj, c );
1450  pD->D = pA->D = 0;
1451  pD->A = pA->A = p->pCells[c ^ Const].Area;
1452  pD->CutH = pA->CutH = Nf_CutHandle(pCutSet, pCut);
1453  pD->Gate = pA->Gate = c ^ Const;
1454  pD->Conf = pA->Conf = 0;
1455  }
1456  return;
1457  }
1458  if ( nFans == 1 )
1459  {
1460  int Const = (iFuncLit == 3);
1461  assert( iFuncLit == 2 || iFuncLit == 3 );
1462  for ( c = 0; c < 2; c++ )
1463  {
1464  pD = Nf_ObjMatchD( p, iObj, c );
1465  pA = Nf_ObjMatchA( p, iObj, c );
1466  pD->D = pA->D = pBestF[0]->M[c ^ !Const][0].D + p->pCells[2 + (c ^ Const)].Delays[0];
1467  pD->A = pA->A = pBestF[0]->M[c ^ !Const][0].A + p->pCells[2 + (c ^ Const)].Area;
1468  pD->CutH = pA->CutH = Nf_CutHandle(pCutSet, pCut);
1469  pD->Gate = pA->Gate = 2 + (c ^ Const);
1470  pD->Conf = pA->Conf = 0;
1471  }
1472  return;
1473  }
1474  // consider matches of this function
1475  Vec_IntForEachEntryDouble( vArr, Info, Offset, i )
1476  {
1477  Mio_Cell_t* pC = Nf_ManCell( p, Info >> 8 );
1478  int Type = (Info >> 4) & 15;
1479  int fCompl = (Info & 1) ^ fComplExt;
1480  char * pInfo = Vec_StrEntryP( p->vMemStore, Offset );
1481  float Required = Nf_ObjRequired( p, iObj, fCompl );
1482  Nf_Mat_t * pD = &pBest->M[fCompl][0];
1483  Nf_Mat_t * pA = &pBest->M[fCompl][1];
1484  assert( nFans == (int)pC->nFanins );
1485 // if ( iObj == 9 && fCompl == 0 && i == 192 )
1486 // Nf_StoPrintOne( p, -1, Abc_Lit2Var(iFuncLit), i, pC, Type, fCompl, pInfo );
1487  if ( Type == NF_PRIME )
1488  {
1489  float Area = pC->Area, Delay = 0;
1490  for ( k = 0; k < nFans; k++ )
1491  {
1492  iFanin = Abc_Lit2Var((int)pInfo[k]);
1493  fComplF = Abc_LitIsCompl((int)pInfo[k]);
1494  ArrivalD = pBestF[k]->M[fComplF][0].D;
1495  ArrivalA = pBestF[k]->M[fComplF][1].D;
1496  if ( ArrivalA + pC->Delays[iFanin] < Required + Epsilon && Required != NF_INFINITY )
1497  {
1498  Delay = Abc_MaxFloat( Delay, ArrivalA + pC->Delays[iFanin] );
1499  Area += pBestF[k]->M[fComplF][1].A;
1500  }
1501  else
1502  {
1503 // assert( ArrivalD + pC->Delays[iFanin] < Required + Epsilon );
1504  if ( pD->D < NF_INFINITY && pA->D < NF_INFINITY && ArrivalD + pC->Delays[iFanin] >= Required + Epsilon )
1505  break;
1506  Delay = Abc_MaxFloat( Delay, ArrivalD + pC->Delays[iFanin] );
1507  Area += pBestF[k]->M[fComplF][0].A;
1508  }
1509  }
1510  if ( k < nFans )
1511  continue;
1512  if ( p->fUseEla )
1513  {
1514  Nf_Mat_t Temp, * pTemp = &Temp;
1515  memset( pTemp, 0, sizeof(Nf_Mat_t) );
1516  pTemp->D = Delay;
1517  pTemp->A = Area;
1518  pTemp->CutH = Nf_CutHandle(pCutSet, pCut);
1519  pTemp->Gate = pC->Id;
1520  pTemp->Conf = 0;
1521  for ( k = 0; k < nFans; k++ )
1522 // pD->Conf |= ((int)pInfo[k] << (k << 2));
1523  pTemp->Conf |= (Abc_Var2Lit(k, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2));
1524  Area = Nf_MatchRef2Area(p, iObj, fCompl, pTemp );
1525  }
1526  // select best match
1527  if ( pD->D > Delay )//+ Epsilon )
1528  {
1529  pD->D = Delay;
1530  pD->A = Area;
1531  pD->CutH = Nf_CutHandle(pCutSet, pCut);
1532  pD->Gate = pC->Id;
1533  pD->Conf = 0;
1534  for ( k = 0; k < nFans; k++ )
1535 // pD->Conf |= ((int)pInfo[k] << (k << 2));
1536  pD->Conf |= (Abc_Var2Lit(k, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2));
1537  }
1538  if ( pA->A > Area )//+ Epsilon )
1539  {
1540  pA->D = Delay;
1541  pA->A = Area;
1542  pA->CutH = Nf_CutHandle(pCutSet, pCut);
1543  pA->Gate = pC->Id;
1544  pA->Conf = 0;
1545  for ( k = 0; k < nFans; k++ )
1546 // pA->Conf |= ((int)pInfo[k] << (k << 2));
1547  pA->Conf |= (Abc_Var2Lit(k, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2));
1548  }
1549  }
1550  else if ( Type == NF_XOR )
1551  {
1552  int m, nMints = 1 << nFans;
1553  for ( m = 0; m < nMints; m++ )
1554  {
1555  int fComplAll = fCompl;
1556  // collect best fanin delays
1557  float Area = pC->Area, Delay = 0;
1558  for ( k = 0; k < nFans; k++ )
1559  {
1560  assert( !Abc_LitIsCompl((int)pInfo[k]) );
1561  iFanin = Abc_Lit2Var((int)pInfo[k]);
1562  fComplF = ((m >> k) & 1);
1563  ArrivalD = pBestF[k]->M[fComplF][0].D;
1564  ArrivalA = pBestF[k]->M[fComplF][1].D;
1565  if ( ArrivalA + pC->Delays[iFanin] <= Required && Required != NF_INFINITY )
1566  {
1567  Delay = Abc_MaxFloat( Delay, ArrivalA + pC->Delays[iFanin] );
1568  Area += pBestF[k]->M[fComplF][1].A;
1569  }
1570  else
1571  {
1572  assert( ArrivalD + pC->Delays[iFanin] < Required + Epsilon );
1573  Delay = Abc_MaxFloat( Delay, ArrivalD + pC->Delays[iFanin] );
1574  Area += pBestF[k]->M[fComplF][0].A;
1575  }
1576  fComplAll ^= fComplF;
1577  }
1578  pD = &pBest->M[fComplAll][0];
1579  pA = &pBest->M[fComplAll][1];
1580  if ( pD->D > Delay )
1581  {
1582  pD->D = Delay;
1583  pD->A = Area;
1584  pD->CutH = Nf_CutHandle(pCutSet, pCut);
1585  pD->Gate = pC->Id;
1586  pD->Conf = 0;
1587  for ( k = 0; k < nFans; k++ )
1588 // pD->Conf |= Abc_LitNotCond((int)pInfo[k], (m >> k) & 1) << (k << 2);
1589  pD->Conf |= (Abc_Var2Lit(k, (m >> k) & 1) << (Abc_Lit2Var((int)pInfo[k]) << 2));
1590  }
1591  if ( pA->A > Area )
1592  {
1593  pA->D = Delay;
1594  pA->A = Area;
1595  pA->CutH = Nf_CutHandle(pCutSet, pCut);
1596  pA->Gate = pC->Id;
1597  pA->Conf = 0;
1598  for ( k = 0; k < nFans; k++ )
1599 // pA->Conf |= Abc_LitNotCond((int)pInfo[k], (m >> k) & 1) << (k << 2);
1600  pA->Conf |= (Abc_Var2Lit(k, (m >> k) & 1) << (Abc_Lit2Var((int)pInfo[k]) << 2));
1601  }
1602  }
1603  }
1604  else if ( Type == NF_ANDOR )
1605  {
1606  float Area = pC->Area, Delay = 0;
1607  int g, Conf = 0, nGroups = (int)*pInfo++;
1608  for ( g = 0; g < nGroups; g++ )
1609  {
1610  int nSizeAll = (int)*pInfo++;
1611  int nSizeNeg = (int)*pInfo++;
1612  float ArrivalD, ArrivalA;
1613  for ( k = 0; k < nSizeAll; k++ )
1614  {
1615  fComplF = Abc_LitIsCompl((int)pInfo[k]);
1616  iFanin = Abc_Lit2Var((int)pInfo[k]);
1617  ArrivalD = pBestF[k]->M[fComplF][0].D;
1618  ArrivalA = pBestF[k]->M[fComplF][1].D;
1619  if ( ArrivalA + pC->Delays[iFanin] < Required + Epsilon && Required != NF_INFINITY )
1620  {
1621  Delay = Abc_MaxFloat( Delay, ArrivalA + pC->Delays[iFanin] );
1622  Area += pBestF[k]->M[fComplF][1].A;
1623  }
1624  else
1625  {
1626  assert( ArrivalD + pC->Delays[iFanin] < Required + Epsilon );
1627  Delay = Abc_MaxFloat( Delay, ArrivalD + pC->Delays[iFanin] );
1628  Area += pBestF[k]->M[fComplF][0].A;
1629  }
1630 // Conf |= Abc_LitNotCond((int)pInfo[k], 0) << (iFanin << 2);
1631  Conf |= Abc_Var2Lit(iFanin, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2);
1632  }
1633  pInfo += nSizeAll; nSizeNeg = 0;
1634  }
1635  assert( Conf > 0 );
1636  if ( pD->D > Delay )
1637  {
1638  pD->D = Delay;
1639  pD->A = Area;
1640  pD->CutH = Nf_CutHandle(pCutSet, pCut);
1641  pD->Gate = pC->Id;
1642  pD->Conf = Conf;
1643  }
1644  if ( pA->A > Area )
1645  {
1646  pA->D = Delay;
1647  pA->A = Area;
1648  pA->CutH = Nf_CutHandle(pCutSet, pCut);
1649  pA->Gate = pC->Id;
1650  pA->Conf = Conf;
1651  }
1652  }
1653  }
1654 /*
1655  Nf_ManCutMatchprintf( p, iObj, 0, &pBest->M[0][0] );
1656  Nf_ManCutMatchprintf( p, iObj, 0, &pBest->M[0][1] );
1657  Nf_ManCutMatchprintf( p, iObj, 1, &pBest->M[1][0] );
1658  Nf_ManCutMatchprintf( p, iObj, 1, &pBest->M[1][1] );
1659 */
1660 }
char * memset()
Definition: giaNf.c:43
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
unsigned CutH
Definition: giaNf.c:60
Definition: giaNf.c:43
Vec_Str_t * vMemStore
Definition: giaNf.c:81
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
float A
Definition: giaNf.c:65
Nf_Mat_t M[2][2]
Definition: giaNf.c:70
#define NF_INFINITY
Definition: giaNf.c:41
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
float Epsilon
Definition: gia.h:305
Mio_Cell_t * pCells
Definition: giaNf.c:82
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned nFanins
Definition: mio.h:53
unsigned Id
Definition: mio.h:52
unsigned Gate
Definition: giaNf.c:59
int Conf
Definition: giaNf.c:63
static int Nf_CutFunc(int *pCut)
Definition: giaNf.c:146
float Nf_MatchRef2Area(Nf_Man_t *p, int i, int c, Nf_Mat_t *pM)
Definition: giaNf.c:1364
Definition: giaNf.c:43
Jf_Par_t * pPars
Definition: giaNf.c:77
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
int fUseEla
Definition: giaNf.c:97
float Area
Definition: mio.h:51
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
static Nf_Mat_t * Nf_ObjMatchA(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:130
static int * Nf_CutLeaves(int *pCut)
Definition: giaNf.c:147
#define assert(ex)
Definition: util_old.h:213
float Delays[6]
Definition: mio.h:54
static float Nf_ObjRequired(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:125
static char * Vec_StrEntryP(Vec_Str_t *p, int i)
Definition: vecStr.h:353
float D
Definition: giaNf.c:64
static int Nf_CutHandle(int *pCutSet, int *pCut)
Definition: giaNf.c:150
void Nf_ManCutMatchprintf ( Nf_Man_t p,
int  iObj,
int  fCompl,
Nf_Mat_t pM 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1388 of file giaNf.c.

1389 {
1390  Mio_Cell_t * pCell;
1391  int i, * pCut;
1392  printf( "%5d %d : ", iObj, fCompl );
1393  if ( pM->CutH == 0 )
1394  {
1395  printf( "Unassigned\n" );
1396  return;
1397  }
1398  pCell = Nf_ManCell( p, pM->Gate );
1399  pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, iObj), pM->CutH );
1400  printf( "D = %8.2f ", pM->D );
1401  printf( "A = %8.2f ", pM->A );
1402  printf( "C = %d ", pM->fCompl );
1403 // printf( "B = %d ", pM->fBest );
1404  printf( " " );
1405  printf( "Cut = {" );
1406  for ( i = 0; i < (int)pCell->nFanins; i++ )
1407  printf( "%5d ", Nf_CutLeaves(pCut)[i] );
1408  for ( ; i < 6; i++ )
1409  printf( " " );
1410  printf( "} " );
1411  printf( "%12s ", pCell->pName );
1412  printf( "%d ", pCell->nFanins );
1413  printf( "{" );
1414  for ( i = 0; i < (int)pCell->nFanins; i++ )
1415  printf( "%7.2f ", pCell->Delays[i] );
1416  for ( ; i < 6; i++ )
1417  printf( " " );
1418  printf( " } " );
1419  for ( i = 0; i < (int)pCell->nFanins; i++ )
1420  printf( "%2d ", Nf_CutConfLit(pM->Conf, i) );
1421  for ( ; i < 6; i++ )
1422  printf( " " );
1423  Dau_DsdPrintFromTruth( &pCell->uTruth, pCell->nFanins );
1424 }
char * pName
Definition: mio.h:49
unsigned CutH
Definition: giaNf.c:60
float A
Definition: giaNf.c:65
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
word uTruth
Definition: mio.h:50
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
unsigned fCompl
Definition: giaNf.c:61
unsigned nFanins
Definition: mio.h:53
unsigned Gate
Definition: giaNf.c:59
int Conf
Definition: giaNf.c:63
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static int * Nf_CutLeaves(int *pCut)
Definition: giaNf.c:147
static int Nf_CutConfLit(int Conf, int i)
Definition: giaNf.c:152
float Delays[6]
Definition: mio.h:54
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
float D
Definition: giaNf.c:64
static int* Nf_ManCutSet ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 109 of file giaNf.c.

109 { 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: giaNf.c:86
Gia_Man_t* Nf_ManDeriveMapping ( Nf_Man_t p)

Definition at line 2120 of file giaNf.c.

2121 {
2122  Vec_Int_t * vMapping;
2123  Nf_Mat_t * pM;
2124  int i, k, c, Id, iLit, * pCut;
2125  assert( p->pGia->vCellMapping == NULL );
2126  vMapping = Vec_IntAlloc( 2*Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
2127  Vec_IntFill( vMapping, 2*Gia_ManObjNum(p->pGia), 0 );
2128  // create CI inverters
2129  Gia_ManForEachCiId( p->pGia, Id, i )
2130  if ( Nf_ObjMapRefNum(p, Id, 1) )
2131  Vec_IntWriteEntry( vMapping, Abc_Var2Lit(Id, 1), -1 );
2132  // create internal nodes
2133  Gia_ManForEachAndId( p->pGia, i )
2134  {
2135  Gia_Obj_t * pObj = Gia_ManObj(p->pGia, i);
2136  if ( Gia_ObjIsBuf(pObj) )
2137  {
2138  if ( Nf_ObjMapRefNum(p, i, 1) )
2139  Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, 1), -1 );
2140  Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, 0), -2 );
2141  continue;
2142  }
2143  for ( c = 0; c < 2; c++ )
2144  if ( Nf_ObjMapRefNum(p, i, c) )
2145  {
2146  // printf( "Using %d %d\n", i, c );
2147  pM = Nf_ObjMatchBest( p, i, c );
2148  // remember inverter
2149  if ( pM->fCompl )
2150  {
2151  Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, c), -1 );
2152  continue;
2153  }
2154  // Nf_ManCutMatchprintf( p, i, c, pM );
2155  pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
2156  // create mapping
2157  Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, c), Vec_IntSize(vMapping) );
2158  Vec_IntPush( vMapping, Nf_CutSize(pCut) );
2159  Nf_CutForEachLit( pCut, pM->Conf, iLit, k )
2160  Vec_IntPush( vMapping, iLit );
2161  Vec_IntPush( vMapping, pM->Gate );
2162  }
2163  }
2164 // assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
2165  p->pGia->vCellMapping = vMapping;
2166  return p->pGia;
2167 }
unsigned CutH
Definition: giaNf.c:60
word Edge
Definition: gia.h:299
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
#define Nf_CutForEachLit(pCut, Conf, iLit, i)
Definition: giaNf.c:158
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
word Area
Definition: gia.h:298
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
unsigned fCompl
Definition: giaNf.c:61
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
int Conf
Definition: giaNf.c:63
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
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_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
Jf_Par_t * pPars
Definition: giaNf.c:77
Vec_Int_t * vCellMapping
Definition: gia.h:132
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Nf_Mat_t * Nf_ObjMatchBest(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:132
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
#define assert(ex)
Definition: util_old.h:213
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
Gia_Man_t * pGia
Definition: giaNf.c:76
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static Nf_Obj_t* Nf_ManObj ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 107 of file giaNf.c.

107 { return p->pNfObjs + i; }
Nf_Obj_t * pNfObjs
Definition: giaNf.c:85
Gia_Man_t* Nf_ManPerformMapping ( Gia_Man_t pGia,
Jf_Par_t pPars 
)

Definition at line 2502 of file giaNf.c.

2503 {
2504  Gia_Man_t * pNew = NULL, * pCls;
2505  Nf_Man_t * p; int i, Id;
2506  if ( Gia_ManHasChoices(pGia) )
2507  pPars->fCoarsen = 0;
2508  pCls = pPars->fCoarsen ? Gia_ManDupMuxes(pGia, pPars->nCoarseLimit) : pGia;
2509  p = Nf_StoCreate( pCls, pPars );
2510 // if ( pPars->fVeryVerbose )
2511 // Nf_StoPrint( p, pPars->fVeryVerbose );
2512  if ( pPars->fVerbose && pPars->fCoarsen )
2513  {
2514  printf( "Initial " ); Gia_ManPrintMuxStats( pGia ); printf( "\n" );
2515  printf( "Derived " ); Gia_ManPrintMuxStats( pCls ); printf( "\n" );
2516  }
2517  Nf_ManPrintInit( p );
2518  Nf_ManComputeCuts( p );
2519  Nf_ManPrintQuit( p );
2520  Gia_ManForEachCiId( p->pGia, Id, i )
2521  Nf_ObjPrepareCi( p, Id );
2522  for ( p->Iter = 0; p->Iter < p->pPars->nRounds; p->Iter++ )
2523  {
2524  Nf_ManComputeMapping( p );
2525  Nf_ManSetMapRefs( p );
2526  Nf_ManPrintStats( p, p->Iter ? "Area " : "Delay" );
2527  }
2528  p->fUseEla = 1;
2529  for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
2530  {
2531  Nf_ManComputeMapping( p );
2532  Nf_ManUpdateStats( p );
2533  Nf_ManPrintStats( p, "Ela " );
2534  }
2535  pNew = Nf_ManDeriveMapping( p );
2536 // Gia_ManMappingVerify( pNew );
2537  Nf_StoDelete( p );
2538  if ( pCls != pGia )
2539  Gia_ManStop( pCls );
2540  if ( pNew == NULL )
2541  return Gia_ManDup( pGia );
2542  return pNew;
2543 }
int Nf_ManSetMapRefs(Nf_Man_t *p)
Definition: giaNf.c:1918
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
int Iter
Definition: giaNf.c:96
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Nf_ManPrintStats(Nf_Man_t *p, char *pTitle)
Definition: giaNf.c:1244
Gia_Man_t * Nf_ManDeriveMapping(Nf_Man_t *p)
Definition: giaNf.c:2120
Nf_Man_t * Nf_StoCreate(Gia_Man_t *pGia, Jf_Par_t *pPars)
Definition: giaNf.c:615
void Nf_ManPrintInit(Nf_Man_t *p)
Definition: giaNf.c:1257
for(p=first;p->value< newval;p=p->next)
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
void Nf_ManUpdateStats(Nf_Man_t *p)
Definition: giaNf.c:2168
void Nf_ManComputeCuts(Nf_Man_t *p)
Definition: giaNf.c:1216
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
Definition: giaMuxes.c:96
void Nf_ManComputeMapping(Nf_Man_t *p)
Definition: giaNf.c:1877
Jf_Par_t * pPars
Definition: giaNf.c:77
void Gia_ManPrintMuxStats(Gia_Man_t *p)
Definition: giaMuxes.c:61
int fUseEla
Definition: giaNf.c:97
int nRounds
Definition: gia.h:270
Definition: gia.h:95
void Nf_ManPrintQuit(Nf_Man_t *p)
Definition: giaNf.c:1276
void Nf_StoDelete(Nf_Man_t *p)
Definition: giaNf.c:668
static void Nf_ObjPrepareCi(Nf_Man_t *p, int iObj)
Definition: giaNf.c:1661
int nRoundsEla
Definition: gia.h:271
Gia_Man_t * pGia
Definition: giaNf.c:76
int nCoarseLimit
Definition: gia.h:273
int fVerbose
Definition: gia.h:291
int fCoarsen
Definition: gia.h:281
static int Nf_ManPrepareCuts ( Nf_Cut_t pCuts,
Nf_Man_t p,
int  iObj,
int  fAddUnit 
)
inlinestatic

Definition at line 798 of file giaNf.c.

799 {
800  if ( Nf_ObjHasCuts(p, iObj) )
801  {
802  Nf_Cut_t * pMfCut = pCuts;
803  int i, * pCut, * pList = Nf_ObjCutSet(p, iObj);
804  Nf_SetForEachCut( pList, pCut, i )
805  {
806  pMfCut->Delay = 0;
807  pMfCut->Flow = 0;
808  pMfCut->iFunc = Nf_CutFunc( pCut );
809  pMfCut->nLeaves = Nf_CutSize( pCut );
810  pMfCut->Sign = Nf_CutGetSign( pCut+1, Nf_CutSize(pCut) );
811  memcpy( pMfCut->pLeaves, pCut+1, sizeof(int) * Nf_CutSize(pCut) );
812  pMfCut++;
813  }
814  if ( fAddUnit && pCuts->nLeaves > 1 )
815  return pList[0] + Nf_CutCreateUnit( pMfCut, iObj );
816  return pList[0];
817  }
818  return Nf_CutCreateUnit( pCuts, iObj );
819 }
#define Nf_SetForEachCut(pList, pCut, i)
Definition: giaNf.c:156
static int Nf_CutCreateUnit(Nf_Cut_t *p, int i)
Definition: giaNf.c:773
float Flow
Definition: giaNf.c:50
char * memcpy()
unsigned nLeaves
Definition: giaNf.c:53
static int Nf_ObjHasCuts(Nf_Man_t *p, int i)
Definition: giaNf.c:112
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static int Nf_CutFunc(int *pCut)
Definition: giaNf.c:146
int Delay
Definition: giaNf.c:49
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
unsigned iFunc
Definition: giaNf.c:51
static word Nf_CutGetSign(int *pLeaves, int nLeaves)
Definition: giaNf.c:766
word Sign
Definition: giaNf.c:48
void Nf_ManPrintInit ( Nf_Man_t p)

Definition at line 1257 of file giaNf.c.

1258 {
1259  int nChoices;
1260  if ( !p->pPars->fVerbose )
1261  return;
1262  printf( "LutSize = %d ", p->pPars->nLutSize );
1263  printf( "CutNum = %d ", p->pPars->nCutNum );
1264  printf( "Iter = %d ", p->pPars->nRounds + p->pPars->nRoundsEla );
1265  printf( "Coarse = %d ", p->pPars->fCoarsen );
1266  printf( "Cells = %d ", p->nCells );
1267  printf( "Funcs = %d ", Vec_MemEntryNum(p->vTtMem) );
1268  printf( "Matches = %d ", Vec_WecSizeSize(p->vTt2Match)/2 );
1269  nChoices = Gia_ManChoiceNum( p->pGia );
1270  if ( nChoices )
1271  printf( "Choices = %d ", nChoices );
1272  printf( "\n" );
1273  printf( "Computing cuts...\r" );
1274  fflush( stdout );
1275 }
int nCutNum
Definition: gia.h:268
int nLutSize
Definition: gia.h:267
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
static int Gia_ManChoiceNum(Gia_Man_t *p)
Definition: gia.h:398
int nCells
Definition: giaNf.c:83
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
Jf_Par_t * pPars
Definition: giaNf.c:77
int nRounds
Definition: gia.h:270
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
int nRoundsEla
Definition: gia.h:271
Gia_Man_t * pGia
Definition: giaNf.c:76
static int Vec_WecSizeSize(Vec_Wec_t *p)
Definition: vecWec.h:202
int fVerbose
Definition: gia.h:291
int fCoarsen
Definition: gia.h:281
void Nf_ManPrintQuit ( Nf_Man_t p)

Definition at line 1276 of file giaNf.c.

1277 {
1278  float MemGia = Gia_ManMemory(p->pGia) / (1<<20);
1279  float MemMan =(1.0 * sizeof(Nf_Obj_t) + 8.0 * sizeof(int)) * Gia_ManObjNum(p->pGia) / (1<<20);
1280  float MemCuts = 1.0 * sizeof(int) * (1 << 16) * Vec_PtrSize(&p->vPages) / (1<<20);
1281  float MemTt = p->vTtMem ? Vec_MemMemory(p->vTtMem) / (1<<20) : 0;
1282  if ( p->CutCount[0] == 0 )
1283  p->CutCount[0] = 1;
1284  if ( !p->pPars->fVerbose )
1285  return;
1286  printf( "CutPair = %.0f ", p->CutCount[0] );
1287  printf( "Merge = %.0f (%.1f) ", p->CutCount[1], 1.0*p->CutCount[1]/Gia_ManAndNum(p->pGia) );
1288  printf( "Eval = %.0f (%.1f) ", p->CutCount[2], 1.0*p->CutCount[2]/Gia_ManAndNum(p->pGia) );
1289  printf( "Cut = %.0f (%.1f) ", p->CutCount[3], 1.0*p->CutCount[3]/Gia_ManAndNum(p->pGia) );
1290  printf( "Use = %.0f (%.1f) ", p->CutCount[4], 1.0*p->CutCount[4]/Gia_ManAndNum(p->pGia) );
1291  printf( "Mat = %.0f (%.1f) ", p->CutCount[5], 1.0*p->CutCount[5]/Gia_ManAndNum(p->pGia) );
1292 // printf( "Equ = %d (%.2f %%) ", p->nCutUseAll, 100.0*p->nCutUseAll /p->CutCount[0] );
1293  printf( "\n" );
1294  printf( "Gia = %.2f MB ", MemGia );
1295  printf( "Man = %.2f MB ", MemMan );
1296  printf( "Cut = %.2f MB ", MemCuts );
1297  printf( "TT = %.2f MB ", MemTt );
1298  printf( "Total = %.2f MB ", MemGia + MemMan + MemCuts + MemTt );
1299 // printf( "\n" );
1300  Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
1301  fflush( stdout );
1302 }
struct Nf_Obj_t_ Nf_Obj_t
Definition: giaNf.c:67
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
abctime clkStart
Definition: giaNf.c:102
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
double CutCount[6]
Definition: giaNf.c:103
static double Vec_MemMemory(Vec_Mem_t *p)
Definition: vecMem.h:175
Jf_Par_t * pPars
Definition: giaNf.c:77
Vec_Ptr_t vPages
Definition: giaNf.c:86
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
double Gia_ManMemory(Gia_Man_t *p)
Definition: giaMan.c:156
Gia_Man_t * pGia
Definition: giaNf.c:76
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int fVerbose
Definition: gia.h:291
void Nf_ManPrintStats ( Nf_Man_t p,
char *  pTitle 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1244 of file giaNf.c.

1245 {
1246  if ( !p->pPars->fVerbose )
1247  return;
1248  printf( "%s : ", pTitle );
1249  printf( "Delay =%8.2f ", p->pPars->MapDelay );
1250  printf( "Area =%12.2f ", p->pPars->MapArea );
1251  printf( "Gate =%6d ", (int)p->pPars->Area );
1252  printf( "Inv =%6d ", (int)p->nInvs );
1253  printf( "Edge =%7d ", (int)p->pPars->Edge );
1254  Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
1255  fflush( stdout );
1256 }
int nInvs
Definition: giaNf.c:98
float MapArea
Definition: gia.h:303
word Edge
Definition: gia.h:299
float MapDelay
Definition: gia.h:302
static abctime Abc_Clock()
Definition: abc_global.h:279
abctime clkStart
Definition: giaNf.c:102
word Area
Definition: gia.h:298
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
Jf_Par_t * pPars
Definition: giaNf.c:77
int fVerbose
Definition: gia.h:291
static int Nf_ManSaveCuts ( Nf_Man_t p,
Nf_Cut_t **  pCuts,
int  nCuts,
int  fUseful 
)
inlinestatic

Definition at line 820 of file giaNf.c.

821 {
822  int i, * pPlace, iCur, nInts = 1, nCutsNew = 0;
823  for ( i = 0; i < nCuts; i++ )
824  if ( !fUseful || !pCuts[i]->Useless )
825  nInts += pCuts[i]->nLeaves + 1, nCutsNew++;
826  if ( (p->iCur & 0xFFFF) + nInts > 0xFFFF )
827  p->iCur = ((p->iCur >> 16) + 1) << 16;
828  if ( Vec_PtrSize(&p->vPages) == (p->iCur >> 16) )
829  Vec_PtrPush( &p->vPages, ABC_ALLOC(int, (1<<16)) );
830  iCur = p->iCur; p->iCur += nInts;
831  pPlace = Nf_ManCutSet( p, iCur );
832  *pPlace++ = nCutsNew;
833  for ( i = 0; i < nCuts; i++ )
834  if ( !fUseful || !pCuts[i]->Useless )
835  {
836  *pPlace++ = Nf_CutSetBoth( pCuts[i]->nLeaves, pCuts[i]->iFunc );
837  memcpy( pPlace, pCuts[i]->pLeaves, sizeof(int) * pCuts[i]->nLeaves );
838  pPlace += pCuts[i]->nLeaves;
839  }
840  return iCur;
841 }
static int * Nf_ManCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:109
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
unsigned nLeaves
Definition: giaNf.c:53
int iCur
Definition: giaNf.c:95
Vec_Ptr_t vPages
Definition: giaNf.c:86
static int Nf_CutSetBoth(int n, int f)
Definition: giaNf.c:148
void Nf_ManSetDefaultPars ( Jf_Par_t pPars)

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

Synopsis [Technology mappping.]

Description []

SideEffects []

SeeAlso [] Function*************************************************************

Synopsis [Technology mappping.]

Description []

SideEffects []

SeeAlso []

Definition at line 2476 of file giaNf.c.

2477 {
2478  memset( pPars, 0, sizeof(Jf_Par_t) );
2479  pPars->nLutSize = 6;
2480  pPars->nCutNum = 16;
2481  pPars->nProcNum = 0;
2482  pPars->nRounds = 3;
2483  pPars->nRoundsEla = 0;
2484  pPars->nRelaxRatio = 0;
2485  pPars->nCoarseLimit = 3;
2486  pPars->nAreaTuner = 1;
2487  pPars->nVerbLimit = 5;
2488  pPars->DelayTarget = -1;
2489  pPars->fAreaOnly = 0;
2490  pPars->fOptEdge = 1;
2491  pPars->fCoarsen = 0;
2492  pPars->fCutMin = 1;
2493  pPars->fGenCnf = 0;
2494  pPars->fPureAig = 0;
2495  pPars->fVerbose = 0;
2496  pPars->fVeryVerbose = 0;
2497  pPars->nLutSizeMax = NF_LEAF_MAX;
2498  pPars->nCutNumMax = NF_CUT_MAX;
2499  pPars->MapDelayTarget = -1;
2500  pPars->Epsilon = (float)0.01;
2501 }
char * memset()
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
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
float Epsilon
Definition: gia.h:305
float MapDelayTarget
Definition: gia.h:304
int fOptEdge
Definition: gia.h:278
Definition: gia.h:265
#define NF_CUT_MAX
Definition: giaNf.c:39
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
int Nf_ManSetMapRefs ( Nf_Man_t p)

Definition at line 1918 of file giaNf.c.

1919 {
1920  float Coef = 1.0 / (1.0 + (p->Iter + 1) * (p->Iter + 1));
1921  float * pFlowRefs = Vec_FltArray( &p->vFlowRefs );
1922  int * pMapRefs = Vec_IntArray( &p->vMapRefs );
1923  float Epsilon = p->pPars->Epsilon;
1924  int nLits = 2*Gia_ManObjNum(p->pGia);
1925  int i, c, Id, nRefs[2];
1926  Nf_Mat_t * pD, * pA, * pM;
1927  Nf_Mat_t * pDs[2], * pAs[2], * pMs[2];
1928  Gia_Obj_t * pObj;
1929  float Required = 0, Requireds[2];
1930  // check references
1931  assert( !p->fUseEla );
1932  memset( pMapRefs, 0, sizeof(int) * nLits );
1933  Vec_FltFill( &p->vRequired, nLits, NF_INFINITY );
1934 // for ( i = 0; i < Gia_ManObjNum(p->pGia); i++ )
1935 // assert( !Nf_ObjMapRefNum(p, i, 0) && !Nf_ObjMapRefNum(p, i, 1) );
1936  // compute delay
1937  p->pPars->MapDelay = 0;
1938  Gia_ManForEachCo( p->pGia, pObj, i )
1939  {
1940  Required = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
1941  if ( Required == NF_INFINITY )
1942  {
1944  }
1945  p->pPars->MapDelay = Abc_MaxFloat( p->pPars->MapDelay, Required );
1946  }
1947  // check delay target
1948  if ( p->pPars->MapDelayTarget == -1 && p->pPars->nRelaxRatio )
1949  p->pPars->MapDelayTarget = (int)((float)p->pPars->MapDelay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
1950  if ( p->pPars->MapDelayTarget != -1 )
1951  {
1952  if ( p->pPars->MapDelay < p->pPars->MapDelayTarget + Epsilon )
1953  p->pPars->MapDelay = p->pPars->MapDelayTarget;
1954  else if ( p->pPars->nRelaxRatio == 0 )
1955  Abc_Print( 0, "Relaxing user-specified delay target from %.2f to %.2f.\n", p->pPars->MapDelayTarget, p->pPars->MapDelay );
1956  }
1957  // set required times
1958  Gia_ManForEachCo( p->pGia, pObj, i )
1959  {
1960  Required = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
1961  Required = p->pPars->fDoAverage ? Required * (100.0 + p->pPars->nRelaxRatio) / 100.0 : p->pPars->MapDelay;
1962  Nf_ObjUpdateRequired( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj), Required );
1963  Nf_ObjMapRefInc( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj));
1964  }
1965  // compute area and edges
1966  p->nInvs = 0;
1967  p->pPars->MapArea = 0;
1968  p->pPars->Area = p->pPars->Edge = 0;
1969  Gia_ManForEachAndReverse( p->pGia, pObj, i )
1970  {
1971  if ( Gia_ObjIsBuf(pObj) )
1972  {
1973  if ( Nf_ObjMapRefNum(p, i, 1) )
1974  {
1975  Nf_ObjMapRefInc( p, i, 0 );
1976  Nf_ObjUpdateRequired( p, i, 0, Nf_ObjRequired(p, i, 1) - p->InvDelay );
1977  p->pPars->MapArea += p->InvArea;
1978  p->pPars->Edge++;
1979  p->pPars->Area++;
1980  p->nInvs++;
1981  }
1982  Nf_ObjUpdateRequired( p, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj), Nf_ObjRequired(p, i, 0) );
1983  Nf_ObjMapRefInc( p, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj));
1984  continue;
1985  }
1986  // skip if this node is not used
1987  for ( c = 0; c < 2; c++ )
1988  {
1989  nRefs[c] = Nf_ObjMapRefNum(p, i, c);
1990 
1991  //if ( Nf_ObjMatchD( p, i, c )->fCompl )
1992  // printf( "Match D of node %d has inv in phase %d.\n", i, c );
1993  //if ( Nf_ObjMatchA( p, i, c )->fCompl )
1994  // printf( "Match A of node %d has inv in phase %d.\n", i, c );
1995  }
1996  if ( !nRefs[0] && !nRefs[1] )
1997  continue;
1998 
1999  // consider two cases
2000  if ( nRefs[0] && nRefs[1] )
2001  {
2002  // find best matches for both phases
2003  for ( c = 0; c < 2; c++ )
2004  {
2005  Requireds[c] = Nf_ObjRequired( p, i, c );
2006  //assert( Requireds[c] < NF_INFINITY );
2007  pDs[c] = Nf_ObjMatchD( p, i, c );
2008  pAs[c] = Nf_ObjMatchA( p, i, c );
2009  pMs[c] = (pAs[c]->D < Requireds[c] + Epsilon) ? pAs[c] : pDs[c];
2010  }
2011  // swap complemented matches
2012  if ( pMs[0]->fCompl && pMs[1]->fCompl )
2013  {
2014  pMs[0]->fCompl = pMs[1]->fCompl = 0;
2015  ABC_SWAP( Nf_Mat_t *, pMs[0], pMs[1] );
2016  }
2017  // check if intervers are involved
2018  if ( !pMs[0]->fCompl && !pMs[1]->fCompl )
2019  {
2020  // no inverters
2021  for ( c = 0; c < 2; c++ )
2022  Nf_ManSetMapRefsGate( p, i, Requireds[c], pMs[c] );
2023  }
2024  else
2025  {
2026  // one interver
2027  assert( !pMs[0]->fCompl || !pMs[1]->fCompl );
2028  c = pMs[1]->fCompl;
2029  assert( pMs[c]->fCompl && !pMs[!c]->fCompl );
2030  //printf( "Using inverter at node %d in phase %d\n", i, c );
2031 
2032  // update this phase phase
2033  pM = pMs[c];
2034  pM->fBest = 1;
2035  Required = Requireds[c];
2036 
2037  // update opposite phase
2038  Nf_ObjMapRefInc( p, i, !c );
2039  Nf_ObjUpdateRequired( p, i, !c, Required - p->InvDelay );
2040 
2041  // select oppositve phase
2042  Required = Nf_ObjRequired( p, i, !c );
2043  //assert( Required < NF_INFINITY );
2044  pD = Nf_ObjMatchD( p, i, !c );
2045  pA = Nf_ObjMatchA( p, i, !c );
2046  pM = (pA->D < Required + Epsilon) ? pA : pD;
2047  assert( !pM->fCompl );
2048 
2049  // account for the inverter
2050  p->pPars->MapArea += p->InvArea;
2051  p->pPars->Edge++;
2052  p->pPars->Area++;
2053  p->nInvs++;
2054 
2055  // create gate
2056  Nf_ManSetMapRefsGate( p, i, Required, pM );
2057  }
2058  }
2059  else
2060  {
2061  c = (int)(nRefs[1] > 0);
2062  assert( nRefs[c] && !nRefs[!c] );
2063  // consider this phase
2064  Required = Nf_ObjRequired( p, i, c );
2065  //assert( Required < NF_INFINITY );
2066  pD = Nf_ObjMatchD( p, i, c );
2067  pA = Nf_ObjMatchA( p, i, c );
2068  pM = (pA->D < Required + Epsilon) ? pA : pD;
2069 
2070  if ( pM->fCompl ) // use inverter
2071  {
2072  p->nInvs++;
2073  //printf( "Using inverter at node %d in phase %d\n", i, c );
2074  pM->fBest = 1;
2075  // update opposite phase
2076  Nf_ObjMapRefInc( p, i, !c );
2077  Nf_ObjUpdateRequired( p, i, !c, Required - p->InvDelay );
2078  // select oppositve phase
2079  Required = Nf_ObjRequired( p, i, !c );
2080  //assert( Required < NF_INFINITY );
2081  pD = Nf_ObjMatchD( p, i, !c );
2082  pA = Nf_ObjMatchA( p, i, !c );
2083  pM = (pA->D < Required + Epsilon) ? pA : pD;
2084  assert( !pM->fCompl );
2085 
2086  // account for the inverter
2087  p->pPars->MapArea += p->InvArea;
2088  p->pPars->Edge++;
2089  p->pPars->Area++;
2090  }
2091 
2092  // create gate
2093  Nf_ManSetMapRefsGate( p, i, Required, pM );
2094  }
2095 
2096 
2097  // the result of this:
2098  // - only one phase can be implemented as inverter of the other phase
2099  // - required times are propagated correctly
2100  // - references are set correctly
2101  }
2102  Gia_ManForEachCiId( p->pGia, Id, i )
2103  if ( Nf_ObjMapRefNum(p, Id, 1) )
2104  {
2105  Nf_ObjMapRefInc( p, Id, 0 );
2106  Nf_ObjUpdateRequired( p, Id, 0, Required - p->InvDelay );
2107  p->pPars->MapArea += p->InvArea;
2108  p->pPars->Edge++;
2109  p->pPars->Area++;
2110  p->nInvs++;
2111  }
2112  // blend references
2113  for ( i = 0; i < nLits; i++ )
2114 // pFlowRefs[i] = Abc_MaxFloat(1.0, pMapRefs[i]);
2115  pFlowRefs[i] = Abc_MaxFloat(1.0, Coef * pFlowRefs[i] + (1.0 - Coef) * Abc_MaxFloat(1, pMapRefs[i]));
2116 // pFlowRefs[i] = 0.2 * pFlowRefs[i] + 0.8 * Abc_MaxFloat(1, pMapRefs[i]);
2117 // memset( pMapRefs, 0, sizeof(int) * nLits );
2118  return p->pPars->Area;
2119 }
char * memset()
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
unsigned fBest
Definition: giaNf.c:62
int nInvs
Definition: giaNf.c:98
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
float MapArea
Definition: gia.h:303
int Iter
Definition: giaNf.c:96
word Edge
Definition: gia.h:299
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
float MapDelay
Definition: gia.h:302
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
static float * Vec_FltArray(Vec_Flt_t *p)
Definition: vecFlt.h:274
Vec_Int_t vMapRefs
Definition: giaNf.c:88
static void Vec_FltFill(Vec_Flt_t *p, int nSize, float Entry)
Definition: vecFlt.h:450
#define NF_INFINITY
Definition: giaNf.c:41
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
void Nf_ManCutMatchprintf(Nf_Man_t *p, int iObj, int fCompl, Nf_Mat_t *pM)
Definition: giaNf.c:1388
Definition: gia.h:75
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
int nRelaxRatio
Definition: gia.h:272
float Epsilon
Definition: gia.h:305
float MapDelayTarget
Definition: gia.h:304
word Area
Definition: gia.h:298
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
unsigned fCompl
Definition: giaNf.c:61
Vec_Flt_t vFlowRefs
Definition: giaNf.c:89
#define Gia_ManForEachAndReverse(p, pObj, i)
Definition: gia.h:1010
float InvDelay
Definition: giaNf.c:99
if(last==0)
Definition: sparse_int.h:34
static int Nf_ObjMapRefInc(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:122
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
Jf_Par_t * pPars
Definition: giaNf.c:77
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static void Nf_ObjUpdateRequired(Nf_Man_t *p, int i, int c, float f)
Definition: giaNf.c:127
int fDoAverage
Definition: gia.h:288
int fUseEla
Definition: giaNf.c:97
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
void Nf_ManSetMapRefsGate(Nf_Man_t *p, int iObj, float Required, Nf_Mat_t *pM)
Definition: giaNf.c:1899
static Nf_Mat_t * Nf_ObjMatchA(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:130
#define assert(ex)
Definition: util_old.h:213
float InvArea
Definition: giaNf.c:100
Vec_Flt_t vRequired
Definition: giaNf.c:90
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Gia_Man_t * pGia
Definition: giaNf.c:76
static float Nf_ObjRequired(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:125
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
float D
Definition: giaNf.c:64
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
void Nf_ManSetMapRefsGate ( Nf_Man_t p,
int  iObj,
float  Required,
Nf_Mat_t pM 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1899 of file giaNf.c.

1900 {
1901  int k, iVar, fCompl;
1902  Mio_Cell_t * pCell = Nf_ManCell( p, pM->Gate );
1903  int * pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, iObj), pM->CutH );
1904  Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
1905  {
1906  Nf_ObjMapRefInc( p, iVar, fCompl );
1907  Nf_ObjUpdateRequired( p, iVar, fCompl, Required - pCell->Delays[k] );
1908  }
1909  assert( Nf_CutSize(pCut) == (int)pCell->nFanins );
1910  // update global stats
1911  p->pPars->MapArea += pCell->Area;
1912  p->pPars->Edge += Nf_CutSize(pCut);
1913  p->pPars->Area++;
1914  // update status of the gate
1915  assert( pM->fBest == 0 );
1916  pM->fBest = 1;
1917 }
unsigned fBest
Definition: giaNf.c:62
float MapArea
Definition: gia.h:303
unsigned CutH
Definition: giaNf.c:60
word Edge
Definition: gia.h:299
#define Nf_CutForEachVar(pCut, Conf, iVar, c, i)
Definition: giaNf.c:159
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
word Area
Definition: gia.h:298
unsigned nFanins
Definition: mio.h:53
unsigned Gate
Definition: giaNf.c:59
int Conf
Definition: giaNf.c:63
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static int Nf_ObjMapRefInc(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:122
Jf_Par_t * pPars
Definition: giaNf.c:77
static void Nf_ObjUpdateRequired(Nf_Man_t *p, int i, int c, float f)
Definition: giaNf.c:127
float Area
Definition: mio.h:51
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
#define assert(ex)
Definition: util_old.h:213
float Delays[6]
Definition: mio.h:54
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
void Nf_ManUpdateStats ( Nf_Man_t p)

Definition at line 2168 of file giaNf.c.

2169 {
2170  Nf_Mat_t * pM;
2171  Gia_Obj_t * pObj;
2172  Mio_Cell_t * pCell;
2173  int i, c, Id, * pCut;
2174  p->pPars->MapDelay = 0;
2175  Gia_ManForEachCo( p->pGia, pObj, i )
2176  {
2177  float Delay = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
2178  p->pPars->MapDelay = Abc_MaxFloat( p->pPars->MapDelay, Delay );
2179  }
2180  p->pPars->MapArea = 0;
2181  p->pPars->Area = p->pPars->Edge = 0;
2182  Gia_ManForEachAndId( p->pGia, i )
2183  for ( c = 0; c < 2; c++ )
2184  if ( Nf_ObjMapRefNum(p, i, c) )
2185  {
2186  pM = Nf_ObjMatchBest( p, i, c );
2187  pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
2188  pCell = Nf_ManCell( p, pM->Gate );
2189  assert( Nf_CutSize(pCut) == (int)pCell->nFanins );
2190  p->pPars->MapArea += pCell->Area;
2191  p->pPars->Edge += Nf_CutSize(pCut);
2192  p->pPars->Area++;
2193  }
2194  Gia_ManForEachCiId( p->pGia, Id, i )
2195  if ( Nf_ObjMapRefNum(p, Id, 1) )
2196  {
2197  p->pPars->MapArea += p->InvArea;
2198  p->pPars->Edge++;
2199  p->pPars->Area++;
2200  }
2201 }
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
float MapArea
Definition: gia.h:303
unsigned CutH
Definition: giaNf.c:60
word Edge
Definition: gia.h:299
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
float MapDelay
Definition: gia.h:302
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
for(p=first;p->value< newval;p=p->next)
Definition: gia.h:75
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
word Area
Definition: gia.h:298
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
unsigned nFanins
Definition: mio.h:53
unsigned Gate
Definition: giaNf.c:59
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
if(last==0)
Definition: sparse_int.h:34
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
Jf_Par_t * pPars
Definition: giaNf.c:77
float Area
Definition: mio.h:51
static Nf_Mat_t * Nf_ObjMatchBest(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:132
static int Nf_CutSize(int *pCut)
Definition: giaNf.c:145
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define assert(ex)
Definition: util_old.h:213
#define Gia_ManForEachAndId(p, i)
Definition: gia.h:1004
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Gia_Man_t * pGia
Definition: giaNf.c:76
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
float D
Definition: giaNf.c:64
float Nf_MatchDeref2_rec ( Nf_Man_t p,
int  i,
int  c,
Nf_Mat_t pM 
)

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

Synopsis [Technology mappping.]

Description []

SideEffects []

SeeAlso []

Definition at line 1316 of file giaNf.c.

1317 {
1318  int k, iVar, fCompl, * pCut;
1319  float Area = 0;
1320  if ( pM->fCompl )
1321  {
1322  assert( Nf_ObjMapRefNum(p, i, !c) > 0 );
1323  if ( !Nf_ObjMapRefDec(p, i, !c) )
1324  Area += Nf_MatchDeref2_rec( p, i, !c, Nf_ObjMatchBest(p, i, !c) );
1325  return Area + p->InvArea;
1326  }
1327  if ( Nf_ObjCutSetId(p, i) == 0 )
1328  return 0;
1329  pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
1330  Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
1331  {
1332  assert( Nf_ObjMapRefNum(p, iVar, fCompl) > 0 );
1333  if ( !Nf_ObjMapRefDec(p, iVar, fCompl) )
1334  Area += Nf_MatchDeref2_rec( p, iVar, fCompl, Nf_ObjMatchBest(p, iVar, fCompl) );
1335  }
1336  return Area + Nf_ManCell(p, pM->Gate)->Area;
1337 }
unsigned CutH
Definition: giaNf.c:60
static int Nf_ObjCutSetId(Nf_Man_t *p, int i)
Definition: giaNf.c:110
#define Nf_CutForEachVar(pCut, Conf, iVar, c, i)
Definition: giaNf.c:159
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
float Nf_MatchDeref2_rec(Nf_Man_t *p, int i, int c, Nf_Mat_t *pM)
Definition: giaNf.c:1316
unsigned fCompl
Definition: giaNf.c:61
unsigned Gate
Definition: giaNf.c:59
int Conf
Definition: giaNf.c:63
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
float Area
Definition: mio.h:51
static int Nf_ObjMapRefDec(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:123
static Nf_Mat_t * Nf_ObjMatchBest(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:132
#define assert(ex)
Definition: util_old.h:213
float InvArea
Definition: giaNf.c:100
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
float Nf_MatchRef2_rec ( Nf_Man_t p,
int  i,
int  c,
Nf_Mat_t pM,
Vec_Int_t vBackup 
)

Definition at line 1338 of file giaNf.c.

1339 {
1340  int k, iVar, fCompl, * pCut;
1341  float Area = 0;
1342  if ( pM->fCompl )
1343  {
1344  if ( vBackup )
1345  Vec_IntPush( vBackup, Abc_Var2Lit(i, !c) );
1346  assert( Nf_ObjMapRefNum(p, i, !c) >= 0 );
1347  if ( !Nf_ObjMapRefInc(p, i, !c) )
1348  Area += Nf_MatchRef2_rec( p, i, !c, Nf_ObjMatchBest(p, i, !c), vBackup );
1349  return Area + p->InvArea;
1350  }
1351  if ( Nf_ObjCutSetId(p, i) == 0 )
1352  return 0;
1353  pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
1354  Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
1355  {
1356  if ( vBackup )
1357  Vec_IntPush( vBackup, Abc_Var2Lit(iVar, fCompl) );
1358  assert( Nf_ObjMapRefNum(p, iVar, fCompl) >= 0 );
1359  if ( !Nf_ObjMapRefInc(p, iVar, fCompl) )
1360  Area += Nf_MatchRef2_rec( p, iVar, fCompl, Nf_ObjMatchBest(p, iVar, fCompl), vBackup );
1361  }
1362  return Area + Nf_ManCell(p, pM->Gate)->Area;
1363 }
unsigned CutH
Definition: giaNf.c:60
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Nf_ObjCutSetId(Nf_Man_t *p, int i)
Definition: giaNf.c:110
#define Nf_CutForEachVar(pCut, Conf, iVar, c, i)
Definition: giaNf.c:159
static Mio_Cell_t * Nf_ManCell(Nf_Man_t *p, int i)
Definition: giaNf.c:108
unsigned fCompl
Definition: giaNf.c:61
unsigned Gate
Definition: giaNf.c:59
int Conf
Definition: giaNf.c:63
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static int Nf_ObjMapRefInc(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:122
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
float Area
Definition: mio.h:51
static Nf_Mat_t * Nf_ObjMatchBest(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:132
#define assert(ex)
Definition: util_old.h:213
float InvArea
Definition: giaNf.c:100
float Nf_MatchRef2_rec(Nf_Man_t *p, int i, int c, Nf_Mat_t *pM, Vec_Int_t *vBackup)
Definition: giaNf.c:1338
static int * Nf_CutFromHandle(int *pCutSet, int h)
Definition: giaNf.c:151
float Nf_MatchRef2Area ( Nf_Man_t p,
int  i,
int  c,
Nf_Mat_t pM 
)

Definition at line 1364 of file giaNf.c.

1365 {
1366  float Area; int iLit, k;
1367  Vec_IntClear( &p->vBackup );
1368  Area = Nf_MatchRef2_rec( p, i, c, pM, &p->vBackup );
1369  Vec_IntForEachEntry( &p->vBackup, iLit, k )
1370  {
1371  assert( Nf_ObjMapRefNum(p, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit)) > 0 );
1372  Nf_ObjMapRefDec( p, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
1373  }
1374  return Area;
1375 }
Vec_Int_t vBackup
Definition: giaNf.c:93
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
static int Nf_ObjMapRefDec(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:123
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
float Nf_MatchRef2_rec(Nf_Man_t *p, int i, int c, Nf_Mat_t *pM, Vec_Int_t *vBackup)
Definition: giaNf.c:1338
static void Nf_ObjComputeRequired ( Nf_Man_t p,
int  iObj 
)
inlinestatic

Definition at line 1718 of file giaNf.c.

1719 {
1720  Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
1721  int c, * pCutSet = Nf_ObjCutSet( p, iObj );
1722  for ( c = 0; c < 2; c++ )
1723  if ( Nf_ObjRequired(p, iObj, c) == NF_INFINITY )
1724  Nf_ObjSetRequired( p, iObj, c, Nf_CutRequired(p, &pBest->M[c][0], pCutSet) );
1725 }
Nf_Mat_t M[2][2]
Definition: giaNf.c:70
#define NF_INFINITY
Definition: giaNf.c:41
static void Nf_ObjSetRequired(Nf_Man_t *p, int i, int c, float f)
Definition: giaNf.c:126
static int * Nf_ObjCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:111
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
static float Nf_CutRequired(Nf_Man_t *p, Nf_Mat_t *pM, int *pCutSet)
Definition: giaNf.c:1698
static float Nf_ObjRequired(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:125
static int* Nf_ObjCutBest ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 113 of file giaNf.c.

113 { return NULL; }
static int Nf_ObjCutDelay ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 117 of file giaNf.c.

117 { return Vec_IntEntry(&p->vCutDelays, i); }
Vec_Int_t vCutDelays
Definition: giaNf.c:92
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static float Nf_ObjCutFlow ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 116 of file giaNf.c.

116 { return Vec_FltEntry(&p->vCutFlows, i); }
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
Vec_Flt_t vCutFlows
Definition: giaNf.c:91
static int* Nf_ObjCutSet ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 111 of file giaNf.c.

111 { return Nf_ManCutSet(p, Nf_ObjCutSetId(p, i)); }
static int * Nf_ManCutSet(Nf_Man_t *p, int i)
Definition: giaNf.c:109
static int Nf_ObjCutSetId(Nf_Man_t *p, int i)
Definition: giaNf.c:110
static int Nf_ObjCutSetId ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 110 of file giaNf.c.

110 { return Vec_IntEntry( &p->vCutSets, i ); }
Vec_Int_t vCutSets
Definition: giaNf.c:87
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Nf_ObjCutUseless ( Nf_Man_t p,
int  TruthId 
)
inlinestatic

Definition at line 114 of file giaNf.c.

114 { return (int)(TruthId >= Vec_WecSize(p->vTt2Match)); }
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static float Nf_ObjFlowRefs ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 124 of file giaNf.c.

124 { return Vec_FltEntry(&p->vFlowRefs, Abc_Var2Lit(i,c)); }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Vec_Flt_t vFlowRefs
Definition: giaNf.c:89
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
static int Nf_ObjHasCuts ( Nf_Man_t p,
int  i 
)
inlinestatic

Definition at line 112 of file giaNf.c.

112 { return (int)(Vec_IntEntry(&p->vCutSets, i) > 0); }
Vec_Int_t vCutSets
Definition: giaNf.c:87
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Nf_ObjMapRefDec ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 123 of file giaNf.c.

123 { return --(*Vec_IntEntryP(&p->vMapRefs, Abc_Var2Lit(i,c))); }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Vec_Int_t vMapRefs
Definition: giaNf.c:88
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static int Nf_ObjMapRefInc ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 122 of file giaNf.c.

122 { return (*Vec_IntEntryP(&p->vMapRefs, Abc_Var2Lit(i,c)))++; }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Vec_Int_t vMapRefs
Definition: giaNf.c:88
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static int Nf_ObjMapRefNum ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 121 of file giaNf.c.

121 { return Vec_IntEntry(&p->vMapRefs, Abc_Var2Lit(i,c)); }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Vec_Int_t vMapRefs
Definition: giaNf.c:88
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Nf_Mat_t* Nf_ObjMatchA ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 130 of file giaNf.c.

130 { return &Nf_ManObj(p, i)->M[c][1]; }
Nf_Mat_t M[2][2]
Definition: giaNf.c:70
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
static Nf_Mat_t* Nf_ObjMatchBest ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 132 of file giaNf.c.

133 {
134  Nf_Mat_t * pD = Nf_ObjMatchD(p, i, c);
135  Nf_Mat_t * pA = Nf_ObjMatchA(p, i, c);
136  assert( pD->fBest != pA->fBest );
137  assert( Nf_ObjMapRefNum(p, i, c) > 0 );
138  if ( pA->fBest )
139  return pA;
140  if ( pD->fBest )
141  return pD;
142  return NULL;
143 }
unsigned fBest
Definition: giaNf.c:62
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
static int Nf_ObjMapRefNum(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:121
static Nf_Mat_t * Nf_ObjMatchA(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:130
#define assert(ex)
Definition: util_old.h:213
static Nf_Mat_t* Nf_ObjMatchD ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 129 of file giaNf.c.

129 { return &Nf_ManObj(p, i)->M[c][0]; }
Nf_Mat_t M[2][2]
Definition: giaNf.c:70
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
void Nf_ObjMergeOrder ( Nf_Man_t p,
int  iObj 
)

Definition at line 1114 of file giaNf.c.

1115 {
1116  Nf_Cut_t pCuts0[NF_CUT_MAX], pCuts1[NF_CUT_MAX], pCuts[NF_CUT_MAX], * pCutsR[NF_CUT_MAX];
1117  Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
1118  //Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
1119  float dFlowRefs = Nf_ObjFlowRefs(p, iObj, 0) + Nf_ObjFlowRefs(p, iObj, 1);
1120  int nLutSize = p->pPars->nLutSize;
1121  int nCutNum = p->pPars->nCutNum;
1122  int nCuts0 = Nf_ManPrepareCuts(pCuts0, p, Gia_ObjFaninId0(pObj, iObj), 1);
1123  int nCuts1 = Nf_ManPrepareCuts(pCuts1, p, Gia_ObjFaninId1(pObj, iObj), 1);
1124  int fComp0 = Gia_ObjFaninC0(pObj);
1125  int fComp1 = Gia_ObjFaninC1(pObj);
1126  int iSibl = Gia_ObjSibl(p->pGia, iObj);
1127  Nf_Cut_t * pCut0, * pCut1, * pCut0Lim = pCuts0 + nCuts0, * pCut1Lim = pCuts1 + nCuts1;
1128  int i, nCutsUse, nCutsR = 0;
1129  assert( !Gia_ObjIsBuf(pObj) );
1130  for ( i = 0; i < nCutNum; i++ )
1131  pCutsR[i] = pCuts + i;
1132  if ( iSibl )
1133  {
1134  Nf_Cut_t pCuts2[NF_CUT_MAX];
1135  Gia_Obj_t * pObjE = Gia_ObjSiblObj(p->pGia, iObj);
1136  int fCompE = Gia_ObjPhase(pObj) ^ Gia_ObjPhase(pObjE);
1137  int nCuts2 = Nf_ManPrepareCuts(pCuts2, p, iSibl, 0);
1138  Nf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
1139  for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
1140  {
1141  *pCutsR[nCutsR] = *pCut2;
1142  pCutsR[nCutsR]->iFunc = Abc_LitNotCond( pCutsR[nCutsR]->iFunc, fCompE );
1143  Nf_CutParams( p, pCutsR[nCutsR], dFlowRefs );
1144  nCutsR = Nf_SetAddCut( pCutsR, nCutsR, nCutNum );
1145  }
1146  }
1147  if ( Gia_ObjIsMuxId(p->pGia, iObj) )
1148  {
1149  Nf_Cut_t pCuts2[NF_CUT_MAX];
1150  int nCuts2 = Nf_ManPrepareCuts(pCuts2, p, Gia_ObjFaninId2(p->pGia, iObj), 1);
1151  int fComp2 = Gia_ObjFaninC2(p->pGia, pObj);
1152  Nf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
1153  p->CutCount[0] += nCuts0 * nCuts1 * nCuts2;
1154  for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
1155  for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
1156  for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
1157  {
1158  if ( Nf_CutCountBits(pCut0->Sign | pCut1->Sign | pCut2->Sign) > nLutSize )
1159  continue;
1160  p->CutCount[1]++;
1161  if ( !Nf_CutMergeOrderMux(pCut0, pCut1, pCut2, pCutsR[nCutsR], nLutSize) )
1162  continue;
1163  if ( Nf_SetLastCutIsContained(pCutsR, nCutsR) )
1164  continue;
1165  p->CutCount[2]++;
1166  if ( Nf_CutComputeTruthMux6(p, pCut0, pCut1, pCut2, fComp0, fComp1, fComp2, pCutsR[nCutsR]) )
1167  pCutsR[nCutsR]->Sign = Nf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
1168  Nf_CutParams( p, pCutsR[nCutsR], dFlowRefs );
1169  nCutsR = Nf_SetAddCut( pCutsR, nCutsR, nCutNum );
1170  }
1171  }
1172  else
1173  {
1174  int fIsXor = Gia_ObjIsXor(pObj);
1175  p->CutCount[0] += nCuts0 * nCuts1;
1176  for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
1177  for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
1178  {
1179  if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nLutSize && Nf_CutCountBits(pCut0->Sign | pCut1->Sign) > nLutSize )
1180  continue;
1181  p->CutCount[1]++;
1182  if ( !Nf_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nLutSize) )
1183  continue;
1184  if ( Nf_SetLastCutIsContained(pCutsR, nCutsR) )
1185  continue;
1186  p->CutCount[2]++;
1187  if ( Nf_CutComputeTruth6(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
1188  pCutsR[nCutsR]->Sign = Nf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
1189  Nf_CutParams( p, pCutsR[nCutsR], dFlowRefs );
1190  nCutsR = Nf_SetAddCut( pCutsR, nCutsR, nCutNum );
1191  }
1192  }
1193  // debug printout
1194  if ( 0 )
1195 // if ( iObj % 10000 == 0 )
1196 // if ( iObj == 1090 )
1197  {
1198  printf( "*** Obj = %d Useful = %d\n", iObj, Nf_ManCountUseful(pCutsR, nCutsR) );
1199  for ( i = 0; i < nCutsR; i++ )
1200  Nf_Cutprintf( p, pCutsR[i] );
1201  printf( "\n" );
1202  }
1203  // verify
1204  assert( nCutsR > 0 && nCutsR < nCutNum );
1205 // assert( Nf_SetCheckArray(pCutsR, nCutsR) );
1206  // store the cutset
1207  Nf_ObjSetCutFlow( p, iObj, pCutsR[0]->Flow );
1208  Nf_ObjSetCutDelay( p, iObj, pCutsR[0]->Delay );
1209  *Vec_IntEntryP(&p->vCutSets, iObj) = Nf_ManSaveCuts(p, pCutsR, nCutsR, 0);
1210  p->CutCount[3] += nCutsR;
1211  nCutsUse = Nf_ManCountUseful(pCutsR, nCutsR);
1212  p->CutCount[4] += nCutsUse;
1213  p->nCutUseAll += nCutsUse == nCutsR;
1214  p->CutCount[5] += Nf_ManCountMatches(p, pCutsR, nCutsR);
1215 }
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 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
static int Nf_SetLastCutIsContained(Nf_Cut_t **pCuts, int nCuts)
Definition: giaNf.c:1038
Vec_Int_t vCutSets
Definition: giaNf.c:87
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Nf_ManPrepareCuts(Nf_Cut_t *pCuts, Nf_Man_t *p, int iObj, int fAddUnit)
Definition: giaNf.c:798
static void Nf_CutParams(Nf_Man_t *p, Nf_Cut_t *pCut, float FlowRefs)
Definition: giaNf.c:1100
static void Nf_Cutprintf(Nf_Man_t *p, Nf_Cut_t *pCut)
Definition: giaNf.c:783
static int Nf_ManCountUseful(Nf_Cut_t **pCuts, int nCuts)
Definition: giaNf.c:842
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
static float Nf_ObjFlowRefs(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:124
static int Nf_SetAddCut(Nf_Cut_t **pCuts, int nCuts, int nCutNum)
Definition: giaNf.c:1086
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static void Nf_ObjSetCutFlow(Nf_Man_t *p, int i, float a)
Definition: giaNf.c:118
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
unsigned nLeaves
Definition: giaNf.c:53
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
double CutCount[6]
Definition: giaNf.c:103
static int Nf_CutCountBits(word i)
Definition: giaNf.c:759
#define NF_CUT_MAX
Definition: giaNf.c:39
static int Nf_ManCountMatches(Nf_Man_t *p, Nf_Cut_t **pCuts, int nCuts)
Definition: giaNf.c:849
static int Gia_ObjIsXor(Gia_Obj_t *pObj)
Definition: gia.h:423
Jf_Par_t * pPars
Definition: giaNf.c:77
static void Nf_ObjSetCutDelay(Nf_Man_t *p, int i, int d)
Definition: giaNf.c:119
static int Nf_CutComputeTruthMux6(Nf_Man_t *p, Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, Nf_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, Nf_Cut_t *pCutR)
Definition: giaNf.c:724
static int Nf_CutComputeTruth6(Nf_Man_t *p, Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, int fCompl0, int fCompl1, Nf_Cut_t *pCutR, int fIsXor)
Definition: giaNf.c:704
static int Nf_CutMergeOrderMux(Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, Nf_Cut_t *pCut2, Nf_Cut_t *pCut, int nLutSize)
Definition: giaNf.c:988
unsigned iFunc
Definition: giaNf.c:51
static word Nf_CutGetSign(int *pLeaves, int nLeaves)
Definition: giaNf.c:766
static int Nf_CutMergeOrder(Nf_Cut_t *pCut0, Nf_Cut_t *pCut1, Nf_Cut_t *pCut, int nLutSize)
Definition: giaNf.c:925
#define assert(ex)
Definition: util_old.h:213
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static int Gia_ObjFaninId2(Gia_Man_t *p, int ObjId)
Definition: gia.h:462
static int Nf_ManSaveCuts(Nf_Man_t *p, Nf_Cut_t **pCuts, int nCuts, int fUseful)
Definition: giaNf.c:820
int nCutUseAll
Definition: giaNf.c:104
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
Gia_Man_t * pGia
Definition: giaNf.c:76
word Sign
Definition: giaNf.c:48
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static void Nf_ObjPrepareBuf ( Nf_Man_t p,
Gia_Obj_t pObj 
)
inlinestatic

Definition at line 1674 of file giaNf.c.

1675 {
1676  // get fanin info
1677  int iObj = Gia_ObjId( p->pGia, pObj );
1678  int iFanin = Gia_ObjFaninId0( pObj, iObj );
1679  Nf_Mat_t * pDf = Nf_ObjMatchD( p, iFanin, Gia_ObjFaninC0(pObj) );
1680  //Nf_Mat_t * pAf = Nf_ObjMatchA( p, iFanin, Gia_ObjFaninC0(pObj) );
1681  // set the direct phase
1682  Nf_Mat_t * pDp = Nf_ObjMatchD( p, iObj, 0 );
1683  Nf_Mat_t * pAp = Nf_ObjMatchA( p, iObj, 0 );
1684  Nf_Mat_t * pDn = Nf_ObjMatchD( p, iObj, 1 );
1685  Nf_Mat_t * pAn = Nf_ObjMatchA( p, iObj, 1 );
1686  assert( Gia_ObjIsBuf(pObj) );
1687  memset( Nf_ManObj(p, iObj), 0, sizeof(Nf_Obj_t) );
1688  // set the direct phase
1689  pDp->D = pAp->D = pDf->D;
1690  pDp->A = pAp->A = pDf->A; // do not pass flow???
1691  pDp->fBest = 1;
1692  // set the inverted phase
1693  pDn->D = pAn->D = pDf->D + p->InvDelay;
1694  pDn->A = pAn->A = pDf->A + p->InvArea;
1695  pDn->fCompl = pAn->fCompl = 1;
1696  pDn->fBest = 1;
1697 }
char * memset()
unsigned fBest
Definition: giaNf.c:62
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
float A
Definition: giaNf.c:65
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
unsigned fCompl
Definition: giaNf.c:61
float InvDelay
Definition: giaNf.c:99
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static Nf_Obj_t * Nf_ManObj(Nf_Man_t *p, int i)
Definition: giaNf.c:107
static Nf_Mat_t * Nf_ObjMatchA(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:130
#define assert(ex)
Definition: util_old.h:213
float InvArea
Definition: giaNf.c:100
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Gia_Man_t * pGia
Definition: giaNf.c:76
float D
Definition: giaNf.c:64
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static void Nf_ObjPrepareCi ( Nf_Man_t p,
int  iObj 
)
inlinestatic

Definition at line 1661 of file giaNf.c.

1662 {
1663  Nf_Mat_t * pD = Nf_ObjMatchD( p, iObj, 1 );
1664  Nf_Mat_t * pA = Nf_ObjMatchA( p, iObj, 1 );
1665  pD->fCompl = 1;
1666  pD->D = p->InvDelay;
1667  pD->A = p->InvArea;
1668  pA->fCompl = 1;
1669  pA->D = p->InvDelay;
1670  pA->A = p->InvArea;
1671  Nf_ObjMatchD( p, iObj, 0 )->fBest = 1;
1672  Nf_ObjMatchD( p, iObj, 1 )->fBest = 1;
1673 }
unsigned fBest
Definition: giaNf.c:62
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
float A
Definition: giaNf.c:65
unsigned fCompl
Definition: giaNf.c:61
float InvDelay
Definition: giaNf.c:99
static Nf_Mat_t * Nf_ObjMatchA(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:130
float InvArea
Definition: giaNf.c:100
float D
Definition: giaNf.c:64
static float Nf_ObjRequired ( Nf_Man_t p,
int  i,
int  c 
)
inlinestatic

Definition at line 125 of file giaNf.c.

125 { return Vec_FltEntry(&p->vRequired, Abc_Var2Lit(i,c)); }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
Vec_Flt_t vRequired
Definition: giaNf.c:90
static void Nf_ObjSetCutDelay ( Nf_Man_t p,
int  i,
int  d 
)
inlinestatic

Definition at line 119 of file giaNf.c.

119 { Vec_IntWriteEntry(&p->vCutDelays, i, d); }
Vec_Int_t vCutDelays
Definition: giaNf.c:92
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Nf_ObjSetCutFlow ( Nf_Man_t p,
int  i,
float  a 
)
inlinestatic

Definition at line 118 of file giaNf.c.

118 { Vec_FltWriteEntry(&p->vCutFlows, i, a); }
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
Vec_Flt_t vCutFlows
Definition: giaNf.c:91
static void Nf_ObjSetRequired ( Nf_Man_t p,
int  i,
int  c,
float  f 
)
inlinestatic

Definition at line 126 of file giaNf.c.

126 { Vec_FltWriteEntry(&p->vRequired, Abc_Var2Lit(i,c), f); }
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Vec_Flt_t vRequired
Definition: giaNf.c:90
static void Nf_ObjUpdateRequired ( Nf_Man_t p,
int  i,
int  c,
float  f 
)
inlinestatic

Definition at line 127 of file giaNf.c.

127 { if (Nf_ObjRequired(p, i, c) > f) Nf_ObjSetRequired(p, i, c, f); }
static void Nf_ObjSetRequired(Nf_Man_t *p, int i, int c, float f)
Definition: giaNf.c:126
static float Nf_ObjRequired(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:125
static int Nf_SetAddCut ( Nf_Cut_t **  pCuts,
int  nCuts,
int  nCutNum 
)
inlinestatic

Definition at line 1086 of file giaNf.c.

1087 {
1088  if ( nCuts == 0 )
1089  return 1;
1090  nCuts = Nf_SetLastCutContainsArea(pCuts, nCuts);
1091  Nf_SetSortByArea( pCuts, nCuts );
1092  return Abc_MinInt( nCuts + 1, nCutNum - 1 );
1093 }
static void Nf_SetSortByArea(Nf_Cut_t **pCuts, int nCuts)
Definition: giaNf.c:1076
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static int Nf_SetLastCutContainsArea(Nf_Cut_t **pCuts, int nCuts)
Definition: giaNf.c:1046
static int Nf_SetCheckArray ( Nf_Cut_t **  ppCuts,
int  nCuts 
)
inlinestatic

Definition at line 885 of file giaNf.c.

886 {
887  Nf_Cut_t * pCut0, * pCut1;
888  int i, k, m, n, Value;
889  assert( nCuts > 0 );
890  for ( i = 0; i < nCuts; i++ )
891  {
892  pCut0 = ppCuts[i];
893  assert( pCut0->nLeaves <= NF_LEAF_MAX );
894  assert( pCut0->Sign == Nf_CutGetSign(pCut0->pLeaves, pCut0->nLeaves) );
895  // check duplicates
896  for ( m = 0; m < (int)pCut0->nLeaves; m++ )
897  for ( n = m + 1; n < (int)pCut0->nLeaves; n++ )
898  assert( pCut0->pLeaves[m] < pCut0->pLeaves[n] );
899  // check pairs
900  for ( k = 0; k < nCuts; k++ )
901  {
902  pCut1 = ppCuts[k];
903  if ( pCut0 == pCut1 )
904  continue;
905  // check containments
906  Value = Nf_CutCheck( pCut0, pCut1 );
907  assert( Value == 0 );
908  }
909  }
910  return 1;
911 }
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
unsigned nLeaves
Definition: giaNf.c:53
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
static int Nf_CutCheck(Nf_Cut_t *pBase, Nf_Cut_t *pCut)
Definition: giaNf.c:869
static word Nf_CutGetSign(int *pLeaves, int nLeaves)
Definition: giaNf.c:766
#define assert(ex)
Definition: util_old.h:213
word Sign
Definition: giaNf.c:48
static int Nf_SetCutIsContainedOrder ( Nf_Cut_t pBase,
Nf_Cut_t pCut 
)
inlinestatic

Definition at line 1012 of file giaNf.c.

1013 {
1014  int i, nSizeB = pBase->nLeaves;
1015  int k, nSizeC = pCut->nLeaves;
1016  if ( nSizeB == nSizeC )
1017  {
1018  for ( i = 0; i < nSizeB; i++ )
1019  if ( pBase->pLeaves[i] != pCut->pLeaves[i] )
1020  return 0;
1021  return 1;
1022  }
1023  assert( nSizeB > nSizeC );
1024  if ( nSizeC == 0 )
1025  return 1;
1026  for ( i = k = 0; i < nSizeB; i++ )
1027  {
1028  if ( pBase->pLeaves[i] > pCut->pLeaves[k] )
1029  return 0;
1030  if ( pBase->pLeaves[i] == pCut->pLeaves[k] )
1031  {
1032  if ( ++k == nSizeC )
1033  return 1;
1034  }
1035  }
1036  return 0;
1037 }
unsigned nLeaves
Definition: giaNf.c:53
int pLeaves[NF_LEAF_MAX+1]
Definition: giaNf.c:54
#define assert(ex)
Definition: util_old.h:213
static int Nf_SetLastCutContainsArea ( Nf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 1046 of file giaNf.c.

1047 {
1048  int i, k, fChanges = 0;
1049  for ( i = 0; i < nCuts; i++ )
1050  if ( pCuts[nCuts]->nLeaves < pCuts[i]->nLeaves && (pCuts[nCuts]->Sign & pCuts[i]->Sign) == pCuts[nCuts]->Sign && Nf_SetCutIsContainedOrder(pCuts[i], pCuts[nCuts]) )
1051  pCuts[i]->nLeaves = NF_NO_LEAF, fChanges = 1;
1052  if ( !fChanges )
1053  return nCuts;
1054  for ( i = k = 0; i <= nCuts; i++ )
1055  {
1056  if ( pCuts[i]->nLeaves == NF_NO_LEAF )
1057  continue;
1058  if ( k < i )
1059  ABC_SWAP( Nf_Cut_t *, pCuts[k], pCuts[i] );
1060  k++;
1061  }
1062  return k - 1;
1063 }
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
unsigned nLeaves
Definition: giaNf.c:53
static int Nf_SetCutIsContainedOrder(Nf_Cut_t *pBase, Nf_Cut_t *pCut)
Definition: giaNf.c:1012
#define NF_NO_LEAF
Definition: giaNf.c:40
static int Nf_SetLastCutIsContained ( Nf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

Definition at line 1038 of file giaNf.c.

1039 {
1040  int i;
1041  for ( i = 0; i < nCuts; i++ )
1042  if ( pCuts[i]->nLeaves <= pCuts[nCuts]->nLeaves && (pCuts[i]->Sign & pCuts[nCuts]->Sign) == pCuts[i]->Sign && Nf_SetCutIsContainedOrder(pCuts[nCuts], pCuts[i]) )
1043  return 1;
1044  return 0;
1045 }
static int Nf_SetCutIsContainedOrder(Nf_Cut_t *pBase, Nf_Cut_t *pCut)
Definition: giaNf.c:1012
static void Nf_SetSortByArea ( Nf_Cut_t **  pCuts,
int  nCuts 
)
inlinestatic

= 1 )

Definition at line 1076 of file giaNf.c.

1077 {
1078  int i;
1079  for ( i = nCuts; i > 0; i-- )
1080  {
1081  if ( Nf_CutCompareArea(pCuts[i - 1], pCuts[i]) < 0 )//!= 1 )
1082  return;
1083  ABC_SWAP( Nf_Cut_t *, pCuts[i - 1], pCuts[i] );
1084  }
1085 }
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Nf_CutCompareArea(Nf_Cut_t *pCut0, Nf_Cut_t *pCut1)
Definition: giaNf.c:1064
int Nf_StoBuildDsdAnd ( Nf_Man_t pMan,
Mio_Cell_t pCell,
char *  p 
)

Definition at line 279 of file giaNf.c.

280 {
281  int pGroups[NF_LEAF_MAX][NF_LEAF_MAX], pGroups2[NF_LEAF_MAX][NF_LEAF_MAX];
282  int nGroupSizes[NF_LEAF_MAX], nGroupInvs[NF_LEAF_MAX], Phases[NF_LEAF_MAX];
283  int nGroups = 0, nVars = 0, nConfigs = 1;
284  int i, k, c, Res, fCompl = 0;
285  char ** pp = &p;
286  word uTruth;
287  assert( *(p+1) != 0 );
288  if ( *p == '!' )
289  (*pp)++, fCompl = 1;
290  assert( **pp != '!' );
291  Res = Nf_StoBuildDsdAnd_rec( pMan, pCell, p, pp, Dau_DsdComputeMatches(p), pGroups, nGroupSizes, &nGroups );
292  assert( Res == -1 );
293  assert( *++p == 0 );
294  // create groups
295  for ( i = 0; i < nGroups; i++ )
296  {
297  nVars += nGroupSizes[i];
298  nConfigs *= (1 << nGroupSizes[i]);
299  }
300  assert( nVars == (int)pCell->nFanins );
301  // iterate through phase assignments
302  for ( c = 0; c < nConfigs; c++ )
303  {
304  int Start = c;
305  for ( i = nGroups - 1; i >= 0; i-- )
306  {
307  Phases[i] = Start % (1 << nGroupSizes[i]);
308  Start /= (1 << nGroupSizes[i]);
309  memcpy( pGroups2[i], pGroups[i], sizeof(int) * nGroupSizes[i] );
310 // printf( "%d ", Phases[i] );
311  }
312 // printf( "\n" );
313 
314  // create configuration
315  uTruth = pCell->uTruth;
316  for ( i = 0; i < nGroups; i++ )
317  {
318  nGroupInvs[i] = 0;
319  for ( k = 0; k < nGroupSizes[i]; k++ )
320  if ( (Phases[i] >> k) & 1 )
321  {
322  pGroups2[i][k] = Abc_LitNot(pGroups2[i][k]);
323  uTruth = Abc_Tt6Flip( uTruth, Abc_Lit2Var(pGroups2[i][k]) );
324  nGroupInvs[i]++;
325  }
326 /*
327  if ( pCell->nFanins == 4 && nGroups == 1 )
328  {
329  printf( "Group before:\n" );
330  for ( k = 0; k < nGroupSizes[i]; k++ )
331  printf( "%d %.2f\n", pGroups2[i][k], pCell->Delays[Abc_Lit2Var(pGroups2[i][k])] );
332  }
333 */
334 // Nf_StoSelectSortLit( pGroups2[i], nGroupSizes[i], pCell );
335 /*
336  if ( pCell->nFanins == 4 && nGroups == 1 )
337  {
338  printf( "Group after:\n" );
339  for ( k = 0; k < nGroupSizes[i]; k++ )
340  printf( "%d %.2f\n", pGroups2[i][k], pCell->Delays[Abc_Lit2Var(pGroups2[i][k])] );
341  printf( "\n" );
342  }
343 */
344  }
345  // save
346  Nf_StoCreateGateAdd( pMan, uTruth, NULL, -1, pCell->Id, NF_ANDOR );
347  Vec_StrPush( pMan->vMemStore, (char)nGroups );
348  for ( i = 0; i < nGroups; i++ )
349  for ( k = 0; k < nGroupSizes[i]; k++ )
350  {
351  Vec_StrPush( pMan->vMemStore, (char)nGroupSizes[i] );
352  Vec_StrPush( pMan->vMemStore, (char)nGroupInvs[i] );
353  for ( k = 0; k < nGroupSizes[i]; k++ )
354  Vec_StrPush( pMan->vMemStore, (char)pGroups2[i][k] );
355  }
356  }
357  return Res;
358 }
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
Vec_Str_t * vMemStore
Definition: giaNf.c:81
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * memcpy()
word uTruth
Definition: mio.h:50
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int * Dau_DsdComputeMatches(char *p)
Definition: dauDsd.c:80
unsigned nFanins
Definition: mio.h:53
unsigned Id
Definition: mio.h:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: giaNf.c:43
static word Abc_Tt6Flip(word Truth, int iVar)
Definition: utilTruth.h:1126
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
void Nf_StoCreateGateAdd(Nf_Man_t *pMan, word uTruth, int *pFans, int nFans, int CellId, int Type)
Definition: giaNf.c:217
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
int Nf_StoBuildDsdAnd_rec(Nf_Man_t *pMan, Mio_Cell_t *pCell, char *pStr, char **p, int *pMatches, int pGroups[NF_LEAF_MAX][NF_LEAF_MAX], int *nGroupSizes, int *pnGroups)
Definition: giaNf.c:245
int Nf_StoBuildDsdAnd_rec ( Nf_Man_t pMan,
Mio_Cell_t pCell,
char *  pStr,
char **  p,
int *  pMatches,
int  pGroups[NF_LEAF_MAX][NF_LEAF_MAX],
int *  nGroupSizes,
int *  pnGroups 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file giaNf.c.

247 {
248  int fCompl = 0;
249  if ( **p == '!' )
250  (*p)++, fCompl = 1;
251  if ( **p >= 'a' && **p < 'a' + NF_LEAF_MAX ) // var
252 // return Abc_Var2Lit( **p - 'a', fCompl );
253  return Abc_Var2Lit( **p - 'a', 0 );
254  if ( **p == '(' ) // and/or
255  {
256  char * q = pStr + pMatches[ *p - pStr ];
257  int pFans[NF_LEAF_MAX], nFans = 0;
258  assert( **p == '(' && *q == ')' );
259  for ( (*p)++; *p < q; (*p)++ )
260  {
261  int Value = Nf_StoBuildDsdAnd_rec( pMan, pCell, pStr, p, pMatches, pGroups, nGroupSizes, pnGroups );
262  if ( Value == -1 )
263  continue;
264  pFans[nFans++] = Value;
265  }
266  // collect
267  if ( nFans > 0 )
268  {
269  memcpy( pGroups[*pnGroups], pFans, sizeof(int) * nFans );
270  nGroupSizes[*pnGroups] = nFans;
271  (*pnGroups)++;
272  }
273  assert( *p == q );
274  return -1;
275  }
276  assert( 0 );
277  return 0;
278 }
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
char * memcpy()
#define assert(ex)
Definition: util_old.h:213
int Nf_StoBuildDsdAnd_rec(Nf_Man_t *pMan, Mio_Cell_t *pCell, char *pStr, char **p, int *pMatches, int pGroups[NF_LEAF_MAX][NF_LEAF_MAX], int *nGroupSizes, int *pnGroups)
Definition: giaNf.c:245
int Nf_StoCheckDsdAnd ( char *  p)

Definition at line 378 of file giaNf.c.

379 {
380  int Res;
381  assert( *(p+1) != 0 );
383 // assert( *++p == 0 );
384  return Res;
385 }
int Nf_StoCheckDsdAnd_rec(char *pStr, char **p, int *pMatches)
Definition: giaNf.c:360
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int * Dau_DsdComputeMatches(char *p)
Definition: dauDsd.c:80
#define assert(ex)
Definition: util_old.h:213
int Nf_StoCheckDsdAnd_rec ( char *  pStr,
char **  p,
int *  pMatches 
)

Definition at line 360 of file giaNf.c.

361 {
362  if ( **p == '!' )
363  (*p)++;
364  if ( **p >= 'a' && **p < 'a' + NF_LEAF_MAX ) // var
365  return 1;
366  if ( **p == '(' ) // and/or
367  {
368  char * q = pStr + pMatches[ *p - pStr ];
369  assert( **p == '(' && *q == ')' );
370  for ( (*p)++; *p < q; (*p)++ )
371  if ( Nf_StoCheckDsdAnd_rec(pStr, p, pMatches) != 1 )
372  return 0;
373  assert( *p == q );
374  return 1;
375  }
376  return 0;
377 }
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
int Nf_StoCheckDsdAnd_rec(char *pStr, char **p, int *pMatches)
Definition: giaNf.c:360
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
int Nf_StoCheckDsdXor ( char *  p)

Definition at line 410 of file giaNf.c.

411 {
412  int Res;
413  assert( *(p+1) != 0 );
415 // assert( *++p == 0 );
416  return Res;
417 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int * Dau_DsdComputeMatches(char *p)
Definition: dauDsd.c:80
int Nf_StoCheckDsdXor_rec(char *pStr, char **p, int *pMatches)
Definition: giaNf.c:387
#define assert(ex)
Definition: util_old.h:213
int Nf_StoCheckDsdXor_rec ( char *  pStr,
char **  p,
int *  pMatches 
)

Definition at line 387 of file giaNf.c.

388 {
389  int Value, fCompl = 0;
390  if ( **p == '!' )
391  (*p)++, fCompl ^= 1;
392  if ( **p >= 'a' && **p < 'a' + NF_LEAF_MAX ) // var
393  return fCompl;
394  if ( **p == '[' ) // xor
395  {
396  char * q = pStr + pMatches[ *p - pStr ];
397  assert( **p == '[' && *q == ']' );
398  for ( (*p)++; *p < q; (*p)++ )
399  {
400  Value = Nf_StoCheckDsdXor_rec( pStr, p, pMatches );
401  if ( Value == -1 )
402  return -1;
403  fCompl ^= Value;
404  }
405  assert( *p == q );
406  return fCompl;
407  }
408  return -1;
409 }
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Nf_StoCheckDsdXor_rec(char *pStr, char **p, int *pMatches)
Definition: giaNf.c:387
#define assert(ex)
Definition: util_old.h:213
Nf_Man_t* Nf_StoCreate ( Gia_Man_t pGia,
Jf_Par_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file giaNf.c.

616 {
617  extern void Mf_ManSetFlowRefs( Gia_Man_t * p, Vec_Int_t * vRefs );
618  Vec_Int_t * vFlowRefs;
619  Nf_Man_t * p;
620  int i, Entry;
621  assert( pPars->nCutNum > 1 && pPars->nCutNum <= NF_CUT_MAX );
622  assert( pPars->nLutSize > 1 && pPars->nLutSize <= NF_LEAF_MAX );
623  ABC_FREE( pGia->pRefs );
624  Vec_IntFreeP( &pGia->vCellMapping );
625  if ( Gia_ManHasChoices(pGia) )
626  Gia_ManSetPhase(pGia);
627  // create
628  p = ABC_CALLOC( Nf_Man_t, 1 );
629  p->clkStart = Abc_Clock();
630  p->pGia = pGia;
631  p->pPars = pPars;
632  p->pNfObjs = ABC_CALLOC( Nf_Obj_t, Gia_ManObjNum(pGia) );
633  p->iCur = 2;
634  // other
635  Vec_PtrGrow( &p->vPages, 256 ); // cut memory
636  Vec_IntFill( &p->vMapRefs, 2*Gia_ManObjNum(pGia), 0 ); // mapping refs (2x)
637  Vec_FltFill( &p->vFlowRefs, 2*Gia_ManObjNum(pGia), 0 ); // flow refs (2x)
638  Vec_FltFill( &p->vRequired, 2*Gia_ManObjNum(pGia), NF_INFINITY ); // required times (2x)
639  Vec_IntFill( &p->vCutSets, Gia_ManObjNum(pGia), 0 ); // cut offsets
640  Vec_FltFill( &p->vCutFlows, Gia_ManObjNum(pGia), 0 ); // cut area
641  Vec_IntFill( &p->vCutDelays,Gia_ManObjNum(pGia), 0 ); // cut delay
642  Vec_IntGrow( &p->vBackup, 1000 );
643  Vec_IntGrow( &p->vBackup2, 1000 );
644  // references
645  vFlowRefs = Vec_IntAlloc(0);
646  Mf_ManSetFlowRefs( pGia, vFlowRefs );
647  Vec_IntForEachEntry( vFlowRefs, Entry, i )
648  {
649  Vec_FltWriteEntry( &p->vFlowRefs, 2*i, /*0.5* */Entry );
650  Vec_FltWriteEntry( &p->vFlowRefs, 2*i+1, /*0.5* */Entry );
651  }
652  Vec_IntFree(vFlowRefs);
653  // matching
654  p->vTtMem = Vec_MemAllocForTT( 6, 0 );
655  p->vTt2Match = Vec_WecAlloc( 1000 );
656  p->vMemStore = Vec_StrAlloc( 10000 );
660  Nf_StoDeriveMatches( p, 0 );//pPars->fVerbose );
661  p->InvDelay = p->pCells[3].Delays[0];
662  p->InvArea = p->pCells[3].Area;
663  Nf_ObjMatchD(p, 0, 0)->Gate = 0;
664  Nf_ObjMatchD(p, 0, 1)->Gate = 1;
665  // prepare cuts
666  return p;
667 }
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
static Nf_Mat_t * Nf_ObjMatchD(Nf_Man_t *p, int i, int c)
Definition: giaNf.c:129
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
int nCutNum
Definition: gia.h:268
int nLutSize
Definition: gia.h:267
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
Vec_Int_t vCutSets
Definition: giaNf.c:87
Vec_Str_t * vMemStore
Definition: giaNf.c:81
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
Definition: vecPtr.h:430
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
Vec_Int_t vCutDelays
Definition: giaNf.c:92
Vec_Int_t vBackup2
Definition: giaNf.c:94
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
Vec_Int_t vBackup
Definition: giaNf.c:93
Vec_Int_t vMapRefs
Definition: giaNf.c:88
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Vec_FltFill(Vec_Flt_t *p, int nSize, float Entry)
Definition: vecFlt.h:450
#define NF_INFINITY
Definition: giaNf.c:41
int * pRefs
Definition: gia.h:114
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
abctime clkStart
Definition: giaNf.c:102
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
Mio_Cell_t * pCells
Definition: giaNf.c:82
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int iCur
Definition: giaNf.c:95
unsigned Gate
Definition: giaNf.c:59
#define NF_CUT_MAX
Definition: giaNf.c:39
Vec_Flt_t vFlowRefs
Definition: giaNf.c:89
static Vec_Mem_t * Vec_MemAllocForTT(int nVars, int fCompl)
Definition: vecMem.h:378
float InvDelay
Definition: giaNf.c:99
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
Jf_Par_t * pPars
Definition: giaNf.c:77
Vec_Int_t * vCellMapping
Definition: gia.h:132
float Area
Definition: mio.h:51
Vec_Ptr_t vPages
Definition: giaNf.c:86
void Nf_StoDeriveMatches(Nf_Man_t *p, int fVerbose)
Definition: giaNf.c:488
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
Definition: gia.h:95
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
float InvArea
Definition: giaNf.c:100
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_Flt_t vRequired
Definition: giaNf.c:90
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
float Delays[6]
Definition: mio.h:54
Nf_Obj_t * pNfObjs
Definition: giaNf.c:85
Gia_Man_t * pGia
Definition: giaNf.c:76
Vec_Flt_t vCutFlows
Definition: giaNf.c:91
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Nf_StoCreateGateAdd ( Nf_Man_t pMan,
word  uTruth,
int *  pFans,
int  nFans,
int  CellId,
int  Type 
)

Definition at line 217 of file giaNf.c.

218 {
219  Vec_Int_t * vArray;
220  int i, fCompl = (int)(uTruth & 1);
221  word uFunc = fCompl ? ~uTruth : uTruth;
222  int iFunc = Vec_MemHashInsert( pMan->vTtMem, &uFunc );
223  if ( iFunc == Vec_WecSize(pMan->vTt2Match) )
224  Vec_WecPushLevel( pMan->vTt2Match );
225  vArray = Vec_WecEntry( pMan->vTt2Match, iFunc );
226  Vec_IntPush( vArray, (CellId << 8) | (Type << 4) | fCompl );
227  Vec_IntPush( vArray, Vec_StrSize(pMan->vMemStore) );
228  if ( Type == NF_ANDOR )
229  return;
230  for ( i = 0; i < nFans; i++ )
231  Vec_StrPush( pMan->vMemStore, (char)pFans[i] );
232 }
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
Vec_Str_t * vMemStore
Definition: giaNf.c:81
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: giaNf.c:43
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
void Nf_StoCreateGateDsd ( Nf_Man_t pMan,
Mio_Cell_t pCell,
int **  pComp,
int **  pPerm,
int *  pnPerms 
)

Definition at line 460 of file giaNf.c.

461 {
462 /*
463  char pDsd[1000];
464  int i, Value, Perm[NF_LEAF_MAX];
465  word uTruth = pCell->uTruth;
466  int nSizeNonDec = Dau_DsdDecompose( &uTruth, pCell->nFanins, 0, 0, pDsd );
467  assert( pCell->nFanins > 1 );
468  if ( nSizeNonDec == 0 )
469  {
470  if ( Nf_StoCheckDsdAnd(pDsd) )
471  {
472  Nf_StoBuildDsdAnd( pMan, pCell, pDsd );
473  return;
474  }
475  Value = Nf_StoCheckDsdXor(pDsd);
476  if ( Value >= 0 )
477  {
478  for ( i = 0; i < (int)pCell->nFanins; i++ )
479  Perm[i] = Abc_Var2Lit(i, 0);
480 // Nf_StoSelectSort( Perm, pCell->nFanins, pCell );
481  Nf_StoCreateGateAdd( pMan, pCell->uTruth, Perm, pCell->nFanins, pCell->Id, NF_XOR );
482  return;
483  }
484  }
485 */
486  Nf_StoCreateGateNonDsd( pMan, pCell, pComp, pPerm, pnPerms );
487 }
void Nf_StoCreateGateNonDsd(Nf_Man_t *pMan, Mio_Cell_t *pCell, int **pComp, int **pPerm, int *pnPerms)
Definition: giaNf.c:430
static int pPerm[13719]
Definition: rwrTemp.c:32
void Nf_StoCreateGateNonDsd ( Nf_Man_t pMan,
Mio_Cell_t pCell,
int **  pComp,
int **  pPerm,
int *  pnPerms 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 430 of file giaNf.c.

431 {
432  int Perm[NF_LEAF_MAX], * Perm1, * Perm2;
433  int nPerms = pnPerms[pCell->nFanins];
434  int nMints = (1 << pCell->nFanins);
435  word tCur, tTemp1, tTemp2;
436  int i, p, c;
437  for ( i = 0; i < (int)pCell->nFanins; i++ )
438  Perm[i] = Abc_Var2Lit( i, 0 );
439  tCur = tTemp1 = pCell->uTruth;
440  for ( p = 0; p < nPerms; p++ )
441  {
442  tTemp2 = tCur;
443  for ( c = 0; c < nMints; c++ )
444  {
445  Nf_StoCreateGateAdd( pMan, tCur, Perm, pCell->nFanins, pCell->Id, NF_PRIME );
446  // update
447  tCur = Abc_Tt6Flip( tCur, pComp[pCell->nFanins][c] );
448  Perm1 = Perm + pComp[pCell->nFanins][c];
449  *Perm1 = Abc_LitNot( *Perm1 );
450  }
451  assert( tTemp2 == tCur );
452  // update
453  tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[pCell->nFanins][p] );
454  Perm1 = Perm + pPerm[pCell->nFanins][p];
455  Perm2 = Perm1 + 1;
456  ABC_SWAP( int, *Perm1, *Perm2 );
457  }
458  assert( tTemp1 == tCur );
459 }
Definition: giaNf.c:43
#define NF_LEAF_MAX
DECLARATIONS ///.
Definition: giaNf.c:38
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
word uTruth
Definition: mio.h:50
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static word Abc_Tt6SwapAdjacent(word Truth, int iVar)
Definition: utilTruth.h:1186
unsigned nFanins
Definition: mio.h:53
unsigned Id
Definition: mio.h:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word Abc_Tt6Flip(word Truth, int iVar)
Definition: utilTruth.h:1126
static int pPerm[13719]
Definition: rwrTemp.c:32
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
void Nf_StoCreateGateAdd(Nf_Man_t *pMan, word uTruth, int *pFans, int nFans, int CellId, int Type)
Definition: giaNf.c:217
#define assert(ex)
Definition: util_old.h:213
void Nf_StoDelete ( Nf_Man_t p)

Definition at line 668 of file giaNf.c.

669 {
670  Vec_PtrFreeData( &p->vPages );
671  ABC_FREE( p->vPages.pArray );
672  ABC_FREE( p->vMapRefs.pArray );
673  ABC_FREE( p->vFlowRefs.pArray );
674  ABC_FREE( p->vRequired.pArray );
675  ABC_FREE( p->vCutSets.pArray );
676  ABC_FREE( p->vCutFlows.pArray );
677  ABC_FREE( p->vCutDelays.pArray );
678  ABC_FREE( p->vBackup.pArray );
679  ABC_FREE( p->vBackup2.pArray );
680  ABC_FREE( p->pNfObjs );
681  // matching
682  Vec_WecFree( p->vTt2Match );
683  Vec_MemHashFree( p->vTtMem );
684  Vec_MemFree( p->vTtMem );
685  Vec_StrFree( p->vMemStore );
686  ABC_FREE( p->pCells );
687  ABC_FREE( p );
688 }
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
Vec_Int_t vCutSets
Definition: giaNf.c:87
Vec_Str_t * vMemStore
Definition: giaNf.c:81
static void Vec_WecFree(Vec_Wec_t *p)
Definition: vecWec.h:345
Vec_Int_t vCutDelays
Definition: giaNf.c:92
Vec_Int_t vBackup2
Definition: giaNf.c:94
Vec_Int_t vBackup
Definition: giaNf.c:93
Vec_Int_t vMapRefs
Definition: giaNf.c:88
Mio_Cell_t * pCells
Definition: giaNf.c:82
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
Vec_Flt_t vFlowRefs
Definition: giaNf.c:89
static void Vec_MemFree(Vec_Mem_t *p)
Definition: utilMem.c:93
Vec_Ptr_t vPages
Definition: giaNf.c:86
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static void Vec_MemHashFree(Vec_Mem_t *p)
Definition: vecMem.h:311
Vec_Flt_t vRequired
Definition: giaNf.c:90
static void Vec_PtrFreeData(Vec_Ptr_t *p)
Definition: vecPtr.h:561
Nf_Obj_t * pNfObjs
Definition: giaNf.c:85
Vec_Flt_t vCutFlows
Definition: giaNf.c:91
void Nf_StoDeriveMatches ( Nf_Man_t p,
int  fVerbose 
)

Definition at line 488 of file giaNf.c.

489 {
490 // abctime clk = Abc_Clock();
491  int * pComp[7];
492  int * pPerm[7];
493  int nPerms[7], i;
494  for ( i = 2; i <= 6; i++ )
495  pComp[i] = Extra_GreyCodeSchedule( i );
496  for ( i = 2; i <= 6; i++ )
497  pPerm[i] = Extra_PermSchedule( i );
498  for ( i = 2; i <= 6; i++ )
499  nPerms[i] = Extra_Factorial( i );
500  p->pCells = Mio_CollectRootsNewDefault( 6, &p->nCells, fVerbose );
501  for ( i = 4; i < p->nCells; i++ )
502  Nf_StoCreateGateDsd( p, p->pCells + i, pComp, pPerm, nPerms );
503  for ( i = 2; i <= 6; i++ )
504  ABC_FREE( pComp[i] );
505  for ( i = 2; i <= 6; i++ )
506  ABC_FREE( pPerm[i] );
507 // Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
508 }
int * Extra_GreyCodeSchedule(int n)
int * Extra_PermSchedule(int n)
int nCells
Definition: giaNf.c:83
Mio_Cell_t * pCells
Definition: giaNf.c:82
void Nf_StoCreateGateDsd(Nf_Man_t *pMan, Mio_Cell_t *pCell, int **pComp, int **pPerm, int *pnPerms)
Definition: giaNf.c:460
static int pPerm[13719]
Definition: rwrTemp.c:32
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Extra_Factorial(int n)
Mio_Cell_t * Mio_CollectRootsNewDefault(int nInputs, int *pnGates, int fVerbose)
Definition: mioUtils.c:498
void Nf_StoPrint ( Nf_Man_t p,
int  fVerbose 
)

Definition at line 560 of file giaNf.c.

561 {
562  int t, i, Info, Offset, Count = 0, CountMux = 0;
563  for ( t = 2; t < Vec_WecSize(p->vTt2Match); t++ )
564  {
565  Vec_Int_t * vArr = Vec_WecEntry( p->vTt2Match, t );
566  Vec_IntForEachEntryDouble( vArr, Info, Offset, i )
567  {
568  Mio_Cell_t*pC = p->pCells + (Info >> 8);
569  int Type = (Info >> 4) & 15;
570  int fCompl = (Info & 1);
571  char * pInfo = Vec_StrEntryP( p->vMemStore, Offset );
572  if ( Type == NF_PRIME && pC->nFanins != 3 )
573  {
574  Count++;
575  CountMux++;
576  continue;
577  }
578  if ( !fVerbose )
579  {
580  Count++;
581  continue;
582  }
583  Nf_StoPrintOne( p, Count, t, i, pC, Type, fCompl, pInfo );
584  }
585  }
586  printf( "Gates = %d. Truths = %d. Matches = %d. MatchesPrime = %d. Size = %d.\n",
587  p->nCells, Vec_MemEntryNum(p->vTtMem), Count, CountMux, Vec_StrSize(p->vMemStore) );
588 }
Definition: giaNf.c:43
Vec_Wec_t * vTt2Match
Definition: giaNf.c:80
Vec_Str_t * vMemStore
Definition: giaNf.c:81
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int nCells
Definition: giaNf.c:83
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
Mio_Cell_t * pCells
Definition: giaNf.c:82
unsigned nFanins
Definition: mio.h:53
void Nf_StoPrintOne(Nf_Man_t *p, int Count, int t, int i, Mio_Cell_t *pC, int Type, int fCompl, char *pInfo)
Definition: giaNf.c:509
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static char * Vec_StrEntryP(Vec_Str_t *p, int i)
Definition: vecStr.h:353
void Nf_StoPrintOne ( Nf_Man_t p,
int  Count,
int  t,
int  i,
Mio_Cell_t pC,
int  Type,
int  fCompl,
char *  pInfo 
)

Definition at line 509 of file giaNf.c.

510 {
511  word * pTruth = Vec_MemReadEntry(p->vTtMem, t);
512  int k, nSuppSize = Abc_TtSupportSize(pTruth, 6);
513  printf( "%6d : ", Count++ );
514  printf( "%6d : ", t );
515  printf( "%6d : ", i/2 );
516  printf( "Gate %16s ", pC->pName );
517  printf( "Inputs = %d ", pC->nFanins );
518  if ( Type == NF_PRIME )
519  printf( "prime" );
520  else if ( Type == NF_XOR )
521  printf( "xor " );
522  else if ( Type == NF_ANDOR )
523  printf( "andor" );
524  else assert( 0 );
525  if ( fCompl )
526  printf( " compl " );
527  else
528  printf( " " );
529  if ( Type == NF_PRIME || Type == NF_XOR )
530  {
531  for ( k = 0; k < (int)pC->nFanins; k++ )
532  {
533  int fComplF = Abc_LitIsCompl((int)pInfo[k]);
534  int iFanin = Abc_Lit2Var((int)pInfo[k]);
535  printf( "%c", 'a' + iFanin - fComplF * ('a' - 'A') );
536  }
537  }
538  else if ( Type == NF_ANDOR )
539  {
540  int g, nGroups = (int)*pInfo++;
541  for ( g = 0; g < nGroups; g++ )
542  {
543  int nSizeAll = (int)*pInfo++;
544  int nSizeNeg = (int)*pInfo++;
545  printf( "{" );
546  for ( k = 0; k < nSizeAll; k++ )
547  {
548  int fComplF = Abc_LitIsCompl((int)pInfo[k]);
549  int iFanin = Abc_Lit2Var((int)pInfo[k]);
550  printf( "%c", 'a' + iFanin - fComplF * ('a' - 'A') );
551  }
552  printf( "}" );
553  pInfo += nSizeAll; nSizeNeg = 0;
554  }
555  }
556  else assert( 0 );
557  printf( " " );
558  Dau_DsdPrintFromTruth( pTruth, nSuppSize );
559 }
Definition: giaNf.c:43
char * pName
Definition: mio.h:49
Definition: giaNf.c:43
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned nFanins
Definition: mio.h:53
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: giaNf.c:43
Vec_Mem_t * vTtMem
Definition: giaNf.c:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Abc_TtSupportSize(word *t, int nVars)
Definition: utilTruth.h:986
#define assert(ex)
Definition: util_old.h:213
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
static void Nf_StoSelectSort ( int *  pArray,
int  nSize,
Mio_Cell_t pCell 
)
inlinestatic

FUNCTION DEFINITIONS ///.

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

Synopsis [Sort inputs by delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file giaNf.c.

190 {
191  int i, j, best_i;
192  for ( i = 0; i < nSize-1; i++ )
193  {
194  best_i = i;
195  for ( j = i+1; j < nSize; j++ )
196  if ( pCell->Delays[Abc_Lit2Var(pArray[j])] < pCell->Delays[Abc_Lit2Var(pArray[best_i])] )
197  best_i = j;
198  if ( i != best_i )
199  ABC_SWAP( int, pArray[i], pArray[best_i] );
200  }
201 }
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
float Delays[6]
Definition: mio.h:54
static void Nf_StoSelectSortLit ( int *  pArray,
int  nSize,
Mio_Cell_t pCell 
)
inlinestatic

Definition at line 202 of file giaNf.c.

203 {
204  int i, j, best_i;
205  for ( i = 0; i < nSize-1; i++ )
206  {
207  best_i = i;
208  for ( j = i+1; j < nSize; j++ )
209  if ( Abc_LitIsCompl(pArray[j]) > Abc_LitIsCompl(pArray[best_i]) ||
210  (Abc_LitIsCompl(pArray[j]) == Abc_LitIsCompl(pArray[best_i]) &&
211  pCell->Delays[Abc_Lit2Var(pArray[j])] < pCell->Delays[Abc_Lit2Var(pArray[best_i])]) )
212  best_i = j;
213  if ( i != best_i )
214  ABC_SWAP( int, pArray[i], pArray[best_i] );
215  }
216 }
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
float Delays[6]
Definition: mio.h:54