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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Extra_TruthWordNum (int nVars)
 DECLARATIONS ///. More...
 
static void Extra_TruthNot (unsigned *pOut, unsigned *pIn, int nVars)
 
static void Extra_TruthOr (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static void Extra_TruthSharp (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static Hop_Obj_tBdc_FunCopyHop (Bdc_Fun_t *pObj)
 
Hop_Obj_tNwk_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 Nwk_ManBidecResyn (Nwk_Man_t *pNtk, int fVerbose)
 

Function Documentation

static Hop_Obj_t* Bdc_FunCopyHop ( Bdc_Fun_t pObj)
inlinestatic

Definition at line 50 of file nwkBidec.c.

50 { 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
static void Extra_TruthNot ( unsigned *  pOut,
unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 31 of file nwkBidec.c.

32 {
33  int w;
34  for ( w = Extra_TruthWordNum(nVars)-1; w >= 0; w-- )
35  pOut[w] = ~pIn[w];
36 }
static ABC_NAMESPACE_IMPL_START int Extra_TruthWordNum(int nVars)
DECLARATIONS ///.
Definition: nwkBidec.c:30
static void Extra_TruthOr ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 37 of file nwkBidec.c.

38 {
39  int w;
40  for ( w = Extra_TruthWordNum(nVars)-1; w >= 0; w-- )
41  pOut[w] = pIn0[w] | pIn1[w];
42 }
static ABC_NAMESPACE_IMPL_START int Extra_TruthWordNum(int nVars)
DECLARATIONS ///.
Definition: nwkBidec.c:30
static void Extra_TruthSharp ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 43 of file nwkBidec.c.

44 {
45  int w;
46  for ( w = Extra_TruthWordNum(nVars)-1; w >= 0; w-- )
47  pOut[w] = pIn0[w] & ~pIn1[w];
48 }
static ABC_NAMESPACE_IMPL_START int Extra_TruthWordNum(int nVars)
DECLARATIONS ///.
Definition: nwkBidec.c:30
static ABC_NAMESPACE_IMPL_START int Extra_TruthWordNum ( int  nVars)
inlinestatic

DECLARATIONS ///.

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

FileName [nwkBidec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Logic network representation.]

Synopsis [Bi-decomposition of local functions.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 30 of file nwkBidec.c.

30 { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
void Nwk_ManBidecResyn ( Nwk_Man_t pNtk,
int  fVerbose 
)

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

Synopsis [Resynthesizes nodes using bi-decomposition.]

Description []

SideEffects []

SeeAlso []

Definition at line 129 of file nwkBidec.c.

130 {
131  Bdc_Par_t Pars = {0}, * pPars = &Pars;
132  Bdc_Man_t * p;
133  Nwk_Obj_t * pObj;
134  Vec_Int_t * vTruth;
135  int i, nGainTotal = 0, nNodes1, nNodes2;
136  abctime clk = Abc_Clock();
137  pPars->nVarsMax = Nwk_ManGetFaninMax( pNtk );
138  pPars->fVerbose = fVerbose;
139  if ( pPars->nVarsMax < 2 )
140  {
141  printf( "Resynthesis is not performed for networks whose nodes are less than 2 inputs.\n" );
142  return;
143  }
144  if ( pPars->nVarsMax > 15 )
145  {
146  if ( fVerbose )
147  printf( "Resynthesis is not performed for nodes with more than 15 inputs.\n" );
148  pPars->nVarsMax = 15;
149  }
150  vTruth = Vec_IntAlloc( 0 );
151  p = Bdc_ManAlloc( pPars );
152  Nwk_ManForEachNode( pNtk, pObj, i )
153  {
154  if ( Nwk_ObjFaninNum(pObj) > 15 )
155  continue;
156  nNodes1 = Hop_DagSize(pObj->pFunc);
157  pObj->pFunc = Nwk_NodeIfNodeResyn( p, pNtk->pManHop, pObj->pFunc, Nwk_ObjFaninNum(pObj), vTruth, NULL, -1.0 );
158  nNodes2 = Hop_DagSize(pObj->pFunc);
159  nGainTotal += nNodes1 - nNodes2;
160  }
161  Bdc_ManFree( p );
162  Vec_IntFree( vTruth );
163  if ( fVerbose )
164  {
165  printf( "Total gain in AIG nodes = %d. ", nGainTotal );
166  ABC_PRT( "Total runtime", Abc_Clock() - clk );
167  }
168 }
int Hop_DagSize(Hop_Obj_t *pObj)
Definition: hopDfs.c:279
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
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 abctime Abc_Clock()
Definition: abc_global.h:279
static int Nwk_ObjFaninNum(Nwk_Obj_t *p)
Definition: nwk.h:137
Hop_Man_t * pManHop
Definition: nwk.h:73
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL int Nwk_ManGetFaninMax(Nwk_Man_t *pNtk)
Definition: nwkUtil.c:71
Definition: bdc.h:45
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Hop_Obj_t * Nwk_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: nwkBidec.c:67
void Bdc_ManFree(Bdc_Man_t *p)
Definition: bdcCore.c:113
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Nwk_ManForEachNode(p, pObj, i)
Definition: nwk.h:192
Hop_Obj_t* Nwk_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 67 of file nwkBidec.c.

68 {
69  unsigned * pTruth;
70  Bdc_Fun_t * pFunc;
71  int nNodes, i;
72  assert( nVars <= 16 );
73  // derive truth table
74  pTruth = Hop_ManConvertAigToTruth( pHop, Hop_Regular(pRoot), nVars, vTruth, 0 );
75  if ( Hop_IsComplement(pRoot) )
76  for ( i = Abc_TruthWordNum(nVars)-1; i >= 0; i-- )
77  pTruth[i] = ~pTruth[i];
78  // perform power-aware decomposition
79  if ( dProb >= 0.0 )
80  {
81  float Prob = (float)2.0 * dProb * (1.0 - dProb);
82  assert( Prob >= 0.0 && Prob <= 0.5 );
83  if ( Prob >= 0.4 )
84  {
85  Extra_TruthNot( puCare, puCare, nVars );
86  if ( dProb > 0.5 ) // more 1s than 0s
87  Extra_TruthOr( pTruth, pTruth, puCare, nVars );
88  else
89  Extra_TruthSharp( pTruth, pTruth, puCare, nVars );
90  Extra_TruthNot( puCare, puCare, nVars );
91  // decompose truth table
92  Bdc_ManDecompose( p, pTruth, NULL, nVars, NULL, 1000 );
93  }
94  else
95  {
96  // decompose truth table
97  Bdc_ManDecompose( p, pTruth, puCare, nVars, NULL, 1000 );
98  }
99  }
100  else
101  {
102  // decompose truth table
103  Bdc_ManDecompose( p, pTruth, puCare, nVars, NULL, 1000 );
104  }
105  // convert back into HOP
106  Bdc_FuncSetCopy( Bdc_ManFunc( p, 0 ), Hop_ManConst1( pHop ) );
107  for ( i = 0; i < nVars; i++ )
108  Bdc_FuncSetCopy( Bdc_ManFunc( p, i+1 ), Hop_ManPi( pHop, i ) );
109  nNodes = Bdc_ManNodeNum(p);
110  for ( i = nVars + 1; i < nNodes; i++ )
111  {
112  pFunc = Bdc_ManFunc( p, i );
114  }
115  return Bdc_FunCopyHop( Bdc_ManRoot(p) );
116 }
Bdc_Fun_t * Bdc_ManRoot(Bdc_Man_t *p)
Definition: bdcCore.c:47
static Hop_Obj_t * Bdc_FunCopyHop(Bdc_Fun_t *pObj)
Definition: nwkBidec.c:50
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
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
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 void Extra_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: nwkBidec.c:31
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: nwkBidec.c:43
Bdc_Fun_t * Bdc_FuncFanin0(Bdc_Fun_t *p)
Definition: bdcCore.c:50
static void Extra_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: nwkBidec.c:37
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