abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcBidec.c File Reference
#include "base/abc/abc.h"
#include "bool/bdc/bdc.h"
#include "bool/kit/kit.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
Hop_Obj_t
Bdc_FunCopyHop (Bdc_Fun_t *pObj)
 DECLARATIONS ///. More...
 
Hop_Obj_tAbc_NodeIfNodeResyn (Bdc_Man_t *p, Hop_Man_t *pHop, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, unsigned *puCare, float dProb)
 FUNCTION DEFINITIONS ///. More...
 
void Abc_NtkBidecResyn (Abc_Ntk_t *pNtk, int fVerbose)
 

Function Documentation

Hop_Obj_t* Abc_NodeIfNodeResyn ( Bdc_Man_t p,
Hop_Man_t pHop,
Hop_Obj_t pRoot,
int  nVars,
Vec_Int_t vTruth,
unsigned *  puCare,
float  dProb 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Resynthesizes nodes using bi-decomposition.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file abcBidec.c.

50 {
51  unsigned * pTruth;
52  Bdc_Fun_t * pFunc;
53  int nNodes, i;
54  assert( nVars <= 16 );
55  // derive truth table
56  pTruth = Hop_ManConvertAigToTruth( pHop, Hop_Regular(pRoot), nVars, vTruth, 0 );
57  if ( Hop_IsComplement(pRoot) )
58  Extra_TruthNot( pTruth, pTruth, nVars );
59  // perform power-aware decomposition
60  if ( dProb >= 0.0 )
61  {
62  float Prob = (float)2.0 * dProb * (1.0 - dProb);
63  assert( Prob >= 0.0 && Prob <= 0.5 );
64  if ( Prob >= 0.4 )
65  {
66  Extra_TruthNot( puCare, puCare, nVars );
67  if ( dProb > 0.5 ) // more 1s than 0s
68  Extra_TruthOr( pTruth, pTruth, puCare, nVars );
69  else
70  Extra_TruthSharp( pTruth, pTruth, puCare, nVars );
71  Extra_TruthNot( puCare, puCare, nVars );
72  // decompose truth table
73  Bdc_ManDecompose( p, pTruth, NULL, nVars, NULL, 1000 );
74  }
75  else
76  {
77  // decompose truth table
78  Bdc_ManDecompose( p, pTruth, puCare, nVars, NULL, 1000 );
79  }
80  }
81  else
82  {
83  // decompose truth table
84  Bdc_ManDecompose( p, pTruth, puCare, nVars, NULL, 1000 );
85  }
86  // convert back into HOP
87  Bdc_FuncSetCopy( Bdc_ManFunc( p, 0 ), Hop_ManConst1( pHop ) );
88  for ( i = 0; i < nVars; i++ )
89  Bdc_FuncSetCopy( Bdc_ManFunc( p, i+1 ), Hop_ManPi( pHop, i ) );
90  nNodes = Bdc_ManNodeNum(p);
91  for ( i = nVars + 1; i < nNodes; i++ )
92  {
93  pFunc = Bdc_ManFunc( p, i );
95  }
96  return Bdc_FunCopyHop( Bdc_ManRoot(p) );
97 }
static void Extra_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: extra.h:332
Bdc_Fun_t * Bdc_ManRoot(Bdc_Man_t *p)
Definition: bdcCore.c:47
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
int Bdc_ManDecompose(Bdc_Man_t *p, unsigned *puFunc, unsigned *puCare, int nVars, Vec_Ptr_t *vDivs, int nNodesMax)
Definition: bdcCore.c:291
Bdc_Fun_t * Bdc_ManFunc(Bdc_Man_t *p, int i)
DECLARATIONS ///.
Definition: bdcCore.c:46
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
void Bdc_FuncSetCopy(Bdc_Fun_t *p, void *pCopy)
Definition: bdcCore.c:54
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
static ABC_NAMESPACE_IMPL_START Hop_Obj_t * Bdc_FunCopyHop(Bdc_Fun_t *pObj)
DECLARATIONS ///.
Definition: abcBidec.c:32
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static void Extra_TruthSharp(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: extra.h:338
Bdc_Fun_t * Bdc_FuncFanin0(Bdc_Fun_t *p)
Definition: bdcCore.c:50
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
Definition: hopTruth.c:143
int Bdc_ManNodeNum(Bdc_Man_t *p)
Definition: bdcCore.c:48
#define assert(ex)
Definition: util_old.h:213
Bdc_Fun_t * Bdc_FuncFanin1(Bdc_Fun_t *p)
Definition: bdcCore.c:51
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
static void Extra_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: extra.h:320
void Abc_NtkBidecResyn ( Abc_Ntk_t pNtk,
int  fVerbose 
)

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

Synopsis [Resynthesizes nodes using bi-decomposition.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file abcBidec.c.

111 {
112  Bdc_Par_t Pars = {0}, * pPars = &Pars;
113  Bdc_Man_t * p;
114  Abc_Obj_t * pObj;
115  Vec_Int_t * vTruth;
116  int i, nGainTotal = 0, nNodes1, nNodes2;
117  abctime clk = Abc_Clock();
118  assert( Abc_NtkIsLogic(pNtk) );
119  if ( !Abc_NtkToAig(pNtk) )
120  return;
121  pPars->nVarsMax = Abc_NtkGetFaninMax( pNtk );
122  pPars->fVerbose = fVerbose;
123  if ( pPars->nVarsMax > 15 )
124  {
125  if ( fVerbose )
126  printf( "Resynthesis is not performed for nodes with more than 15 inputs.\n" );
127  pPars->nVarsMax = 15;
128  }
129  vTruth = Vec_IntAlloc( 0 );
130  p = Bdc_ManAlloc( pPars );
131  Abc_NtkForEachNode( pNtk, pObj, i )
132  {
133  if ( Abc_ObjFaninNum(pObj) > 15 )
134  continue;
135  nNodes1 = Hop_DagSize((Hop_Obj_t *)pObj->pData);
136  pObj->pData = Abc_NodeIfNodeResyn( p, (Hop_Man_t *)pNtk->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj), vTruth, NULL, -1.0 );
137  nNodes2 = Hop_DagSize((Hop_Obj_t *)pObj->pData);
138  nGainTotal += nNodes1 - nNodes2;
139  }
140  Bdc_ManFree( p );
141  Vec_IntFree( vTruth );
142  if ( fVerbose )
143  {
144  printf( "Total gain in AIG nodes = %d. ", nGainTotal );
145  ABC_PRT( "Total runtime", Abc_Clock() - clk );
146  }
147 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
int Hop_DagSize(Hop_Obj_t *pObj)
Definition: hopDfs.c:279
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Bdc_Man_t * Bdc_ManAlloc(Bdc_Par_t *pPars)
MACRO DEFINITIONS ///.
Definition: bdcCore.c:68
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: hop.h:65
void * pManFunc
Definition: abc.h:191
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
Definition: bdc.h:45
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Hop_Obj_t * Abc_NodeIfNodeResyn(Bdc_Man_t *p, Hop_Man_t *pHop, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, unsigned *puCare, float dProb)
FUNCTION DEFINITIONS ///.
Definition: abcBidec.c:49
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1192
#define assert(ex)
Definition: util_old.h:213
void Bdc_ManFree(Bdc_Man_t *p)
Definition: bdcCore.c:113
void * pData
Definition: abc.h:145
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
static ABC_NAMESPACE_IMPL_START Hop_Obj_t* Bdc_FunCopyHop ( Bdc_Fun_t pObj)
inlinestatic

DECLARATIONS ///.

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

FileName [abcBidec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Interface to bi-decomposition.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 32 of file abcBidec.c.

32 { return Hop_NotCond( (Hop_Obj_t *)Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
Definition: hop.h:65
static int Bdc_IsComplement(Bdc_Fun_t *p)
Definition: bdc.h:54
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
void * Bdc_FuncCopy(Bdc_Fun_t *p)
Definition: bdcCore.c:52
static Bdc_Fun_t * Bdc_Regular(Bdc_Fun_t *p)
Definition: bdc.h:55