Changeset 38 for vis_dev/vis-2.3/src/debug
- Timestamp:
- Jan 8, 2012, 3:30:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vis_dev/vis-2.3/src/debug/debug.c
r37 r38 176 176 177 177 ******************************************************************************/ 178 static int 179 checkIndex( 180 int index, 181 BmcCnfClauses_t *cnfClauses) 182 { 183 int rtnValue = -1; /* it is not TRUE or FALSE*/ 184 185 if (index == 0){ /* TRUE or FALSE*/ 186 if (cnfClauses->emptyClause){ /* last added clause was empty = FALSE*/ 187 rtnValue = 0; /* FALSE */ 188 } else { 189 /* 190 if (cnfClauses->noOfClauses == 0) 191 rtnValue = 1; 192 } 193 */ 194 rtnValue = 1; /* TRUE */ 195 } 196 } 197 return rtnValue; 198 } 178 199 179 200 … … 188 209 Ntk_Network_t * network; 189 210 bAig_Manager_t *manager; 190 211 array_t *formulaArray; 212 array_t *LTLformulaArray; 213 char *ltlFileName = NIL(char); 191 214 192 215 /* … … 194 217 */ 195 218 util_getopt_reset(); 196 while ((c = util_getopt(argc, argv, "vh :m:k:o:")) != EOF) {219 while ((c = util_getopt(argc, argv, "vhp:m:k:o:")) != EOF) { 197 220 switch(c) { 198 221 case 'v': … … 220 243 case 'o': 221 244 options->cnfFileName = util_strsav(util_optarg); 222 break; 245 break; 246 case 'p': 247 ltlFileName = util_strsav(util_optarg); 248 break; 223 249 224 250 default: … … 226 252 } 227 253 } 254 printf("MAX K %d", options->maxK); 228 255 if (options->minK > options->maxK){ 229 256 (void) fprintf(vis_stderr, "** bmc error: value for -m option must not be greater than vlaue for -k option\n"); … … 282 309 } 283 310 311 /* 312 * Read the formula 313 */ 314 /* Read LTL Formulae */ 315 if (!ltlFileName) 316 goto usage; 317 318 options->ltlFile = Cmd_FileOpen(ltlFileName, "r", NIL(char *), 0); 319 if (options->ltlFile == NIL(FILE)) { 320 (void) fprintf(vis_stdout,"** _sat_debug error: Cannot open the file %s\n", ltlFileName); 321 FREE(ltlFileName); 322 BmcOptionFree(options); 323 } 324 FREE(ltlFileName); 325 326 formulaArray = Ctlsp_FileParseFormulaArray(options->ltlFile); 327 if (formulaArray == NIL(array_t)) { 328 (void) fprintf(vis_stderr, 329 "** bmc error: error in parsing CTL* Fromula from file\n"); 330 BmcOptionFree(options); 331 return 1; 332 } 333 if (array_n(formulaArray) == 0) { 334 (void) fprintf(vis_stderr, "** bmc error: No formula in file\n"); 335 BmcOptionFree(options); 336 Ctlsp_FormulaArrayFree(formulaArray); 337 return 1; 338 } 339 LTLformulaArray = Ctlsp_FormulaArrayConvertToLTL(formulaArray); 340 Ctlsp_FormulaArrayFree(formulaArray); 341 if (LTLformulaArray == NIL(array_t)){ 342 (void) fprintf(vis_stdout, "** bmc error: Invalid LTL formula\n"); 343 BmcOptionFree(options); 344 return 1; 345 } 346 Ctlsp_Formula_t *ltlFormula = array_fetch(Ctlsp_Formula_t *, LTLformulaArray, 0); 347 348 349 284 350 /* 285 351 Compute the cone of influence 286 here a list of state variables (latches)352 here : a list of state variables (latches) 287 353 */ 288 354 st_table *CoiTable = generateAllLatches(network); … … 316 382 Generate clauses for an initialized path of length k 317 383 */ 384 Ctlsp_FormulaPrint(vis_stdout, ltlFormula); 385 fprintf(vis_stdout, "\n"); 318 386 BmcCnfGenerateClausesForPath(network, 0, options->maxK, BMC_INITIAL_STATES, 319 387 cnfClauses, nodeToMvfAigTable, CoiTable); 388 389 //Generate ltl CNF 390 // BmcGenerateCnfForLtl Génére la formule borné et retourne un index 391 // aprÚs il faut ajouter l'objectif de l'index avec boucle ou pas ... 392 // cf. BmcLtlVerifyGeneralLtl 393 int k = options->maxK; 394 int l; 395 // return the clause number 396 int noLoopIndex = BmcGenerateCnfForLtl(network, ltlFormula, 0, k, -1, cnfClauses); 397 398 int leftValue = checkIndex(noLoopIndex, cnfClauses); 399 printf("noLoopIndex %d , leftValue %d \n", noLoopIndex,leftValue); 400 int rightValue,loop,andIndex; 401 array_t *orClause = NIL(array_t); 402 array_t *loopClause, *tmpclause; 403 404 if (leftValue != 1) { 405 orClause = array_alloc(int, 0); 406 if (leftValue == -1){ 407 array_insert_last(int, orClause, noLoopIndex); 408 } 409 loopClause = array_alloc(int, k+1); 410 for(l=0; l<=k; l++){ 411 int loopIndex = BmcGenerateCnfForLtl(network, ltlFormula, 0, k, l, cnfClauses); 412 rightValue = checkIndex(loopIndex, cnfClauses); 413 if (rightValue == 0){ 414 break; 415 } 416 if (rightValue !=0){ 417 loop = cnfClauses->cnfGlobalIndex++; 418 BmcCnfGenerateClausesFromStateToState(network, k, l, cnfClauses, 419 nodeToMvfAigTable, CoiTable, loop); 420 array_insert(int, loopClause, l, loop); 421 if(rightValue == -1){ 422 423 andIndex = cnfClauses->cnfGlobalIndex++; 424 tmpclause = array_alloc(int, 2); 425 array_insert(int, tmpclause, 0, loop); 426 array_insert(int, tmpclause, 1, -andIndex); 427 BmcCnfInsertClause(cnfClauses, tmpclause); 428 429 array_insert(int, tmpclause, 0, loopIndex); 430 array_insert(int, tmpclause, 1, -andIndex); 431 BmcCnfInsertClause(cnfClauses, tmpclause); 432 array_free(tmpclause); 433 array_insert_last(int, orClause, andIndex); 434 } 435 else { 436 array_insert_last(int, orClause, loop); 437 } 438 }} // for l loop 439 } 440 BmcCnfInsertClause(cnfClauses, orClause); 441 array_free(orClause); 442 443 444 445 446 447 448 320 449 if(verbose) 321 450 (void) fprintf(vis_stdout, "The _sat_debug generates %d clauses with %d\ 322 451 latches %d nodetomvf.\n",cnfClauses->noOfClauses,st_count(CoiTable),st_count(nodeToMvfAigTable)); 323 452 324 453 Ctlsp_FormulaArrayFree(LTLformulaArray); 325 454 BmcWriteClauses(manager, cnfFile, cnfClauses, options); 326 455 fclose(cnfFile); … … 330 459 usage: 331 460 (void) fprintf(vis_stderr, "usage: _sat_debug [-h] [-v] [-k max length] [-m \ 332 minimum length] [-o cnf_file] \n");461 minimum length] [-o cnf_file] [-p ltl_file]\n"); 333 462 (void) fprintf(vis_stderr, " -h\t\tprint the command usage\n"); 334 463 (void) fprintf(vis_stderr, " -v\t\tverbose\n"); 335 464 (void) fprintf(vis_stderr, " -m \tminimum length of counterexample to be checked (default is 0)\n"); 336 465 (void) fprintf(vis_stderr, " -k \tmaximum length of counterexample to be checked (default is 1)\n"); 337 (void) fprintf(vis_stderr, " -o <cnf_file> contains CNF of the counterexample\n"); 466 (void) fprintf(vis_stderr, " -o <cnf_file> contains CNF of the debug instance\n"); 467 (void) fprintf(vis_stderr, " -p <ltl_file> contains the ltl formula\n"); 338 468 return 1; /* error exit */ 339 469
Note: See TracChangeset
for help on using the changeset viewer.