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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Abc_NodeStrashToGia_rec (Gia_Man_t *pNew, Hop_Obj_t *pObj)
 DECLARATIONS ///.
 
int Abc_NodeStrashToGia (Gia_Man_t *pNew, Abc_Obj_t *pNode)
 
void Abc_NtkFlattenHierarchyGia2_rec (Gia_Man_t *pNew, Abc_Ntk_t *pNtk, int *pCounter, Vec_Int_t *vBufs)
 
Gia_Man_tAbc_NtkFlattenHierarchyGia2 (Abc_Ntk_t *pNtk)
 
void Gia_ManPrintBarBufDrivers (Gia_Man_t *p)
 
Gia_Man_tGia_ManSweepHierarchy (Gia_Man_t *p)
 
int Gia_ManFlattenLogicPrepare (Abc_Ntk_t *pNtk)
 
int Abc_NtkFlattenHierarchyGia_rec (Gia_Man_t *pNew, Vec_Ptr_t *vSupers, Abc_Obj_t *pObj, Vec_Ptr_t *vBuffers)
 
Gia_Man_tAbc_NtkFlattenHierarchyGia (Abc_Ntk_t *pNtk, Vec_Ptr_t **pvBuffers, int fVerbose)
 
Abc_Obj_tGia_ManInsertOne_rec (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew, Abc_Obj_t *pObj)
 
void Gia_ManInsertOne (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew)
 
void Abc_NtkInsertHierarchyGia (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew, int fVerbose)
 

Function Documentation

◆ Abc_NodeStrashToGia()

int Abc_NodeStrashToGia ( Gia_Man_t * pNew,
Abc_Obj_t * pNode )

Definition at line 56 of file abcHieGia.c.

