VIS
|
00001 00018 #include "maig.h" 00019 #include "ntk.h" 00020 #include "cmd.h" 00021 #include "baig.h" 00022 #include "baigInt.h" 00023 #include "heap.h" 00024 #include "sat.h" 00025 #include "bmc.h" 00026 00027 static char rcsid[] UNUSED = "$ $"; 00028 00029 /* #define TIMEFRAME_VERIFY_ */ 00030 /*---------------------------------------------------------------------------*/ 00031 /* Constant declarations */ 00032 /*---------------------------------------------------------------------------*/ 00033 00034 00035 /*---------------------------------------------------------------------------*/ 00036 /* Stucture declarations */ 00037 /*---------------------------------------------------------------------------*/ 00038 00039 00040 /*---------------------------------------------------------------------------*/ 00041 /* Type declarations */ 00042 /*---------------------------------------------------------------------------*/ 00043 00044 00045 /*---------------------------------------------------------------------------*/ 00046 /* Variable declarations */ 00047 /*---------------------------------------------------------------------------*/ 00048 00049 /*---------------------------------------------------------------------------*/ 00050 /* Macro declarations */ 00051 /*---------------------------------------------------------------------------*/ 00052 00053 00056 /*---------------------------------------------------------------------------*/ 00057 /* Static function prototypes */ 00058 /*---------------------------------------------------------------------------*/ 00059 00060 static int nameCompare(const void * node1, const void * node2); 00061 static int NoOfBitEncode(int n); 00062 static bAigEdge_t CaseNew(mAig_Manager_t *manager, bAigEdge_t *arr, array_t * encodeList, int index); 00063 00067 /*---------------------------------------------------------------------------*/ 00068 /* Definition of exported functions */ 00069 /*---------------------------------------------------------------------------*/ 00070 00084 void 00085 bAig_ExpandTimeFrame( 00086 Ntk_Network_t *network, 00087 mAig_Manager_t *manager, 00088 int bound, 00089 int withInitialState) 00090 { 00091 bAigTimeFrame_t *timeframe; 00092 int nLatches, nInputs, nOutputs, nInternals; 00093 int nbLatches, nbInputs; 00094 int i, j; 00095 int index, index1, bindex, tindex; 00096 int mvfSize, lmvfSize; 00097 int lmAigId; 00098 array_t *iindexArray; 00099 MvfAig_Function_t *mvfAig, *lmvfAig; 00100 bAigEdge_t *li, *bli; 00101 bAigEdge_t *pre_li, *ori_li; 00102 bAigEdge_t v, nv = bAig_NULL; 00103 Ntk_Node_t *node, *latch; 00104 st_table *node2MvfAigTable, *old2new; 00105 mAigMvar_t lmVar; 00106 mAigBvar_t lbVar; 00107 array_t *bVarList, *mVarList; 00108 lsGen gen; 00109 00110 00111 if(withInitialState) timeframe = manager->timeframe; 00112 else timeframe = manager->timeframeWOI; 00113 00114 if(timeframe == 0) 00115 timeframe = bAig_InitTimeFrame(network, manager, withInitialState); 00116 00117 node2MvfAigTable = 00118 (st_table *)Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY); 00119 00120 nbLatches = timeframe->nbLatches; 00121 nbInputs = timeframe->nbInputs; 00122 nLatches = timeframe->nLatches; 00123 nInputs = timeframe->nInputs; 00124 nOutputs = timeframe->nOutputs; 00125 nInternals = timeframe->nInternals; 00126 00127 iindexArray = timeframe->iindexArray; 00128 00129 if(bound > timeframe->currentTimeframe) { 00130 timeframe->latchInputs = (bAigEdge_t **) 00131 realloc(timeframe->latchInputs, sizeof(bAigEdge_t *)*(bound+2)); 00132 timeframe->inputs = (bAigEdge_t **) 00133 realloc(timeframe->inputs, sizeof(bAigEdge_t *)*(bound+1)); 00134 timeframe->blatchInputs = (bAigEdge_t **) 00135 realloc(timeframe->blatchInputs, sizeof(bAigEdge_t *)*(bound+2)); 00136 timeframe->binputs = (bAigEdge_t **) 00137 realloc(timeframe->binputs, sizeof(bAigEdge_t *)*(bound+1)); 00138 timeframe->outputs = (bAigEdge_t **) 00139 realloc(timeframe->outputs, sizeof(bAigEdge_t *)*(bound+1)); 00140 timeframe->internals = (bAigEdge_t **) 00141 realloc(timeframe->internals, sizeof(bAigEdge_t *)*(bound+1)); 00142 } 00143 00144 bVarList = mAigReadBinVarList(manager); 00145 mVarList = mAigReadMulVarList(manager); 00146 00147 for(j=timeframe->currentTimeframe+1; j<=bound; j++) { 00149 timeframe->inputs = (bAigEdge_t **) 00150 realloc(timeframe->inputs, sizeof(bAigEdge_t *)*(j+1)); 00151 timeframe->binputs = (bAigEdge_t **) 00152 realloc(timeframe->binputs, sizeof(bAigEdge_t *)*(j+1)); 00153 bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbInputs); 00154 timeframe->binputs[j] = bli; 00155 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs); 00156 timeframe->inputs[j] = li; 00157 index = 0; 00158 index1 = 0; 00159 bindex = 0; 00160 Ntk_NetworkForEachPrimaryInput(network, gen, node) { 00161 bAig_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index); 00162 00163 st_lookup(node2MvfAigTable, node, &mvfAig); 00164 mvfSize = array_n(mvfAig); 00165 for(i=0; i< mvfSize; i++){ 00166 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00167 #ifdef TIMEFRAME_VERIFY_ 00168 fprintf(vis_stdout, "IN(%d) %s(%d) : %d -> %d\n", j, Ntk_NodeReadName(node), i, v, li[index1]); 00169 #endif 00170 index1++; 00171 } 00172 } 00173 Ntk_NetworkForEachPseudoInput(network, gen, node) { 00174 bAig_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index); 00175 00176 st_lookup(node2MvfAigTable, node, &mvfAig); 00177 mvfSize = array_n(mvfAig); 00178 for(i=0; i< mvfSize; i++){ 00179 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00180 #ifdef TIMEFRAME_VERIFY_ 00181 fprintf(vis_stdout, "PI(%d) %s(%d) : %d -> %d\n", j, Ntk_NodeReadName(node), i, v, li[index1]); 00182 #endif 00183 index1++; 00184 } 00185 } 00186 00188 old2new = st_init_table(st_ptrcmp, st_ptrhash); 00189 pre_li = timeframe->inputs[j]; 00190 ori_li = timeframe->oriInputs; 00191 for(i=0; i<nInputs; i++) 00192 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00193 00194 pre_li = timeframe->latchInputs[j]; 00195 ori_li = timeframe->oriLatchInputs; 00196 for(i=0; i<nLatches; i++) 00197 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00198 00199 pre_li = timeframe->binputs[j]; 00200 ori_li = timeframe->oribInputs; 00201 for(i=0; i<nbInputs; i++) 00202 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00203 00204 pre_li = timeframe->blatchInputs[j]; 00205 ori_li = timeframe->oribLatchInputs; 00206 for(i=0; i<nbLatches; i++) 00207 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00208 00210 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches); 00211 bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches); 00212 timeframe->latchInputs[j+1] = li; 00213 timeframe->blatchInputs[j+1] = bli; 00214 bindex = index = 0; 00215 Ntk_NetworkForEachLatch(network, gen, latch) { 00216 node = Ntk_LatchReadDataInput(latch); 00217 mvfAig = lmvfAig = 0; 00218 st_lookup(node2MvfAigTable, node, &mvfAig); 00219 mvfSize = array_n(mvfAig); 00220 st_lookup(node2MvfAigTable, latch, &lmvfAig); 00221 lmvfSize = array_n(lmvfAig); 00222 if(mvfSize != lmvfSize) { 00223 fprintf(vis_stdout, "WARNING : the number of values of signals mismatched\n"); 00224 fprintf(vis_stdout, " %s(%d), %s(%d)\n", 00225 Ntk_NodeReadName(node), mvfSize, 00226 Ntk_NodeReadName(latch), lmvfSize); 00227 for(i=0; i< mvfSize; i++){ 00228 v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i)); 00229 nv = bAig_ExpandForEachCone(manager, v, old2new); 00230 st_insert(old2new, (char *)v, (char *)nv); 00231 li[index++] = nv; 00232 } 00233 for(i=mvfSize; i< lmvfSize; i++){ 00234 li[index++] = nv; 00235 } 00236 } 00237 else { 00238 for(i=0; i< mvfSize; i++){ 00239 v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i)); 00247 nv = bAig_ExpandForEachCone(manager, v, old2new); 00248 flags(nv) |= StateBitMask; 00249 st_insert(old2new, (char *)v, (char *)nv); 00250 #ifdef TIMEFRAME_VERIFY_ 00251 fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n", 00252 j+1, Ntk_NodeReadName(latch), i, v, nv); 00253 #endif 00254 li[index++] = nv; 00255 } 00256 } 00257 00258 lmAigId = Ntk_NodeReadMAigId(node); 00259 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 00260 for(i=0, tindex=lmVar.bVars; i<lmVar.encodeLength; i++) { 00261 lbVar = array_fetch(mAigBvar_t, bVarList, tindex); 00262 tindex++; 00263 v = bAig_GetCanonical(manager, lbVar.node); 00264 nv = bAig_ExpandForEachCone(manager, v, old2new); 00265 flags(nv) |= StateBitMask; 00266 st_insert(old2new, (char *)v, (char *)nv); 00267 bli[bindex++] = nv; 00268 } 00269 } 00270 00271 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nOutputs); 00272 timeframe->outputs[j] = li; 00273 index = 0; 00274 Ntk_NetworkForEachPrimaryOutput(network, gen, node) { 00275 st_lookup(node2MvfAigTable, node, &mvfAig); 00276 mvfSize = array_n(mvfAig); 00277 for(i=0; i< mvfSize; i++){ 00278 v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i)); 00279 00287 nv = bAig_ExpandForEachCone(manager, v, old2new); 00288 st_insert(old2new, (char *)v, (char *)nv); 00289 #ifdef TIMEFRAME_VERIFY_ 00290 fprintf(vis_stdout, "PO(%d) %s(%d) : %d -> %d\n", j+1, Ntk_NodeReadName(node), i, v, li[index]); 00291 #endif 00292 st_insert(old2new, (char *)v, (char *)nv); 00293 li[index++] = nv; 00294 } 00295 } 00296 00297 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInternals); 00298 timeframe->internals[j] = li; 00299 for(i=0; i<array_n(iindexArray); i++) { 00300 v = array_fetch(bAigEdge_t, iindexArray, i); 00301 nv = bAig_ExpandForEachCone(manager, v, old2new); 00302 st_insert(old2new, (char *)v, (char *)nv); 00303 li[i] = nv; 00304 } 00305 st_free_table(old2new); 00306 } 00307 00308 timeframe->currentTimeframe = bound; 00309 } 00310 00322 static int 00323 nameCompare( 00324 const void * node1, 00325 const void * node2) 00326 { 00327 char *name1, *name2; 00328 00329 name1 = Ntk_NodeReadName((Ntk_Node_t *)node1); 00330 name2 = Ntk_NodeReadName((Ntk_Node_t *)node2); 00331 return(strcmp(*(char**)name1, *(char **)name2)); 00332 00333 } 00334 00335 00347 bAigTimeFrame_t * 00348 bAig_InitTimeFrame( 00349 Ntk_Network_t *network, 00350 mAig_Manager_t *manager, 00351 int withInitialState) 00352 { 00353 bAigTimeFrame_t *timeframe; 00354 array_t *latchArr, *inputArr, *outputArr; 00355 array_t *iindexArray; 00356 st_table *li2index, *o2index, *i2index, *pi2index; 00357 st_table *bli2index, *bpi2index; 00358 Ntk_Node_t *node, *latch; 00359 st_table *node2MvfAigTable, *old2new; 00360 lsGen gen; 00361 int nLatches, nInputs, nOutputs, nInternals; 00362 int nbLatches, nbInputs; 00363 int i; 00364 int index, index1, mvfSize, lmvfSize; 00365 int bindex, tindex, tindex1; 00366 MvfAig_Function_t *mvfAig, *tmpMvfAig, *lmvfAig; 00367 bAigEdge_t *li, *pre_li, *ori_li; 00368 bAigEdge_t *bli, *ori_bli; 00369 bAigEdge_t v=bAig_NULL, nv; 00370 mAigMvar_t mVar; 00371 mAigBvar_t bVar; 00372 array_t *bVarList, *mVarList; 00373 int mAigId; 00374 int lmAigId; 00375 mAigMvar_t lmVar; 00376 mAigBvar_t lbVar; 00377 00378 node2MvfAigTable = 00379 (st_table *)Ntk_NetworkReadApplInfo(network, MVFAIG_NETWORK_APPL_KEY); 00380 00381 timeframe = ALLOC(bAigTimeFrame_t, 1); 00382 memset(timeframe, 0, sizeof(bAigTimeFrame_t)); 00383 if(withInitialState) manager->timeframe = timeframe; 00384 else manager->timeframeWOI = timeframe; 00385 00386 latchArr = array_alloc(Ntk_Node_t *, 0); 00387 inputArr = array_alloc(Ntk_Node_t *, 0); 00388 outputArr = array_alloc(Ntk_Node_t *, 0); 00389 timeframe->latchArr = latchArr; 00390 timeframe->inputArr = inputArr; 00391 timeframe->outputArr = outputArr; 00392 00393 li2index = st_init_table(st_ptrcmp, st_ptrhash); 00394 o2index = st_init_table(st_ptrcmp, st_ptrhash); 00395 i2index = st_init_table(st_ptrcmp, st_ptrhash); 00396 pi2index = st_init_table(st_ptrcmp, st_ptrhash); 00397 00398 bli2index = st_init_table(st_ptrcmp, st_ptrhash); 00399 bpi2index = st_init_table(st_ptrcmp, st_ptrhash); 00400 00401 timeframe->li2index = li2index; 00402 timeframe->o2index = o2index; 00403 timeframe->pi2index = pi2index; 00404 timeframe->i2index = i2index; 00405 00406 timeframe->bli2index = bli2index; 00407 timeframe->bpi2index = bpi2index; 00414 bVarList = mAigReadBinVarList(manager); 00415 mVarList = mAigReadMulVarList(manager); 00416 00417 nLatches = 0; 00418 nbLatches = 0; 00419 Ntk_NetworkForEachLatch(network, gen, latch) { 00420 array_insert_last(Ntk_Node_t *, latchArr, latch); 00421 st_lookup(node2MvfAigTable, latch, &mvfAig); 00422 mvfSize = array_n(mvfAig); 00423 for(i=0; i< mvfSize; i++){ 00424 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00425 st_insert(li2index, (char *)v, (char *)(long)nLatches++); 00426 } 00427 00428 mAigId = Ntk_NodeReadMAigId(latch); 00429 mVar = array_fetch(mAigMvar_t, mVarList, mAigId); 00430 for(i=0, index1=mVar.bVars; i<mVar.encodeLength; i++) { 00431 bVar = array_fetch(mAigBvar_t, bVarList, index1); 00432 st_insert(bli2index, (char *)bVar.node, (char *)(long)nbLatches++); 00433 index1++; 00434 } 00435 } 00436 timeframe->nLatches = nLatches; 00437 timeframe->nbLatches = nbLatches; 00438 00439 nOutputs = 0; 00440 Ntk_NetworkForEachPrimaryOutput(network, gen, node) { 00441 array_insert_last(Ntk_Node_t *, outputArr, node); 00442 st_lookup(node2MvfAigTable, node, &mvfAig); 00443 mvfSize = array_n(mvfAig); 00444 for(i=0; i< mvfSize; i++){ 00445 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00446 st_insert(o2index, (char *)(long)v, (char *)(long)nOutputs++); 00447 } 00448 } 00449 timeframe->nOutputs = nOutputs; 00450 00451 timeframe->iindexArray = iindexArray = array_alloc(bAigEdge_t, 0); 00452 nInternals = 0; 00453 Ntk_NetworkForEachNode(network, gen, node) { 00454 if(Ntk_NodeTestIsShadow(node)) continue; 00455 if(Ntk_NodeTestIsCombInput(node)) continue; 00456 if(Ntk_NodeTestIsCombOutput(node))continue; 00457 if(!st_lookup(node2MvfAigTable, node, &mvfAig)) { 00458 tmpMvfAig = Bmc_NodeBuildMVF(network, node); 00459 array_free(tmpMvfAig); 00460 mvfAig = Bmc_ReadMvfAig(node, node2MvfAigTable); 00461 } 00462 mvfSize = array_n(mvfAig); 00463 for(i=0; i< mvfSize; i++){ 00464 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00465 if(!st_lookup(i2index, (char *)v, &index1)) { 00466 array_insert_last(bAigEdge_t, iindexArray, v); 00467 st_insert(i2index, (char *)v, (char *)(long)nInternals++); 00468 } 00469 } 00470 #ifdef TIMEFRAME_VERIFY_ 00471 if(!strcmp(Ntk_NodeReadName(node), "v25") || 00472 !strcmp(Ntk_NodeReadName(node), "v27")) { 00473 fprintf(stdout, "current error %d %d\n", v, nInternals); 00474 } 00475 #endif 00476 } 00477 timeframe->nInternals = nInternals; 00478 00479 nInputs = 0; 00480 nbInputs = 0; 00481 Ntk_NetworkForEachPrimaryInput(network, gen, node) { 00482 array_insert_last(Ntk_Node_t *, inputArr, node); 00483 if(!st_lookup(node2MvfAigTable, node, &mvfAig)) { 00484 tmpMvfAig = Bmc_NodeBuildMVF(network, node); 00485 array_free(tmpMvfAig); 00486 mvfAig = Bmc_ReadMvfAig(node, node2MvfAigTable); 00487 } 00488 mvfSize = array_n(mvfAig); 00489 for(i=0; i< mvfSize; i++){ 00490 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00491 st_insert(pi2index, (char *)(long)v, (char *)(long)nInputs++); 00492 } 00493 00494 mAigId = Ntk_NodeReadMAigId(node); 00495 mVar = array_fetch(mAigMvar_t, mVarList, mAigId); 00496 for(i=0, index1=mVar.bVars; i<mVar.encodeLength; i++) { 00497 bVar = array_fetch(mAigBvar_t, bVarList, index1); 00498 st_insert(bpi2index, (char *)bVar.node, (char *)(long)nbInputs++); 00499 index1++; 00500 } 00501 } 00502 Ntk_NetworkForEachPseudoInput(network, gen, node) { 00503 array_insert_last(Ntk_Node_t *, inputArr, node); 00504 if(!st_lookup(node2MvfAigTable, node, &mvfAig)) { 00505 tmpMvfAig = Bmc_NodeBuildMVF(network, node); 00506 array_free(tmpMvfAig); 00507 mvfAig = Bmc_ReadMvfAig(node, node2MvfAigTable); 00508 } 00509 mvfSize = array_n(mvfAig); 00510 for(i=0; i< mvfSize; i++){ 00511 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00512 st_insert(pi2index, (char *)(long)v, (char *)(long)nInputs++); 00513 } 00514 00515 mAigId = Ntk_NodeReadMAigId(node); 00516 mVar = array_fetch(mAigMvar_t, mVarList, mAigId); 00517 for(i=0, index1=mVar.bVars; i<mVar.encodeLength; i++) { 00518 bVar = array_fetch(mAigBvar_t, bVarList, index1); 00519 st_insert(bpi2index, (char *)bVar.node, (char *)(long)nbInputs++); 00520 index1++; 00521 } 00522 } 00523 timeframe->nInputs = nInputs; 00524 timeframe->nbInputs = nbInputs; 00525 00526 array_sort(inputArr, nameCompare); 00527 array_sort(latchArr, nameCompare); 00528 array_sort(outputArr, nameCompare); 00529 00531 old2new = st_init_table(st_ptrcmp, st_ptrhash); 00532 bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbInputs); 00533 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs); 00534 index1 = index = 0; 00535 bindex = 0; 00536 Ntk_NetworkForEachPrimaryInput(network, gen, node) { 00537 bAig_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index); 00538 00539 st_lookup(node2MvfAigTable, node, &mvfAig); 00540 mvfSize = array_n(mvfAig); 00541 for(i=0; i< mvfSize; i++){ 00542 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00543 #ifdef TIMEFRAME_VERIFY_ 00544 fprintf(vis_stdout, "IN(%d) %s(%d) : %d -> %d\n", -1, Ntk_NodeReadName(node), i, v, li[index1]); 00545 #endif 00546 st_insert(old2new, (char *)v, (char *)(li[index1++])); 00547 } 00548 } 00549 Ntk_NetworkForEachPseudoInput(network, gen, node) { 00550 bAig_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index); 00551 00552 st_lookup(node2MvfAigTable, node, &mvfAig); 00553 mvfSize = array_n(mvfAig); 00554 for(i=0; i< mvfSize; i++){ 00555 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00556 #ifdef TIMEFRAME_VERIFY_ 00557 fprintf(vis_stdout, "PI(%d) %s(%d) : %d -> %d\n", -1, Ntk_NodeReadName(node), i, v, li[index1]); 00558 #endif 00559 st_insert(old2new, (char *)v, (char *)(li[index1++])); 00560 } 00561 } 00562 00563 timeframe->blatchInputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)*(2)); 00564 bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches); 00565 timeframe->blatchInputs[0] = bli; 00566 00567 timeframe->latchInputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)*(2)); 00568 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches); 00569 timeframe->latchInputs[0] = li; 00570 00571 ori_li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches); 00572 ori_bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches); 00573 timeframe->oriLatchInputs = ori_li; 00574 timeframe->oribLatchInputs = ori_bli; 00575 00576 index1 = index = 0; 00577 bindex = tindex = tindex1 = 0; 00578 00579 if(withInitialState == 0) { 00580 Ntk_NetworkForEachLatch(network, gen, latch) { 00581 bAig_CreateNewNode(manager, node2MvfAigTable, latch, bli, li, &bindex, &index); 00582 00583 st_lookup(node2MvfAigTable, latch, &mvfAig); 00584 mvfSize = array_n(mvfAig); 00585 for(i=0; i< mvfSize; i++){ 00586 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00587 st_insert(old2new, (char *)v, (char *)(li[index1])); 00588 #ifdef TIMEFRAME_VERIFY_ 00589 fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(latch), i, v, li[index1]); 00590 #endif 00591 ori_li[index1++] = v; 00592 } 00593 00594 lmAigId = Ntk_NodeReadMAigId(latch); 00595 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 00596 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) { 00597 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 00598 tindex1++; 00599 v = bAig_GetCanonical(manager, lbVar.node); 00600 ori_bli[tindex++] = v ; 00601 } 00602 } 00603 } 00604 else { 00605 Ntk_NetworkForEachLatch(network, gen, latch) { 00606 node = Ntk_LatchReadInitialInput(latch); 00607 mvfAig = lmvfAig = 0; 00608 st_lookup(node2MvfAigTable, node, &mvfAig); 00609 mvfSize = array_n(mvfAig); 00610 if(!st_lookup(node2MvfAigTable, latch, &lmvfAig)) { 00611 tmpMvfAig = Bmc_NodeBuildMVF(network, latch); 00612 array_free(tmpMvfAig); 00613 lmvfAig = Bmc_ReadMvfAig(latch, node2MvfAigTable); 00614 } 00615 lmvfSize = array_n(lmvfAig); 00616 if(mvfSize != lmvfSize) { 00617 fprintf(vis_stdout, "WARNING : the number of values of signals mismatched\n"); 00618 fprintf(vis_stdout, " %s(%d), %s(%d)\n", 00619 Ntk_NodeReadName(node), mvfSize, 00620 Ntk_NodeReadName(latch), lmvfSize); 00621 for(i=0; i< mvfSize; i++){ 00622 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00623 nv = bAig_ExpandForEachCone(manager, v, old2new); 00624 st_insert(old2new, (char *)v, (char *)nv); 00625 li[index++] = nv; 00626 } 00627 for(i=mvfSize; i<lmvfSize; i++) { 00628 nv = bAig_ExpandForEachCone(manager, v, old2new); 00629 st_insert(old2new, (char *)v, (char *)nv); 00630 li[index++] = nv; 00631 } 00632 } 00633 else { 00634 for(i=0; i< mvfSize; i++){ 00635 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00636 nv = bAig_ExpandForEachCone(manager, v, old2new); 00637 st_insert(old2new, (char *)v, (char *)nv); 00638 li[index++] = nv; 00639 } 00640 } 00641 for(i=0; i< lmvfSize; i++){ 00642 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(lmvfAig, i)); 00643 #ifdef TIMEFRAME_VERIFY_ 00644 fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(latch), i, v, li[index1]); 00645 #endif 00646 ori_li[index1++] = v; 00647 } 00648 lmAigId = Ntk_NodeReadMAigId(latch); 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 node = Ntk_LatchReadInitialInput(latch); 00657 lmAigId = Ntk_NodeReadMAigId(node); 00658 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 00659 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) { 00660 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 00661 tindex1++; 00662 v = bAig_GetCanonical(manager, lbVar.node); 00663 if(st_lookup(old2new, (char *)v, &nv)) 00664 bli[bindex++] = nv; 00665 else 00666 bli[bindex++] = v; 00667 } 00668 } 00669 } 00670 st_free_table(old2new); 00671 00672 timeframe->binputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)); 00673 bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbInputs); 00674 timeframe->binputs[0] = bli; 00675 00676 timeframe->inputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)); 00677 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs); 00678 ori_li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs); 00679 ori_bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInputs); 00680 timeframe->inputs[0] = li; 00681 timeframe->oriInputs = ori_li; 00682 timeframe->oribInputs = ori_bli; 00683 index1 = index = 0; 00684 tindex = bindex = tindex1 = 0; 00685 Ntk_NetworkForEachPrimaryInput(network, gen, node) { 00686 bAig_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index); 00687 00688 st_lookup(node2MvfAigTable, node, &mvfAig); 00689 mvfSize = array_n(mvfAig); 00690 for(i=0; i< mvfSize; i++){ 00691 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00692 #ifdef TIMEFRAME_VERIFY_ 00693 fprintf(vis_stdout, "IN(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(node), i, v, li[index1]); 00694 #endif 00695 ori_li[index1++] = v; 00696 } 00697 lmAigId = Ntk_NodeReadMAigId(node); 00698 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 00699 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) { 00700 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 00701 tindex1++; 00702 v = bAig_GetCanonical(manager, lbVar.node); 00703 ori_bli[tindex++] = v; 00704 } 00705 } 00706 Ntk_NetworkForEachPseudoInput(network, gen, node) { 00707 bAig_CreateNewNode(manager, node2MvfAigTable, node, bli, li, &bindex, &index); 00708 00709 st_lookup(node2MvfAigTable, node, &mvfAig); 00710 mvfSize = array_n(mvfAig); 00711 for(i=0; i< mvfSize; i++){ 00712 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00713 #ifdef TIMEFRAME_VERIFY_ 00714 fprintf(vis_stdout, "PI(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(node), i, v, li[index1]); 00715 #endif 00716 ori_li[index1++] = v; 00717 } 00718 lmAigId = Ntk_NodeReadMAigId(node); 00719 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 00720 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++) { 00721 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 00722 tindex1++; 00723 v = bAig_GetCanonical(manager, lbVar.node); 00724 ori_bli[tindex++] = v; 00725 } 00726 } 00727 00729 old2new = st_init_table(st_ptrcmp, st_ptrhash); 00730 pre_li = timeframe->inputs[0]; 00731 ori_li = timeframe->oriInputs; 00732 for(i=0; i<nInputs; i++) 00733 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00734 pre_li = timeframe->latchInputs[0]; 00735 ori_li = timeframe->oriLatchInputs; 00736 for(i=0; i<nLatches; i++) 00737 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00738 00739 pre_li = timeframe->binputs[0]; 00740 ori_li = timeframe->oribInputs; 00741 for(i=0; i<nbInputs; i++) 00742 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00743 pre_li = timeframe->blatchInputs[0]; 00744 ori_li = timeframe->oribLatchInputs; 00745 for(i=0; i<nbLatches; i++) 00746 st_insert(old2new, (char *)ori_li[i], (char *)pre_li[i]); 00747 00749 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nLatches); 00750 timeframe->latchInputs[1] = li; 00751 bli = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nbLatches); 00752 timeframe->blatchInputs[1] = bli; 00753 bindex = index = 0; 00754 Ntk_NetworkForEachLatch(network, gen, latch) { 00755 node = Ntk_LatchReadDataInput(latch); 00756 mvfAig = lmvfAig = 0; 00757 st_lookup(node2MvfAigTable, node, &mvfAig); 00758 mvfSize = array_n(mvfAig); 00759 st_lookup(node2MvfAigTable, latch, &lmvfAig); 00760 lmvfSize = array_n(lmvfAig); 00761 if(mvfSize != lmvfSize) { 00762 fprintf(vis_stdout, "WARNING : the number of values of signals mismatched\n"); 00763 fprintf(vis_stdout, " %s(%d), %s(%d)\n", 00764 Ntk_NodeReadName(node), mvfSize, 00765 Ntk_NodeReadName(latch), lmvfSize); 00766 for(i=0; i< mvfSize; i++){ 00767 v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i)); 00768 nv = bAig_ExpandForEachCone(manager, v, old2new); 00769 st_insert(old2new, (char *)v, (char *)nv); 00770 li[index++] = nv; 00771 } 00772 for(i=mvfSize; i< lmvfSize; i++){ 00773 li[index++] = nv; 00774 } 00775 } 00776 else { 00777 for(i=0; i< mvfSize; i++){ 00778 v = bAig_GetCanonical(manager,MvfAig_FunctionReadComponent(mvfAig, i)); 00779 nv = bAig_ExpandForEachCone(manager, v, old2new); 00780 /* flags(nv) |= StateBitMask; */ 00781 st_insert(old2new, (char *)v, (char *)nv); 00782 #ifdef TIMEFRAME_VERIFY_ 00783 fprintf(vis_stdout, "LI(%d) %s(%d) : %d -> %d\n", 00784 1, Ntk_NodeReadName(latch), i, v, nv); 00785 #endif 00786 li[index++] = nv; 00787 } 00788 } 00789 /* State bit mapping **/ 00790 lmAigId = Ntk_NodeReadMAigId(node); 00791 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 00792 for(i=0, tindex=lmVar.bVars; i<lmVar.encodeLength; i++) { 00793 lbVar = array_fetch(mAigBvar_t, bVarList, tindex); 00794 tindex++; 00795 v = bAig_GetCanonical(manager, lbVar.node); 00796 nv = bAig_ExpandForEachCone(manager, v, old2new); 00797 flags(nv) |= StateBitMask; 00798 st_insert(old2new, (char *)v, (char *)nv); 00799 bli[bindex++] = nv; 00800 } 00801 00802 } 00803 00804 timeframe->outputs = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)); 00805 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nOutputs); 00806 timeframe->outputs[0] = li; 00807 index = 0; 00808 Ntk_NetworkForEachPrimaryOutput(network, gen, node) { 00809 st_lookup(node2MvfAigTable, node, &mvfAig); 00810 mvfSize = array_n(mvfAig); 00811 for(i=0; i< mvfSize; i++){ 00812 v = bAig_GetCanonical(manager, MvfAig_FunctionReadComponent(mvfAig, i)); 00813 nv = bAig_ExpandForEachCone(manager, v, old2new); 00814 #ifdef TIMEFRAME_VERIFY_ 00815 fprintf(vis_stdout, "PO(%d) %s(%d) : %d -> %d\n", 0, Ntk_NodeReadName(node), i, v, li[index]); 00816 #endif 00817 st_insert(old2new, (char *)v, (char *)nv); 00818 li[index++] = nv; 00819 } 00820 } 00821 00822 index = 0; 00823 timeframe->internals = (bAigEdge_t **)malloc(sizeof(bAigEdge_t *)); 00824 li = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*nInternals); 00825 timeframe->internals[0] = li; 00826 for(i=0; i<array_n(iindexArray); i++) { 00827 v = array_fetch(bAigEdge_t, iindexArray, i); 00828 nv = bAig_ExpandForEachCone(manager, v, old2new); 00829 st_insert(old2new, (char *)v, (char *)nv); 00830 li[i] = nv; 00831 } 00832 st_free_table(old2new); 00833 00834 timeframe->currentTimeframe = 0; 00835 00836 return(timeframe); 00837 00838 } 00839 00852 void 00853 bAig_CreateNewNode( 00854 mAig_Manager_t *manager, 00855 st_table *node2MvfAigTable, 00856 Ntk_Node_t *node, 00857 bAigEdge_t *bli, 00858 bAigEdge_t *li, 00859 int *bindex, 00860 int *index) 00861 { 00862 int i, j, value, noBits; 00863 bAigEdge_t *arr, v, tv; 00864 MvfAig_Function_t *mvfAig; 00865 array_t *encodeList; 00866 bAigEdge_t *ManagerNodesArray; 00867 bAigTimeFrame_t *timeframe; 00868 00869 timeframe = manager->timeframe; 00870 00871 value = Var_VariableReadNumValues(Ntk_NodeReadVariable(node)); 00872 noBits = NoOfBitEncode(value); 00873 arr = (bAigEdge_t *)malloc(sizeof(bAigEdge_t)*noBits); 00874 mvfAig = 0; 00875 st_lookup(node2MvfAigTable, node, &mvfAig); 00876 for(i=0; i<noBits; i++) { 00877 arr[i] = bAig_CreateNode(manager, bAig_NULL, bAig_NULL); 00878 bli[(*bindex)++] = arr[i]; 00879 00880 flags(arr[i]) |= IsSystemMask; 00881 } 00882 00883 for(i=0; i<value; i++) { 00884 v = MvfAig_FunctionReadComponent(mvfAig, i); 00891 encodeList = array_alloc(bAigEdge_t, 0); 00892 for(j=0; j<value; j++) { 00893 if(j == i)array_insert_last(bAigEdge_t, encodeList, mAig_One); 00894 else array_insert_last(bAigEdge_t, encodeList, mAig_Zero); 00895 } 00896 tv = CaseNew(manager, arr, encodeList, noBits-1); 00897 li[(*index)++] = tv; 00898 00899 ManagerNodesArray = manager->NodesArray; 00900 00901 array_free(encodeList); 00902 if(v == bAig_Zero){ 00903 flags(tv) |= StaticLearnMask; 00904 if(timeframe->assertedArray == 0) 00905 timeframe->assertedArray = array_alloc(bAigEdge_t, 0); 00906 array_insert_last(bAigEdge_t, timeframe->assertedArray, bAig_Not(tv)); 00907 } 00908 else if(v == bAig_One){ 00909 flags(tv) |= StaticLearnMask; 00910 if(timeframe->assertedArray == 0) 00911 timeframe->assertedArray = array_alloc(bAigEdge_t, 0); 00912 array_insert_last(bAigEdge_t, timeframe->assertedArray, tv); 00913 } 00914 } 00915 free(arr); 00916 } 00917 00929 static int 00930 NoOfBitEncode( int n) 00931 { 00932 int i = 0; 00933 int j = 1; 00934 00935 if (n < 2) return 1; /* Takes care of mv.values <= 1 */ 00936 00937 while (j < n) { 00938 j = j * 2; 00939 i++; 00940 } 00941 return i; 00942 } 00943 00955 static bAigEdge_t 00956 CaseNew(mAig_Manager_t *manager, 00957 bAigEdge_t *arr, 00958 array_t * encodeList, 00959 int index) 00960 { 00961 int encodeLen; 00962 int i, count; 00963 bAigEdge_t v; 00964 bAigEdge_t andResult1, andResult2, orResult, result; 00965 bAigEdge_t node1, node2; 00966 array_t *newEncodeList; 00967 00968 encodeLen = array_n(encodeList); 00969 if (encodeLen == 1) 00970 return array_fetch(bAigEdge_t, encodeList, 0); 00971 newEncodeList = array_alloc(bAigEdge_t, 0); 00972 00973 v = arr[index]; 00974 count = 0; 00975 for (i=0; i< (encodeLen/2); i++){ 00976 node1 = array_fetch(bAigEdge_t, encodeList, count++); 00977 node2 = array_fetch(bAigEdge_t, encodeList, count++); 00978 00979 /* performs ITE operator */ 00980 andResult1 = bAig_And(manager, v, node2); 00981 andResult2 = bAig_And(manager, bAig_Not(v), node1); 00982 orResult = bAig_Or (manager, andResult1, andResult2); 00983 flags(andResult1) |= IsSystemMask; 00984 flags(andResult2) |= IsSystemMask; 00985 flags(orResult) |= IsSystemMask; 00986 00987 array_insert_last(bAigEdge_t, newEncodeList, orResult); 00988 } 00989 00990 if(encodeLen%2){ 00991 node1 = array_fetch(bAigEdge_t, encodeList, count); 00992 array_insert_last(bAigEdge_t, newEncodeList, node1); 00993 } 00994 00995 result = CaseNew(manager, arr, newEncodeList, index-1); 00996 array_free(newEncodeList); 00997 return(result); 00998 } 00999 01000 01012 bAigEdge_t 01013 bAig_ExpandForEachCone( 01014 mAig_Manager_t *manager, 01015 bAigEdge_t v, 01016 st_table *old2new) 01017 { 01018 bAigEdge_t left, right, nv; 01019 01020 v = bAig_GetCanonical(manager, v); 01021 if(v == bAig_One || v == bAig_Zero) return(v); 01022 if(v == bAig_NULL) { 01023 fprintf(vis_stdout, "current error\n"); 01024 return(v); 01025 } 01026 01027 01028 if(st_lookup(old2new, (char *)v, &nv)) 01029 return(nv); 01030 if(st_lookup(old2new, (char *)bAig_Not(v), &nv)) 01031 return(bAig_Not(nv)); 01032 01033 left = bAig_ExpandForEachCone(manager, leftChild(v), old2new); 01034 right = bAig_ExpandForEachCone(manager, rightChild(v), old2new); 01035 01036 nv = bAig_And(manager, left, right); 01037 01038 flags(nv) |= IsSystemMask; 01039 01040 if(bAig_IsInverted(v)) nv = bAig_Not(nv); 01041 st_insert(old2new, (char *)v, (char *)nv); 01042 01043 return(nv); 01044 01045 } 01046 01047 01048 01060 void 01061 bAig_CheckConnect( 01062 bAig_Manager_t *manager, 01063 int from, int to) 01064 { 01065 int reached; 01066 01067 reached = bAig_CheckConnectFanin(manager, from, leftChild(to)); 01068 if(reached == 0) 01069 reached = bAig_CheckConnectFanin(manager, from, rightChild(to)); 01070 01071 if(reached == 0) 01072 fprintf(stdout, "Node %d is not (backward) reachable from node %d\n", 01073 from, to); 01074 01075 reached = bAig_CheckConnectFanout(manager, from, to); 01076 if(reached == 0) 01077 fprintf(stdout, "Node %d is not (forward) reachable from node %d\n", 01078 to, from); 01079 01080 } 01081 01082 01094 int 01095 bAig_CheckConnectFanin(bAig_Manager_t *manager, 01096 int from, int to) 01097 { 01098 int left, right; 01099 int reached; 01100 01101 if(bAig_NonInvertedEdge(from) == bAig_NonInvertedEdge(to)) 01102 return(1); 01103 01104 left = leftChild(to); 01105 if(left == 2) 01106 return(0); 01107 01108 right = leftChild(to); 01109 01110 01111 reached = bAig_CheckConnectFanin(manager, from, left); 01112 if(reached == 1) 01113 return(1); 01114 reached = bAig_CheckConnectFanin(manager, from, right); 01115 if(reached == 1) 01116 return(1); 01117 01118 return(0); 01119 } 01120 01132 int 01133 bAig_CheckConnectFanout(bAig_Manager_t *manager, 01134 int from, int to) 01135 { 01136 long *pfan, cur; 01137 int size, j; 01138 int reached; 01139 01140 size = nFanout(from); 01141 for(j=0, pfan = (bAigEdge_t *)fanout(from); j<size; j++) { 01142 cur = pfan[j]; 01143 cur = cur >> 1; 01144 reached = bAig_CheckConnectFanout(manager, cur, to); 01145 if(reached == 1) 01146 return(1); 01147 } 01148 return(0); 01149 } 01150 01162 void 01163 bAig_GetCOIForNode(Ntk_Node_t *node, st_table *table) 01164 { 01165 int i; 01166 Ntk_Node_t *faninNode; 01167 01168 if(node == NIL(Ntk_Node_t)){ 01169 return; 01170 } 01171 if (Ntk_NodeTestIsLatch(node)){ 01172 st_insert(table, (char *)node, (char *)node); 01173 return; 01174 } 01175 01176 Ntk_NodeForEachFanin(node, i, faninNode) { 01177 bAig_GetCOIForNode(faninNode, table); 01178 } 01179 return; 01180 } 01181 01193 void 01194 bAig_GetCOIForNodeMain(Ntk_Network_t * network, char *name) 01195 { 01196 int i, found; 01197 Ntk_Node_t *node, *faninNode; 01198 lsGen gen; 01199 st_generator *gen1; 01200 st_table *table; 01201 01202 node = Ntk_NetworkFindNodeByName(network, name); 01203 if(node == 0) { 01204 found = 0; 01205 Ntk_NetworkForEachNode(network, gen, node) { 01206 if(!strcmp(Ntk_NodeReadName(node), name)) { 01207 found = 1; 01208 break; 01209 } 01210 } 01211 01212 if(found == 0) 01213 node = 0; 01214 } 01215 01216 if(node == NIL(Ntk_Node_t)){ 01217 return; 01218 } 01219 if (Ntk_NodeTestIsLatch(node)){ 01220 fprintf(stdout, "%s\n", Ntk_NodeReadName(node)); 01221 return; 01222 } 01223 01224 table = st_init_table(st_ptrcmp, st_ptrhash); 01225 01226 Ntk_NodeForEachFanin(node, i, faninNode) { 01227 bAig_GetCOIForNode(faninNode, table); 01228 } 01229 01230 st_foreach_item(table, gen1, &node, &node) { 01231 fprintf(stdout, "%s\n", Ntk_NodeReadName(node)); 01232 } 01233 01234 st_free_table(table); 01235 return; 01236 } 01237 01238 01250 void 01251 bAig_CheckLatchStatus(Ntk_Network_t * network, bAig_Manager_t *manager) 01252 { 01253 Ntk_Node_t *node; 01254 Ntk_Node_t *data, *init; 01255 lsGen gen; 01256 mAigMvar_t lmVar; 01257 mAigBvar_t lbVar; 01258 int tindex1, v, i, lmAigId; 01259 array_t *mVarList, *bVarList; 01260 01261 mVarList = mAigReadMulVarList(manager); 01262 bVarList = mAigReadBinVarList(manager); 01263 Ntk_NetworkForEachNode(network, gen, node) { 01264 if(Ntk_NodeTestIsPrimaryInput(node)) { 01265 fprintf(stdout, "Primary I %s :", Ntk_NodeReadName(node)); 01266 lmAigId = Ntk_NodeReadMAigId(node); 01267 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 01268 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++, tindex1++) { 01269 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 01270 v = bAig_GetCanonical(manager, lbVar.node); 01271 fprintf(stdout, "%d ", v); 01272 } 01273 fprintf(stdout, "\n"); 01274 } 01275 } 01276 Ntk_NetworkForEachNode(network, gen, node) { 01277 if(Ntk_NodeTestIsPseudoInput(node)) { 01278 fprintf(stdout, "Pseudo I %s :", Ntk_NodeReadName(node)); 01279 lmAigId = Ntk_NodeReadMAigId(node); 01280 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 01281 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++, tindex1++) { 01282 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 01283 v = bAig_GetCanonical(manager, lbVar.node); 01284 fprintf(stdout, "%d ", v); 01285 } 01286 fprintf(stdout, "\n"); 01287 } 01288 } 01289 Ntk_NetworkForEachNode(network, gen, node) { 01290 if (Ntk_NodeTestIsLatch(node)){ 01291 fprintf(stdout, "Latch %s :", Ntk_NodeReadName(node)); 01292 lmAigId = Ntk_NodeReadMAigId(node); 01293 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 01294 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++, tindex1++) { 01295 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 01296 v = bAig_GetCanonical(manager, lbVar.node); 01297 fprintf(stdout, "%d ", v); 01298 } 01299 fprintf(stdout, "\n"); 01300 01301 data = Ntk_LatchReadDataInput(node); 01302 fprintf(stdout, " data input %s :", Ntk_NodeReadName(data)); 01303 lmAigId = Ntk_NodeReadMAigId(data); 01304 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 01305 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++, tindex1++) { 01306 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 01307 v = bAig_GetCanonical(manager, lbVar.node); 01308 fprintf(stdout, "%d ", v); 01309 } 01310 fprintf(stdout, "\n"); 01311 01312 init = Ntk_LatchReadInitialInput(node); 01313 fprintf(stdout, " latch init %s :", Ntk_NodeReadName(init)); 01314 lmAigId = Ntk_NodeReadMAigId(init); 01315 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 01316 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++, tindex1++) { 01317 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 01318 v = bAig_GetCanonical(manager, lbVar.node); 01319 fprintf(stdout, "%d ", v); 01320 } 01321 fprintf(stdout, "\n"); 01322 } 01323 } 01324 Ntk_NetworkForEachNode(network, gen, node) { 01325 lmAigId = Ntk_NodeReadMAigId(node); 01326 if(lmAigId == 2 || lmAigId == 0) { 01327 fprintf(stdout, "node aig id %s\n", Ntk_NodeReadName(node)); 01328 } 01329 } 01330 } 01331 01343 void 01344 bAig_PrintNodeAigStatus(bAig_Manager_t *manager, Ntk_Node_t *node) 01345 { 01346 mAigMvar_t lmVar; 01347 mAigBvar_t lbVar; 01348 int tindex1, v, i, lmAigId; 01349 array_t *mVarList, *bVarList; 01350 01351 mVarList = mAigReadMulVarList(manager); 01352 bVarList = mAigReadBinVarList(manager); 01353 fprintf(stdout, "node %s :", Ntk_NodeReadName(node)); 01354 lmAigId = Ntk_NodeReadMAigId(node); 01355 lmVar = array_fetch(mAigMvar_t, mVarList, lmAigId); 01356 for(i=0, tindex1=lmVar.bVars; i<lmVar.encodeLength; i++, tindex1++) { 01357 lbVar = array_fetch(mAigBvar_t, bVarList, tindex1); 01358 v = bAig_GetCanonical(manager, lbVar.node); 01359 fprintf(stdout, "%d ", v); 01360 } 01361 fprintf(stdout, "\n"); 01362 } 01363 01375 void 01376 bAig_PrintNodeAigStatusWithName(Ntk_Network_t * network, bAig_Manager_t *manager, char *name) 01377 { 01378 Ntk_Node_t *node; 01379 01380 node = Ntk_NetworkFindNodeByName(network, name); 01381 bAig_PrintNodeAigStatus(manager, node); 01382 } 01383 01395 void 01396 bAig_FreeTimeFrame(bAigTimeFrame_t * timeframe) 01397 { 01398 int i; 01399 long *li; 01400 01401 if(timeframe == 0) return; 01402 01403 if(timeframe->li2index) st_free_table(timeframe->li2index); 01404 if(timeframe->o2index) st_free_table(timeframe->o2index); 01405 if(timeframe->i2index) st_free_table(timeframe->i2index); 01406 if(timeframe->pi2index) st_free_table(timeframe->pi2index); 01407 if(timeframe->latchArr) array_free(timeframe->latchArr); 01408 if(timeframe->inputArr) array_free(timeframe->inputArr); 01409 if(timeframe->outputArr) array_free(timeframe->outputArr); 01410 if(timeframe->iindexArray) array_free(timeframe->iindexArray); 01411 if(timeframe->assertedArray) array_free(timeframe->assertedArray); 01412 if(timeframe->oriLatchInputs)free(timeframe->oriLatchInputs); 01413 if(timeframe->oriInputs) free(timeframe->oriInputs); 01414 if(timeframe->oribLatchInputs)free(timeframe->oribLatchInputs); 01415 if(timeframe->oribInputs) free(timeframe->oribInputs); 01416 01417 if(timeframe->inputs) { 01418 for(i=0; i<timeframe->currentTimeframe; i++) { 01419 li = timeframe->inputs[i]; 01420 if(li) free(li); 01421 } 01422 free(timeframe->inputs); 01423 } 01424 if(timeframe->binputs) { 01425 for(i=0; i<timeframe->currentTimeframe; i++) { 01426 li = timeframe->binputs[i]; 01427 if(li) free(li); 01428 } 01429 free(timeframe->binputs); 01430 } 01431 if(timeframe->outputs) { 01432 for(i=0; i<timeframe->currentTimeframe; i++) { 01433 li = timeframe->outputs[i]; 01434 if(li) free(li); 01435 } 01436 free(timeframe->outputs); 01437 } 01438 if(timeframe->latchInputs) { 01439 for(i=0; i<timeframe->currentTimeframe; i++) { 01440 li = timeframe->latchInputs[i]; 01441 if(li) free(li); 01442 } 01443 free(timeframe->latchInputs); 01444 } 01445 if(timeframe->blatchInputs) { 01446 for(i=0; i<timeframe->currentTimeframe; i++) { 01447 li = timeframe->blatchInputs[i]; 01448 if(li) free(li); 01449 } 01450 free(timeframe->blatchInputs); 01451 } 01452 if(timeframe->internals) { 01453 for(i=0; i<timeframe->currentTimeframe; i++) { 01454 li = timeframe->internals[i]; 01455 if(li) free(li); 01456 } 01457 free(timeframe->internals); 01458 } 01459 } 01460