VIS

src/puresat/puresatTFrame.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 
00077 static int nameCompare(const void * node1, const void * node2);
00078 static int NoOfBitEncode( int n);
00079 
00080 
00083 /*---------------------------------------------------------------------------*/
00084 /* Definition of exported functions                                          */
00085 /*---------------------------------------------------------------------------*/
00086 
00100 bAigEdge_t
00101 PureSat_CaseNew(mAig_Manager_t *manager,
00102   bAigEdge_t      *arr,
00103   array_t *       encodeList,
00104   int             index)
00105 {
00106   int encodeLen;
00107   int i, count;
00108   bAigEdge_t v;
00109   bAigEdge_t    andResult1, andResult2, orResult, result;
00110   bAigEdge_t    node1, node2;
00111   array_t *newEncodeList;
00112 
00113   encodeLen = array_n(encodeList);
00114   if (encodeLen == 1)
00115     return array_fetch(bAigEdge_t, encodeList, 0);
00116   newEncodeList =  array_alloc(bAigEdge_t, 0);
00117 
00118   v = arr[index];
00119   count = 0;
00120   for (i=0; i< (encodeLen/2); i++){
00121     node1 = array_fetch(bAigEdge_t, encodeList, count++);
00122     node2 = array_fetch(bAigEdge_t, encodeList, count++);
00123 
00124      /*  performs ITE operator */
00125     andResult1 = PureSat_And(manager, v,           node2);
00126     andResult2 = PureSat_And(manager, bAig_Not(v), node1);
00127     orResult   = PureSat_Or (manager, andResult1,  andResult2);
00128     flags(andResult1) |= IsSystemMask;
00129     flags(andResult2) |= IsSystemMask;
00130     flags(orResult) |= IsSystemMask;
00131 
00132     array_insert_last(bAigEdge_t, newEncodeList, orResult);
00133   }
00134 
00135   if(encodeLen%2){
00136     node1 = array_fetch(bAigEdge_t, encodeList, count);
00137     array_insert_last(bAigEdge_t, newEncodeList, node1);
00138   }
00139 
00140   result = PureSat_CaseNew(manager, arr, newEncodeList, index-1);
00141   array_free(newEncodeList);
00142   return(result);
00143 }
00144 
00158 void PureSat_CreateNewNode(
00159         mAig_Manager_t *manager,
00160         st_table *node2MvfAigTable,
00161         Ntk_Node_t *node,
00162         bAigEdge_t *bli,
00163         bAigEdge_t *li,
00164         int *bindex,
00165         int *index,
00166         int withInitialState)
00167 {
00168   int i, j, value, noBits;
00169   bAigEdge_t *arr, v, tv;
00170   MvfAig_Function_t  *mvfAig;
00171   array_t *encodeList;
00172   bAigEdge_t *ManagerNodesArray;
00173   bAigTimeFrame_t *timeframe;
00174 
00175 
00176   if(withInitialState)
00177     timeframe = manager->timeframe;
00178   else
00179     timeframe = manager->timeframeWOI;
00180 
00181   value = Var_VariableReadNumValues(Ntk_NodeReadVariable(node));
00182   noBits = NoOfBitEncode(value);
00183   arr = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*noBits);
00184   mvfAig = 0;
00185   st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00186   for(i=0; i<noBits; i++) {
00187     arr[i] = bAig_CreateNode(manager, bAig_NULL, bAig_NULL);
00188     bli[(*bindex)++] = arr[i];
00189 
00190     flags(arr[i]) |= IsSystemMask;
00191   }
00192 
00193   for(i=0; i<value; i++) {
00194     v = MvfAig_FunctionReadComponent(mvfAig, i);
00195 
00196     encodeList = array_alloc(bAigEdge_t, 0);
00197     for(j=0; j<value; j++) {
00198       if(j == i)array_insert_last(bAigEdge_t, encodeList, mAig_One);
00199       else      array_insert_last(bAigEdge_t, encodeList, mAig_Zero);
00200     }
00201     tv = PureSat_CaseNew(manager, arr, encodeList, noBits-1);
00202     li[(*index)++] = tv;
00203 
00204     ManagerNodesArray = manager->NodesArray;
00205 
00206     array_free(encodeList);
00207     if(v == bAig_Zero){
00208       flags(tv) |= StaticLearnMask;
00209       if(timeframe->assertedArray == 0)
00210         timeframe->assertedArray = array_alloc(bAigEdge_t, 0);
00211       array_insert_last(bAigEdge_t, timeframe->assertedArray, bAig_Not(tv));
00212     }
00213     else if(v == bAig_One){
00214       flags(tv) |= StaticLearnMask;
00215       if(timeframe->assertedArray == 0)
00216         timeframe->assertedArray = array_alloc(bAigEdge_t, 0);
00217       array_insert_last(bAigEdge_t, timeframe->assertedArray, tv);
00218     }
00219   }
00220   free(arr);
00221 }
00222 
00236 bAigEdge_t
00237 PureSat_ExpandForEachCone(
00238         mAig_Manager_t *manager,
00239         bAigEdge_t v,
00240         st_table *old2new)
00241 {
00242   bAigEdge_t left, right, nv;
00243 
00244   v = bAig_GetCanonical(manager, v);
00245   if(v == bAig_One || v == bAig_Zero)   return(v);
00246   if(v == bAig_NULL)    {
00247       fprintf(vis_stdout, "current error\n");
00248       return(v);
00249   }
00250 
00251 
00252   if(st_lookup(old2new, (char *)v, &nv))
00253     return(nv);
00254   if(st_lookup(old2new, (char *)bAig_Not(v), &nv))
00255     return(bAig_Not(nv));
00256 
00257   left = PureSat_ExpandForEachCone(manager, leftChild(v), old2new);
00258   right = PureSat_ExpandForEachCone(manager, rightChild(v), old2new);
00259 
00260   nv = PureSat_And(manager, left, right);
00261 
00262   flags(nv) |= IsSystemMask;
00263 
00264   if(bAig_IsInverted(v))        nv = bAig_Not(nv);
00265   st_insert(old2new, (char *)v, (char *)nv);
00266 
00267 
00268   return(nv);
00269 
00270 }
00271 
00284 bAigTimeFrame_t *
00285 bAig_PureSat_InitTimeFrame(
00286         Ntk_Network_t *network,
00287         mAig_Manager_t *manager,
00288         PureSat_Manager_t *pm,
00289         int withInitialState)
00290 {
00291 bAigTimeFrame_t *timeframe;
00292 array_t *latchArr, *inputArr, *outputArr;
00293 array_t *iindexArray;
00294 st_table   *li2index, *o2index, *i2index, *pi2index;
00295 st_table   *bli2index, *bpi2index;
00296 Ntk_Node_t *node, *latch;
00297 st_table   *node2MvfAigTable, *old2new;
00298 lsGen gen;
00299 int nLatches, nInputs, nOutputs, nInternals;
00300 int nbLatches, nbInputs;
00301 int i;
00302 int index, index1, mvfSize, lmvfSize;
00303 int bindex, tindex, tindex1;
00304 MvfAig_Function_t  *mvfAig, *tmpMvfAig, *lmvfAig;
00305 bAigEdge_t *li, *pre_li, *ori_li;
00306 bAigEdge_t *bli, *ori_bli;
00307 bAigEdge_t v, nv;
00308 mAigMvar_t mVar;
00309 mAigBvar_t bVar;
00310 array_t   *bVarList, *mVarList;
00311 int mAigId;
00312 int lmAigId;
00313 mAigMvar_t lmVar;
00314 mAigBvar_t lbVar;
00315 
00316 bAigEdge_t vi, tmpv1, tmpv2,tmpv3;
00317 char * name, *name1;
00318 int imvfSize;
00319 st_table *idx2name,*MultiLatchTable,*table;
00320 
00321   manager->class_ = 1;
00322 
00323   node2MvfAigTable =
00324         (st_table *)Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY);
00325 
00326   timeframe = ALLOC(bAigTimeFrame_t, 1);
00327   memset(timeframe, 0, sizeof(bAigTimeFrame_t));
00328   if(withInitialState) manager->timeframe = timeframe;
00329   else                 manager->timeframeWOI = timeframe;
00330 
00331   latchArr = array_alloc(Ntk_Node_t *, 0);
00332   inputArr = array_alloc(Ntk_Node_t *, 0);
00333   outputArr = array_alloc(Ntk_Node_t *, 0);
00334   timeframe->latchArr = latchArr;
00335   timeframe->inputArr = inputArr;
00336   timeframe->outputArr = outputArr;
00337 
00338   li2index = st_init_table(st_ptrcmp, st_ptrhash);
00339   o2index = st_init_table(st_ptrcmp, st_ptrhash);
00340   i2index = st_init_table(st_ptrcmp, st_ptrhash);
00341   pi2index = st_init_table(st_ptrcmp, st_ptrhash);
00342 
00343   bli2index = st_init_table(st_ptrcmp, st_ptrhash);
00344   bpi2index = st_init_table(st_ptrcmp, st_ptrhash);
00345 
00346   idx2name = st_init_table(st_ptrcmp,st_ptrhash);
00347   timeframe->idx2name = idx2name;
00348   MultiLatchTable = st_init_table(st_ptrcmp,st_ptrhash);
00349   timeframe->MultiLatchTable = MultiLatchTable;
00350 
00351   timeframe->li2index = li2index;
00352   timeframe->o2index = o2index;
00353   timeframe->pi2index = pi2index;
00354   timeframe->i2index = i2index;
00355 
00356   timeframe->bli2index = bli2index;
00357   timeframe->bpi2index = bpi2index;
00364   bVarList = mAigReadBinVarList(manager);
00365   mVarList = mAigReadMulVarList(manager);
00366 
00367   nLatches = 0;
00368   nbLatches = 0;
00369   Ntk_NetworkForEachLatch(network, gen, latch) {
00370 
00371     name = Ntk_NodeReadName(latch);
00372     array_insert_last(Ntk_Node_t *, latchArr, latch);
00373     st_lookup(node2MvfAigTable, (char *)latch, &mvfAig);
00374     mvfSize = array_n(mvfAig);
00375     for(i=0; i< mvfSize; i++){
00376       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00377       st_insert(li2index, (char *)v, (char *)(long)nLatches++);
00378 
00379 #ifdef TIMEFRAME_VERIFY_
00380       fprintf(vis_stdout,"Latch:%s v-->idx:%d-->%d\n",name,v,nLatches-1);
00381 #endif
00382     }
00383 
00384 
00385     mAigId = Ntk_NodeReadMAigId(latch);
00386     mVar = array_fetch(mAigMvar_t, mVarList, mAigId);
00387     for(i=0, index1=mVar.bVars; i<mVar.encodeLength; i++) {
00388       bVar = array_fetch(mAigBvar_t, bVarList, index1);
00389       st_insert(bli2index, (char *)bVar.node, (char *)(long)nbLatches++);
00390       index1++;
00391     }
00392   }
00393   timeframe->nLatches = nLatches;
00394   timeframe->nbLatches = nbLatches;
00395 
00396   nOutputs = 0;
00397   Ntk_NetworkForEachPrimaryOutput(network, gen, node) {
00398     array_insert_last(Ntk_Node_t *, outputArr, node);
00399     st_lookup(node2MvfAigTable, (char *)node, &mvfAig);
00400     mvfSize = array_n(mvfAig);
00401     for(i=0; i< mvfSize; i++){
00402       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00403       st_insert(o2index, (char *)v, (char *)(long)nOutputs++);
00404     }
00405   }
00406   timeframe->nOutputs = nOutputs;
00407 
00408   timeframe->iindexArray = iindexArray = array_alloc(bAigEdge_t, 0);
00409   nInternals = 0;
00410   Ntk_NetworkForEachNode(network, gen, node) {
00411     if(Ntk_NodeTestIsShadow(node))      continue;
00412     if(Ntk_NodeTestIsCombInput(node))   continue;
00413     if(Ntk_NodeTestIsCombOutput(node))continue;
00414     if(!st_lookup(node2MvfAigTable, (char *)node, &mvfAig)) {
00415       tmpMvfAig = Bmc_NodeBuildMVF(network, node);
00416       array_free(tmpMvfAig);
00417       mvfAig = Bmc_ReadMvfAig(node, node2MvfAigTable);
00418     }
00419     mvfSize = array_n(mvfAig);
00420     for(i=0; i< mvfSize; i++){
00421       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00422       if(!st_lookup(i2index, (char *)v, &index1)) {
00423         array_insert_last(bAigEdge_t, iindexArray, v);
00424         st_insert(i2index, (char *)v, (char *)(long)nInternals++);
00425       }
00426     }
00427   }
00428   timeframe->nInternals = nInternals;
00429 
00430   nInputs = 0;
00431   nbInputs = 0;
00432   Ntk_NetworkForEachPrimaryInput(network, gen, node) {
00433     array_insert_last(Ntk_Node_t *, inputArr, node);
00434     if(!st_lookup(node2MvfAigTable, (char *)node, &mvfAig)) {
00435       tmpMvfAig = Bmc_NodeBuildMVF(network, node);
00436       array_free(tmpMvfAig);
00437       mvfAig = Bmc_ReadMvfAig(node, node2MvfAigTable);
00438     }
00439     mvfSize = array_n(mvfAig);
00440     for(i=0; i< mvfSize; i++){
00441       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00442         st_insert(pi2index, (char *)v, (char *)(long)nInputs++);
00443     }
00444 
00445     mAigId = Ntk_NodeReadMAigId(node);
00446     mVar = array_fetch(mAigMvar_t, mVarList, mAigId);
00447     for(i=0, index1=mVar.bVars; i<mVar.encodeLength; i++) {
00448       bVar = array_fetch(mAigBvar_t, bVarList, index1);
00449       st_insert(bpi2index, (char *)bVar.node, (char *)(long)nbInputs++);
00450       index1++;
00451     }
00452   }
00453   Ntk_NetworkForEachPseudoInput(network, gen, node)  {
00454     array_insert_last(Ntk_Node_t *, inputArr, node);
00455     if(!st_lookup(node2MvfAigTable, (char *)node, &mvfAig)) {
00456       tmpMvfAig = Bmc_NodeBuildMVF(network, node);
00457       array_free(tmpMvfAig);
00458       mvfAig = Bmc_ReadMvfAig(node, node2MvfAigTable);
00459     }
00460     mvfSize = array_n(mvfAig);
00461     for(i=0; i< mvfSize; i++){
00462       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00463         st_insert(pi2index, (char *)v, (char *)(long)nInputs++);
00464     }
00465 
00466     mAigId = Ntk_NodeReadMAigId(node);
00467     mVar = array_fetch(mAigMvar_t, mVarList, mAigId);
00468     for(i=0, index1=mVar.bVars; i<mVar.encodeLength; i++) {
00469       bVar = array_fetch(mAigBvar_t, bVarList, index1);
00470       st_insert(bpi2index, (char *)bVar.node, (char *)(long)nbInputs++);
00471       index1++;
00472     }
00473   }
00474   timeframe->nInputs = nInputs;
00475   timeframe->nbInputs = nbInputs;
00476 
00477   array_sort(inputArr, nameCompare);
00478   array_sort(latchArr, nameCompare);
00479   array_sort(outputArr, nameCompare);
00480 
00482   manager->SymbolTableArray[0] = st_init_table(strcmp,st_strhash);
00483   manager->HashTableArray[0] = ALLOC(bAigEdge_t, bAig_HashTableSize);
00484   for (i=0; i<bAig_HashTableSize; i++)
00485        manager->HashTableArray[0][i]= bAig_NULL;
00486   manager->SymbolTableArray[1] = st_init_table(strcmp,st_strhash);
00487   manager->HashTableArray[1] = ALLOC(bAigEdge_t, bAig_HashTableSize);
00488   for (i=0; i<bAig_HashTableSize; i++)
00489        manager->HashTableArray[1][i]= bAig_NULL;
00490 
00491   old2new = st_init_table(st_ptrcmp, st_ptrhash);
00492   bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbInputs);
00493   li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs);
00494   index1 = index = 0;
00495   bindex = 0;
00496   Ntk_NetworkForEachPrimaryInput(network, gen, node) {
00497 
00498     PureSat_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index,withInitialState);
00499 
00500     st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00501     mvfSize = array_n(mvfAig);
00502     for(i=0; i< mvfSize; i++){
00503       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00504 #ifdef TIMEFRAME_VERIFY_
00505       fprintf(vis_stdout, "IN(%d) %s(%d) : %d -> %d\n", -1, Ntk_NodeReadName(node), i, v, li[index1]);
00506 #endif
00507       st_insert(old2new, (char *)v, (char *)(li[index1++]));
00508     }
00509   }
00510   Ntk_NetworkForEachPseudoInput(network, gen, node) {
00511 
00512     PureSat_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index,withInitialState);
00513 
00514     st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00515     mvfSize = array_n(mvfAig);
00516     for(i=0; i< mvfSize; i++){
00517       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00518 #ifdef TIMEFRAME_VERIFY_
00519       fprintf(vis_stdout, "PI(%d) %s(%d) : %d -> %d\n", -1, Ntk_NodeReadName(node), i, v, li[index1]);
00520 #endif
00521       st_insert(old2new, (char *)v, (char *)(li[index1++]));
00522     }
00523   }
00524 
00525   timeframe->blatchInputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)*(2));
00526   bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches);
00527   timeframe->blatchInputs[0] = bli;
00528 
00529   timeframe->latchInputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)*(2));
00530   li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches);
00531   timeframe->latchInputs[0] = li;
00532 
00533   ori_li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches);
00534   ori_bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches);
00535   timeframe->oriLatchInputs = ori_li;
00536   timeframe->oribLatchInputs = ori_bli;
00537 
00538   index1 = index = 0;
00539   bindex = tindex = tindex1 = 0;
00540 
00541   if(withInitialState == 0) {
00542     manager->InitState = bAig_One;
00543     Ntk_NetworkForEachLatch(network, gen, latch) {
00544 
00545       manager->class_ = 0;
00546 
00547       PureSat_CreateNewNode(manager, node2MvfAigTable, latch, bli, li, &bindex, &index,withInitialState);
00548       node =  Ntk_LatchReadInitialInput(latch);
00549       st_lookup(node2MvfAigTable,(char*)node,&tmpMvfAig);
00550 
00551       st_lookup(node2MvfAigTable, (char *) latch, &mvfAig);
00552       mvfSize = array_n(mvfAig);
00553       imvfSize = array_n(tmpMvfAig);
00554       if(mvfSize!=imvfSize){
00555         fprintf(vis_stdout,"mvfSize:%d!=imvSize:%d, exit\n",mvfSize, imvfSize);
00556         exit(0);
00557       }
00558       tmpv3=0;
00559       for(i=0; i< mvfSize; i++){
00560         bAigEdge_t tmpvvv;
00561         tmpvvv = manager->InitState;
00562         v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00563         st_insert(old2new, (char *)v, (char *)(li[index1]));
00564         flags(li[index1]) |= StateBitMask;
00565 #ifdef TIMEFRAME_VERIFY_
00566         fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(latch), i, v, li[index1]);
00567 #endif
00568         ori_li[index1++] = v;
00569         if(tmpv3!=SATnormalNode(li[index1-1])){
00570 
00571           vi = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(tmpMvfAig,i));
00572 
00573           if(vi == bAig_One){
00574             manager->InitState =
00575               PureSat_And(manager,manager->InitState,li[index1-1]);
00576 #ifdef TIMEFRAME_VERIFY_
00577             fprintf(vis_stdout,"%d AND %d = %d\n",li[index1-1],tmpvvv,manager->InitState);
00578 #endif
00579           }
00580           else if(vi == bAig_Zero){
00581             manager->InitState =
00582               PureSat_And(manager,manager->InitState,bAig_Not(li[index1-1]));
00583 #ifdef TIMEFRAME_VERIFY_
00584             fprintf(vis_stdout,"%d AND %d = %d\n",bAig_Not(li[index1-1]),tmpvvv,manager->InitState);
00585 #endif
00586           }
00587           else{
00588             tmpv1 = PureSat_ExpandForEachCone(manager,vi,old2new);
00589             tmpv2 = PureSat_Eq(manager,li[index1-1],tmpv1);
00590             manager->InitState = PureSat_And(manager,manager->InitState,tmpv2);
00591 #ifdef TIMEFRAME_VERIFY_
00592 
00593             fprintf(vis_stdout,"%d AND %d = %d, %d is EQ node for funct node %d<-->%d\n",
00594                    tmpvvv,tmpv2,manager->InitState,tmpv2,tmpv1,li[index1-1] );
00595 #endif
00596           }
00597         }
00598         tmpv3 = SATnormalNode(li[index1-1]);
00599       }
00600 
00601       lmAigId = Ntk_NodeReadMAigId(latch);
00602       lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId);
00603       for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) {
00604         lbVar = array_fetch(mAigBvar_t, bVarList, tindex1);
00605         tindex1++;
00606         v = bAig_GetCanonical(manager, lbVar.node);
00607         flags(bli[tindex])|=StateBitMask;
00608         ori_bli[tindex++] = v;
00609       }
00610 
00611     }
00612 
00613 #if DBG
00614     assert(tindex==bindex&&index1==index);
00615 #endif
00616   }
00617 
00618   st_free_table(old2new);
00619 
00620   manager->class_ = 1;
00621 
00622   timeframe->binputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *));
00623   bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbInputs);
00624   timeframe->binputs[0] = bli;
00625 
00626   timeframe->inputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *));
00627   li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs);
00628   ori_li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs);
00629   ori_bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs);
00630   timeframe->inputs[0] = li;
00631   timeframe->oriInputs = ori_li;
00632   timeframe->oribInputs = ori_bli;
00633   index1 = index = 0;
00634   tindex = bindex = tindex1 = 0;
00635   Ntk_NetworkForEachPrimaryInput(network, gen, node) {
00636 
00637     PureSat_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index,withInitialState);
00638 
00639     st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00640     mvfSize = array_n(mvfAig);
00641     for(i=0; i< mvfSize; i++){
00642       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00643 #ifdef TIMEFRAME_VERIFY_
00644         fprintf(vis_stdout, "IN(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(node), i, v, li[index1]);
00645 #endif
00646         ori_li[index1++] = v;
00647     }
00648     lmAigId = Ntk_NodeReadMAigId(node);
00649     lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId);
00650     for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) {
00651       lbVar = array_fetch(mAigBvar_t, bVarList, tindex1);
00652       tindex1++;
00653       v = bAig_GetCanonical(manager, lbVar.node);
00654       ori_bli[tindex++] = v;
00655     }
00656   }
00657   Ntk_NetworkForEachPseudoInput(network, gen, node) {
00658 
00659     PureSat_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index,withInitialState);
00660 
00661     st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00662     mvfSize = array_n(mvfAig);
00663     for(i=0; i< mvfSize; i++){
00664       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00665 #ifdef TIMEFRAME_VERIFY_
00666         fprintf(vis_stdout, "PI(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(node), i, v, li[index1]);
00667 #endif
00668         ori_li[index1++] = v;
00669     }
00670     lmAigId = Ntk_NodeReadMAigId(node);
00671     lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId);
00672     for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) {
00673       lbVar = array_fetch(mAigBvar_t, bVarList, tindex1);
00674       tindex1++;
00675       v = bAig_GetCanonical(manager, lbVar.node);
00676       ori_bli[tindex++] = v;
00677     }
00678   }
00679 
00681   old2new = st_init_table(st_ptrcmp, st_ptrhash);
00682 
00683   pre_li = timeframe->inputs[0];
00684   ori_li = timeframe->oriInputs;
00685 
00686   for(i=0; i<nInputs; i++){
00687     st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
00688 
00689     }
00690   pre_li = timeframe->latchInputs[0];
00691   ori_li = timeframe->oriLatchInputs;
00692 
00693     for(i=0; i<nLatches; i++){
00694     st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
00695 
00696     }
00697 
00698   pre_li = timeframe->binputs[0];
00699   ori_li = timeframe->oribInputs;
00700   for(i=0; i<nbInputs; i++){
00701     st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
00702 
00703   }
00704   pre_li = timeframe->blatchInputs[0];
00705   ori_li = timeframe->oribLatchInputs;
00706 
00707   for(i=0; i<nbLatches; i++){
00708     st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
00709 
00710   }
00711 
00712 
00714   li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches);
00715   timeframe->latchInputs[1] = li;
00716   bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches);
00717   timeframe->blatchInputs[1] = bli;
00718 
00719 
00720   bindex = index = 0;
00721   Ntk_NetworkForEachLatch(network, gen, latch) {
00722     char * name = Ntk_NodeReadName(latch);
00723     node  = Ntk_LatchReadDataInput(latch);
00724     mvfAig = lmvfAig = 0;
00725     st_lookup(node2MvfAigTable, (char *)node, &mvfAig);
00726     mvfSize = array_n(mvfAig);
00727     st_lookup(node2MvfAigTable, (char *)latch, &lmvfAig);
00728     lmvfSize = array_n(lmvfAig);
00729     if(mvfSize != lmvfSize) {
00730         fprintf(vis_stdout, "WARNING : the number of values of signals mismatched\n");
00731         exit(0);
00732     }
00733 
00734     else {
00735       for(i=0; i< mvfSize; i++){
00736         v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i));
00737 
00738         nv = PureSat_ExpandForEachCone(manager, v, old2new);
00739         flags(nv) |= StateBitMask;
00740         st_insert(old2new, (char *)v, (char *)nv);
00741 #ifdef TIMEFRAME_VERIFY_
00742         fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n",
00743               1, Ntk_NodeReadName(latch), i, v, nv);
00744 #endif
00745         li[index++] = nv;
00746         if(nv==bAig_Zero||nv==bAig_One)
00747           continue;
00748         if(!st_lookup(idx2name,(char*)bAig_NonInvertedEdge(nv),(char**)&name1)){
00749           st_insert(idx2name,(char*)bAig_NonInvertedEdge(nv),(char*)name);
00750 #ifdef TIMEFRAME_VERIFY_
00751         fprintf(vis_stdout,"idx2name:%d-->%s\n",bAig_NonInvertedEdge(nv),name);
00752 #endif
00753         }
00754         else{
00755           /*if they are not equal, resort to MultiLatchTable*/
00756           if(strcmp(name,name1)){
00757             if(st_lookup(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),&table)){
00758 #ifdef TIMEFRAME_VERIFY_
00759               fprintf(vis_stdout,"found entry In MultiLatchTable for %d,insert %s \n",
00760                      bAig_NonInvertedEdge(nv),name);
00761 #endif
00762               st_insert(table,(char*)name,(char*)0);
00763             }
00764             else{
00765               table = st_init_table(strcmp,st_strhash);
00766 #ifdef TIMEFRAME_VERIFY_
00767               fprintf(vis_stdout,"NO entry In MultiLatchTable for %d,insert %s, %s \n",
00768                      bAig_NonInvertedEdge(nv),name,name1);
00769 #endif
00770               st_insert(table,(char*)name1,(char*)0);
00771               st_insert(table,(char*)name,(char*)0);
00772               st_insert(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),(char*)table);
00773             }
00774           }
00775         }
00776 
00777       }
00778     }
00779 
00780 
00781     lmAigId = Ntk_NodeReadMAigId(node);
00782     lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId);
00783     for(i=0, tindex=lmVar.bVars; i<lmVar.encodeLength; i++) {
00784       lbVar = array_fetch(mAigBvar_t, bVarList, tindex);
00785       v = bAig_GetCanonical(manager, lbVar.node);
00786 
00787       nv = PureSat_ExpandForEachCone(manager, v, old2new);
00788       flags(nv) |= StateBitMask;
00789       st_insert(old2new, (char *)v, (char *)nv);
00790 #ifdef TIMEFRAME_VERIFY_
00791         ffprintf(vis_stdout,vis_stdout, "BLI(%d) %s(%d) : %d -> %d\n",
00792               1, Ntk_NodeReadName(latch), i, v, nv);
00793 #endif
00794       bli[bindex++] = nv;
00795 
00796       tindex++;
00797       if(nv==bAig_Zero||nv==bAig_One)
00798         continue;
00799       if(!st_lookup(idx2name,(char*)bAig_NonInvertedEdge(nv),(char**)&name1)){
00800         st_insert(idx2name,(char*)bAig_NonInvertedEdge(nv),(char*)name);
00801 #ifdef TIMEFRAME_VERIFY_
00802         fprintf(vis_stdout,"idx2name:%d-->%s\n",bAig_NonInvertedEdge(nv),name);
00803 #endif
00804       }
00805       else{
00806         /*if they are not equal, resort to MultiLatchTable*/
00807         if(strcmp(name,name1)){
00808           if(st_lookup(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),&table)){
00809 #ifdef TIMEFRAME_VERIFY_
00810             fprintf(vis_stdout,"found entry In MultiLatchTable for %d,insert %s \n",
00811                    bAig_NonInvertedEdge(nv),name);
00812 #endif
00813             st_insert(table,(char*)name,(char*)0);
00814           }
00815           else{
00816             table = st_init_table(strcmp,st_strhash);
00817 #ifdef TIMEFRAME_VERIFY_
00818             fprintf(vis_stdout,"NO entry In MultiLatchTable for %d,insert %s, %s \n",
00819                    bAig_NonInvertedEdge(nv),name,name1);
00820 #endif
00821             st_insert(table,(char*)name1,(char*)0);
00822             st_insert(table,(char*)name,(char*)0);
00823             st_insert(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),(char*)table);
00824           }
00825         }
00826       }
00827     }/*for(i=0, tindex=lmVar.bVars; i<lmVar.en...*/
00828   }/*Ntk_NetworkForEachLatch(network, gen, latch) {*/
00829 
00830 
00831 #ifdef TIMEFRAME_VERIFY_
00832 
00833   fprintf(vis_stdout,"after build latches of TF 1\n");
00834 #endif
00835 
00836 
00837   timeframe->outputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *));
00838   li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nOutputs);
00839   timeframe->outputs[0] = li;
00840   index = 0;
00841   Ntk_NetworkForEachPrimaryOutput(network, gen, node) {
00842     st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00843     mvfSize = array_n(mvfAig);
00844     for(i=0; i< mvfSize; i++){
00845       v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00846 
00847       nv = PureSat_ExpandForEachCone(manager, v, old2new);
00848       st_insert(old2new, (char *)v, (char *)nv);
00849       li[index++] = nv;
00850     }
00851   }
00852 
00853   index = 0;
00854   timeframe->internals = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *));
00855   li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInternals);
00856   timeframe->internals[0] = li;
00857   for(i=0; i<array_n(iindexArray); i++) {
00858     v = array_fetch(bAigEdge_t, iindexArray, i);
00859 
00860     nv = PureSat_ExpandForEachCone(manager, v, old2new);
00861     st_insert(old2new, (char *)v, (char *)nv);
00862     li[i] = nv;
00863   }
00864 
00865   /*change the class of latch vars of tf */
00866   st_free_table(old2new);
00867 
00868   timeframe->currentTimeframe = 0;
00869 
00870   return(timeframe);
00871 
00872 }
00873 
00885 void
00886 bAig_PureSat_ExpandTimeFrame(
00887         Ntk_Network_t *network,
00888         mAig_Manager_t *manager,
00889         PureSat_Manager_t *pm,
00890         int bound,
00891         int withInitialState)
00892 {
00893 bAigTimeFrame_t *timeframe;
00894 int nLatches, nInputs, nOutputs, nInternals;
00895 int nbLatches, nbInputs;
00896 int i, j;
00897 int index, index1, bindex, tindex;
00898 int mvfSize, lmvfSize;
00899 int lmAigId;
00900 array_t *iindexArray;
00901 MvfAig_Function_t  *mvfAig, *lmvfAig;
00902 bAigEdge_t *li, *bli;
00903 bAigEdge_t *pre_li, *ori_li;
00904 bAigEdge_t v, nv;
00905 Ntk_Node_t *node, *latch;
00906 st_table   *node2MvfAigTable, *old2new;
00907 mAigMvar_t lmVar;
00908 mAigBvar_t lbVar;
00909 array_t   *bVarList, *mVarList;
00910 lsGen gen;
00911 
00912 st_table *idx2name, *table, *MultiLatchTable;
00913 char *name, *name1;
00914 
00915 
00916   if(withInitialState) timeframe = manager->timeframe;
00917   else                 timeframe = manager->timeframeWOI;
00918 
00919   if(timeframe == 0)
00920     timeframe = bAig_PureSat_InitTimeFrame(network, manager, pm,withInitialState);
00921 
00922 
00923   idx2name = timeframe->idx2name;
00924   MultiLatchTable = timeframe->MultiLatchTable;
00925 
00926   node2MvfAigTable =
00927         (st_table *)Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY);
00928 
00929   nbLatches = timeframe->nbLatches;
00930   nbInputs = timeframe->nbInputs;
00931   nLatches = timeframe->nLatches;
00932   nInputs = timeframe->nInputs;
00933   nOutputs = timeframe->nOutputs;
00934   nInternals = timeframe->nInternals;
00935 
00936   iindexArray = timeframe->iindexArray;
00937 
00938   if(bound > timeframe->currentTimeframe) {
00939     timeframe->latchInputs = (bAigEdge_t **)
00940         realloc(timeframe->latchInputs, sizeof(bAigEdge_t *)*(bound+2));
00941     timeframe->inputs = (bAigEdge_t **)
00942       realloc(timeframe->inputs, sizeof(bAigEdge_t *)*(bound+1));
00943     timeframe->blatchInputs = (bAigEdge_t **)
00944         realloc(timeframe->blatchInputs, sizeof(bAigEdge_t *)*(bound+2));
00945     timeframe->binputs = (bAigEdge_t **)
00946       realloc(timeframe->binputs, sizeof(bAigEdge_t *)*(bound+1));
00947     timeframe->outputs = (bAigEdge_t **)
00948       realloc(timeframe->outputs, sizeof(bAigEdge_t *)*(bound+1));
00949     timeframe->internals = (bAigEdge_t **)
00950       realloc(timeframe->internals, sizeof(bAigEdge_t *)*(bound+1));
00951   }
00952 
00953   bVarList = mAigReadBinVarList(manager);
00954   mVarList = mAigReadMulVarList(manager);
00955 
00956   for(j=timeframe->currentTimeframe+1; j<=bound; j++) {
00957     manager->class_ = j+1;
00958     if(j>=manager->NumOfTable){
00959       manager->NumOfTable *= 2;
00960       manager->SymbolTableArray = REALLOC(st_table *,
00961                  manager->SymbolTableArray,manager->NumOfTable);
00962       manager->HashTableArray = REALLOC(bAigEdge_t *,
00963                  manager->HashTableArray,manager->NumOfTable);
00964     }
00965     manager->SymbolTableArray[manager->class_] = st_init_table(strcmp,st_strhash);
00966     manager->HashTableArray[manager->class_] = ALLOC(bAigEdge_t, bAig_HashTableSize);
00967     for (i=0; i<bAig_HashTableSize; i++)
00968       manager->HashTableArray[manager->class_][i]= bAig_NULL;
00969 
00970 
00972     timeframe->inputs = (bAigEdge_t **)
00973         realloc(timeframe->inputs, sizeof(bAigEdge_t *)*(j+1));
00974     timeframe->binputs = (bAigEdge_t **)
00975         realloc(timeframe->binputs, sizeof(bAigEdge_t *)*(j+1));
00976     bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbInputs);
00977     timeframe->binputs[j] = bli;
00978     li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs);
00979     timeframe->inputs[j] = li;
00980     index = 0;
00981     index1 = 0;
00982     bindex = 0;
00983     Ntk_NetworkForEachPrimaryInput(network, gen, node) {
00984 
00985       PureSat_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index,withInitialState);
00986 
00987       st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
00988       mvfSize = array_n(mvfAig);
00989       for(i=0; i< mvfSize; i++){
00990         v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
00991 #ifdef TIMEFRAME_VERIFY_
00992         fprintf(vis_stdout, "IN(%d) %s(%d) : %d -> %d\n", j, Ntk_NodeReadName(node), i, v, li[index1]);
00993 #endif
00994         index1++;
00995       }
00996     }
00997     Ntk_NetworkForEachPseudoInput(network, gen, node) {
00998 
00999       PureSat_CreateNewNode(manager, node2MvfAigTable, node, bli, li,  &bindex, &index,withInitialState);
01000 
01001       st_lookup(node2MvfAigTable, (char *) node, &mvfAig);
01002       mvfSize = array_n(mvfAig);
01003       for(i=0; i< mvfSize; i++){
01004         v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i));
01005 #ifdef TIMEFRAME_VERIFY_
01006         fprintf(vis_stdout, "PI(%d) %s(%d) : %d -> %d\n", j, Ntk_NodeReadName(node), i, v, li[index1]);
01007 #endif
01008         index1++;
01009       }
01010     }
01011 
01013     old2new = st_init_table(st_ptrcmp, st_ptrhash);
01014     pre_li = timeframe->inputs[j];
01015     ori_li = timeframe->oriInputs;
01016 
01017     for(i=0; i<nInputs; i++){
01018       st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
01019 
01020     }
01021     pre_li = timeframe->latchInputs[j];
01022     ori_li = timeframe->oriLatchInputs;
01023 
01024     for(i=0; i<nLatches; i++){
01025       st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
01026 
01027     }
01028 
01029     pre_li = timeframe->binputs[j];
01030     ori_li = timeframe->oribInputs;
01031 
01032     for(i=0; i<nbInputs; i++){
01033       st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
01034 
01035     }
01036 
01037     pre_li = timeframe->blatchInputs[j];
01038     ori_li = timeframe->oribLatchInputs;
01039 
01040     for(i=0; i<nbLatches; i++){
01041       st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]);
01042 
01043     }
01044 
01045 
01047     li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches);
01048     bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches);
01049     timeframe->latchInputs[j+1] = li;
01050     timeframe->blatchInputs[j+1] = bli;
01051     bindex = index = 0;
01052     Ntk_NetworkForEachLatch(network, gen, latch) {
01053       name = Ntk_NodeReadName(latch);
01054 
01055       node  = Ntk_LatchReadDataInput(latch);
01056       mvfAig = lmvfAig = 0;
01057       st_lookup(node2MvfAigTable, (char *)node, &mvfAig);
01058       mvfSize = array_n(mvfAig);
01059       st_lookup(node2MvfAigTable, (char *)latch, &lmvfAig);
01060       lmvfSize = array_n(lmvfAig);
01061       if(mvfSize != lmvfSize) {
01062         fprintf(vis_stdout, "WARNING : the number of values of signals mismatched\n");
01063         fprintf(vis_stdout, "          %s(%d), %s(%d)\n",
01064                 Ntk_NodeReadName(node), mvfSize,
01065                 Ntk_NodeReadName(latch), lmvfSize);
01066         exit(0);
01067       }
01068       else {
01069         for(i=0; i< mvfSize; i++){
01070           v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i));
01071           nv = PureSat_ExpandForEachCone(manager, v, old2new);
01072           st_insert(old2new, (char *)v, (char *)nv);
01073 #ifdef TIMEFRAME_VERIFY_
01074           fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n",
01075                   j+1, Ntk_NodeReadName(latch), i, v, nv);
01076 #endif
01077           li[index++] = nv;
01078           flags(nv) |= StateBitMask;
01079           if(nv==bAig_Zero||nv==bAig_One)
01080             continue;
01081 
01082           if(!st_lookup(idx2name,(char*)bAig_NonInvertedEdge(nv),(char**)&name1)){
01083             st_insert(idx2name,(char*)bAig_NonInvertedEdge(nv),(char*)name);
01084 #ifdef TIMEFRAME_VERIFY_
01085             fprintf(vis_stdout,"idx2name:%d-->%s\n",bAig_NonInvertedEdge(nv),name);
01086 #endif
01087           }
01088           else{
01089             /*if they are not equal, resort to MultiLatchTable*/
01090             if(strcmp(name,name1)){
01091               if(st_lookup(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),&table)){
01092 #ifdef TIMEFRAME_VERIFY_
01093                 fprintf(vis_stdout,"found entry In MultiLatchTable for %d,insert %s \n",
01094                        bAig_NonInvertedEdge(nv),name);
01095 #endif
01096                 st_insert(table,(char*)name,(char*)0);
01097               }
01098               else{
01099                 table = st_init_table(strcmp,st_strhash);
01100 #ifdef TIMEFRAME_VERIFY_
01101                 fprintf(vis_stdout,"NO entry In MultiLatchTable for %d,insert %s, %s \n",
01102                        bAig_NonInvertedEdge(nv),name,name1);
01103 #endif
01104                 st_insert(table,(char*)name1,(char*)0);
01105                 st_insert(table,(char*)name,(char*)0);
01106                 st_insert(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),(char*)table);
01107               }
01108             }
01109           }
01110 
01111         }/* for(i=0; i< mvfSize; i++){*/
01112       }/*else {*/
01113 
01114       lmAigId = Ntk_NodeReadMAigId(node);
01115       lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId);
01116       for(i=0, tindex=lmVar.bVars; i<lmVar.encodeLength; i++) {
01117         lbVar = array_fetch(mAigBvar_t, bVarList, tindex);
01118         v = bAig_GetCanonical(manager, lbVar.node);
01119         nv = PureSat_ExpandForEachCone(manager, v, old2new);
01120         flags(nv) |= StateBitMask;
01121         st_insert(old2new, (char *)v, (char *)nv);
01122 #ifdef TIMEFRAME_VERIFY_
01123         fprintf(vis_stdout, "BLI(%d) %s(%d) : %d -> %d\n",
01124               j+1, Ntk_NodeReadName(latch), i, v, nv);
01125 #endif
01126         bli[bindex++] = nv;
01127         if(nv==bAig_Zero||nv==bAig_One)
01128           continue;
01129 
01130         if(!st_lookup(idx2name,(char*)bAig_NonInvertedEdge(nv),(char**)&name1)){
01131           st_insert(idx2name,(char*)bAig_NonInvertedEdge(nv),(char*)name);
01132 #ifdef TIMEFRAME_VERIFY_
01133           fprintf(vis_stdout,"idx2name:%d-->%s\n",bAig_NonInvertedEdge(nv),name);
01134 #endif
01135         }
01136         else{
01137           /*if they are not equal, resort to MultiLatchTable*/
01138           if(strcmp(name,name1)){
01139             if(st_lookup(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),&table)){
01140 #ifdef TIMEFRAME_VERIFY_
01141               fprintf(vis_stdout,"found entry In MultiLatchTable for %d,insert %s \n",
01142                      bAig_NonInvertedEdge(nv),name);
01143 #endif
01144               st_insert(table,(char*)name,(char*)0);
01145             }
01146             else{
01147               table = st_init_table(strcmp,st_strhash);
01148 #ifdef TIMEFRAME_VERIFY_
01149               fprintf(vis_stdout,"NO entry In MultiLatchTable for %d,insert %s, %s \n",
01150                      bAig_NonInvertedEdge(nv),name,name1);
01151 #endif
01152               st_insert(table,(char*)name1,(char*)0);
01153               st_insert(table,(char*)name,(char*)0);
01154               st_insert(MultiLatchTable,(char*)bAig_NonInvertedEdge(nv),(char*)table);
01155             }
01156           }
01157         }
01158 
01159         tindex++;
01160       }
01161     }
01162 
01163     li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nOutputs);
01164     timeframe->outputs[j] = li;
01165     index = 0;
01166     Ntk_NetworkForEachPrimaryOutput(network, gen, node) {
01167       st_lookup(node2MvfAigTable, (char *)node, &mvfAig);
01168       mvfSize = array_n(mvfAig);
01169       for(i=0; i< mvfSize; i++){
01170         v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i));
01171         nv = PureSat_ExpandForEachCone(manager, v, old2new);
01172         st_insert(old2new, (char *)v, (char *)nv);
01173         li[index++] = nv;
01174       }
01175     }
01176 
01177     li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInternals);
01178     timeframe->internals[j] = li;
01179     for(i=0; i<array_n(iindexArray); i++) {
01180       v = array_fetch(bAigEdge_t, iindexArray, i);
01181       nv = PureSat_ExpandForEachCone(manager, v, old2new);
01182       st_insert(old2new, (char *)v, (char *)nv);
01183       li[i] = nv;
01184     }
01185     st_free_table(old2new);
01186 
01187 
01188   }
01189 
01190 
01191   timeframe->currentTimeframe = bound;
01192 }
01193 
01205 static int
01206 nameCompare(
01207   const void * node1,
01208   const void * node2)
01209 {
01210   char *name1, *name2;
01211 
01212   name1 = Ntk_NodeReadName((Ntk_Node_t *)node1);
01213   name2 = Ntk_NodeReadName((Ntk_Node_t *)node2);
01214   return(strcmp(*(char**)name1, *(char **)name2));
01215 
01216 }
01217 
01229 static int
01230 NoOfBitEncode( int n)
01231 {
01232   int i = 0;
01233   int j = 1;
01234 
01235   if (n < 2) return 1; /* Takes care of mv.values <= 1 */
01236 
01237   while (j < n) {
01238     j = j * 2;
01239     i++;
01240   }
01241   return i;
01242 }