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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Abc_Obj_t
Lpk_ImplementFun (Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *p)
 DECLARATIONS ///. More...
 
Abc_Obj_tLpk_Implement_rec (Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *pFun)
 
Abc_Obj_tLpk_Implement (Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, int nLeavesOld)
 
int Lpk_Decompose_rec (Lpk_Man_t *pMan, Lpk_Fun_t *p)
 
void Lpk_DecomposeClean (Vec_Ptr_t *vLeaves, int nLeavesOld)
 
Abc_Obj_tLpk_Decompose (Lpk_Man_t *p, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, unsigned *puSupps, int nLutK, int AreaLim, int DelayLim)
 FUNCTION DECLARATIONS ///. More...
 

Function Documentation

Abc_Obj_t* Lpk_Decompose ( Lpk_Man_t p,
Abc_Ntk_t pNtk,
Vec_Ptr_t vLeaves,
unsigned *  pTruth,
unsigned *  puSupps,
int  nLutK,
int  AreaLim,
int  DelayLim 
)

FUNCTION DECLARATIONS ///.

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

Synopsis [Decomposes the function using recursive MUX decomposition.]

Description []

SideEffects []

SeeAlso []

Definition at line 258 of file lpkAbcDec.c.

259 {
260  Lpk_Fun_t * pFun;
261  Abc_Obj_t * pObjNew = NULL;
262  int nLeaves = Vec_PtrSize( vLeaves );
263  pFun = Lpk_FunCreate( pNtk, vLeaves, pTruth, nLutK, AreaLim, DelayLim );
264  if ( puSupps[0] || puSupps[1] )
265  {
266 /*
267  int i;
268  Lpk_FunComputeCofSupps( pFun );
269  for ( i = 0; i < nLeaves; i++ )
270  {
271  assert( pFun->puSupps[2*i+0] == puSupps[2*i+0] );
272  assert( pFun->puSupps[2*i+1] == puSupps[2*i+1] );
273  }
274 */
275  memcpy( pFun->puSupps, puSupps, sizeof(unsigned) * 2 * nLeaves );
276  pFun->fSupports = 1;
277  }
278  Lpk_FunSuppMinimize( pFun );
279  if ( pFun->nVars <= pFun->nLutK )
280  pObjNew = Lpk_ImplementFun( p, pNtk, vLeaves, pFun );
281  else if ( Lpk_Decompose_rec(p, pFun) )
282  pObjNew = Lpk_Implement( p, pNtk, vLeaves, nLeaves );
283  Lpk_DecomposeClean( vLeaves, nLeaves );
284  return pObjNew;
285 }
Abc_Obj_t * Lpk_Implement(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, int nLeavesOld)
Definition: lpkAbcDec.c:120
unsigned nVars
Definition: lpkInt.h:148
unsigned nLutK
Definition: lpkInt.h:149
unsigned fSupports
Definition: lpkInt.h:152
char * memcpy()
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Lpk_FunSuppMinimize(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:143
int Lpk_Decompose_rec(Lpk_Man_t *pMan, Lpk_Fun_t *p)
Definition: lpkAbcDec.c:147
void Lpk_DecomposeClean(Vec_Ptr_t *vLeaves, int nLeavesOld)
Definition: lpkAbcDec.c:238
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Lpk_ImplementFun(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *p)
DECLARATIONS ///.
Definition: lpkAbcDec.c:45
unsigned puSupps[32]
Definition: lpkInt.h:155
Lpk_Fun_t * Lpk_FunCreate(Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, int nLutK, int AreaLim, int DelayLim)
Definition: lpkAbcUtil.c:80
int Lpk_Decompose_rec ( Lpk_Man_t pMan,
Lpk_Fun_t p 
)

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

Synopsis [Decomposes the function using recursive MUX decomposition.]

Description [Returns the ID of the top-most decomposition node implementing this function, or 0 if there is no decomposition satisfying the constraints on area and delay.]

SideEffects []

SeeAlso []

Definition at line 147 of file lpkAbcDec.c.

148 {
149  Lpk_Res_t * pResMux, * pResDsd;
150  Lpk_Fun_t * p2;
151  abctime clk;
152 
153  // is only called for non-trivial blocks
154  assert( p->nLutK >= 3 && p->nLutK <= 6 );
155  assert( p->nVars > p->nLutK );
156  // skip if area bound is exceeded
157  if ( Lpk_LutNumLuts(p->nVars, p->nLutK) > (int)p->nAreaLim )
158  return 0;
159  // skip if delay bound is exceeded
160  if ( Lpk_SuppDelay(p->uSupp, p->pDelays) > (int)p->nDelayLim )
161  return 0;
162 
163  // compute supports if needed
164  if ( !p->fSupports )
166 
167  // check DSD decomposition
168 clk = Abc_Clock();
169  pResDsd = Lpk_DsdAnalize( pMan, p, pMan->pPars->nVarsShared );
170 pMan->timeEvalDsdAn += Abc_Clock() - clk;
171  if ( pResDsd && (pResDsd->nBSVars == (int)p->nLutK || pResDsd->nBSVars == (int)p->nLutK - 1) &&
172  pResDsd->AreaEst <= (int)p->nAreaLim && pResDsd->DelayEst <= (int)p->nDelayLim )
173  {
174 clk = Abc_Clock();
175  p2 = Lpk_DsdSplit( pMan, p, pResDsd->pCofVars, pResDsd->nCofVars, pResDsd->BSVars );
176 pMan->timeEvalDsdSp += Abc_Clock() - clk;
177  assert( p2->nVars <= (int)p->nLutK );
178  if ( p->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p ) )
179  return 0;
180  return 1;
181  }
182 
183  // check MUX decomposition
184 clk = Abc_Clock();
185  pResMux = Lpk_MuxAnalize( pMan, p );
186 pMan->timeEvalMuxAn += Abc_Clock() - clk;
187 // pResMux = NULL;
188  assert( !pResMux || (pResMux->DelayEst <= (int)p->nDelayLim && pResMux->AreaEst <= (int)p->nAreaLim) );
189  // accept MUX decomposition if it is "good"
190  if ( pResMux && pResMux->nSuppSizeS <= (int)p->nLutK && pResMux->nSuppSizeL <= (int)p->nLutK )
191  pResDsd = NULL;
192  else if ( pResMux && pResDsd )
193  {
194  // compare two decompositions
195  if ( pResMux->AreaEst < pResDsd->AreaEst ||
196  (pResMux->AreaEst == pResDsd->AreaEst && pResMux->nSuppSizeL < pResDsd->nSuppSizeL) ||
197  (pResMux->AreaEst == pResDsd->AreaEst && pResMux->nSuppSizeL == pResDsd->nSuppSizeL && pResMux->DelayEst < pResDsd->DelayEst) )
198  pResDsd = NULL;
199  else
200  pResMux = NULL;
201  }
202  assert( pResMux == NULL || pResDsd == NULL );
203  if ( pResMux )
204  {
205 clk = Abc_Clock();
206  p2 = Lpk_MuxSplit( pMan, p, pResMux->Variable, pResMux->Polarity );
207 pMan->timeEvalMuxSp += Abc_Clock() - clk;
208  if ( p2->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p2 ) )
209  return 0;
210  if ( p->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p ) )
211  return 0;
212  return 1;
213  }
214  if ( pResDsd )
215  {
216 clk = Abc_Clock();
217  p2 = Lpk_DsdSplit( pMan, p, pResDsd->pCofVars, pResDsd->nCofVars, pResDsd->BSVars );
218 pMan->timeEvalDsdSp += Abc_Clock() - clk;
219  assert( p2->nVars <= (int)p->nLutK );
220  if ( p->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p ) )
221  return 0;
222  return 1;
223  }
224  return 0;
225 }
unsigned nAreaLim
Definition: lpkInt.h:150
Lpk_Par_t * pPars
Definition: lpkInt.h:72
int nCofVars
Definition: lpkInt.h:167
void Lpk_FunComputeCofSupps(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:186
unsigned nVars
Definition: lpkInt.h:148
int Variable
Definition: lpkInt.h:173
int Lpk_SuppDelay(unsigned uSupp, char *pDelays)
Definition: lpkAbcUtil.c:215
unsigned nLutK
Definition: lpkInt.h:149
int AreaEst
Definition: lpkInt.h:172
abctime timeEvalMuxSp
Definition: lpkInt.h:135
unsigned uSupp
Definition: lpkInt.h:154
unsigned fSupports
Definition: lpkInt.h:152
int nBSVars
Definition: lpkInt.h:165
static abctime Abc_Clock()
Definition: abc_global.h:279
Lpk_Fun_t * Lpk_DsdSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, char *pCofVars, int nCofVars, unsigned uBoundSet)
Definition: lpkAbcDsd.c:564
unsigned BSVars
Definition: lpkInt.h:166
abctime timeEvalMuxAn
Definition: lpkInt.h:134
char pCofVars[4]
Definition: lpkInt.h:168
abctime timeEvalDsdSp
Definition: lpkInt.h:137
int DelayEst
Definition: lpkInt.h:171
int nSuppSizeS
Definition: lpkInt.h:169
int Lpk_Decompose_rec(Lpk_Man_t *pMan, Lpk_Fun_t *p)
Definition: lpkAbcDec.c:147
Lpk_Res_t * Lpk_DsdAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p, int nShared)
Definition: lpkAbcDsd.c:452
char pDelays[16]
Definition: lpkInt.h:156
int Polarity
Definition: lpkInt.h:174
static int Lpk_LutNumLuts(int nVarsMax, int nLutK)
Definition: lpkInt.h:178
abctime timeEvalDsdAn
Definition: lpkInt.h:136
#define assert(ex)
Definition: util_old.h:213
Lpk_Fun_t * Lpk_MuxSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, int Var, int Pol)
Definition: lpkAbcMux.c:164
ABC_NAMESPACE_IMPL_START Lpk_Res_t * Lpk_MuxAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p)
DECLARATIONS ///.
Definition: lpkAbcMux.c:45
ABC_INT64_T abctime
Definition: abc_global.h:278
int nSuppSizeL
Definition: lpkInt.h:170
unsigned nDelayLim
Definition: lpkInt.h:151
void Lpk_DecomposeClean ( Vec_Ptr_t vLeaves,
int  nLeavesOld 
)

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