57{
58 Hop_Man_t * pMan = (Hop_Man_t *)pNode->pNtk->pManFunc;
59 Hop_Obj_t * pRoot = (Hop_Obj_t *)pNode->pData;
60 Abc_Obj_t * pFanin; int i;
61 assert( Abc_ObjIsNode(pNode) );
62 assert( Abc_NtkHasAig(pNode->pNtk) && !Abc_NtkIsStrash(pNode->pNtk) );
63 // check the constant case
64 if ( Abc_NodeIsConst(pNode) || Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
65 return Abc_LitNotCond( 1, Hop_IsComplement(pRoot) );
66 // set elementary variables
67 Abc_ObjForEachFanin( pNode, pFanin, i )
68 assert( pFanin->iTemp != -1 );
69 Abc_ObjForEachFanin( pNode, pFanin, i )
70 Hop_IthVar(pMan, i)->iData = pFanin->iTemp;
71 // strash the AIG of this node
72 Abc_NodeStrashToGia_rec( pNew, Hop_Regular(pRoot) );
73 Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
74 return Abc_LitNotCond( Hop_Regular(pRoot)->iData, Hop_IsComplement(pRoot) );
75}
ABC_NAMESPACE_IMPL_START void Abc_NodeStrashToGia_rec(Gia_Man_t *pNew, Hop_Obj_t *pObj)
DECLARATIONS ///.
Definition abcHieGia.c:45
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition abcObj.c:867
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition hopDfs.c:257
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition hopOper.c:63
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
Abc_Ntk_t * pNtk
Definition abc.h:130
int iTemp
Definition abc.h:149
int iData
Definition hop.h:69
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeStrashToGia_rec()

ABC_NAMESPACE_IMPL_START void Abc_NodeStrashToGia_rec ( Gia_Man_t * pNew,
Hop_Obj_t * pObj )

DECLARATIONS ///.

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

FileName [abcHieGia.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures to handle hierarchy.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Transfers the AIG from one manager into another.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcHieGia.c.

46{
47 assert( !Hop_IsComplement(pObj) );
48 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
49 return;
50 Abc_NodeStrashToGia_rec( pNew, Hop_ObjFanin0(pObj) );
51 Abc_NodeStrashToGia_rec( pNew, Hop_ObjFanin1(pObj) );
52 pObj->iData = Gia_ManHashAnd( pNew, Hop_ObjChild0CopyI(pObj), Hop_ObjChild1CopyI(pObj) );
53 assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
54 Hop_ObjSetMarkA( pObj );
55}
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkFlattenHierarchyGia()

Gia_Man_t * Abc_NtkFlattenHierarchyGia ( Abc_Ntk_t * pNtk,
Vec_Ptr_t ** pvBuffers,
int fVerbose )

Definition at line 418 of file abcHieGia.c.

419{
420 int fUseBufs = 1;
421 Gia_Man_t * pNew, * pTemp;
422 Abc_Ntk_t * pModel;
423 Abc_Obj_t * pTerm;
424 Vec_Ptr_t * vSupers;
425 Vec_Ptr_t * vBuffers = fUseBufs ? Vec_PtrAlloc(1000) : NULL;
426 int i, Counter = 0;
427 assert( Abc_NtkIsNetlist(pNtk) );
428// Abc_NtkPrintBoxInfo( pNtk );
429
430 // set the PI/PO numbers
431 Counter -= Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk);
432 if ( !pNtk->pDesign )
433 Counter += Gia_ManFlattenLogicPrepare( pNtk );
434 else
435 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
436 Counter += Gia_ManFlattenLogicPrepare( pModel );
437
438 // start the manager
439 pNew = Gia_ManStart( Abc_NtkObjNumMax(pNtk) );
440 pNew->pName = Abc_UtilStrsav(pNtk->pName);
441 pNew->pSpec = Abc_UtilStrsav(pNtk->pSpec);
442
443 // create PIs and buffers
444 Abc_NtkForEachPi( pNtk, pTerm, i )
445 pTerm->iTemp = Gia_ManAppendCi( pNew );
446
447 // call recursively
448 vSupers = Vec_PtrAlloc( 100 );
449 Gia_ManHashAlloc( pNew );
450 Abc_NtkForEachPo( pNtk, pTerm, i )
451 Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pTerm, vBuffers );
452 Gia_ManHashStop( pNew );
453 Vec_PtrFree( vSupers );
454 printf( "Hierarchy reader flattened %d instances of boxes and added %d barbufs (out of %d).\n",
455 pNtk->pDesign ? Vec_PtrSize(pNtk->pDesign->vModules)-1 : 0, Vec_PtrSize(vBuffers), Counter );
456
457 // create buffers and POs
458 Abc_NtkForEachPo( pNtk, pTerm, i )
459 Gia_ManAppendCo( pNew, pTerm->iTemp );
460
461 if ( pvBuffers )
462 *pvBuffers = vBuffers;
463 else
464 Vec_PtrFreeP( &vBuffers );
465
466 // cleanup
467 pNew = Gia_ManCleanup( pTemp = pNew );
468 Gia_ManStop( pTemp );
469// Gia_ManPrintStats( pNew, NULL );
470 pNew = Gia_ManSweepHierarchy( pTemp = pNew );
471 Gia_ManStop( pTemp );
472// Gia_ManPrintStats( pNew, NULL );
473 return pNew;
474}
Gia_Man_t * Gia_ManSweepHierarchy(Gia_Man_t *p)
Definition abcHieGia.c:292
int Abc_NtkFlattenHierarchyGia_rec(Gia_Man_t *pNew, Vec_Ptr_t *vSupers, Abc_Obj_t *pObj, Vec_Ptr_t *vBuffers)
Definition abcHieGia.c:374
int Gia_ManFlattenLogicPrepare(Abc_Ntk_t *pNtk)
Definition abcHieGia.c:355
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
Vec_Ptr_t * vModules
Definition abc.h:225
char * pName
Definition abc.h:158
Abc_Des_t * pDesign
Definition abc.h:180
char * pSpec
Definition abc.h:159
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#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:

◆ Abc_NtkFlattenHierarchyGia2()

Gia_Man_t * Abc_NtkFlattenHierarchyGia2 ( Abc_Ntk_t * pNtk)

Definition at line 134 of file abcHieGia.c.

