VIS
|
00001 00048 #include "puresatInt.h" 00049 00050 /*---------------------------------------------------------------------------*/ 00051 /* Constant declarations */ 00052 /*---------------------------------------------------------------------------*/ 00053 00054 /*---------------------------------------------------------------------------*/ 00055 /* Structure declarations */ 00056 /*---------------------------------------------------------------------------*/ 00057 00058 /*---------------------------------------------------------------------------*/ 00059 /* Type declarations */ 00060 /*---------------------------------------------------------------------------*/ 00061 00062 /*---------------------------------------------------------------------------*/ 00063 /* Variable declarations */ 00064 /*---------------------------------------------------------------------------*/ 00065 00066 /*---------------------------------------------------------------------------*/ 00067 /* Macro declarations */ 00068 /*---------------------------------------------------------------------------*/ 00069 00072 /*---------------------------------------------------------------------------*/ 00073 /* Static function prototypes */ 00074 /*---------------------------------------------------------------------------*/ 00075 00076 00079 /*---------------------------------------------------------------------------*/ 00080 /* Definition of exported functions */ 00081 /*---------------------------------------------------------------------------*/ 00082 00083 00084 /*---------------------------------------------------------------------------*/ 00085 /* Definition of internal functions */ 00086 /*---------------------------------------------------------------------------*/ 00087 00100 void PureSatInsertNewClauseForSimplePath(array_t *vertexArray, 00101 Ntk_Network_t *network, 00102 int step1, 00103 int step2, 00104 BmcCnfClauses_t *cnfClauses, 00105 st_table *nodeToMvfAigTable) 00106 { 00107 int i,j,k,mvfSize,index1,index2, cnfIndex; 00108 Ntk_Node_t * latch; 00109 MvfAig_Function_t *latchMvfAig; 00110 bAigEdge_t * latchBAig; 00111 array_t * tmpclause, *clauseArray, * clause, * clause1,*latchClause; 00112 mAig_Manager_t *manager = Ntk_NetworkReadMAigManager(network); 00113 char * Name; 00114 boolean nextLatch = FALSE; 00115 00116 latchClause = array_alloc(int,0); 00117 arrayForEachItem(char *,vertexArray,j,Name) 00118 { 00119 nextLatch = FALSE; 00120 clause = array_alloc(int,0); /*(-A + -A1 + -A2 + -A3)*/ 00121 clauseArray = array_alloc(array_t *,0);/*(A + -A1)(A + -A2)(A + -A3)*/ 00122 latch = Ntk_NetworkFindNodeByName(network,Name); 00123 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00124 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00125 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00126 array_free(latchMvfAig); 00127 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00128 } 00129 mvfSize = array_n(latchMvfAig); 00130 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00131 00132 for(i=0; i< mvfSize; i++){ 00133 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00134 } 00135 for(i=0; i< mvfSize; i++){ 00136 if (latchBAig[i] == bAig_One) 00137 nextLatch=TRUE;break; /* the clause is always true */ 00138 } 00139 00140 if(!nextLatch) 00141 { 00142 for(i=0; i< mvfSize; i++){ 00143 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00144 index1 = BmcGenerateCnfFormulaForAigFunction(manager,latchBAig[i],step1,cnfClauses); 00145 index2 = BmcGenerateCnfFormulaForAigFunction(manager,latchBAig[i],step2,cnfClauses); 00146 00147 cnfIndex = cnfClauses->cnfGlobalIndex++; 00148 tmpclause = array_alloc(int, 3); 00149 array_insert(int, tmpclause, 0, -index2); 00150 array_insert(int, tmpclause, 1, -index1); 00151 array_insert(int, tmpclause, 2, cnfIndex); 00152 BmcCnfInsertClause(cnfClauses, tmpclause); 00153 array_free(tmpclause); 00154 00155 tmpclause = array_alloc(int, 2); 00156 array_insert(int, tmpclause, 0, index2); 00157 array_insert(int, tmpclause, 1, -cnfIndex); 00158 BmcCnfInsertClause(cnfClauses, tmpclause); 00159 array_free(tmpclause); 00160 00161 tmpclause = array_alloc(int, 2); 00162 array_insert(int, tmpclause, 0, index1); 00163 array_insert(int, tmpclause, 1, -cnfIndex); 00164 BmcCnfInsertClause(cnfClauses, tmpclause); 00165 array_free(tmpclause); 00166 00167 /*(-A + A1 + A2 + A3)*/ 00168 array_insert_last(int,clause,cnfIndex); 00169 /*(A + -A1)(A + -A2)(A + -A3)*/ 00170 clause1 = array_alloc(int,0);/*(A + -A1/2/3)*/ 00171 array_insert_last(int,clause1,-cnfIndex); 00172 array_insert_last(array_t *,clauseArray,clause1); 00173 00174 } 00175 00176 cnfIndex = cnfClauses->cnfGlobalIndex++; /*A*/ 00177 /*(A + -A1)(A + -A2)(A + -A3)*/ 00178 arrayForEachItem(array_t *,clauseArray,k,clause1) 00179 { 00180 array_insert_last(int,clause1,cnfIndex); 00181 BmcCnfInsertClause(cnfClauses,clause1); 00182 array_free(clause1); 00183 } 00184 array_free(clauseArray); 00185 00186 /*(-A + A1 + A2 + A3)*/ 00187 array_insert_last(int,clause,-cnfIndex); 00188 BmcCnfInsertClause(cnfClauses,clause); 00189 array_free(clause); 00190 00191 /*(C + -A + -B)*/ 00192 array_insert_last(int,latchClause,-cnfIndex); 00193 } 00194 FREE(latchBAig); 00195 } 00196 cnfIndex = cnfClauses->cnfGlobalIndex++; /* C*/ 00197 array_insert_last(int,latchClause,cnfIndex); /*(C + -A + -B)*/ 00198 BmcCnfInsertClause(cnfClauses,latchClause); 00199 array_free(latchClause); 00200 00201 /*(-C)*/ 00202 latchClause = array_alloc(int,0); 00203 array_insert_last(int,latchClause,-cnfIndex); 00204 BmcCnfInsertClause(cnfClauses,latchClause); 00205 array_free(latchClause); 00206 } 00207 00208 00221 void PureSatInsertNewClauseForInit(array_t *vertexArray, 00222 Ntk_Network_t *network, 00223 int step1, 00224 int step2, 00225 BmcCnfClauses_t *cnfClauses, 00226 st_table *nodeToMvfAigTable) 00227 { 00228 int i,j,k,mvfSize,index1=0,index2=0, cnfIndex; 00229 Ntk_Node_t * latch, *latchInit; 00230 MvfAig_Function_t *initMvfAig,*latchMvfAig; 00231 bAigEdge_t * latchBAig,* initBAig; 00232 array_t * tmpclause, *clauseArray, * clause, * clause1,*latchClause; 00233 mAig_Manager_t *manager = Ntk_NetworkReadMAigManager(network); 00234 char * Name; 00235 boolean nextLatch = FALSE; 00236 00237 latchClause = array_alloc(int,0); 00238 arrayForEachItem(char *,vertexArray,j,Name) 00239 { 00240 nextLatch = FALSE; 00241 clause = array_alloc(int,0); /*(-A + -A1 + -A2 + -A3)*/ 00242 clauseArray = array_alloc(array_t *,0);/*(A + -A1)(A + -A2)(A + -A3)*/ 00243 latch = Ntk_NetworkFindNodeByName(network,Name); 00244 latchInit = Ntk_LatchReadInitialInput(latch); 00245 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00246 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00247 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00248 array_free(latchMvfAig); 00249 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00250 } 00251 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00252 00253 00254 mvfSize = array_n(latchMvfAig); 00255 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00256 initBAig = ALLOC(bAigEdge_t, mvfSize); 00257 /* printf("mvfSize = %d \n",mvfSize);*/ 00258 00259 for(i=0; i< mvfSize; i++){ 00260 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00261 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00262 } 00263 00264 for(i=0; i< mvfSize; i++){ 00265 if ((initBAig[i] == bAig_One) && (latchBAig[i] == bAig_One)) 00266 { 00267 nextLatch=TRUE; 00268 break; /* the clause is always true */ 00269 } 00270 } 00271 00272 00273 if(!nextLatch) 00274 { 00275 for(i=0; i< mvfSize; i++){ 00276 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00277 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00278 if(initBAig[i]==bAig_Zero ||latchBAig[i]==bAig_Zero) 00279 { 00280 continue; 00281 } 00282 if(initBAig[i]!=bAig_One) 00283 { 00284 index1 = BmcGenerateCnfFormulaForAigFunction(manager,initBAig[i],step1,cnfClauses); 00285 } 00286 if(latchBAig[i]!=bAig_One) 00287 { 00288 index2 = BmcGenerateCnfFormulaForAigFunction(manager,latchBAig[i],step2,cnfClauses); 00289 } 00290 00291 cnfIndex = cnfClauses->cnfGlobalIndex++; 00292 if (initBAig[i] == bAig_One){ 00293 tmpclause = array_alloc(int, 2); 00294 array_insert(int, tmpclause, 0, -index2); 00295 array_insert(int, tmpclause, 1, cnfIndex); 00296 BmcCnfInsertClause(cnfClauses, tmpclause); 00297 array_free(tmpclause); 00298 00299 tmpclause = array_alloc(int, 2); 00300 array_insert(int, tmpclause, 0, index2); 00301 array_insert(int, tmpclause, 1, -cnfIndex); 00302 BmcCnfInsertClause(cnfClauses, tmpclause); 00303 array_free(tmpclause); 00304 00305 } else if (latchBAig[i] == bAig_One){ 00306 tmpclause = array_alloc(int, 2); 00307 array_insert(int, tmpclause, 0, -index1); 00308 array_insert(int, tmpclause, 1, cnfIndex); 00309 BmcCnfInsertClause(cnfClauses, tmpclause); 00310 array_free(tmpclause); 00311 00312 tmpclause = array_alloc(int, 2); 00313 array_insert(int, tmpclause, 0, index1); 00314 array_insert(int, tmpclause, 1, -cnfIndex); 00315 BmcCnfInsertClause(cnfClauses, tmpclause); 00316 array_free(tmpclause); 00317 00318 } else { 00319 tmpclause = array_alloc(int, 3); 00320 array_insert(int, tmpclause, 0, -index2); 00321 array_insert(int, tmpclause, 1, -index1); 00322 array_insert(int, tmpclause, 2, cnfIndex); 00323 BmcCnfInsertClause(cnfClauses, tmpclause); 00324 array_free(tmpclause); 00325 00326 tmpclause = array_alloc(int, 2); 00327 array_insert(int, tmpclause, 0, index2); 00328 array_insert(int, tmpclause, 1, -cnfIndex); 00329 BmcCnfInsertClause(cnfClauses, tmpclause); 00330 array_free(tmpclause); 00331 00332 tmpclause = array_alloc(int, 2); 00333 array_insert(int, tmpclause, 0, index1); 00334 array_insert(int, tmpclause, 1, -cnfIndex); 00335 BmcCnfInsertClause(cnfClauses, tmpclause); 00336 array_free(tmpclause); 00337 } 00338 /*(-A + A1 + A2 + A3)*/ 00339 array_insert_last(int,clause,cnfIndex); 00340 /*(A + -A1)(A + -A2)(A + -A3)*/ 00341 clause1 = array_alloc(int,0);/*(A + -A1/2/3)*/ 00342 array_insert_last(int,clause1,-cnfIndex); 00343 array_insert_last(array_t *,clauseArray,clause1); 00344 00345 }/* for(i=0; i< mvfSize;*/ 00346 00347 cnfIndex = cnfClauses->cnfGlobalIndex++; /*A*/ 00348 /*(A + -A1)(A + -A2)(A + -A3)*/ 00349 arrayForEachItem(array_t *,clauseArray,k,clause1) 00350 { 00351 array_insert_last(int,clause1,cnfIndex); 00352 BmcCnfInsertClause(cnfClauses,clause1); 00353 array_free(clause1); 00354 } 00355 array_free(clauseArray); 00356 00357 /*(-A + A1 + A2 + A3)*/ 00358 array_insert_last(int,clause,-cnfIndex); 00359 BmcCnfInsertClause(cnfClauses,clause); 00360 array_free(clause); 00361 00362 /*(C + -A + -B)*/ 00363 array_insert_last(int,latchClause,-cnfIndex); 00364 }/* if(!nextLatch)*/ 00365 FREE(latchBAig); 00366 FREE(initBAig); 00367 }/*arrayForEach..*/ 00368 cnfIndex = cnfClauses->cnfGlobalIndex++; /* C*/ 00369 array_insert_last(int,latchClause,cnfIndex); /*(C + -A + -B)*/ 00370 BmcCnfInsertClause(cnfClauses,latchClause); 00371 array_free(latchClause); 00372 00373 /*(-C)*/ 00374 latchClause = array_alloc(int,0); 00375 array_insert_last(int,latchClause,-cnfIndex); 00376 BmcCnfInsertClause(cnfClauses,latchClause); 00377 array_free(latchClause); 00378 } 00379 00380 00392 void PureSatSetInitStatesForSimplePath(array_t * vertexArray, 00393 Ntk_Network_t *network, 00394 BmcCnfClauses_t *cnfClauses, 00395 st_table * nodeToMvfAigTable) 00396 { 00397 mAig_Manager_t *maigManager = Ntk_NetworkReadMAigManager(network); 00398 Ntk_Node_t *latch, *latchInit; 00399 MvfAig_Function_t *initMvfAig, *latchMvfAig; 00400 bAigEdge_t *initBAig, *latchBAig; 00401 int i,j, mvfSize; 00402 char *nodeName; 00403 00404 for(j=0;j<array_n(vertexArray);j++) 00405 { 00406 nodeName = array_fetch(char *,vertexArray,j); 00407 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00408 latchInit = Ntk_LatchReadInitialInput(latch); 00409 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00410 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00411 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00412 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00413 array_free(latchMvfAig); 00414 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00415 } 00416 00417 mvfSize = array_n(initMvfAig); 00418 initBAig = ALLOC(bAigEdge_t, mvfSize); 00419 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00420 00421 for(i=0; i< mvfSize; i++){ 00422 latchBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00423 initBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00424 } 00425 BmcGenerateClausesFromStateTostate(maigManager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 00426 FREE(initBAig); 00427 FREE(latchBAig); 00428 } 00429 } 00430 00431 00443 boolean PureSatExistASimplePath(Ntk_Network_t *network, 00444 PureSat_IncreSATManager_t * pism, 00445 array_t * vertexArray, 00446 bAigEdge_t property, 00447 PureSat_Manager_t * pm) 00448 { 00449 mAig_Manager_t *maigManager = Ntk_NetworkReadMAigManager(network); 00450 Ntk_Node_t *latch, *latchData, *latchInit; 00451 MvfAig_Function_t *initMvfAig, *dataMvfAig, *latchMvfAig; 00452 bAigEdge_t *initBAig, *latchBAig, *dataBAig; 00453 int i,j, k, mvfSize,propertyIndex; 00454 char *nodeName; 00455 array_t * Pclause = array_alloc(int,0); 00456 st_table *nodeToMvfAigTable; 00457 BmcCnfStates_t *cnfstate1,*cnfstate2; 00458 array_t *supportLatches; 00459 int status; 00460 int beginPosition = pism->beginPosition; 00461 int Length = pism->Length; 00462 int oldLength = pism->oldLength; 00463 BmcCnfClauses_t * cnfClauses = pism->cnfClauses; 00464 satManager_t * cm = pism->cm; 00465 00466 /* construct loopfree path;*/ 00467 nodeToMvfAigTable =(st_table *) Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY); 00468 if (nodeToMvfAigTable == NIL(st_table)){ 00469 (void) fprintf(vis_stderr,"** bmc error: please run buid_partiton_maigs first"); 00470 exit(0); 00471 } 00472 00473 for(j=beginPosition;j<array_n(vertexArray);j++){ 00474 nodeName = array_fetch(char *,vertexArray,j); 00475 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00476 latchInit = Ntk_LatchReadInitialInput(latch); 00477 latchData = Ntk_LatchReadDataInput(latch); 00478 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00479 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00480 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00481 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00482 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00483 array_free(latchMvfAig); 00484 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00485 } 00486 00487 mvfSize = array_n(initMvfAig); 00488 initBAig = ALLOC(bAigEdge_t, mvfSize); 00489 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00490 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00491 00492 for(i=0; i< mvfSize; i++){ 00493 dataBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00494 latchBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00495 initBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00496 } 00497 00498 /* BmcGenerateClausesFromStateTostate(maigManager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0);*/ 00499 for (k=0; k < oldLength; k++){ 00500 BmcGenerateClausesFromStateTostate(maigManager, dataBAig,latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00501 } 00502 FREE(initBAig); 00503 FREE(dataBAig); 00504 FREE(latchBAig); 00505 } /*st_foreach_item(vertexTable,*/ 00506 00507 if(oldLength<Length){ 00508 for(j=0;j<array_n(vertexArray);j++){ 00509 nodeName = array_fetch(char *,vertexArray,j); 00510 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00511 latchInit = Ntk_LatchReadInitialInput(latch); 00512 latchData = Ntk_LatchReadDataInput(latch); 00513 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00514 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00515 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00516 00517 mvfSize = array_n(initMvfAig); 00518 initBAig = ALLOC(bAigEdge_t, mvfSize); 00519 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00520 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00521 00522 for(i=0; i< mvfSize; i++){ 00523 dataBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00524 latchBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00525 initBAig[i] = bAig_GetCanonical(maigManager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00526 } 00527 00528 for (k=oldLength; k <Length; k++){ 00529 BmcGenerateClausesFromStateTostate(maigManager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00530 } 00531 FREE(initBAig); 00532 FREE(dataBAig); 00533 FREE(latchBAig); 00534 } 00535 }/*if(oldLength!=0){*/ 00536 00537 if(pm->verbosity>=1) 00538 fprintf(vis_stdout,"forward simple path testing...\n"); 00539 cnfstate1 = BmcCnfClausesFreeze(cnfClauses); 00540 00541 /*generate NODE(i)!=NODE(i+1)*/ 00542 for(i=1;i<Length;i++) 00543 for(j=i+1;j<=Length;j++) 00544 PureSatInsertNewClauseForSimplePath(vertexArray,network,i,j,cnfClauses,nodeToMvfAigTable); /*Si!=Sj*/ 00545 00546 cnfstate2 = BmcCnfClausesFreeze(cnfClauses); 00547 supportLatches = PureSatGetImmediateSupportLatches(network, 0, vertexArray); 00548 /*I(S0)*/ 00549 PureSatSetInitStatesForSimplePath(supportLatches/*vertexArray*/,network,cnfClauses,nodeToMvfAigTable); 00550 /*generate all.!I(S(1...i)), the first constraint*/ 00551 for(i=1;i<=Length;i++) 00552 PureSatInsertNewClauseForInit(supportLatches/*vertexArray*/,network,-1,i,cnfClauses,nodeToMvfAigTable); 00553 array_free(supportLatches); 00554 00555 pism->propertyPos = cnfstate1->nextIndex; 00556 PureSatReadClauses(pism,pm); 00557 /*no incremental */ 00558 if(!pm->incre){ 00559 if(cm->savedConflictClauses) 00560 sat_ArrayFree(cm->savedConflictClauses); 00561 cm->savedConflictClauses = 0; 00562 } 00563 sat_Main(cm); 00564 status = cm->status; 00565 PureSatCleanSat(cm); 00566 BmcCnfClausesRestore(cnfClauses, cnfstate1); 00567 00568 if(status == SAT_SAT) 00569 { 00570 if(pm->verbosity>=1) 00571 fprintf(vis_stdout,"backward simple path testing...\n"); 00572 cnfstate2 = BmcCnfClausesFreeze(cnfClauses); 00573 /*generate NODE(i)!=NODE(i+1)*/ 00574 for(i=1;i<Length;i++) 00575 for(j=i+1;j<=Length;j++) 00576 PureSatInsertNewClauseForSimplePath(vertexArray,network,i,j,cnfClauses,nodeToMvfAigTable); 00578 propertyIndex = BmcGenerateCnfFormulaForAigFunction(maigManager,property, Length, cnfClauses); 00579 array_insert_last(int, Pclause,propertyIndex); 00580 BmcCnfInsertClause(cnfClauses, Pclause); 00581 array_free(Pclause); 00582 /*all.P(S(0,...i-1))*/ 00583 property = bAig_Not(property); 00584 for(k=0; k <= Length-1; k++){ 00585 propertyIndex = BmcGenerateCnfFormulaForAigFunction(maigManager,property,k, cnfClauses); 00586 Pclause = array_alloc(int,0); 00587 array_insert_last(int, Pclause, propertyIndex); 00588 BmcCnfInsertClause(cnfClauses, Pclause); 00589 array_free(Pclause); 00590 } 00591 00592 pism->propertyPos = cnfstate2->nextIndex; 00593 PureSatReadClauses(pism,pm); 00594 /*no incremental */ 00595 if(!pm->incre){ 00596 if(cm->savedConflictClauses) 00597 sat_ArrayFree(cm->savedConflictClauses); 00598 cm->savedConflictClauses = 0; 00599 } 00600 sat_Main(cm); 00601 status = cm->status; 00602 PureSatCleanSat(cm); 00603 if(status == SAT_SAT) 00604 { 00605 BmcCnfClausesRestore(cnfClauses, cnfstate1); 00606 FREE(cnfstate1); 00607 FREE(cnfstate2); 00608 return TRUE; 00609 } 00610 } 00611 FREE(cnfstate1); 00612 FREE(cnfstate2); 00613 return FALSE; 00614 } 00615 00628 boolean PureSatExistCE(Ntk_Network_t * network, 00629 PureSat_IncreSATManager_t * pism, 00630 BmcOption_t *options, 00631 array_t *vertexArray, 00632 bAigEdge_t property, 00633 PureSat_Manager_t * pm, 00634 int extractCexInfo) 00635 { 00636 mAig_Manager_t *manager = Ntk_NetworkReadMAigManager(network); 00637 Ntk_Node_t *latch, *latchData, *latchInit; 00638 MvfAig_Function_t *initMvfAig, *dataMvfAig, *latchMvfAig; 00639 bAigEdge_t *initBAig, *latchBAig, *dataBAig; 00640 int i,j, k, mvfSize; 00641 char *nodeName; 00642 array_t *result; 00643 array_t *Pclause = array_alloc(int, 0); 00644 FILE *cnfFile; 00645 st_table *nodeToMvfAigTable; 00646 BmcCnfStates_t *cnfstate; 00647 int beginPosition = pism->beginPosition; 00648 int oldLength = pism->oldLength; 00649 int Length = pism->Length; 00650 BmcCnfClauses_t *cnfClauses = pism->cnfClauses; 00651 00652 double t2, t1 = util_cpu_ctime(); 00653 00654 options->verbosityLevel = (Bmc_VerbosityLevel) pm->verbosity; 00655 nodeToMvfAigTable =(st_table *) Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY); 00656 if (nodeToMvfAigTable == NIL(st_table)){ 00657 (void) fprintf(vis_stderr,"** bmc error: please run buid_partiton_maigs first"); 00658 exit(0); 00659 } 00660 00661 00662 #if 1 00663 { 00664 array_t *supportLatches = PureSatGetImmediateSupportLatches(network, beginPosition, vertexArray); 00665 arrayForEachItem(char *, supportLatches, j, nodeName) { 00666 latch = Ntk_NetworkFindNodeByName(network, nodeName); 00667 latchInit = Ntk_LatchReadInitialInput(latch); 00668 latchData = Ntk_LatchReadDataInput(latch); 00669 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00670 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00671 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00672 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00673 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00674 array_free(latchMvfAig); 00675 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00676 } 00677 00678 mvfSize = array_n(initMvfAig); 00679 initBAig = ALLOC(bAigEdge_t, mvfSize); 00680 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00681 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00682 00683 for(i=0; i< mvfSize; i++){ 00684 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00685 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00686 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00687 } 00688 00689 BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 00690 FREE(initBAig); 00691 FREE(dataBAig); 00692 FREE(latchBAig); 00693 } 00694 array_free(supportLatches); 00695 } 00696 00697 00698 for(j=beginPosition;j<array_n(vertexArray);j++){ 00699 nodeName = array_fetch(char *,vertexArray,j); 00700 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00701 latchInit = Ntk_LatchReadInitialInput(latch); 00702 latchData = Ntk_LatchReadDataInput(latch); 00703 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00704 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00705 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00706 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00707 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00708 array_free(latchMvfAig); 00709 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00710 } 00711 00712 mvfSize = array_n(initMvfAig); 00713 initBAig = ALLOC(bAigEdge_t, mvfSize); 00714 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00715 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00716 00717 for(i=0; i< mvfSize; i++){ 00718 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00719 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00720 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00721 } 00722 /* BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0);*/ 00723 for (k=0; k <oldLength; k++){ 00724 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00725 } 00726 FREE(initBAig); 00727 FREE(dataBAig); 00728 FREE(latchBAig); 00729 } /*st_foreach_item(vertexTable,*/ 00730 #else 00731 /*build TR for more latches*/ 00732 00733 for(j=beginPosition;j<array_n(vertexArray);j++){ 00734 nodeName = array_fetch(char *,vertexArray,j); 00735 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00736 latchInit = Ntk_LatchReadInitialInput(latch); 00737 latchData = Ntk_LatchReadDataInput(latch); 00738 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00739 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00740 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00741 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00742 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00743 array_free(latchMvfAig); 00744 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00745 } 00746 00747 mvfSize = array_n(initMvfAig); 00748 initBAig = ALLOC(bAigEdge_t, mvfSize); 00749 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00750 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00751 00752 for(i=0; i< mvfSize; i++){ 00753 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00754 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00755 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00756 } 00757 BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 00758 for (k=0; k <oldLength; k++){ 00759 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00760 } 00761 FREE(initBAig); 00762 FREE(dataBAig); 00763 FREE(latchBAig); 00764 } /*st_foreach_item(vertexTable,*/ 00765 #endif 00766 00767 /* for more length*/ 00768 if(oldLength<Length){ 00769 for(j=0;j<array_n(vertexArray);j++){ 00770 nodeName = array_fetch(char *,vertexArray,j); 00771 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00772 latchInit = Ntk_LatchReadInitialInput(latch); 00773 latchData = Ntk_LatchReadDataInput(latch); 00774 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00775 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00776 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00777 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00778 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00779 array_free(latchMvfAig); 00780 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00781 } 00782 00783 mvfSize = array_n(initMvfAig); 00784 initBAig = ALLOC(bAigEdge_t, mvfSize); 00785 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00786 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00787 00788 for(i=0; i< mvfSize; i++){ 00789 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00790 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00791 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00792 } 00793 00794 for (k=oldLength; k<Length; k++){ 00795 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00796 } 00797 FREE(initBAig); 00798 FREE(dataBAig); 00799 FREE(latchBAig); 00800 } 00801 } 00802 00803 00804 k=Length; 00805 cnfstate = BmcCnfClausesFreeze(cnfClauses); 00806 /* for(k=0; k <= Length; k++){*/ 00807 array_insert_last(int, Pclause, BmcGenerateCnfFormulaForAigFunction(manager, property,k, cnfClauses)); 00808 /* } */ 00809 BmcCnfInsertClause(cnfClauses, Pclause); 00810 array_free(Pclause); 00811 cnfFile = Cmd_FileOpen(options->satInFile, "w", NIL(char *), 0); 00812 BmcWriteClauses(manager, cnfFile, cnfClauses, options); 00813 (void) fclose(cnfFile); 00814 result = BmcCheckSAT(options); 00815 BmcCnfClausesRestore(cnfClauses, cnfstate); 00816 FREE(cnfstate); 00817 00818 t2 = util_cpu_ctime(); 00819 /*timeElapse_Sol += t2-t1;*/ 00820 if(pm->verbosity>=2) 00821 fprintf(vis_stdout, "timeElapse_sol_noIncre: += %g\n", (double)((t2-t1)/1000.0)); 00822 00823 00824 if(extractCexInfo && pm->dbgLevel>=1 && result!=NIL(array_t)){ 00825 pm->result = array_dup(result); 00826 } 00827 00828 if(result!=NIL(array_t)) 00829 { 00830 if(pm->verbosity>=2) 00831 fprintf(vis_stdout, "find CEX\n"); 00832 array_free(result); 00833 return TRUE; 00834 } 00835 else 00836 { 00837 if(pm->verbosity>=2) 00838 fprintf(vis_stdout, "didn't find CEX\n"); 00839 return FALSE; 00840 } 00841 } 00842 00855 boolean PureSatIncreExistCE(Ntk_Network_t * network, 00856 PureSat_IncreSATManager_t *pism, 00857 array_t *vertexArray, 00858 bAigEdge_t property, 00859 PureSat_Manager_t * pm) 00860 { 00861 mAig_Manager_t *manager = Ntk_NetworkReadMAigManager(network); 00862 Ntk_Node_t *latch, *latchData, *latchInit; 00863 MvfAig_Function_t *initMvfAig, *dataMvfAig, *latchMvfAig; 00864 bAigEdge_t *initBAig, *latchBAig, *dataBAig; 00865 int i,j, k, mvfSize; 00866 int status; 00867 char *nodeName; 00868 array_t *Pclause = array_alloc(int, 0); 00869 st_table *nodeToMvfAigTable; 00870 BmcCnfStates_t *cnfstate; 00871 int beginPosition = pism->beginPosition; 00872 int Length = pism->Length; 00873 int oldLength = pism->oldLength; 00874 BmcCnfClauses_t * cnfClauses = pism->cnfClauses; 00875 satManager_t * cm = pism->cm; 00876 00877 nodeToMvfAigTable =(st_table *) Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY); 00878 if (nodeToMvfAigTable == NIL(st_table)){ 00879 (void) fprintf(vis_stderr,"** bmc error: please run buid_partiton_maigs first"); 00880 exit(0); 00881 } 00882 00883 { 00884 array_t *supportLatches = PureSatGetImmediateSupportLatches(network, beginPosition, vertexArray); 00885 arrayForEachItem(char *, supportLatches, j, nodeName) { 00886 latch = Ntk_NetworkFindNodeByName(network, nodeName); 00887 latchInit = Ntk_LatchReadInitialInput(latch); 00888 latchData = Ntk_LatchReadDataInput(latch); 00889 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00890 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00891 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00892 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00893 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00894 array_free(latchMvfAig); 00895 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00896 } 00897 00898 mvfSize = array_n(initMvfAig); 00899 initBAig = ALLOC(bAigEdge_t, mvfSize); 00900 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00901 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00902 00903 for(i=0; i< mvfSize; i++){ 00904 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00905 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00906 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00907 } 00908 00909 BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 00910 FREE(initBAig); 00911 FREE(dataBAig); 00912 FREE(latchBAig); 00913 } 00914 array_free(supportLatches); 00915 } 00916 00917 for(j=beginPosition;j<array_n(vertexArray);j++){ 00918 nodeName = array_fetch(char *,vertexArray,j); 00919 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00920 latchInit = Ntk_LatchReadInitialInput(latch); 00921 latchData = Ntk_LatchReadDataInput(latch); 00922 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00923 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00924 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00925 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00926 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00927 array_free(latchMvfAig); 00928 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00929 } 00930 00931 mvfSize = array_n(initMvfAig); 00932 initBAig = ALLOC(bAigEdge_t, mvfSize); 00933 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00934 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00935 00936 for(i=0; i< mvfSize; i++){ 00937 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00938 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00939 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00940 } 00941 BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 00942 for (k=0; k <oldLength; k++){ 00943 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00944 } 00945 FREE(initBAig); 00946 FREE(dataBAig); 00947 FREE(latchBAig); 00948 } 00949 00950 /* for more length*/ 00951 if(oldLength<Length){ 00952 for(j=0;j<array_n(vertexArray);j++){ 00953 nodeName = array_fetch(char *,vertexArray,j); 00954 latch = Ntk_NetworkFindNodeByName(network,nodeName); 00955 latchInit = Ntk_LatchReadInitialInput(latch); 00956 latchData = Ntk_LatchReadDataInput(latch); 00957 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 00958 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 00959 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00960 if (latchMvfAig == NIL(MvfAig_Function_t)){ 00961 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 00962 array_free(latchMvfAig); 00963 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 00964 } 00965 00966 mvfSize = array_n(initMvfAig); 00967 initBAig = ALLOC(bAigEdge_t, mvfSize); 00968 dataBAig = ALLOC(bAigEdge_t, mvfSize); 00969 latchBAig = ALLOC(bAigEdge_t, mvfSize); 00970 00971 for(i=0; i< mvfSize; i++){ 00972 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 00973 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 00974 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 00975 } 00976 00977 for (k=oldLength; k<Length; k++){ 00978 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 00979 } 00980 FREE(initBAig); 00981 FREE(dataBAig); 00982 FREE(latchBAig); 00983 } 00984 } 00985 00986 k=Length; 00987 cnfstate = BmcCnfClausesFreeze(cnfClauses); 00988 /* for(k=0; k <= Length; k++){*/ 00989 array_insert_last(int, Pclause, BmcGenerateCnfFormulaForAigFunction(manager, property,k, cnfClauses)); 00990 /* }*/ 00991 BmcCnfInsertClause(cnfClauses, Pclause); 00992 array_free(Pclause); 00993 pism->propertyPos = cnfstate->nextIndex; 00994 PureSatReadClauses(pism, pm); 00995 00996 /*no incremental */ 00997 if(!pm->incre){ 00998 if(cm->savedConflictClauses) 00999 sat_ArrayFree(cm->savedConflictClauses); 01000 cm->savedConflictClauses = 0; 01001 } 01002 cm->status = 0; 01003 sat_Main(cm); 01004 status = cm->status; 01005 PureSatCleanSat(cm); 01006 BmcCnfClausesRestore(cnfClauses, cnfstate); 01007 FREE(cnfstate); 01008 if(status == SAT_SAT) 01009 { 01010 if(pm->verbosity>=1) 01011 fprintf(vis_stdout, "find CEX\n"); 01012 return TRUE; 01013 } 01014 else 01015 { 01016 if(pm->verbosity>=1) 01017 fprintf(vis_stdout, "didn't find CEX\n"); 01018 return FALSE; 01019 } 01020 } 01021 01044 boolean PureSatIncreExistCEForRefineOnAbs(Ntk_Network_t *network, 01045 PureSat_IncreSATManager_t *pism, 01046 array_t *vertexArray, 01047 bAigEdge_t property, 01048 boolean firstTime, 01049 PureSat_Manager_t * pm) 01050 01051 { 01052 mAig_Manager_t *manager = Ntk_NetworkReadMAigManager(network); 01053 Ntk_Node_t *latch, *latchData, *latchInit; 01054 MvfAig_Function_t *initMvfAig, *dataMvfAig, *latchMvfAig; 01055 bAigEdge_t *initBAig, *latchBAig, *dataBAig; 01056 int i,j, k, mvfSize, status; 01057 char *nodeName; 01058 array_t *Pclause = array_alloc(int, 0); 01059 st_table *nodeToMvfAigTable; 01060 int beginPosition = pism->beginPosition; 01061 int Length = pism->Length; 01062 int oldLength = pism->oldLength; 01063 BmcCnfClauses_t * cnfClauses = pism->cnfClauses; 01064 satManager_t * cm = pism->cm; 01065 01066 nodeToMvfAigTable =(st_table *) Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY); 01067 if (nodeToMvfAigTable == NIL(st_table)){ 01068 (void) fprintf(vis_stderr,"** bmc error: please run buid_partiton_maigs first"); 01069 exit(0); 01070 } 01071 01072 { 01073 array_t *supportLatches = PureSatGetImmediateSupportLatches(network, beginPosition, vertexArray); 01074 arrayForEachItem(char *, supportLatches, j, nodeName) { 01075 latch = Ntk_NetworkFindNodeByName(network, nodeName); 01076 latchInit = Ntk_LatchReadInitialInput(latch); 01077 latchData = Ntk_LatchReadDataInput(latch); 01078 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 01079 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 01080 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01081 if (latchMvfAig == NIL(MvfAig_Function_t)){ 01082 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 01083 array_free(latchMvfAig); 01084 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01085 } 01086 01087 mvfSize = array_n(initMvfAig); 01088 initBAig = ALLOC(bAigEdge_t, mvfSize); 01089 dataBAig = ALLOC(bAigEdge_t, mvfSize); 01090 latchBAig = ALLOC(bAigEdge_t, mvfSize); 01091 01092 for(i=0; i< mvfSize; i++){ 01093 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 01094 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 01095 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 01096 } 01097 01098 BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 01099 FREE(initBAig); 01100 FREE(dataBAig); 01101 FREE(latchBAig); 01102 } 01103 array_free(supportLatches); 01104 } 01105 01106 01107 for(j=beginPosition;j<array_n(vertexArray);j++){ 01108 nodeName = array_fetch(char *,vertexArray,j); 01109 latch = Ntk_NetworkFindNodeByName(network,nodeName); 01110 latchInit = Ntk_LatchReadInitialInput(latch); 01111 latchData = Ntk_LatchReadDataInput(latch); 01112 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 01113 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 01114 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01115 if (latchMvfAig == NIL(MvfAig_Function_t)){ 01116 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 01117 array_free(latchMvfAig); 01118 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01119 } 01120 01121 mvfSize = array_n(initMvfAig); 01122 initBAig = ALLOC(bAigEdge_t, mvfSize); 01123 dataBAig = ALLOC(bAigEdge_t, mvfSize); 01124 latchBAig = ALLOC(bAigEdge_t, mvfSize); 01125 01126 for(i=0; i< mvfSize; i++){ 01127 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 01128 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 01129 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 01130 } 01131 01132 /*BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0);*/ 01133 for (k=0; k <oldLength; k++){ 01134 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 01135 } 01136 FREE(initBAig); 01137 FREE(dataBAig); 01138 FREE(latchBAig); 01139 } 01140 01141 /*for more length */ 01142 if(oldLength<Length){ 01143 for(j=0;j<array_n(vertexArray);j++){ 01144 nodeName = array_fetch(char *,vertexArray,j); 01145 latch = Ntk_NetworkFindNodeByName(network,nodeName); 01146 latchInit = Ntk_LatchReadInitialInput(latch); 01147 latchData = Ntk_LatchReadDataInput(latch); 01148 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 01149 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 01150 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01151 if (latchMvfAig == NIL(MvfAig_Function_t)){ 01152 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 01153 array_free(latchMvfAig); 01154 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01155 } 01156 01157 mvfSize = array_n(initMvfAig); 01158 initBAig = ALLOC(bAigEdge_t, mvfSize); 01159 dataBAig = ALLOC(bAigEdge_t, mvfSize); 01160 latchBAig = ALLOC(bAigEdge_t, mvfSize); 01161 01162 for(i=0; i< mvfSize; i++){ 01163 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 01164 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 01165 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 01166 } 01167 01168 for (k=oldLength; k<Length; k++){ 01169 BmcGenerateClausesFromStateTostate(manager, dataBAig, latchBAig, mvfSize, k, k+1, cnfClauses, 0); 01170 } 01171 FREE(initBAig); 01172 FREE(dataBAig); 01173 FREE(latchBAig); 01174 } 01175 } 01176 01177 01178 /*cnfstate = BmcCnfClausesFreeze(cnfClauses);*/ 01179 if(firstTime){ 01180 /* pism->propertyPos = cnfstate->nextIndex;*/ 01181 array_insert_last(int, Pclause, BmcGenerateCnfFormulaForAigFunction(manager, 01182 property,Length, cnfClauses)); 01183 BmcCnfInsertClause(cnfClauses, Pclause); 01184 array_free(Pclause); 01185 } 01186 PureSatReadClauses(pism,pm); 01187 sat_Main(cm); 01188 if(pm->dbgLevel>=1 && cm->status==SAT_SAT){ 01189 pm->result = array_alloc(int, 0); 01190 { 01191 int size, value; 01192 size = cm->initNumVariables * satNodeSize; 01193 for(i=satNodeSize; i<=size; i+=satNodeSize) { 01194 value = SATvalue(i); 01195 if(value == 1) { 01196 array_insert_last(int, pm->result, SATnodeID(i)); 01197 } 01198 else if(value == 0) { 01199 array_insert_last(int, pm->result, -(SATnodeID(i))); 01200 } 01201 } 01202 } 01203 } 01204 status = cm->status; 01205 PureSatCleanSat(cm); 01206 /*FREE(cnfstate);*/ 01207 if(status == SAT_SAT) 01208 { 01209 if(pm->verbosity>=1) 01210 fprintf(vis_stdout, "find CEX\n"); 01211 return TRUE; 01212 } 01213 else 01214 { 01215 if(pm->verbosity>=1) 01216 fprintf(vis_stdout, "didn't find CEX\n"); 01217 return FALSE; 01218 } 01219 } 01220 01221 01236 void 01237 PureSatGenerateClausesFromStateTostateWithTable( 01238 bAig_Manager_t *manager, 01239 bAigEdge_t *fromAigArray, 01240 bAigEdge_t *toAigArray, 01241 int mvfSize, 01242 int fromState, 01243 int toState, 01244 BmcCnfClauses_t *cnfClauses, 01245 int outIndex, 01246 st_table *ClsidxToLatchTable, 01247 char *nodeName) 01248 { 01249 array_t *clause, *tmpclause; 01250 int toIndex, fromIndex, cnfIndex; 01251 int i; 01252 01253 toIndex =0; 01254 fromIndex = 0; 01255 01256 for(i=0; i< mvfSize; i++){ 01257 if ((fromAigArray[i] == bAig_One) && (toAigArray[i] == bAig_One)){ 01258 return; /* the clause is always true */ 01259 } 01260 } 01261 clause = array_alloc(int, 0); 01262 for(i=0; i< mvfSize; i++){ 01263 if ((fromAigArray[i] != bAig_Zero) && (toAigArray[i] != bAig_Zero)){ 01264 if (toAigArray[i] != bAig_One){ 01265 toIndex = BmcGenerateCnfFormulaForAigFunction(manager,toAigArray[i], 01266 toState,cnfClauses); 01267 } 01268 if (fromAigArray[i] != bAig_One){ 01269 fromIndex = BmcGenerateCnfFormulaForAigFunction(manager,fromAigArray[i], 01270 fromState,cnfClauses); 01271 } 01272 cnfIndex = cnfClauses->cnfGlobalIndex++; /* index of the output of the OR of T(from, to) */ 01273 if (toAigArray[i] == bAig_One){ 01274 tmpclause = array_alloc(int, 2); 01275 array_insert(int, tmpclause, 0, -fromIndex); 01276 array_insert(int, tmpclause, 1, cnfIndex); 01277 BmcCnfInsertClause(cnfClauses, tmpclause); 01278 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01279 array_free(tmpclause); 01280 01281 tmpclause = array_alloc(int, 2); 01282 array_insert(int, tmpclause, 0, fromIndex); 01283 array_insert(int, tmpclause, 1, -cnfIndex); 01284 BmcCnfInsertClause(cnfClauses, tmpclause); 01285 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01286 array_free(tmpclause); 01287 01288 } else if (fromAigArray[i] == bAig_One){ 01289 tmpclause = array_alloc(int, 2); 01290 array_insert(int, tmpclause, 0, -toIndex); 01291 array_insert(int, tmpclause, 1, cnfIndex); 01292 BmcCnfInsertClause(cnfClauses, tmpclause); 01293 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01294 array_free(tmpclause); 01295 01296 tmpclause = array_alloc(int, 2); 01297 array_insert(int, tmpclause, 0, toIndex); 01298 array_insert(int, tmpclause, 1, -cnfIndex); 01299 BmcCnfInsertClause(cnfClauses, tmpclause); 01300 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01301 array_free(tmpclause); 01302 01303 } else { 01304 tmpclause = array_alloc(int, 3); 01305 array_insert(int, tmpclause, 0, -toIndex); 01306 array_insert(int, tmpclause, 1, -fromIndex); 01307 array_insert(int, tmpclause, 2, cnfIndex); 01308 BmcCnfInsertClause(cnfClauses, tmpclause); 01309 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01310 array_free(tmpclause); 01311 01312 tmpclause = array_alloc(int, 2); 01313 array_insert(int, tmpclause, 0, toIndex); 01314 array_insert(int, tmpclause, 1, -cnfIndex); 01315 BmcCnfInsertClause(cnfClauses, tmpclause); 01316 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01317 array_free(tmpclause); 01318 01319 tmpclause = array_alloc(int, 2); 01320 array_insert(int, tmpclause, 0, fromIndex); 01321 array_insert(int, tmpclause, 1, -cnfIndex); 01322 BmcCnfInsertClause(cnfClauses, tmpclause); 01323 st_insert(ClsidxToLatchTable,(char *)(long)(cnfClauses->noOfClauses-1),nodeName); 01324 array_free(tmpclause); 01325 } 01326 array_insert_last(int, clause, cnfIndex); 01327 } /* if */ 01328 01329 } /* for i loop */ 01330 if (outIndex != 0 ){ 01331 array_insert_last(int, clause, -outIndex); 01332 } 01333 BmcCnfInsertClause(cnfClauses, clause); 01334 array_free(clause); 01335 01336 return; 01337 } 01338 01339 01352 void 01353 PureSatGenerateClausesForPath_EnhanceInit( 01354 Ntk_Network_t *network, 01355 int from, 01356 int to, 01357 PureSat_IncreSATManager_t * pism, 01358 PureSat_Manager_t * pm, 01359 st_table *nodeToMvfAigTable, 01360 st_table *CoiTable) 01361 { 01362 mAig_Manager_t *manager = Ntk_NetworkReadMAigManager(network); 01363 lsGen gen; 01364 01365 Ntk_Node_t *latch, *latchData, *latchInit; 01366 MvfAig_Function_t *initMvfAig, *dataMvfAig, *latchMvfAig; 01367 bAigEdge_t *initBAig, *latchBAig, *dataBAig; 01368 int i,j, k, mvfSize; 01369 array_t * vertexArray = array_alloc(char *,0); 01370 char * nodeName; 01371 BmcCnfClauses_t * cnfClauses = pism->cnfClauses; 01372 st_table * ClsidxToLatchTable = pm->ClsidxToLatchTable; 01373 01374 if(from == 0){ 01375 if(pm->verbosity>=2) 01376 fprintf(vis_stdout, "node in vertexArray: "); 01377 Ntk_NetworkForEachLatch(network, gen, latch) { 01378 int tmp; 01379 if (!st_lookup_int(CoiTable, latch, &tmp)){ 01380 continue; 01381 } 01382 nodeName = Ntk_NodeReadName(latch); 01383 array_insert_last(char *,vertexArray,nodeName); 01384 if(pm->verbosity>=2) 01385 fprintf(vis_stdout, "%s ",nodeName); 01386 } 01387 if(pm->verbosity>=2) 01388 fprintf(vis_stdout, "\n"); 01389 } 01390 01391 if(from == 0){ 01392 array_t *supportLatches = PureSatGetImmediateSupportLatches(network, 0, vertexArray); 01393 arrayForEachItem(char *, supportLatches, j, nodeName) { 01394 latch = Ntk_NetworkFindNodeByName(network, nodeName); 01395 latchInit = Ntk_LatchReadInitialInput(latch); 01396 latchData = Ntk_LatchReadDataInput(latch); 01397 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 01398 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 01399 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01400 if (latchMvfAig == NIL(MvfAig_Function_t)){ 01401 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 01402 array_free(latchMvfAig); 01403 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01404 } 01405 01406 mvfSize = array_n(initMvfAig); 01407 initBAig = ALLOC(bAigEdge_t, mvfSize); 01408 dataBAig = ALLOC(bAigEdge_t, mvfSize); 01409 latchBAig = ALLOC(bAigEdge_t, mvfSize); 01410 01411 for(i=0; i< mvfSize; i++){ 01412 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 01413 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 01414 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 01415 } 01416 01417 BmcGenerateClausesFromStateTostate(manager, initBAig, latchBAig, mvfSize, -1, 0, cnfClauses, 0); 01418 FREE(initBAig); 01419 FREE(dataBAig); 01420 FREE(latchBAig); 01421 } 01422 array_free(supportLatches); 01423 array_free(vertexArray); 01424 } 01425 01426 Ntk_NetworkForEachLatch(network, gen, latch) { 01427 int tmp; 01428 if (!st_lookup_int(CoiTable, latch, &tmp)){ 01429 continue; 01430 } 01431 nodeName = Ntk_NodeReadName(latch); 01432 latchInit = Ntk_LatchReadInitialInput(latch); 01433 latchData = Ntk_LatchReadDataInput(latch); 01434 01435 /* Get the multi-valued function for each node*/ 01436 initMvfAig = Bmc_ReadMvfAig(latchInit, nodeToMvfAigTable); 01437 if (initMvfAig == NIL(MvfAig_Function_t)){ 01438 (void) fprintf(vis_stdout, "No multi-valued function for this node %s \n", Ntk_NodeReadName(latchInit)); 01439 return; 01440 } 01441 dataMvfAig = Bmc_ReadMvfAig(latchData, nodeToMvfAigTable); 01442 if (dataMvfAig == NIL(MvfAig_Function_t)){ 01443 (void) fprintf(vis_stdout, "No multi-valued function for this node %s \n", Ntk_NodeReadName(latchData)); 01444 return; 01445 } 01446 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01447 if (latchMvfAig == NIL(MvfAig_Function_t)){ 01448 latchMvfAig = Bmc_NodeBuildMVF(network, latch); 01449 array_free(latchMvfAig); 01450 latchMvfAig = Bmc_ReadMvfAig(latch, nodeToMvfAigTable); 01451 } 01452 01453 mvfSize = array_n(initMvfAig); 01454 initBAig = ALLOC(bAigEdge_t, mvfSize); 01455 dataBAig = ALLOC(bAigEdge_t, mvfSize); 01456 latchBAig = ALLOC(bAigEdge_t, mvfSize); 01457 01458 for(i=0; i< mvfSize; i++){ 01459 dataBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(dataMvfAig, i)); 01460 latchBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(latchMvfAig, i)); 01461 initBAig[i] = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(initMvfAig, i)); 01462 } 01463 /* Generate the CNF for the transition functions */ 01464 for (k=from; k < to; k++){ 01465 PureSatGenerateClausesFromStateTostateWithTable(manager, dataBAig,latchBAig, mvfSize, k, 01466 k+1, cnfClauses,0,ClsidxToLatchTable, nodeName); 01467 } /* for k state loop */ 01468 FREE(initBAig); 01469 FREE(dataBAig); 01470 FREE(latchBAig); 01471 } /* ForEachLatch loop*/ 01472 01473 return; 01474 }