/* * Adds a vector to the display... */ int AddVector( bvptr vec ) { Trptr t; int n; if(!vec) return(0); /* must've passed it a null pointer by mistake */ signalwindow_width_dirty=1; n = vec->nbits; t = (Trptr) calloc_2(1, sizeof( TraceEnt ) ); if( t == NULL ) { fprintf( stderr, "Out of memory, can't add %s to analyzer\n", vec->name ); return( 0 ); } if(!hier_max_level) { t->name = vec->name; } else { t->name = hier_extract(vec->name, hier_max_level); } t->flags = ( n > 3 ) ? TR_HEX|TR_RJUSTIFY : TR_BIN|TR_RJUSTIFY; t->vector = TRUE; t->n.vec = vec; AddTrace( t ); return( 1 ); }
int traverse_vector_nodes(Trptr t) { int i; int cvt_ok = 0; if((t->t_filter) && (t->flags & TR_TTRANSLATED) && (t->vector) && (!t->t_filter_converted)) { #if !defined _MSC_VER && !defined __MINGW32__ int rc = save_nodes_to_trans(GLOBALS->ttrans_filter[t->t_filter]->sout, t); #else int rc = save_nodes_to_trans((FILE *)(GLOBALS->ttrans_filter[t->t_filter]->g_hChildStd_IN_Wr), t); #endif if(rc == VCDSAV_OK) { int is_finish = 0; bvptr prev_transaction_trace = NULL; while(!is_finish) { struct VectorEnt *vt_head = NULL, *vt_curr = NULL; struct VectorEnt *vt; struct VectorEnt *vprev; bvptr bv; int regions = 2; TimeType prev_tim = LLDescriptor(-1); char *trace_name = NULL; char *orig_name = t->n.vec->bvname; cvt_ok = 1; vt_head = vt_curr = vt = calloc_2(1, sizeof(struct VectorEnt)); vt->time = LLDescriptor(-2); vprev = vt; /* for duplicate removal */ vt_curr = vt_curr->next = vt = calloc_2(1, sizeof(struct VectorEnt)); vt->time = LLDescriptor(-1); for(;;) { char buf[1025]; char *pnt, *rtn; #if !defined _MSC_VER && !defined __MINGW32__ if(feof(GLOBALS->ttrans_filter[t->t_filter]->sin)) break; /* should never happen */ buf[0] = 0; pnt = fgets(buf, 1024, GLOBALS->ttrans_filter[t->t_filter]->sin); if(!pnt) break; rtn = pnt; while(*rtn) { if((*rtn == '\n') || (*rtn == '\r')) { *rtn = 0; break; } rtn++; } #else { BOOL bSuccess; DWORD dwRead; int n; for(n=0;n<1024;n++) { do { bSuccess = ReadFile(GLOBALS->ttrans_filter[t->t_filter]->g_hChildStd_OUT_Rd, buf+n, 1, &dwRead, NULL); if((!bSuccess)||(buf[n]=='\n')) { goto ex; } } while(buf[n]=='\r'); } ex: buf[n] = 0; pnt = buf; } #endif while(*pnt) { if(isspace((int)(unsigned char)*pnt)) pnt++; else break;} if(*pnt=='#') { TimeType tim = atoi_64(pnt+1) * GLOBALS->time_scale; int slen; char *sp; while(*pnt) { if(!isspace((int)(unsigned char)*pnt)) pnt++; else break; } while(*pnt) { if(isspace((int)(unsigned char)*pnt)) pnt++; else break; } sp = pnt; slen = strlen(sp); if(slen) { pnt = sp + slen - 1; do { if(isspace((int)(unsigned char)*pnt)) { *pnt = 0; pnt--; slen--; } else { break; } } while(pnt != (sp-1)); } vt = calloc_2(1, sizeof(struct VectorEnt) + slen); if(sp) strcpy((char *)vt->v, sp); if(tim > prev_tim) { prev_tim = vt->time = tim; vt_curr->next = vt; vt_curr = vt; vprev = vprev->next; /* bump forward the -2 node pointer */ regions++; } else if(tim == prev_tim) { vt->time = prev_tim; free_2(vt_curr); vt_curr = vprev->next = vt; /* splice new one in -1 node place */ } else { free_2(vt); /* throw it away */ } continue; } else if((*pnt=='M')||(*pnt=='m')) { pnt++; if(((*pnt>='A')&&(*pnt<='Z')) || ((*pnt>='a')&&(*pnt<='z'))) { int which_marker = ((*pnt>='A')&&(*pnt<='Z')) ? (*pnt - 'A') : (*pnt - 'a'); TimeType tim = atoi_64(pnt+1) * GLOBALS->time_scale; int slen; char *sp; if(tim < LLDescriptor(0)) tim = LLDescriptor(-1); GLOBALS->named_markers[which_marker] = tim; while(*pnt) { if(!isspace((int)(unsigned char)*pnt)) pnt++; else break; } while(*pnt) { if(isspace((int)(unsigned char)*pnt)) pnt++; else break; } sp = pnt; slen = strlen(sp); if(slen) { pnt = sp + slen - 1; do { if(isspace((int)(unsigned char)*pnt)) { *pnt = 0; pnt--; slen--; } else { break; } } while(pnt != (sp-1)); } if(GLOBALS->marker_names[which_marker]) free_2(GLOBALS->marker_names[which_marker]); GLOBALS->marker_names[which_marker] = (sp && (*sp) && (tim >= LLDescriptor(0))) ? strdup_2(sp) : NULL; } continue; } else if(*pnt == '$') { if(!strncmp(pnt+1, "finish", 6)) { is_finish = 1; break; } else if(!strncmp(pnt+1, "next", 4)) { break; } else if(!strncmp(pnt+1, "name", 4)) { int slen; char *sp; pnt+=5; while(*pnt) { if(isspace((int)(unsigned char)*pnt)) pnt++; else break; } sp = pnt; slen = strlen(sp); if(slen) { pnt = sp + slen - 1; do { if(isspace((int)(unsigned char)*pnt)) { *pnt = 0; pnt--; slen--; } else { break; } } while(pnt != (sp-1)); } if(sp && *sp) { if(trace_name) free_2(trace_name); trace_name = strdup_2(sp); } } } } vt_curr = vt_curr->next = vt = calloc_2(1, sizeof(struct VectorEnt)); vt->time = MAX_HISTENT_TIME - 1; regions++; /* vt_curr = */ vt_curr->next = vt = calloc_2(1, sizeof(struct VectorEnt)); /* scan-build */ vt->time = MAX_HISTENT_TIME; regions++; bv = calloc_2(1, sizeof(struct BitVector) + (sizeof(vptr) * (regions-1))); bv->bvname = strdup_2(trace_name ? trace_name : orig_name); bv->nbits = 1; bv->numregions = regions; bv->bits = t->n.vec->bits; vt = vt_head; for(i=0;i<regions;i++) { bv->vectors[i] = vt; vt = vt->next; } if(!prev_transaction_trace) { prev_transaction_trace = bv; bv->transaction_cache = t->n.vec; /* for possible restore later */ t->n.vec = bv; t->t_filter_converted = 1; if(trace_name) /* if NULL, no need to regen display as trace name didn't change */ { t->name = t->n.vec->bvname; if(GLOBALS->hier_max_level) t->name = hier_extract(t->name, GLOBALS->hier_max_level); regen_display(); } } else { prev_transaction_trace->transaction_chain = bv; prev_transaction_trace = bv; } } } else { /* failed */ t->flags &= ~(TR_TTRANSLATED|TR_ANALOGMASK); } } return(cvt_ok); }
int install_ttrans_filter(int which) { int found = 0; if((which<0)||(which>=(PROC_FILTER_MAX+1))) { which = 0; } if(GLOBALS->traces.first) { Trptr t = GLOBALS->traces.first; while(t) { if(t->flags&TR_HIGHLIGHT) { if((!t->vector) && (which)) { bvptr v = combine_traces(1, t); /* down: make single signal a vector */ if(v) { v->transaction_nd = t->n.nd; /* cache for savefile, disable */ t->vector = 1; t->n.vec = v; /* splice in */ } } if((t->vector) && (!(t->flags&(TR_BLANK|TR_ANALOG_BLANK_STRETCH)))) { t->t_filter = which; t->t_filter_converted = 0; /* back out allocation to revert (if any) */ if(t->n.vec->transaction_cache) { int i; bvptr bv = t->n.vec; bvptr bv2; nptr ndcache = NULL; t->n.vec = bv->transaction_cache; if((t->n.vec->transaction_nd) && (!which)) { ndcache = t->n.vec->transaction_nd; } while(bv) { bv2 = bv->transaction_chain; if(bv->bvname) { free_2(bv->bvname); } for(i=0;i<bv->numregions;i++) { free_2(bv->vectors[i]); } free_2(bv); bv = bv2; } t->name = t->n.vec->bvname; if(GLOBALS->hier_max_level) t->name = hier_extract(t->name, GLOBALS->hier_max_level); if(ndcache) { t->n.nd = ndcache; t->vector = 0; /* still need to deallocate old t->n.vec! */ } } if(!which) { t->flags &= (~(TR_TTRANSLATED|TR_ANALOGMASK)); } else { t->flags &= (~(TR_ANALOGMASK)); t->flags |= TR_TTRANSLATED; if(t->transaction_args) free_2(t->transaction_args); if(GLOBALS->ttranslate_args) { t->transaction_args = strdup_2(GLOBALS->ttranslate_args); } else { t->transaction_args = NULL; } traverse_vector_nodes(t); } found++; if(t->t_match) { Trptr curr_trace = t; t = t->t_next; while(t && (t->t_match != curr_trace)) { t = t->t_next; } } } } t=GiveNextTrace(t); } } if(found) { regen_display(); } return(found); }
/* * Adds a single bit signal to the display... */ int AddNode(nptr nd, char *aliasname) { Trptr t; hptr histpnt; hptr *harray; int histcount; int i; if(!nd) return(0); /* passed it a null node ptr by mistake */ if(nd->mvlfac) import_trace(nd); signalwindow_width_dirty=1; if( (t = (Trptr) calloc_2( 1, sizeof( TraceEnt ))) == NULL ) { fprintf( stderr, "Out of memory, can't add %s to analyzer\n", nd->nname ); return( 0 ); } if(!nd->harray) /* make quick array lookup for aet display */ { histpnt=&(nd->head); histcount=0; while(histpnt) { histcount++; histpnt=histpnt->next; } nd->numhist=histcount; if(!(nd->harray=harray=(hptr *)malloc_2(histcount*sizeof(hptr)))) { fprintf( stderr, "Out of memory, can't add %s to analyzer\n", nd->nname ); free_2(t); return(0); } histpnt=&(nd->head); for(i=0;i<histcount;i++) { *harray=histpnt; /* printf("%s, time: %d, val: %d\n", nd->nname, (*harray)->time, (*harray)->val); */ harray++; histpnt=histpnt->next; } } if(aliasname) { char *alias; t->name=alias=(char *)malloc_2((strlen(aliasname)+2)+1); strcpy(alias,"+ "); /* use plus sign to mark aliases */ strcpy(alias+2,aliasname); t->is_alias=1; /* means can be freed later */ } else { if(!hier_max_level) { t->name = nd->nname; } else { t->name = hier_extract(nd->nname, hier_max_level); } } if(nd->ext) /* expansion vectors */ { int n; n = nd->ext->msi - nd->ext->lsi; if(n<0)n=-n; n++; t->flags = (( n > 3 )||( n < -3 )) ? TR_HEX|TR_RJUSTIFY : TR_BIN|TR_RJUSTIFY; } else { t->flags |= TR_BIN; /* binary */ } t->vector = FALSE; t->n.nd = nd; AddTrace( t ); return( 1 ); }