135{
136 int fUseBufs = 1;
137 int fUseInter = 0;
138 Gia_Man_t * pNew, * pTemp;
139 Abc_Ntk_t * pModel;
140 Abc_Obj_t * pTerm;
141 int i, Counter = -1;
142 assert( Abc_NtkIsNetlist(pNtk) );
143// Abc_NtkPrintBoxInfo( pNtk );
144 Abc_NtkFillTemp( pNtk );
145
146 // start the manager
147 pNew = Gia_ManStart( Abc_NtkObjNumMax(pNtk) );
148 pNew->pName = Abc_UtilStrsav(pNtk->pName);
149 pNew->pSpec = Abc_UtilStrsav(pNtk->pSpec);
150 if ( fUseBufs )
151 pNew->vBarBufs = Vec_IntAlloc( 1000 );
152
153 // create PIs and buffers
154 Abc_NtkForEachPi( pNtk, pTerm, i )
155 pTerm->iTemp = Gia_ManAppendCi( pNew );
156 Abc_NtkForEachPi( pNtk, pTerm, i )
157 Abc_ObjFanout0(pTerm)->iTemp = fUseInter ? Gia_ManAppendBuf(pNew, pTerm->iTemp) : pTerm->iTemp;
158
159 // create DFS order of nets
160 if ( !pNtk->pDesign )
161 pNtk->pData = Abc_NtkDfsWithBoxes( pNtk );
162 else
163 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
164 pModel->pData = Abc_NtkDfsWithBoxes( pModel );
165
166 // call recursively
167 Gia_ManHashAlloc( pNew );
168 Abc_NtkFlattenHierarchyGia2_rec( pNew, pNtk, &Counter, pNew->vBarBufs );
169 Gia_ManHashStop( pNew );
170 printf( "Hierarchy reader flattened %d instances of logic boxes.\n", Counter );
171
172 // delete DFS order of nets
173 if ( !pNtk->pDesign )
174 Vec_PtrFreeP( (Vec_Ptr_t **)&pNtk->pData );
175 else
176 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
177 Vec_PtrFreeP( (Vec_Ptr_t **)&pModel->pData );
178
179 // create buffers and POs
180 Abc_NtkForEachPo( pNtk, pTerm, i )
181 pTerm->iTemp = fUseInter ? Gia_ManAppendBuf(pNew, Abc_ObjFanin0(pTerm)->iTemp) : Abc_ObjFanin0(pTerm)->iTemp;
182 Abc_NtkForEachPo( pNtk, pTerm, i )
183 Gia_ManAppendCo( pNew, pTerm->iTemp );
184
185 // save buffers
186 if ( fUseInter )
187 {
188 Vec_IntPush( pNew->vBarBufs, 0 );
189 Vec_IntPush( pNew->vBarBufs, Abc_NtkPiNum(pNtk) );
190 Vec_IntPush( pNew->vBarBufs, Gia_ManBufNum(pNew) - Abc_NtkPoNum(pNtk) );
191 Vec_IntPush( pNew->vBarBufs, Abc_NtkPoNum(pNtk) );
192 }
193 if ( fUseBufs )
194 Vec_IntPrint( pNew->vBarBufs );
195
196 // cleanup
197 pNew = Gia_ManCleanup( pTemp = pNew );
198 Gia_ManStop( pTemp );
199 return pNew;
200}
void Abc_NtkFlattenHierarchyGia2_rec(Gia_Man_t *pNew, Abc_Ntk_t *pNtk, int *pCounter, Vec_Int_t *vBufs)
Definition abcHieGia.c:89
ABC_DLL Vec_Ptr_t * Abc_NtkDfsWithBoxes(Abc_Ntk_t *pNtk)
Definition abcDfs.c:799
ABC_DLL void Abc_NtkFillTemp(Abc_Ntk_t *pNtk)
Definition abcUtil.c:586
void * pData
Definition abc.h:203
Vec_Int_t * vBarBufs
Definition gia.h:163
Here is the call graph for this function:

◆ Abc_NtkFlattenHierarchyGia2_rec()

void Abc_NtkFlattenHierarchyGia2_rec ( Gia_Man_t * pNew,
Abc_Ntk_t * pNtk,
int * pCounter,
Vec_Int_t * vBufs )

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file abcHieGia.c.

