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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Abc_Obj_tLpk_ImplementFun (Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, Lpk_Fun_t *p)
 DECLARATIONS ///.
 
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 ///.
 

Function Documentation

◆ Lpk_Decompose()

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}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
Cube * p
Definition exorList.c:222
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
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_Obj_t * Lpk_Implement(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, int nLeavesOld)
Definition lpkAbcDec.c:120
int Lpk_FunSuppMinimize(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:143
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
struct Lpk_Fun_t_ Lpk_Fun_t
Definition lpkInt.h:144
unsigned nLutK
Definition lpkInt.h:150
unsigned nVars
Definition lpkInt.h:149
unsigned fSupports
Definition lpkInt.h:152
unsigned puSupps[32]
Definition lpkInt.h:155
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lpk_Decompose_rec()

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
168clk = Abc_Clock();
169 pResDsd = Lpk_DsdAnalize( pMan, p, pMan->pPars->nVarsShared );
170pMan->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 {
174clk = Abc_Clock();
175 p2 = Lpk_DsdSplit( pMan, p, pResDsd->pCofVars, pResDsd->nCofVars, pResDsd->BSVars );
176pMan->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
184clk = Abc_Clock();
185 pResMux = Lpk_MuxAnalize( pMan, p );
186pMan->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 {
205clk = Abc_Clock();
206 p2 = Lpk_MuxSplit( pMan, p, pResMux->Variable, pResMux->Polarity );
207pMan->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 {
216clk = Abc_Clock();
217 p2 = Lpk_DsdSplit( pMan, p, pResDsd->pCofVars, pResDsd->nCofVars, pResDsd->BSVars );
218pMan->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}
ABC_INT64_T abctime
Definition abc_global.h:332
Lpk_Res_t * Lpk_DsdAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p, int nShared)
Definition lpkAbcDsd.c:452
Lpk_Fun_t * Lpk_DsdSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, char *pCofVars, int nCofVars, unsigned uBoundSet)
Definition lpkAbcDsd.c:564
ABC_NAMESPACE_IMPL_START Lpk_Res_t * Lpk_MuxAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p)
DECLARATIONS ///.
Definition lpkAbcMux.c:45
Lpk_Fun_t * Lpk_MuxSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, int Var, int Pol)
Definition lpkAbcMux.c:164
int Lpk_SuppDelay(unsigned uSupp, int *pDelays)
Definition lpkAbcUtil.c:215
void Lpk_FunComputeCofSupps(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:186
struct Lpk_Res_t_ Lpk_Res_t
Definition lpkInt.h:163
abctime timeEvalDsdAn
Definition lpkInt.h:137
abctime timeEvalMuxSp
Definition lpkInt.h:136
Lpk_Par_t * pPars
Definition lpkInt.h:72
abctime timeEvalMuxAn
Definition lpkInt.h:135
abctime timeEvalDsdSp
Definition lpkInt.h:138
int nSuppSizeS
Definition lpkInt.h:170
int Variable
Definition lpkInt.h:174
int nCofVars
Definition lpkInt.h:168
int Polarity
Definition lpkInt.h:175
unsigned BSVars
Definition lpkInt.h:167
int DelayEst
Definition lpkInt.h:172
int nBSVars
Definition lpkInt.h:166
int AreaEst
Definition lpkInt.h:173
char pCofVars[4]
Definition lpkInt.h:169
int nSuppSizeL
Definition lpkInt.h:171
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lpk_DecomposeClean()

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}
void Lpk_FunFree(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:64
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lpk_Implement()

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}
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
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition vecPtr.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lpk_Implement_rec()

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}
char pFanins[16]
Definition lpkInt.h:158
unsigned Id
Definition lpkInt.h:148
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lpk_ImplementFun()

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}
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL int Abc_ObjLevelNew(Abc_Obj_t *pObj)
Definition abcTiming.c:1170
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
Hop_Obj_t * Kit_TruthToHop(Hop_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition kitHop.c:271
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
int nDsds
Definition lpkInt.h:117
int nMuxes
Definition lpkInt.h:116
Here is the call graph for this function:
Here is the caller graph for this function: