Changeset 44 for vis_dev/vis-2.3/src/debug
- Timestamp:
- Jan 24, 2012, 3:41:23 PM (13 years ago)
- Location:
- vis_dev/vis-2.3/src/debug
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vis_dev/vis-2.3/src/debug/debug.c
r42 r44 132 132 { 133 133 Ntk_Network_t * ntk; 134 int c,verbose; 134 int c,verbose = 0; 135 array_t * excludes = NIL(array_t); 135 136 Dbg_Abnormal_t * abnormal; 136 137 ntk = Ntk_HrcManagerReadCurrentNetwork(*hmgr); 138 char * subs; 137 139 if (ntk == NIL(Ntk_Network_t)) { 138 140 (void) fprintf(vis_stdout, "** abn error: No network\n"); 139 141 return 1; 140 142 } 141 while ((c = util_getopt(argc, argv, "vh :m:k:o:")) != EOF) {143 while ((c = util_getopt(argc, argv, "vhs:")) != EOF) { 142 144 switch(c) { 145 case 'h': 146 goto usage; 143 147 case 'v': 144 148 verbose = 1; 145 149 break; 150 case 's': 151 subs = util_strsav(util_optarg); 152 excludes = array_alloc(char*,0); 153 array_insert_last(char*,excludes,subs); 154 break; 155 default : 156 goto usage; 146 157 } 147 158 } 148 159 abnormal = Dbg_DebugAbnormalAlloc(ntk); 149 160 abnormal->verbose = verbose; 150 Dbg_AddAbnormalPredicatetoNetwork(abnormal); 151 } 161 printf("SUBS %s \n",subs); 162 Dbg_AddAbnormalPredicatetoNetwork(abnormal,excludes); 163 printf("\t # Abnormal predicate created %d\n", array_n(abnormal->abnormal)); 164 return 0; 165 usage : 166 (void) fprintf(vis_stderr, "usage: _createAbn [-h] [-v verboseLevel] [-s substystem excludes\n"); 167 (void) fprintf(vis_stderr, " -h \tprint the command usage\n"); 168 (void) fprintf(vis_stderr, " -v \t verbosity\n"); 169 (void) fprintf(vis_stderr, " -s <subsystemName> \texclude the abnormal predicate\ 170 for this subssytem\n"); 171 return 1; 172 } 173 152 174 /**Function******************************************************************** 153 175 … … 190 212 array_t * formulaArray; 191 213 array_t * LTLformulaArray; 192 char * ltlFileName = NIL(char);193 214 array_t * faultNodes = array_alloc(Ntk_Node_t*,0); 194 215 … … 201 222 202 223 203 printf("MAX K %d", options->maxK);204 224 205 225 if (verbose) { … … 252 272 } 253 273 Ctlsp_Formula_t *ltlFormula = array_fetch(Ctlsp_Formula_t *, LTLformulaArray, 0); 254 255 274 256 275 … … 283 302 int l; 284 303 // return the clause number 285 int noLoopIndex = BmcGenerateCnfForLtl(network, ltlFormula, 0, k, k, cnfClauses); 304 int noLoopIndex = BmcGenerateCnfForLtl(network, ltlFormula, 0, k, k, cnfClauses); printf("LTL %d \n",noLoopIndex); 286 305 287 306 … … 298 317 assert(nodeToMvfAigTable != NIL(st_table)); 299 318 300 Dbg_InitAbn(abn,manager, nodeToMvfAigTable, cnfClauses);319 Dbg_InitAbn(abn,manager, nodeToMvfAigTable,k,cnfClauses); 301 320 302 321 //loop abnormal … … 305 324 Dbg_ForEachAbnormal(abn,aIndex,abnNode){ 306 325 char * nodeName = Ntk_NodeReadName(abnNode); 307 //set abnormal 308 int cnfIndex = array_fetch(int,abn->abnCnfIndexArray, aIndex); 326 //set abnormal for each step 327 array_t * cnfIndexArray = array_fetch(array_t*,abn->abnCnfIndexArray,aIndex); 328 int cnfIndex; 329 int step; 309 330 bAigEdge_t* abnBAig = array_fetch(bAigEdge_t*,abn->abnAigArray, aIndex); 310 int abnIndex = BmcGenerateCnfFormulaForAigFunction(manager,abnBAig[1],0,cnfClauses); 311 array_insert(int,cnfClauses->clauseArray,cnfIndex,abnIndex); 312 FILE *cnfFile = Cmd_FileOpen(options->satInFile, "w", NIL(char *), 0); 313 BmcWriteClauses(manager, cnfFile, cnfClauses, options); 314 fclose(cnfFile); 315 331 array_t * cnfVal = array_alloc(int,0); 332 arrayForEachItem(int, cnfIndexArray, step, cnfIndex){ 333 int abnIndex = BmcGenerateCnfFormulaForAigFunction(manager,abnBAig[1],step,cnfClauses); 334 array_insert(int,cnfClauses->clauseArray,cnfIndex,abnIndex); 335 array_insert_last(int,cnfVal,abnIndex); 336 FILE *cnfFile = Cmd_FileOpen(options->satInFile, "w", NIL(char *), 0); 337 BmcWriteClauses(manager, cnfFile, cnfClauses, options); 338 fclose(cnfFile); 339 printf("AINDEX %d\n",aIndex); 340 if(aIndex == 0) 341 { 342 FILE *cnfFile = Cmd_FileOpen("test_aks.cnf", "w", NIL(char *), 0); 343 BmcWriteClauses(manager, cnfFile, cnfClauses, options); 344 fclose(cnfFile); 345 346 } 347 }//end for each step 348 316 349 //SAT procedure 317 350 //assig assig input from cex 318 351 //TODO build cex correctly 319 int res = Dbg_SatCheck("assig",options-> cnfFileName,options->verbosityLevel);352 int res = Dbg_SatCheck("assig",options->satInFile,options->verbosityLevel); 320 353 // Build set of FaultCandidates 321 354 if (res == SAT_SAT) 322 355 { 323 356 char * realNodeName = util_strsav(nodeName); 324 realNodeName[strlen(nodeName)-4] = '\0'; 357 realNodeName[strlen(nodeName)-3] = '\0'; 358 printf("Real = %s\n", realNodeName); 325 359 Ntk_Node_t * realNode = Ntk_NetworkFindNodeByName(network,realNodeName); 326 360 array_insert_last(Ntk_Node_t*,faultNodes,realNode); 327 361 } 328 362 329 330 array_insert(int,cnfClauses->clauseArray,cnfIndex,-abnIndex); 363 arrayForEachItem(int, cnfIndexArray, step, cnfIndex){ 364 int abnIndex = array_fetch(int,cnfVal,step); 365 array_insert(int,cnfClauses->clauseArray,cnfIndex,-abnIndex); 366 } 331 367 } 332 368 … … 335 371 latches %d \n",cnfClauses->noOfClauses,st_count(CoiTable)); 336 372 373 337 374 (void) fprintf(vis_stdout,"Number of Fault candidates %d\n", 338 375 array_n(faultNodes)); 339 376 (void) fprintf(vis_stdout,"gates : \n"); 377 378 340 379 printNodeArray(faultNodes); 341 380 … … 346 385 array_free(faultNodes); 347 386 return 0; 348 349 } 387 } 388 350 389 /**Function******************************************************************** 351 390 … … 420 459 if (argc - util_optind != 0) 421 460 { 422 423 461 outName = util_strsav(argv[util_optind]); 462 /* create SAT Solver input file */ 424 463 options->cnfFileName= outName; 425 options->satInFile = options->cnfFileName;426 cnfFile = Cmd_FileOpen(options->satInFile, "w", NIL(char *), 0);464 options->satInFile = options->cnfFileName; 465 cnfFile = Cmd_FileOpen(options->satInFile, "w", NIL(char *), 0); 427 466 } 428 467 -
vis_dev/vis-2.3/src/debug/debug.h
r42 r44 126 126 EXTERN void Dbg_DebugAbnormalFree(Dbg_Abnormal_t * abn); 127 127 EXTERN void Dbg_AbnormalFreeCallback(void *data); 128 EXTERN void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal); 128 EXTERN void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal,array_t* 129 excludes); 129 130 EXTERN void Dbg_AddAbnormalPredicate(Dbg_Abnormal_t * abn, Ntk_Node_t* abnNode); 130 131 EXTERN void Dbg_AddFreeInput(Dbg_Abnormal_t * abn, Ntk_Node_t* fNode); … … 133 134 EXTERN Dbg_Abnormal_t * Dbg_NetworkReadAbnormal(Ntk_Network_t * network); 134 135 EXTERN void Dbg_InitAbn(Dbg_Abnormal_t * abn, bAig_Manager_t * manager, 135 st_table * nodeToMvfAigTable, BmcCnfClauses_t *cnfClauses);136 st_table * nodeToMvfAigTable, int k, BmcCnfClauses_t *cnfClauses); 136 137 EXTERN int Dbg_SatCheck(char * forceAssigName, char * cnfFileName, int verbose); 137 138 EXTERN BmcCnfClauses_t* Dbg_GenerateCNF(Ntk_Network_t * network, … … 140 141 141 142 142 143 143 /**AutomaticEnd***************************************************************/ 144 144 -
vis_dev/vis-2.3/src/debug/debugAbnormal.c
r42 r44 19 19 char * nodeName = util_strsav(Ntk_NodeReadName(node)); 20 20 //Create var Name 21 char * newVarName = (char *) malloc(strlen(nodeName) + strlen(varName) +1); 22 sprintf(newVarName,"%s_%s",nodeName,varName); 21 //char * newVarName = (char *) malloc(strlen(nodeName) + strlen(varName) +1); 22 //sprintf(newVarName,"%s_%s",nodeName,varName); 23 char * newVarName = util_strcat3(nodeName,varName,""); 23 24 Var_Variable_t * var = Var_VariableAlloc(NIL(Hrc_Node_t),newVarName); 24 25 //Create new Node … … 45 46 For a combinatorial node n is tranformed into (abn_n)?i_n:n 46 47 If the abnormal predicate is active then n is replaced by a free input. 47 We assume that the combinatorial gate at on one bit only.] 48 We assume that the combinatorial gate at on one bit only. 49 The array excludes contains name of submodules which we do not want to add 50 abnormal predicates.] 48 51 49 52 SideEffects [fill the abnormal structure] … … 53 56 ******************************************************************************/ 54 57 55 void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal ) /*abnormal struct*/58 void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal,array_t* excludes) 56 59 { 57 60 … … 61 64 Ntk_NetworkForEachNode(ntk,gen,node){ 62 65 //For each combinatorial node 63 if(Ntk_NodeTestIsCombinational(node) ){66 if(Ntk_NodeTestIsCombinational(node) && !Ntk_NodeTestIsLatchDataInput(node)){ 64 67 if(Ntk_NodeReadNumFanins(node) > 1 && Ntk_NodeReadNumFanouts(node)> 0) 65 68 { 66 69 char * nodeName = util_strsav(Ntk_NodeReadName(node)); 70 71 72 if(!Dbg_TestNodeInSubs(nodeName,excludes)){ 67 73 printf("%s \n", nodeName); 68 74 … … 125 131 Tbl_TableWriteBlifMvToFile(table,0,vis_stdout); 126 132 } 133 } 127 134 } 128 135 } … … 132 139 (void *) abnormal); 133 140 } 141 134 142 /**Function******************************************************************** 135 143 … … 289 297 Synopsis [Initialize the abnormal predicate in the clauses array abni =0] 290 298 291 Description [Fill the Dbg data structure, abnAigArray con ains the set of Aig299 Description [Fill the Dbg data structure, abnAigArray contains the set of Aig 292 300 for the set of abnormal perdicate. Each abnormal are set to zero in the clause 293 array.predicabnCnfIndexArray is the cnf index. The correspondance is made by 294 the index in the table, the index of a node in abnArray is the same in 301 array.predicabnCnfIndexArray is the cnf index for each k steps. 302 The correspondance is made by the index in the table, 303 the index of a node in abnArray is the same in 295 304 abnAigArray and in abnIndexArray. If this array were alredy computed nothing 296 is done, if the aig or index information either. ]305 is done, if the aig or index information either. ] 297 306 298 307 SideEffects [Fill abnAigArray and abnCnfIndexArray] … … 304 313 bAig_Manager_t * manager, 305 314 st_table * nodeToMvfAigTable, 315 int k, 306 316 BmcCnfClauses_t *cnfClauses) 307 317 { … … 315 325 int size = array_n(abn->abnormal); 316 326 array_t * abnAigArray = array_alloc(bAigEdge_t *,size); 317 array_t * abnIndexArray = array_alloc(int,size); 327 array_t * abnIndexArray = array_alloc(array_t*,size); 328 int i; 318 329 int aIndex; 319 330 Ntk_Node_t * abnNode; … … 322 333 if (abnMvfAig == NIL(MvfAig_Function_t)){ 323 334 (void) fprintf(vis_stdout, "No multi-valued function for this node %s \ 324 create abnormal predicate firs \n", Ntk_NodeReadName(abnNode));335 create abnormal predicate first \n", Ntk_NodeReadName(abnNode)); 325 336 return ; 326 337 } … … 335 346 } 336 347 array_insert(bAigEdge_t*,abnAigArray,aIndex,abnBAig); 337 int abnIndex = BmcGenerateCnfFormulaForAigFunction(manager,abnBAig[0],0,cnfClauses); 338 array_insert(int,abnIndexArray,aIndex,cnfClauses->nextIndex); 339 // Create clause 340 array_t *abnClause = NIL(array_t); 341 abnClause = array_alloc(int, 0); 342 array_insert_last(int, abnClause, abnIndex); 343 BmcCnfInsertClause(cnfClauses, abnClause); 344 array_free(abnClause); 348 // Cnf Index 349 array_t * indexArray = array_alloc(int,k); 350 for (i = 0; i <= k;i++) 351 { 352 int abnIndex = BmcGenerateCnfFormulaForAigFunction(manager,abnBAig[0],i,cnfClauses); 353 array_insert(int,indexArray,i,cnfClauses->nextIndex); 354 // Create clause 355 array_t *abnClause = NIL(array_t); 356 abnClause = array_alloc(int, 0); 357 array_insert_last(int, abnClause, abnIndex); 358 BmcCnfInsertClause(cnfClauses, abnClause); 359 array_free(abnClause); 360 } 361 array_insert(array_t*,abnIndexArray,aIndex,indexArray); 362 //array_free(indexArray); 345 363 } 346 364 abn->abnAigArray = abnAigArray; -
vis_dev/vis-2.3/src/debug/debugInt.h
r42 r44 56 56 array_t * freeInputs; /* Array of Ntk_Node_t* */ 57 57 array_t * abnAigArray; /* Array of bAigEdge_t* as many entries as possible value */ 58 array_t * abnCnfIndexArray; /* Array of int*/58 array_t * abnCnfIndexArray; /* Array of array of cnf index for each steps */ 59 59 int verbose; 60 60 }; … … 86 86 void mdd_GetState_Values(mdd_manager *mgr, mdd_t * top, FILE * f); 87 87 void printNodeArray(array_t * nodeArray); 88 boolean Dbg_TestNodeInSubs(char* nodeName,array_t * subsName); 88 89 89 90 /**AutomaticEnd***************************************************************/ -
vis_dev/vis-2.3/src/debug/debugUtilities.c
r42 r44 236 236 } 237 237 } 238 238 /**Function******************************************************************** 239 240 Synopsis [Test if a node is in a given submodule] 241 242 Description [Return true if the node is in one of the submdule, 243 else return false. The comparison is made by the name of the node 244 compare to the name of the submodule. Node name n that belongs to a 245 subsystem named sub as in the following form : sub.n] 246 247 SideEffects [] 248 249 SeeAlso [] 250 251 ******************************************************************************/ 252 253 boolean Dbg_TestNodeInSubs(char* nodeName,array_t * subsName) 254 { 255 assert(nodeName != NIL(char)); 256 if(subsName == NIL(array_t)) 257 return 0; 258 if(array_n(subsName) == 0) 259 return 0; 260 int i; 261 char * subName; 262 arrayForEachItem(char*, subsName, i, subName){ 263 if(strstr(nodeName,subName) != NULL) 264 return 1; 265 } 266 return 0; 267 } 268
Note: See TracChangeset
for help on using the changeset viewer.