90{
91 Vec_Ptr_t * vDfs = (Vec_Ptr_t *)pNtk->pData;
92 Abc_Obj_t * pObj, * pTerm;
93 int i, k; (*pCounter)++;
94 //printf( "[%d:%d] ", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
95 Vec_PtrForEachEntry( Abc_Obj_t *, vDfs, pObj, i )
96 {
97 if ( Abc_ObjIsNode(pObj) )
98 Abc_ObjFanout0(pObj)->iTemp = Abc_NodeStrashToGia( pNew, pObj );
99 else
100 {
101 int iBufStart = Gia_ManBufNum(pNew);
102 Abc_Ntk_t * pModel = (Abc_Ntk_t *)pObj->pData;
103 assert( !Abc_ObjIsLatch(pObj) );
104 assert( Abc_NtkPiNum(pModel) == Abc_ObjFaninNum(pObj) );
105 assert( Abc_NtkPoNum(pModel) == Abc_ObjFanoutNum(pObj) );
106 Abc_NtkFillTemp( pModel );
107 Abc_ObjForEachFanin( pObj, pTerm, k )
108 {
109 assert( Abc_ObjIsNet(Abc_ObjFanin0(pTerm)) );
110 Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp = Abc_ObjFanin0(pTerm)->iTemp;
111 }
112 if ( vBufs )
113 Abc_ObjForEachFanin( pObj, pTerm, k )
114 Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp );
115 Abc_NtkFlattenHierarchyGia2_rec( pNew, pModel, pCounter, vBufs );
116 if ( vBufs )
117 Abc_ObjForEachFanout( pObj, pTerm, k )
118 Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp );
119 Abc_ObjForEachFanout( pObj, pTerm, k )
120 {
121 assert( Abc_ObjIsNet(Abc_ObjFanout0(pTerm)) );
122 Abc_ObjFanout0(pTerm)->iTemp = Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp;
123 }
124 // save buffers
125 if ( vBufs == NULL )
126 continue;
127 Vec_IntPush( vBufs, iBufStart );
128 Vec_IntPush( vBufs, Abc_NtkPiNum(pModel) );
129 Vec_IntPush( vBufs, Gia_ManBufNum(pNew) - Abc_NtkPoNum(pModel) );
130 Vec_IntPush( vBufs, Abc_NtkPoNum(pModel) );
131 }
132 }
133}
int Abc_NodeStrashToGia(Gia_Man_t *pNew, Abc_Obj_t *pNode)
Definition abcHieGia.c:56
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkFlattenHierarchyGia_rec()

int Abc_NtkFlattenHierarchyGia_rec ( Gia_Man_t * pNew,
Vec_Ptr_t * vSupers,
Abc_Obj_t * pObj,
Vec_Ptr_t * vBuffers )

Definition at line 374 of file abcHieGia.c.

375{
376 Abc_Ntk_t * pModel;
377 Abc_Obj_t * pBox, * pFanin;
378 int iLit, i;
379 if ( pObj->iTemp != -1 )
380 return pObj->iTemp;
381 if ( Abc_ObjIsNet(pObj) || Abc_ObjIsPo(pObj) || Abc_ObjIsBi(pObj) )
382 return (pObj->iTemp = Abc_NtkFlattenHierarchyGia_rec(pNew, vSupers, Abc_ObjFanin0(pObj), vBuffers));
383 if ( Abc_ObjIsPi(pObj) )
384 {
385 pBox = (Abc_Obj_t *)Vec_PtrPop( vSupers );
386 pModel = Abc_ObjModel(pBox);
387 //printf( " Exiting %s\n", Abc_NtkName(pModel) );
388 assert( Abc_ObjFaninNum(pBox) == Abc_NtkPiNum(pModel) );
389 assert( pObj->iData >= 0 && pObj->iData < Abc_NtkPiNum(pModel) );
390 pFanin = Abc_ObjFanin( pBox, pObj->iData );
391 iLit = Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pFanin, vBuffers );
392 Vec_PtrPush( vSupers, pBox );
393 //if ( vBuffers ) Vec_PtrPush( vBuffers, pFanin ); // save BI
394 if ( vBuffers ) Vec_PtrPush( vBuffers, pObj ); // save PI
395 return (pObj->iTemp = (vBuffers ? Gia_ManAppendBuf(pNew, iLit) : iLit));
396 }
397 if ( Abc_ObjIsBo(pObj) )
398 {
399 pBox = Abc_ObjFanin0(pObj);
400 assert( Abc_ObjIsBox(pBox) );
401 Vec_PtrPush( vSupers, pBox );
402 pModel = Abc_ObjModel(pBox);
403 //printf( "Entering %s\n", Abc_NtkName(pModel) );
404 assert( Abc_ObjFanoutNum(pBox) == Abc_NtkPoNum(pModel) );
405 assert( pObj->iData >= 0 && pObj->iData < Abc_NtkPoNum(pModel) );
406 pFanin = Abc_NtkPo( pModel, pObj->iData );
407 iLit = Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pFanin, vBuffers );
408 Vec_PtrPop( vSupers );
409 //if ( vBuffers ) Vec_PtrPush( vBuffers, pObj ); // save BO
410 if ( vBuffers ) Vec_PtrPush( vBuffers, pFanin ); // save PO
411 return (pObj->iTemp = (vBuffers ? Gia_ManAppendBuf(pNew, iLit) : iLit));
412 }
413 assert( Abc_ObjIsNode(pObj) );
414 Abc_ObjForEachFanin( pObj, pFanin, i )
415 Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pFanin, vBuffers );
416 return (pObj->iTemp = Abc_NodeStrashToGia( pNew, pObj ));
417}
int iData
Definition abc.h:146
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkInsertHierarchyGia()

