ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcNtk.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22#include "abcInt.h"
23#include "base/main/main.h"
24#include "map/mio/mio.h"
25#include "aig/gia/gia.h"
26
27#ifdef ABC_USE_CUDD
28#include "bdd/extrab/extraBdd.h"
29#endif
30
32
33
37
41
53Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan )
54{
55 Abc_Ntk_t * pNtk;
56 pNtk = ABC_ALLOC( Abc_Ntk_t, 1 );
57 memset( pNtk, 0, sizeof(Abc_Ntk_t) );
58 pNtk->ntkType = Type;
59 pNtk->ntkFunc = Func;
60 // start the object storage
61 pNtk->vObjs = Vec_PtrAlloc( 100 );
62 pNtk->vPios = Vec_PtrAlloc( 100 );
63 pNtk->vPis = Vec_PtrAlloc( 100 );
64 pNtk->vPos = Vec_PtrAlloc( 100 );
65 pNtk->vCis = Vec_PtrAlloc( 100 );
66 pNtk->vCos = Vec_PtrAlloc( 100 );
67 pNtk->vBoxes = Vec_PtrAlloc( 100 );
68 pNtk->vLtlProperties = Vec_PtrAlloc( 100 );
69 // start the memory managers
70 pNtk->pMmObj = fUseMemMan? Mem_FixedStart( sizeof(Abc_Obj_t) ) : NULL;
71 pNtk->pMmStep = fUseMemMan? Mem_StepStart( ABC_NUM_STEPS ) : NULL;
72 // get ready to assign the first Obj ID
73 pNtk->nTravIds = 1;
74 // start the functionality manager
75 if ( !Abc_NtkIsStrash(pNtk) )
76 Vec_PtrPush( pNtk->vObjs, NULL );
77 if ( Abc_NtkIsStrash(pNtk) )
78 pNtk->pManFunc = Abc_AigAlloc( pNtk );
79 else if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
80 pNtk->pManFunc = Mem_FlexStart();
81#ifdef ABC_USE_CUDD
82 else if ( Abc_NtkHasBdd(pNtk) )
83 pNtk->pManFunc = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
84#endif
85 else if ( Abc_NtkHasAig(pNtk) )
86 pNtk->pManFunc = Hop_ManStart();
87 else if ( Abc_NtkHasMapping(pNtk) )
89 else if ( !Abc_NtkHasBlackbox(pNtk) )
90 assert( 0 );
91 // name manager
92 pNtk->pManName = Nm_ManCreate( 200 );
93 // attribute manager
94 pNtk->vAttrs = Vec_PtrStart( VEC_ATTR_TOTAL_NUM );
95 // estimated AndGateDelay
96 pNtk->AndGateDelay = 0.0;
97 return pNtk;
98}
99Abc_Ntk_t * Abc_NtkAllocBdd( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan, int nVars )
100{
101 Abc_Ntk_t * pNtk;
102 pNtk = ABC_ALLOC( Abc_Ntk_t, 1 );
103 memset( pNtk, 0, sizeof(Abc_Ntk_t) );
104 pNtk->ntkType = Type;
105 pNtk->ntkFunc = Func;
106 // start the object storage
107 pNtk->vObjs = Vec_PtrAlloc( 100 );
108 pNtk->vPios = Vec_PtrAlloc( 100 );
109 pNtk->vPis = Vec_PtrAlloc( 100 );
110 pNtk->vPos = Vec_PtrAlloc( 100 );
111 pNtk->vCis = Vec_PtrAlloc( 100 );
112 pNtk->vCos = Vec_PtrAlloc( 100 );
113 pNtk->vBoxes = Vec_PtrAlloc( 100 );
114 pNtk->vLtlProperties = Vec_PtrAlloc( 100 );
115 // start the memory managers
116 pNtk->pMmObj = fUseMemMan? Mem_FixedStart( sizeof(Abc_Obj_t) ) : NULL;
117 pNtk->pMmStep = fUseMemMan? Mem_StepStart( ABC_NUM_STEPS ) : NULL;
118 // get ready to assign the first Obj ID
119 pNtk->nTravIds = 1;
120 // start the functionality manager
121 if ( !Abc_NtkIsStrash(pNtk) )
122 Vec_PtrPush( pNtk->vObjs, NULL );
123 if ( Abc_NtkIsStrash(pNtk) )
124 pNtk->pManFunc = Abc_AigAlloc( pNtk );
125 else if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
126 pNtk->pManFunc = Mem_FlexStart();
127#ifdef ABC_USE_CUDD
128 else if ( Abc_NtkHasBdd(pNtk) )
129 pNtk->pManFunc = Cudd_Init( nVars, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
130#endif
131 else if ( Abc_NtkHasAig(pNtk) )
132 pNtk->pManFunc = Hop_ManStart();
133 else if ( Abc_NtkHasMapping(pNtk) )
135 else if ( !Abc_NtkHasBlackbox(pNtk) )
136 assert( 0 );
137 // name manager
138 pNtk->pManName = Nm_ManCreate( 200 );
139 // attribute manager
140 pNtk->vAttrs = Vec_PtrStart( VEC_ATTR_TOTAL_NUM );
141 // estimated AndGateDelay
142 pNtk->AndGateDelay = 0.0;
143 return pNtk;
144}
145
158{
159 Abc_Ntk_t * pNtkNew;
160 Abc_Obj_t * pObj;
161 int fCopyNames, i;
162 if ( pNtk == NULL )
163 return NULL;
164 // decide whether to copy the names
165 fCopyNames = ( Type != ABC_NTK_NETLIST );
166 // start the network
167 pNtkNew = Func == ABC_FUNC_BDD ? Abc_NtkAllocBdd( Type, Func, 1, Abc_NtkCiNum(pNtk) ) : Abc_NtkAlloc( Type, Func, 1 );
168 pNtkNew->nConstrs = pNtk->nConstrs;
169 pNtkNew->nBarBufs = pNtk->nBarBufs;
170 // duplicate the name and the spec
171 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
172 pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
173 // clean the node copy fields
174 Abc_NtkCleanCopy( pNtk );
175 // map the constant nodes
176 if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
177 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
178 // clone CIs/CIs/boxes
179 Abc_NtkForEachPi( pNtk, pObj, i )
180 Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
181 Abc_NtkForEachPo( pNtk, pObj, i )
182 Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
183 Abc_NtkForEachBox( pNtk, pObj, i )
184 Abc_NtkDupBox( pNtkNew, pObj, fCopyNames );
185 // transfer logic level
186 Abc_NtkForEachCi( pNtk, pObj, i )
187 pObj->pCopy->Level = pObj->Level;
188 // transfer the names
189// Abc_NtkTrasferNames( pNtk, pNtkNew );
190 Abc_ManTimeDup( pNtk, pNtkNew );
191 if ( pNtk->vOnehots )
192 pNtkNew->vOnehots = (Vec_Ptr_t *)Vec_VecDupInt( (Vec_Vec_t *)pNtk->vOnehots );
193 if ( pNtk->pSeqModel )
194 pNtkNew->pSeqModel = Abc_CexDup( pNtk->pSeqModel, Abc_NtkLatchNum(pNtk) );
195 if ( pNtk->vObjPerm )
196 pNtkNew->vObjPerm = Vec_IntDup( pNtk->vObjPerm );
197 pNtkNew->AndGateDelay = pNtk->AndGateDelay;
198 if ( pNtkNew->pManTime && Abc_FrameReadLibGen() && pNtkNew->AndGateDelay == 0.0 )
200 // initialize logic level of the CIs
201 if ( pNtk->AndGateDelay != 0.0 && pNtk->pManTime != NULL && pNtk->ntkType != ABC_NTK_STRASH && Type == ABC_NTK_STRASH )
202 {
203 Abc_NtkForEachCi( pNtk, pObj, i )
204 pObj->pCopy->Level = (int)(Abc_MaxFloat(0, Abc_NodeReadArrivalWorst(pObj)) / pNtk->AndGateDelay);
205 }
206 // check that the CI/CO/latches are copied correctly
207 assert( Abc_NtkCiNum(pNtk) == Abc_NtkCiNum(pNtkNew) );
208 assert( Abc_NtkCoNum(pNtk) == Abc_NtkCoNum(pNtkNew) );
209 assert( Abc_NtkLatchNum(pNtk) == Abc_NtkLatchNum(pNtkNew) );
210 return pNtkNew;
211}
212
225{
226 Abc_Ntk_t * pNtkNew;
227 Abc_Obj_t * pObj, * pNode0, * pNode1;
228 int fCopyNames, i;
229 if ( pNtk == NULL )
230 return NULL;
231 assert( Abc_NtkLatchNum(pNtk) == 0 );
232 // decide whether to copy the names
233 fCopyNames = ( Type != ABC_NTK_NETLIST );
234 // start the network
235 pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
236 pNtkNew->nConstrs = pNtk->nConstrs;
237 pNtkNew->nBarBufs = pNtk->nBarBufs;
238 // duplicate the name and the spec
239 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
240 pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
241 // clean the node copy fields
242 Abc_NtkCleanCopy( pNtk );
243 // map the constant nodes
244 if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
245 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
246 // clone CIs/CIs/boxes
247 for ( i = 0; i < Abc_NtkPiNum(pNtk)-nLatches; i++ )
248 Abc_NtkDupObj( pNtkNew, Abc_NtkPi(pNtk, i), fCopyNames );
249 for ( i = 0; i < Abc_NtkPoNum(pNtk)-nLatches; i++ )
250 Abc_NtkDupObj( pNtkNew, Abc_NtkPo(pNtk, i), fCopyNames );
251 for ( i = 0; i < nLatches; i++ )
252 {
253 pObj = Abc_NtkCreateLatch(pNtkNew);
254 Abc_LatchSetInit0( pObj );
255 pNode0 = Abc_NtkCreateBi(pNtkNew);
256 Abc_NtkPo(pNtk, Abc_NtkPoNum(pNtk)-nLatches+i)->pCopy = pNode0;
257 pNode1 = Abc_NtkCreateBo(pNtkNew);
258 Abc_NtkPi(pNtk, Abc_NtkPiNum(pNtk)-nLatches+i)->pCopy = pNode1;
259 Abc_ObjAddFanin( pObj, pNode0 );
260 Abc_ObjAddFanin( pNode1, pObj );
261 Abc_ObjAssignName( pNode0, Abc_ObjName(pNode0), NULL );
262 Abc_ObjAssignName( pNode1, Abc_ObjName(pNode1), NULL );
263 }
264 // transfer logic level
265// Abc_NtkForEachCi( pNtk, pObj, i )
266// pObj->pCopy->Level = pObj->Level;
267 // transfer the names
268// Abc_NtkTrasferNames( pNtk, pNtkNew );
269 Abc_ManTimeDup( pNtk, pNtkNew );
270 if ( pNtk->vOnehots )
271 pNtkNew->vOnehots = (Vec_Ptr_t *)Vec_VecDupInt( (Vec_Vec_t *)pNtk->vOnehots );
272 if ( pNtk->pSeqModel )
273 pNtkNew->pSeqModel = Abc_CexDup( pNtk->pSeqModel, Abc_NtkLatchNum(pNtk) );
274 if ( pNtk->vObjPerm )
275 pNtkNew->vObjPerm = Vec_IntDup( pNtk->vObjPerm );
276 pNtkNew->AndGateDelay = pNtk->AndGateDelay;
277 // initialize logic level of the CIs
278 if ( pNtk->AndGateDelay != 0.0 && pNtk->pManTime != NULL && pNtk->ntkType != ABC_NTK_STRASH && Type == ABC_NTK_STRASH )
279 {
280 Abc_NtkForEachCi( pNtk, pObj, i )
281 pObj->pCopy->Level = (int)(Abc_MaxFloat(0, Abc_NodeReadArrivalWorst(pObj)) / pNtk->AndGateDelay);
282 }
283 // check that the CI/CO/latches are copied correctly
284 assert( Abc_NtkCiNum(pNtk) == Abc_NtkCiNum(pNtkNew) );
285 assert( Abc_NtkCoNum(pNtk) == Abc_NtkCoNum(pNtkNew) );
286 assert( nLatches == Abc_NtkLatchNum(pNtkNew) );
287 return pNtkNew;
288}
289
302{
303 Abc_Ntk_t * pNtkNew;
304 Abc_Obj_t * pObj;
305 int i;
306 if ( pNtk == NULL )
307 return NULL;
308 assert( Type != ABC_NTK_NETLIST );
309 // start the network
310 pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
311 pNtkNew->nConstrs = pNtk->nConstrs;
312 pNtkNew->nBarBufs = pNtk->nBarBufs;
313 // duplicate the name and the spec
314 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
315 pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
316 // clean the node copy fields
317 Abc_NtkCleanCopy( pNtk );
318 // map the constant nodes
319 if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
320 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
321 // clone CIs/CIs/boxes
322 Abc_NtkForEachPi( pNtk, pObj, i )
323 Abc_NtkDupObj( pNtkNew, pObj, 1 );
324 Abc_NtkForEachPo( pNtk, pObj, i )
325 Abc_NtkDupObj( pNtkNew, pObj, 1 );
326 Abc_NtkForEachBox( pNtk, pObj, i )
327 {
328 if ( Abc_ObjIsLatch(pObj) )
329 continue;
330 Abc_NtkDupBox(pNtkNew, pObj, 1);
331 }
332 if ( pNtk->vObjPerm )
333 pNtkNew->vObjPerm = Vec_IntDup( pNtk->vObjPerm );
334 pNtkNew->AndGateDelay = pNtk->AndGateDelay;
335 // transfer the names
336// Abc_NtkTrasferNamesNoLatches( pNtk, pNtkNew );
337 Abc_ManTimeDup( pNtk, pNtkNew );
338 // check that the CI/CO/latches are copied correctly
339 assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
340 assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
341 return pNtkNew;
342}
343
355void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
356{
357 Abc_Obj_t * pObj, * pDriver, * pDriverNew;
358 int i;
359 // set the COs of the strashed network
360 Abc_NtkForEachCo( pNtk, pObj, i )
361 {
362 pDriver = Abc_ObjFanin0Ntk( Abc_ObjFanin0(pObj) );
363 pDriverNew = Abc_ObjNotCond(pDriver->pCopy, Abc_ObjFaninC0(pObj));
364 Abc_ObjAddFanin( pObj->pCopy, pDriverNew );
365 }
366 // duplicate timing manager
367 if ( pNtk->pManTime )
368 Abc_NtkTimeInitialize( pNtkNew, pNtk );
369 if ( pNtk->vPhases )
370 Abc_NtkTransferPhases( pNtkNew, pNtk );
371 if ( pNtk->pWLoadUsed )
372 pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
373}
374
387{
388 Abc_Ntk_t * pNtkNew;
389 // allocate the empty network
391 // set the specs
392 pNtkNew->pName = Extra_FileNameGeneric(pName);
393 pNtkNew->pSpec = Extra_UtilStrsav(pName);
394 if ( pNtkNew->pName == NULL || strlen(pNtkNew->pName) == 0 )
395 {
396 ABC_FREE( pNtkNew->pName );
397 pNtkNew->pName = Extra_UtilStrsav("unknown");
398 }
399 return pNtkNew;
400}
401
414{
415 Abc_Obj_t * pBox, * pObj, * pTerm, * pNet;
416 int i;
417 if ( Abc_NtkHasBlackbox(pNtk) && Abc_NtkBoxNum(pNtk) == 0 )
418 {
419 pBox = Abc_NtkCreateBlackbox(pNtk);
420 Abc_NtkForEachPi( pNtk, pObj, i )
421 {
422 pTerm = Abc_NtkCreateBi(pNtk);
423 Abc_ObjAddFanin( pTerm, Abc_ObjFanout0(pObj) );
424 Abc_ObjAddFanin( pBox, pTerm );
425 }
426 Abc_NtkForEachPo( pNtk, pObj, i )
427 {
428 pTerm = Abc_NtkCreateBo(pNtk);
429 Abc_ObjAddFanin( pTerm, pBox );
430 Abc_ObjAddFanin( Abc_ObjFanin0(pObj), pTerm );
431 }
432 return;
433 }
434 assert( Abc_NtkIsNetlist(pNtk) );
435
436 // check if constant 0 net is used
437 pNet = Abc_NtkFindNet( pNtk, "1\'b0" );
438 if ( pNet )
439 {
440 if ( Abc_ObjFanoutNum(pNet) == 0 )
441 Abc_NtkDeleteObj(pNet);
442 else if ( Abc_ObjFaninNum(pNet) == 0 )
444 }
445 // check if constant 1 net is used
446 pNet = Abc_NtkFindNet( pNtk, "1\'b1" );
447 if ( pNet )
448 {
449 if ( Abc_ObjFanoutNum(pNet) == 0 )
450 Abc_NtkDeleteObj(pNet);
451 else if ( Abc_ObjFaninNum(pNet) == 0 )
453 }
454 // fix the net drivers
456
457 // reorder the CI/COs to PI/POs first
458 Abc_NtkOrderCisCos( pNtk );
459}
460
473{
474 Abc_Ntk_t * pNtkNew;
475 Abc_Obj_t * pObj, * pFanin;
476 int i, k;
477 if ( pNtk == NULL )
478 return NULL;
479 // start the network
480 pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
481 // copy the internal nodes
482 if ( Abc_NtkIsStrash(pNtk) )
483 {
484 // copy the AND gates
485 Abc_AigForEachAnd( pNtk, pObj, i )
486 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
487 // relink the choice nodes
488 Abc_AigForEachAnd( pNtk, pObj, i )
489 if ( pObj->pData )
490 pObj->pCopy->pData = ((Abc_Obj_t *)pObj->pData)->pCopy;
491 // relink the CO nodes
492 Abc_NtkForEachCo( pNtk, pObj, i )
493 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
494 // get the number of nodes before and after
495 if ( Abc_NtkNodeNum(pNtk) != Abc_NtkNodeNum(pNtkNew) )
496 printf( "Warning: Structural hashing during duplication reduced %d nodes (this is a minor bug).\n",
497 Abc_NtkNodeNum(pNtk) - Abc_NtkNodeNum(pNtkNew) );
498 }
499 else
500 {
501 // duplicate the nets and nodes (CIs/COs/latches already dupped)
502 Abc_NtkForEachObj( pNtk, pObj, i )
503 if ( pObj->pCopy == NULL )
504 Abc_NtkDupObj(pNtkNew, pObj, Abc_NtkHasBlackbox(pNtk) && Abc_ObjIsNet(pObj));
505 // reconnect all objects (no need to transfer attributes on edges)
506 Abc_NtkForEachObj( pNtk, pObj, i )
507 if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
508 Abc_ObjForEachFanin( pObj, pFanin, k )
509 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
510 // move object IDs
511 if ( pNtk->vOrigNodeIds )
512 {
513 pNtkNew->vOrigNodeIds = Vec_IntStartFull( Abc_NtkObjNumMax(pNtkNew) );
514 Abc_NtkForEachObj( pNtk, pObj, i )
515 if ( pObj->pCopy && Vec_IntEntry(pNtk->vOrigNodeIds, pObj->Id) > 0 )
516 Vec_IntWriteEntry( pNtkNew->vOrigNodeIds, pObj->pCopy->Id, Vec_IntEntry(pNtk->vOrigNodeIds, pObj->Id) );
517 }
518
519 }
520 // duplicate the EXDC Ntk
521 if ( pNtk->pExdc )
522 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
523 if ( pNtk->pExcare )
524 pNtkNew->pExcare = Abc_NtkDup( (Abc_Ntk_t *)pNtk->pExcare );
525 // duplicate timing manager
526 if ( pNtk->pManTime )
527 Abc_NtkTimeInitialize( pNtkNew, pNtk );
528 if ( pNtk->vPhases )
529 Abc_NtkTransferPhases( pNtkNew, pNtk );
530 if ( pNtk->pWLoadUsed )
531 pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
532 // check correctness
533 if ( !Abc_NtkCheck( pNtkNew ) )
534 fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
535 pNtk->pCopy = pNtkNew;
536 return pNtkNew;
537}
539{
540 Vec_Ptr_t * vNodes;
541 Abc_Ntk_t * pNtkNew;
542 Abc_Obj_t * pObj, * pFanin;
543 int i, k;
544 if ( pNtk == NULL )
545 return NULL;
546 assert( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsNetlist(pNtk) );
547 // start the network
548 pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
549 // copy the internal nodes
550 vNodes = Abc_NtkDfs( pNtk, 0 );
551 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
552 Abc_NtkDupObj( pNtkNew, pObj, 0 );
553 Vec_PtrFree( vNodes );
554 // reconnect all objects (no need to transfer attributes on edges)
555 Abc_NtkForEachObj( pNtk, pObj, i )
556 if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
557 Abc_ObjForEachFanin( pObj, pFanin, k )
558 if ( pObj->pCopy && pFanin->pCopy )
559 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
560 // duplicate the EXDC Ntk
561 if ( pNtk->pExdc )
562 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
563 if ( pNtk->pExcare )
564 pNtkNew->pExcare = Abc_NtkDup( (Abc_Ntk_t *)pNtk->pExcare );
565 // duplicate timing manager
566 if ( pNtk->pManTime )
567 Abc_NtkTimeInitialize( pNtkNew, pNtk );
568 if ( pNtk->vPhases )
569 Abc_NtkTransferPhases( pNtkNew, pNtk );
570 if ( pNtk->pWLoadUsed )
571 pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
572 // check correctness
573 if ( !Abc_NtkCheck( pNtkNew ) )
574 fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
575 pNtk->pCopy = pNtkNew;
576 return pNtkNew;
577}
579{
580 Vec_Ptr_t * vNodes;
581 Abc_Ntk_t * pNtkNew;
582 Abc_Obj_t * pObj, * pFanin;
583 int i, k;
584 if ( pNtk == NULL )
585 return NULL;
586 assert( Abc_NtkIsLogic(pNtk) );
587 assert( pNtk->nBarBufs2 > 0 );
588 // start the network
589 pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
590 // copy the internal nodes
591 vNodes = Abc_NtkDfs2( pNtk );
592 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
593 if ( Abc_ObjIsBarBuf(pObj) )
594 pObj->pCopy = Abc_ObjFanin0(pObj)->pCopy;
595 else
596 Abc_NtkDupObj( pNtkNew, pObj, 0 );
597 Vec_PtrFree( vNodes );
598 // reconnect all objects (no need to transfer attributes on edges)
599 Abc_NtkForEachObj( pNtk, pObj, i )
600 if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) && !Abc_ObjIsBarBuf(pObj) )
601 Abc_ObjForEachFanin( pObj, pFanin, k )
602 if ( pObj->pCopy && pFanin->pCopy )
603 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
604 // duplicate the EXDC Ntk
605 if ( pNtk->pExdc )
606 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
607 if ( pNtk->pExcare )
608 pNtkNew->pExcare = Abc_NtkDup( (Abc_Ntk_t *)pNtk->pExcare );
609 // duplicate timing manager
610 if ( pNtk->pManTime )
611 Abc_NtkTimeInitialize( pNtkNew, pNtk );
612 if ( pNtk->vPhases )
613 Abc_NtkTransferPhases( pNtkNew, pNtk );
614 if ( pNtk->pWLoadUsed )
615 pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
616 // check correctness
617 if ( !Abc_NtkCheck( pNtkNew ) )
618 fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
619 pNtk->pCopy = pNtkNew;
620 return pNtkNew;
621}
622
635{
636 Abc_Ntk_t * pNtkAig;
637 Abc_Obj_t * pObj;
638 int i;
639 assert( Abc_NtkIsStrash(pNtk) );
640 // start the new network (constants and CIs of the old network will point to the their counterparts in the new network)
641 pNtkAig = Abc_NtkStartFromWithLatches( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG, nLatches );
642 // restrash the nodes (assuming a topological order of the old network)
643 Abc_NtkForEachNode( pNtk, pObj, i )
644 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
645 // finalize the network
646 Abc_NtkFinalize( pNtk, pNtkAig );
647 // make sure everything is okay
648 if ( !Abc_NtkCheck( pNtkAig ) )
649 {
650 printf( "Abc_NtkStrash: The network check has failed.\n" );
651 Abc_NtkDelete( pNtkAig );
652 return NULL;
653 }
654 return pNtkAig;
655
656}
657
670{
671 Abc_Ntk_t * pNtkNew;
672 Abc_Obj_t * pObj, * pObj2, * pMiter;
673 int i;
674 assert( Abc_NtkIsStrash(pNtk) );
675 // start the network
676 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
677 pNtkNew->nConstrs = pNtk->nConstrs;
678 pNtkNew->nBarBufs = pNtk->nBarBufs;
679 // duplicate the name and the spec
680 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
681 pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
682 // clean the node copy fields
683 Abc_NtkCleanCopy( pNtk );
684 // map the constant nodes
685 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
686 // clone CIs/CIs/boxes
687 Abc_NtkForEachPi( pNtk, pObj, i )
688 Abc_NtkDupObj( pNtkNew, pObj, 1 );
689 Abc_NtkForEachPo( pNtk, pObj, i )
690 Abc_NtkDupObj( pNtkNew, pObj, 1 ), i++;
691 Abc_NtkForEachBox( pNtk, pObj, i )
692 Abc_NtkDupBox( pNtkNew, pObj, 1 );
693 // copy the AND gates
694 Abc_AigForEachAnd( pNtk, pObj, i )
695 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
696 // create new miters
697 Abc_NtkForEachPo( pNtk, pObj, i )
698 {
699 pObj2 = Abc_NtkPo( pNtk, ++i );
700 pMiter = Abc_AigXor( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Copy(pObj2) );
701 Abc_ObjAddFanin( pObj->pCopy, pMiter );
702 }
703 Abc_NtkForEachLatchInput( pNtk, pObj, i )
704 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
705 // cleanup
706 Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
707 // check that the CI/CO/latches are copied correctly
708 assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
709 assert( Abc_NtkPoNum(pNtk) == 2*Abc_NtkPoNum(pNtkNew) );
710 assert( Abc_NtkLatchNum(pNtk) == Abc_NtkLatchNum(pNtkNew) );
711 return pNtkNew;
712}
713
726{
727 char Buffer[500];
728 Abc_Ntk_t * pNtkNew;
729 Abc_Obj_t * pObj, * pFanin;
730 int i, k;
731 assert( Abc_NtkIsLogic(pNtk) );
732
733 // start the network
734 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
735 sprintf( Buffer, "%s%s", pNtk->pName, "_2x" );
736 pNtkNew->pName = Extra_UtilStrsav(Buffer);
737
738 // clean the node copy fields
739 Abc_NtkCleanCopy( pNtk );
740 // clone CIs/CIs/boxes
741 Abc_NtkForEachPi( pNtk, pObj, i )
742 Abc_NtkDupObj( pNtkNew, pObj, 0 );
743 Abc_NtkForEachPo( pNtk, pObj, i )
744 Abc_NtkDupObj( pNtkNew, pObj, 0 );
745 Abc_NtkForEachBox( pNtk, pObj, i )
746 Abc_NtkDupBox( pNtkNew, pObj, 0 );
747 // copy the internal nodes
748 // duplicate the nets and nodes (CIs/COs/latches already dupped)
749 Abc_NtkForEachObj( pNtk, pObj, i )
750 if ( pObj->pCopy == NULL )
751 Abc_NtkDupObj(pNtkNew, pObj, 0);
752 // reconnect all objects (no need to transfer attributes on edges)
753 Abc_NtkForEachObj( pNtk, pObj, i )
754 if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
755 Abc_ObjForEachFanin( pObj, pFanin, k )
756 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
757
758 // clean the node copy fields
759 Abc_NtkCleanCopy( pNtk );
760 // clone CIs/CIs/boxes
761 Abc_NtkForEachPi( pNtk, pObj, i )
762 Abc_NtkDupObj( pNtkNew, pObj, 0 );
763 Abc_NtkForEachPo( pNtk, pObj, i )
764 Abc_NtkDupObj( pNtkNew, pObj, 0 );
765 Abc_NtkForEachBox( pNtk, pObj, i )
766 Abc_NtkDupBox( pNtkNew, pObj, 0 );
767 // copy the internal nodes
768 // duplicate the nets and nodes (CIs/COs/latches already dupped)
769 Abc_NtkForEachObj( pNtk, pObj, i )
770 if ( pObj->pCopy == NULL )
771 Abc_NtkDupObj(pNtkNew, pObj, 0);
772 // reconnect all objects (no need to transfer attributes on edges)
773 Abc_NtkForEachObj( pNtk, pObj, i )
774 if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
775 Abc_ObjForEachFanin( pObj, pFanin, k )
776 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
777
778 // assign names
779 Abc_NtkForEachCi( pNtk, pObj, i )
780 {
781 Abc_ObjAssignName( Abc_NtkCi(pNtkNew, i), "1_", Abc_ObjName(pObj) );
782 Abc_ObjAssignName( Abc_NtkCi(pNtkNew, Abc_NtkCiNum(pNtk) + i), "2_", Abc_ObjName(pObj) );
783 }
784 Abc_NtkForEachCo( pNtk, pObj, i )
785 {
786 Abc_ObjAssignName( Abc_NtkCo(pNtkNew, i), "1_", Abc_ObjName(pObj) );
787 Abc_ObjAssignName( Abc_NtkCo(pNtkNew, Abc_NtkCoNum(pNtk) + i), "2_", Abc_ObjName(pObj) );
788 }
789 Abc_NtkOrderCisCos( pNtkNew );
790
791 // perform the final check
792 if ( !Abc_NtkCheck( pNtkNew ) )
793 fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
794 return pNtkNew;
795}
796
808Abc_Ntk_t * Abc_NtkBottom( Abc_Ntk_t * pNtk, int Level )
809{
810 char Buffer[500];
811 Abc_Ntk_t * pNtkNew;
812 Abc_Obj_t * pObj, * pFanin;
813 int i, k;
814 assert( Abc_NtkIsLogic(pNtk) );
815 assert( Abc_NtkLatchNum(pNtk) == 0 );
816
817 // start the network
818 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
819 sprintf( Buffer, "%s%s", pNtk->pName, "_bot" );
820 pNtkNew->pName = Extra_UtilStrsav(Buffer);
821
822 // clean the node copy fields
823 Abc_NtkCleanCopy( pNtk );
824 // clone CIs/CIs/boxes
825 Abc_NtkForEachPi( pNtk, pObj, i )
826 Abc_NtkDupObj( pNtkNew, pObj, 1 );
827
828 // copy the internal nodes
829 // duplicate the nets and nodes (CIs/COs/latches already dupped)
830 Abc_NtkForEachObj( pNtk, pObj, i )
831 if ( pObj->pCopy == NULL && Abc_ObjIsNode(pObj) && Abc_ObjLevel(pObj) <= Level )
832 Abc_NtkDupObj(pNtkNew, pObj, 0);
833 // reconnect all objects (no need to transfer attributes on edges)
834 Abc_NtkForEachObj( pNtk, pObj, i )
835 Abc_ObjForEachFanin( pObj, pFanin, k )
836 if ( pObj->pCopy && pFanin->pCopy )
837 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
838
839 // create new primary outputs
840 Abc_NtkForEachObj( pNtk, pObj, i )
841 Abc_ObjForEachFanin( pObj, pFanin, k )
842 if ( !pObj->pCopy && pFanin->pCopy && Abc_ObjIsNode(pFanin) )
843 {
844 Abc_Obj_t * pNodeNew = Abc_NtkCreatePo(pNtkNew);
845 Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
846 Abc_ObjAssignName( pNodeNew, Abc_ObjName(pNodeNew), NULL );
847 }
848
849 // perform the final check
850 if ( !Abc_NtkCheck( pNtkNew ) )
851 fprintf( stdout, "Abc_NtkBottom(): Network check has failed.\n" );
852 return pNtkNew;
853}
854
867{
868 Abc_Obj_t * pObj, * pFanin, * pBuffer;
869 Vec_Ptr_t * vNodes;
870 int i, k;
871 assert( pNtkBottom != NULL );
872 if ( pNtkTop == NULL )
873 return pNtkBottom;
874 // make sure the networks are combinational
875 assert( Abc_NtkPiNum(pNtkTop) == Abc_NtkCiNum(pNtkTop) );
876 assert( Abc_NtkPiNum(pNtkBottom) == Abc_NtkCiNum(pNtkBottom) );
877 // make sure the POs of the bottom correspond to the PIs of the top
878 assert( Abc_NtkPoNum(pNtkBottom) == Abc_NtkPiNum(pNtkTop) );
879 assert( Abc_NtkPiNum(pNtkBottom) < Abc_NtkPiNum(pNtkTop) );
880 // add buffers for the PIs of the top - save results in the POs of the bottom
881 Abc_NtkForEachPi( pNtkTop, pObj, i )
882 {
883 pBuffer = Abc_NtkCreateNodeBuf( pNtkTop, NULL );
884 Abc_ObjTransferFanout( pObj, pBuffer );
885 Abc_NtkPo(pNtkBottom, i)->pCopy = pBuffer;
886 }
887 // remove useless PIs of the top
888 for ( i = Abc_NtkPiNum(pNtkTop) - 1; i >= Abc_NtkPiNum(pNtkBottom); i-- )
889 Abc_NtkDeleteObj( Abc_NtkPi(pNtkTop, i) );
890 assert( Abc_NtkPiNum(pNtkBottom) == Abc_NtkPiNum(pNtkTop) );
891 // copy the bottom network
892 Abc_NtkForEachPi( pNtkBottom, pObj, i )
893 Abc_NtkPi(pNtkBottom, i)->pCopy = Abc_NtkPi(pNtkTop, i);
894 // construct all nodes
895 vNodes = Abc_NtkDfs( pNtkBottom, 0 );
896 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
897 {
898 Abc_NtkDupObj(pNtkTop, pObj, 0);
899 Abc_ObjForEachFanin( pObj, pFanin, k )
900 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
901 }
902 Vec_PtrFree( vNodes );
903 // connect the POs
904 Abc_NtkForEachPo( pNtkBottom, pObj, i )
905 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pObj)->pCopy );
906 // delete old network
907 Abc_NtkDelete( pNtkBottom );
908 // return the network
909 if ( !Abc_NtkCheck( pNtkTop ) )
910 fprintf( stdout, "Abc_NtkAttachBottom(): Network check has failed.\n" );
911 return pNtkTop;
912}
913
925Abc_Ntk_t * Abc_NtkCreateCone( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNodeName, int fUseAllCis )
926{
927 Abc_Ntk_t * pNtkNew;
928 Vec_Ptr_t * vNodes;
929 Abc_Obj_t * pObj, * pFanin, * pNodeCoNew;
930 char Buffer[1000];
931 int i, k;
932
933 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
934 assert( Abc_ObjIsNode(pNode) || (Abc_NtkIsStrash(pNtk) && (Abc_AigNodeIsConst(pNode) || Abc_ObjIsCi(pNode))) );
935
936 // start the network
937 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
938 // set the name
939 sprintf( Buffer, "%s_%s", pNtk->pName, pNodeName );
940 pNtkNew->pName = Extra_UtilStrsav(Buffer);
941
942 // establish connection between the constant nodes
943 if ( Abc_NtkIsStrash(pNtk) )
944 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
945
946 // collect the nodes in the TFI of the output (mark the TFI)
947 vNodes = Abc_NtkDfsNodes( pNtk, &pNode, 1 );
948 // create the PIs
949 Abc_NtkForEachCi( pNtk, pObj, i )
950 {
951 if ( fUseAllCis || Abc_NodeIsTravIdCurrent(pObj) ) // TravId is set by DFS
952 {
953 pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
954 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
955 }
956 }
957 // add the PO corresponding to this output
958 pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
959 Abc_ObjAssignName( pNodeCoNew, pNodeName, NULL );
960 // copy the nodes
961 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
962 {
963 // if it is an AIG, add to the hash table
964 if ( Abc_NtkIsStrash(pNtk) )
965 {
966 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
967 }
968 else
969 {
970 Abc_NtkDupObj( pNtkNew, pObj, 0 );
971 Abc_ObjForEachFanin( pObj, pFanin, k )
972 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
973 }
974 }
975 // connect the internal nodes to the new CO
976 Abc_ObjAddFanin( pNodeCoNew, pNode->pCopy );
977 Vec_PtrFree( vNodes );
978
979 if ( !Abc_NtkCheck( pNtkNew ) )
980 fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
981 return pNtkNew;
982}
983
995Abc_Ntk_t * Abc_NtkCreateConeArray( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, int fUseAllCis )
996{
997 Abc_Ntk_t * pNtkNew;
998 Vec_Ptr_t * vNodes;
999 Abc_Obj_t * pObj, * pFanin, * pNodeCoNew;
1000 char Buffer[1000];
1001 int i, k;
1002
1003 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
1004
1005 // start the network
1006 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
1007 // set the name
1008 sprintf( Buffer, "%s_part", pNtk->pName );
1009 pNtkNew->pName = Extra_UtilStrsav(Buffer);
1010
1011 // establish connection between the constant nodes
1012 if ( Abc_NtkIsStrash(pNtk) )
1013 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
1014
1015 // collect the nodes in the TFI of the output (mark the TFI)
1016 vNodes = Abc_NtkDfsNodes( pNtk, (Abc_Obj_t **)Vec_PtrArray(vRoots), Vec_PtrSize(vRoots) );
1017
1018 // create the PIs
1019 Abc_NtkForEachCi( pNtk, pObj, i )
1020 {
1021 if ( fUseAllCis || Abc_NodeIsTravIdCurrent(pObj) ) // TravId is set by DFS
1022 {
1023 pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
1024 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
1025 }
1026 }
1027
1028 // copy the nodes
1029 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
1030 {
1031 // if it is an AIG, add to the hash table
1032 if ( Abc_NtkIsStrash(pNtk) )
1033 {
1034 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
1035 }
1036 else
1037 {
1038 Abc_NtkDupObj( pNtkNew, pObj, 0 );
1039 Abc_ObjForEachFanin( pObj, pFanin, k )
1040 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
1041 }
1042 }
1043 Vec_PtrFree( vNodes );
1044
1045 // add the POs corresponding to the root nodes
1046 Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
1047 {
1048 // create the PO node
1049 pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
1050 // connect the internal nodes to the new CO
1051 if ( Abc_ObjIsCo(pObj) )
1052 Abc_ObjAddFanin( pNodeCoNew, Abc_ObjChild0Copy(pObj) );
1053 else
1054 Abc_ObjAddFanin( pNodeCoNew, pObj->pCopy );
1055 // assign the name
1056 Abc_ObjAssignName( pNodeCoNew, Abc_ObjName(pObj), NULL );
1057 }
1058
1059 if ( !Abc_NtkCheck( pNtkNew ) )
1060 fprintf( stdout, "Abc_NtkCreateConeArray(): Network check has failed.\n" );
1061 return pNtkNew;
1062}
1063
1075void Abc_NtkAppendToCone( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots )
1076{
1077 Vec_Ptr_t * vNodes;
1078 Abc_Obj_t * pObj;
1079 int i, iNodeId;
1080
1081 assert( Abc_NtkIsStrash(pNtkNew) );
1082 assert( Abc_NtkIsStrash(pNtk) );
1083
1084 // collect the nodes in the TFI of the output (mark the TFI)
1085 vNodes = Abc_NtkDfsNodes( pNtk, (Abc_Obj_t **)Vec_PtrArray(vRoots), Vec_PtrSize(vRoots) );
1086
1087 // establish connection between the constant nodes
1088 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
1089
1090 // create the PIs
1091 Abc_NtkForEachCi( pNtk, pObj, i )
1092 {
1093 // skip CIs that are not used
1094 if ( !Abc_NodeIsTravIdCurrent(pObj) )
1095 continue;
1096 // find the corresponding CI in the new network
1098 if ( iNodeId == -1 )
1099 {
1100 pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
1101 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
1102 }
1103 else
1104 pObj->pCopy = Abc_NtkObj( pNtkNew, iNodeId );
1105 }
1106
1107 // copy the nodes
1108 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
1109 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
1110 Vec_PtrFree( vNodes );
1111
1112 // do not add the COs
1113 if ( !Abc_NtkCheck( pNtkNew ) )
1114 fprintf( stdout, "Abc_NtkAppendToCone(): Network check has failed.\n" );
1115}
1116
1128Abc_Ntk_t * Abc_NtkCreateMffc( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNodeName )
1129{
1130 Abc_Ntk_t * pNtkNew;
1131 Abc_Obj_t * pObj, * pFanin, * pNodeCoNew;
1132 Vec_Ptr_t * vCone, * vSupp;
1133 char Buffer[1000];
1134 int i, k;
1135
1136 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
1137 assert( Abc_ObjIsNode(pNode) );
1138
1139 // start the network
1140 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
1141 // set the name
1142 sprintf( Buffer, "%s_%s", pNtk->pName, pNodeName );
1143 pNtkNew->pName = Extra_UtilStrsav(Buffer);
1144
1145 // establish connection between the constant nodes
1146 if ( Abc_NtkIsStrash(pNtk) )
1147 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
1148
1149 // collect the nodes in MFFC
1150 vCone = Vec_PtrAlloc( 100 );
1151 vSupp = Vec_PtrAlloc( 100 );
1152 Abc_NodeDeref_rec( pNode );
1153 Abc_NodeMffcConeSupp( pNode, vCone, vSupp );
1154 Abc_NodeRef_rec( pNode );
1155 // create the PIs
1156 Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
1157 {
1158 pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
1159 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
1160 }
1161 // create the PO
1162 pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
1163 Abc_ObjAssignName( pNodeCoNew, pNodeName, NULL );
1164 // copy the nodes
1165 Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, i )
1166 {
1167 // if it is an AIG, add to the hash table
1168 if ( Abc_NtkIsStrash(pNtk) )
1169 {
1170 pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
1171 }
1172 else
1173 {
1174 Abc_NtkDupObj( pNtkNew, pObj, 0 );
1175 Abc_ObjForEachFanin( pObj, pFanin, k )
1176 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
1177 }
1178 }
1179 // connect the topmost node
1180 Abc_ObjAddFanin( pNodeCoNew, pNode->pCopy );
1181 Vec_PtrFree( vCone );
1182 Vec_PtrFree( vSupp );
1183
1184 if ( !Abc_NtkCheck( pNtkNew ) )
1185 fprintf( stdout, "Abc_NtkCreateMffc(): Network check has failed.\n" );
1186 return pNtkNew;
1187}
1188
1201{
1202 Vec_Ptr_t * vNodes;
1203 Abc_Ntk_t * pNtkNew;
1204 Abc_Obj_t * pObj, * pFinal, * pOther, * pNodePo;
1205 int i;
1206
1207 assert( Abc_NtkIsLogic(pNtk) );
1208
1209 // start the network
1210 Abc_NtkCleanCopy( pNtk );
1211 pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
1212 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
1213
1214 // collect the nodes in the TFI of the output
1215 vNodes = Abc_NtkDfsNodes( pNtk, (Abc_Obj_t **)vRoots->pArray, vRoots->nSize );
1216 // create the PIs
1217 Abc_NtkForEachCi( pNtk, pObj, i )
1218 {
1219 pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
1220 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
1221 }
1222 // copy the nodes
1223 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
1224 pObj->pCopy = Abc_NodeStrash( pNtkNew, pObj, 0 );
1225 Vec_PtrFree( vNodes );
1226
1227 // add the PO
1228 pFinal = Abc_AigConst1( pNtkNew );
1229 Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
1230 {
1231 if ( Abc_ObjIsCo(pObj) )
1232 pOther = Abc_ObjFanin0(pObj)->pCopy;
1233 else
1234 pOther = pObj->pCopy;
1235 if ( Vec_IntEntry(vValues, i) == 0 )
1236 pOther = Abc_ObjNot(pOther);
1237 pFinal = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pFinal, pOther );
1238 }
1239
1240 // add the PO corresponding to this output
1241 pNodePo = Abc_NtkCreatePo( pNtkNew );
1242 Abc_ObjAddFanin( pNodePo, pFinal );
1243 Abc_ObjAssignName( pNodePo, "miter", NULL );
1244 if ( !Abc_NtkCheck( pNtkNew ) )
1245 fprintf( stdout, "Abc_NtkCreateTarget(): Network check has failed.\n" );
1246 return pNtkNew;
1247}
1248
1261{
1262 Abc_Ntk_t * pNtkNew;
1263 Abc_Obj_t * pFanin, * pNodePo;
1264 int i;
1265 // start the network
1266 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
1267 pNtkNew->pName = Extra_UtilStrsav(Abc_ObjName(pNode));
1268 // add the PIs corresponding to the fanins of the node
1269 Abc_ObjForEachFanin( pNode, pFanin, i )
1270 {
1271 pFanin->pCopy = Abc_NtkCreatePi( pNtkNew );
1272 Abc_ObjAssignName( pFanin->pCopy, Abc_ObjName(pFanin), NULL );
1273 }
1274 // duplicate and connect the node
1275 pNode->pCopy = Abc_NtkDupObj( pNtkNew, pNode, 0 );
1276 Abc_ObjForEachFanin( pNode, pFanin, i )
1277 Abc_ObjAddFanin( pNode->pCopy, pFanin->pCopy );
1278 // create the only PO
1279 pNodePo = Abc_NtkCreatePo( pNtkNew );
1280 Abc_ObjAddFanin( pNodePo, pNode->pCopy );
1281 Abc_ObjAssignName( pNodePo, Abc_ObjName(pNode), NULL );
1282 if ( !Abc_NtkCheck( pNtkNew ) )
1283 fprintf( stdout, "Abc_NtkCreateFromNode(): Network check has failed.\n" );
1284 return pNtkNew;
1285}
1286
1299{
1300 Abc_Ntk_t * pNtkNew;
1301 Abc_Obj_t * pObj, * pNodeNew, * pNodePo;
1302 Gia_Man_t * p = Abc_NtkClpGia( pNtk ); int i;
1303 Vec_Str_t * vStr = Gia_ManComputeRange( p );
1304 Gia_ManStop( p );
1305 pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
1306 pNtkNew->pName = Extra_UtilStrsav("range");
1307 Abc_NtkForEachCo( pNtk, pObj, i )
1308 Abc_ObjAssignName( Abc_NtkCreatePi(pNtkNew), Abc_ObjName(pObj), NULL );
1309 pNodeNew = Abc_NtkCreateObj( pNtkNew, ABC_OBJ_NODE );
1310 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Vec_StrArray(vStr) );
1311 Vec_StrFree( vStr );
1312 Abc_NtkForEachCi( pNtkNew, pObj, i )
1313 Abc_ObjAddFanin( pNodeNew, pObj );
1314 pNodePo = Abc_NtkCreatePo( pNtkNew );
1315 Abc_ObjAddFanin( pNodePo, pNodeNew );
1316 Abc_ObjAssignName( pNodePo, "range", NULL );
1317 if ( !Abc_NtkCheck( pNtkNew ) )
1318 fprintf( stdout, "Abc_NtkCreateFromNode(): Network check has failed.\n" );
1319 return pNtkNew;
1320}
1321
1334{
1335 Abc_Ntk_t * pNtkNew;
1336 Abc_Obj_t * pFanin, * pNode, * pNodePo;
1337 Vec_Ptr_t * vNames;
1338 int i, nVars;
1339 // start the network
1340 pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
1341 pNtkNew->pName = Extra_UtilStrsav("ex");
1342 // create PIs
1343 Vec_PtrPush( pNtkNew->vObjs, NULL );
1344 nVars = Abc_SopGetVarNum( pSop );
1345 vNames = Abc_NodeGetFakeNames( nVars );
1346 for ( i = 0; i < nVars; i++ )
1347 Abc_ObjAssignName( Abc_NtkCreatePi(pNtkNew), (char *)Vec_PtrEntry(vNames, i), NULL );
1348 Abc_NodeFreeNames( vNames );
1349 // create the node, add PIs as fanins, set the function
1350 pNode = Abc_NtkCreateNode( pNtkNew );
1351 Abc_NtkForEachPi( pNtkNew, pFanin, i )
1352 Abc_ObjAddFanin( pNode, pFanin );
1353 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, pSop );
1354 // create the only PO
1355 pNodePo = Abc_NtkCreatePo(pNtkNew);
1356 Abc_ObjAddFanin( pNodePo, pNode );
1357 Abc_ObjAssignName( pNodePo, "F", NULL );
1358 if ( !Abc_NtkCheck( pNtkNew ) )
1359 fprintf( stdout, "Abc_NtkCreateWithNode(): Network check has failed.\n" );
1360 return pNtkNew;
1361}
1362
1375{
1376 Abc_Ntk_t * pNtkNew;
1377 Abc_Obj_t * pFanin, * pNode, * pNodePo;
1378 Vec_Ptr_t * vNames;
1379 int i, k, nVars; char Buffer[100];
1380 char * pSop = (char *)Vec_PtrEntry(vSop, 0);
1381 // start the network
1382 pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
1383 pNtkNew->pName = Extra_UtilStrsav("ex");
1384 // create PIs
1385 Vec_PtrPush( pNtkNew->vObjs, NULL );
1386 nVars = Abc_SopGetVarNum( pSop );
1387 vNames = Abc_NodeGetFakeNames( nVars );
1388 for ( i = 0; i < nVars; i++ )
1389 Abc_ObjAssignName( Abc_NtkCreatePi(pNtkNew), (char *)Vec_PtrEntry(vNames, i), NULL );
1390 Abc_NodeFreeNames( vNames );
1391 // create the node, add PIs as fanins, set the function
1392 Vec_PtrForEachEntry( char *, vSop, pSop, i )
1393 {
1394 pNode = Abc_NtkCreateNode( pNtkNew );
1395 if ( Abc_SopGetVarNum(pSop) > 0 )
1396 Abc_NtkForEachPi( pNtkNew, pFanin, k )
1397 Abc_ObjAddFanin( pNode, pFanin );
1398 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, pSop );
1399 // create the only PO
1400 pNodePo = Abc_NtkCreatePo(pNtkNew);
1401 Abc_ObjAddFanin( pNodePo, pNode );
1402 sprintf( Buffer, "F%d", i );
1403 Abc_ObjAssignName( pNodePo, Buffer, NULL );
1404 }
1405 if ( !Abc_NtkCheck( pNtkNew ) )
1406 fprintf( stdout, "Abc_NtkCreateWithNode(): Network check has failed.\n" );
1407 return pNtkNew;
1408}
1409
1422{
1423 Abc_Obj_t * pObj;
1424 void * pAttrMan;
1425 int TotalMemory, i;
1426 int fWarning = 0;
1427// int LargePiece = (4 << ABC_NUM_STEPS);
1428 if ( pNtk == NULL )
1429 return;
1430 // free EXDC Ntk
1431 if ( pNtk->pExdc )
1432 Abc_NtkDelete( pNtk->pExdc );
1433 if ( pNtk->pExcare )
1434 Abc_NtkDelete( (Abc_Ntk_t *)pNtk->pExcare );
1435 // dereference the BDDs
1436 if ( Abc_NtkHasBdd(pNtk) )
1437 {
1438#ifdef ABC_USE_CUDD
1439 Abc_NtkForEachNode( pNtk, pObj, i )
1440 Cudd_RecursiveDeref( (DdManager *)pNtk->pManFunc, (DdNode *)pObj->pData );
1441#endif
1442 }
1443 // make sure all the marks are clean
1444 Abc_NtkForEachObj( pNtk, pObj, i )
1445 {
1446 // free large fanout arrays
1447// if ( pNtk->pMmObj && pObj->vFanouts.nCap * 4 > LargePiece )
1448// ABC_FREE( pObj->vFanouts.pArray );
1449 // these flags should be always zero
1450 // if this is not true, something is wrong somewhere
1451// assert( pObj->fMarkA == 0 );
1452// assert( pObj->fMarkB == 0 );
1453// assert( pObj->fMarkC == 0 );
1454 if ( !fWarning && (pObj->fMarkA || pObj->fMarkB || pObj->fMarkC) )
1455 { printf( "Flags A, B, or C are not zero.\n" ), fWarning = 1; }
1456 }
1457 // free the nodes
1458 if ( pNtk->pMmStep == NULL )
1459 {
1460 Abc_NtkForEachObj( pNtk, pObj, i )
1461 {
1462 ABC_FREE( pObj->vFanouts.pArray );
1463 ABC_FREE( pObj->vFanins.pArray );
1464 }
1465 }
1466 if ( pNtk->pMmObj == NULL )
1467 {
1468 Abc_NtkForEachObj( pNtk, pObj, i )
1469 ABC_FREE( pObj );
1470 }
1471
1472 // free the arrays
1473 Vec_PtrFree( pNtk->vPios );
1474 Vec_PtrFree( pNtk->vPis );
1475 Vec_PtrFree( pNtk->vPos );
1476 Vec_PtrFree( pNtk->vCis );
1477 Vec_PtrFree( pNtk->vCos );
1478 Vec_PtrFree( pNtk->vObjs );
1479 Vec_PtrFree( pNtk->vBoxes );
1480 ABC_FREE( pNtk->vTravIds.pArray );
1481 if ( pNtk->vLevelsR ) Vec_IntFree( pNtk->vLevelsR );
1482 ABC_FREE( pNtk->pModel );
1483 ABC_FREE( pNtk->pSeqModel );
1484 if ( pNtk->vSeqModelVec )
1485 Vec_PtrFreeFree( pNtk->vSeqModelVec );
1486 TotalMemory = 0;
1487 TotalMemory += pNtk->pMmObj? Mem_FixedReadMemUsage(pNtk->pMmObj) : 0;
1488 TotalMemory += pNtk->pMmStep? Mem_StepReadMemUsage(pNtk->pMmStep) : 0;
1489// fprintf( stdout, "The total memory allocated internally by the network = %0.2f MB.\n", ((double)TotalMemory)/(1<<20) );
1490 // free the storage
1491 if ( pNtk->pMmObj )
1492 Mem_FixedStop( pNtk->pMmObj, 0 );
1493 if ( pNtk->pMmStep )
1494 Mem_StepStop ( pNtk->pMmStep, 0 );
1495 // name manager
1496 Nm_ManFree( pNtk->pManName );
1497 // free the timing manager
1498 if ( pNtk->pManTime )
1499 Abc_ManTimeStop( pNtk->pManTime );
1500 Vec_IntFreeP( &pNtk->vPhases );
1501 // start the functionality manager
1502 if ( Abc_NtkIsStrash(pNtk) )
1503 Abc_AigFree( (Abc_Aig_t *)pNtk->pManFunc );
1504 else if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
1505 Mem_FlexStop( (Mem_Flex_t *)pNtk->pManFunc, 0 );
1506#ifdef ABC_USE_CUDD
1507 else if ( Abc_NtkHasBdd(pNtk) )
1508 Extra_StopManager( (DdManager *)pNtk->pManFunc );
1509#endif
1510 else if ( Abc_NtkHasAig(pNtk) )
1511 { if ( pNtk->pManFunc ) Hop_ManStop( (Hop_Man_t *)pNtk->pManFunc ); }
1512 else if ( Abc_NtkHasMapping(pNtk) )
1513 pNtk->pManFunc = NULL;
1514 else if ( !Abc_NtkHasBlackbox(pNtk) )
1515 assert( 0 );
1516 // free the hierarchy
1517 if ( pNtk->pDesign )
1518 {
1519 Abc_DesFree( pNtk->pDesign, pNtk );
1520 pNtk->pDesign = NULL;
1521 }
1522// if ( pNtk->pBlackBoxes )
1523// Vec_IntFree( pNtk->pBlackBoxes );
1524 // free node attributes
1525 Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vAttrs, pAttrMan, i )
1526 if ( pAttrMan )
1527 Vec_AttFree( (Vec_Att_t *)pAttrMan, 1 );
1528 assert( pNtk->pSCLib == NULL );
1529 Vec_IntFreeP( &pNtk->vGates );
1530 Vec_PtrFree( pNtk->vAttrs );
1531 Vec_IntFreeP( &pNtk->vNameIds );
1532 ABC_FREE( pNtk->pWLoadUsed );
1533 ABC_FREE( pNtk->pName );
1534 ABC_FREE( pNtk->pSpec );
1535 ABC_FREE( pNtk->pLutTimes );
1536 if ( pNtk->vOnehots )
1537 Vec_VecFree( (Vec_Vec_t *)pNtk->vOnehots );
1538 Vec_PtrFreeP( &pNtk->vLtlProperties );
1539 Vec_IntFreeP( &pNtk->vObjPerm );
1540 Vec_IntFreeP( &pNtk->vTopo );
1541 Vec_IntFreeP( &pNtk->vFins );
1542 Vec_IntFreeP( &pNtk->vOrigNodeIds );
1543 ABC_FREE( pNtk );
1544}
1545
1558{
1559 Vec_Ptr_t * vNets;
1560 Abc_Obj_t * pNet, * pNode;
1561 int i;
1562
1563 if ( Abc_NtkNodeNum(pNtk) == 0 && Abc_NtkBoxNum(pNtk) == 0 )
1564 return;
1565
1566 // special case
1567 pNet = Abc_NtkFindNet( pNtk, "$false" );
1568 if ( pNet != NULL )
1569 {
1570 pNode = Abc_NtkCreateNodeConst0( pNtk );
1571 Abc_ObjAddFanin( pNet, pNode );
1572 }
1573 pNet = Abc_NtkFindNet( pNtk, "$undef" );
1574 if ( pNet != NULL )
1575 {
1576 pNode = Abc_NtkCreateNodeConst0( pNtk );
1577 Abc_ObjAddFanin( pNet, pNode );
1578 }
1579 pNet = Abc_NtkFindNet( pNtk, "$true" );
1580 if ( pNet != NULL )
1581 {
1582 pNode = Abc_NtkCreateNodeConst1( pNtk );
1583 Abc_ObjAddFanin( pNet, pNode );
1584 }
1585 pNet = Abc_NtkFindNet( pNtk, "[_c1_]" );
1586 if ( pNet != NULL )
1587 {
1588 pNode = Abc_NtkCreateNodeConst1( pNtk );
1589 Abc_ObjAddFanin( pNet, pNode );
1590 }
1591
1592 // check for non-driven nets
1593 vNets = Vec_PtrAlloc( 100 );
1594 Abc_NtkForEachNet( pNtk, pNet, i )
1595 {
1596 if ( Abc_ObjFaninNum(pNet) > 0 )
1597 continue;
1598 // add the constant 0 driver
1599 pNode = Abc_NtkCreateNodeConst0( pNtk );
1600 // add the fanout net
1601 Abc_ObjAddFanin( pNet, pNode );
1602 // add the net to those for which the warning will be printed
1603 Vec_PtrPush( vNets, pNet );
1604 }
1605
1606 // print the warning
1607 if ( vNets->nSize > 0 )
1608 {
1609 printf( "Warning: Constant-0 drivers added to %d non-driven nets in network \"%s\":\n", Vec_PtrSize(vNets), pNtk->pName );
1610 Vec_PtrForEachEntry( Abc_Obj_t *, vNets, pNet, i )
1611 {
1612 printf( "%s%s", (i? ", ": ""), Abc_ObjName(pNet) );
1613 if ( i == 3 )
1614 {
1615 if ( Vec_PtrSize(vNets) > 3 )
1616 printf( " ..." );
1617 break;
1618 }
1619 }
1620 printf( "\n" );
1621 }
1622 Vec_PtrFree( vNets );
1623}
1624
1625
1637void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches )
1638{
1639 Abc_Obj_t * pObj;
1640 int i;
1641
1642 if ( Abc_NtkIsComb(pNtk) )
1643 return;
1644
1645 assert( !Abc_NtkIsNetlist(pNtk) );
1646 assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
1647
1648 // detach the latches
1649// Abc_NtkForEachLatch( pNtk, pObj, i )
1650 Vec_PtrForEachEntryReverse( Abc_Obj_t *, pNtk->vBoxes, pObj, i )
1651 Abc_NtkDeleteObj( pObj );
1652 assert( Abc_NtkLatchNum(pNtk) == 0 );
1653 assert( Abc_NtkBoxNum(pNtk) == 0 );
1654
1655 // move CIs to become PIs
1656 Vec_PtrClear( pNtk->vPis );
1657 Abc_NtkForEachCi( pNtk, pObj, i )
1658 {
1659 if ( Abc_ObjIsBo(pObj) )
1660 {
1661 pObj->Type = ABC_OBJ_PI;
1662 pNtk->nObjCounts[ABC_OBJ_PI]++;
1663 pNtk->nObjCounts[ABC_OBJ_BO]--;
1664 }
1665 Vec_PtrPush( pNtk->vPis, pObj );
1666 }
1667 assert( Abc_NtkBoNum(pNtk) == 0 );
1668
1669 if ( fRemoveLatches )
1670 {
1671 // remove registers
1672 Vec_Ptr_t * vBos;
1673 vBos = Vec_PtrAlloc( 100 );
1674 Vec_PtrClear( pNtk->vPos );
1675 Abc_NtkForEachCo( pNtk, pObj, i )
1676 if ( Abc_ObjIsBi(pObj) )
1677 Vec_PtrPush( vBos, pObj );
1678 else
1679 Vec_PtrPush( pNtk->vPos, pObj );
1680 // remove COs
1681 Vec_PtrFree( pNtk->vCos );
1682 pNtk->vCos = NULL;
1683 // remove the BOs
1684 Vec_PtrForEachEntry( Abc_Obj_t *, vBos, pObj, i )
1685 Abc_NtkDeleteObj( pObj );
1686 Vec_PtrFree( vBos );
1687 // create COs
1688 pNtk->vCos = Vec_PtrDup( pNtk->vPos );
1689 // cleanup
1690 if ( Abc_NtkIsLogic(pNtk) )
1691 Abc_NtkCleanup( pNtk, 0 );
1692 else if ( Abc_NtkIsStrash(pNtk) )
1693 Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
1694 else
1695 assert( 0 );
1696 }
1697 else
1698 {
1699 // move COs to become POs
1700 Vec_PtrClear( pNtk->vPos );
1701 Abc_NtkForEachCo( pNtk, pObj, i )
1702 {
1703 if ( Abc_ObjIsBi(pObj) )
1704 {
1705 pObj->Type = ABC_OBJ_PO;
1706 pNtk->nObjCounts[ABC_OBJ_PO]++;
1707 pNtk->nObjCounts[ABC_OBJ_BI]--;
1708 }
1709 Vec_PtrPush( pNtk->vPos, pObj );
1710 }
1711 }
1712 assert( Abc_NtkBiNum(pNtk) == 0 );
1713
1714 if ( !Abc_NtkCheck( pNtk ) )
1715 fprintf( stdout, "Abc_NtkMakeComb(): Network check has failed.\n" );
1716}
1717
1729void Abc_NtkMakeSeq( Abc_Ntk_t * pNtk, int nLatchesToAdd )
1730{
1731 Abc_Obj_t * pObjLi, * pObjLo, * pObj;
1732 int i;
1733 assert( Abc_NtkBoxNum(pNtk) == 0 );
1734 if ( !Abc_NtkIsComb(pNtk) )
1735 {
1736 printf( "The network is a not a combinational one.\n" );
1737 return;
1738 }
1739 if ( nLatchesToAdd >= Abc_NtkPiNum(pNtk) )
1740 {
1741 printf( "The number of latches is more or equal than the number of PIs.\n" );
1742 return;
1743 }
1744 if ( nLatchesToAdd >= Abc_NtkPoNum(pNtk) )
1745 {
1746 printf( "The number of latches is more or equal than the number of POs.\n" );
1747 return;
1748 }
1749
1750 // move the last PIs to become CIs
1751 Vec_PtrClear( pNtk->vPis );
1752 Abc_NtkForEachCi( pNtk, pObj, i )
1753 {
1754 if ( i < Abc_NtkCiNum(pNtk) - nLatchesToAdd )
1755 {
1756 Vec_PtrPush( pNtk->vPis, pObj );
1757 continue;
1758 }
1759 pObj->Type = ABC_OBJ_BO;
1760 pNtk->nObjCounts[ABC_OBJ_PI]--;
1761 pNtk->nObjCounts[ABC_OBJ_BO]++;
1762 }
1763
1764 // move the last POs to become COs
1765 Vec_PtrClear( pNtk->vPos );
1766 Abc_NtkForEachCo( pNtk, pObj, i )
1767 {
1768 if ( i < Abc_NtkCoNum(pNtk) - nLatchesToAdd )
1769 {
1770 Vec_PtrPush( pNtk->vPos, pObj );
1771 continue;
1772 }
1773 pObj->Type = ABC_OBJ_BI;
1774 pNtk->nObjCounts[ABC_OBJ_PO]--;
1775 pNtk->nObjCounts[ABC_OBJ_BI]++;
1776 }
1777
1778 // create latches
1779 for ( i = 0; i < nLatchesToAdd; i++ )
1780 {
1781 pObjLo = Abc_NtkCi( pNtk, Abc_NtkCiNum(pNtk) - nLatchesToAdd + i );
1782 pObjLi = Abc_NtkCo( pNtk, Abc_NtkCoNum(pNtk) - nLatchesToAdd + i );
1783 pObj = Abc_NtkCreateLatch( pNtk );
1784 Abc_ObjAddFanin( pObj, pObjLi );
1785 Abc_ObjAddFanin( pObjLo, pObj );
1786 Abc_LatchSetInit0( pObj );
1787 }
1788
1789 if ( !Abc_NtkCheck( pNtk ) )
1790 fprintf( stdout, "Abc_NtkMakeSeq(): Network check has failed.\n" );
1791}
1792
1793
1806{
1807 Abc_Ntk_t * pNtk;
1808 Vec_Ptr_t * vPosLeft;
1809 Vec_Ptr_t * vCosLeft;
1810 Abc_Obj_t * pNodePo;
1811 int i, Index;
1812 assert( !Abc_NtkIsNetlist(pNtkInit) );
1813 assert( Abc_NtkHasOnlyLatchBoxes(pNtkInit) );
1814 pNtk = Abc_NtkDup( pNtkInit );
1815 if ( Abc_NtkPoNum(pNtk) == 1 )
1816 return pNtk;
1817 vPosLeft = Vec_PtrAlloc( Vec_IntSize(vPoIds) );
1818 Vec_IntForEachEntry( vPoIds, Index, i ) {
1819 Vec_PtrPush( vPosLeft, Abc_NtkPo(pNtk, Index) );
1820 Vec_PtrWriteEntry( pNtk->vPos, Index, NULL );
1821 }
1822 // filter COs
1823 vCosLeft = Vec_PtrDup( vPosLeft );
1824 for ( i = Abc_NtkPoNum(pNtk); i < Abc_NtkCoNum(pNtk); i++ )
1825 Vec_PtrPush( vCosLeft, Abc_NtkCo(pNtk, i) );
1826 // remove remaiing POs
1827 Abc_NtkForEachPo( pNtk, pNodePo, i )
1828 if ( pNodePo )
1829 Abc_NtkDeleteObjPo( pNodePo );
1830 // update arrays
1831 Vec_PtrFree( pNtk->vPos ); pNtk->vPos = vPosLeft;
1832 Vec_PtrFree( pNtk->vCos ); pNtk->vCos = vCosLeft;
1833 // clean the network
1834 if ( Abc_NtkIsStrash(pNtk) ) {
1835 Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
1836 if ( Abc_NtkLatchNum(pNtk) ) printf( "Run sequential cleanup (\"scl\") to get rid of dangling logic.\n" );
1837 }
1838 else {
1839 if ( Abc_NtkLatchNum(pNtk) ) printf( "Run sequential cleanup (\"st; scl\") to get rid of dangling logic.\n" );
1840 }
1841 if ( !Abc_NtkCheck( pNtk ) )
1842 fprintf( stdout, "Abc_NtkMakeComb(): Network check has failed.\n" );
1843 return pNtk;
1844}
1845
1857Abc_Ntk_t * Abc_NtkMakeOnePo( Abc_Ntk_t * pNtkInit, int Output, int nRange )
1858{
1859 Abc_Ntk_t * pNtk;
1860 Vec_Ptr_t * vPosLeft;
1861 Vec_Ptr_t * vCosLeft;
1862 Abc_Obj_t * pNodePo;
1863 int i;
1864 assert( !Abc_NtkIsNetlist(pNtkInit) );
1865 assert( Abc_NtkHasOnlyLatchBoxes(pNtkInit) );
1866 if ( Output < 0 || Output >= Abc_NtkPoNum(pNtkInit) )
1867 {
1868 printf( "PO index is incorrect.\n" );
1869 return NULL;
1870 }
1871
1872 pNtk = Abc_NtkDup( pNtkInit );
1873 if ( Abc_NtkPoNum(pNtk) == 1 )
1874 return pNtk;
1875
1876 if ( nRange < 1 )
1877 nRange = 1;
1878
1879 // filter POs
1880 vPosLeft = Vec_PtrAlloc( nRange );
1881 Abc_NtkForEachPo( pNtk, pNodePo, i )
1882 if ( i < Output || i >= Output + nRange )
1883 Abc_NtkDeleteObjPo( pNodePo );
1884 else
1885 Vec_PtrPush( vPosLeft, pNodePo );
1886 // filter COs
1887 vCosLeft = Vec_PtrDup( vPosLeft );
1888 for ( i = Abc_NtkPoNum(pNtk); i < Abc_NtkCoNum(pNtk); i++ )
1889 Vec_PtrPush( vCosLeft, Abc_NtkCo(pNtk, i) );
1890 // update arrays
1891 Vec_PtrFree( pNtk->vPos ); pNtk->vPos = vPosLeft;
1892 Vec_PtrFree( pNtk->vCos ); pNtk->vCos = vCosLeft;
1893
1894 // clean the network
1895 if ( Abc_NtkIsStrash(pNtk) )
1896 {
1897 Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
1898 if ( Abc_NtkLatchNum(pNtk) ) printf( "Run sequential cleanup (\"scl\") to get rid of dangling logic.\n" );
1899 }
1900 else
1901 {
1902 if ( Abc_NtkLatchNum(pNtk) ) printf( "Run sequential cleanup (\"st; scl\") to get rid of dangling logic.\n" );
1903 }
1904
1905 if ( !Abc_NtkCheck( pNtk ) )
1906 fprintf( stdout, "Abc_NtkMakeComb(): Network check has failed.\n" );
1907 return pNtk;
1908}
1909
1922{
1923 Abc_Obj_t * pObj;
1924 int i, k, m;
1925
1926 // filter POs
1927 k = m = 0;
1928 Abc_NtkForEachCo( pNtk, pObj, i )
1929 {
1930 if ( Abc_ObjIsPo(pObj) )
1931 {
1932 // remove constant nodes and PI pointers
1933 if ( Abc_ObjFaninNum(Abc_ObjFanin0(pObj)) == 0 )
1934 {
1935 Abc_ObjDeleteFanin( pObj, Abc_ObjFanin0(pObj) );
1936 if ( Abc_ObjFanoutNum(Abc_ObjFanin0(pObj)) == 0 && !Abc_ObjIsPi(Abc_ObjFanin0(pObj)) )
1937 Abc_NtkDeleteObj_rec( Abc_ObjFanin0(pObj), 1 );
1938 pNtk->vObjs->pArray[pObj->Id] = NULL;
1939 pObj->Id = (1<<26)-1;
1940 pNtk->nObjCounts[pObj->Type]--;
1941 pNtk->nObjs--;
1942 Abc_ObjRecycle( pObj );
1943 continue;
1944 }
1945 // remove buffers/inverters of PIs
1946 if ( Abc_ObjFaninNum(Abc_ObjFanin0(pObj)) == 1 )
1947 {
1948 if ( Abc_ObjIsPi(Abc_ObjFanin0(Abc_ObjFanin0(pObj))) )
1949 {
1950 Abc_ObjDeleteFanin( pObj, Abc_ObjFanin0(pObj) );
1951 if ( Abc_ObjFanoutNum(Abc_ObjFanin0(pObj)) == 0 )
1952 Abc_NtkDeleteObj_rec( Abc_ObjFanin0(pObj), 1 );
1953 pNtk->vObjs->pArray[pObj->Id] = NULL;
1954 pObj->Id = (1<<26)-1;
1955 pNtk->nObjCounts[pObj->Type]--;
1956 pNtk->nObjs--;
1957 Abc_ObjRecycle( pObj );
1958 continue;
1959 }
1960 }
1961 Vec_PtrWriteEntry( pNtk->vPos, m++, pObj );
1962 }
1963 Vec_PtrWriteEntry( pNtk->vCos, k++, pObj );
1964 }
1965 Vec_PtrShrink( pNtk->vPos, m );
1966 Vec_PtrShrink( pNtk->vCos, k );
1967
1968 // filter PIs
1969 k = m = 0;
1970 Abc_NtkForEachCi( pNtk, pObj, i )
1971 {
1972 if ( Abc_ObjIsPi(pObj) )
1973 {
1974 if ( Abc_ObjFanoutNum(pObj) == 0 )
1975 {
1976 pNtk->vObjs->pArray[pObj->Id] = NULL;
1977 pObj->Id = (1<<26)-1;
1978 pNtk->nObjCounts[pObj->Type]--;
1979 pNtk->nObjs--;
1980 Abc_ObjRecycle( pObj );
1981 continue;
1982 }
1983 Vec_PtrWriteEntry( pNtk->vPis, m++, pObj );
1984 }
1985 Vec_PtrWriteEntry( pNtk->vCis, k++, pObj );
1986 }
1987 Vec_PtrShrink( pNtk->vPis, m );
1988 Vec_PtrShrink( pNtk->vCis, k );
1989
1990 return Abc_NtkDup( pNtk );
1991}
1992
2004void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose )
2005{
2006 Abc_Obj_t * pObj, * pConst0, * pFaninNew;
2007 int i, Counter = 0;
2008 assert( Vec_PtrSize(vCexes) == Abc_NtkPoNum(pNtk) );
2009 pConst0 = Abc_ObjNot( Abc_AigConst1(pNtk) );
2010 Abc_NtkForEachPo( pNtk, pObj, i )
2011 {
2012 if ( Vec_PtrEntry( vCexes, i ) == NULL )
2013 continue;
2014 Counter++;
2015 pFaninNew = Abc_ObjNotCond( pConst0, Abc_ObjFaninC0(pObj) );
2016 Abc_ObjPatchFanin( pObj, Abc_ObjFanin0(pObj), pFaninNew );
2017 assert( Abc_ObjChild0(pObj) == pConst0 );
2018 // if a PO is driven by a latch, they have the same name...
2019// if ( Abc_ObjIsBo(pObj) )
2020// Nm_ManDeleteIdName( pNtk->pManName, Abc_ObjId(pObj) );
2021 }
2022 if ( fVerbose )
2023 printf( "Logic cones of %d POs have been replaced by constant 0.\n", Counter );
2024 Counter = Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
2025// printf( "Cleanup removed %d nodes.\n", Counter );
2026}
2027
2039void Abc_NtkDropOneOutput( Abc_Ntk_t * pNtk, int iOutput, int fSkipSweep, int fUseConst1 )
2040{
2041 Abc_Obj_t * pObj, * pConst0, * pFaninNew;
2042 pObj = Abc_NtkPo( pNtk, iOutput );
2043 if ( Abc_ObjFanin0(pObj) == Abc_AigConst1(pNtk) )
2044 {
2045 if ( !Abc_ObjFaninC0(pObj) ^ fUseConst1 )
2046 Abc_ObjXorFaninC( pObj, 0 );
2047 return;
2048 }
2049 pConst0 = Abc_ObjNotCond( Abc_AigConst1(pNtk), !fUseConst1 );
2050 pFaninNew = Abc_ObjNotCond( pConst0, Abc_ObjFaninC0(pObj) );
2051 Abc_ObjPatchFanin( pObj, Abc_ObjFanin0(pObj), pFaninNew );
2052 assert( Abc_ObjChild0(pObj) == pConst0 );
2053 if ( fSkipSweep )
2054 return;
2055 Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
2056}
2057
2069void Abc_NtkSwapOneOutput( Abc_Ntk_t * pNtk, int iOutput )
2070{
2071 Abc_Obj_t * pObj1, * pObj2;
2072 Abc_Obj_t * pChild1Old, * pChild2Old;
2073 Abc_Obj_t * pChild1, * pChild2;
2074 if ( iOutput == 0 )
2075 return;
2076 pObj1 = Abc_NtkPo( pNtk, 0 );
2077 pObj2 = Abc_NtkPo( pNtk, iOutput );
2078 if ( Abc_ObjFanin0(pObj1) == Abc_ObjFanin0(pObj2) )
2079 {
2080 if ( Abc_ObjFaninC0(pObj1) ^ Abc_ObjFaninC0(pObj2) )
2081 {
2082 Abc_ObjXorFaninC( pObj1, 0 );
2083 Abc_ObjXorFaninC( pObj2, 0 );
2084 }
2085 return;
2086 }
2087 pChild1Old = Abc_ObjChild0( pObj1 );
2088 pChild2Old = Abc_ObjChild0( pObj2 );
2089 pChild1 = Abc_ObjNotCond( pChild1Old, Abc_ObjFaninC0(pObj2) );
2090 pChild2 = Abc_ObjNotCond( pChild2Old, Abc_ObjFaninC0(pObj1) );
2091 Abc_ObjPatchFanin( pObj1, Abc_ObjFanin0(pObj1), pChild2 );
2092 Abc_ObjPatchFanin( pObj2, Abc_ObjFanin0(pObj2), pChild1 );
2093 assert( Abc_ObjChild0(pObj1) == pChild2Old );
2094 assert( Abc_ObjChild0(pObj2) == pChild1Old );
2095}
2096
2108void Abc_NtkRemovePo( Abc_Ntk_t * pNtk, int iOutput, int fRemoveConst0 )
2109{
2110 Abc_Obj_t * pObj = Abc_NtkPo(pNtk, iOutput);
2111 if ( Abc_ObjFanin0(pObj) == Abc_AigConst1(pNtk) && Abc_ObjFaninC0(pObj) == fRemoveConst0 )
2112 Abc_NtkDeleteObj( pObj );
2113}
2114
2126Vec_Int_t * Abc_NtkReadSignalPerm2( char * pFileName, int nSignals )
2127{
2128 char Buffer[1000];
2129 FILE * pFile;
2130 Vec_Int_t * vSignals;
2131 int iFlop = -1;
2132 pFile = fopen( pFileName, "rb" );
2133 if ( pFile == NULL )
2134 {
2135 printf( "Cannot open input file \"%s\".\n", pFileName );
2136 return NULL;
2137 }
2138 vSignals = Vec_IntAlloc( nSignals );
2139 while ( fgets( Buffer, 1000, pFile ) != NULL )
2140 {
2141 if ( Buffer[0] == ' ' || Buffer[0] == '\r' || Buffer[0] == '\n' )
2142 continue;
2143 iFlop = atoi( Buffer );
2144 if ( iFlop < 0 || iFlop >= nSignals )
2145 {
2146 printf( "The zero-based signal ID (%d) is out of range.\n", iFlop );
2147 fclose( pFile );
2148 Vec_IntFree( vSignals );
2149 return NULL;
2150 }
2151 Vec_IntPush( vSignals, iFlop );
2152 }
2153 fclose( pFile );
2154 if ( Vec_IntSize(vSignals) != nSignals )
2155 {
2156 printf( "The number of indexes read in from file (%d) is different from the number of signals in the circuit (%d).\n", Vec_IntSize(vSignals), nSignals );
2157 Vec_IntFree( vSignals );
2158 return NULL;
2159 }
2160 return vSignals;
2161}
2162
2163Vec_Int_t * Abc_NtkReadSignalPerm( char * pFileName, int nSignals )
2164{
2165 int Num = -1;
2166 Vec_Int_t * vSignals;
2167 FILE * pFile = fopen( pFileName, "rb" );
2168 if ( pFile == NULL )
2169 {
2170 printf( "Cannot open input file \"%s\".\n", pFileName );
2171 return NULL;
2172 }
2173 vSignals = Vec_IntAlloc( nSignals );
2174 while ( fscanf( pFile, "%d", &Num ) == 1 )
2175 {
2176 if ( Num <= 0 || Num > nSignals )
2177 {
2178 printf( "The one-based signal ID (%d) is out of range (%d).\n", Num, nSignals );
2179 fclose( pFile );
2180 Vec_IntFree( vSignals );
2181 return NULL;
2182 }
2183 Vec_IntPush( vSignals, Num-1 );
2184 }
2185 fclose( pFile );
2186 if ( Vec_IntSize(vSignals) != nSignals )
2187 {
2188 printf( "The number of indexes read in from file (%d) is different from the number of signals in the circuit (%d).\n", Vec_IntSize(vSignals), nSignals );
2189 Vec_IntFree( vSignals );
2190 return NULL;
2191 }
2192 return vSignals;
2193}
2194
2206void Abc_NtkPermute( Abc_Ntk_t * pNtk, int fInputs, int fOutputs, int fFlops, char * pInPermFile, char * pOutPermFile, char * pFlopPermFile )
2207{
2208 Abc_Obj_t * pTemp;
2209 Vec_Int_t * vInputs, * vOutputs, * vFlops, * vTemp;
2210 int i, k, Entry;
2211 // start permutation arrays
2212 if ( pInPermFile )
2213 {
2214 vInputs = Abc_NtkReadSignalPerm( pInPermFile, Abc_NtkPiNum(pNtk) );
2215 if ( vInputs == NULL )
2216 return;
2217 fInputs = 1;
2218 }
2219 else
2220 vInputs = Vec_IntStartNatural( Abc_NtkPiNum(pNtk) );
2221 if ( pOutPermFile )
2222 {
2223 vOutputs = Abc_NtkReadSignalPerm( pOutPermFile, Abc_NtkPoNum(pNtk) );
2224 if ( vOutputs == NULL )
2225 return;
2226 fOutputs = 1;
2227 }
2228 else
2229 vOutputs = Vec_IntStartNatural( Abc_NtkPoNum(pNtk) );
2230 if ( pFlopPermFile )
2231 {
2232 vFlops = Abc_NtkReadSignalPerm( pFlopPermFile, Abc_NtkLatchNum(pNtk) );
2233 if ( vFlops == NULL )
2234 return;
2235 fFlops = 1;
2236 }
2237 else
2238 vFlops = Vec_IntStartNatural( Abc_NtkLatchNum(pNtk) );
2239 // permute inputs
2240 Vec_Ptr_t * vCis = Vec_PtrDup(pNtk->vCis);
2241 Vec_Ptr_t * vCos = Vec_PtrDup(pNtk->vCos);
2242 Vec_Ptr_t * vFfs = Vec_PtrDup(pNtk->vBoxes);
2243 if ( fInputs )
2244 for ( i = 0; i < Abc_NtkPiNum(pNtk); i++ )
2245 {
2246 if ( pInPermFile )
2247 {
2248 k = Vec_IntEntry( vInputs, i );
2249 pTemp = (Abc_Obj_t *)Vec_PtrEntry( vCis, k );
2250 Vec_PtrWriteEntry( pNtk->vPis, i, pTemp );
2251 Vec_PtrWriteEntry( pNtk->vCis, i, pTemp );
2252 }
2253 else
2254 {
2255 k = rand() % Abc_NtkPiNum(pNtk);
2256 // swap indexes
2257 Entry = Vec_IntEntry( vInputs, i );
2258 Vec_IntWriteEntry( vInputs, i, Vec_IntEntry(vInputs, k) );
2259 Vec_IntWriteEntry( vInputs, k, Entry );
2260 // swap PIs
2261 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vPis, i );
2262 Vec_PtrWriteEntry( pNtk->vPis, i, Vec_PtrEntry(pNtk->vPis, k) );
2263 Vec_PtrWriteEntry( pNtk->vPis, k, pTemp );
2264 // swap CIs
2265 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCis, i );
2266 Vec_PtrWriteEntry( pNtk->vCis, i, Vec_PtrEntry(pNtk->vCis, k) );
2267 Vec_PtrWriteEntry( pNtk->vCis, k, pTemp );
2268 }
2269//printf( "Swapping PIs %d and %d.\n", i, k );
2270 }
2271 // permute outputs
2272 if ( fOutputs )
2273 for ( i = 0; i < Abc_NtkPoNum(pNtk); i++ )
2274 {
2275 if ( pOutPermFile )
2276 {
2277 k = Vec_IntEntry( vOutputs, i );
2278 pTemp = (Abc_Obj_t *)Vec_PtrEntry( vCos, k );
2279 Vec_PtrWriteEntry( pNtk->vPos, i, pTemp );
2280 Vec_PtrWriteEntry( pNtk->vCos, i, pTemp );
2281 }
2282 else
2283 {
2284 k = rand() % Abc_NtkPoNum(pNtk);
2285 // swap indexes
2286 Entry = Vec_IntEntry( vOutputs, i );
2287 Vec_IntWriteEntry( vOutputs, i, Vec_IntEntry(vOutputs, k) );
2288 Vec_IntWriteEntry( vOutputs, k, Entry );
2289 // swap POs
2290 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vPos, i );
2291 Vec_PtrWriteEntry( pNtk->vPos, i, Vec_PtrEntry(pNtk->vPos, k) );
2292 Vec_PtrWriteEntry( pNtk->vPos, k, pTemp );
2293 // swap COs
2294 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCos, i );
2295 Vec_PtrWriteEntry( pNtk->vCos, i, Vec_PtrEntry(pNtk->vCos, k) );
2296 Vec_PtrWriteEntry( pNtk->vCos, k, pTemp );
2297 }
2298//printf( "Swapping POs %d and %d.\n", i, k );
2299 }
2300 // permute flops
2301 assert( Abc_NtkBoxNum(pNtk) == Abc_NtkLatchNum(pNtk) );
2302 if ( fFlops )
2303 for ( i = 0; i < Abc_NtkLatchNum(pNtk); i++ )
2304 {
2305 if ( pFlopPermFile )
2306 {
2307 k = Vec_IntEntry( vFlops, i );
2308 pTemp = (Abc_Obj_t *)Vec_PtrEntry( vFfs, k );
2309 Vec_PtrWriteEntry( pNtk->vBoxes, i, pTemp );
2310 pTemp = (Abc_Obj_t *)Vec_PtrEntry( vCis, Abc_NtkPiNum(pNtk)+k );
2311 Vec_PtrWriteEntry( pNtk->vCis, Abc_NtkPiNum(pNtk)+i, pTemp );
2312 pTemp = (Abc_Obj_t *)Vec_PtrEntry( vCos, Abc_NtkPoNum(pNtk)+k );
2313 Vec_PtrWriteEntry( pNtk->vCos, Abc_NtkPoNum(pNtk)+i, pTemp );
2314 }
2315 else
2316 {
2317 k = rand() % Abc_NtkLatchNum(pNtk);
2318 // swap indexes
2319 Entry = Vec_IntEntry( vFlops, i );
2320 Vec_IntWriteEntry( vFlops, i, Vec_IntEntry(vFlops, k) );
2321 Vec_IntWriteEntry( vFlops, k, Entry );
2322 // swap flops
2323 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vBoxes, i );
2324 Vec_PtrWriteEntry( pNtk->vBoxes, i, Vec_PtrEntry(pNtk->vBoxes, k) );
2325 Vec_PtrWriteEntry( pNtk->vBoxes, k, pTemp );
2326 // swap CIs
2327 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCis, Abc_NtkPiNum(pNtk)+i );
2328 Vec_PtrWriteEntry( pNtk->vCis, Abc_NtkPiNum(pNtk)+i, Vec_PtrEntry(pNtk->vCis, Abc_NtkPiNum(pNtk)+k) );
2329 Vec_PtrWriteEntry( pNtk->vCis, Abc_NtkPiNum(pNtk)+k, pTemp );
2330 // swap COs
2331 pTemp = (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCos, Abc_NtkPoNum(pNtk)+i );
2332 Vec_PtrWriteEntry( pNtk->vCos, Abc_NtkPoNum(pNtk)+i, Vec_PtrEntry(pNtk->vCos, Abc_NtkPoNum(pNtk)+k) );
2333 Vec_PtrWriteEntry( pNtk->vCos, Abc_NtkPoNum(pNtk)+k, pTemp );
2334 }
2335
2336//printf( "Swapping flops %d and %d.\n", i, k );
2337 }
2338 Vec_PtrFree(vCis);
2339 Vec_PtrFree(vCos);
2340 Vec_PtrFree(vFfs);
2341 // invert arrays
2342 vInputs = Vec_IntInvert( vTemp = vInputs, -1 );
2343 Vec_IntFree( vTemp );
2344 vOutputs = Vec_IntInvert( vTemp = vOutputs, -1 );
2345 Vec_IntFree( vTemp );
2346 vFlops = Vec_IntInvert( vTemp = vFlops, -1 );
2347 Vec_IntFree( vTemp );
2348 // pack the results into the output array
2349 Vec_IntFreeP( &pNtk->vObjPerm );
2350 pNtk->vObjPerm = Vec_IntAlloc( Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk) + Abc_NtkLatchNum(pNtk) );
2351 Vec_IntForEachEntry( vInputs, Entry, i )
2352 Vec_IntPush( pNtk->vObjPerm, Entry );
2353 Vec_IntForEachEntry( vOutputs, Entry, i )
2354 Vec_IntPush( pNtk->vObjPerm, Entry );
2355 Vec_IntForEachEntry( vFlops, Entry, i )
2356 Vec_IntPush( pNtk->vObjPerm, Entry );
2357 // cleanup
2358 Vec_IntFree( vInputs );
2359 Vec_IntFree( vOutputs );
2360 Vec_IntFree( vFlops );
2361}
2362
2375{
2376 int Diff = Abc_ObjFanoutNum(*pp2) - Abc_ObjFanoutNum(*pp1);
2377 if ( Diff < 0 )
2378 return -1;
2379 if ( Diff > 0 )
2380 return 1;
2381 Diff = strcmp( Abc_ObjName(*pp1), Abc_ObjName(*pp2) );
2382 if ( Diff < 0 )
2383 return -1;
2384 if ( Diff > 0 )
2385 return 1;
2386 return 0;
2387}
2389{
2390 Abc_Obj_t * pNode; int i;
2391 qsort( (void *)Vec_PtrArray(pNtk->vPis), (size_t)Vec_PtrSize(pNtk->vPis), sizeof(Abc_Obj_t *),
2392 (int (*)(const void *, const void *)) Abc_NodeCompareByFanoutCount );
2393 Vec_PtrClear( pNtk->vCis );
2394 Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vPis, pNode, i )
2395 Vec_PtrPush( pNtk->vCis, pNode );
2396}
2397
2410{
2411 Vec_Ptr_t * vTemp, * vTemp2, * vLatch;
2412 int i, * pInputs, * pOutputs, * pFlops;
2413 if ( pNtk->vObjPerm == NULL )
2414 {
2415 printf( "Abc_NtkUnpermute(): Initial permutation is not available.\n" );
2416 return;
2417 }
2418 assert( Abc_NtkBoxNum(pNtk) == Abc_NtkLatchNum(pNtk) );
2419 // get reverve permutation
2420 pInputs = Vec_IntArray( pNtk->vObjPerm );
2421 pOutputs = pInputs + Abc_NtkPiNum(pNtk);
2422 pFlops = pOutputs + Abc_NtkPoNum(pNtk);
2423 // create new PI array
2424 vTemp = Vec_PtrAlloc( Abc_NtkPiNum(pNtk) );
2425 for ( i = 0; i < Abc_NtkPiNum(pNtk); i++ )
2426 Vec_PtrPush( vTemp, Abc_NtkPi(pNtk, pInputs[i]) );
2427 Vec_PtrFreeP( &pNtk->vPis );
2428 pNtk->vPis = vTemp;
2429 // create new PO array
2430 vTemp = Vec_PtrAlloc( Abc_NtkPoNum(pNtk) );
2431 for ( i = 0; i < Abc_NtkPoNum(pNtk); i++ )
2432 Vec_PtrPush( vTemp, Abc_NtkPo(pNtk, pOutputs[i]) );
2433 Vec_PtrFreeP( &pNtk->vPos );
2434 pNtk->vPos = vTemp;
2435 // create new CI/CO arrays
2436 vTemp = Vec_PtrDup( pNtk->vPis );
2437 vTemp2 = Vec_PtrDup( pNtk->vPos );
2438 vLatch = Vec_PtrAlloc( Abc_NtkLatchNum(pNtk) );
2439 for ( i = 0; i < Abc_NtkLatchNum(pNtk); i++ )
2440 {
2441//printf( "Setting flop %d to be %d.\n", i, pFlops[i] );
2442 Vec_PtrPush( vTemp, Abc_NtkCi(pNtk, Abc_NtkPiNum(pNtk) + pFlops[i]) );
2443 Vec_PtrPush( vTemp2, Abc_NtkCo(pNtk, Abc_NtkPoNum(pNtk) + pFlops[i]) );
2444 Vec_PtrPush( vLatch, Abc_NtkBox(pNtk, pFlops[i]) );
2445 }
2446 Vec_PtrFreeP( &pNtk->vCis );
2447 Vec_PtrFreeP( &pNtk->vCos );
2448 Vec_PtrFreeP( &pNtk->vBoxes );
2449 pNtk->vCis = vTemp;
2450 pNtk->vCos = vTemp2;
2451 pNtk->vBoxes = vLatch;
2452 // cleanup
2453 Vec_IntFreeP( &pNtk->vObjPerm );
2454}
2455
2467Abc_Ntk_t * Abc_NtkNodeDup( Abc_Ntk_t * pNtkInit, int nLimit, int fVerbose )
2468{
2469 Vec_Ptr_t * vNodes, * vFanouts;
2470 Abc_Ntk_t * pNtk;
2471 Abc_Obj_t * pObj, * pObjNew, * pFanin, * pFanout;
2472 int i, k;
2473 pNtk = Abc_NtkDup( pNtkInit );
2474 vNodes = Vec_PtrAlloc( 100 );
2475 vFanouts = Vec_PtrAlloc( 100 );
2476 do
2477 {
2478 Vec_PtrClear( vNodes );
2479 Abc_NtkForEachNode( pNtk, pObj, i )
2480 if ( Abc_ObjFanoutNum(pObj) >= nLimit )
2481 Vec_PtrPush( vNodes, pObj );
2482 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2483 {
2484 pObjNew = Abc_NtkDupObj( pNtk, pObj, 0 );
2485 Abc_ObjForEachFanin( pObj, pFanin, k )
2486 Abc_ObjAddFanin( pObjNew, pFanin );
2487 Abc_NodeCollectFanouts( pObj, vFanouts );
2488 Vec_PtrShrink( vFanouts, nLimit / 2 );
2489 Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, k )
2490 Abc_ObjPatchFanin( pFanout, pObj, pObjNew );
2491 }
2492 if ( fVerbose )
2493 printf( "Duplicated %d nodes.\n", Vec_PtrSize(vNodes) );
2494 }
2495 while ( Vec_PtrSize(vNodes) > 0 );
2496 Vec_PtrFree( vFanouts );
2497 Vec_PtrFree( vNodes );
2498 return pNtk;
2499}
2500
2513{
2514 int i, k, nObjBeg;
2515 char * pSop = (char *)Vec_PtrEntry(vSops, 0);
2517 pNtk->pName = Extra_UtilStrsav( pName );
2518 for ( k = 0; pSop[k] != ' '; k++ )
2519 Abc_NtkCreatePi( pNtk );
2520 nObjBeg = Abc_NtkObjNumMax(pNtk);
2521 Vec_PtrForEachEntry( char *, vSops, pSop, i )
2522 {
2523 Abc_Obj_t * pObj = Abc_NtkCreateNode( pNtk );
2524 pObj->pData = Abc_SopRegister( (Mem_Flex_t*)pNtk->pManFunc, pSop );
2525 for ( k = 0; pSop[k] != ' '; k++ )
2526 Abc_ObjAddFanin( pObj, Abc_NtkCi(pNtk, k) );
2527 }
2528 for ( i = 0; i < Vec_PtrSize(vSops); i++ )
2529 {
2530 Abc_Obj_t * pObj = Abc_NtkObj( pNtk, nObjBeg + i );
2531 Abc_Obj_t * pObjPo = Abc_NtkCreatePo( pNtk );
2532 Abc_ObjAddFanin( pObjPo, pObj );
2533 }
2534 Abc_NtkAddDummyPiNames( pNtk );
2535 Abc_NtkAddDummyPoNames( pNtk );
2536 return pNtk;
2537}
2538
2550Abc_Ntk_t * Abc_NtkCreateFromGias( char * pName, Vec_Ptr_t * vGias, Gia_Man_t * pMulti )
2551{
2552 Gia_Man_t * pGia = pMulti ? pMulti : (Gia_Man_t *)Vec_PtrEntry(vGias, 0);
2554 Abc_Obj_t * pAbcObj, * pAbcObjPo;
2555 Gia_Obj_t * pObj; int i, k;
2556 pNtk->pName = Extra_UtilStrsav( pName );
2557 for ( k = 0; k < Gia_ManCiNum(pGia); k++ )
2558 Abc_NtkCreatePi( pNtk );
2559 if ( pMulti )
2560 {
2561 Gia_ManCleanValue(pGia);
2562 Gia_ManForEachCi( pGia, pObj, k )
2563 pObj->Value = Abc_ObjId( Abc_NtkCi(pNtk, k) );
2564 Gia_ManForEachAnd( pGia, pObj, k )
2565 {
2566 Abc_Obj_t * pAbcObj0 = Abc_NtkObj( pNtk, Gia_ObjFanin0(pObj)->Value );
2567 Abc_Obj_t * pAbcObj1 = Abc_NtkObj( pNtk, Gia_ObjFanin1(pObj)->Value );
2568 pAbcObj0 = Abc_ObjNotCond( pAbcObj0, Gia_ObjFaninC0(pObj) );
2569 pAbcObj1 = Abc_ObjNotCond( pAbcObj1, Gia_ObjFaninC1(pObj) );
2570 pAbcObj = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAbcObj0, pAbcObj1 );
2571 pObj->Value = Abc_ObjId( pAbcObj );
2572 }
2573 Gia_ManForEachCo( pGia, pObj, k )
2574 {
2575 //pObj = Gia_ManCo(pGia, 0);
2576 if ( Gia_ObjFaninId0p(pGia, pObj) == 0 )
2577 pAbcObj = Abc_ObjNot( Abc_AigConst1(pNtk) );
2578 else
2579 pAbcObj = Abc_NtkObj( pNtk, Gia_ObjFanin0(pObj)->Value );
2580 pAbcObj = Abc_ObjNotCond( pAbcObj, Gia_ObjFaninC0(pObj) );
2581 pAbcObjPo = Abc_NtkCreatePo( pNtk );
2582 Abc_ObjAddFanin( pAbcObjPo, pAbcObj );
2583 }
2584 }
2585 else
2586 {
2587 Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
2588 {
2589 assert( Gia_ManCoNum(pGia) == 1 );
2590 Gia_ManCleanValue(pGia);
2591 Gia_ManForEachCi( pGia, pObj, k )
2592 pObj->Value = Abc_ObjId( Abc_NtkCi(pNtk, k) );
2593 Gia_ManForEachAnd( pGia, pObj, k )
2594 {
2595 Abc_Obj_t * pAbcObj0 = Abc_NtkObj( pNtk, Gia_ObjFanin0(pObj)->Value );
2596 Abc_Obj_t * pAbcObj1 = Abc_NtkObj( pNtk, Gia_ObjFanin1(pObj)->Value );
2597 pAbcObj0 = Abc_ObjNotCond( pAbcObj0, Gia_ObjFaninC0(pObj) );
2598 pAbcObj1 = Abc_ObjNotCond( pAbcObj1, Gia_ObjFaninC1(pObj) );
2599 pAbcObj = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAbcObj0, pAbcObj1 );
2600 pObj->Value = Abc_ObjId( pAbcObj );
2601 }
2602 pObj = Gia_ManCo(pGia, 0);
2603 if ( Gia_ObjFaninId0p(pGia, pObj) == 0 )
2604 pAbcObj = Abc_ObjNot( Abc_AigConst1(pNtk) );
2605 else
2606 pAbcObj = Abc_NtkObj( pNtk, Gia_ObjFanin0(pObj)->Value );
2607 pAbcObj = Abc_ObjNotCond( pAbcObj, Gia_ObjFaninC0(pObj) );
2608 pAbcObjPo = Abc_NtkCreatePo( pNtk );
2609 Abc_ObjAddFanin( pAbcObjPo, pAbcObj );
2610 }
2611 }
2612 Abc_NtkAddDummyPiNames( pNtk );
2613 Abc_NtkAddDummyPoNames( pNtk );
2614 return pNtk;
2615}
2616
2617
2621
2622
2624
#define ABC_NUM_STEPS
INCLUDES ///.
Definition abcInt.h:36
void Abc_NtkRemovePo(Abc_Ntk_t *pNtk, int iOutput, int fRemoveConst0)
Definition abcNtk.c:2108
Abc_Ntk_t * Abc_NtkDupDfsNoBarBufs(Abc_Ntk_t *pNtk)
Definition abcNtk.c:578
Abc_Ntk_t * Abc_NtkDupTransformMiter(Abc_Ntk_t *pNtk)
Definition abcNtk.c:669
Abc_Ntk_t * Abc_NtkStartFromWithLatches(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func, int nLatches)
Definition abcNtk.c:224
Abc_Ntk_t * Abc_NtkNodeDup(Abc_Ntk_t *pNtkInit, int nLimit, int fVerbose)
Definition abcNtk.c:2467
Vec_Int_t * Abc_NtkReadSignalPerm(char *pFileName, int nSignals)
Definition abcNtk.c:2163
Abc_Ntk_t * Abc_NtkCreateFromSops(char *pName, Vec_Ptr_t *vSops)
Definition abcNtk.c:2512
Abc_Ntk_t * Abc_NtkCreateFromNode(Abc_Ntk_t *pNtk, Abc_Obj_t *pNode)
Definition abcNtk.c:1260
void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
Abc_Ntk_t * Abc_NtkCreateWithNodes(Vec_Ptr_t *vSop)
Definition abcNtk.c:1374
Abc_Ntk_t * Abc_NtkCreateFromRange(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1298
Abc_Ntk_t * Abc_NtkCreateConeArray(Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots, int fUseAllCis)
Definition abcNtk.c:995
void Abc_NtkPermutePiUsingFanout(Abc_Ntk_t *pNtk)
Definition abcNtk.c:2388
Abc_Ntk_t * Abc_NtkDouble(Abc_Ntk_t *pNtk)
Definition abcNtk.c:725
Abc_Ntk_t * Abc_NtkTrim(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1921
Abc_Ntk_t * Abc_NtkCreateCone(Abc_Ntk_t *pNtk, Abc_Obj_t *pNode, char *pNodeName, int fUseAllCis)
Definition abcNtk.c:925
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
Abc_Ntk_t * Abc_NtkSelectPos(Abc_Ntk_t *pNtkInit, Vec_Int_t *vPoIds)
Definition abcNtk.c:1805
void Abc_NtkAppendToCone(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots)
Definition abcNtk.c:1075
Abc_Ntk_t * Abc_NtkStartRead(char *pName)
Definition abcNtk.c:386
Abc_Ntk_t * Abc_NtkRestrashWithLatches(Abc_Ntk_t *pNtk, int nLatches)
Definition abcNtk.c:634
void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition abcNtk.c:355
int Abc_NodeCompareByFanoutCount(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition abcNtk.c:2374
Abc_Ntk_t * Abc_NtkCreateMffc(Abc_Ntk_t *pNtk, Abc_Obj_t *pNode, char *pNodeName)
Definition abcNtk.c:1128
Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
void Abc_NtkFixNonDrivenNets(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1557
Abc_Ntk_t * Abc_NtkBottom(Abc_Ntk_t *pNtk, int Level)
Definition abcNtk.c:808
Abc_Ntk_t * Abc_NtkMakeOnePo(Abc_Ntk_t *pNtkInit, int Output, int nRange)
Definition abcNtk.c:1857
void Abc_NtkMakeSeq(Abc_Ntk_t *pNtk, int nLatchesToAdd)
Definition abcNtk.c:1729
void Abc_NtkUnpermute(Abc_Ntk_t *pNtk)
Definition abcNtk.c:2409
Vec_Int_t * Abc_NtkReadSignalPerm2(char *pFileName, int nSignals)
Definition abcNtk.c:2126
Abc_Ntk_t * Abc_NtkAttachBottom(Abc_Ntk_t *pNtkTop, Abc_Ntk_t *pNtkBottom)
Definition abcNtk.c:866
void Abc_NtkPermute(Abc_Ntk_t *pNtk, int fInputs, int fOutputs, int fFlops, char *pInPermFile, char *pOutPermFile, char *pFlopPermFile)
Definition abcNtk.c:2206
void Abc_NtkFinalizeRead(Abc_Ntk_t *pNtk)
Definition abcNtk.c:413
void Abc_NtkSwapOneOutput(Abc_Ntk_t *pNtk, int iOutput)
Definition abcNtk.c:2069
Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:157
void Abc_NtkDropOneOutput(Abc_Ntk_t *pNtk, int iOutput, int fSkipSweep, int fUseConst1)
Definition abcNtk.c:2039
Abc_Ntk_t * Abc_NtkDupDfs(Abc_Ntk_t *pNtk)
Definition abcNtk.c:538
void Abc_NtkMakeComb(Abc_Ntk_t *pNtk, int fRemoveLatches)
Definition abcNtk.c:1637
void Abc_NtkDropSatOutputs(Abc_Ntk_t *pNtk, Vec_Ptr_t *vCexes, int fVerbose)
Definition abcNtk.c:2004
Abc_Ntk_t * Abc_NtkCreateTarget(Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots, Vec_Int_t *vValues)
Definition abcNtk.c:1200
Abc_Ntk_t * Abc_NtkAllocBdd(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan, int nVars)
Definition abcNtk.c:99
Abc_Ntk_t * Abc_NtkCreateWithNode(char *pSop)
Definition abcNtk.c:1333
Abc_Ntk_t * Abc_NtkCreateFromGias(char *pName, Vec_Ptr_t *vGias, Gia_Man_t *pMulti)
Definition abcNtk.c:2550
Abc_Ntk_t * Abc_NtkStartFromNoLatches(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:301
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_NtkForEachNet(pNtk, pNet, i)
Definition abc.h:461
ABC_DLL Abc_Obj_t * Abc_NodeStrash(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode, int fRecord)
Definition abcStrash.c:468
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:735
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL Vec_Ptr_t * Abc_NtkDfs2(Abc_Ntk_t *pNtk)
Definition abcDfs.c:127
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
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_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:706
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition abcSweep.c:478
ABC_DLL void Abc_DesFree(Abc_Des_t *p, Abc_Ntk_t *pNtk)
Definition abcLib.c:94
ABC_DLL void Abc_NtkTransferPhases(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk)
Definition abcUtil.c:2924
ABC_DLL void Abc_ObjRecycle(Abc_Obj_t *pObj)
Definition abcObj.c:77
ABC_DLL Gia_Man_t * Abc_NtkClpGia(Abc_Ntk_t *pNtk)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition abcDfs.c:82
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
ABC_DLL void Abc_NodeFreeNames(Vec_Ptr_t *vNames)
Definition abcNames.c:264
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
@ ABC_OBJ_NODE
Definition abc.h:94
@ ABC_OBJ_BI
Definition abc.h:91
@ ABC_OBJ_BO
Definition abc.h:92
@ ABC_OBJ_PI
Definition abc.h:89
@ ABC_OBJ_PO
Definition abc.h:90
ABC_DLL void Abc_ManTimeDup(Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew)
Definition abcTiming.c:573
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL void Abc_NtkDeleteObj_rec(Abc_Obj_t *pObj, int fOnlyNodes)
Definition abcObj.c:278
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1647
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
ABC_DLL Abc_Aig_t * Abc_AigAlloc(Abc_Ntk_t *pNtk)
FUNCTION DECLARATIONS ///.
Definition abcAig.c:128
Abc_NtkType_t
INCLUDES ///.
Definition abc.h:54
@ ABC_NTK_LOGIC
Definition abc.h:57
@ ABC_NTK_STRASH
Definition abc.h:58
@ ABC_NTK_NETLIST
Definition abc.h:56
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition abcFanio.c:292
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
ABC_DLL void Abc_NtkTimeInitialize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkOld)
Definition abcTiming.c:343
ABC_DLL void Abc_ObjDeleteFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:111
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition abcAig.c:194
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
Definition abc.h:503
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL void Abc_NtkDeleteObjPo(Abc_Obj_t *pObj)
Definition abcObj.c:249
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL Abc_Obj_t * Abc_NtkCreateObj(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
Definition abcObj.c:109
ABC_DLL Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:151
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition abcFanio.c:172
Abc_NtkFunc_t
Definition abc.h:63
@ ABC_FUNC_SOP
Definition abc.h:65
@ ABC_FUNC_BDD
Definition abc.h:66
@ ABC_FUNC_AIG
Definition abc.h:67
ABC_DLL Vec_Ptr_t * Abc_NodeGetFakeNames(int nNames)
Definition abcNames.c:228
ABC_DLL void Abc_AigFree(Abc_Aig_t *pMan)
Definition abcAig.c:165
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition abc.h:498
ABC_DLL void Abc_ManTimeStop(Abc_ManTime_t *p)
Definition abcTiming.c:547
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition abcUtil.c:76
ABC_DLL int Abc_NodeRef_rec(Abc_Obj_t *pNode)
Definition abcRefs.c:241
ABC_DLL int Abc_NodeDeref_rec(Abc_Obj_t *pNode)
Definition abcRefs.c:215
ABC_DLL float Abc_NodeReadArrivalWorst(Abc_Obj_t *pNode)
Definition abcTiming.c:111
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:515
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
ABC_DLL void Abc_NodeMffcConeSupp(Abc_Obj_t *pNode, Vec_Ptr_t *vCone, Vec_Ptr_t *vSupp)
Definition abcRefs.c:299
ABC_DLL Abc_Obj_t * Abc_NtkDupBox(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
Definition abcObj.c:415
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Cube * p
Definition exorList.c:222
void Extra_StopManager(DdManager *dd)
char * Extra_UtilStrsav(const char *s)
char * Extra_FileNameGeneric(char *FileName)
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
Vec_Str_t * Gia_ManComputeRange(Gia_Man_t *p)
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ManCleanValue(Gia_Man_t *p)
Definition giaUtil.c:351
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
void Hop_ManStop(Hop_Man_t *p)
Definition hopMan.c:84
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
Definition hopMan.c:45
int Mem_FixedReadMemUsage(Mem_Fixed_t *p)
Definition mem.c:293
void Mem_FixedStop(Mem_Fixed_t *p, int fVerbose)
Definition mem.c:139
Mem_Flex_t * Mem_FlexStart()
Definition mem.c:327
void Mem_StepStop(Mem_Step_t *p, int fVerbose)
Definition mem.c:526
Mem_Step_t * Mem_StepStart(int nSteps)
Definition mem.c:490
Mem_Fixed_t * Mem_FixedStart(int nEntrySize)
FUNCTION DEFINITIONS ///.
Definition mem.c:100
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition mem.c:359
int Mem_StepReadMemUsage(Mem_Step_t *p)
Definition mem.c:609
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
float Mio_LibraryReadDelayAigNode(Mio_Library_t *pLib)
Definition mioApi.c:64
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void Nm_ManFree(Nm_Man_t *p)
Definition nmApi.c:76
int Nm_ManFindIdByNameTwoTypes(Nm_Man_t *p, char *pName, int Type1, int Type2)
Definition nmApi.c:239
Nm_Man_t * Nm_ManCreate(int nSize)
MACRO DEFINITIONS ///.
Definition nmApi.c:45
Abc_NtkType_t ntkType
Definition abc.h:156
Vec_Ptr_t * vAttrs
Definition abc.h:214
Vec_Ptr_t * vCis
Definition abc.h:165
Vec_Int_t * vLevelsR
Definition abc.h:196
char * pName
Definition abc.h:158
int nBarBufs
Definition abc.h:174
Vec_Ptr_t * vCos
Definition abc.h:166
Abc_Cex_t * pSeqModel
Definition abc.h:199
int nTravIds
Definition abc.h:187
Abc_Des_t * pDesign
Definition abc.h:180
float * pLutTimes
Definition abc.h:210
char * pWLoadUsed
Definition abc.h:209
int nConstrs
Definition abc.h:173
Vec_Int_t * vGates
Definition abc.h:207
float AndGateDelay
Definition abc.h:194
Vec_Ptr_t * vPos
Definition abc.h:164
Vec_Ptr_t * vBoxes
Definition abc.h:168
int nObjs
Definition abc.h:172
Vec_Int_t * vOrigNodeIds
Definition abc.h:217
Mem_Step_t * pMmStep
Definition abc.h:190
Vec_Int_t * vNameIds
Definition abc.h:215
Abc_Ntk_t * pExdc
Definition abc.h:201
int nObjCounts[ABC_OBJ_NUMBER]
Definition abc.h:171
void * pSCLib
Definition abc.h:206
Vec_Int_t * vFins
Definition abc.h:216
Vec_Int_t * vTopo
Definition abc.h:213
Vec_Ptr_t * vPios
Definition abc.h:167
void * pManFunc
Definition abc.h:191
Mem_Fixed_t * pMmObj
Definition abc.h:189
void * pExcare
Definition abc.h:202
Vec_Ptr_t * vOnehots
Definition abc.h:211
int * pModel
Definition abc.h:198
Abc_ManTime_t * pManTime
Definition abc.h:192
Nm_Man_t * pManName
Definition abc.h:160
Abc_Ntk_t * pCopy
Definition abc.h:204
char * pSpec
Definition abc.h:159
Vec_Int_t * vObjPerm
Definition abc.h:212
Vec_Ptr_t * vPis
Definition abc.h:163
Vec_Int_t vTravIds
Definition abc.h:188
int nBarBufs2
Definition abc.h:175
Vec_Ptr_t * vObjs
Definition abc.h:162
Vec_Int_t * vPhases
Definition abc.h:208
Vec_Ptr_t * vSeqModelVec
Definition abc.h:200
Vec_Ptr_t * vLtlProperties
Definition abc.h:169
Abc_NtkFunc_t ntkFunc
Definition abc.h:157
void * pData
Definition abc.h:145
unsigned fMarkC
Definition abc.h:136
Vec_Int_t vFanins
Definition abc.h:143
int Id
Definition abc.h:132
unsigned fMarkB
Definition abc.h:135
Vec_Int_t vFanouts
Definition abc.h:144
Abc_Obj_t * pCopy
Definition abc.h:148
unsigned fMarkA
Definition abc.h:134
unsigned Type
Definition abc.h:133
unsigned Level
Definition abc.h:142
unsigned Value
Definition gia.h:89
Abc_Cex_t * Abc_CexDup(Abc_Cex_t *p, int nRegsNew)
Definition utilCex.c:145
#define assert(ex)
Definition util_old.h:213
char * memset()
int strlen()
int strcmp()
char * sprintf()
@ VEC_ATTR_TOTAL_NUM
Definition vecAtt.h:55
struct Vec_Att_t_ Vec_Att_t
BASIC TYPES ///.
Definition vecAtt.h:62
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
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
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42