Changeset 44 for vis_dev


Ignore:
Timestamp:
Jan 24, 2012, 3:41:23 PM (13 years ago)
Author:
cecile
Message:

abnormal predicate done

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  
    132132{
    133133  Ntk_Network_t * ntk;
    134   int c,verbose;
     134  int c,verbose = 0;
     135  array_t * excludes = NIL(array_t);
    135136  Dbg_Abnormal_t * abnormal;
    136137  ntk = Ntk_HrcManagerReadCurrentNetwork(*hmgr);
     138  char * subs;
    137139  if (ntk == NIL(Ntk_Network_t)) {
    138140        (void) fprintf(vis_stdout, "** abn error: No network\n");
    139141        return 1;
    140142  }
    141   while ((c = util_getopt(argc, argv, "vh:m:k:o:")) != EOF) {
     143  while ((c = util_getopt(argc, argv, "vhs:")) != EOF) {
    142144        switch(c) {
     145        case 'h':
     146          goto usage;
    143147                case 'v':
    144148                        verbose = 1;
    145149                        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;
    146157                }
    147158 }
    148159  abnormal = Dbg_DebugAbnormalAlloc(ntk);
    149160  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
    152174/**Function********************************************************************
    153175
     
    190212array_t          * formulaArray;
    191213array_t          * LTLformulaArray;
    192 char             * ltlFileName     = NIL(char);
    193214array_t          * faultNodes = array_alloc(Ntk_Node_t*,0);
    194215
     
    201222
    202223
    203 printf("MAX K %d", options->maxK);
    204224
    205225if (verbose) {
     
    252272}
    253273Ctlsp_Formula_t *ltlFormula  = array_fetch(Ctlsp_Formula_t *, LTLformulaArray, 0);
    254 
    255274
    256275
     
    283302    int l;
    284303    // 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);
    286305   
    287306
     
    298317    assert(nodeToMvfAigTable != NIL(st_table));
    299318
    300     Dbg_InitAbn(abn,manager, nodeToMvfAigTable,cnfClauses);
     319    Dbg_InitAbn(abn,manager, nodeToMvfAigTable,k,cnfClauses);
    301320
    302321    //loop abnormal
     
    305324    Dbg_ForEachAbnormal(abn,aIndex,abnNode){
    306325      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;
    309330      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
    316349      //SAT procedure
    317350      //assig assig input from cex
    318351      //TODO build cex correctly
    319       int res = Dbg_SatCheck("assig",options->cnfFileName,options->verbosityLevel);
     352      int res = Dbg_SatCheck("assig",options->satInFile,options->verbosityLevel);
    320353      // Build set of FaultCandidates
    321354      if (res == SAT_SAT)
    322355      {
    323356        char * realNodeName = util_strsav(nodeName);
    324         realNodeName[strlen(nodeName)-4] = '\0';
     357        realNodeName[strlen(nodeName)-3] = '\0';
     358        printf("Real = %s\n", realNodeName);
    325359        Ntk_Node_t * realNode =  Ntk_NetworkFindNodeByName(network,realNodeName);
    326360        array_insert_last(Ntk_Node_t*,faultNodes,realNode);
    327361      }
    328362
    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      }
    331367   }
    332368
     
    335371                latches %d \n",cnfClauses->noOfClauses,st_count(CoiTable));
    336372 
     373   
    337374        (void) fprintf(vis_stdout,"Number of Fault candidates %d\n",
    338375    array_n(faultNodes));
    339376        (void) fprintf(vis_stdout,"gates : \n");
     377
     378
    340379    printNodeArray(faultNodes);
    341380
     
    346385array_free(faultNodes);
    347386return 0;
    348  
    349 }
     387}
     388
    350389/**Function********************************************************************
    351390
     
    420459   if (argc - util_optind != 0)
    421460   {
    422       outName  = util_strsav(argv[util_optind]);
    423       /* create SAT Solver input file */
     461     outName  = util_strsav(argv[util_optind]);
     462     /* create SAT Solver input file */
    424463     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);
    427466  }
    428467 
  • vis_dev/vis-2.3/src/debug/debug.h

    r42 r44  
    126126EXTERN void Dbg_DebugAbnormalFree(Dbg_Abnormal_t * abn);
    127127EXTERN void Dbg_AbnormalFreeCallback(void *data);
    128 EXTERN void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal);
     128EXTERN void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal,array_t*
     129excludes);
    129130EXTERN void Dbg_AddAbnormalPredicate(Dbg_Abnormal_t * abn, Ntk_Node_t* abnNode);
    130131EXTERN void Dbg_AddFreeInput(Dbg_Abnormal_t * abn, Ntk_Node_t* fNode);
     
    133134EXTERN Dbg_Abnormal_t * Dbg_NetworkReadAbnormal(Ntk_Network_t * network);
    134135EXTERN void Dbg_InitAbn(Dbg_Abnormal_t * abn, bAig_Manager_t   * manager,
    135 st_table * nodeToMvfAigTable, BmcCnfClauses_t *cnfClauses);
     136st_table * nodeToMvfAigTable, int k, BmcCnfClauses_t *cnfClauses);
    136137EXTERN int Dbg_SatCheck(char * forceAssigName, char * cnfFileName, int verbose);
    137138EXTERN BmcCnfClauses_t* Dbg_GenerateCNF(Ntk_Network_t * network,
     
    140141
    141142
    142 
    143143/**AutomaticEnd***************************************************************/
    144144
  • vis_dev/vis-2.3/src/debug/debugAbnormal.c

    r42 r44  
    1919        char * nodeName = util_strsav(Ntk_NodeReadName(node));
    2020        //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,"");
    2324        Var_Variable_t * var = Var_VariableAlloc(NIL(Hrc_Node_t),newVarName);
    2425        //Create new Node
     
    4546  For a combinatorial node n is tranformed into (abn_n)?i_n:n
    4647  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.]
    4851
    4952  SideEffects [fill the abnormal structure]
     
    5356******************************************************************************/
    5457
    55 void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal ) /*abnormal struct*/
     58void Dbg_AddAbnormalPredicatetoNetwork(Dbg_Abnormal_t* abnormal,array_t* excludes)
    5659{
    5760
     
    6164  Ntk_NetworkForEachNode(ntk,gen,node){
    6265  //For each combinatorial node
    63   if(Ntk_NodeTestIsCombinational(node)){
     66  if(Ntk_NodeTestIsCombinational(node) && !Ntk_NodeTestIsLatchDataInput(node)){
    6467        if(Ntk_NodeReadNumFanins(node) > 1 && Ntk_NodeReadNumFanouts(node)> 0)
    6568        {
    6669                char * nodeName = util_strsav(Ntk_NodeReadName(node));
     70
     71
     72      if(!Dbg_TestNodeInSubs(nodeName,excludes)){
    6773        printf("%s \n",  nodeName);
    6874
     
    125131                 Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
    126132        }
     133      }
    127134          }
    128135        }
     
    132139 (void *) abnormal);
    133140}
     141
    134142/**Function********************************************************************
    135143 
     
    289297  Synopsis    [Initialize the abnormal predicate in the clauses array abni =0]
    290298
    291   Description [Fill the Dbg data structure, abnAigArray conains the set of Aig
     299  Description [Fill the Dbg data structure, abnAigArray contains the set of Aig
    292300  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
    295304  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. ]
    297306
    298307  SideEffects [Fill abnAigArray and abnCnfIndexArray]
     
    304313bAig_Manager_t   * manager,
    305314st_table * nodeToMvfAigTable,
     315int k,
    306316BmcCnfClauses_t *cnfClauses)
    307317{
     
    315325   int size = array_n(abn->abnormal);
    316326   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;
    318329   int aIndex;
    319330   Ntk_Node_t * abnNode;
     
    322333    if (abnMvfAig ==  NIL(MvfAig_Function_t)){
    323334     (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));
    325336     return ;
    326337    }
     
    335346    }
    336347    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);
    345363   }
    346364   abn->abnAigArray = abnAigArray;
  • vis_dev/vis-2.3/src/debug/debugInt.h

    r42 r44  
    5656        array_t * freeInputs; /* Array of Ntk_Node_t* */
    5757        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 */
    5959        int verbose;
    6060};
     
    8686void mdd_GetState_Values(mdd_manager *mgr, mdd_t * top, FILE * f);
    8787void printNodeArray(array_t * nodeArray);
     88boolean Dbg_TestNodeInSubs(char* nodeName,array_t * subsName);
    8889
    8990/**AutomaticEnd***************************************************************/
  • vis_dev/vis-2.3/src/debug/debugUtilities.c

    r42 r44  
    236236  }
    237237}
    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
     253boolean 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.