void Abc_NtkInsertHierarchyGia ( Abc_Ntk_t * pNtk,
Abc_Ntk_t * pNew,
int fVerbose )

Definition at line 535 of file abcHieGia.c.

536{
537 Vec_Ptr_t * vBuffers;
538 Gia_Man_t * pGia = Abc_NtkFlattenHierarchyGia( pNtk, &vBuffers, 0 );
539 Abc_Ntk_t * pModel;
540 Abc_Obj_t * pObj;
541 int i, k = 0;
542
543 assert( Gia_ManPiNum(pGia) == Abc_NtkPiNum(pNtk) );
544 assert( Gia_ManPiNum(pGia) == Abc_NtkPiNum(pNew) );
545 assert( Gia_ManPoNum(pGia) == Abc_NtkPoNum(pNtk) );
546 assert( Gia_ManPoNum(pGia) == Abc_NtkPoNum(pNew) );
547 assert( Gia_ManBufNum(pGia) == Vec_PtrSize(vBuffers) );
548 assert( Gia_ManBufNum(pGia) == pNew->nBarBufs2 );
549 Gia_ManStop( pGia );
550
551 // clean the networks
552 if ( !pNtk->pDesign )
553 Abc_NtkCleanCopy( pNtk );
554 else
555 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
556 Abc_NtkCleanCopy( pModel );
557
558 // annotate PIs and POs of each network with barbufs
559 Abc_NtkForEachPi( pNew, pObj, i )
560 Abc_NtkPi(pNtk, i)->pCopy = pObj;
561 Abc_NtkForEachPo( pNew, pObj, i )
562 Abc_NtkPo(pNtk, i)->pCopy = pObj;
563 Abc_NtkForEachBarBuf( pNew, pObj, i )
564 ((Abc_Obj_t *)Vec_PtrEntry(vBuffers, k++))->pCopy = pObj;
565 Vec_PtrFree( vBuffers );
566
567 // connect each model
568 Abc_NtkCleanCopy( pNew );
569 Gia_ManInsertOne( pNtk, pNew );
570 if ( pNtk->pDesign )
571 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
572 if ( pModel != pNtk )
573 Gia_ManInsertOne( pModel, pNew );
574}
Gia_Man_t * Abc_NtkFlattenHierarchyGia(Abc_Ntk_t *pNtk, Vec_Ptr_t **pvBuffers, int fVerbose)
Definition abcHieGia.c:418
void Gia_ManInsertOne(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew)
Definition abcHieGia.c:503
#define Abc_NtkForEachBarBuf(pNtk, pNode, i)
Definition abc.h:482
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
int nBarBufs2
Definition abc.h:175
Abc_Obj_t * pCopy
Definition abc.h:148
Here is the call graph for this function:

◆ Gia_ManFlattenLogicPrepare()

int Gia_ManFlattenLogicPrepare ( Abc_Ntk_t * pNtk)

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

Synopsis [Flattens the logic hierarchy of the netlist.]

Description [This procedure requires that models are uniqified.]

SideEffects []

SeeAlso []

Definition at line 355 of file abcHieGia.c.

356{
357 Abc_Obj_t * pTerm, * pBox;
358 int i, k;
359 Abc_NtkFillTemp( pNtk );
360 Abc_NtkForEachPi( pNtk, pTerm, i )
361 pTerm->iData = i;
362 Abc_NtkForEachPo( pNtk, pTerm, i )
363 pTerm->iData = i;
364 Abc_NtkForEachBox( pNtk, pBox, i )
365 {
366 assert( !Abc_ObjIsLatch(pBox) );
367 Abc_ObjForEachFanin( pBox, pTerm, k )
368 pTerm->iData = k;
369 Abc_ObjForEachFanout( pBox, pTerm, k )
370 pTerm->iData = k;
371 }
372 return Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk);
373}
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition abc.h:498
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManInsertOne()

