abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaIf.c File Reference
#include "gia.h"
#include "aig/aig/aig.h"
#include "map/if/if.h"
#include "bool/kit/kit.h"
#include "base/main/main.h"
#include "sat/bsat/satSolver.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Kit_TruthToGia (Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
 DECLARATIONS ///. More...
 
int Abc_RecToGia3 (Gia_Man_t *pMan, If_Man_t *pIfMan, If_Cut_t *pCut, Vec_Int_t *vLeaves, int fHash)
 
void Gia_ManSetIfParsDefault (void *pp)
 FUNCTION DEFINITIONS ///. More...
 
int Gia_ManLutFaninCount (Gia_Man_t *p)
 
int Gia_ManLutSizeMax (Gia_Man_t *p)
 
int Gia_ManLutNum (Gia_Man_t *p)
 
int Gia_ManLutLevel (Gia_Man_t *p)
 
void Gia_ManLutParams (Gia_Man_t *p, int *pnCurLuts, int *pnCurEdges, int *pnCurLevels)
 
void Gia_ManSetRefsMapped (Gia_Man_t *p)
 
int Gia_ManComputeOverlap2One_rec (Gia_Man_t *p, int iObj, Vec_Str_t *vLabel, Vec_Int_t *vVisit)
 
int Gia_ManComputeOverlap2One (Gia_Man_t *p, int iObj, Vec_Str_t *vLabel, Vec_Int_t *vVisit)
 
int Gia_ManComputeOverlap2 (Gia_Man_t *p)
 
int Gia_ManComputeOverlapOne_rec (Gia_Man_t *p, int iObj)
 
int Gia_ManComputeOverlapOne (Gia_Man_t *p, int iObj)
 
int Gia_ManComputeOverlap (Gia_Man_t *p)
 
void Gia_ManPrintGetMuxFanins (Gia_Man_t *p, Gia_Obj_t *pObj, int *pFanins)
 
int Gia_ManCountDupLut (Gia_Man_t *p)
 
void Gia_ManPrintMappingStats (Gia_Man_t *p, char *pDumpFile)
 
void Gia_ManPrintPackingStats (Gia_Man_t *p)
 
void Gia_ManPrintNodeProfile (int *pCounts, int nSizeMax)
 
void Gia_ManPrintLutStats (Gia_Man_t *p)
 
void Gia_ManChoiceLevel_rec (Gia_Man_t *p, Gia_Obj_t *pObj)
 
int Gia_ManChoiceLevel (Gia_Man_t *p)
 
static If_Obj_tIf_ManFanin0Copy (If_Man_t *pIfMan, Gia_Obj_t *pObj)
 
static If_Obj_tIf_ManFanin1Copy (If_Man_t *pIfMan, Gia_Obj_t *pObj)
 
If_Man_tGia_ManToIf (Gia_Man_t *p, If_Par_t *pPars)
 
int Gia_ManBuildFromMiniInt (Gia_Man_t *pNew, Vec_Int_t *vLeaves, Vec_Int_t *vAig, int fHash)
 
int Gia_ManBuildFromMini (Gia_Man_t *pNew, If_Man_t *pIfMan, If_Cut_t *pCut, Vec_Int_t *vLeaves, Vec_Int_t *vAig, int fHash, int fUseDsd)
 
int Gia_ManFromIfAig_rec (Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj)
 
Gia_Man_tGia_ManFromIfAig (If_Man_t *pIfMan)
 
