ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcLatch.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22
23#ifdef ABC_USE_CUDD
24#include "bdd/extrab/extraBdd.h"
25#endif
26
28
32
36
48int Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot )
49{
50 Abc_Obj_t * pFanin;
51 assert( Abc_ObjIsLatch(pLatch) );
52 if ( pLatch == pLatchRoot )
53 return 1;
54 pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
55 if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
56 return 0;
57 return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
58}
59
72{
73 Abc_Obj_t * pFanin;
74 assert( Abc_ObjIsLatch(pLatch) );
75 pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
76 if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
77 return 0;
78 return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
79}
80
93{
94 Abc_Obj_t * pLatch;
95 int i, Counter;
96 Counter = 0;
97 Abc_NtkForEachLatch( pNtk, pLatch, i )
98 {
99// if ( Abc_NtkLatchIsSelfFeed(pLatch) && Abc_ObjFanoutNum(pLatch) > 1 )
100// printf( "Fanouts = %d.\n", Abc_ObjFanoutNum(pLatch) );
101 Counter += Abc_NtkLatchIsSelfFeed( pLatch );
102 }
103 return Counter;
104}
105
118{
119 Abc_Obj_t * pLatch, * pConst1;
120 int i, Counter;
121 Counter = 0;
122 Abc_NtkForEachLatch( pNtk, pLatch, i )
123 {
124 if ( Abc_NtkLatchIsSelfFeed( pLatch ) )
125 {
126 if ( Abc_NtkIsStrash(pNtk) )
127 pConst1 = Abc_AigConst1(pNtk);
128 else
129 pConst1 = Abc_NtkCreateNodeConst1(pNtk);
130 Abc_ObjPatchFanin( Abc_ObjFanin0(pLatch), Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
131 Counter++;
132 }
133 }
134 return Counter;
135}
136
148void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches )
149{
150 Vec_Ptr_t * vNodes;
151 Abc_Obj_t * pObj, * pFanin, * pFanout;
152 int i, k, nTotal, nDigits;
153 if ( nLatches < 1 )
154 return;
155 nTotal = nLatches * Abc_NtkPiNum(pNtk);
156 nDigits = Abc_Base10Log( nTotal );
157 vNodes = Vec_PtrAlloc( 100 );
158 Abc_NtkForEachPi( pNtk, pObj, i )
159 {
160 Abc_NodeCollectFanouts( pObj, vNodes );
161 for ( pFanin = pObj, k = 0; k < nLatches; k++ )
162 pFanin = Abc_NtkAddLatch( pNtk, pFanin, ABC_INIT_ZERO );
163 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pFanout, k )
164 Abc_ObjPatchFanin( pFanout, pObj, pFanin );
165 }
166 Vec_PtrFree( vNodes );
167 Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
168}
169
182{
183 Vec_Int_t * vValues;
184 Abc_Obj_t * pLatch;
185 int i;
186 vValues = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
187 Abc_NtkForEachLatch( pNtk, pLatch, i )
188 Vec_IntPush( vValues, Abc_LatchIsInit1(pLatch) );
189 return vValues;
190}
191
204{
205 char * pInits;
206 Abc_Obj_t * pLatch;
207 int i;
208 pInits = ABC_ALLOC( char, Abc_NtkLatchNum(pNtk) + 1 );
209 Abc_NtkForEachLatch( pNtk, pLatch, i )
210 {
211 if ( Abc_LatchIsInit0(pLatch) )
212 pInits[i] = '0';
213 else if ( Abc_LatchIsInit1(pLatch) )
214 pInits[i] = '1';
215 else if ( Abc_LatchIsInitDc(pLatch) )
216 pInits[i] = 'x';
217 else
218 assert( 0 );
219 }
220 pInits[i] = 0;
221 return pInits;
222}
223
236{
237 Abc_Obj_t * pLatch;
238 int i;
239 Abc_NtkForEachLatch( pNtk, pLatch, i )
240 pLatch->pData = (void *)(ABC_PTRINT_T)(vValues? (Vec_IntEntry(vValues,i)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
241}
242
255{
256 Abc_Obj_t * pLatchOut, * pLatch, * pLatchIn;
257 pLatchOut = Abc_NtkCreateBo(pNtk);
258 pLatch = Abc_NtkCreateLatch(pNtk);
259 pLatchIn = Abc_NtkCreateBi(pNtk);
260 Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_lo" );
261 Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatch), "_li" );
262 Abc_ObjAddFanin( pLatchOut, pLatch );
263 Abc_ObjAddFanin( pLatch, pLatchIn );
264 if ( pDriver )
265 Abc_ObjAddFanin( pLatchIn, pDriver );
266 pLatch->pData = (void *)Init;
267 return pLatchOut;
268}
269
281void Abc_NtkNodeConvertToMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0, Abc_Obj_t * pMux )
282{
283 assert( Abc_NtkIsLogic(pNtk) );
284 Abc_ObjAddFanin( pMux, pNodeC );
285 Abc_ObjAddFanin( pMux, pNode1 );
286 Abc_ObjAddFanin( pMux, pNode0 );
287 if ( Abc_NtkHasSop(pNtk) )
288 pMux->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, "11- 1\n0-1 1\n" );
289#ifdef ABC_USE_CUDD
290 else if ( Abc_NtkHasBdd(pNtk) )
291 pMux->pData = Cudd_bddIte((DdManager *)pNtk->pManFunc,Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,1),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,2)), Cudd_Ref( (DdNode *)pMux->pData );
292#endif
293 else if ( Abc_NtkHasAig(pNtk) )
295 else
296 assert( 0 );
297}
298
311{
312 Abc_Obj_t * pCtrl, * pLatch, * pMux, * pPi;
314 int i, fFound = 0, Counter;
315 // check if there are latches with DC values
316 Abc_NtkForEachLatch( pNtk, pLatch, i )
317 if ( Abc_LatchIsInitDc(pLatch) )
318 {
319 fFound = 1;
320 break;
321 }
322 if ( !fFound )
323 return;
324 // add control latch
325 pCtrl = Abc_NtkAddLatch( pNtk, Abc_NtkCreateNodeConst1(pNtk), Init );
326 // add fanouts for each latch with DC values
327 Counter = 0;
328 Abc_NtkForEachLatch( pNtk, pLatch, i )
329 {
330 if ( !Abc_LatchIsInitDc(pLatch) )
331 continue;
332 // change latch value
333 pLatch->pData = (void *)Init;
334 // if the latch output has the same name as a PO, rename it
335 if ( Abc_NodeFindCoFanout( Abc_ObjFanout0(pLatch) ) )
336 {
337 Nm_ManDeleteIdName( pLatch->pNtk->pManName, Abc_ObjFanout0(pLatch)->Id );
338 Abc_ObjAssignName( Abc_ObjFanout0(pLatch), Abc_ObjName(pLatch), "_lo" );
339 }
340 // create new PIs
341 pPi = Abc_NtkCreatePi( pNtk );
342 Abc_ObjAssignName( pPi, Abc_ObjName(pLatch), "_pi" );
343 // create a new node and transfer fanout from latch output to the new node
344 pMux = Abc_NtkCreateNode( pNtk );
345 Abc_ObjTransferFanout( Abc_ObjFanout0(pLatch), pMux );
346 // convert the node into a mux
347 Abc_NtkNodeConvertToMux( pNtk, pCtrl, Abc_ObjFanout0(pLatch), pPi, pMux );
348 Counter++;
349 }
350 printf( "The number of converted latches with DC values = %d.\n", Counter );
351}
352
365{
366 Vec_Ptr_t * vResult, * vNames;
367 Vec_Int_t * vNumbers;
368 Abc_Obj_t * pObj;
369 char * pName;
370 int i, k, Num;
371 if ( pNtk->vOnehots == NULL )
372 return NULL;
373 // set register numbers
374 Abc_NtkForEachLatch( pNtk, pObj, i )
375 pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
376 // add the numbers
377 vResult = Vec_PtrAlloc( Vec_PtrSize(pNtk->vOnehots) );
378 Vec_PtrForEachEntry( Vec_Ptr_t *, pNtk->vOnehots, vNames, i )
379 {
380 vNumbers = Vec_IntAlloc( Vec_PtrSize(vNames) );
381 Vec_PtrForEachEntry( char *, vNames, pName, k )
382 {
383 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
384 if ( Num < 0 )
385 continue;
386 pObj = Abc_NtkObj( pNtk, Num );
387 if ( Abc_ObjFaninNum(pObj) != 1 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
388 continue;
389 Vec_IntPush( vNumbers, (int)(ABC_PTRINT_T)pObj->pNext );
390 }
391 if ( Vec_IntSize( vNumbers ) > 1 )
392 {
393 Vec_PtrPush( vResult, vNumbers );
394printf( "Converted %d one-hot registers.\n", Vec_IntSize(vNumbers) );
395 }
396 else
397 Vec_IntFree( vNumbers );
398 }
399 // clean the numbers
400 Abc_NtkForEachLatch( pNtk, pObj, i )
401 pObj->pNext = NULL;
402 return vResult;
403}
404
405
418{
419 Vec_Ptr_t * vNodes;
420 Abc_Ntk_t * pNtkNew;
421 Abc_Obj_t * pObj, * pFanin, * pObjNew, * pObjLiNew, * pObjLoNew;
422 int i, k, nFlops, nStates, iState, pfCompl[32];
423 assert( Abc_NtkIsLogic(pNtk) );
424 nFlops = Abc_NtkLatchNum(pNtk);
425 if ( nFlops == 0 )
426 return Abc_NtkDup( pNtk );
427 if ( nFlops > 16 )
428 {
429 printf( "Cannot re-encode %d flops because it will lead to 2^%d states.\n", nFlops, nFlops );
430 return NULL;
431 }
432 // check if there are latches with DC values
433 iState = 0;
434 Abc_NtkForEachLatch( pNtk, pObj, i )
435 {
436 if ( Abc_LatchIsInitDc(pObj) )
437 {
438 printf( "Cannot process logic network with don't-care init values. Run \"zero\".\n" );
439 return NULL;
440 }
441 if ( Abc_LatchIsInit1(pObj) )
442 iState |= (1 << i);
443 }
444 // transfer logic to SOPs
445 Abc_NtkToSop( pNtk, -1, ABC_INFINITY );
446 // create new network
447 pNtkNew = Abc_NtkStartFromNoLatches( pNtk, pNtk->ntkType, pNtk->ntkFunc );
448 nStates = (1 << nFlops);
449 for ( i = 0; i < nStates; i++ )
450 {
451 pObjNew = Abc_NtkCreateLatch( pNtkNew );
452 pObjLiNew = Abc_NtkCreateBi( pNtkNew );
453 pObjLoNew = Abc_NtkCreateBo( pNtkNew );
454 Abc_ObjAddFanin( pObjNew, pObjLiNew );
455 Abc_ObjAddFanin( pObjLoNew, pObjNew );
456 if ( i == iState )
457 Abc_LatchSetInit1( pObjNew );
458 else
459 Abc_LatchSetInit0( pObjNew );
460 }
461 Abc_NtkAddDummyBoxNames( pNtkNew );
462 assert( Abc_NtkLatchNum(pNtkNew) == nStates );
463 assert( Abc_NtkPiNum(pNtkNew) == Abc_NtkPiNum(pNtk) );
464 assert( Abc_NtkPoNum(pNtkNew) == Abc_NtkPoNum(pNtk) );
465 assert( Abc_NtkCiNum(pNtkNew) == Abc_NtkPiNum(pNtkNew) + nStates );
466 assert( Abc_NtkCoNum(pNtkNew) == Abc_NtkPoNum(pNtkNew) + nStates );
467 assert( Abc_NtkCiNum(pNtk) == Abc_NtkPiNum(pNtk) + nFlops );
468 assert( Abc_NtkCoNum(pNtk) == Abc_NtkPoNum(pNtk) + nFlops );
469 // create hot-to-log transformers
470 for ( i = 0; i < nFlops; i++ )
471 {
472 pObjNew = Abc_NtkCreateNode( pNtkNew );
473 for ( k = 0; k < nStates; k++ )
474 if ( (k >> i) & 1 )
475 Abc_ObjAddFanin( pObjNew, Abc_NtkCi(pNtkNew, Abc_NtkPiNum(pNtkNew)+k) );
476 assert( Abc_ObjFaninNum(pObjNew) == nStates/2 );
477 pObjNew->pData = Abc_SopCreateOr( (Mem_Flex_t *)pNtkNew->pManFunc, nStates/2, NULL );
478 // save the new flop
479 pObj = Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i );
480 pObj->pCopy = pObjNew;
481 }
482 // duplicate the nodes
483 vNodes = Abc_NtkDfs( pNtk, 0 );
484 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
485 {
486 pObj->pCopy = Abc_NtkDupObj( pNtkNew, pObj, 1 );
487 Abc_ObjForEachFanin( pObj, pFanin, k )
488 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
489 }
490 Vec_PtrFree( vNodes );
491 // connect the POs
492 Abc_NtkForEachPo( pNtk, pObj, i )
493 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjNotCond(Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj)) );
494 // write entries into the nodes
495 Abc_NtkForEachCo( pNtk, pObj, i )
496 pObj->pCopy = Abc_ObjNotCond(Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj));
497 // create log-to-hot transformers
498 for ( k = 0; k < nStates; k++ )
499 {
500 pObjNew = Abc_NtkCreateNode( pNtkNew );
501 for ( i = 0; i < nFlops; i++ )
502 {
503 pObj = Abc_NtkCo( pNtk, Abc_NtkPoNum(pNtk) + i );
504 Abc_ObjAddFanin( pObjNew, Abc_ObjRegular(pObj->pCopy) );
505 pfCompl[i] = Abc_ObjIsComplement(pObj->pCopy) ^ !((k >> i) & 1);
506 }
507 pObjNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, nFlops, pfCompl );
508 // connect it to the flop input
509 Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, Abc_NtkPoNum(pNtkNew)+k), pObjNew );
510 }
511 if ( !Abc_NtkCheck( pNtkNew ) )
512 fprintf( stdout, "Abc_NtkConvertOnehot(): Network check has failed.\n" );
513 return pNtkNew;
514}
515
517
518#include "aig/gia/giaAig.h"
519
521
522
534Aig_Man_t * Abc_NtkRetimeWithClassesAig( Aig_Man_t * pMan, Vec_Int_t * vClasses, Vec_Int_t ** pvClasses, int fVerbose )
535{
536 Aig_Man_t * pManNew;
537 Gia_Man_t * pGia, * pGiaNew;
538 pGia = Gia_ManFromAigSimple( pMan );
539 assert( Gia_ManRegNum(pGia) == Vec_IntSize(vClasses) );
540 pGia->vFlopClasses = vClasses;
541 pGiaNew = Gia_ManRetimeForward( pGia, 10, fVerbose );
542 *pvClasses = pGiaNew->vFlopClasses;
543 pGiaNew->vFlopClasses = NULL;
544 pManNew = Gia_ManToAig( pGiaNew, 0 );
545 Gia_ManStop( pGiaNew );
546 Gia_ManStop( pGia );
547 return pManNew;
548}
549
561Abc_Ntk_t * Abc_NtkRetimeWithClassesNtk( Abc_Ntk_t * pNtk, Vec_Int_t * vClasses, Vec_Int_t ** pvClasses, int fVerbose )
562{
563 extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
564 extern Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
565 Abc_Ntk_t * pNtkAig, * pNtkAigRet, * pNtkRes;
566 Aig_Man_t * pMan, * pManNew;
567 pNtkAig = Abc_NtkStrash( pNtk, 0, 1, 0 );
568 pMan = Abc_NtkToDar( pNtkAig, 0, 1 );
569 pManNew = Abc_NtkRetimeWithClassesAig( pMan, vClasses, pvClasses, fVerbose );
570 pNtkAigRet = Abc_NtkFromDarSeqSweep( pNtkAig, pManNew );
571 pNtkRes = Abc_NtkToLogic( pNtkAigRet );
572 Abc_NtkDelete( pNtkAigRet );
573 Abc_NtkDelete( pNtkAig );
574 Aig_ManStop( pManNew );
575 Aig_ManStop( pMan );
576 return pNtkRes;
577}
578
590void Abc_NtkTransformBack( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, Vec_Ptr_t * vControls, Vec_Int_t * vClasses )
591{
592 Abc_Obj_t * pObj, * pNodeNew, * pCtrl, * pDriver;
593 int i, Class;
594 assert( Abc_NtkPoNum(pNtkOld) == Abc_NtkPoNum(pNtkNew) );
595 // match the POs of the old into new
596 Abc_NtkForEachPo( pNtkOld, pObj, i )
597 pObj->pCopy = Abc_NtkPo( pNtkNew, i );
598 // remap the flops
599 Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
600 {
601 assert( Abc_ObjIsPo(pObj) && pObj->pNtk == pNtkOld );
602 Vec_PtrWriteEntry( vControls, i, pObj->pCopy );
603 }
604 // create self-loops
605 assert( Abc_NtkLatchNum(pNtkNew) == Vec_IntSize(vClasses) );
606 Abc_NtkForEachLatch( pNtkNew, pObj, i )
607 {
608 Class = Vec_IntEntry( vClasses, i );
609 if ( Class == -1 )
610 continue;
611 pDriver = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
612 pCtrl = (Abc_Obj_t *)Vec_PtrEntry( vControls, Class );
613 pCtrl = Abc_ObjFanin0( pCtrl );
614 pNodeNew = Abc_NtkCreateNode( pNtkNew );
615 Abc_ObjAddFanin( pNodeNew, pCtrl );
616 Abc_ObjAddFanin( pNodeNew, pDriver );
617 Abc_ObjAddFanin( pNodeNew, Abc_ObjFanout0(pObj) );
618 Abc_ObjSetData( pNodeNew, Abc_SopRegister((Mem_Flex_t *)pNtkNew->pManFunc, "0-1 1\n11- 1\n") );
619 Abc_ObjPatchFanin( Abc_ObjFanin0(pObj), pDriver, pNodeNew );
620 }
621 // remove the useless POs
622 Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
623 Abc_NtkDeleteObj( pObj );
624}
625
637Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose )
638{
639 Abc_Ntk_t * pNtkNew;
640 Vec_Ptr_t * vControls;
641 Vec_Int_t * vFlopClasses, * vFlopClassesNew;
642 Abc_Obj_t * pObj, * pDriver, * pFlopOut, * pObjPo;
643 int i, iFlop, CountN = 0, Count2 = 0, Count1 = 0, Count0 = 0;
644
645 // duplicate the AIG
646 pNtk = Abc_NtkDup( pNtk );
647
648 // update registers
649 vControls = Vec_PtrAlloc( 100 );
650 vFlopClasses = Vec_IntAlloc( 100 );
651 Abc_NtkForEachLatch( pNtk, pObj, i )
652 {
653 pFlopOut = Abc_ObjFanout0(pObj);
654 pDriver = Abc_ObjFanin0( Abc_ObjFanin0(pObj) );
655 if ( Abc_ObjFaninNum(pDriver) != 3 )
656 {
657 Vec_IntPush( vFlopClasses, -1 );
658 CountN++;
659 continue;
660 }
661 if ( Abc_ObjFanin(pDriver, 1) != pFlopOut && Abc_ObjFanin(pDriver, 2) != pFlopOut )
662 {
663 Vec_IntPush( vFlopClasses, -1 );
664 Count2++;
665 continue;
666 }
667 if ( Abc_ObjFanin(pDriver, 1) == pFlopOut )
668 {
669 Vec_IntPush( vFlopClasses, -1 );
670 Count1++;
671 continue;
672 }
673 assert( Abc_ObjFanin(pDriver, 2) == pFlopOut );
674 Count0++;
675 Vec_PtrPushUnique( vControls, Abc_ObjFanin0(pDriver) );
676 // set the flop class
677 iFlop = Vec_PtrFind( vControls, Abc_ObjFanin0(pDriver) );
678 Vec_IntPush( vFlopClasses, iFlop );
679 // update
680 Abc_ObjPatchFanin( Abc_ObjFanin0(pObj), pDriver, Abc_ObjFanin(pDriver, 1) );
681 }
682 if ( Count1 )
683 printf( "Opposite phase enable is present in %d flops (out of %d).\n", Count1, Abc_NtkLatchNum(pNtk) );
684 if ( fVerbose )
685 printf( "CountN = %4d. Count2 = %4d. Count1 = %4d. Count0 = %4d. Ctrls = %d.\n",
686 CountN, Count2, Count1, Count0, Vec_PtrSize(vControls) );
687
688 // add the controls to the list of POs
689 Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
690 {
691 pObjPo = Abc_NtkCreatePo( pNtk );
692 Abc_ObjAddFanin( pObjPo, pObj );
693 Abc_ObjAssignName( pObjPo, Abc_ObjName(pObjPo), NULL );
694 Vec_PtrWriteEntry( vControls, i, pObjPo );
695 }
696 Abc_NtkOrderCisCos( pNtk );
697 Abc_NtkCleanup( pNtk, fVerbose );
698
699 // performs retiming with classes
700 pNtkNew = Abc_NtkRetimeWithClassesNtk( pNtk, vFlopClasses, &vFlopClassesNew, fVerbose );
701 Abc_NtkTransformBack( pNtk, pNtkNew, vControls, vFlopClassesNew );
702// assert( Abc_NtkPoNum(pNtkNew) == Abc_NtkPoNum(pNtk) );
703 Abc_NtkDelete( pNtk );
704
705 Vec_PtrFree( vControls );
706// Vec_IntFree( vFlopClasses );
707 Vec_IntFree( vFlopClassesNew );
708 return pNtkNew;
709}
710
723{
724 Abc_Obj_t * pObj;
725 int RetValue, i, k, iBit = 0;
726 assert( Abc_NtkIsStrash(pNtk) );
727 assert( p->nPis == Abc_NtkPiNum(pNtk) );
728// assert( p->nRegs == Abc_NtkLatchNum(pNtk) );
729 Abc_NtkCleanMarkC( pNtk );
730 Abc_AigConst1(pNtk)->fMarkC = 1;
731 // initialize flops
732 Abc_NtkForEachLatch( pNtk, pObj, i )
733 Abc_ObjFanout0(pObj)->fMarkC = Abc_InfoHasBit(p->pData, iBit++);
734 // simulate timeframes
735 iBit = p->nRegs;
736 for ( i = 0; i <= p->iFrame; i++ )
737 {
738 Abc_NtkForEachPi( pNtk, pObj, k )
739 pObj->fMarkC = Abc_InfoHasBit(p->pData, iBit++);
740 Abc_NtkForEachNode( pNtk, pObj, k )
741 pObj->fMarkC = (Abc_ObjFanin0(pObj)->fMarkC ^ Abc_ObjFaninC0(pObj)) &
742 (Abc_ObjFanin1(pObj)->fMarkC ^ Abc_ObjFaninC1(pObj));
743 Abc_NtkForEachCo( pNtk, pObj, k )
744 pObj->fMarkC = Abc_ObjFanin0(pObj)->fMarkC ^ Abc_ObjFaninC0(pObj);
745 Abc_NtkForEachLatch( pNtk, pObj, k )
746 Abc_ObjFanout0(pObj)->fMarkC = Abc_ObjFanin0(pObj)->fMarkC;
747 }
748 assert( iBit == p->nBits );
749 // figure out the number of failed output
750 RetValue = -1;
751 Abc_NtkForEachPo( pNtk, pObj, i )
752 {
753 if ( pObj->fMarkC )
754 {
755 RetValue = i;
756 break;
757 }
758 }
759 Abc_NtkCleanMarkC( pNtk );
760 return RetValue;
761}
762
766
767
769
Abc_Ntk_t * Abc_NtkFromDarSeqSweep(Abc_Ntk_t *pNtkOld, Aig_Man_t *pMan)
Definition abcDar.c:473
Abc_Obj_t * Abc_NtkAddLatch(Abc_Ntk_t *pNtk, Abc_Obj_t *pDriver, Abc_InitType_t Init)
Definition abcLatch.c:254
Vec_Int_t * Abc_NtkCollectLatchValues(Abc_Ntk_t *pNtk)
Definition abcLatch.c:181
int Abc_NtkVerifyCex(Abc_Ntk_t *pNtk, Abc_Cex_t *p)
Definition abcLatch.c:722
int Abc_NtkLatchIsSelfFeed(Abc_Obj_t *pLatch)
Definition abcLatch.c:71
void Abc_NtkLatchPipe(Abc_Ntk_t *pNtk, int nLatches)
Definition abcLatch.c:148
Abc_Ntk_t * Abc_NtkConvertOnehot(Abc_Ntk_t *pNtk)
Definition abcLatch.c:417
ABC_NAMESPACE_IMPL_START int Abc_NtkLatchIsSelfFeed_rec(Abc_Obj_t *pLatch, Abc_Obj_t *pLatchRoot)
DECLARATIONS ///.
Definition abcLatch.c:48
Vec_Ptr_t * Abc_NtkConverLatchNamesIntoNumbers(Abc_Ntk_t *pNtk)
Definition abcLatch.c:364
int Abc_NtkRemoveSelfFeedLatches(Abc_Ntk_t *pNtk)
Definition abcLatch.c:117
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Aig_Man_t * Abc_NtkRetimeWithClassesAig(Aig_Man_t *pMan, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
Definition abcLatch.c:534
Abc_Ntk_t * Abc_NtkRetimeWithClassesNtk(Abc_Ntk_t *pNtk, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
Definition abcLatch.c:561
char * Abc_NtkCollectLatchValuesStr(Abc_Ntk_t *pNtk)
Definition abcLatch.c:203
void Abc_NtkConvertDcLatches(Abc_Ntk_t *pNtk)
Definition abcLatch.c:310
void Abc_NtkTransformBack(Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew, Vec_Ptr_t *vControls, Vec_Int_t *vClasses)
Definition abcLatch.c:590
void Abc_NtkNodeConvertToMux(Abc_Ntk_t *pNtk, Abc_Obj_t *pNodeC, Abc_Obj_t *pNode1, Abc_Obj_t *pNode0, Abc_Obj_t *pMux)
Definition abcLatch.c:281
void Abc_NtkInsertLatchValues(Abc_Ntk_t *pNtk, Vec_Int_t *vValues)
Definition abcLatch.c:235
int Abc_NtkCountSelfFeedLatches(Abc_Ntk_t *pNtk)
Definition abcLatch.c:92
Abc_Ntk_t * Abc_NtkCRetime(Abc_Ntk_t *pNtk, int fVerbose)
Definition abcLatch.c:637
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL void Abc_NtkCleanMarkC(Abc_Ntk_t *pNtk)
Definition abcUtil.c:734
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
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcNetlist.c:52
#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 void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:547
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition abcSweep.c:478
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
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_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL Abc_Ntk_t * Abc_NtkStartFromNoLatches(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:301
@ ABC_OBJ_BO
Definition abc.h:92
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:212
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
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_InitType_t
Definition abc.h:102
@ ABC_INIT_ZERO
Definition abc.h:104
@ ABC_INIT_ONE
Definition abc.h:105
@ ABC_INIT_DC
Definition abc.h:106
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition abcFanio.c:292
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:168
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition abcUtil.c:1080
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
Definition abcFunc.c:1261
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition abcStrash.c:265
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Obj_t * Abc_NodeFindCoFanout(Abc_Obj_t *pNode)
Definition abcUtil.c:812
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition abcFanio.c:172
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition abcUtil.c:76
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
Aig_Man_t * Gia_ManToAig(Gia_Man_t *p, int fChoices)
Definition giaAig.c:318
Gia_Man_t * Gia_ManFromAigSimple(Aig_Man_t *p)
Definition giaAig.c:212
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Definition abcDar.c:237
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManRetimeForward(Gia_Man_t *p, int nMaxIters, int fVerbose)
Definition giaRetime.c:267
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
Hop_Obj_t * Hop_Mux(Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
Definition hopOper.c:187
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void Nm_ManDeleteIdName(Nm_Man_t *p, int ObjId)
Definition nmApi.c:149
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
Definition nmApi.c:219
Abc_NtkType_t ntkType
Definition abc.h:156
void * pManFunc
Definition abc.h:191
Vec_Ptr_t * vOnehots
Definition abc.h:211
Nm_Man_t * pManName
Definition abc.h:160
Abc_NtkFunc_t ntkFunc
Definition abc.h:157
void * pData
Definition abc.h:145
unsigned fMarkC
Definition abc.h:136
Abc_Ntk_t * pNtk
Definition abc.h:130
Abc_Obj_t * pCopy
Definition abc.h:148
Abc_Obj_t * pNext
Definition abc.h:131
Vec_Int_t * vFlopClasses
Definition gia.h:156
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
#define assert(ex)
Definition util_old.h:213
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