ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
nwkBidec.c File Reference
#include "nwk.h"
Include dependency graph for nwkBidec.c:

Go to the source code of this file.

Functions

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 ///.
 
void Nwk_ManBidecResyn (Nwk_Man_t *pNtk, int fVerbose)
 

Function Documentation

◆ Nwk_ManBidecResyn()

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}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Bdc_Par_t_ Bdc_Par_t
Definition bdc.h:44
struct Bdc_Man_t_ Bdc_Man_t
Definition bdc.h:43
void Bdc_ManFree(Bdc_Man_t *p)
Definition bdcCore.c:113
Bdc_Man_t * Bdc_ManAlloc(Bdc_Par_t *pPars)
MACRO DEFINITIONS ///.
Definition bdcCore.c:68
Cube * p
Definition exorList.c:222
int Hop_DagSize(Hop_Obj_t *pObj)
Definition hopDfs.c:279
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
#define Nwk_ManForEachNode(p, pObj, i)
Definition nwk.h:192
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition nwk.h:49
ABC_DLL int Nwk_ManGetFaninMax(Nwk_Man_t *pNtk)
Definition nwkUtil.c:71
Hop_Man_t * pManHop
Definition nwk.h:73
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nwk_NodeIfNodeResyn()

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 );
113 Bdc_FuncSetCopy( pFunc, Hop_And( pHop, Bdc_FunCopyHop(Bdc_FuncFanin0(pFunc)), Bdc_FunCopyHop(Bdc_FuncFanin1(pFunc)) ) );
114 }
115 return Bdc_FunCopyHop( Bdc_ManRoot(p) );
116}
int Bdc_ManNodeNum(Bdc_Man_t *p)
Definition bdcCore.c:48
Bdc_Fun_t * Bdc_FuncFanin0(Bdc_Fun_t *p)
Definition bdcCore.c:50
Bdc_Fun_t * Bdc_ManRoot(Bdc_Man_t *p)
Definition bdcCore.c:47
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition bdc.h:42
void Bdc_FuncSetCopy(Bdc_Fun_t *p, void *pCopy)
Definition bdcCore.c:54
Bdc_Fun_t * Bdc_FuncFanin1(Bdc_Fun_t *p)
Definition bdcCore.c:51
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
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:104
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
Definition hopTruth.c:143
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function: