583{
584 int * pNs2Glo = Vec_IntArray(
p->vNs2Glo );
585 int * pCs2Glo = Vec_IntArray(
p->vCs2Glo );
586 int * pGlo2Cs = Vec_IntArray(
p->vGlo2Cs );
587 DdNode * bCurrent, * bReached, * bNext, * bTemp, * bCube;
588 DdNode * bConstrCs, * bConstrNs;
589 abctime clk2, clk = Abc_Clock();
590 int nIters, nBddSize = 0;
591
592
593
594 p->pPars->TimeTarget =
p->pPars->TimeLimit ?
p->pPars->TimeLimit * CLOCKS_PER_SEC + Abc_Clock(): 0;
595
596
598
599
603 p->dd = Cudd_Init( Vec_IntSize(
p->vVar2Obj), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
604 p->ddR = Cudd_Init( Aig_ManCiNum(
p->pAig), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
605 if ( pddGlo && *pddGlo )
606 p->ddG = *pddGlo, *pddGlo = NULL;
607 else
608 p->ddG = Cudd_Init( Aig_ManRegNum(
p->pAig), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
609
610 if (
p->pPars->fReorder )
611 {
612 Cudd_AutodynEnable(
p->dd, CUDD_REORDER_SYMM_SIFT );
613 Cudd_AutodynEnable(
p->ddG, CUDD_REORDER_SYMM_SIFT );
614 Cudd_AutodynEnable(
p->ddR, CUDD_REORDER_SYMM_SIFT );
615 }
616 else
617 {
618 Cudd_AutodynDisable(
p->dd );
619 Cudd_AutodynDisable(
p->ddG );
620 Cudd_AutodynDisable(
p->ddR );
621 }
622
623
624 p->dd->TimeStop =
p->pPars->TimeTarget;
625 p->ddG->TimeStop =
p->pPars->TimeTarget;
626 p->ddR->TimeStop =
p->pPars->TimeTarget;
627
628
630 if (
p->ddR->bFunc == NULL )
631 {
632 if ( !
p->pPars->fSilent )
633 printf(
"Reached timeout (%d seconds) during constructing the bad states.\n",
p->pPars->TimeLimit );
634 p->pPars->iFrame = -1;
635 return -1;
636 }
637 Cudd_Ref(
p->ddR->bFunc );
638
639
642
643
644
645
646
648 {
649 bReached =
p->ddG->bFunc;
p->ddG->bFunc = NULL;
651 }
652 else
653 {
656 }
657
658
659
660
661 for ( nIters = 0; nIters <
p->pPars->nIterMax; nIters++ )
662 {
663 clk2 = Abc_Clock();
664
665 if (
p->pPars->TimeLimit && Abc_Clock() >
p->pPars->TimeTarget )
666 {
667 if ( !
p->pPars->fSilent )
668 printf(
"Reached timeout during image computation (%d seconds).\n",
p->pPars->TimeLimit );
669 p->pPars->iFrame = nIters - 1;
670 Cudd_RecursiveDeref(
p->dd, bCurrent ); bCurrent = NULL;
671 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
672 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
673 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
674 return -1;
675 }
676
677
679 if ( bTemp == NULL )
680 {
681 if ( !
p->pPars->fSilent )
682 printf(
"Reached timeout (%d seconds) during ring transfer.\n",
p->pPars->TimeLimit );
683 p->pPars->iFrame = nIters - 1;
684 Cudd_RecursiveDeref(
p->dd, bCurrent ); bCurrent = NULL;
685 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
686 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
687 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
688 return -1;
689 }
690 Cudd_Ref( bTemp );
691 Vec_PtrPush(
p->vRings, bTemp );
692
693
694 if ( !
p->pPars->fSkipOutCheck && !Cudd_bddLeq(
p->ddR, bTemp, Cudd_Not(
p->ddR->bFunc) ) )
695 {
696 assert(
p->pAigGlo->pSeqModel == NULL );
697 if ( !
p->pPars->fBackward )
699 if ( !
p->pPars->fSilent )
700 {
701 if ( !
p->pPars->fBackward )
702 Abc_Print( 1,
"Output %d of miter \"%s\" was asserted in frame %d. ",
p->pAigGlo->pSeqModel->iPo,
p->pAigGlo->pName,
p->pAigGlo->pName, nIters );
703 else
704 Abc_Print( 1,
"Output ??? of miter \"%s\" was asserted in frame %d (counter-example is not produced). ",
p->pAigGlo->pName, nIters );
705 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
706 }
707 p->pPars->iFrame = nIters - 1;
708 Cudd_RecursiveDeref(
p->dd, bCurrent ); bCurrent = NULL;
709 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
710 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
711 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
712 return 0;
713 }
714
715
716 if ( vHints )
717 {
718 bCurrent = Cudd_bddAnd(
p->dd, bTemp = bCurrent, bConstrCs ); Cudd_Ref( bCurrent );
719 Cudd_RecursiveDeref(
p->dd, bTemp );
720 }
721
722
724 bCurrent = Cudd_bddExistAbstract(
p->dd, bTemp = bCurrent, bCube ); Cudd_Ref( bCurrent );
725 Cudd_RecursiveDeref(
p->dd, bTemp );
726 Cudd_RecursiveDeref(
p->dd, bCube );
727
728
730 if ( bNext == NULL )
731 {
732 if ( !
p->pPars->fSilent )
733 printf(
"Reached timeout (%d seconds) during image computation.\n",
p->pPars->TimeLimit );
734 p->pPars->iFrame = nIters - 1;
735 Cudd_RecursiveDeref(
p->dd, bCurrent ); bCurrent = NULL;
736 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
737 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
738 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
739 return -1;
740 }
741 Cudd_Ref( bNext );
742 Cudd_RecursiveDeref(
p->dd, bCurrent ); bCurrent = NULL;
743
744
745 if ( vHints )
746 {
747 bNext = Cudd_bddAnd(
p->dd, bTemp = bNext, bConstrNs ); Cudd_Ref( bNext );
748 Cudd_RecursiveDeref(
p->dd, bTemp );
749 }
750
751
752
753
754
755
757 if ( bNext == NULL )
758 {
759 if ( !
p->pPars->fSilent )
760 printf(
"Reached timeout (%d seconds) during image computation in transfer 1.\n",
p->pPars->TimeLimit );
761 p->pPars->iFrame = nIters - 1;
762 Cudd_RecursiveDeref(
p->dd, bTemp );
763 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
764 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
765 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
766 return -1;
767 }
768 Cudd_Ref( bNext );
769 Cudd_RecursiveDeref(
p->dd, bTemp );
770
771
772
773 if ( Cudd_bddLeq(
p->ddG, bNext, bReached ) )
774 {
775 Cudd_RecursiveDeref(
p->ddG, bNext ); bNext = NULL;
776 break;
777 }
778
779
780 nBddSize = Cudd_DagSize(bNext);
781 if ( nBddSize >
p->pPars->nBddMax )
782 {
783 Cudd_RecursiveDeref(
p->ddG, bNext ); bNext = NULL;
784 break;
785 }
786
787
788 bCurrent = Cudd_bddAnd(
p->ddG, bNext, Cudd_Not(bReached) );
789 if ( bCurrent == NULL )
790 {
791 Cudd_RecursiveDeref(
p->ddG, bNext ); bNext = NULL;
792 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
793 break;
794 }
795 Cudd_Ref( bCurrent );
796
797
798
799
800
801
802
803
804
805
807 if ( bCurrent == NULL )
808 {
809 if ( !
p->pPars->fSilent )
810 printf(
"Reached timeout (%d seconds) during image computation in transfer 2.\n",
p->pPars->TimeLimit );
811 p->pPars->iFrame = nIters - 1;
812 Cudd_RecursiveDeref(
p->ddG, bTemp );
813 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
814 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
815 Cudd_RecursiveDeref(
p->ddG, bReached ); bReached = NULL;
816 return -1;
817 }
818 Cudd_Ref( bCurrent );
819 Cudd_RecursiveDeref(
p->ddG, bTemp );
820
821
822
823 bReached = Cudd_bddOr(
p->ddG, bTemp = bReached, bNext );
824 if ( bReached == NULL )
825 {
826 Cudd_RecursiveDeref(
p->ddG, bTemp ); bTemp = NULL;
827 Cudd_RecursiveDeref(
p->ddG, bNext ); bNext = NULL;
828 break;
829 }
830 Cudd_Ref( bReached );
831 Cudd_RecursiveDeref(
p->ddG, bTemp );
832 Cudd_RecursiveDeref(
p->ddG, bNext );
833 bNext = NULL;
834
835 if (
p->pPars->fVerbose )
836 {
837 fprintf( stdout, "F =%5d : ", nIters );
838 fprintf( stdout, "Im =%6d ", nBddSize );
839 fprintf( stdout,
"(%4d %3d) ", Cudd_ReadReorderings(
p->dd), Cudd_ReadGarbageCollections(
p->dd) );
840 fprintf( stdout, "Rea =%6d ", Cudd_DagSize(bReached) );
841 fprintf( stdout,
"(%4d%4d) ", Cudd_ReadReorderings(
p->ddG), Cudd_ReadGarbageCollections(
p->ddG) );
842 Abc_PrintTime( 1, "Time", Abc_Clock() - clk2 );
843 }
844
845
846
847
848
849
850
851
852
853 }
854 Cudd_RecursiveDeref(
p->dd, bConstrCs ); bConstrCs = NULL;
855 Cudd_RecursiveDeref(
p->dd, bConstrNs ); bConstrNs = NULL;
856 if ( bReached == NULL )
857 {
858 p->pPars->iFrame = nIters - 1;
859 return 0;
860 }
861
862 if ( bCurrent )
863 Cudd_RecursiveDeref(
p->dd, bCurrent );
864
865 if (
p->pPars->fVerbose )
866 {
867 double nMints = Cudd_CountMinterm(
p->ddG, bReached, Saig_ManRegNum(
p->pAig) );
868 if ( nIters >=
p->pPars->nIterMax || nBddSize >
p->pPars->nBddMax )
869 fprintf( stdout, "Reachability analysis is stopped after %d frames.\n", nIters );
870 else
871 fprintf( stdout, "Reachability analysis completed after %d frames.\n", nIters );
872 fprintf( stdout,
"Reachable states = %.0f. (Ratio = %.4f %%)\n", nMints, 100.0*nMints/pow(2.0, Saig_ManRegNum(
p->pAig)) );
873 fflush( stdout );
874 }
875 if ( nIters >=
p->pPars->nIterMax || nBddSize >
p->pPars->nBddMax )
876 {
877 if ( !
p->pPars->fSilent )
878 printf( "Verified only for states reachable in %d frames. ", nIters );
879 p->pPars->iFrame =
p->pPars->nIterMax;
880 Cudd_RecursiveDeref(
p->ddG, bReached );
881 return -1;
882 }
883 if ( pddGlo )
884 {
885 assert(
p->ddG->bFunc == NULL );
886 p->ddG->bFunc = bReached; bReached = NULL;
887 assert( *pddGlo == NULL );
888 *pddGlo =
p->ddG;
p->ddG = NULL;
889 }
890 else
891 Cudd_RecursiveDeref(
p->ddG, bReached );
892 if ( !
p->pPars->fSilent )
893 printf( "The miter is proved unreachable after %d iterations. ", nIters );
894 p->pPars->iFrame = nIters - 1;
895 return 1;
896}
void Llb_ManPrepareVarLimits(Llb_Man_t *p)
Abc_Cex_t * Llb_ManReachDeriveCex(Llb_Man_t *p)
DdNode * Llb_ManComputeImage(Llb_Man_t *p, DdNode *bInit, int fBackward)
DdNode * Llb_ManCreateConstraints(Llb_Man_t *p, Vec_Int_t *vHints, int fUseNsVars)
DdNode * Llb_ManComputeInitState(Llb_Man_t *p, DdManager *dd)
ABC_NAMESPACE_IMPL_START DdNode * Llb_BddComputeBad(Aig_Man_t *pInit, DdManager *dd, abctime TimeOut)
DECLARATIONS ///.