VIS

src/puresat/puresatIPRefine.c

Go to the documentation of this file.
00001 
00048 #include "puresatInt.h"
00049 
00050 
00051 /*---------------------------------------------------------------------------*/
00052 /* Constant declarations                                                     */
00053 /*---------------------------------------------------------------------------*/
00054 
00055 /*---------------------------------------------------------------------------*/
00056 /* Structure declarations                                                    */
00057 /*---------------------------------------------------------------------------*/
00058 
00059 /*---------------------------------------------------------------------------*/
00060 /* Type declarations                                                         */
00061 /*---------------------------------------------------------------------------*/
00062 
00063 /*---------------------------------------------------------------------------*/
00064 /* Variable declarations                                                     */
00065 /*---------------------------------------------------------------------------*/
00066 
00067 /*---------------------------------------------------------------------------*/
00068 /* Macro declarations                                                        */
00069 /*---------------------------------------------------------------------------*/
00070 
00073 /*---------------------------------------------------------------------------*/
00074 /* Static function prototypes                                                */
00075 /*---------------------------------------------------------------------------*/
00076 
00079 /*---------------------------------------------------------------------------*/
00080 /* Definition of exported functions                                          */
00081 /*---------------------------------------------------------------------------*/
00082 
00095 #if UNSATCORE
00096 void PureSat_GetSufAbsFromCoreRecur(mAig_Manager_t *manager,
00097                                     satManager_t * cm,
00098                                     RTnode_t RTnode,
00099                                     st_table *ctTable,
00100                                     st_table *refineTable,
00101                                     FILE * fp)
00102 #else
00103 void PureSat_GetSufAbsFromCoreRecur(mAig_Manager_t *manager,
00104                                     satManager_t * cm,
00105                                     RTnode_t RTnode,
00106                                     st_table *ctTable,
00107                                     st_table *refineTable)
00108 #endif
00109 {
00110   int i,ct;
00111   bAigTimeFrame_t *tf = manager->timeframeWOI;
00112   char *name;
00113   bAigEdge_t v,*lp;
00114   st_table *table;
00115   st_generator *stgen;
00116   RTManager_t * rm = cm->rm;
00117 
00118   if(RT_flag(RTnode)&RT_VisitedMask)
00119     return;
00120 
00121   RT_flag(RTnode) |= RT_VisitedMask;
00122   /*leaf*/
00123   if(RT_pivot(RTnode)==0){
00124 #if DBG
00125     assert(RT_oriClsIdx(RTnode)==0);
00126 #endif
00127     if(RT_oriClsIdx(RTnode)!=0)
00128       lp = (long*)SATfirstLit(RT_oriClsIdx(RTnode));
00129     else
00130 
00131       lp = RT_formula(RTnode) + cm->rm->fArray;
00132     for(i=0;i<RT_fSize(RTnode);i++,lp++){
00133       if(RT_oriClsIdx(RTnode)!=0)
00134         v = SATgetNode(*lp);
00135       else
00136         v = *lp;
00137       if(*lp<0)
00138         continue;
00139 
00140 #if UNSATCORE
00141       v = SATnormalNode(v);
00142       fprintf(fp,"%d_%d ",v,SATclass(v));
00143       if(SATflags(v)&DummyMask)
00144         fprintf(fp,"DM ");
00145       if(SATflags(v)&VisibleVarMask)
00146         fprintf(fp,"Visible  ");
00147       else
00148         if(SATflags(v)&StateBitMask)
00149           fprintf(fp, "InvSV  ");
00150 
00151 #endif
00152       v = SATnormalNode(v);
00153       if((SATflags(v)&VisibleVarMask)){
00154 
00155         if(SATclass(v)==0){
00156           if(!st_lookup(tf->idx2name,(char*)v,&name)&&
00157              !st_lookup(tf->MultiLatchTable,(char*)v,&table))
00158             continue;
00159         }
00160 #if 1
00161         /* at least 2 times to be choosen as a candidate*/
00162         if(st_lookup(ctTable,(char*)v,&ct)){
00163           if(ct<0)
00164             continue;
00165           if(ct>=1){
00166 
00167             if(!st_lookup(tf->MultiLatchTable,(char*)v,&table)){
00168               int retVal = st_lookup(tf->idx2name,(char*)v,&name);
00169               assert(retVal);
00170               st_insert(refineTable,(char*)name,(char*)0);
00171               st_insert(ctTable,(char*)v,(char*)-1);
00172 
00173             }
00174             else{
00175 #ifdef TIMEFRAME_VERIFY_
00176               fprintf(vis_stdout,"%d is in MultiLatchTable: ",v);
00177 #endif
00178               st_foreach_item(table,stgen,(char**)&name,
00179                               NIL(char*)){
00180 #ifdef TIMEFRAME_VERIFY_
00181                 fprintf(vis_stdout,"%s   ",name);
00182 #endif
00183                 st_insert(refineTable,(char*)name,(char*)0);
00184               }
00185 #ifdef TIMEFRAME_VERIFY_
00186               fprintf(vis_stdout,"\n");
00187 #endif
00188               st_insert(ctTable,(char*)v,(char*)-1);
00189             }
00190           }
00191         }
00192         else{
00193           ct=1;
00194           st_insert(ctTable,(char*)v,(char*)(long)ct);
00195         }
00196 #else
00197         retVal = st_lookup(tf->idx2name,(char*)v,(char**)&name);
00198         assert(retVal);
00199         st_insert(refineTable,(char*)name,(char*)0);
00200 
00201 #endif
00202       }/* if(SATflags(v)&StateBitMask){*/
00203     }
00204 #if UNSATCORE
00205     fprintf(fp,"0\n");
00206 #endif
00207   }
00208   /*non leaf*/
00209   else{
00210     assert(RT_left(RTnode)!=RT_NULL&&RT_right(RTnode)!=RT_NULL);
00211 #if UNSATCORE
00212     PureSat_GetSufAbsFromCoreRecur(manager,cm,RT_left(RTnode),
00213                                    ctTable,refineTable,fp);
00214     PureSat_GetSufAbsFromCoreRecur(manager,cm,RT_right(RTnode),
00215                                    ctTable,refineTable,fp);
00216 #else
00217     PureSat_GetSufAbsFromCoreRecur(manager,cm,RT_left(RTnode),
00218                                    ctTable,refineTable);
00219     PureSat_GetSufAbsFromCoreRecur(manager,cm,RT_right(RTnode),
00220                                    ctTable,refineTable);
00221 #endif
00222   }
00223   return;
00224 }
00225 
00238 //new pick latch
00239 #if UNSATCORE
00240 void PureSat_GetSufAbsFromCoreRecur_2side(mAig_Manager_t *manager,
00241                                           satManager_t * cm,
00242                                           RTnode_t RTnode,
00243                                           st_table *ctTable,
00244                                           st_table *refineTable,
00245                                           st_table *SufNameTable,
00246                                           FILE * fp)
00247 #else
00248 void PureSat_GetSufAbsFromCoreRecur_2side(mAig_Manager_t *manager,
00249                                           satManager_t * cm,
00250                                           RTnode_t RTnode,
00251                                           st_table *ctTable,
00252                                           st_table *refineTable,
00253                                           st_table *SufNameTable)
00254 #endif
00255 {
00256   int i,j,find,find1,times;
00257   bAigTimeFrame_t *tf = manager->timeframeWOI;
00258   char *name,*name1;
00259   bAigEdge_t v,v1,*lp,*lp1, *lp2, left,right;
00260   st_table *table;
00261   st_generator *stgen;
00262   RTManager_t * rm = cm->rm;
00263   long maxNode;
00264 
00265   if(RT_flag(RTnode)&RT_VisitedMask)
00266     return;
00267 
00268   RT_flag(RTnode) |= RT_VisitedMask;
00269 
00270   if(RT_pivot(RTnode)==0){
00271 #if DBG
00272     assert(RT_oriClsIdx(RTnode)==0);
00273 #endif
00274     if(RT_oriClsIdx(RTnode)!=0)
00275       lp = (long*)SATfirstLit(RT_oriClsIdx(RTnode));
00276     else
00277 
00278       lp = RT_formula(RTnode) + cm->rm->fArray;
00279     lp1 = lp;
00280     (cm->line)++;
00281     for(i=0;i<RT_fSize(RTnode);i++,lp++){
00282       if(RT_oriClsIdx(RTnode)!=0)
00283         v = SATgetNode(*lp);
00284       else
00285         v = *lp;
00286       if(*lp<0)
00287         continue;
00288 #if UNSATCORE
00289       v = SATnormalNode(v);
00290       fprintf(fp,"%d_%d ",v,SATclass(v));
00291       if(SATflags(v)&DummyMask)
00292         fprintf(fp,"DM ");
00293       if(SATflags(v)&VisibleVarMask)
00294         fprintf(fp,"Visible  ");
00295       else
00296         if(SATflags(v)&StateBitMask)
00297           fprintf(fp, "InvSV  ");
00298 
00299 #endif
00300       v = SATnormalNode(v);
00301 #if LAI
00302       /*mark every node in core for latch interface abs*/
00303       flags(v) |= VisitedMask;
00304 #endif
00305       if(SATflags(v)&VisibleVarMask){
00306         if((SATclass(v)==0)&&
00307            (st_lookup(tf->idx2name,(char*)v,&name)==0)&&
00308            (st_lookup(tf->MultiLatchTable,(char*)v,&table)==0))
00309             continue;
00310 
00311         lp2 = lp1;
00312         left = SATnormalNode(leftChild(v));
00313         right = SATnormalNode(rightChild(v));
00314         //find largest node
00315         maxNode = -1;
00316         for(j=0;j<RT_fSize(RTnode);j++,lp2++){
00317           if(RT_oriClsIdx(RTnode)!=0)
00318             v1 = SATgetNode(*lp2);
00319           else
00320             v1 = *lp2;
00321           if(maxNode < SATnormalNode(v1))
00322             maxNode = SATnormalNode(v1);
00323         }
00324         if(maxNode == v){
00325 #if DBG
00326           lp2 = lp1;
00327           for(j=0;j<RT_fSize(RTnode);j++,lp2++){
00328             if(RT_oriClsIdx(RTnode)!=0)
00329               v1 = SATgetNode(*lp2);
00330             else
00331               v1 = *lp2;
00332             if(*lp2<0||SATnormalNode(v1)==v)
00333               continue;
00334             assert((SATnormalNode(v1) == SATnormalNode(leftChild(v)))||
00335                    SATnormalNode(v1) == SATnormalNode(rightChild(v)));
00336           }
00337 #endif
00338           SATflags(v) |= Visited2Mask; /*left side*/
00339         }
00340         else{
00341 #if DBG
00342           lp2 = lp1;
00343           for(j=0;j<RT_fSize(RTnode);j++,lp2++){
00344             if(RT_oriClsIdx(RTnode)!=0)
00345               v1 = SATgetNode(*lp2);
00346             else
00347               v1 = *lp2;
00348             if(*lp2<0||SATnormalNode(v1)==maxNode)
00349               continue;
00350             assert((SATnormalNode(v1) == SATnormalNode(leftChild(maxNode)))||
00351                    (SATnormalNode(v1) == SATnormalNode(rightChild(maxNode))));
00352           }
00353 #endif
00354           SATflags(v) |= Visited3Mask; /*right side*/
00355 #if THROUGHPICK
00356           /*pick latch due to split*/
00357             if(SATflags(v)&VPGVMask){
00358               if(SATclass(maxNode)<=1)
00359                 SATflags(v) |= NewMask; /*the same tf*/
00360               else
00361                 SATflags(v) |= Visited4Mask; /* larger tf*/
00362             }
00363 #endif
00364         }
00365 
00366       }
00367 
00368 #if THROUGHPICK
00369       if((SATflags(v)&VisibleVarMask)&&
00370          (((SATflags(v)&Visited2Mask)&&(SATflags(v)&Visited3Mask))||
00371          ((SATflags(v)&Visited4Mask)&&(SATflags(v)&NewMask)))){
00372 #else
00373       if((SATflags(v)&VisibleVarMask)&&
00374          ((SATflags(v)&Visited2Mask)&&(SATflags(v)&Visited3Mask))){
00375 #endif
00376         times = 1;
00377         if(!st_lookup(tf->MultiLatchTable,(char*)v,&table)){
00378           int retVal = st_lookup(tf->idx2name,(char*)v,&name);
00379           assert(retVal);
00380 
00381           if(st_lookup(refineTable,(char*)name,&times))
00382             times++;
00383           st_insert(refineTable,(char*)name,(char*)(long)times);
00384         }
00385 
00386         /*for iden latches, we only add one, which is enough*/
00387         else{
00388           find = 0;
00389           find1 = 0;
00390           st_foreach_item(table,stgen,(char**)&name,
00391                           NIL(char*)){
00392             if(st_lookup(refineTable,name,NIL(char*))){
00393               find = 1;
00394               break;
00395             }
00396             if(find1==0){
00397               if(st_lookup(SufNameTable,name, NIL(char*))){
00398                 name1 = name;
00399                 find1 = 1;
00400               }
00401             }
00402           }
00403           if(find==0){
00404             times = 1;
00405             if(st_lookup(refineTable,(char*)name1,&times))
00406               times++;
00407             st_insert(refineTable,(char*)name1,(char*)(long)times);
00408 
00409           }
00410         }
00411 
00412 
00413       }
00414     }
00415 #if UNSATCORE
00416    fprintf(fp,"0\n");
00417 #endif
00418   }
00419     /*non leaf*/
00420   else{
00421     assert(RT_left(RTnode)!=RT_NULL&&RT_right(RTnode)!=RT_NULL);
00422 #if UNSATCORE
00423     PureSat_GetSufAbsFromCoreRecur_2side(manager,cm,RT_left(RTnode),
00424                                    ctTable,refineTable,SufNameTable,fp);
00425     PureSat_GetSufAbsFromCoreRecur_2side(manager,cm,RT_right(RTnode),
00426                                    ctTable,refineTable,SufNameTable,fp);
00427 #else
00428     PureSat_GetSufAbsFromCoreRecur_2side(manager,cm,RT_left(RTnode),
00429                                    ctTable,refineTable,SufNameTable);
00430     PureSat_GetSufAbsFromCoreRecur_2side(manager,cm,RT_right(RTnode),
00431                                    ctTable,refineTable,SufNameTable);
00432 #endif
00433   }
00434   return;
00435 }
00436 
00437 
00438 
00451 array_t * PureSat_GetSufAbsFromCore(Ntk_Network_t *network,
00452                                     satManager_t * cm,
00453                                     PureSat_Manager_t *pm,
00454                                     bAigEdge_t property,
00455                                     st_table * SufAbsNameTable)
00456 {
00457   array_t * refArray = array_alloc(char *,0);
00458   char *name;
00459   st_generator *stgen;
00460   Ntk_Node_t *latch;
00461   bAig_Manager_t * manager = Ntk_NetworkReadMAigManager(network);
00462   st_table * ctTable = st_init_table(st_numcmp,st_numhash);
00463   st_table * refineTable = st_init_table(strcmp,st_strhash);
00464   int times;
00465 #if UNSATCORE
00466   FILE * fp = fopen("unsatcore.txt","w");
00467 #endif
00468 #if LAI
00469   st_table * refineTable1 = st_init_table(strcmp,st_strhash);
00470 
00471 #endif
00472 
00473 
00474   PureSat_CleanMask(manager,ResetVisited1234NewMask);
00475 #if UNSATCORE
00476   fprintf(fp,"p cnf %d line, # nodes:%d\n",
00477           cm->initNumVariables,cm->nodesArraySize);
00478   cm->line = 0;
00479   PureSat_GetSufAbsFromCoreRecur_2side(manager,cm,cm->rm->root,
00480                                  ctTable,refineTable,SufAbsNameTable,fp);
00481   fprintf(fp,"total lines: %d\n",cm->line);
00482 #else
00483   PureSat_GetSufAbsFromCoreRecur_2side(manager,cm,cm->rm->root,
00484                                  ctTable,refineTable,SufAbsNameTable);
00485 
00486 #endif
00487   PureSat_CleanMask(manager,ResetVisited1234NewMask);
00488 
00489 #if LAI
00490   ResetRTree(cm->rm);
00491   PureSat_GetLIAForNode(manager,property);
00492   PureSat_GetSufAbsByLIA(manager,cm,cm->rm->root,
00493                         refineTable1);
00494 #endif
00495 
00496 
00497   st_foreach_item(refineTable,stgen,&name,&times){
00498     latch = Ntk_NetworkFindNodeByName(network,name);
00499 
00500     if(!st_lookup(pm->vertexTable,(char*)name,NIL(char*))&&
00501       st_lookup(pm->SufAbsTable, (char*)latch,NIL(char*))){
00502       array_insert_last(char *,refArray,name);
00503       if(pm->verbosity>=2)
00504         fprintf(vis_stdout,"ref cand:%s %d\n",name,times);
00505     }
00506   }
00507 
00508 #if LAI
00509   st_foreach_item(refineTable1,stgen,(char**)&name,NIL(char*)){
00510     latch = Ntk_NetworkFindNodeByName(network,name);
00511     if(!st_lookup(pm->vertexTable,(char*)name,NIL(char*))&&
00512        st_lookup(pm->CoiTable, (char*)latch,NIL(char*))){
00513       if(pm->verbosity>=2)
00514         fprintf(vis_stdout,"from LIA ref candidate:%s\n",name);
00515 
00516     }
00517   }
00518 #endif
00519 
00520 #if UNSATCORE
00521   fclose(fp);
00522 #endif
00523 
00524   st_free_table(ctTable);
00525   st_free_table(refineTable);
00526 #if LAI
00527   st_free_table(refineTable1);
00528 #endif
00529   return refArray;
00530 }
00531 
00532 
00533 
00546 array_t *PureSat_RefineOnAbs(Ntk_Network_t *network,
00547                              PureSat_Manager_t *pm,
00548                              bAigEdge_t property,
00549                              array_t *previousResultArray,
00550                              int latchThreshHold,
00551                              int * sccArray,
00552                              array_t * sufArray)
00553 {
00554   array_t * tmpRef,*tmpRef1,*tmpRef2,*tmpRef3;
00555   array_t * tmpModel = array_alloc(char *,0),*tmpArray1,*tmpArray2;
00556   satManager_t *cm;
00557   mAig_Manager_t * manager = Ntk_NetworkReadMAigManager(network);
00558   st_table *table;
00559   char * name;
00560   int i,j;
00561   int NumInSecondLevel;
00562   st_generator *stgen;
00563   Ntk_Node_t *latch;
00564   double t1,t2,t3,t4;
00565   st_table * SufAbsNameTable = st_init_table(strcmp,st_strhash);
00566   st_table * junkTable;
00567   int noArosat = 1;
00568 
00569 
00570   tmpRef = array_alloc(char *,0);
00571   st_foreach_item(pm->SufAbsTable,stgen,&latch,NIL(char*)){
00572     name = Ntk_NodeReadName(latch);
00573     if(st_lookup(pm->vertexTable,name,NIL(char *)))
00574       array_insert_last(char *,tmpModel,name);
00575     array_insert_last(char *,tmpRef,name);
00576     st_insert(SufAbsNameTable,name,(char *)0);
00577 
00578   }
00579 
00580   t1 = util_cpu_ctime();
00581   manager->assertArray = sat_ArrayAlloc(1);
00582   sat_ArrayInsert(manager->assertArray,manager->InitState);
00583   cm = PureSat_SatManagerAlloc_WOCOI(manager,pm,property,previousResultArray);
00584   if(pm->Arosat){
00585     cm->option->decisionHeuristic &= RESET_LC;
00586     cm->option->decisionHeuristic |= DVH_DECISION;
00587     cm->option->arosat = 1;
00588   }
00589   cm->option->coreGeneration = 1;
00590   cm->option->AbRf = 1;
00591   cm->property = property;
00592   cm->option->IP = 1;
00593   PureSat_CleanMask(manager,ResetVisibleVarMask);
00594   PuresatMarkVisibleVarWithVPGV(network,tmpRef,pm,0,pm->Length+1);
00595   array_free(tmpRef);
00596   t3 = util_cpu_ctime();
00597   PureSatPreprocess(network,cm,pm,SufAbsNameTable,pm->Length);
00598   t4 = util_cpu_ctime();
00599   pm->tPro += t4-t3;
00600   if(pm->verbosity>=2)
00601     fprintf(vis_stdout,"process time:%g,total:%g\n",
00602            (double)((t4-t3)/1000.0),pm->tPro/1000);
00603 
00604   if(cm->option->arosat){
00605     PureSatCreateLayer(network,pm,cm,tmpModel,sufArray);
00606     cm->Length = pm->Length;
00607     AS_Main(cm);
00608     noArosat = 0;
00609     st_foreach_item(cm->layerTable,stgen,&table,NIL(char*))
00610       st_free_table(table);
00611     st_free_table(cm->layerTable);
00612     FREE(cm->assignedArray);
00613     FREE(cm->numArray);
00614   }
00615   else
00616     sat_Main(cm);
00617 
00618   manager->NodesArray = cm->nodesArray;;
00619   assert(cm->status==SAT_UNSAT);
00620   t3 = util_cpu_ctime();
00621   PureSatPostprocess(manager,cm,pm);
00622   PureSatProcessDummy(manager,cm,cm->rm->root);
00623   ResetRTree(cm->rm);
00624   t4 = util_cpu_ctime();
00625   pm->tPro += t4-t3;
00626   if(pm->verbosity>=2)
00627     fprintf(vis_stdout,"process time:%g,total:%g\n",
00628            (double)((t4-t3)/1000.0),pm->tPro/1000);
00629   t2 = util_cpu_ctime();
00630   pm->tCoreGen += t2 - t1;
00631   if(pm->verbosity>=2)
00632     fprintf(vis_stdout,"time for UNsat core generation:%g,total:%g\n",
00633            (double)(t2-t1)/1000.0,pm->tCoreGen/1000.0);
00634 
00635   t1 = util_cpu_ctime();
00636   tmpRef1 = PureSat_GetSufAbsFromCore(network,cm,pm,property,SufAbsNameTable);
00637   t2 = util_cpu_ctime();
00638 
00639   st_free_table(SufAbsNameTable);
00640   RT_Free(cm->rm);
00641   sat_ArrayFree(manager->assertArray);
00642   PureSat_SatFreeManager(cm);
00643 
00644   /*Get suff set*/
00645   tmpRef2 = array_alloc(char *,0);
00646   tmpRef3 = array_alloc(char *,0);
00647   tmpArray1 = array_alloc(char *,0);
00648   tmpArray2 = array_alloc(char *,0);
00649 
00650   if(noArosat){
00651     t1 = util_cpu_ctime();
00652     if(array_n(tmpRef1)){
00653       tmpRef = PureSatGenerateRCArray_2(network,pm,tmpRef1,
00654                                         &NumInSecondLevel);
00655       array_free(pm->latchArray);
00656     }
00657 
00658   }
00659   else{
00660     if(array_n(tmpRef1)){
00661       tmpRef = PureSatGenerateRCArray_2(network,pm,tmpRef1,
00662                                         &NumInSecondLevel);
00663       array_free(pm->latchArray);
00664     }
00665     else
00666       tmpRef = array_alloc(char*,0);
00667 #if NOREFMIN
00668     if(pm->verbosity>=1){
00669       fprintf(vis_stdout,"\n sufficient refinement candidates from CA\n");
00670       arrayForEachItem(char *,tmpRef,i,name)
00671         fprintf(vis_stdout,"%s\n",name);
00672     }
00673     PureSatAddIdenLatchToAbs(network,pm,tmpRef);
00674     array_free(tmpRef1);
00675     array_free(tmpModel);
00676     return tmpRef;
00677 #endif
00678   }
00679 
00680 
00681   /*Ref Minimization
00682     //try all the candidates*/
00683   t1 = util_cpu_ctime();
00684 
00685   if(pm->CoreRefMin && array_n(tmpRef)>=5){
00686     if(pm->verbosity>=1)
00687       fprintf(vis_stdout,"Core Ref Min\n");
00688     junkTable = st_init_table(strcmp,st_strhash);
00689     for(i=array_n(tmpRef)-1;i>=0;i--)
00690       {
00691         array_t * tmpA;
00692         name = array_fetch(char *,tmpRef,i);
00693         if(pm->verbosity>=1)
00694           fprintf(vis_stdout,"RefMin: testing %s\n",name);
00695         tmpArray2 = PureSatRemove_char(tmpRef,i);
00696         if(st_lookup(junkTable,name,NIL(char))){
00697           array_free(tmpRef);
00698           tmpRef = tmpArray2;
00699           if(pm->verbosity>=1)
00700             fprintf(vis_stdout,"%s is junk\n",name);
00701           continue;
00702         }
00703         tmpA = array_dup(tmpModel);
00704         array_append(tmpA,tmpArray2);
00705 
00706         t3 = util_cpu_time();
00707         tmpArray1 = array_alloc(char*,0);
00708         arrayForEachItem(char*,tmpA,j,name)
00709           if(!st_lookup(junkTable,name,NIL(char)))
00710             array_insert_last(char*,tmpArray1,name);
00711         array_free(tmpA);
00712 
00713         if(!PureSat_ConcretTest_Core(network,pm,tmpArray1,property,
00714                                      previousResultArray,junkTable)){
00715           /*then the candidate can' be deleted*/
00716           t4 = util_cpu_time();
00717           if(pm->verbosity>=2)
00718             fprintf(vis_stdout," %g\n",(t4-t3)/1000);
00719           array_free(tmpArray2);
00720         }
00721         else /*delete it*/
00722           {
00723             t4 = util_cpu_time();
00724             if(pm->verbosity>=2)
00725               fprintf(vis_stdout,"time: %g\n",(t4-t3)/1000);
00726             array_free(tmpRef);
00727             tmpRef = tmpArray2;
00728           }
00729         array_free(tmpArray1);
00730       }
00731     st_free_table(junkTable);
00732   }
00733   else{
00734     for(i=array_n(tmpRef)-1;i>=0;i--)
00735       {
00736         name = array_fetch(char *,tmpRef,i);
00737 
00738         if(pm->verbosity>=1)
00739           fprintf(vis_stdout,"RefMin: testing %s\n",name);
00740         tmpArray2 = PureSatRemove_char(tmpRef,i);
00741         tmpArray1 = array_dup(tmpModel);
00742         array_append(tmpArray1,tmpArray2);
00743 
00744         t3 = util_cpu_time();
00745         if(!PureSat_ConcretTest(network,pm,tmpArray1,property,
00746                                 previousResultArray,0,0,0)){
00747           t4 = util_cpu_time();
00748           if(pm->verbosity>=2)
00749             fprintf(vis_stdout," %g\n",(t4-t3)/1000);
00750           array_free(tmpArray2);
00751         }
00752         else /*delete it*/
00753           {
00754             t4 = util_cpu_time();
00755             if(pm->verbosity>=2)
00756               fprintf(vis_stdout,"time: %g\n",(t4-t3)/1000);
00757             array_free(tmpRef);
00758             tmpRef = tmpArray2;
00759           }
00760         array_free(tmpArray1);
00761       }
00762   }
00763 
00764 
00765   t2 = util_cpu_ctime();
00766   pm->tRefMin += t2 - t1;
00767   if(pm->verbosity>=2)
00768     fprintf(vis_stdout,"\ntime for Ref Min: %g, total:%g\n",
00769            (t2-t1)/1000,pm->tRefMin/1000);
00770   if(pm->verbosity>=1){
00771     fprintf(vis_stdout,"\n sufficient refinement candidates from CA\n");
00772     arrayForEachItem(char *,tmpRef,i,name)
00773       fprintf(vis_stdout,"%s\n",name);
00774   }
00775   PureSatAddIdenLatchToAbs(network,pm,tmpRef);
00776   array_free(tmpRef1);
00777   array_free(tmpModel);
00778   return tmpRef;
00779 }
00780 
00781 
00795 array_t *PureSat_RefineOnAbs_DA(Ntk_Network_t *network,
00796                              PureSat_Manager_t *pm,
00797                              bAigEdge_t property,
00798                              array_t *previousResultArray,
00799                              int latchThreshHold,
00800                              int * sccArray,
00801                              array_t * sufArray)
00802 {
00803   array_t * tmpRef,*tmpRef1,*tmpRef2,*tmpRef3; //= array_alloc(char *,0);
00804   array_t * tmpModel = array_alloc(char *,0),*tmpArray1,*tmpArray2;
00805   satManager_t *cm;
00806   mAig_Manager_t * manager = Ntk_NetworkReadMAigManager(network);
00807   st_table *table;
00808   char * name;
00809   int i;
00810   int NumInSecondLevel;
00811   st_generator *stgen;
00812   Ntk_Node_t *latch;
00813   double t1,t2,t3,t4;
00814   st_table * SufAbsNameTable = st_init_table(strcmp,st_strhash);
00815   int noArosat = 1;
00816 
00817 
00818   tmpRef = array_alloc(char *,0);
00819   st_foreach_item(pm->SufAbsTable,stgen,&latch,NIL(char*)){
00820     name = Ntk_NodeReadName(latch);
00821     if(st_lookup(pm->vertexTable,name,NIL(char *)))
00822       array_insert_last(char *,tmpModel,name);
00823     array_insert_last(char *,tmpRef,name);
00824     st_insert(SufAbsNameTable,name,(char *)0);
00825 
00826   }
00827 
00828   t1 = util_cpu_ctime();
00829   manager->assertArray = sat_ArrayAlloc(1);
00830   sat_ArrayInsert(manager->assertArray,manager->InitState);
00831   cm = PureSat_SatManagerAlloc_WOCOI(manager,pm,property,previousResultArray);
00832 #if AROSAT
00833   cm->option->decisionHeuristic &= RESET_LC;
00834   cm->option->decisionHeuristic |= DVH_DECISION;
00835   cm->option->arosat = 1;
00836 #endif
00837   cm->option->coreGeneration = 1;
00838   cm->option->AbRf = 1;
00839 
00840   cm->option->IP = 1;
00841   cm->property = property;
00842   PureSat_CleanMask(manager,ResetVisibleVarMask);
00843   PuresatMarkVisibleVarWithVPGV(network,tmpRef,pm,0,pm->Length+1);
00844   array_free(tmpRef);
00845   t3 = util_cpu_ctime();
00846   PureSatPreprocess(network,cm,pm,SufAbsNameTable,pm->Length);
00847   t4 = util_cpu_ctime();
00848   pm->tPro += t4-t3;
00849   if(pm->verbosity>=2)
00850     fprintf(vis_stdout,"process time:%g,total:%g\n",
00851            (double)((t4-t3)/1000.0),pm->tPro/1000);
00852 #if DBG
00853   PureSatCheckCoi(manager);
00854 #endif
00855   if(cm->option->arosat){
00856     PureSatCreateLayer(network,pm,cm,tmpModel,sufArray);
00857     cm->Length = pm->Length;
00858     AS_Main(cm);
00859     noArosat = 0;
00860     st_foreach_item(cm->layerTable,stgen,&table,NIL(char*))
00861       st_free_table(table);
00862     st_free_table(cm->layerTable);
00863     FREE(cm->assignedArray);
00864     FREE(cm->numArray);
00865   }
00866   else
00867     sat_Main(cm);
00868   manager->NodesArray = cm->nodesArray;;
00869   assert(cm->status==SAT_UNSAT);
00870   t3 = util_cpu_ctime();
00871   PureSatPostprocess(manager,cm,pm);
00872   PureSatProcessDummy(manager,cm,cm->rm->root);
00873   ResetRTree(cm->rm);
00874   t4 = util_cpu_ctime();
00875   pm->tPro += t4-t3;
00876   if(pm->verbosity>=2)
00877     fprintf(vis_stdout,"process time:%g,total:%g\n",
00878            (double)((t4-t3)/1000.0),pm->tPro/1000);
00879   t2 = util_cpu_ctime();
00880   pm->tCoreGen += t2 - t1;
00881   if(pm->verbosity>=2)
00882     fprintf(vis_stdout,"time for UNsat core generation:%g,total:%g\n",
00883            (double)(t2-t1)/1000.0,pm->tCoreGen/1000.0);
00884 #if DBG
00885   PureSat_CheckFanoutFanin(manager);
00886 #endif
00887   t1 = util_cpu_ctime();
00888   tmpRef1 = PureSat_GetSufAbsFromCore(network,cm,pm,property,SufAbsNameTable);
00889   t2 = util_cpu_ctime();
00890 
00891   st_free_table(SufAbsNameTable);
00892   RT_Free(cm->rm);
00893   sat_ArrayFree(manager->assertArray);
00894   PureSat_SatFreeManager(cm);
00895 
00896   /*Get suff set*/
00897 
00898   tmpRef2 = array_alloc(char *,0);
00899   tmpRef3 = array_alloc(char *,0);
00900   tmpArray1 = array_alloc(char *,0);
00901   tmpArray2 = array_alloc(char *,0);
00902 
00903   if(noArosat){
00904     t1 = util_cpu_ctime();
00905     if(array_n(tmpRef1)){
00906      tmpRef = PureSatGenerateRCArray_2(network,pm,tmpRef1,
00907                                         &NumInSecondLevel);
00908 
00909       array_free(pm->latchArray);
00910     }
00911   }
00912   /*if arosat*/
00913   else{
00914     if(array_n(tmpRef1)){
00915       tmpRef = PureSatGenerateRCArray_2(network,pm,tmpRef1,
00916                                         &NumInSecondLevel);
00917       array_free(pm->latchArray);
00918     }
00919     else
00920       tmpRef = array_alloc(char*,0);
00921 
00922     if(pm->verbosity>=1){
00923       fprintf(vis_stdout,"\n sufficient refinement candidates from CA\n");
00924       arrayForEachItem(char *,tmpRef,i,name)
00925         fprintf(vis_stdout,"%s\n",name);
00926     }
00927     PureSatAddIdenLatchToAbs(network,pm,tmpRef);
00928     array_free(tmpRef1);
00929     array_free(tmpModel);
00930     return tmpRef;
00931   }
00932 }