void Gia_ManInsertOne ( Abc_Ntk_t * pNtk,
Abc_Ntk_t * pNew )

Definition at line 503 of file abcHieGia.c.

504{
505 Abc_Obj_t * pObj, * pBox; int i, k;
506 assert( !Abc_NtkHasMapping(pNtk) );
507 assert( Abc_NtkHasMapping(pNew) );
508 // check that PIs point to barbufs
509 Abc_NtkForEachPi( pNtk, pObj, i )
510 assert( !pObj->pCopy || Abc_ObjNtk(pObj->pCopy) == pNew );
511 // make barbufs point to box outputs
512 Abc_NtkForEachBox( pNtk, pBox, i )
513 Abc_ObjForEachFanout( pBox, pObj, k )
514 {
515 pObj->pCopy = Abc_NtkPo(Abc_ObjModel(pBox), k)->pCopy;
516 assert( !pObj->pCopy || Abc_ObjNtk(pObj->pCopy) == pNew );
517 }
518 // remove internal nodes
519 Abc_NtkForEachNode( pNtk, pObj, i )
520 Abc_NtkDeleteObj( pObj );
521 // start traversal from box inputs
522 Abc_NtkForEachBox( pNtk, pBox, i )
523 Abc_ObjForEachFanin( pBox, pObj, k )
524 if ( Abc_ObjFaninNum(pObj) == 0 )
525 Abc_ObjAddFanin( pObj, Gia_ManInsertOne_rec(pNtk, pNew, Abc_NtkPi(Abc_ObjModel(pBox), k)->pCopy) );
526 // start traversal from primary outputs
527 Abc_NtkForEachPo( pNtk, pObj, i )
528 if ( Abc_ObjFaninNum(pObj) == 0 )
529 Abc_ObjAddFanin( pObj, Gia_ManInsertOne_rec(pNtk, pNew, pObj->pCopy) );
530 // update the functionality manager
531 pNtk->pManFunc = pNew->pManFunc;
532 pNtk->ntkFunc = pNew->ntkFunc;
533 assert( Abc_NtkHasMapping(pNtk) );
534}
Abc_Obj_t * Gia_ManInsertOne_rec(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew, Abc_Obj_t *pObj)
Definition abcHieGia.c:488
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
Abc_NtkFunc_t ntkFunc
Definition abc.h:157
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManInsertOne_rec()

Abc_Obj_t * Gia_ManInsertOne_rec ( Abc_Ntk_t * pNtk,
Abc_Ntk_t * pNew,
Abc_Obj_t * pObj )

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

Synopsis [Inserts the result of mapping into logic hierarchy.]

Description [When this procedure is called PIs/POs of pNtk point to the corresponding nodes in network with barbufs.]

SideEffects []

SeeAlso []

Definition at line 488 of file abcHieGia.c.

489{
490 Abc_Obj_t * pFanin; int i;
491 if ( pObj == NULL )
492 return Abc_NtkCreateNodeConst0( pNtk );
493 assert( Abc_ObjNtk(pObj) == pNew );
494 if ( pObj->pCopy )
495 return pObj->pCopy;
496 Abc_ObjForEachFanin( pObj, pFanin, i )
497 Gia_ManInsertOne_rec( pNtk, pNew, pFanin );
498 pObj->pCopy = Abc_NtkDupObj( pNtk, pObj, 0 );
499 Abc_ObjForEachFanin( pObj, pFanin, i )
500 Abc_ObjAddFanin( pObj, pFanin );
501 return pObj->pCopy;
502}
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition abcObj.c:342
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManPrintBarBufDrivers()

void Gia_ManPrintBarBufDrivers ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 213 of file abcHieGia.c.