int Gia_ManFromIfLogicCreateLut (Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
 
int Gia_ManFromIfLogicCreateLutSpecial (Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vLeavesTemp, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking)
 
int Gia_ManFromIfLogicNode (void *pIfMan, Gia_Man_t *pNew, int iObj, Vec_Int_t *vLeaves, Vec_Int_t *vLeavesTemp, word *pRes, char *pStr, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking, int fCheck75, int fCheck44e)
 
int Gia_ManNodeIfToGia_rec (Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Ptr_t *vVisited, int fHash)
 
int Gia_ManNodeIfToGia (Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Int_t *vLeaves, int fHash)
 
int Gia_ManFromIfLogicFindLut (If_Man_t *pIfMan, Gia_Man_t *pNew, If_Cut_t *pCutBest, sat_solver *pSat, Vec_Int_t *vLeaves, Vec_Int_t *vLits, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking)
 
int Gia_ManFromIfLogicFindCell (If_Man_t *pIfMan, Gia_Man_t *pNew, Gia_Man_t *pTemp, If_Cut_t *pCutBest, sat_solver *pSat, Vec_Int_t *vPiVars, Vec_Int_t *vPoVars, Ifn_Ntk_t *pNtkCell, int nLutMax, Vec_Int_t *vLeaves, Vec_Int_t *vLits, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking)
 
Gia_Man_tGia_ManFromIfLogic (If_Man_t *pIfMan)
 
int Gia_ManMappingVerify_rec (Gia_Man_t *p, Gia_Obj_t *pObj)
 
void Gia_ManMappingVerify (Gia_Man_t *p)
 
void Gia_ManTransferMapping (Gia_Man_t *p, Gia_Man_t *pGia)
 
void Gia_ManTransferPacking (Gia_Man_t *p, Gia_Man_t *pGia)
 
void Gia_ManTransferTiming (Gia_Man_t *p, Gia_Man_t *pGia)
 
Gia_Man_tGia_ManPerformMappingInt (Gia_Man_t *p, If_Par_t *pPars)
 
Gia_Man_tGia_ManPerformMapping (Gia_Man_t *p, void *pp)
 
Gia_Man_tGia_ManPerformSopBalance (Gia_Man_t *p, int nCutNum, int nRelaxRatio, int fVerbose)
 
Gia_Man_tGia_ManPerformDsdBalance (Gia_Man_t *p, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose)
 
void Gia_ManTestStruct (Gia_Man_t *p)
 

Function Documentation

int Abc_RecToGia3 ( Gia_Man_t pMan,
If_Man_t pIfMan,
If_Cut_t pCut,
Vec_Int_t vLeaves,
int  fHash 
)

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

Synopsis [Reexpresses the best structure of the cut in the GIA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1105 of file abcRec3.c.

1106 {
1107  Lms_Man_t * p = s_pMan3;
1108  char pCanonPerm[LMS_VAR_MAX];
1109  unsigned uCanonPhase;
1110  int iFan0, iFan1, iGiaObj;
1111  Gia_Man_t * pGia = p->pGia;
1112  Gia_Obj_t * pGiaPo, * pGiaTemp = NULL;
1113  int i, uSupport, BestPo = -1, nLeaves = If_CutLeaveNum(pCut);
1114  assert( pIfMan->pPars->fCutMin == 1 );
1115  assert( nLeaves == Vec_IntSize(vLeaves) );
1116 
1117  // compute support
1118  uSupport = Abc_TtSupport( If_CutTruthW(pIfMan, pCut), nLeaves );
1119  if ( uSupport == 0 )
1120  return Abc_LitNotCond( 0, If_CutTruthIsCompl(pCut) );
1121  if ( !Abc_TtSuppIsMinBase(uSupport) || uSupport == 1 )
1122  {
1123  assert( Abc_TtSuppOnlyOne(uSupport) );
1124  return Abc_LitNotCond( Vec_IntEntry(vLeaves, Abc_TtSuppFindFirst(uSupport)), If_CutTruthIsCompl(pCut) );
1125  }
1126  assert( Gia_WordCountOnes(uSupport) == nLeaves );
1127 
1128  // get the best output for this node
1129  If_CutFindBestStruct( pIfMan, pCut, pCanonPerm, &uCanonPhase, &BestPo );
1130  assert( BestPo >= 0 );
1131  pGiaPo = Gia_ManCo( pGia, BestPo );
1132 
1133  // collect internal nodes into pGia->vTtNodes
1134  if ( pGia->vTtNodes == NULL )
1135  pGia->vTtNodes = Vec_IntAlloc( 256 );
1136  assert( Gia_ObjIsAnd( Gia_ObjFanin0(pGiaPo) ) );
1137  Gia_ObjCollectInternal( pGia, Gia_ObjFanin0(pGiaPo) );
1138  assert( Vec_IntSize(pGia->vTtNodes) > 0 );
1139 
1140  // collect GIA nodes for leaves
1141  Vec_IntClear( p->vLabels );
1142  for (i = 0; i < nLeaves; i++)
1143  Vec_IntPush( p->vLabels, Abc_LitNotCond(Vec_IntEntry(vLeaves, pCanonPerm[i]), (uCanonPhase >> i) & 1) );
1144 
1145  // compute HOP nodes for internal nodes
1146  Gia_ManForEachObjVec( pGia->vTtNodes, pGia, pGiaTemp, i )
1147  {
1148  pGiaTemp->fMark0 = 0; // unmark node marked by Gia_ObjCollectInternal()
1149  if ( Gia_ObjIsAnd(Gia_ObjFanin0(pGiaTemp)) )
1150  iFan0 = Vec_IntEntry(p->vLabels, Gia_ObjNum(pGia, Gia_ObjFanin0(pGiaTemp)) + nLeaves);
1151  else
1152  iFan0 = Vec_IntEntry(p->vLabels, Gia_ObjCioId(Gia_ObjFanin0(pGiaTemp)));
1153  iFan0 = Abc_LitNotCond(iFan0, Gia_ObjFaninC0(pGiaTemp));
1154  if ( Gia_ObjIsAnd(Gia_ObjFanin1(pGiaTemp)) )
1155  iFan1 = Vec_IntEntry(p->vLabels, Gia_ObjNum(pGia, Gia_ObjFanin1(pGiaTemp)) + nLeaves);
1156  else
1157  iFan1 = Vec_IntEntry(p->vLabels, Gia_ObjCioId(Gia_ObjFanin1(pGiaTemp)));
1158  iFan1 = Abc_LitNotCond(iFan1, Gia_ObjFaninC1(pGiaTemp));
1159  if ( fHash )
1160  iGiaObj = Gia_ManHashAnd(pMan, iFan0, iFan1);
1161  else
1162  iGiaObj = Gia_ManAppendAnd(pMan, iFan0, iFan1);
1163  Vec_IntPush(p->vLabels, iGiaObj);
1164  }
1165  // get the final result
1166  assert( Gia_ObjIsAnd(pGiaTemp) );
1167  iGiaObj = Vec_IntEntry(p->vLabels, Gia_ObjNum(pGia, pGiaTemp) + nLeaves);
1168  // complement the result if needed
1169  return Abc_LitNotCond( iGiaObj, Gia_ObjFaninC0(pGiaPo) ^ ((uCanonPhase >> nLeaves) & 1) ^ pCut->fCompl );
1170 }
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
static int Abc_TtSuppFindFirst(int Supp)
Definition: utilTruth.h:929
void Gia_ObjCollectInternal(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:159
static int Abc_TtSupport(word *t, int nVars)
Definition: utilTruth.h:978
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Int_t * vLabels
Definition: abcRec3.c:71
static int Abc_TtSuppIsMinBase(int Supp)
Definition: utilTruth.h:944
static int Gia_ObjNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:513
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
Gia_Man_t * pGia
Definition: abcRec3.c:58
#define LMS_VAR_MAX
Definition: abcRec3.c:31
static int Gia_WordCountOnes(unsigned uWord)
Definition: gia.h:313
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
static int If_CutTruthIsCompl(If_Cut_t *pCut)
Definition: if.h:418
static int If_CutFindBestStruct(If_Man_t *pIfMan, If_Cut_t *pCut, char *pCanonPerm, unsigned *puCanonPhase, int *pBestPo)
Definition: abcRec3.c:903
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
If_Par_t * pPars
Definition: if.h:184
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
Definition: gia.h:404
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned fMark0
Definition: gia.h:79
Vec_Int_t * vTtNodes
Definition: gia.h:185
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static int Abc_TtSuppOnlyOne(int Supp)
Definition: utilTruth.h:938
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
int fCutMin
Definition: if.h:120
static Lms_Man_t * s_pMan3
Definition: abcRec3.c:96
#define assert(ex)
Definition: util_old.h:213
unsigned fCompl
Definition: if.h:285
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
int Gia_ManBuildFromMini ( Gia_Man_t pNew,
If_Man_t pIfMan,
If_Cut_t pCut,
Vec_Int_t vLeaves,
Vec_Int_t vAig,
int  fHash,
int  fUseDsd 
)

Definition at line 848 of file giaIf.c.

849 {
850  if ( fUseDsd )
851  If_CutDsdBalanceEval( pIfMan, pCut, vAig );
852  else
853  If_CutSopBalanceEval( pIfMan, pCut, vAig );
854  return Gia_ManBuildFromMiniInt( pNew, vLeaves, vAig, fHash );
855 }
int If_CutSopBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDelay.c:248
int If_CutDsdBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDsd.c:2288
int Gia_ManBuildFromMiniInt(Gia_Man_t *pNew, Vec_Int_t *vLeaves, Vec_Int_t *vAig, int fHash)
Definition: giaIf.c:810
int Gia_ManBuildFromMiniInt ( Gia_Man_t pNew,
Vec_Int_t vLeaves,
Vec_Int_t vAig,
int  fHash 
)

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

Synopsis [Rebuilds GIA from mini AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 810 of file giaIf.c.

811 {
812  assert( Vec_IntSize(vAig) > 0 );
813  assert( Vec_IntEntryLast(vAig) < 2 );
814  if ( Vec_IntSize(vAig) == 1 ) // const
815  return Vec_IntEntry(vAig, 0);
816  if ( Vec_IntSize(vAig) == 2 ) // variable
817  {
818  assert( Vec_IntEntry(vAig, 0) == 0 );
819  assert( Vec_IntSize(vLeaves) == 1 );
820  return Abc_LitNotCond( Vec_IntEntry(vLeaves, 0), Vec_IntEntry(vAig, 1) );
821  }
822  else
823  {
824  int nLeaves = Vec_IntSize(vLeaves);
825  int i, iVar0, iVar1, iLit0, iLit1, iLit = 0;
826  assert( Vec_IntSize(vAig) & 1 );
827  Vec_IntForEachEntryDouble( vAig, iLit0, iLit1, i )
828  {
829  iVar0 = Abc_Lit2Var( iLit0 );
830  iVar1 = Abc_Lit2Var( iLit1 );
831  iLit0 = Abc_LitNotCond( iVar0 < nLeaves ? Vec_IntEntry(vLeaves, iVar0) : Vec_IntEntry(vAig, iVar0 - nLeaves), Abc_LitIsCompl(iLit0) );
832  iLit1 = Abc_LitNotCond( iVar1 < nLeaves ? Vec_IntEntry(vLeaves, iVar1) : Vec_IntEntry(vAig, iVar1 - nLeaves), Abc_LitIsCompl(iLit1) );
833  if ( fHash )
834  iLit = Gia_ManHashAnd( pNew, iLit0, iLit1 );
835  else if ( iLit0 == iLit1 )
836  iLit = iLit0;
837  else
838  iLit = Gia_ManAppendAnd( pNew, iLit0, iLit1 );
839  assert( (i & 1) == 0 );
840  Vec_IntWriteEntry( vAig, Abc_Lit2Var(i), iLit ); // overwriting entries
841  }
842  assert( i == Vec_IntSize(vAig) - 1 );
843  iLit = Abc_LitNotCond( iLit, Vec_IntEntry(vAig, i) );
844  Vec_IntClear( vAig ); // useless
845  return iLit;
846  }
847 }
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
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
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
int Gia_ManChoiceLevel ( Gia_Man_t p)

Definition at line 699 of file giaIf.c.

700 {
701  Gia_Obj_t * pObj;
702  int i, LevelMax = 0;
703 // assert( Gia_ManRegNum(p) == 0 );
706  Gia_ManForEachCo( p, pObj, i )
707  {
708  Gia_ManChoiceLevel_rec( p, pObj );
709  if ( LevelMax < Gia_ObjLevel(p, pObj) )
710  LevelMax = Gia_ObjLevel(p, pObj);
711  }
712  // account for dangling boxes
713  Gia_ManForEachCi( p, pObj, i )
714  {
715  Gia_ManChoiceLevel_rec( p, pObj );
716  if ( LevelMax < Gia_ObjLevel(p, pObj) )
717  LevelMax = Gia_ObjLevel(p, pObj);
718 // Abc_Print( 1, "%d ", Gia_ObjLevel(p, pObj) );
719  }
720 // Abc_Print( 1, "\n" );
721  Gia_ManForEachAnd( p, pObj, i )
722  assert( Gia_ObjLevel(p, pObj) > 0 );
723 // printf( "Max level %d\n", LevelMax );
724  return LevelMax;
725 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
void Gia_ManChoiceLevel_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaIf.c:638
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
void Gia_ManCleanLevels(Gia_Man_t *p, int Size)
Definition: giaUtil.c:470
#define assert(ex)
Definition: util_old.h:213
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManChoiceLevel_rec ( Gia_Man_t p,
Gia_Obj_t pObj 
)

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

Synopsis [Computes levels for AIG with choices and white boxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 638 of file giaIf.c.

639 {
640  Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
641  Gia_Obj_t * pNext;
642  int i, iBox, iTerm1, nTerms, LevelMax = 0;
643  if ( Gia_ObjIsTravIdCurrent( p, pObj ) )
644  return;
645  Gia_ObjSetTravIdCurrent( p, pObj );
646  if ( Gia_ObjIsCi(pObj) )
647  {
648  if ( pManTime )
649  {
650  iBox = Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) );
651  if ( iBox >= 0 ) // this is not a true PI
652  {
653  iTerm1 = Tim_ManBoxInputFirst( pManTime, iBox );
654  nTerms = Tim_ManBoxInputNum( pManTime, iBox );
655  for ( i = 0; i < nTerms; i++ )
656  {
657  pNext = Gia_ManCo( p, iTerm1 + i );
658  Gia_ManChoiceLevel_rec( p, pNext );
659  if ( LevelMax < Gia_ObjLevel(p, pNext) )
660  LevelMax = Gia_ObjLevel(p, pNext);
661  }
662  LevelMax++;
663  }
664  }
665 // Abc_Print( 1, "%d ", pObj->Level );
666  }
667  else if ( Gia_ObjIsCo(pObj) )
668  {
669  pNext = Gia_ObjFanin0(pObj);
670  Gia_ManChoiceLevel_rec( p, pNext );
671  if ( LevelMax < Gia_ObjLevel(p, pNext) )
672  LevelMax = Gia_ObjLevel(p, pNext);
673  }
674  else if ( Gia_ObjIsAnd(pObj) )
675  {
676  // get the maximum level of the two fanins
677  pNext = Gia_ObjFanin0(pObj);
678  Gia_ManChoiceLevel_rec( p, pNext );
679  if ( LevelMax < Gia_ObjLevel(p, pNext) )
680  LevelMax = Gia_ObjLevel(p, pNext);
681  pNext = Gia_ObjFanin1(pObj);
682  Gia_ManChoiceLevel_rec( p, pNext );
683  if ( LevelMax < Gia_ObjLevel(p, pNext) )
684  LevelMax = Gia_ObjLevel(p, pNext);
685  LevelMax++;
686 
687  // get the level of the nodes in the choice node
688  if ( (pNext = Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))) )
689  {
690  Gia_ManChoiceLevel_rec( p, pNext );
691  if ( LevelMax < Gia_ObjLevel(p, pNext) )
692  LevelMax = Gia_ObjLevel(p, pNext);
693  }
694  }
695  else if ( !Gia_ObjIsConst0(pObj) )
696  assert( 0 );
697  Gia_ObjSetLevel( p, pObj, LevelMax );
698 }
int Tim_ManBoxForCi(Tim_Man_t *p, int iCo)
Definition: timBox.c:86
static Gia_Obj_t * Gia_ObjSiblObj(Gia_Man_t *p, int Id)
Definition: gia.h:894
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
Definition: gia.h:75
void Gia_ManChoiceLevel_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaIf.c:638
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
if(last==0)
Definition: sparse_int.h:34
void * pManTime
Definition: gia.h:165
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:186
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
Definition: gia.h:404
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:122
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
static void Gia_ObjSetLevel(Gia_Man_t *p, Gia_Obj_t *pObj, int l)
Definition: gia.h:503
int Gia_ManComputeOverlap ( Gia_Man_t p)

Definition at line 341 of file giaIf.c.

342 {
343  int i, Count = -Gia_ManAndNum(p);
345  Gia_ManForEachLut( p, i )
346  Count += Gia_ManComputeOverlapOne( p, i );
347  return Count;
348 }
int Gia_ManComputeOverlapOne(Gia_Man_t *p, int iObj)
Definition: giaIf.c:333
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
#define assert(ex)
Definition: util_old.h:213
int Gia_ManComputeOverlap2 ( Gia_Man_t p)

Definition at line 296 of file giaIf.c.

297 {
298  Vec_Int_t * vVisit;
299  Vec_Str_t * vLabel;
300  int i, Count = -Gia_ManAndNum(p);
302  vVisit = Vec_IntAlloc( 100 );
303  vLabel = Vec_StrStart( Gia_ManObjNum(p) );
304  Gia_ManForEachLut( p, i )
305  Count += Gia_ManComputeOverlap2One( p, i, vLabel, vVisit );
306  Vec_StrFree( vLabel );
307  Vec_IntFree( vVisit );
308  return Count;
309 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Gia_ManComputeOverlap2One(Gia_Man_t *p, int iObj, Vec_Str_t *vLabel, Vec_Int_t *vVisit)
Definition: giaIf.c:283
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static Vec_Str_t * Vec_StrStart(int nSize)
Definition: vecStr.h:95
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Gia_ManComputeOverlap2One ( Gia_Man_t p,
int  iObj,
Vec_Str_t vLabel,
Vec_Int_t vVisit 
)

Definition at line 283 of file giaIf.c.

284 {
285  int iFan, k, Counter;
286  Vec_IntClear( vVisit );
287  Gia_LutForEachFanin( p, iObj, iFan, k )
288  Vec_StrWriteEntry( vLabel, iFan, 1 );
289  Counter = Gia_ManComputeOverlap2One_rec( p, iObj, vLabel, vVisit );
290  Gia_LutForEachFanin( p, iObj, iFan, k )
291  Vec_StrWriteEntry( vLabel, iFan, 0 );
292  Vec_IntForEachEntry( vVisit, iFan, k )
293  Vec_StrWriteEntry( vLabel, iFan, 0 );
294  return Counter;
295 }
int Gia_ManComputeOverlap2One_rec(Gia_Man_t *p, int iObj, Vec_Str_t *vLabel, Vec_Int_t *vVisit)
Definition: giaIf.c:269
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static int Counter
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
int Gia_ManComputeOverlap2One_rec ( Gia_Man_t p,
int  iObj,
Vec_Str_t vLabel,
Vec_Int_t vVisit 
)

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

Synopsis [Calculate mapping overlap.]

Description []

SideEffects []

SeeAlso []

Definition at line 269 of file giaIf.c.

270 {
271  Gia_Obj_t * pObj;
272  int Counter;
273  if ( Vec_StrEntry(vLabel, iObj) )
274  return 0;
275  Vec_StrWriteEntry( vLabel, iObj, 1 );
276  pObj = Gia_ManObj( p, iObj );
277  assert( Gia_ObjIsAnd(pObj) );
278  Counter = Gia_ManComputeOverlap2One_rec( p, Gia_ObjFaninId0(pObj, iObj), vLabel, vVisit );
279  Counter += Gia_ManComputeOverlap2One_rec( p, Gia_ObjFaninId1(pObj, iObj), vLabel, vVisit );
280  Vec_IntPush( vVisit, iObj );
281  return Counter + 1;
282 }
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
int Gia_ManComputeOverlap2One_rec(Gia_Man_t *p, int iObj, Vec_Str_t *vLabel, Vec_Int_t *vVisit)
Definition: giaIf.c:269
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
int Gia_ManComputeOverlapOne ( Gia_Man_t p,
int  iObj 
)

Definition at line 333 of file giaIf.c.

334 {
335  int iFan, k;
337  Gia_LutForEachFanin( p, iObj, iFan, k )
338  Gia_ObjSetTravIdCurrentId( p, iFan );
339  return Gia_ManComputeOverlapOne_rec( p, iObj );
340 }
int Gia_ManComputeOverlapOne_rec(Gia_Man_t *p, int iObj)
Definition: giaIf.c:322
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static void Gia_ObjSetTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:535
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
int Gia_ManComputeOverlapOne_rec ( Gia_Man_t p,
int  iObj 
)

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

Synopsis [Calculate mapping overlap.]

Description []

SideEffects []

SeeAlso []

Definition at line 322 of file giaIf.c.

323 {
324  Gia_Obj_t * pObj;
325  if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
326  return 0;
327  Gia_ObjSetTravIdCurrentId( p, iObj );
328  pObj = Gia_ManObj( p, iObj );
329  assert( Gia_ObjIsAnd(pObj) );
330  return 1 + Gia_ManComputeOverlapOne_rec( p, Gia_ObjFaninId0(pObj, iObj) )
331  + Gia_ManComputeOverlapOne_rec( p, Gia_ObjFaninId1(pObj, iObj) );
332 }
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
int Gia_ManComputeOverlapOne_rec(Gia_Man_t *p, int iObj)
Definition: giaIf.c:322
static int Gia_ObjIsTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:536
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static void Gia_ObjSetTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:535
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
int Gia_ManCountDupLut ( Gia_Man_t p)

Definition at line 369 of file giaIf.c.

370 {
371  Gia_Obj_t * pObj, * pFanin;
372  int i, pFanins[3], nCountDup = 0, nCountPis = 0, nCountMux = 0;
373  Gia_ManCleanMark01( p );
374  Gia_ManForEachLut( p, i )
375  if ( Gia_ObjLutIsMux(p, i) )
376  {
377  pObj = Gia_ManObj( p, i );
378  pObj->fMark1 = 1;
379  if ( Gia_ObjLutSize(p, i) == 3 )
380  {
381  Gia_ManPrintGetMuxFanins( p, pObj, pFanins );
382 
383  pFanin = Gia_ManObj(p, pFanins[1]);
384  nCountPis += Gia_ObjIsCi(pFanin);
385  nCountDup += pFanin->fMark0;
386  nCountMux += pFanin->fMark1;
387  pFanin->fMark0 = 1;
388 
389  pFanin = Gia_ManObj(p, pFanins[2]);
390  nCountPis += Gia_ObjIsCi(pFanin);
391  nCountDup += pFanin->fMark0;
392  nCountMux += pFanin->fMark1;
393  pFanin->fMark0 = 1;
394  }
395  else if ( Gia_ObjLutSize(p, i) == 2 )
396  {
397  pFanin = Gia_ObjFanin0(pObj);
398  if ( pFanin->fMark0 || pFanin->fMark1 )
399  {
400  pFanin = Gia_ObjFanin1(pObj);
401  nCountPis += Gia_ObjIsCi(pFanin);
402  nCountDup += pFanin->fMark0;
403  nCountMux += pFanin->fMark1;
404  pFanin->fMark0 = 1;
405  }
406  else
407  {
408  nCountPis += Gia_ObjIsCi(pFanin);
409  nCountDup += pFanin->fMark0;
410  nCountMux += pFanin->fMark1;
411  pFanin->fMark0 = 1;
412  }
413  }
414  else assert( 0 );
415  }
416  Gia_ManCleanMark01( p );
417  if ( nCountDup + nCountPis + nCountMux )
418  printf( "Dup fanins = %d. CI fanins = %d. MUX fanins = %d. Total = %d. (%.2f %%)\n",
419  nCountDup, nCountPis, nCountMux, nCountDup + nCountPis, 100.0 * (nCountDup + nCountPis + nCountMux) / Gia_ManLutNum(p) );
420  return nCountDup + nCountPis;
421 }
unsigned fMark1
Definition: gia.h:84
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
void Gia_ManPrintGetMuxFanins(Gia_Man_t *p, Gia_Obj_t *pObj, int *pFanins)
Definition: giaIf.c:361
int Gia_ManLutNum(Gia_Man_t *p)
Definition: giaIf.c:144
if(last==0)
Definition: sparse_int.h:34
static int Gia_ObjLutIsMux(Gia_Man_t *p, int Id)
Definition: gia.h:957
unsigned fMark0
Definition: gia.h:79
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
void Gia_ManCleanMark01(Gia_Man_t *p)
Definition: giaUtil.c:177
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
Gia_Man_t* Gia_ManFromIfAig ( If_Man_t pIfMan)

Definition at line 880 of file giaIf.c.

881 {
882  int fHash = 0;
883  Gia_Man_t * pNew, * pTemp;
884  If_Obj_t * pIfObj, * pIfLeaf;
885  If_Cut_t * pCutBest;
886  Vec_Int_t * vLeaves;
887  Vec_Int_t * vAig;
888  int i, k;
889  assert( pIfMan->pPars->pLutStruct == NULL );
890  assert( pIfMan->pPars->fDelayOpt || pIfMan->pPars->fDsdBalance || pIfMan->pPars->fUserRecLib );
891  // create new manager
892  pNew = Gia_ManStart( If_ManObjNum(pIfMan) );
893  Gia_ManHashAlloc( pNew );
894  // iterate through nodes used in the mapping
895  vAig = Vec_IntAlloc( 1 << 16 );
896  vLeaves = Vec_IntAlloc( 16 );
897 // If_ManForEachObj( pIfMan, pIfObj, i )
898 // pIfObj->iCopy = 0;
899  If_ManForEachObj( pIfMan, pIfObj, i )
900  {
901  if ( pIfObj->nRefs == 0 && !If_ObjIsTerm(pIfObj) )
902  continue;
903  if ( If_ObjIsAnd(pIfObj) )
904  {
905  pCutBest = If_ObjCutBest( pIfObj );
906  // if the cut does not offer delay improvement
907 // if ( (int)pIfObj->Level <= (int)pCutBest->Delay )
908 // {
909 // Gia_ManFromIfAig_rec( pNew, pIfMan, pIfObj );
910 // continue;
911 // }
912  // collect leaves of the best cut
913  Vec_IntClear( vLeaves );
914  If_CutForEachLeaf( pIfMan, pCutBest, pIfLeaf, k )
915  Vec_IntPush( vLeaves, pIfLeaf->iCopy );
916  // get the functionality
917  if ( pIfMan->pPars->fDelayOpt )
918  pIfObj->iCopy = Gia_ManBuildFromMini( pNew, pIfMan, pCutBest, vLeaves, vAig, fHash, 0 );
919  else if ( pIfMan->pPars->fDsdBalance )
920  pIfObj->iCopy = Gia_ManBuildFromMini( pNew, pIfMan, pCutBest, vLeaves, vAig, fHash, 1 );
921  else if ( pIfMan->pPars->fUserRecLib )
922  pIfObj->iCopy = Abc_RecToGia3( pNew, pIfMan, pCutBest, vLeaves, fHash );
923  else assert( 0 );
924  }
925  else if ( If_ObjIsCi(pIfObj) )
926  pIfObj->iCopy = Gia_ManAppendCi(pNew);
927  else if ( If_ObjIsCo(pIfObj) )
928  pIfObj->iCopy = Gia_ManAppendCo( pNew, Abc_LitNotCond(If_ObjFanin0(pIfObj)->iCopy, If_ObjFaninC0(pIfObj)) );
929  else if ( If_ObjIsConst1(pIfObj) )
930  pIfObj->iCopy = 1;
931  else assert( 0 );
932  }
933  Vec_IntFree( vAig );
934  Vec_IntFree( vLeaves );
935  pNew = Gia_ManRehash( pTemp = pNew, 0 );
936  Gia_ManStop( pTemp );
937  return pNew;
938 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
Definition: if.h:275
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int If_ObjFaninC0(If_Obj_t *pObj)
Definition: if.h:382
char * pLutStruct
Definition: if.h:141
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int Abc_RecToGia3(Gia_Man_t *pMan, If_Man_t *pIfMan, If_Cut_t *pCut, Vec_Int_t *vLeaves, int fHash)
Definition: abcRec3.c:1105
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
int nRefs
Definition: if.h:318
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
int fDsdBalance
Definition: if.h:123
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
Gia_Man_t * Gia_ManRehash(Gia_Man_t *p, int fAddStrash)
Definition: giaHash.c:719
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int If_ObjIsTerm(If_Obj_t *pObj)
Definition: if.h:375
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
If_Par_t * pPars
Definition: if.h:184
int Gia_ManBuildFromMini(Gia_Man_t *pNew, If_Man_t *pIfMan, If_Cut_t *pCut, Vec_Int_t *vLeaves, Vec_Int_t *vAig, int fHash, int fUseDsd)
Definition: giaIf.c:848
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
Definition: gia.h:95
int fUserRecLib
Definition: if.h:124
int fDelayOpt
Definition: if.h:121
#define assert(ex)
Definition: util_old.h:213
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Gia_ManFromIfAig_rec ( Gia_Man_t pNew,
If_Man_t pIfMan,
If_Obj_t pIfObj 
)

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

Synopsis [Converts IF into GIA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 868 of file giaIf.c.

869 {
870  int iLit0, iLit1;
871  if ( pIfObj->iCopy )
872  return pIfObj->iCopy;
873  iLit0 = Gia_ManFromIfAig_rec( pNew, pIfMan, pIfObj->pFanin0 );
874  iLit1 = Gia_ManFromIfAig_rec( pNew, pIfMan, pIfObj->pFanin1 );
875  iLit0 = Abc_LitNotCond( iLit0, pIfObj->fCompl0 );
876  iLit1 = Abc_LitNotCond( iLit1, pIfObj->fCompl1 );
877  pIfObj->iCopy = Gia_ManHashAnd( pNew, iLit0, iLit1 );
878  return pIfObj->iCopy;
879 }
If_Obj_t * pFanin0
Definition: if.h:321
int iCopy
Definition: if.h:329
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
int Gia_ManFromIfAig_rec(Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj)
Definition: giaIf.c:868
If_Obj_t * pFanin1
Definition: if.h:322
unsigned fCompl1
Definition: if.h:307
unsigned fCompl0
Definition: if.h:306
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
Gia_Man_t* Gia_ManFromIfLogic ( If_Man_t pIfMan)

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

Synopsis [Converts IF into GIA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1535 of file giaIf.c.

1536 {
1537  Gia_Man_t * pNew, * pHashed = NULL;
1538  If_Cut_t * pCutBest;
1539  If_Obj_t * pIfObj, * pIfLeaf;
1540  Vec_Int_t * vMapping, * vMapping2, * vPacking = NULL;
1541  Vec_Int_t * vLeaves, * vLeaves2, * vCover, * vLits;
1542  Vec_Int_t * vPiVars = NULL, * vPoVars = NULL;
1543  sat_solver * pSat = NULL;
1544  Ifn_Ntk_t * pNtkCell = NULL;
1545  int i, k, nLutMax = -1, Entry;
1546  assert( !pIfMan->pPars->fDeriveLuts || pIfMan->pPars->fTruth );
1547 // if ( pIfMan->pPars->fEnableCheck07 )
1548 // pIfMan->pPars->fDeriveLuts = 0;
1549  // start mapping and packing
1550  vMapping = Vec_IntStart( If_ManObjNum(pIfMan) );
1551  vMapping2 = Vec_IntStart( 1 );
1552  if ( pIfMan->pPars->fDeriveLuts && (pIfMan->pPars->pLutStruct || pIfMan->pPars->fEnableCheck75 || pIfMan->pPars->fEnableCheck75u || pIfMan->pPars->fEnableCheck07 || pIfMan->pPars->fUseDsdTune) )
1553  {
1554  vPacking = Vec_IntAlloc( 1000 );
1555  Vec_IntPush( vPacking, 0 );
1556  }
1557  // create new manager
1558  pNew = Gia_ManStart( If_ManObjNum(pIfMan) );
1559  // iterate through nodes used in the mapping
1560  vLits = Vec_IntAlloc( 1000 );
1561  vCover = Vec_IntAlloc( 1 << 16 );
1562  vLeaves = Vec_IntAlloc( 16 );
1563  vLeaves2 = Vec_IntAlloc( 16 );
1564  If_ManCleanCutData( pIfMan );
1565  If_ManForEachObj( pIfMan, pIfObj, i )
1566  {
1567  if ( pIfObj->nRefs == 0 && !If_ObjIsTerm(pIfObj) )
1568  continue;
1569  if ( If_ObjIsAnd(pIfObj) )
1570  {
1571  pCutBest = If_ObjCutBest( pIfObj );
1572  // perform sorting of cut leaves by delay, so that the slowest pin drives the fastest input of the LUT
1573  if ( !pIfMan->pPars->fUseTtPerm && !pIfMan->pPars->fDelayOpt && !pIfMan->pPars->fDelayOptLut && !pIfMan->pPars->fDsdBalance &&
1574  !pIfMan->pPars->pLutStruct && !pIfMan->pPars->fUserRecLib && !pIfMan->pPars->nGateSize && !pIfMan->pPars->fEnableCheck75 &&
1575  !pIfMan->pPars->fEnableCheck75u && !pIfMan->pPars->fEnableCheck07 && !pIfMan->pPars->fUseDsdTune &&
1576  !pIfMan->pPars->fUseCofVars && !pIfMan->pPars->fUseAndVars )
1577  If_CutRotatePins( pIfMan, pCutBest );
1578  // collect leaves of the best cut
1579  Vec_IntClear( vLeaves );
1580  If_CutForEachLeaf( pIfMan, pCutBest, pIfLeaf, k )
1581  Vec_IntPush( vLeaves, pIfLeaf->iCopy );
1582  // perform one of the two types of mapping: with and without structures
1583  if ( pIfMan->pPars->fUseDsd && pIfMan->pPars->pLutStruct )
1584  {
1585  if ( pSat == NULL )
1586  pSat = (sat_solver *)If_ManSatBuildXY( (int)(pIfMan->pPars->pLutStruct[0] - '0') );
1587  if ( pIfMan->pPars->pLutStruct && pIfMan->pPars->fDeriveLuts )
1588  pIfObj->iCopy = Gia_ManFromIfLogicFindLut( pIfMan, pNew, pCutBest, pSat, vLeaves, vLits, vCover, vMapping, vMapping2, vPacking );
1589  else
1590  pIfObj->iCopy = Gia_ManFromIfLogicCreateLut( pNew, If_CutTruthW(pIfMan, pCutBest), vLeaves, vCover, vMapping, vMapping2 );
1591  pIfObj->iCopy = Abc_LitNotCond( pIfObj->iCopy, pCutBest->fCompl );
1592  }
1593  else if ( pIfMan->pPars->fUseDsd && pIfMan->pPars->fUseDsdTune && pIfMan->pPars->fDeriveLuts )
1594  {
1595  if ( pSat == NULL )
1596  {
1597  pSat = (sat_solver *)If_ManSatBuildFromCell( If_DsdManGetCellStr(pIfMan->pIfDsdMan), &vPiVars, &vPoVars, &pNtkCell );
1598  nLutMax = Ifn_NtkLutSizeMax( pNtkCell );
1599  pHashed = Gia_ManStart( 10000 );
1600  Vec_IntFillExtra( &pHashed->vCopies, 10000, -1 );
1601  for ( k = 0; k < pIfMan->pPars->nLutSize; k++ )
1602  Gia_ManAppendCi( pHashed );
1603  Gia_ManHashAlloc( pHashed );
1604  }
1605  pIfObj->iCopy = Gia_ManFromIfLogicFindCell( pIfMan, pNew, pHashed, pCutBest, pSat, vPiVars, vPoVars, pNtkCell, nLutMax, vLeaves, vLits, vCover, vMapping, vMapping2, vPacking );
1606  pIfObj->iCopy = Abc_LitNotCond( pIfObj->iCopy, pCutBest->fCompl );
1607  }
1608  else if ( pIfMan->pPars->fUseCofVars && pIfMan->pPars->fDeriveLuts && (int)pCutBest->nLeaves > pIfMan->pPars->nLutSize/2 )
1609  {
1610  word pTruthCof[128], * pTruth = If_CutTruthW(pIfMan, pCutBest);
1611  int pVarsNew[16], nVarsNew, iLitCofs[3];
1612  int nLeaves = pCutBest->nLeaves;
1613  int nWords = Abc_Truth6WordNum(nLeaves);
1614  int truthId = Abc_Lit2Var(pCutBest->iCutFunc);
1615  int c, iVar = Vec_StrEntry(pIfMan->vTtVars[nLeaves], truthId), iTemp, iTopLit;
1616  assert( iVar >= 0 && iVar < nLeaves && pIfMan->pPars->nLutSize <= 13 );
1617  for ( c = 0; c < 2; c++ )
1618  {
1619  for ( k = 0; k < nLeaves; k++ )
1620  pVarsNew[k] = k;
1621  if ( c )
1622  Abc_TtCofactor1p( pTruthCof, pTruth, nWords, iVar );
1623  else
1624  Abc_TtCofactor0p( pTruthCof, pTruth, nWords, iVar );
1625  nVarsNew = Abc_TtMinBase( pTruthCof, pVarsNew, pCutBest->nLeaves, Abc_MaxInt(6, pCutBest->nLeaves) );
1626  // derive LUT
1627  Vec_IntClear( vLeaves2 );
1628  for ( k = 0; k < nVarsNew; k++ )
1629  Vec_IntPush( vLeaves2, Vec_IntEntry(vLeaves, pVarsNew[k]) );
1630  iLitCofs[c] = Kit_TruthToGia( pNew, (unsigned *)pTruthCof, nVarsNew, vCover, vLeaves2, 0 );
1631  if ( nVarsNew < 2 )
1632  continue;
1633  // create mapping
1634  assert( Gia_ObjIsAnd(Gia_ManObj(pNew, Abc_Lit2Var(iLitCofs[c]))) );
1635  Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLitCofs[c]), Vec_IntSize(vMapping2) );
1636  Vec_IntPush( vMapping2, Vec_IntSize(vLeaves2) );
1637  Vec_IntForEachEntry( vLeaves2, iTemp, k )
1638  Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
1639  Vec_IntPush( vMapping2, Abc_Lit2Var(iLitCofs[c]) );
1640  }
1641  iLitCofs[2] = Vec_IntEntry(vLeaves, iVar);
1642  // derive MUX
1643  if ( iLitCofs[0] > 1 && iLitCofs[1] > 1 )
1644  {
1645  pTruthCof[0] = ABC_CONST(0xCACACACACACACACA);
1646  Vec_IntClear( vLeaves2 );
1647  Vec_IntPush( vLeaves2, iLitCofs[0] );
1648  Vec_IntPush( vLeaves2, iLitCofs[1] );
1649  Vec_IntPush( vLeaves2, iLitCofs[2] );
1650  pIfObj->iCopy = Kit_TruthToGia( pNew, (unsigned *)pTruthCof, Vec_IntSize(vLeaves2), vCover, vLeaves2, 0 );
1651  iTopLit = pIfObj->iCopy;
1652  }
1653  else
1654  {
1655  assert( iLitCofs[0] > 1 || iLitCofs[1] > 1 );
1656  // collect leaves
1657  Vec_IntClear( vLeaves2 );
1658  for ( k = 0; k < 3; k++ )
1659  if ( iLitCofs[k] > 1 )
1660  Vec_IntPush( vLeaves2, iLitCofs[k] );
1661  assert( Vec_IntSize(vLeaves2) == 2 );
1662  // consider three possibilities
1663  if ( iLitCofs[0] == 0 )
1664  pIfObj->iCopy = Gia_ManAppendAnd( pNew, iLitCofs[2], iLitCofs[1] );
1665  else if ( iLitCofs[0] == 1 )
1666  pIfObj->iCopy = Gia_ManAppendOr( pNew, Abc_LitNot(iLitCofs[2]), iLitCofs[1] );
1667  else if ( iLitCofs[1] == 0 )
1668  pIfObj->iCopy = Gia_ManAppendAnd( pNew, Abc_LitNot(iLitCofs[2]), iLitCofs[0] );
1669  else if ( iLitCofs[1] == 1 )
1670  pIfObj->iCopy = Gia_ManAppendOr( pNew, iLitCofs[2], iLitCofs[0] );
1671  else assert( 0 );
1672  iTopLit = iLitCofs[2];
1673  }
1674  // create mapping
1675  Vec_IntSetEntry( vMapping, Abc_Lit2Var(pIfObj->iCopy), Vec_IntSize(vMapping2) );
1676  Vec_IntPush( vMapping2, Vec_IntSize(vLeaves2) );
1677  Vec_IntForEachEntry( vLeaves2, iTemp, k )
1678  Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
1679  Vec_IntPush( vMapping2, -Abc_Lit2Var(iTopLit) );
1680  pIfObj->iCopy = Abc_LitNotCond( pIfObj->iCopy, pCutBest->fCompl );
1681  }
1682  else if ( pIfMan->pPars->fUseAndVars && pIfMan->pPars->fDeriveLuts && (int)pCutBest->nLeaves > pIfMan->pPars->nLutSize/2 )
1683  {
1684  assert( 0 );
1685  }
1686  else if ( (pIfMan->pPars->fDeriveLuts && pIfMan->pPars->fTruth) || pIfMan->pPars->fUseDsd || pIfMan->pPars->fUseTtPerm )
1687  {
1688  word * pTruth = If_CutTruthW(pIfMan, pCutBest);
1689  if ( pIfMan->pPars->fUseTtPerm )
1690  for ( k = 0; k < (int)pCutBest->nLeaves; k++ )
1691  if ( If_CutLeafBit(pCutBest, k) )
1692  Abc_TtFlip( pTruth, Abc_TtWordNum(pCutBest->nLeaves), k );
1693  // perform decomposition of the cut
1694  pIfObj->iCopy = Gia_ManFromIfLogicNode( pIfMan, pNew, i, vLeaves, vLeaves2, pTruth, pIfMan->pPars->pLutStruct, vCover, vMapping, vMapping2, vPacking, (pIfMan->pPars->fEnableCheck75 || pIfMan->pPars->fEnableCheck75u), pIfMan->pPars->fEnableCheck07 );
1695  pIfObj->iCopy = Abc_LitNotCond( pIfObj->iCopy, pCutBest->fCompl );
1696  }
1697  else
1698  {
1699  pIfObj->iCopy = Gia_ManNodeIfToGia( pNew, pIfMan, pIfObj, vLeaves, 0 );
1700  // write mapping
1701  Vec_IntSetEntry( vMapping, Abc_Lit2Var(pIfObj->iCopy), Vec_IntSize(vMapping2) );
1702  Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
1703  Vec_IntForEachEntry( vLeaves, Entry, k )
1704  assert( Abc_Lit2Var(Entry) < Abc_Lit2Var(pIfObj->iCopy) );
1705  Vec_IntForEachEntry( vLeaves, Entry, k )
1706  Vec_IntPush( vMapping2, Abc_Lit2Var(Entry) );
1707  Vec_IntPush( vMapping2, Abc_Lit2Var(pIfObj->iCopy) );
1708  }
1709  }
1710  else if ( If_ObjIsCi(pIfObj) )
1711  pIfObj->iCopy = Gia_ManAppendCi(pNew);
1712  else if ( If_ObjIsCo(pIfObj) )
1713  pIfObj->iCopy = Gia_ManAppendCo( pNew, Abc_LitNotCond(If_ObjFanin0(pIfObj)->iCopy, If_ObjFaninC0(pIfObj)) );
1714  else if ( If_ObjIsConst1(pIfObj) )
1715  {
1716  pIfObj->iCopy = 1;
1717  // create const LUT
1718  Vec_IntWriteEntry( vMapping, 0, Vec_IntSize(vMapping2) );
1719  Vec_IntPush( vMapping2, 0 );
1720  Vec_IntPush( vMapping2, 0 );
1721  }
1722  else assert( 0 );
1723  }
1724  Vec_IntFree( vLits );
1725  Vec_IntFree( vCover );
1726  Vec_IntFree( vLeaves );
1727  Vec_IntFree( vLeaves2 );
1728  Vec_IntFreeP( &vPiVars );
1729  Vec_IntFreeP( &vPoVars );
1730  if ( pNtkCell )
1731  ABC_FREE( pNtkCell );
1732  if ( pSat )
1733  sat_solver_delete(pSat);
1734  if ( pHashed )
1735  Gia_ManStop( pHashed );
1736 // printf( "Mapping array size: IfMan = %d. Gia = %d. Increase = %.2f\n",
1737 // If_ManObjNum(pIfMan), Gia_ManObjNum(pNew), 1.0 * Gia_ManObjNum(pNew) / If_ManObjNum(pIfMan) );
1738  // finish mapping
1739  if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
1740  Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
1741  else
1742  Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
1743  assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
1744  Vec_IntForEachEntry( vMapping, Entry, i )
1745  if ( Entry > 0 )
1746  Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
1747  Vec_IntAppend( vMapping, vMapping2 );
1748  Vec_IntFree( vMapping2 );
1749  // attach mapping and packing
1750  assert( pNew->vMapping == NULL );
1751  assert( pNew->vPacking == NULL );
1752  pNew->vMapping = vMapping;
1753  pNew->vPacking = vPacking;
1754  // verify that COs have mapping
1755  {
1756  Gia_Obj_t * pObj;
1757  Gia_ManForEachCo( pNew, pObj, i )
1758  assert( !Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) || Gia_ObjIsLut(pNew, Gia_ObjFaninId0p(pNew, pObj)) );
1759  }
1760  // verify that internal nodes have mapping
1761  {
1762  Gia_Obj_t * pFanin;
1763  Gia_ManForEachLut( pNew, i )
1764  Gia_LutForEachFaninObj( pNew, i, pFanin, k )
1765  assert( !Gia_ObjIsAnd(pFanin) || Gia_ObjIsLut(pNew, Gia_ObjId(pNew, pFanin)) );
1766  }
1767  // verify that CIs have no mapping
1768  {
1769  Gia_Obj_t * pObj;
1770  Gia_ManForEachCi( pNew, pObj, i )
1771  assert( !Gia_ObjIsLut(pNew, Gia_ObjId(pNew, pObj)) );
1772  }
1773  return pNew;
1774 }
void If_CutRotatePins(If_Man_t *p, If_Cut_t *pCut)
Definition: ifTruth.c:67
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
unsigned nLeaves
Definition: if.h:289
Vec_Str_t * vTtVars[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:248
static int Abc_TtMinBase(word *pTruth, int *pVars, int nVars, int nVarsAll)
Definition: utilTruth.h:1395
int nLutSize
Definition: if.h:103
int iCopy
Definition: if.h:329
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static void Abc_TtCofactor1p(word *pOut, word *pIn, int nWords, int iVar)
Definition: utilTruth.h:403
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: if.h:303
int Gia_ManFromIfLogicFindCell(If_Man_t *pIfMan, Gia_Man_t *pNew, Gia_Man_t *pTemp, If_Cut_t *pCutBest, sat_solver *pSat, Vec_Int_t *vPiVars, Vec_Int_t *vPoVars, Ifn_Ntk_t *pNtkCell, int nLutMax, Vec_Int_t *vLeaves, Vec_Int_t *vLits, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking)
Definition: giaIf.c:1470
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
Definition: if.h:275
int fDeriveLuts
Definition: if.h:138
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
int fDelayOptLut
Definition: if.h:122
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static int If_ObjFaninC0(If_Obj_t *pObj)
Definition: if.h:382
char * pLutStruct
Definition: if.h:141
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
int Ifn_NtkLutSizeMax(Ifn_Ntk_t *p)
Definition: ifTune.c:159
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int Gia_ManFromIfLogicCreateLut(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
Definition: giaIf.c:952
int nWords
Definition: abcNpn.c:127
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
int nRefs
Definition: if.h:318
int fUseCofVars
Definition: if.h:135
static int Gia_ManAppendOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:718
int fEnableCheck75u
Definition: if.h:132
int nGateSize
Definition: if.h:107
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
int fEnableCheck75
Definition: if.h:131
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
void * If_ManSatBuildFromCell(char *pStr, Vec_Int_t **pvPiVars, Vec_Int_t **pvPoVars, Ifn_Ntk_t **ppNtk)
Definition: ifTune.c:622
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
int fDsdBalance
Definition: if.h:123
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Abc_TtCofactor0p(word *pOut, word *pIn, int nWords, int iVar)
Definition: utilTruth.h:381
#define Gia_LutForEachFaninObj(p, i, pFanin, k)
Definition: gia.h:972
int fTruth
Definition: if.h:146
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int fEnableCheck07
Definition: if.h:128
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void * If_ManSatBuildXY(int nLutSize)
DECLARATIONS ///.
Definition: ifSat.c:45
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
int fUseAndVars
Definition: if.h:136
static int If_ObjIsTerm(If_Obj_t *pObj)
Definition: if.h:375
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:80
static void Abc_TtFlip(word *pTruth, int nWords, int iVar)
Definition: utilTruth.h:1130
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
static int If_CutLeafBit(If_Cut_t *pCut, int i)
Definition: if.h:396
int fUseDsd
Definition: if.h:133
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
If_Par_t * pPars
Definition: if.h:184
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_TtWordNum(int nVars)
Definition: utilTruth.h:169
int Gia_ManNodeIfToGia(Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Int_t *vLeaves, int fHash)
Definition: giaIf.c:1342
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
int fUseDsdTune
Definition: if.h:134
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Gia_ManFromIfLogicFindLut(If_Man_t *pIfMan, Gia_Man_t *pNew, If_Cut_t *pCutBest, sat_solver *pSat, Vec_Int_t *vLeaves, Vec_Int_t *vLits, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking)
Definition: giaIf.c:1380
Definition: gia.h:95
void If_ManCleanCutData(If_Man_t *p)
Definition: ifUtil.c:64
int fUserRecLib
Definition: if.h:124
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int fDelayOpt
Definition: if.h:121
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
char * If_DsdManGetCellStr(If_DsdMan_t *p)
Definition: ifDsd.c:203
int fUseTtPerm
Definition: if.h:137
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
unsigned fCompl
Definition: if.h:285
int Gia_ManFromIfLogicNode(void *pIfMan, Gia_Man_t *pNew, int iObj, Vec_Int_t *vLeaves, Vec_Int_t *vLeavesTemp, word *pRes, char *pStr, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking, int fCheck75, int fCheck44e)
Definition: giaIf.c:1037
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int iCutFunc
Definition: if.h:281
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Vec_Int_t vCopies
Definition: gia.h:138
int Gia_ManFromIfLogicCreateLut ( Gia_Man_t pNew,
word pRes,
Vec_Int_t vLeaves,
Vec_Int_t vCover,
Vec_Int_t vMapping,
Vec_Int_t vMapping2 
)

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

Synopsis [Write mapping for LUT with given fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 952 of file giaIf.c.

953 {
954  int i, iLit, iObjLit1;
955  iObjLit1 = Kit_TruthToGia( pNew, (unsigned *)pRes, Vec_IntSize(vLeaves), vCover, vLeaves, 0 );
956  // do not create LUT in the simple case
957  if ( Abc_Lit2Var(iObjLit1) == 0 )
958  return iObjLit1;
959  Vec_IntForEachEntry( vLeaves, iLit, i )
960  if ( Abc_Lit2Var(iObjLit1) == Abc_Lit2Var(iLit) )
961  return iObjLit1;
962  // write mapping
963  Vec_IntSetEntry( vMapping, Abc_Lit2Var(iObjLit1), Vec_IntSize(vMapping2) );
964  Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
965 // Vec_IntForEachEntry( vLeaves, iLit, i )
966 // assert( Abc_Lit2Var(iLit) < Abc_Lit2Var(iObjLit1) );
967  Vec_IntForEachEntry( vLeaves, iLit, i )
968  Vec_IntPush( vMapping2, Abc_Lit2Var(iLit) );
969  Vec_IntPush( vMapping2, Abc_Lit2Var(iObjLit1) );
970  return iObjLit1;
971 }
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:80
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Gia_ManFromIfLogicCreateLutSpecial ( Gia_Man_t pNew,
word pRes,
Vec_Int_t vLeaves,
Vec_Int_t vLeavesTemp,
Vec_Int_t vCover,
Vec_Int_t vMapping,
Vec_Int_t vMapping2,
Vec_Int_t vPacking 
)

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

Synopsis [Write mapping for LUT with given fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 984 of file giaIf.c.

985 {
986  word z = If_CutPerformDerive07( NULL, (unsigned *)pRes, Vec_IntSize(vLeaves), Vec_IntSize(vLeaves), NULL );
987  word Truth;
988  int i, iObjLit1, iObjLit2;
989  // create first LUT
990  Vec_IntClear( vLeavesTemp );
991  for ( i = 0; i < 4; i++ )
992  {
993  int v = (int)((z >> (16+(i<<2))) & 7);
994  if ( v == 6 && Vec_IntSize(vLeaves) == 5 )
995  continue;
996  Vec_IntPush( vLeavesTemp, Vec_IntEntry(vLeaves, v) );
997  }
998  Truth = (z & 0xffff);
999  Truth |= (Truth << 16);
1000  Truth |= (Truth << 32);
1001  iObjLit1 = Gia_ManFromIfLogicCreateLut( pNew, &Truth, vLeavesTemp, vCover, vMapping, vMapping2 );
1002  // create second LUT
1003  Vec_IntClear( vLeavesTemp );
1004  for ( i = 0; i < 4; i++ )
1005  {
1006  int v = (int)((z >> (48+(i<<2))) & 7);
1007  if ( v == 6 && Vec_IntSize(vLeaves) == 5 )
1008  continue;
1009  if ( v == 7 )
1010  Vec_IntPush( vLeavesTemp, iObjLit1 );
1011  else
1012  Vec_IntPush( vLeavesTemp, Vec_IntEntry(vLeaves, v) );
1013  }
1014  Truth = ((z >> 32) & 0xffff);
1015  Truth |= (Truth << 16);
1016  Truth |= (Truth << 32);
1017  iObjLit2 = Gia_ManFromIfLogicCreateLut( pNew, &Truth, vLeavesTemp, vCover, vMapping, vMapping2 );
1018  // write packing
1019  Vec_IntPush( vPacking, 2 );
1020  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit1) );
1021  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit2) );
1022  Vec_IntAddToEntry( vPacking, 0, 1 );
1023  return iObjLit2;
1024 }
word If_CutPerformDerive07(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition: ifDec07.c:1029
int Gia_ManFromIfLogicCreateLut(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
Definition: giaIf.c:952
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Gia_ManFromIfLogicFindCell ( If_Man_t pIfMan,
Gia_Man_t pNew,
Gia_Man_t pTemp,
If_Cut_t pCutBest,
sat_solver pSat,
Vec_Int_t vPiVars,
Vec_Int_t vPoVars,
Ifn_Ntk_t pNtkCell,
int  nLutMax,
Vec_Int_t vLeaves,
Vec_Int_t vLits,
Vec_Int_t vCover,
Vec_Int_t vMapping,
Vec_Int_t vMapping2,
Vec_Int_t vPacking 
)

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

Synopsis [Converts IF into GIA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1470 of file giaIf.c.

1471 {
1472  int iLit;
1473  if ( Vec_IntSize(vLeaves) <= nLutMax )
1474  iLit = Gia_ManFromIfLogicCreateLut( pNew, If_CutTruthW(pIfMan, pCutBest), vLeaves, vCover, vMapping, vMapping2 );
1475  else
1476  {
1477  Gia_Obj_t * pObj;
1478  int i, Id, iLitTemp;
1479  // extract variable permutation
1480  char * pCutPerm = If_CutDsdPerm( pIfMan, pCutBest ); // DSD input -> cut input
1481  word Perm = If_DsdManGetFuncPerm( pIfMan->pIfDsdMan, If_CutDsdLit(pIfMan, pCutBest) ); // cell input -> DSD input
1482  assert( Perm > 0 );
1483  // (extend storage for configuration bits)
1484  // derive mapping from cell inputs into cut inputs
1485  // retrieve config bits of the LUTs
1486  // perform boolean matching
1487  if ( !If_ManSatFindCofigBits( pSat, vPiVars, vPoVars, If_CutTruthW(pIfMan, pCutBest), Vec_IntSize(vLeaves), Perm, Ifn_NtkInputNum(pNtkCell), vLits ) )
1488  {
1489  printf( "Boolean matching does not exist.\n" );
1490  return -1;
1491  }
1492  // use config bits to generate the network
1493  iLit = If_ManSatDeriveGiaFromBits( pTemp, pNtkCell, vLits, vCover );
1494  // copy GIA back into the manager
1495  Vec_IntFillExtra( &pTemp->vCopies, Gia_ManObjNum(pTemp), -1 );
1496  Gia_ObjSetCopyArray( pTemp, 0, 0 );
1497  Vec_IntForEachEntry( vLeaves, iLitTemp, i )
1498  Gia_ObjSetCopyArray( pTemp, Gia_ManCiIdToId(pTemp, i), iLitTemp );
1499  // collect nodes
1500  Gia_ManIncrementTravId( pTemp );
1501  Id = Abc_Lit2Var( iLit );
1502  Gia_ManCollectAnds( pTemp, &Id, 1, vCover );
1503  Vec_IntPrint( vCover );
1504  Gia_ManForEachObjVec( vCover, pTemp, pObj, i )
1505  Gia_ObjPrint( pTemp, pObj );
1506  // copy GIA
1507  Gia_ManForEachObjVec( vCover, pTemp, pObj, i )
1508  {
1509  iLit = Gia_ManAppendAnd( pNew, Gia_ObjFanin0CopyArray(pTemp, pObj), Gia_ObjFanin1CopyArray(pTemp, pObj) );
1510  Gia_ObjSetCopyArray( pTemp, Gia_ObjId(pTemp, pObj), iLit );
1511  }
1512  iLit = Abc_LitNotCond( Gia_ObjCopyArray(pTemp, Id), Abc_LitIsCompl(iLit) );
1513  }
1514  // write packing
1515  if ( !Gia_ObjIsCi(Gia_ManObj(pNew, Abc_Lit2Var(iLit))) && iLit > 1 )
1516  {
1517  Vec_IntPush( vPacking, 1 );
1518  Vec_IntPush( vPacking, Abc_Lit2Var(iLit) );
1519  Vec_IntAddToEntry( vPacking, 0, 1 );
1520  }
1521  return iLit;
1522 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
int If_ManSatFindCofigBits(void *pSat, Vec_Int_t *vPiVars, Vec_Int_t *vPoVars, word *pTruth, int nVars, word Perm, int nInps, Vec_Int_t *vValues)
Definition: ifTune.c:687
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
int Gia_ManFromIfLogicCreateLut(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
Definition: giaIf.c:952
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Gia_ObjFanin1CopyArray(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:494
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Gia_ObjCopyArray(Gia_Man_t *p, int iObj)
Definition: gia.h:487
int Ifn_NtkInputNum(Ifn_Ntk_t *p)
Definition: ifTune.c:167
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaUtil.c:1258
int If_ManSatDeriveGiaFromBits(void *pNew, Ifn_Ntk_t *p, Vec_Int_t *vLeaves, Vec_Int_t *vValues)
Definition: ifTune.c:731
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
word If_DsdManGetFuncPerm(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:199
static void Gia_ObjSetCopyArray(Gia_Man_t *p, int iObj, int iLit)
Definition: gia.h:488
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Gia_ManCollectAnds(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vNodes)
Definition: giaDfs.c:123
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFanin0CopyArray(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:493
static void Vec_IntPrint(Vec_Int_t *vVec)
Definition: vecInt.h:1803
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManCiIdToId(Gia_Man_t *p, int CiId)
Definition: gia.h:438
Vec_Int_t vCopies
Definition: gia.h:138
int Gia_ManFromIfLogicFindLut ( If_Man_t pIfMan,
Gia_Man_t pNew,
If_Cut_t pCutBest,
sat_solver pSat,
Vec_Int_t vLeaves,
Vec_Int_t vLits,
Vec_Int_t vCover,
Vec_Int_t vMapping,
Vec_Int_t vMapping2,
Vec_Int_t vPacking 
)

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

Synopsis [Converts IF into GIA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1380 of file giaIf.c.

1381 {
1382  word uBound, uFree;
1383  int nLutSize = (int)(pIfMan->pPars->pLutStruct[0] - '0');
1384  int nVarsF = 0, pVarsF[IF_MAX_FUNC_LUTSIZE];
1385  int nVarsB = 0, pVarsB[IF_MAX_FUNC_LUTSIZE];
1386  int nVarsS = 0, pVarsS[IF_MAX_FUNC_LUTSIZE];
1387  unsigned uSetNew, uSetOld;
1388  int RetValue, RetValue2, k;
1389  char * pPerm;
1390  if ( Vec_IntSize(vLeaves) <= nLutSize )
1391  {
1392  RetValue = Gia_ManFromIfLogicCreateLut( pNew, If_CutTruthW(pIfMan, pCutBest), vLeaves, vCover, vMapping, vMapping2 );
1393  // write packing
1394  if ( !Gia_ObjIsCi(Gia_ManObj(pNew, Abc_Lit2Var(RetValue))) && RetValue > 1 )
1395  {
1396  Vec_IntPush( vPacking, 1 );
1397  Vec_IntPush( vPacking, Abc_Lit2Var(RetValue) );
1398  Vec_IntAddToEntry( vPacking, 0, 1 );
1399  }
1400  return RetValue;
1401  }
1402  assert( If_DsdManSuppSize(pIfMan->pIfDsdMan, If_CutDsdLit(pIfMan, pCutBest)) == (int)pCutBest->nLeaves );
1403  // find the bound set
1404  if ( pIfMan->pPars->fDelayOptLut )
1405  uSetOld = pCutBest->uMaskFunc;
1406  else
1407  uSetOld = If_DsdManCheckXY( pIfMan->pIfDsdMan, If_CutDsdLit(pIfMan, pCutBest), nLutSize, 1, 0, 1, 0 );
1408  // remap bound set
1409  uSetNew = 0;
1410  pPerm = If_CutDsdPerm( pIfMan, pCutBest );
1411  for ( k = 0; k < If_CutLeaveNum(pCutBest); k++ )
1412  {
1413  int iVar = Abc_Lit2Var((int)pPerm[k]);
1414  int Value = ((uSetOld >> (k << 1)) & 3);
1415  if ( Value == 1 )
1416  uSetNew |= (1 << (2*iVar));
1417  else if ( Value == 3 )
1418  uSetNew |= (3 << (2*iVar));
1419  else assert( Value == 0 );
1420  }
1421  RetValue = If_ManSatCheckXY( pSat, nLutSize, If_CutTruthW(pIfMan, pCutBest), pCutBest->nLeaves, uSetNew, &uBound, &uFree, vLits );
1422  assert( RetValue );
1423  // collect variables
1424  for ( k = 0; k < If_CutLeaveNum(pCutBest); k++ )
1425  {
1426  int Value = ((uSetNew >> (k << 1)) & 3);
1427  if ( Value == 0 )
1428  pVarsF[nVarsF++] = k;
1429  else if ( Value == 1 )
1430  pVarsB[nVarsB++] = k;
1431  else if ( Value == 3 )
1432  pVarsS[nVarsS++] = k;
1433  else assert( Value == 0 );
1434  }
1435  // collect bound set variables
1436  Vec_IntClear( vLits );
1437  for ( k = 0; k < nVarsS; k++ )
1438  Vec_IntPush( vLits, Vec_IntEntry(vLeaves, pVarsS[k]) );
1439  for ( k = 0; k < nVarsB; k++ )
1440  Vec_IntPush( vLits, Vec_IntEntry(vLeaves, pVarsB[k]) );
1441  RetValue = Gia_ManFromIfLogicCreateLut( pNew, &uBound, vLits, vCover, vMapping, vMapping2 );
1442  // collecct free set variables
1443  Vec_IntClear( vLits );
1444  Vec_IntPush( vLits, RetValue );
1445  for ( k = 0; k < nVarsS; k++ )
1446  Vec_IntPush( vLits, Vec_IntEntry(vLeaves, pVarsS[k]) );
1447  for ( k = 0; k < nVarsF; k++ )
1448  Vec_IntPush( vLits, Vec_IntEntry(vLeaves, pVarsF[k]) );
1449  // add packing
1450  RetValue2 = Gia_ManFromIfLogicCreateLut( pNew, &uFree, vLits, vCover, vMapping, vMapping2 );
1451  // write packing
1452  Vec_IntPush( vPacking, 2 );
1453  Vec_IntPush( vPacking, Abc_Lit2Var(RetValue) );
1454  Vec_IntPush( vPacking, Abc_Lit2Var(RetValue2) );
1455  Vec_IntAddToEntry( vPacking, 0, 1 );
1456  return RetValue2;
1457 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
unsigned nLeaves
Definition: if.h:289
unsigned If_DsdManCheckXY(If_DsdMan_t *p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose)
Definition: ifDsd.c:1986
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
int fDelayOptLut
Definition: if.h:122
char * pLutStruct
Definition: if.h:141
int Gia_ManFromIfLogicCreateLut(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
Definition: giaIf.c:952
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int If_ManSatCheckXY(void *pSat, int nLutSize, word *pTruth, int nVars, unsigned uSet, word *pTBound, word *pTFree, Vec_Int_t *vLits)
Definition: ifSat.c:150
static int pPerm[13719]
Definition: rwrTemp.c:32
int If_DsdManSuppSize(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:181
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
If_Par_t * pPars
Definition: if.h:184
int uMaskFunc
Definition: if.h:282
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
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
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
int Gia_ManFromIfLogicNode ( void *  pIfMan,
Gia_Man_t pNew,
int  iObj,
Vec_Int_t vLeaves,
Vec_Int_t vLeavesTemp,
word pRes,
char *  pStr,
Vec_Int_t vCover,
Vec_Int_t vMapping,
Vec_Int_t vMapping2,
Vec_Int_t vPacking,
int  fCheck75,
int  fCheck44e 
)

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

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 1037 of file giaIf.c.

1039 {
1040  int nLeaves = Vec_IntSize(vLeaves);
1041  int i, Length, nLutLeaf, nLutLeaf2, nLutRoot, iObjLit1, iObjLit2, iObjLit3;
1042  // workaround for the special case
1043  if ( fCheck75 )
1044  pStr = "54";
1045  // perform special case matching for 44
1046  if ( fCheck44e )
1047  {
1048  if ( Vec_IntSize(vLeaves) <= 4 )
1049  {
1050  // create mapping
1051  iObjLit1 = Gia_ManFromIfLogicCreateLut( pNew, pRes, vLeaves, vCover, vMapping, vMapping2 );
1052  // write packing
1053  if ( !Gia_ObjIsCi(Gia_ManObj(pNew, Abc_Lit2Var(iObjLit1))) && iObjLit1 > 1 )
1054  {
1055  Vec_IntPush( vPacking, 1 );
1056  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit1) );
1057  Vec_IntAddToEntry( vPacking, 0, 1 );
1058  }
1059  return iObjLit1;
1060  }
1061  return Gia_ManFromIfLogicCreateLutSpecial( pNew, pRes, vLeaves, vLeavesTemp, vCover, vMapping, vMapping2, vPacking );
1062  }
1063  // check if there is no LUT structures
1064  if ( pStr == NULL )
1065  return Gia_ManFromIfLogicCreateLut( pNew, pRes, vLeaves, vCover, vMapping, vMapping2 );
1066  // quit if parameters are wrong
1067  Length = strlen(pStr);
1068  if ( Length != 2 && Length != 3 )
1069  {
1070  printf( "Wrong LUT struct (%s)\n", pStr );
1071  return -1;
1072  }
1073  for ( i = 0; i < Length; i++ )
1074  if ( pStr[i] - '0' < 3 || pStr[i] - '0' > 6 )
1075  {
1076  printf( "The LUT size (%d) should belong to {3,4,5,6}.\n", pStr[i] - '0' );
1077  return -1;
1078  }
1079 
1080  nLutLeaf = pStr[0] - '0';
1081  nLutLeaf2 = ( Length == 3 ) ? pStr[1] - '0' : 0;
1082  nLutRoot = pStr[Length-1] - '0';
1083  if ( nLeaves > nLutLeaf - 1 + (nLutLeaf2 ? nLutLeaf2 - 1 : 0) + nLutRoot )
1084  {
1085  printf( "The node size (%d) is too large for the LUT structure %s.\n", nLeaves, pStr );
1086  return -1;
1087  }
1088 
1089  // consider easy case
1090  if ( nLeaves <= Abc_MaxInt( nLutLeaf2, Abc_MaxInt(nLutLeaf, nLutRoot) ) )
1091  {
1092  // create mapping
1093  iObjLit1 = Gia_ManFromIfLogicCreateLut( pNew, pRes, vLeaves, vCover, vMapping, vMapping2 );
1094  // write packing
1095  if ( !Gia_ObjIsCi(Gia_ManObj(pNew, Abc_Lit2Var(iObjLit1))) && iObjLit1 > 1 )
1096  {
1097  Vec_IntPush( vPacking, 1 );
1098  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit1) );
1099  Vec_IntAddToEntry( vPacking, 0, 1 );
1100  }
1101  return iObjLit1;
1102  }
1103  else
1104  {
1105  extern int If_CluMinimumBase( word * t, int * pSupp, int nVarsAll, int * pnVars );
1106 
1107  static word TruthStore[16][1<<10] = {{0}}, * pTruths[16];
1108  word Func0, Func1, Func2;
1109  char pLut0[32], pLut1[32], pLut2[32] = {0};
1110 
1111  if ( TruthStore[0][0] == 0 )
1112  {
1113  static word Truth6[6] = {
1114  0xAAAAAAAAAAAAAAAA,
1115  0xCCCCCCCCCCCCCCCC,
1116  0xF0F0F0F0F0F0F0F0,
1117  0xFF00FF00FF00FF00,
1118  0xFFFF0000FFFF0000,
1119  0xFFFFFFFF00000000
1120  };
1121  int nVarsMax = 16;
1122  int nWordsMax = (1 << 10);
1123  int i, k;
1124  assert( nVarsMax <= 16 );
1125  for ( i = 0; i < nVarsMax; i++ )
1126  pTruths[i] = TruthStore[i];
1127  for ( i = 0; i < 6; i++ )
1128  for ( k = 0; k < nWordsMax; k++ )
1129  pTruths[i][k] = Truth6[i];
1130  for ( i = 6; i < nVarsMax; i++ )
1131  for ( k = 0; k < nWordsMax; k++ )
1132  pTruths[i][k] = ((k >> (i-6)) & 1) ? ~(word)0 : 0;
1133  }
1134  // derive truth table
1135  if ( Kit_TruthIsConst0((unsigned *)pRes, nLeaves) || Kit_TruthIsConst1((unsigned *)pRes, nLeaves) )
1136  {
1137 // fprintf( pFile, ".names %s\n %d\n", Abc_ObjName(Abc_ObjFanout0(pObj)), Kit_TruthIsConst1((unsigned *)pRes, nLeaves) );
1138  iObjLit1 = Abc_LitNotCond( 0, Kit_TruthIsConst1((unsigned *)pRes, nLeaves) );
1139  // write mapping
1140  if ( Vec_IntEntry(vMapping, 0) == 0 )
1141  {
1142  Vec_IntSetEntry( vMapping, 0, Vec_IntSize(vMapping2) );
1143  Vec_IntPush( vMapping2, 0 );
1144  Vec_IntPush( vMapping2, 0 );
1145  }
1146  return iObjLit1;
1147  }
1148  // check for elementary truth table
1149  for ( i = 0; i < nLeaves; i++ )
1150  {
1151  if ( Kit_TruthIsEqual((unsigned *)pRes, (unsigned *)pTruths[i], nLeaves) )
1152  return Vec_IntEntry(vLeaves, i);
1153  if ( Kit_TruthIsOpposite((unsigned *)pRes, (unsigned *)pTruths[i], nLeaves) )
1154  return Abc_LitNot(Vec_IntEntry(vLeaves, i));
1155  }
1156 
1157  // perform decomposition
1158  if ( fCheck75 )
1159  {
1160 // if ( nLeaves < 8 && If_CutPerformCheck16( p, (unsigned *)pTruth, nVars, nLeaves, "44" ) )
1161  if ( nLeaves < 8 && If_CluCheckExt( NULL, pRes, nLeaves, 4, 4, pLut0, pLut1, &Func0, &Func1 ) )
1162  {
1163  nLutLeaf = 4;
1164  nLutRoot = 4;
1165  }
1166 // if ( If_CutPerformCheck45( p, (unsigned *)pTruth, nVars, nLeaves, pStr ) )
1167  else if ( If_CluCheckExt( NULL, pRes, nLeaves, 5, 4, pLut0, pLut1, &Func0, &Func1 ) )
1168  {
1169  nLutLeaf = 5;
1170  nLutRoot = 4;
1171  }
1172 // if ( If_CutPerformCheck54( p, (unsigned *)pTruth, nVars, nLeaves, pStr ) )
1173  else if ( If_CluCheckExt( NULL, pRes, nLeaves, 4, 5, pLut0, pLut1, &Func0, &Func1 ) )
1174  {
1175  nLutLeaf = 4;
1176  nLutRoot = 5;
1177  }
1178  else
1179  {
1180  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1181  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1182  printf( "Node %d is not decomposable. Deriving LUT structures has failed.\n", iObj );
1183  return -1;
1184  }
1185  }
1186  else
1187  {
1188  if ( Length == 2 )
1189  {
1190  if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
1191  {
1192  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1193  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1194  printf( "Node %d is not decomposable. Deriving LUT structures has failed.\n", iObj );
1195  return -1;
1196  }
1197  }
1198  else
1199  {
1200  if ( !If_CluCheckExt3( pIfMan, pRes, nLeaves, nLutLeaf, nLutLeaf2, nLutRoot, pLut0, pLut1, pLut2, &Func0, &Func1, &Func2 ) )
1201  {
1202  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1203  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1204  printf( "Node %d is not decomposable. Deriving LUT structures has failed.\n", iObj );
1205  return -1;
1206  }
1207  }
1208  }
1209 
1210 /*
1211  // write leaf node
1212  Id = Abc2_NtkAllocObj( pNew, pLut1[0], Abc2_ObjType(pObj) );
1213  iObjLit1 = Abc_Var2Lit( Id, 0 );
1214  pObjNew = Abc2_NtkObj( pNew, Id );
1215  for ( i = 0; i < pLut1[0]; i++ )
1216  Abc2_ObjSetFaninLit( pObjNew, i, Abc2_ObjFaninCopy(pObj, pLut1[2+i]) );
1217  Abc2_ObjSetTruth( pObjNew, Func1 );
1218 */
1219  // write leaf node
1220  Vec_IntClear( vLeavesTemp );
1221  for ( i = 0; i < pLut1[0]; i++ )
1222  Vec_IntPush( vLeavesTemp, Vec_IntEntry(vLeaves, pLut1[2+i]) );
1223  iObjLit1 = Gia_ManFromIfLogicCreateLut( pNew, &Func1, vLeavesTemp, vCover, vMapping, vMapping2 );
1224 
1225  if ( Length == 3 && pLut2[0] > 0 )
1226  {
1227  /*
1228  Id = Abc2_NtkAllocObj( pNew, pLut2[0], Abc2_ObjType(pObj) );
1229  iObjLit2 = Abc_Var2Lit( Id, 0 );
1230  pObjNew = Abc2_NtkObj( pNew, Id );
1231  for ( i = 0; i < pLut2[0]; i++ )
1232  if ( pLut2[2+i] == nLeaves )
1233  Abc2_ObjSetFaninLit( pObjNew, i, iObjLit1 );
1234  else
1235  Abc2_ObjSetFaninLit( pObjNew, i, Abc2_ObjFaninCopy(pObj, pLut2[2+i]) );
1236  Abc2_ObjSetTruth( pObjNew, Func2 );
1237  */
1238 
1239  // write leaf node
1240  Vec_IntClear( vLeavesTemp );
1241  for ( i = 0; i < pLut2[0]; i++ )
1242  if ( pLut2[2+i] == nLeaves )
1243  Vec_IntPush( vLeavesTemp, iObjLit1 );
1244  else
1245  Vec_IntPush( vLeavesTemp, Vec_IntEntry(vLeaves, pLut2[2+i]) );
1246  iObjLit2 = Gia_ManFromIfLogicCreateLut( pNew, &Func2, vLeavesTemp, vCover, vMapping, vMapping2 );
1247 
1248  // write packing
1249  Vec_IntPush( vPacking, 3 );
1250  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit1) );
1251  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit2) );
1252  }
1253  else
1254  {
1255  // write packing
1256  Vec_IntPush( vPacking, 2 );
1257  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit1) );
1258  iObjLit2 = -1;
1259  }
1260 /*
1261  // write root node
1262  Id = Abc2_NtkAllocObj( pNew, pLut0[0], Abc2_ObjType(pObj) );
1263  iObjLit3 = Abc_Var2Lit( Id, 0 );
1264  pObjNew = Abc2_NtkObj( pNew, Id );
1265  for ( i = 0; i < pLut0[0]; i++ )
1266  if ( pLut0[2+i] == nLeaves )
1267  Abc2_ObjSetFaninLit( pObjNew, i, iObjLit1 );
1268  else if ( pLut0[2+i] == nLeaves+1 )
1269  Abc2_ObjSetFaninLit( pObjNew, i, iObjLit2 );
1270  else
1271  Abc2_ObjSetFaninLit( pObjNew, i, Abc2_ObjFaninCopy(pObj, pLut0[2+i]) );
1272  Abc2_ObjSetTruth( pObjNew, Func0 );
1273  Abc2_ObjSetCopy( pObj, iObjLit3 );
1274 */
1275  // write root node
1276  Vec_IntClear( vLeavesTemp );
1277  for ( i = 0; i < pLut0[0]; i++ )
1278  if ( pLut0[2+i] == nLeaves )
1279  Vec_IntPush( vLeavesTemp, iObjLit1 );
1280  else if ( pLut0[2+i] == nLeaves+1 )
1281  Vec_IntPush( vLeavesTemp, iObjLit2 );
1282  else
1283  Vec_IntPush( vLeavesTemp, Vec_IntEntry(vLeaves, pLut0[2+i]) );
1284  iObjLit3 = Gia_ManFromIfLogicCreateLut( pNew, &Func0, vLeavesTemp, vCover, vMapping, vMapping2 );
1285 
1286  // write packing
1287  Vec_IntPush( vPacking, Abc_Lit2Var(iObjLit3) );
1288  Vec_IntAddToEntry( vPacking, 0, 1 );
1289  }
1290  return iObjLit3;
1291 }
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
Definition: rwrTemp.c:30
int If_CluCheckExt(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutRoot, char *pLut0, char *pLut1, word *pFunc0, word *pFunc1)
Definition: ifDec16.c:2066
int If_CluCheckExt3(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, char *pLut0, char *pLut1, char *pLut2, word *pFunc0, word *pFunc1, word *pFunc2)
Definition: ifDec16.c:2079
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int Gia_ManFromIfLogicCreateLutSpecial(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vLeavesTemp, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2, Vec_Int_t *vPacking)
Definition: giaIf.c:984
int Gia_ManFromIfLogicCreateLut(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
Definition: giaIf.c:952
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
int If_CluMinimumBase(word *t, int *pSupp, int nVarsAll, int *pnVars)
Definition: ifDec16.c:1532
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static word Truth6[6]
Definition: ifDec07.c:52
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Kit_TruthIsOpposite(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:290
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
int strlen()
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
int Gia_ManLutFaninCount ( Gia_Man_t p)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file giaIf.c.

107 {
108  int i, Counter = 0;
109  Gia_ManForEachLut( p, i )
110  Counter += Gia_ObjLutSize(p, i);
111  return Counter;
112 }
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
static int Counter
int Gia_ManLutLevel ( Gia_Man_t p)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file giaIf.c.

164 {
165  Gia_Obj_t * pObj;
166  int i, k, iFan, Level;
167  int * pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
168  Gia_ManForEachLut( p, i )
169  {
170  Level = 0;
171  Gia_LutForEachFanin( p, i, iFan, k )
172  if ( Level < pLevels[iFan] )
173  Level = pLevels[iFan];
174  pLevels[i] = Level + 1;
175  }
176  Level = 0;
177  Gia_ManForEachCo( p, pObj, k )
178  if ( Level < pLevels[Gia_ObjFaninId0p(p, pObj)] )
179  Level = pLevels[Gia_ObjFaninId0p(p, pObj)];
180  ABC_FREE( pLevels );
181  return Level;
182 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
if(last==0)
Definition: sparse_int.h:34
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Gia_ManLutNum ( Gia_Man_t p)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 144 of file giaIf.c.

145 {
146  int i, Counter = 0;
147  Gia_ManForEachLut( p, i )
148  Counter ++;
149  return Counter;
150 }
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static int Counter
void Gia_ManLutParams ( Gia_Man_t p,
int *  pnCurLuts,
int *  pnCurEdges,
int *  pnCurLevels 
)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 195 of file giaIf.c.

196 {
197  if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) )
198  {
199  int i;
200  *pnCurLuts = 0;
201  *pnCurEdges = 0;
202  Gia_ManForEachLut( p, i )
203  {
204  (*pnCurLuts)++;
205  (*pnCurEdges) += Gia_ObjLutSize(p, i);
206  }
207  *pnCurLevels = Gia_ManLutLevelWithBoxes( p );
208  }
209  else
210  {
211  Gia_Obj_t * pObj;
212  int i, k, iFan;
213  int * pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
214  *pnCurLuts = 0;
215  *pnCurEdges = 0;
216  Gia_ManForEachLut( p, i )
217  {
218  int Level = 0;
219  (*pnCurLuts)++;
220  (*pnCurEdges) += Gia_ObjLutSize(p, i);
221  Gia_LutForEachFanin( p, i, iFan, k )
222  if ( Level < pLevels[iFan] )
223  Level = pLevels[iFan];
224  pLevels[i] = Level + 1;
225  }
226  *pnCurLevels = 0;
227  Gia_ManForEachCo( p, pObj, k )
228  if ( *pnCurLevels < pLevels[Gia_ObjFaninId0p(p, pObj)] )
229  *pnCurLevels = pLevels[Gia_ObjFaninId0p(p, pObj)];
230  ABC_FREE( pLevels );
231  }
232 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
if(last==0)
Definition: sparse_int.h:34
void * pManTime
Definition: gia.h:165
int Tim_ManBoxNum(Tim_Man_t *p)
Definition: timMan.c:702
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
int Gia_ManLutLevelWithBoxes(Gia_Man_t *p)
Definition: giaTim.c:572
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Gia_ManLutSizeMax ( Gia_Man_t p)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file giaIf.c.

126 {
127  int i, nSizeMax = -1;
128  Gia_ManForEachLut( p, i )
129  nSizeMax = Abc_MaxInt( nSizeMax, Gia_ObjLutSize(p, i) );
130  return nSizeMax;
131 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
void Gia_ManMappingVerify ( Gia_Man_t p)

Definition at line 1807 of file giaIf.c.

1808 {
1809  Gia_Obj_t * pObj, * pFanin;
1810  int i, Result = 1;
1811  assert( Gia_ManHasMapping(p) );
1813  Gia_ManForEachBuf( p, pObj, i )
1814  {
1815  pFanin = Gia_ObjFanin0(pObj);
1816  if ( !Gia_ObjIsAndNotBuf(pFanin) )
1817  continue;
1818  if ( !Gia_ObjIsLut(p, Gia_ObjId(p, pFanin)) )
1819  {
1820  Abc_Print( -1, "Gia_ManMappingVerify: CO driver %d does not have mapping.\n", Gia_ObjId(p, pFanin) );
1821  Result = 0;
1822  continue;
1823  }
1824  Result &= Gia_ManMappingVerify_rec( p, pFanin );
1825  }
1826  Gia_ManForEachCo( p, pObj, i )
1827  {
1828  pFanin = Gia_ObjFanin0(pObj);
1829  if ( !Gia_ObjIsAndNotBuf(pFanin) )
1830  continue;
1831  if ( !Gia_ObjIsLut(p, Gia_ObjId(p, pFanin)) )
1832  {
1833  Abc_Print( -1, "Gia_ManMappingVerify: CO driver %d does not have mapping.\n", Gia_ObjId(p, pFanin) );
1834  Result = 0;
1835  continue;
1836  }
1837  Result &= Gia_ManMappingVerify_rec( p, pFanin );
1838  }
1839 // if ( Result && Gia_NtkIsRoot(p) )
1840 // Abc_Print( 1, "Mapping verified correctly.\n" );
1841 }
static int Gia_ObjIsAndNotBuf(Gia_Obj_t *pObj)
Definition: gia.h:428
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
int Gia_ManMappingVerify_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaIf.c:1788
Definition: gia.h:75
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
#define Gia_ManForEachBuf(p, pObj, i)
Definition: gia.h:998
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
int Gia_ManMappingVerify_rec ( Gia_Man_t p,
Gia_Obj_t pObj 
)

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

Synopsis [Verifies mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 1788 of file giaIf.c.

1789 {
1790  int Id, iFan, k, Result = 1;
1791  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
1792  return 1;
1793  Gia_ObjSetTravIdCurrent(p, pObj);
1794  if ( !Gia_ObjIsAndNotBuf(pObj) )
1795  return 1;
1796  if ( !Gia_ObjIsLut(p, Gia_ObjId(p, pObj)) )
1797  {
1798  Abc_Print( -1, "Gia_ManMappingVerify: Internal node %d does not have mapping.\n", Gia_ObjId(p, pObj) );
1799  return 0;
1800  }
1801  Id = Gia_ObjId(p, pObj);
1802  Gia_LutForEachFanin( p, Id, iFan, k )
1803  if ( Result )
1804  Result &= Gia_ManMappingVerify_rec( p, Gia_ManObj(p, iFan) );
1805  return Result;
1806 }
static int Gia_ObjIsAndNotBuf(Gia_Obj_t *pObj)
Definition: gia.h:428
int Gia_ManMappingVerify_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaIf.c:1788
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
if(last==0)
Definition: sparse_int.h:34
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
int Gia_ManNodeIfToGia ( Gia_Man_t pNew,
If_Man_t pIfMan,
If_Obj_t pIfObj,
Vec_Int_t vLeaves,
int  fHash 
)

Definition at line 1342 of file giaIf.c.

1343 {
1344  If_Cut_t * pCut;
1345  If_Obj_t * pLeaf;
1346  int i, iRes;
1347  // get the best cut
1348  pCut = If_ObjCutBest(pIfObj);
1349  assert( pCut->nLeaves > 1 );
1350  // set the leaf variables
1351  If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
1352  If_CutSetDataInt( If_ObjCutBest(pLeaf), Vec_IntEntry(vLeaves, i) );
1353  // recursively compute the function while collecting visited cuts
1354  Vec_PtrClear( pIfMan->vTemp );
1355  iRes = Gia_ManNodeIfToGia_rec( pNew, pIfMan, pIfObj, pIfMan->vTemp, fHash );
1356  if ( iRes == ~0 )
1357  {
1358  Abc_Print( -1, "Gia_ManNodeIfToGia(): Computing local AIG has failed.\n" );
1359  return ~0;
1360  }
1361  // clean the cuts
1362  If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
1363  If_CutSetDataInt( If_ObjCutBest(pLeaf), 0 );
1364  Vec_PtrForEachEntry( If_Cut_t *, pIfMan->vTemp, pCut, i )
1365  If_CutSetDataInt( pCut, 0 );
1366  return iRes;
1367 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
Definition: if.h:275
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static void If_CutSetDataInt(If_Cut_t *pCut, int Data)
Definition: if.h:415
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int Gia_ManNodeIfToGia_rec(Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Ptr_t *vVisited, int fHash)
Definition: giaIf.c:1304
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Gia_ManNodeIfToGia_rec ( Gia_Man_t pNew,
If_Man_t pIfMan,
If_Obj_t pIfObj,
Vec_Ptr_t vVisited,
int  fHash 
)

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

Synopsis [Recursively derives the local AIG for the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 1304 of file giaIf.c.

1305 {
1306  If_Cut_t * pCut;
1307  If_Obj_t * pTemp;
1308  int iFunc, iFunc0, iFunc1;
1309  // get the best cut
1310  pCut = If_ObjCutBest(pIfObj);
1311  // if the cut is visited, return the result
1312  if ( If_CutDataInt(pCut) )
1313  return If_CutDataInt(pCut);
1314  // mark the node as visited
1315  Vec_PtrPush( vVisited, pCut );
1316  // insert the worst case
1317  If_CutSetDataInt( pCut, ~0 );
1318  // skip in case of primary input
1319  if ( If_ObjIsCi(pIfObj) )
1320  return If_CutDataInt(pCut);
1321  // compute the functions of the children
1322  for ( pTemp = pIfObj; pTemp; pTemp = pTemp->pEquiv )
1323  {
1324  iFunc0 = Gia_ManNodeIfToGia_rec( pNew, pIfMan, pTemp->pFanin0, vVisited, fHash );
1325  if ( iFunc0 == ~0 )
1326  continue;
1327  iFunc1 = Gia_ManNodeIfToGia_rec( pNew, pIfMan, pTemp->pFanin1, vVisited, fHash );
1328  if ( iFunc1 == ~0 )
1329  continue;
1330  // both branches are solved
1331  if ( fHash )
1332  iFunc = Gia_ManHashAnd( pNew, Abc_LitNotCond(iFunc0, pTemp->fCompl0), Abc_LitNotCond(iFunc1, pTemp->fCompl1) );
1333  else
1334  iFunc = Gia_ManAppendAnd( pNew, Abc_LitNotCond(iFunc0, pTemp->fCompl0), Abc_LitNotCond(iFunc1, pTemp->fCompl1) );
1335  if ( pTemp->fPhase != pIfObj->fPhase )
1336  iFunc = Abc_LitNot(iFunc);
1337  If_CutSetDataInt( pCut, iFunc );
1338  break;
1339  }
1340  return If_CutDataInt(pCut);
1341 }
If_Obj_t * pFanin0
Definition: if.h:321
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
Definition: if.h:303
Definition: if.h:275
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static void If_CutSetDataInt(If_Cut_t *pCut, int Data)
Definition: if.h:415
static int If_CutDataInt(If_Cut_t *pCut)
Definition: if.h:414
If_Obj_t * pFanin1
Definition: if.h:322
If_Obj_t * pEquiv
Definition: if.h:323
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
int Gia_ManNodeIfToGia_rec(Gia_Man_t *pNew, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Ptr_t *vVisited, int fHash)
Definition: giaIf.c:1304
unsigned fCompl1
Definition: if.h:307
unsigned fCompl0
Definition: if.h:306
unsigned fPhase
Definition: if.h:308
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
Gia_Man_t* Gia_ManPerformDsdBalance ( Gia_Man_t p,
int  nLutSize,
int  nCutNum,
int  nRelaxRatio,
int  fVerbose 
)

Definition at line 2058 of file giaIf.c.

2059 {
2060  Gia_Man_t * pNew;
2061  If_Man_t * pIfMan;
2062  If_Par_t Pars, * pPars = &Pars;
2063  If_ManSetDefaultPars( pPars );
2064  pPars->nCutsMax = nCutNum;
2065  pPars->nRelaxRatio = nRelaxRatio;
2066  pPars->fVerbose = fVerbose;
2067  pPars->nLutSize = nLutSize;
2068  pPars->fDsdBalance = 1;
2069  pPars->fUseDsd = 1;
2070  pPars->fCutMin = 1;
2071  pPars->fTruth = 1;
2072  pPars->fExpRed = 0;
2073  if ( Abc_FrameReadManDsd2() == NULL )
2075  // perform mapping
2076  pIfMan = Gia_ManToIf( p, pPars );
2078  if ( pPars->fDsdBalance )
2079  If_DsdManAllocIsops( pIfMan->pIfDsdMan, pPars->nLutSize );
2080  If_ManPerformMapping( pIfMan );
2081  pNew = Gia_ManFromIfAig( pIfMan );
2082  If_ManStop( pIfMan );
2083  Gia_ManTransferTiming( pNew, p );
2084  // transfer name
2085  assert( pNew->pName == NULL );
2086  pNew->pName = Abc_UtilStrsav( p->pName );
2087  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2088  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2089  return pNew;
2090 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
int nLutSize
Definition: if.h:103
Definition: if.h:100
void If_ManSetDefaultPars(If_Par_t *pPars)
FUNCTION DECLARATIONS ///.
Definition: ifCore.c:47
Gia_Man_t * Gia_ManFromIfAig(If_Man_t *pIfMan)
Definition: giaIf.c:880
int fVerbose
Definition: if.h:140
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1912
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
int fExpRed
Definition: if.h:116
void If_DsdManAllocIsops(If_DsdMan_t *p, int nLutSize)
Definition: ifDsd.c:289
int fDsdBalance
Definition: if.h:123
char * pName
Definition: gia.h:97
int fTruth
Definition: if.h:146
Definition: if.h:180
char * pSpec
Definition: gia.h:98
If_Man_t * Gia_ManToIf(Gia_Man_t *p, If_Par_t *pPars)
Definition: giaIf.c:742
ABC_DLL void Abc_FrameSetManDsd2(void *pMan)
Definition: mainFrame.c:90
ABC_DLL void * Abc_FrameReadManDsd2()
Definition: mainFrame.c:63
int fUseDsd
Definition: if.h:133
int nRelaxRatio
Definition: if.h:111
If_DsdMan_t * If_DsdManAlloc(int nVars, int nLutSize)
Definition: ifDsd.c:248
int If_ManPerformMapping(If_Man_t *p)
Definition: ifCore.c:80
Definition: gia.h:95
int fCutMin
Definition: if.h:120
#define assert(ex)
Definition: util_old.h:213
int nCutsMax
Definition: if.h:104
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void If_ManStop(If_Man_t *p)
Definition: ifMan.c:205
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Gia_ManPerformMapping ( Gia_Man_t p,
void *  pp 
)

Definition at line 1986 of file giaIf.c.

1987 {
1988  Gia_Man_t * pNew;
1989  if ( p->pManTime && Tim_ManBoxNum(p->pManTime) && Gia_ManIsNormalized(p) )
1990  {
1991  pNew = Gia_ManDupUnnormalize( p );
1992  if ( pNew == NULL )
1993  return NULL;
1994  Gia_ManTransferTiming( pNew, p );
1995  p = pNew;
1996  // mapping
1997  pNew = Gia_ManPerformMappingInt( p, (If_Par_t *)pp );
1998  if ( pNew != p )
1999  {
2000  Gia_ManTransferTiming( pNew, p );
2001  Gia_ManStop( p );
2002  }
2003  // normalize
2004  pNew = Gia_ManDupNormalize( p = pNew );
2005  Gia_ManTransferMapping( pNew, p );
2006  Gia_ManTransferPacking( pNew, p );
2007  Gia_ManTransferTiming( pNew, p );
2008  Gia_ManStop( p );
2009  assert( Gia_ManIsNormalized(pNew) );
2010  }
2011  else
2012  {
2013  // mapping
2014  pNew = Gia_ManPerformMappingInt( p, (If_Par_t *)pp );
2015  Gia_ManTransferTiming( pNew, p );
2016  }
2017  return pNew;
2018 }
void Gia_ManTransferPacking(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1878
Gia_Man_t * Gia_ManDupUnnormalize(Gia_Man_t *p)
Definition: giaTim.c:373
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Definition: if.h:100
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1912
void Gia_ManTransferMapping(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1855
Gia_Man_t * Gia_ManDupNormalize(Gia_Man_t *p)
Definition: giaTim.c:134
void * pManTime
Definition: gia.h:165
int Tim_ManBoxNum(Tim_Man_t *p)
Definition: timMan.c:702
Definition: gia.h:95
int Gia_ManIsNormalized(Gia_Man_t *p)
Definition: giaTim.c:109
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t * Gia_ManPerformMappingInt(Gia_Man_t *p, If_Par_t *pPars)
Definition: giaIf.c:1933
Gia_Man_t* Gia_ManPerformMappingInt ( Gia_Man_t p,
If_Par_t pPars 
)

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

Synopsis [Interface of LUT mapping package.]

Description []

SideEffects []

SeeAlso []

Definition at line 1933 of file giaIf.c.

1934 {
1935  extern void Gia_ManIffTest( Gia_Man_t * pGia, If_LibLut_t * pLib, int fVerbose );
1936  Gia_Man_t * pNew;
1937  If_Man_t * pIfMan;
1938  assert( pPars->pTimesArr == NULL );
1939  assert( pPars->pTimesReq == NULL );
1940  // disable cut minimization when GIA strucure is needed
1941  if ( !pPars->fDelayOpt && !pPars->fDelayOptLut && !pPars->fDsdBalance && !pPars->fUserRecLib && !pPars->fDeriveLuts && !pPars->fUseDsd && !pPars->fUseTtPerm )
1942  pPars->fCutMin = 0;
1943  // translate into the mapper
1944  pIfMan = Gia_ManToIf( p, pPars );
1945  if ( pIfMan == NULL )
1946  return NULL;
1947  // create DSD manager
1948  if ( pPars->fUseDsd )
1949  {
1951  assert( pPars->nLutSize <= If_DsdManVarNum(p) );
1952  assert( (pPars->pLutStruct == NULL && If_DsdManLutSize(p) == 0) || (pPars->pLutStruct && pPars->pLutStruct[0] - '0' == If_DsdManLutSize(p)) );
1953  pIfMan->pIfDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
1954  if ( pPars->fDsdBalance )
1955  If_DsdManAllocIsops( pIfMan->pIfDsdMan, pPars->nLutSize );
1956  }
1957  // compute switching for the IF objects
1958  if ( pPars->fPower )
1959  {
1960  if ( p->pManTime == NULL )
1961  If_ManComputeSwitching( pIfMan );
1962  else
1963  Abc_Print( 0, "Switching activity computation for designs with boxes is disabled.\n" );
1964  }
1965  if ( p->pManTime )
1966  pIfMan->pManTim = Tim_ManDup( (Tim_Man_t *)p->pManTime, pPars->fDelayOpt || pPars->fDelayOptLut || pPars->fDsdBalance || pPars->fUserRecLib );
1967 // Tim_ManPrint( pIfMan->pManTim );
1968  if ( !If_ManPerformMapping( pIfMan ) )
1969  {
1970  If_ManStop( pIfMan );
1971  return NULL;
1972  }
1973  // transform the result of mapping into the new network
1974  if ( pIfMan->pPars->fDelayOpt || pIfMan->pPars->fDsdBalance || pIfMan->pPars->fUserRecLib )
1975  pNew = Gia_ManFromIfAig( pIfMan );
1976  else
1977  pNew = Gia_ManFromIfLogic( pIfMan );
1978  If_ManStop( pIfMan );
1979  // transfer name
1980  assert( pNew->pName == NULL );
1981  pNew->pName = Abc_UtilStrsav( p->pName );
1982  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1983  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1984  return pNew;
1985 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
int nLutSize
Definition: if.h:103
Gia_Man_t * Gia_ManFromIfAig(If_Man_t *pIfMan)
Definition: giaIf.c:880
int fDeriveLuts
Definition: if.h:138
int fDelayOptLut
Definition: if.h:122
char * pLutStruct
Definition: if.h:141
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
void If_ManComputeSwitching(If_Man_t *pIfMan)
FUNCTION DEFINITIONS ///.
Definition: abcIf.c:58
void If_DsdManAllocIsops(If_DsdMan_t *p, int nLutSize)
Definition: ifDsd.c:289
Tim_Man_t * pManTim
Definition: if.h:263
int fDsdBalance
Definition: if.h:123
char * pName
Definition: gia.h:97
Definition: if.h:180
Gia_Man_t * Gia_ManFromIfLogic(If_Man_t *pIfMan)
Definition: giaIf.c:1535
char * pSpec
Definition: gia.h:98
float * pTimesArr
Definition: if.h:161
int If_DsdManVarNum(If_DsdMan_t *p)
Definition: ifDsd.c:165
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
ABC_DLL void * Abc_FrameReadManDsd()
Definition: mainFrame.c:62
float * pTimesReq
Definition: if.h:162
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Gia_ManIffTest(Gia_Man_t *pGia, If_LibLut_t *pLib, int fVerbose)
Definition: giaIff.c:387
If_Man_t * Gia_ManToIf(Gia_Man_t *p, If_Par_t *pPars)
Definition: giaIf.c:742
int fUseDsd
Definition: if.h:133
If_Par_t * pPars
Definition: if.h:184
int If_ManPerformMapping(If_Man_t *p)
Definition: ifCore.c:80
int If_DsdManLutSize(If_DsdMan_t *p)
Definition: ifDsd.c:173
Definition: gia.h:95
int fUserRecLib
Definition: if.h:124
int fPower
Definition: if.h:119
int fDelayOpt
Definition: if.h:121
int fCutMin
Definition: if.h:120
int fUseTtPerm
Definition: if.h:137
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void If_ManStop(If_Man_t *p)
Definition: ifMan.c:205
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Gia_ManPerformSopBalance ( Gia_Man_t p,
int  nCutNum,
int  nRelaxRatio,
int  fVerbose 
)

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

Synopsis [Interface of other mapping-based procedures.]

Description []

SideEffects []

SeeAlso []

Definition at line 2031 of file giaIf.c.

2032 {
2033  Gia_Man_t * pNew;
2034  If_Man_t * pIfMan;
2035  If_Par_t Pars, * pPars = &Pars;
2036  If_ManSetDefaultPars( pPars );
2037  pPars->nCutsMax = nCutNum;
2038  pPars->nRelaxRatio = nRelaxRatio;
2039  pPars->fVerbose = fVerbose;
2040  pPars->nLutSize = 6;
2041  pPars->fDelayOpt = 1;
2042  pPars->fCutMin = 1;
2043  pPars->fTruth = 1;
2044  pPars->fExpRed = 0;
2045  // perform mapping
2046  pIfMan = Gia_ManToIf( p, pPars );
2047  If_ManPerformMapping( pIfMan );
2048  pNew = Gia_ManFromIfAig( pIfMan );
2049  If_ManStop( pIfMan );
2050  Gia_ManTransferTiming( pNew, p );
2051  // transfer name
2052  assert( pNew->pName == NULL );
2053  pNew->pName = Abc_UtilStrsav( p->pName );
2054  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2055  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2056  return pNew;
2057 }
int nLutSize
Definition: if.h:103
Definition: if.h:100
void If_ManSetDefaultPars(If_Par_t *pPars)
FUNCTION DECLARATIONS ///.
Definition: ifCore.c:47
Gia_Man_t * Gia_ManFromIfAig(If_Man_t *pIfMan)
Definition: giaIf.c:880
int fVerbose
Definition: if.h:140
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1912
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
int fExpRed
Definition: if.h:116
char * pName
Definition: gia.h:97
int fTruth
Definition: if.h:146
Definition: if.h:180
char * pSpec
Definition: gia.h:98
If_Man_t * Gia_ManToIf(Gia_Man_t *p, If_Par_t *pPars)
Definition: giaIf.c:742
int nRelaxRatio
Definition: if.h:111
int If_ManPerformMapping(If_Man_t *p)
Definition: ifCore.c:80
Definition: gia.h:95
int fDelayOpt
Definition: if.h:121
int fCutMin
Definition: if.h:120
#define assert(ex)
Definition: util_old.h:213
int nCutsMax
Definition: if.h:104
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void If_ManStop(If_Man_t *p)
Definition: ifMan.c:205
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Gia_ManPrintGetMuxFanins ( Gia_Man_t p,
Gia_Obj_t pObj,
int *  pFanins 
)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 361 of file giaIf.c.

362 {
363  Gia_Obj_t * pData0, * pData1;
364  Gia_Obj_t * pCtrl = Gia_ObjRecognizeMux( pObj, &pData1, &pData0 );
365  pFanins[0] = Gia_ObjId(p, Gia_Regular(pCtrl));
366  pFanins[1] = Gia_ObjId(p, Gia_Regular(pData1));
367  pFanins[2] = Gia_ObjId(p, Gia_Regular(pData0));
368 }
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
Definition: gia.h:75
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
void Gia_ManPrintLutStats ( Gia_Man_t p)

Definition at line 613 of file giaIf.c.

614 {
615  int i, nSizeMax, pCounts[33] = {0};
616  nSizeMax = Gia_ManLutSizeMax( p );
617  if ( nSizeMax > 32 )
618  {
619  Abc_Print( 1, "The max LUT size (%d) is too large.\n", nSizeMax );
620  return;
621  }
622  Gia_ManForEachLut( p, i )
623  pCounts[ Gia_ObjLutSize(p, i) ]++;
624  Gia_ManPrintNodeProfile( pCounts, nSizeMax );
625 }
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
int Gia_ManLutSizeMax(Gia_Man_t *p)
Definition: giaIf.c:125
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Gia_ManPrintNodeProfile(int *pCounts, int nSizeMax)
Definition: giaIf.c:600
void Gia_ManPrintMappingStats ( Gia_Man_t p,
char *  pDumpFile 
)

Definition at line 423 of file giaIf.c.

424 {
425  Gia_Obj_t * pObj;
426  int * pLevels;
427  int i, k, iFan, nLutSize = 0, nLuts = 0, nFanins = 0, LevelMax = 0, Ave = 0, nMuxF = 0;
428  if ( !Gia_ManHasMapping(p) )
429  return;
430  pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
431  Gia_ManForEachLut( p, i )
432  {
433  if ( Gia_ObjLutIsMux(p, i) )
434  {
435  int pFanins[3];
436  if ( Gia_ObjLutSize(p, i) == 3 )
437  {
438  Gia_ManPrintGetMuxFanins( p, Gia_ManObj(p, i), pFanins );
439  pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[0]]+1 );
440  pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[1]] );
441  pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[2]] );
442  }
443  else if ( Gia_ObjLutSize(p, i) == 2 )
444  {
445  pObj = Gia_ManObj( p, i );
446  pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[Gia_ObjFaninId0(pObj, i)] );
447  pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[Gia_ObjFaninId1(pObj, i)] );
448  }
449  LevelMax = Abc_MaxInt( LevelMax, pLevels[i] );
450  nFanins++;
451  nMuxF++;
452  continue;
453  }
454  nLuts++;
455  nFanins += Gia_ObjLutSize(p, i);
456  nLutSize = Abc_MaxInt( nLutSize, Gia_ObjLutSize(p, i) );
457  Gia_LutForEachFanin( p, i, iFan, k )
458  pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[iFan] );
459  pLevels[i]++;
460  LevelMax = Abc_MaxInt( LevelMax, pLevels[i] );
461  }
462  Gia_ManForEachCo( p, pObj, i )
463  Ave += pLevels[Gia_ObjFaninId0p(p, pObj)];
464  ABC_FREE( pLevels );
465 
466 #ifdef WIN32
467  {
468  HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
469  Abc_Print( 1, "Mapping (K=%d) : ", nLutSize );
470  SetConsoleTextAttribute( hConsole, 14 ); // yellow
471  Abc_Print( 1, "lut =%7d ", nLuts );
472  if ( nMuxF )
473  Abc_Print( 1, "muxF =%7d ", nMuxF );
474  SetConsoleTextAttribute( hConsole, 10 ); // green
475  Abc_Print( 1, "edge =%8d ", nFanins );
476  SetConsoleTextAttribute( hConsole, 12 ); // red
477  Abc_Print( 1, "lev =%5d ", LevelMax );
478  Abc_Print( 1, "(%.2f) ", (float)Ave / Gia_ManCoNum(p) );
479 // Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) );
480  if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) )
481  Abc_Print( 1, "levB =%5d ", Gia_ManLutLevelWithBoxes(p) );
482  SetConsoleTextAttribute( hConsole, 7 ); // normal
483  Abc_Print( 1, "mem =%5.2f MB", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) );
484  Abc_Print( 1, "\n" );
485  }
486 #else
487  Abc_Print( 1, "Mapping (K=%d) : ", nLutSize );
488  Abc_Print( 1, "%slut =%7d%s ", "\033[1;33m", nLuts, "\033[0m" ); // yellow
489  Abc_Print( 1, "%sedge =%8d%s ", "\033[1;32m", nFanins, "\033[0m" ); // green
490  Abc_Print( 1, "%slev =%5d%s ", "\033[1;31m", LevelMax, "\033[0m" ); // red
491  Abc_Print( 1, "%s(%.2f)%s ", "\033[1;31m", (float)Ave / Gia_ManCoNum(p), "\033[0m" );
492 // Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) );
493  if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) )
494  Abc_Print( 1, "%slevB =%5d%s ", "\033[1;31m", Gia_ManLutLevelWithBoxes(p), "\033[0m" );
495  Abc_Print( 1, "mem =%5.2f MB", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) );
496  Abc_Print( 1, "\n" );
497 #endif
498 
499  if ( nMuxF )
500  Gia_ManCountDupLut( p );
501 
502  return;
503  if ( pDumpFile )
504  {
505  static char FileNameOld[1000] = {0};
506  static abctime clk = 0;
507  FILE * pTable = fopen( pDumpFile, "a+" );
508  if ( strcmp( FileNameOld, p->pName ) )
509  {
510  sprintf( FileNameOld, "%s", p->pName );
511  fprintf( pTable, "\n" );
512  fprintf( pTable, "%s ", p->pName );
513 // fprintf( pTable, "%d ", Gia_ManCiNum(p) );
514 // fprintf( pTable, "%d ", Gia_ManCoNum(p) );
515 // fprintf( pTable, "%d ", Gia_ManAndNum(p) );
516  fprintf( pTable, "%d ", Gia_ManPiNum(p) - Gia_ManBoxCiNum(p) - Gia_ManRegBoxNum(p) );
517  fprintf( pTable, "%d ", Gia_ManPoNum(p) - Gia_ManBoxCoNum(p) - Gia_ManRegBoxNum(p) );
518  fprintf( pTable, "%d ", Gia_ManClockDomainNum(p) );
519 
520  fprintf( pTable, " " );
521  fprintf( pTable, "%d ", nLuts );
522  fprintf( pTable, "%d ", LevelMax );
523  fprintf( pTable, "%d ", Gia_ManRegBoxNum(p) );
524  fprintf( pTable, "%d ", Gia_ManNonRegBoxNum(p) );
525  clk = Abc_Clock();
526  }
527  else
528  {
529  fprintf( pTable, " " );
530  fprintf( pTable, "%d ", nLuts );
531  fprintf( pTable, "%d ", LevelMax );
532  fprintf( pTable, "%d ", Gia_ManRegBoxNum(p) );
533  fprintf( pTable, "%d ", Gia_ManNonRegBoxNum(p) );
534  fprintf( pTable, "%.2f", 1.0*(Abc_Clock() - clk)/CLOCKS_PER_SEC );
535  clk = Abc_Clock();
536  }
537  fclose( pTable );
538  }
539 
540 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
int Gia_ManRegBoxNum(Gia_Man_t *p)
Definition: giaTim.c:53
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
int strcmp()
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
void Gia_ManPrintGetMuxFanins(Gia_Man_t *p, Gia_Obj_t *pObj, int *pFanins)
Definition: giaIf.c:361
static int Gia_ObjLutIsMux(Gia_Man_t *p, int Id)
Definition: gia.h:957
int Gia_ManBoxCiNum(Gia_Man_t *p)
Definition: giaTim.c:61
char * sprintf()
int Tim_ManBoxNum(Tim_Man_t *p)
Definition: timMan.c:702
int Gia_ManBoxCoNum(Gia_Man_t *p)
Definition: giaTim.c:65
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int Gia_ManNonRegBoxNum(Gia_Man_t *p)
Definition: giaTim.c:57
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
int Gia_ManLutLevelWithBoxes(Gia_Man_t *p)
Definition: giaTim.c:572
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
int Gia_ManCountDupLut(Gia_Man_t *p)
Definition: giaIf.c:369
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
int Gia_ManClockDomainNum(Gia_Man_t *p)
Definition: giaTim.c:69
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
void Gia_ManPrintNodeProfile ( int *  pCounts,
int  nSizeMax 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 600 of file giaIf.c.

601 {
602  int i, SizeAll = 0, NodeAll = 0;
603  for ( i = 0; i <= nSizeMax; i++ )
604  {
605  SizeAll += i * pCounts[i];
606  NodeAll += pCounts[i];
607  }
608  Abc_Print( 1, "LUT = %d : ", NodeAll );
609  for ( i = 2; i <= nSizeMax; i++ )
610  Abc_Print( 1, "%d=%d %.1f %% ", i, pCounts[i], 100.0*pCounts[i]/NodeAll );
611  Abc_Print( 1, "Ave = %.2f\n", 1.0*SizeAll/(NodeAll ? NodeAll : 1) );
612 }
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Gia_ManPrintPackingStats ( Gia_Man_t p)

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

Synopsis [Prints mapping statistics.]

Description []

SideEffects []

SeeAlso []

Definition at line 553 of file giaIf.c.

554 {
555  int fVerbose = 0;
556  int nObjToShow = 200;
557  int nNumStr[5] = {0};
558  int i, k, Entry, nEntries, nEntries2, MaxSize = -1;
559  if ( p->vPacking == NULL )
560  return;
561  nEntries = Vec_IntEntry( p->vPacking, 0 );
562  nEntries2 = 0;
563  Vec_IntForEachEntryStart( p->vPacking, Entry, i, 1 )
564  {
565  assert( Entry > 0 && Entry < 4 );
566  nNumStr[Entry]++;
567  i++;
568  if ( fVerbose && nEntries2 < nObjToShow ) Abc_Print( 1, "{ " );
569  for ( k = 0; k < Entry; k++, i++ )
570  if ( fVerbose && nEntries2 < nObjToShow ) Abc_Print( 1, "%d ", Vec_IntEntry(p->vPacking, i) );
571  if ( fVerbose && nEntries2 < nObjToShow ) Abc_Print( 1, "}\n" );
572  i--;
573  nEntries2++;
574  }
575  assert( nEntries == nEntries2 );
576  if ( nNumStr[3] > 0 )
577  MaxSize = 3;
578  else if ( nNumStr[2] > 0 )
579  MaxSize = 2;
580  else if ( nNumStr[1] > 0 )
581  MaxSize = 1;
582  Abc_Print( 1, "Packing (N=%d) : ", MaxSize );
583  for ( i = 1; i <= MaxSize; i++ )
584  Abc_Print( 1, "%d x LUT = %d ", i, nNumStr[i] );
585  Abc_Print( 1, "Total = %d", nEntries2 );
586  Abc_Print( 1, "\n" );
587 }
Vec_Int_t * vPacking
Definition: gia.h:133
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define assert(ex)
Definition: util_old.h:213
void Gia_ManSetIfParsDefault ( void *  pp)

FUNCTION DEFINITIONS ///.

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

Synopsis [Load the network into FPGA manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 57 of file giaIf.c.

58 {
59  If_Par_t * pPars = (If_Par_t *)pp;
60 // extern void * Abc_FrameReadLibLut();
61  If_Par_t * p = (If_Par_t *)pPars;
62  // set defaults
63  memset( p, 0, sizeof(If_Par_t) );
64  // user-controlable paramters
65  p->nLutSize = -1;
66 // p->nLutSize = 6;
67  p->nCutsMax = 8;
68  p->nFlowIters = 1;
69  p->nAreaIters = 2;
70  p->DelayTarget = -1;
71  p->Epsilon = (float)0.005;
72  p->fPreprocess = 1;
73  p->fArea = 0;
74  p->fFancy = 0;
75  p->fExpRed = 1; ////
76  p->fLatchPaths = 0;
77  p->fEdge = 1;
78  p->fPower = 0;
79  p->fCutMin = 0;
80  p->fVerbose = 0;
81  p->pLutStruct = NULL;
82  // internal parameters
83  p->fTruth = 0;
84  p->nLatchesCi = 0;
85  p->nLatchesCo = 0;
86  p->fLiftLeaves = 0;
87  p->fUseCoAttrs = 1; // use CO attributes
88  p->pLutLib = NULL;
89  p->pTimesArr = NULL;
90  p->pTimesReq = NULL;
91  p->pFuncCost = NULL;
92 }
char * memset()
int nLutSize
Definition: if.h:103
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: if.h:100
int fVerbose
Definition: if.h:140
char * pLutStruct
Definition: if.h:141
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
Definition: if.h:163
int fUseCoAttrs
Definition: if.h:157
int nLatchesCi
Definition: if.h:152
int fExpRed
Definition: if.h:116
int nFlowIters
Definition: if.h:105
int fEdge
Definition: if.h:118
int fPreprocess
Definition: if.h:113
int fTruth
Definition: if.h:146
int fLatchPaths
Definition: if.h:117
float * pTimesArr
Definition: if.h:161
float Epsilon
Definition: if.h:110
float * pTimesReq
Definition: if.h:162
int fFancy
Definition: if.h:115
float DelayTarget
Definition: if.h:109
int nLatchesCo
Definition: if.h:153
int nAreaIters
Definition: if.h:106
int fPower
Definition: if.h:119
int fCutMin
Definition: if.h:120
int nCutsMax
Definition: if.h:104
int fArea
Definition: if.h:114
int fLiftLeaves
Definition: if.h:156
If_LibLut_t * pLutLib
Definition: if.h:160
void Gia_ManSetRefsMapped ( Gia_Man_t p)

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

Synopsis [Assigns levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file giaIf.c.

246 {
247  Gia_Obj_t * pObj;
248  int i, k, iFan;
249  ABC_FREE( p->pRefs );
250  p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) );
251  Gia_ManForEachCo( p, pObj, i )
252  Gia_ObjRefInc( p, Gia_ObjFanin0(pObj) );
253  Gia_ManForEachLut( p, i )
254  Gia_LutForEachFanin( p, i, iFan, k )
255  Gia_ObjRefInc( p, Gia_ManObj(p, iFan) );
256 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjRefInc(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:522
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManTestStruct ( Gia_Man_t p)

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

Synopsis [Tests decomposition structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 2103 of file giaIf.c.

2104 {
2105  int nCutMax = 7;
2106  int LutCount[8] = {0}, LutNDecomp[8] = {0};
2107  int i, k, iFan, nFanins, Status;
2108  Vec_Int_t * vLeaves;
2109  word * pTruth;
2110 
2111  vLeaves = Vec_IntAlloc( 100 );
2112  Gia_ObjComputeTruthTableStart( p, nCutMax );
2113  Gia_ManForEachLut( p, i )
2114  {
2115  nFanins = Gia_ObjLutSize(p, i);
2116  assert( nFanins <= 7 );
2117  LutCount[Abc_MaxInt(nFanins, 5)]++;
2118  if ( nFanins <= 5 )
2119  continue;
2120  Vec_IntClear( vLeaves );
2121  Gia_LutForEachFanin( p, i, iFan, k )
2122  Vec_IntPush( vLeaves, iFan );
2123  pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, i), vLeaves );
2124  // check if it is decomposable
2125  Status = If_CutPerformCheck07( NULL, (unsigned *)pTruth, 7, nFanins, NULL );
2126  if ( Status == 1 )
2127  continue;
2128  LutNDecomp[nFanins]++;
2129  if ( LutNDecomp[nFanins] > 10 )
2130  continue;
2131  Kit_DsdPrintFromTruth( (unsigned *)pTruth, nFanins ); printf( "\n" );
2132  }
2134 
2135  printf( "LUT5 = %d ", LutCount[5] );
2136  printf( "LUT6 = %d NonDec = %d (%.2f %%) ", LutCount[6], LutNDecomp[6], 100.0 * LutNDecomp[6]/Abc_MaxInt(LutCount[6], 1) );
2137  printf( "LUT7 = %d NonDec = %d (%.2f %%) ", LutCount[7], LutNDecomp[7], 100.0 * LutNDecomp[7]/Abc_MaxInt(LutCount[7], 1) );
2138  printf( "\n" );
2139 }
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition: giaTruth.c:282
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition: giaTruth.c:351
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition: giaTruth.c:293
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int If_CutPerformCheck07(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition: ifDec07.c:1071
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
If_Man_t* Gia_ManToIf ( Gia_Man_t p,
If_Par_t pPars 
)

Definition at line 742 of file giaIf.c.

743 {
744  If_Man_t * pIfMan;
745  If_Obj_t * pIfObj;
746  Gia_Obj_t * pObj;
747  int i;
748  // create levels with choices
749  Gia_ManChoiceLevel( p );
750  // mark representative nodes
751  if ( Gia_ManHasChoices(p) )
753  // start the mapping manager and set its parameters
754  pIfMan = If_ManStart( pPars );
755  pIfMan->pName = Abc_UtilStrsav( Gia_ManName(p) );
756  // print warning about excessive memory usage
757  if ( 1.0 * Gia_ManObjNum(p) * pIfMan->nObjBytes / (1<<30) > 1.0 )
758  printf( "Warning: The mapper will allocate %.1f GB for to represent the subject graph with %d AIG nodes.\n",
759  1.0 * Gia_ManObjNum(p) * pIfMan->nObjBytes / (1<<30), Gia_ManObjNum(p) );
760  // load the AIG into the mapper
761  Gia_ManFillValue( p );
762  Gia_ManConst0(p)->Value = If_ObjId( If_ManConst1(pIfMan) );
763  Gia_ManForEachObj1( p, pObj, i )
764  {
765  if ( Gia_ObjIsAnd(pObj) )
766  pIfObj = If_ManCreateAnd( pIfMan, If_ManFanin0Copy(pIfMan, pObj), If_ManFanin1Copy(pIfMan, pObj) );
767  else if ( Gia_ObjIsCi(pObj) )
768  {
769  pIfObj = If_ManCreateCi( pIfMan );
770  If_ObjSetLevel( pIfObj, Gia_ObjLevel(p, pObj) );
771 // Abc_Print( 1, "pi%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
772  if ( pIfMan->nLevelMax < (int)pIfObj->Level )
773  pIfMan->nLevelMax = (int)pIfObj->Level;
774  }
775  else if ( Gia_ObjIsCo(pObj) )
776  {
777  pIfObj = If_ManCreateCo( pIfMan, If_NotCond( If_ManFanin0Copy(pIfMan, pObj), Gia_ObjIsConst0(Gia_ObjFanin0(pObj))) );
778 // Abc_Print( 1, "po%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
779  }
780  else assert( 0 );
781  assert( i == If_ObjId(pIfObj) );
782  Gia_ObjSetValue( pObj, If_ObjId(pIfObj) );
783  // set up the choice node
784  if ( Gia_ObjSibl(p, i) && pObj->fMark0 )
785  {
786  Gia_Obj_t * pSibl, * pPrev;
787  for ( pPrev = pObj, pSibl = Gia_ObjSiblObj(p, i); pSibl; pPrev = pSibl, pSibl = Gia_ObjSiblObj(p, Gia_ObjId(p, pSibl)) )
788  If_ObjSetChoice( If_ManObj(pIfMan, Gia_ObjValue(pPrev)), If_ManObj(pIfMan, Gia_ObjValue(pSibl)) );
789  If_ManCreateChoice( pIfMan, If_ManObj(pIfMan, Gia_ObjValue(pObj)) );
790  pPars->fExpRed = 0;
791  }
792 // assert( If_ObjLevel(pIfObj) == Gia_ObjLevel(pNode) );
793  }
794  if ( Gia_ManHasChoices(p) )
795  Gia_ManCleanMark0( p );
796  return pIfMan;
797 }
static If_Obj_t * If_NotCond(If_Obj_t *p, int c)
Definition: if.h:357
static Gia_Obj_t * Gia_ObjSiblObj(Gia_Man_t *p, int Id)
Definition: gia.h:894
static If_Obj_t * If_ManObj(If_Man_t *p, int i)
Definition: if.h:370
static int If_ObjId(If_Obj_t *pObj)
Definition: if.h:379
static void Gia_ObjSetValue(Gia_Obj_t *pObj, int i)
Definition: gia.h:414
static If_Obj_t * If_ManFanin1Copy(If_Man_t *pIfMan, Gia_Obj_t *pObj)
Definition: giaIf.c:741
If_Man_t * If_ManStart(If_Par_t *pPars)
FUNCTION DEFINITIONS ///.
Definition: ifMan.c:50
static char * Gia_ManName(Gia_Man_t *p)
Definition: gia.h:382
Definition: if.h:303
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition: giaUtil.c:215
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
int nLevelMax
Definition: if.h:194
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
static void If_ObjSetLevel(If_Obj_t *pObj, int Level)
Definition: if.h:386
Definition: gia.h:75
If_Obj_t * If_ManCreateCo(If_Man_t *p, If_Obj_t *pDriver)
Definition: ifMan.c:338
int fExpRed
Definition: if.h:116
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
static int Gia_ObjSibl(Gia_Man_t *p, int Id)
Definition: gia.h:893
char * pName
Definition: if.h:182
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
Definition: if.h:180
static If_Obj_t * If_ManFanin0Copy(If_Man_t *pIfMan, Gia_Obj_t *pObj)
Definition: giaIf.c:740
static If_Obj_t * If_ManConst1(If_Man_t *p)
Definition: if.h:365
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
unsigned Level
Definition: if.h:315
int nObjBytes
Definition: if.h:228
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static void If_ObjSetChoice(If_Obj_t *pObj, If_Obj_t *pEqu)
Definition: if.h:388
unsigned fMark0
Definition: gia.h:79
void If_ManCreateChoice(If_Man_t *p, If_Obj_t *pRepr)
Definition: ifMan.c:442
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
If_Obj_t * If_ManCreateCi(If_Man_t *p)
Definition: ifMan.c:316
If_Obj_t * If_ManCreateAnd(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
Definition: ifMan.c:366
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
#define Gia_ManForEachObj1(p, pObj, i)
Definition: gia.h:986
int Gia_ManChoiceLevel(Gia_Man_t *p)
Definition: giaIf.c:699
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManMarkFanoutDrivers(Gia_Man_t *p)
Definition: giaUtil.c:1553
void Gia_ManTransferMapping ( Gia_Man_t p,
Gia_Man_t pGia 
)

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

Synopsis [Transfers mapping from hie GIA to normalized GIA.]

Description [Hie GIA (pGia) points to normalized GIA (p).]

SideEffects []

SeeAlso []

Definition at line 1855 of file giaIf.c.

1856 {
1857  Gia_Obj_t * pObj;
1858  int i, k, iFan;
1859  if ( !Gia_ManHasMapping(pGia) )
1860  return;
1861  Gia_ManMappingVerify( pGia );
1862  Vec_IntFreeP( &p->vMapping );
1863  p->vMapping = Vec_IntAlloc( 2 * Gia_ManObjNum(p) );
1864  Vec_IntFill( p->vMapping, Gia_ManObjNum(p), 0 );
1865  Gia_ManForEachLut( pGia, i )
1866  {
1868  pObj = Gia_ManObj( p, Abc_Lit2Var(Gia_ObjValue(Gia_ManObj(pGia, i))) );
1870  Vec_IntPush( p->vMapping, Gia_ObjLutSize(pGia, i) );
1871  Gia_LutForEachFanin( pGia, i, iFan, k )
1872  Vec_IntPush( p->vMapping, Abc_Lit2Var(Gia_ObjValue(Gia_ManObj(pGia, iFan))) );
1873  iFan = Abc_Lit2Var( Gia_ObjValue(Gia_ManObj(pGia, Abc_AbsInt(Gia_ObjLutMuxId(pGia, i)))) );
1874  Vec_IntPush( p->vMapping, Gia_ObjLutIsMux(pGia, i) ? -iFan : iFan );
1875  }
1876  Gia_ManMappingVerify( p );
1877 }
static int Abc_AbsInt(int a)
Definition: abc_global.h:237
static int Gia_ObjLutMuxId(Gia_Man_t *p, int Id)
Definition: gia.h:956
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Gia_ObjLutIsMux(Gia_Man_t *p, int Id)
Definition: gia.h:957
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
void Gia_ManMappingVerify(Gia_Man_t *p)
Definition: giaIf.c:1807
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vMapping
Definition: gia.h:131
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManTransferPacking ( Gia_Man_t p,
Gia_Man_t pGia 
)

Definition at line 1878 of file giaIf.c.

1879 {
1880  Vec_Int_t * vPackingNew;
1881  Gia_Obj_t * pObj, * pObjNew;
1882  int i, k, Entry, nEntries, nEntries2;
1883  if ( pGia->vPacking == NULL )
1884  return;
1885  nEntries = Vec_IntEntry( pGia->vPacking, 0 );
1886  nEntries2 = 0;
1887  // create new packing info
1888  vPackingNew = Vec_IntAlloc( Vec_IntSize(pGia->vPacking) );
1889  Vec_IntPush( vPackingNew, nEntries );
1890  Vec_IntForEachEntryStart( pGia->vPacking, Entry, i, 1 )
1891  {
1892  assert( Entry > 0 && Entry < 4 );
1893  Vec_IntPush( vPackingNew, Entry );
1894  i++;
1895  for ( k = 0; k < Entry; k++, i++ )
1896  {
1897  pObj = Gia_ManObj(pGia, Vec_IntEntry(pGia->vPacking, i));
1898  pObjNew = Gia_ManObj(p, Abc_Lit2Var(Gia_ObjValue(pObj)));
1899  assert( Gia_ObjIsLut(pGia, Gia_ObjId(pGia, pObj)) );
1900  assert( Gia_ObjIsLut(p, Gia_ObjId(p, pObjNew)) );
1901  Vec_IntPush( vPackingNew, Gia_ObjId(p, pObjNew) );
1902 // printf( "%d -> %d ", Vec_IntEntry(pGia->vPacking, i), Gia_ObjId(p, pObjNew) );
1903  }
1904  i--;
1905  nEntries2++;
1906  }
1907  assert( nEntries == nEntries2 );
1908  // attach packing info
1909  assert( p->vPacking == NULL );
1910  p->vPacking = vPackingNew;
1911 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
Vec_Int_t * vPacking
Definition: gia.h:133
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
void Gia_ManTransferTiming ( Gia_Man_t p,
Gia_Man_t pGia 
)

Definition at line 1912 of file giaIf.c.

1913 {
1914  if ( pGia->pManTime == NULL || p == pGia )
1915  return;
1916  p->pManTime = pGia->pManTime; pGia->pManTime = NULL;
1917  p->pAigExtra = pGia->pAigExtra; pGia->pAigExtra = NULL;
1918  p->vRegClasses = pGia->vRegClasses; pGia->vRegClasses = NULL;
1919  p->nAnd2Delay = pGia->nAnd2Delay; pGia->nAnd2Delay = 0;
1920 }
Gia_Man_t * pAigExtra
Definition: gia.h:149
Vec_Int_t * vRegClasses
Definition: gia.h:144
void * pManTime
Definition: gia.h:165
int nAnd2Delay
Definition: gia.h:173
static If_Obj_t* If_ManFanin0Copy ( If_Man_t pIfMan,
Gia_Obj_t pObj 
)
inlinestatic

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

Synopsis [Converts GIA into IF manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 740 of file giaIf.c.

740 { return If_NotCond( If_ManObj(pIfMan, Gia_ObjValue(Gia_ObjFanin0(pObj))), Gia_ObjFaninC0(pObj) ); }
static If_Obj_t * If_NotCond(If_Obj_t *p, int c)
Definition: if.h:357
static If_Obj_t * If_ManObj(If_Man_t *p, int i)
Definition: if.h:370
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static If_Obj_t* If_ManFanin1Copy ( If_Man_t pIfMan,
Gia_Obj_t pObj 
)
inlinestatic

Definition at line 741 of file giaIf.c.

741 { return If_NotCond( If_ManObj(pIfMan, Gia_ObjValue(Gia_ObjFanin1(pObj))), Gia_ObjFaninC1(pObj) ); }
static If_Obj_t * If_NotCond(If_Obj_t *p, int c)
Definition: if.h:357
static If_Obj_t * If_ManObj(If_Man_t *p, int i)
Definition: if.h:370
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia ( Gia_Man_t pMan,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vMemory,
Vec_Int_t vLeaves,
int  fHash 
)

DECLARATIONS ///.

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

FileName [giaMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Manipulation of mapping associated with the AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 80 of file kitHop.c.

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