Synopsis [Removes decomposed nodes from the array of fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file lpkAbcDec.c.

239 {
240  Lpk_Fun_t * pFunc;
241  int i;
242  Vec_PtrForEachEntryStart( Lpk_Fun_t *, vLeaves, pFunc, i, nLeavesOld )
243  Lpk_FunFree( pFunc );
244  Vec_PtrShrink( vLeaves, nLeavesOld );
245 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
void Lpk_FunFree(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:64
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
Abc_Obj_t* Lpk_Implement ( Lpk_Man_t pMan,
Abc_Ntk_t pNtk,
Vec_Ptr_t vLeaves,
int  nLeavesOld 
)

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

Synopsis [Implements the function.]

Description [Returns the node implementing this function.]

SideEffects []

SeeAlso []

Definition at line 120 of file lpkAbcDec.c.

121 {
122  Abc_Obj_t * pFanin, * pRes;
123  int i;
124  assert( nLeavesOld < Vec_PtrSize(vLeaves) );
125  // mark implemented nodes
126  Vec_PtrForEachEntryStop( Abc_Obj_t *, vLeaves, pFanin, i, nLeavesOld )
127  Vec_PtrWriteEntry( vLeaves, i, Abc_ObjNot(pFanin) );
128  // recursively construct starting from the first entry
129  pRes = Lpk_Implement_rec( pMan, pNtk, vLeaves, (Lpk_Fun_t *)Vec_PtrEntry( vLeaves, nLeavesOld ) );
130  Vec_PtrShrink( vLeaves, nLeavesOld );
131  return pRes;
132 }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
Abc_Obj_t * Lpk_Implement_rec(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *pFun)
Definition: lpkAbcDec.c:88
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition: vecPtr.h:59
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
Abc_Obj_t* Lpk_Implement_rec ( Lpk_Man_t pMan,
Abc_Ntk_t pNtk,
Vec_Ptr_t vLeaves,
Lpk_Fun_t pFun 
)

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

Synopsis [Implements the function.]

Description [Returns the node implementing this function.]

SideEffects []

SeeAlso []

Definition at line 88 of file lpkAbcDec.c.

89 {
90  Abc_Obj_t * pFanin, * pRes;
91  int i;
92  // prepare the leaves of the function
93  for ( i = 0; i < (int)pFun->nVars; i++ )
94  {
95  pFanin = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, pFun->pFanins[i] );
96  if ( !Abc_ObjIsComplement(pFanin) )
97  Lpk_Implement_rec( pMan, pNtk, vLeaves, (Lpk_Fun_t *)pFanin );
98  pFanin = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, pFun->pFanins[i] );
99  assert( Abc_ObjIsComplement(pFanin) );
100  }
101  // construct the function
102  pRes = Lpk_ImplementFun( pMan, pNtk, vLeaves, pFun );
103  // replace the function
104  Vec_PtrWriteEntry( vLeaves, pFun->Id, Abc_ObjNot(pRes) );
105  Lpk_FunFree( pFun );
106  return pRes;
107 }
unsigned nVars
Definition: lpkInt.h:148
void Lpk_FunFree(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:64
unsigned Id
Definition: lpkInt.h:147
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
Abc_Obj_t * Lpk_Implement_rec(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *pFun)
Definition: lpkAbcDec.c:88
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
char pFanins[16]
Definition: lpkInt.h:157
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Lpk_ImplementFun(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *p)
DECLARATIONS ///.
Definition: lpkAbcDec.c:45
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
ABC_NAMESPACE_IMPL_START Abc_Obj_t* Lpk_ImplementFun ( Lpk_Man_t pMan,
Abc_Ntk_t pNtk,
Vec_Ptr_t vLeaves,
Lpk_Fun_t p 
)

DECLARATIONS ///.

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

FileName [lpkAbcDec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Fast Boolean matching for LUT structures.]

Synopsis [The new core procedure.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
lpkAbcDec.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Implements the function.]

Description [Returns the node implementing this function.]

SideEffects []

SeeAlso []

Definition at line 45 of file lpkAbcDec.c.

46 {
47  extern Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory );
48  unsigned * pTruth;
49  Abc_Obj_t * pObjNew;
50  int i;
51  if ( p->fMark )
52  pMan->nMuxes++;
53  else
54  pMan->nDsds++;
55  // create the new node
56  pObjNew = Abc_NtkCreateNode( pNtk );
57  for ( i = 0; i < (int)p->nVars; i++ )
58  Abc_ObjAddFanin( pObjNew, Abc_ObjRegular((Abc_Obj_t *)Vec_PtrEntry(vLeaves, p->pFanins[i])) );
59  Abc_ObjSetLevel( pObjNew, Abc_ObjLevelNew(pObjNew) );
60  // assign the node's function
61  pTruth = Lpk_FunTruth(p, 0);
62  if ( p->nVars == 0 )
63  {
64  pObjNew->pData = Hop_NotCond( Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc), !(pTruth[0] & 1) );
65  return pObjNew;
66  }
67  if ( p->nVars == 1 )
68  {
69  pObjNew->pData = Hop_NotCond( Hop_ManPi((Hop_Man_t *)pNtk->pManFunc, 0), (pTruth[0] & 1) );
70  return pObjNew;
71  }
72  // create the logic function
73  pObjNew->pData = Kit_TruthToHop( (Hop_Man_t *)pNtk->pManFunc, pTruth, p->nVars, NULL );
74  return pObjNew;
75 }
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
unsigned nVars
Definition: lpkInt.h:148
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Abc_ObjSetLevel(Abc_Obj_t *pObj, int Level)
Definition: abc.h:341
Definition: hop.h:65
Hop_Obj_t * Kit_TruthToHop(Hop_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitHop.c:146
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static unsigned * Lpk_FunTruth(Lpk_Fun_t *p, int Num)
Definition: lpkInt.h:179
static Hop_Obj_t * Hop_ManPi(Hop_Man_t *p, int i)
Definition: hop.h:134
int nDsds
Definition: lpkInt.h:116
void * pManFunc
Definition: abc.h:191
unsigned fMark
Definition: lpkInt.h:153
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
char pFanins[16]
Definition: lpkInt.h:157
void * pData
Definition: abc.h:145
int nMuxes
Definition: lpkInt.h:115
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
ABC_DLL int Abc_ObjLevelNew(Abc_Obj_t *pObj)
Definition: abcTiming.c:1058