214{
215 Vec_Int_t * vMap, * vFan, * vCrits;
216 Gia_Obj_t * pObj;
217 int i, iFanin, CountCrit[2] = {0}, CountFans[2] = {0};
218 // map barbuf drivers into barbuf literals of the first barbuf driven by them
219 vMap = Vec_IntStart( Gia_ManObjNum(p) );
220 vFan = Vec_IntStart( Gia_ManObjNum(p) );
221 vCrits = Vec_IntAlloc( 100 );
222 Gia_ManForEachObj( p, pObj, i )
223 {
224 // count fanouts
225 if ( Gia_ObjIsBuf(pObj) || Gia_ObjIsCo(pObj) )
226 Vec_IntAddToEntry( vFan, Gia_ObjFaninId0(pObj, i), 1 );
227 else if ( Gia_ObjIsAnd(pObj) )
228 {
229 Vec_IntAddToEntry( vFan, Gia_ObjFaninId0(pObj, i), 1 );
230 Vec_IntAddToEntry( vFan, Gia_ObjFaninId1(pObj, i), 1 );
231 }
232 // count critical barbufs
233 if ( Gia_ObjIsBuf(pObj) )
234 {
235 iFanin = Gia_ObjFaninId0( pObj, i );
236 if ( iFanin == 0 || Vec_IntEntry(vMap, iFanin) != 0 )
237 {
238 CountCrit[(int)(iFanin != 0)]++;
239 Vec_IntPush( vCrits, i );
240 continue;
241 }
242 Vec_IntWriteEntry( vMap, iFanin, Abc_Var2Lit(i, Gia_ObjFaninC0(pObj)) );
243 }
244 }
245 // check fanouts of the critical barbufs
246 Gia_ManForEachObjVec( vCrits, p, pObj, i )
247 {
248 assert( Gia_ObjIsBuf(pObj) );
249 if ( Vec_IntEntry(vFan, i) == 0 )
250 continue;
251 iFanin = Gia_ObjFaninId0p( p, pObj );
252 CountFans[(int)(iFanin != 0)]++;
253 }
254 printf( "Detected %d const (out of %d) and %d shared (out of %d) barbufs with fanout.\n",
255 CountFans[0], CountCrit[0], CountFans[1], CountCrit[1] );
256 Vec_IntFree( vMap );
257 Vec_IntFree( vFan );
258 Vec_IntFree( vCrits );
259}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190

◆ Gia_ManSweepHierarchy()

Gia_Man_t * Gia_ManSweepHierarchy ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 292 of file abcHieGia.c.

293{
294 Vec_Int_t * vMap = Vec_IntStart( Gia_ManObjNum(p) );
295 Gia_Man_t * pNew, * pTemp;
296 Gia_Obj_t * pObj, * pObjNew, * pObjNewR;
297 int i, iFanin, CountReals[2] = {0};
298
299 // duplicate AIG while propagating constants and equivalences
300 pNew = Gia_ManStart( Gia_ManObjNum(p) );
301 pNew->pName = Abc_UtilStrsav( p->pName );
302 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
303 Gia_ManConst0(p)->Value = 0;
304 Gia_ManHashAlloc( pNew );
305 Gia_ManForEachObj1( p, pObj, i )
306 {
307 if ( Gia_ObjIsBuf(pObj) )
308 {
309 pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
310 pObjNew = Gia_ManObj( pNew, Abc_Lit2Var(pObj->Value) );
311 iFanin = Gia_ObjFaninId0p( pNew, pObjNew );
312 if ( iFanin == 0 )
313 {
314 pObj->Value = Gia_ObjFaninC0(pObjNew);
315 CountReals[0]++;
316 Gia_ManPatchBufDriver( pNew, Gia_ObjId(pNew, pObjNew), 0 );
317 }
318 else if ( Vec_IntEntry(vMap, iFanin) )
319 {
320 pObjNewR = Gia_ManObj( pNew, Vec_IntEntry(vMap, iFanin) );
321 pObj->Value = Abc_Var2Lit( Vec_IntEntry(vMap, iFanin), Gia_ObjFaninC0(pObjNewR) ^ Gia_ObjFaninC0(pObjNew) );
322 CountReals[1]++;
323 Gia_ManPatchBufDriver( pNew, Gia_ObjId(pNew, pObjNew), 0 );
324 }
325 else
326 Vec_IntWriteEntry( vMap, iFanin, Gia_ObjId(pNew, pObjNew) );
327 }
328 else if ( Gia_ObjIsAnd(pObj) )
329 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
330 else if ( Gia_ObjIsCi(pObj) )
331 pObj->Value = Gia_ManAppendCi( pNew );
332 else if ( Gia_ObjIsCo(pObj) )
333 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
334 }
335 Gia_ManHashStop( pNew );
336 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
337 pNew = Gia_ManCleanup( pTemp = pNew );
338 Gia_ManStop( pTemp );
339// printf( "Updated %d const and %d shared.\n", CountReals[0], CountReals[1] );
340 Vec_IntFree( vMap );
341 return pNew;
342}
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function: