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

Go to the source code of this file.

Classes

struct  Dch_Cla_t_
 

Macros

#define Dch_ManForEachClass(p, ppClass, i)
 
#define Dch_ClassForEachNode(p, pRepr, pNode, i)
 

Functions

Dch_Cla_tDch_ClassesStart (Aig_Man_t *pAig)
 
void Dch_ClassesSetData (Dch_Cla_t *p, void *pManData, unsigned(*pFuncNodeHash)(void *, Aig_Obj_t *), int(*pFuncNodeIsConst)(void *, Aig_Obj_t *), int(*pFuncNodesAreEqual)(void *, Aig_Obj_t *, Aig_Obj_t *))
 
void Dch_ClassesStop (Dch_Cla_t *p)
 
int Dch_ClassesLitNum (Dch_Cla_t *p)
 
Aig_Obj_t ** Dch_ClassesReadClass (Dch_Cla_t *p, Aig_Obj_t *pRepr, int *pnSize)
 
void Dch_ClassesCheck (Dch_Cla_t *p)
 
void Dch_ClassesPrintOne (Dch_Cla_t *p, Aig_Obj_t *pRepr)
 
void Dch_ClassesPrint (Dch_Cla_t *p, int fVeryVerbose)
 
void Dch_ClassesPrepare (Dch_Cla_t *p, int fLatchCorr, int nMaxLevs)
 
int Dch_ClassesRefineOneClass (Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
 
int Dch_ClassesRefine (Dch_Cla_t *p)
 
void Dch_ClassesCollectOneClass (Dch_Cla_t *p, Aig_Obj_t *pRepr, Vec_Ptr_t *vRoots)
 
void Dch_ClassesCollectConst1Group (Dch_Cla_t *p, Aig_Obj_t *pObj, int nNodes, Vec_Ptr_t *vRoots)
 
int Dch_ClassesRefineConst1Group (Dch_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
 

Macro Definition Documentation

◆ Dch_ClassForEachNode

#define Dch_ClassForEachNode ( p,
pRepr,
pNode,
i )
Value:
for ( i = 0; i < p->pClassSizes[pRepr->Id]; i++ ) \
if ( ((pNode) = p->pId2Class[pRepr->Id][i]) == NULL ) {} else
Cube * p
Definition exorList.c:222

Definition at line 71 of file dchClass.c.

71#define Dch_ClassForEachNode( p, pRepr, pNode, i ) \
72 for ( i = 0; i < p->pClassSizes[pRepr->Id]; i++ ) \
73 if ( ((pNode) = p->pId2Class[pRepr->Id][i]) == NULL ) {} else

◆ Dch_ManForEachClass

#define Dch_ManForEachClass ( p,
ppClass,
i )
Value:
for ( i = 0; i < Aig_ManObjNumMax(p->pAig); i++ ) \
if ( ((ppClass) = p->pId2Class[i]) == NULL ) {} else

Definition at line 67 of file dchClass.c.

67#define Dch_ManForEachClass( p, ppClass, i ) \
68 for ( i = 0; i < Aig_ManObjNumMax(p->pAig); i++ ) \
69 if ( ((ppClass) = p->pId2Class[i]) == NULL ) {} else

Function Documentation

◆ Dch_ClassesCheck()

void Dch_ClassesCheck ( Dch_Cla_t * p)

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

Synopsis [Checks candidate equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file dchClass.c.

242{
243 Aig_Obj_t * pObj, * pPrev, ** ppClass;
244 int i, k, nLits, nClasses, nCands1;
245 nClasses = nLits = 0;
246 Dch_ManForEachClass( p, ppClass, k )
247 {
248 pPrev = NULL;
249 Dch_ClassForEachNode( p, ppClass[0], pObj, i )
250 {
251 if ( i == 0 )
252 assert( Aig_ObjRepr(p->pAig, pObj) == NULL );
253 else
254 {
255 assert( Aig_ObjRepr(p->pAig, pObj) == ppClass[0] );
256 assert( pPrev->Id < pObj->Id );
257 nLits++;
258 }
259 pPrev = pObj;
260 }
261 nClasses++;
262 }
263 nCands1 = 0;
264 Aig_ManForEachObj( p->pAig, pObj, i )
265 nCands1 += Dch_ObjIsConst1Cand( p->pAig, pObj );
266 assert( p->nLits == nLits );
267 assert( p->nCands1 == nCands1 );
268 assert( p->nClasses == nClasses );
269}
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Dch_ManForEachClass(p, ppClass, i)
Definition dchClass.c:67
#define Dch_ClassForEachNode(p, pRepr, pNode, i)
Definition dchClass.c:71
int Id
Definition aig.h:85
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Dch_ClassesCollectConst1Group()

void Dch_ClassesCollectConst1Group ( Dch_Cla_t * p,
Aig_Obj_t * pObj,
int nNodes,
Vec_Ptr_t * vRoots )

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

Synopsis [Returns equivalence class of the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 546 of file dchClass.c.

547{
548 int i, Limit;
549 Vec_PtrClear( vRoots );
550 Limit = Abc_MinInt( pObj->Id + nNodes, Aig_ManObjNumMax(p->pAig) );
551 for ( i = pObj->Id; i < Limit; i++ )
552 {
553 pObj = Aig_ManObj( p->pAig, i );
554 if ( pObj && Dch_ObjIsConst1Cand( p->pAig, pObj ) )
555 Vec_PtrPush( vRoots, pObj );
556 }
557}
Here is the caller graph for this function:

◆ Dch_ClassesCollectOneClass()

void Dch_ClassesCollectOneClass ( Dch_Cla_t * p,
Aig_Obj_t * pRepr,
Vec_Ptr_t * vRoots )

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

Synopsis [Returns equivalence class of the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 525 of file dchClass.c.

526{
527 Aig_Obj_t * pObj;
528 int i;
529 Vec_PtrClear( vRoots );
530 Dch_ClassForEachNode( p, pRepr, pObj, i )
531 Vec_PtrPush( vRoots, pObj );
532 assert( Vec_PtrSize(vRoots) > 1 );
533}
Here is the caller graph for this function:

◆ Dch_ClassesLitNum()

int Dch_ClassesLitNum ( Dch_Cla_t * p)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file dchClass.c.

207{
208 return p->nLits;
209}
Here is the caller graph for this function:

◆ Dch_ClassesPrepare()

void Dch_ClassesPrepare ( Dch_Cla_t * p,
int fLatchCorr,
int nMaxLevs )

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

Synopsis [Creates initial simulation classes.]

Description [Assumes that simulation info is assigned.]

SideEffects []

SeeAlso []

Definition at line 336 of file dchClass.c.

337{
338 Aig_Obj_t ** ppTable, ** ppNexts, ** ppClassNew;
339 Aig_Obj_t * pObj, * pTemp, * pRepr;
340 int i, k, nTableSize, nNodes, iEntry, nEntries, nEntries2;
341
342 // allocate the hash table hashing simulation info into nodes
343 nTableSize = Abc_PrimeCudd( Aig_ManObjNumMax(p->pAig)/4 );
344 ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
345 ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
346
347 // add all the nodes to the hash table
348 nEntries = 0;
349 Aig_ManForEachObj( p->pAig, pObj, i )
350 {
351 if ( fLatchCorr )
352 {
353 if ( !Aig_ObjIsCi(pObj) )
354 continue;
355 }
356 else
357 {
358 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
359 continue;
360 // skip the node with more that the given number of levels
361 if ( nMaxLevs && (int)pObj->Level >= nMaxLevs )
362 continue;
363 }
364 // check if the node belongs to the class of constant 1
365 if ( p->pFuncNodeIsConst( p->pManData, pObj ) )
366 {
367 Dch_ObjSetConst1Cand( p->pAig, pObj );
368 p->nCands1++;
369 continue;
370 }
371 // hash the node by its simulation info
372 iEntry = p->pFuncNodeHash( p->pManData, pObj ) % nTableSize;
373 // add the node to the class
374 if ( ppTable[iEntry] == NULL )
375 ppTable[iEntry] = pObj;
376 else
377 {
378 // set the representative of this node
379 pRepr = ppTable[iEntry];
380 Aig_ObjSetRepr( p->pAig, pObj, pRepr );
381 // add node to the table
382 if ( Dch_ObjNext( ppNexts, pRepr ) == NULL )
383 { // this will be the second entry
384 p->pClassSizes[pRepr->Id]++;
385 nEntries++;
386 }
387 // add the entry to the list
388 Dch_ObjSetNext( ppNexts, pObj, Dch_ObjNext( ppNexts, pRepr ) );
389 Dch_ObjSetNext( ppNexts, pRepr, pObj );
390 p->pClassSizes[pRepr->Id]++;
391 nEntries++;
392 }
393 }
394
395 // allocate room for classes
396 p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, nEntries + p->nCands1 );
397 p->pMemClassesFree = p->pMemClasses + nEntries;
398
399 // copy the entries into storage in the topological order
400 nEntries2 = 0;
401 Aig_ManForEachObj( p->pAig, pObj, i )
402 {
403 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
404 continue;
405 nNodes = p->pClassSizes[pObj->Id];
406 // skip the nodes that are not representatives of non-trivial classes
407 if ( nNodes == 0 )
408 continue;
409 assert( nNodes > 1 );
410 // add the nodes to the class in the topological order
411 ppClassNew = p->pMemClasses + nEntries2;
412 ppClassNew[0] = pObj;
413 for ( pTemp = Dch_ObjNext(ppNexts, pObj), k = 1; pTemp;
414 pTemp = Dch_ObjNext(ppNexts, pTemp), k++ )
415 {
416 ppClassNew[nNodes-k] = pTemp;
417 }
418 // add the class of nodes
419 p->pClassSizes[pObj->Id] = 0;
420 Dch_ObjAddClass( p, pObj, ppClassNew, nNodes );
421 // increment the number of entries
422 nEntries2 += nNodes;
423 }
424 assert( nEntries == nEntries2 );
425 ABC_FREE( ppTable );
426 ABC_FREE( ppNexts );
427 // now it is time to refine the classes
430}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
void Dch_ClassesCheck(Dch_Cla_t *p)
Definition dchClass.c:241
int Dch_ClassesRefine(Dch_Cla_t *p)
Definition dchClass.c:504
unsigned Level
Definition aig.h:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dch_ClassesPrint()

void Dch_ClassesPrint ( Dch_Cla_t * p,
int fVeryVerbose )

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 303 of file dchClass.c.

304{
305 Aig_Obj_t ** ppClass;
306 Aig_Obj_t * pObj;
307 int i;
308 Abc_Print( 1, "Equivalence classes: Const1 = %5d. Class = %5d. Lit = %5d.\n",
309 p->nCands1, p->nClasses, p->nLits );
310 if ( !fVeryVerbose )
311 return;
312 Abc_Print( 1, "Constants { " );
313 Aig_ManForEachObj( p->pAig, pObj, i )
314 if ( Dch_ObjIsConst1Cand( p->pAig, pObj ) )
315 Abc_Print( 1, "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
316 Abc_Print( 1, "}\n" );
317 Dch_ManForEachClass( p, ppClass, i )
318 {
319 Abc_Print( 1, "%3d (%3d) : ", i, p->pClassSizes[i] );
320 Dch_ClassesPrintOne( p, ppClass[0] );
321 }
322 Abc_Print( 1, "\n" );
323}
int Aig_SupportSize(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition aigDfs.c:772
void Dch_ClassesPrintOne(Dch_Cla_t *p, Aig_Obj_t *pRepr)
Definition dchClass.c:282
Here is the call graph for this function:

◆ Dch_ClassesPrintOne()

void Dch_ClassesPrintOne ( Dch_Cla_t * p,
Aig_Obj_t * pRepr )

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file dchClass.c.

283{
284 Aig_Obj_t * pObj;
285 int i;
286 Abc_Print( 1, "{ " );
287 Dch_ClassForEachNode( p, pRepr, pObj, i )
288 Abc_Print( 1, "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
289 Abc_Print( 1, "}\n" );
290}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dch_ClassesReadClass()

Aig_Obj_t ** Dch_ClassesReadClass ( Dch_Cla_t * p,
Aig_Obj_t * pRepr,
int * pnSize )

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 222 of file dchClass.c.

223{
224 assert( p->pId2Class[pRepr->Id] != NULL );
225 assert( p->pClassSizes[pRepr->Id] > 1 );
226 *pnSize = p->pClassSizes[pRepr->Id];
227 return p->pId2Class[pRepr->Id];
228}
Here is the caller graph for this function:

◆ Dch_ClassesRefine()

int Dch_ClassesRefine ( Dch_Cla_t * p)

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

Synopsis [Refines the classes after simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 504 of file dchClass.c.

505{
506 Aig_Obj_t ** ppClass;
507 int i, nRefis = 0;
508 Dch_ManForEachClass( p, ppClass, i )
509 nRefis += Dch_ClassesRefineOneClass( p, ppClass[0], 0 );
510 return nRefis;
511}
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition dchClass.c:443
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dch_ClassesRefineConst1Group()

int Dch_ClassesRefineConst1Group ( Dch_Cla_t * p,
Vec_Ptr_t * vRoots,
int fRecursive )

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

Synopsis [Refine the group of constant 1 nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 570 of file dchClass.c.

571{
572 Aig_Obj_t * pObj, * pReprNew, ** ppClassNew;
573 int i;
574 if ( Vec_PtrSize(vRoots) == 0 )
575 return 0;
576 // collect the nodes to be refined
577 Vec_PtrClear( p->vClassNew );
578 Vec_PtrForEachEntry( Aig_Obj_t *, vRoots, pObj, i )
579 if ( !p->pFuncNodeIsConst( p->pManData, pObj ) )
580 Vec_PtrPush( p->vClassNew, pObj );
581 // check if there is a new class
582 if ( Vec_PtrSize(p->vClassNew) == 0 )
583 return 0;
584 p->nCands1 -= Vec_PtrSize(p->vClassNew);
585 pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
586 Aig_ObjSetRepr( p->pAig, pReprNew, NULL );
587 if ( Vec_PtrSize(p->vClassNew) == 1 )
588 return 1;
589 // create a new class composed of these nodes
590 ppClassNew = p->pMemClassesFree;
591 p->pMemClassesFree += Vec_PtrSize(p->vClassNew);
592 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
593 {
594 ppClassNew[i] = pObj;
595 Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
596 }
597 Dch_ObjAddClass( p, pReprNew, ppClassNew, Vec_PtrSize(p->vClassNew) );
598 // refine them recursively
599 if ( fRecursive )
600 return 1 + Dch_ClassesRefineOneClass( p, pReprNew, 1 );
601 return 1;
602}
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dch_ClassesRefineOneClass()

int Dch_ClassesRefineOneClass ( Dch_Cla_t * p,
Aig_Obj_t * pReprOld,
int fRecursive )

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

Synopsis [Iteratively refines the classes after simulation.]

Description [Returns the number of refinements performed.]

SideEffects []

SeeAlso []

Definition at line 443 of file dchClass.c.

444{
445 Aig_Obj_t ** pClassOld, ** pClassNew;
446 Aig_Obj_t * pObj, * pReprNew;
447 int i;
448
449 // split the class
450 Vec_PtrClear( p->vClassOld );
451 Vec_PtrClear( p->vClassNew );
452 Dch_ClassForEachNode( p, pReprOld, pObj, i )
453 if ( p->pFuncNodesAreEqual(p->pManData, pReprOld, pObj) )
454 Vec_PtrPush( p->vClassOld, pObj );
455 else
456 Vec_PtrPush( p->vClassNew, pObj );
457 // check if splitting happened
458 if ( Vec_PtrSize(p->vClassNew) == 0 )
459 return 0;
460
461 // get the new representative
462 pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
463 assert( Vec_PtrSize(p->vClassOld) > 0 );
464 assert( Vec_PtrSize(p->vClassNew) > 0 );
465
466 // create old class
467 pClassOld = Dch_ObjRemoveClass( p, pReprOld );
468 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
469 {
470 pClassOld[i] = pObj;
471 Aig_ObjSetRepr( p->pAig, pObj, i? pReprOld : NULL );
472 }
473 // create new class
474 pClassNew = pClassOld + i;
475 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
476 {
477 pClassNew[i] = pObj;
478 Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
479 }
480
481 // put classes back
482 if ( Vec_PtrSize(p->vClassOld) > 1 )
483 Dch_ObjAddClass( p, pReprOld, pClassOld, Vec_PtrSize(p->vClassOld) );
484 if ( Vec_PtrSize(p->vClassNew) > 1 )
485 Dch_ObjAddClass( p, pReprNew, pClassNew, Vec_PtrSize(p->vClassNew) );
486
487 // check if the class should be recursively refined
488 if ( fRecursive && Vec_PtrSize(p->vClassNew) > 1 )
489 return 1 + Dch_ClassesRefineOneClass( p, pReprNew, 1 );
490 return 1;
491}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dch_ClassesSetData()

void Dch_ClassesSetData ( Dch_Cla_t * p,
void * pManData,
unsigned(* pFuncNodeHash )(void *, Aig_Obj_t *),
int(* pFuncNodeIsConst )(void *, Aig_Obj_t *),
int(* pFuncNodesAreEqual )(void *, Aig_Obj_t *, Aig_Obj_t *) )

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file dchClass.c.

167{
168 p->pManData = pManData;
169 p->pFuncNodeHash = pFuncNodeHash;
170 p->pFuncNodeIsConst = pFuncNodeIsConst;
171 p->pFuncNodesAreEqual = pFuncNodesAreEqual;
172}
Here is the caller graph for this function:

◆ Dch_ClassesStart()

Dch_Cla_t * Dch_ClassesStart ( Aig_Man_t * pAig)

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 137 of file dchClass.c.

138{
139 Dch_Cla_t * p;
140 p = ABC_ALLOC( Dch_Cla_t, 1 );
141 memset( p, 0, sizeof(Dch_Cla_t) );
142 p->pAig = pAig;
143 p->pId2Class = ABC_CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) );
144 p->pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) );
145 p->vClassOld = Vec_PtrAlloc( 100 );
146 p->vClassNew = Vec_PtrAlloc( 100 );
147 assert( pAig->pReprs == NULL );
148 Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
149 return p;
150}
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition aigRepr.c:45
typedefABC_NAMESPACE_HEADER_START struct Dch_Cla_t_ Dch_Cla_t
INCLUDES ///.
Definition dchInt.h:47
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dch_ClassesStop()

void Dch_ClassesStop ( Dch_Cla_t * p)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file dchClass.c.

186{
187 if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
188 if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
189 ABC_FREE( p->pId2Class );
190 ABC_FREE( p->pClassSizes );
191 ABC_FREE( p->pMemClasses );
192 ABC_FREE( p );
193}
Here is the caller graph for this function: