1 /**************************************************************************** 2 Copyright (C) 1987-2015 by Jeffery P. Hansen 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 ****************************************************************************/ 18 #ifndef __scope_h 19 #define __scope_h 20 21 /* Value codes */ 22 #define VC_UNRECORDED -1 23 #define VC_ZERO 0 24 #define VC_ONE 1 25 #define VC_UNKNOWN 2 26 #define VC_FLOAT 3 27 #define VC_HIGH 4 28 #define VC_LOW 5 29 #define VC_CONTENTION 6 30 #define VC_NUMCASES 7 31 32 #define ScopeTRACEHEIGHT 20 33 #define ScopeBOTTOMHEIGHT 45 34 #define ScopeLEFTMARGIN 110 35 #define ScopeRIGHTMARGIN 20 36 37 #define ScopeLOW (20*ScopeTRACEHEIGHT/100) 38 #define ScopeHIGH (80*ScopeTRACEHEIGHT/100) 39 #define ScopeLOWMED (40*ScopeTRACEHEIGHT/100) 40 #define ScopeHIGHMED (60*ScopeTRACEHEIGHT/100) 41 #define ScopeMEDIUM (50*ScopeTRACEHEIGHT/100) 42 #define ScopeTEXTPOS (30*ScopeTRACEHEIGHT/100) 43 44 #define MAXMARKS 10 45 #define MINMARKS 5 46 47 #define MAXRANGEPOS 18 48 #define DEFAULTRANGEPOS 5 49 50 #define MAXACTIVE 100 /* Maximum number of active traces */ 51 #define MAXMARK 2 /* Maximum number of marks */ 52 53 typedef struct value GateValue; 54 struct value { 55 simtime_t v_time; /* Time which value becomes effective */ 56 short v_code; /* value code (see VC_ macros) */ 57 char *v_hexValue; /* Value string for multi-bit values */ 58 char *v_dpyHexValue; /* Currently displayed hex value */ 59 GateValue *v_next; /* Next change in value */ 60 GateValue *v_prev; /* Previous change in value */ 61 }; 62 63 typedef struct trace { 64 char *t_name; /* Name of signal */ 65 char *t_printName; /* Print Name of signal */ 66 char *t_visName; /* Visible part of PrintName */ 67 char *t_dVisName; /* Deletable ref to VisName */ 68 int t_nBits; /* Number of bits of signal */ 69 GateValue *t_first; /* First value entry */ 70 GateValue *t_last; /* Latest change in value */ 71 GateValue *t_current; /* Current value entry visible on left side of scope */ 72 } GTrace; 73 74 typedef struct scope { 75 Tk_Window win; /* The TK Window for the scope */ 76 Display *d; /* The display */ 77 Tcl_Interp *tcl; /* The tcl interpreter */ 78 GC gc; /* The GC for this window */ 79 int x,y; /* Position of window */ 80 int Width,Height; /* Size of window */ 81 82 XColor *bgColor; 83 XColor *fgColor; 84 char *xscroll; 85 char *yscroll; 86 87 int NumTraces; /* Total number of traces */ 88 int Start; /* First currently displayed trace */ 89 GTrace *Traces[MAXACTIVE]; /* Active traces */ 90 91 int hash_width; /* Width of the '#' character */ 92 93 int enable_xhair; /* Enable crosshair */ 94 int show_xhair; /* Show crosshair */ 95 int xhair_x; /* Crosshair x position */ 96 int show_mark; /* Show selection */ 97 int mark_count; /* Number of active marks */ 98 int mark_x[MAXMARK]; /* Mark x positions */ 99 int mark_val[MAXMARK]; /* Mark values */ 100 101 int s_baseRangePos; /* Base range position */ 102 int s_rangePos; /* Range position */ 103 simtime_t s_precision; /* Precision */ 104 105 simtime_t s_oldTime; /* Old time */ 106 simtime_t s_time; /* Current time */ 107 simtime_t s_leftTime; /* Time at left margin */ 108 simtime_t s_range; /* Number of epochs displayed */ 109 simtime_t s_interval; /* Tickmark Interval */ 110 double s_scale; /* Scale for points */ 111 } GScope; 112 113 GTrace *new_GTrace(const char *name,const char *printName,int nbits, simtime_t curTime); 114 void delete_GTrace(GTrace*); 115 void trace_observe(GTrace *T,simtime_t time,int vcode,const char *hexValue); 116 117 GateValue *new_Value(simtime_t CurTime,int Code,const char *Value,GateValue *Prev); 118 119 120 void Scope_stepTo(simtime_t t); 121 void Scope_setValue(const char *name,const char *val); 122 void Scope_rename(const char *oldName,const char *newName); 123 124 GScope *new_GScope(simtime_t precision); 125 void delete_GScope(GScope *); 126 void GScope_addTrace(GScope*,const char *Name,const char *PrintName,int Bits,int doSort); 127 GTrace *GScope_findTrace(GScope *S,const char *Name); 128 void GScope_fullUpdate(GScope*); 129 void GScope_deleteTrace(GScope*,const char *name); 130 void GScope_showCrossLine(GScope *S); 131 void GScope_hideCrossLine(GScope *S); 132 void GScope_drawCrossLine(GScope *S,int x); 133 134 void GScope_setMark(GScope *S,int x,int isDn,unsigned state); /* Set initial mark point */ 135 136 void GScope_clearSelection(GScope *S); /* Clear the trace selection */ 137 void GScope_showSelection(GScope *S); /* Make trace selection visible */ 138 void GScope_hideSelection(GScope *S); /* Make trace selection invisible */ 139 void GScope_setShowXHairState(int); 140 void GScope_moveSelection(GScope *S); /* Move selection with mouse */ 141 GTrace *GScope_hitTrace(GScope *S,int y); /* Look for trace at specified y coordinate */ 142 void GScope_moveTrace(GScope *S,GTrace *t,int y); /* Move trace so that y is in trace */ 143 void GScope_setTraceHighlight(GScope *S,GTrace *t); 144 void GScope_deleteSelectedTrace(GScope *S); /* Delete the trace that is selected in the scope window */ 145 146 simtime_t GScope_x2t(GScope*,int x); /* Convert an x screen position to a time */ 147 int GScope_t2x(GScope*,simtime_t x); /* Convert a time to an x screen position */ 148 149 void GScope_pickInterval(simtime_t *R,simtime_t *I,simtime_t precision); 150 151 void GScope_saveProbes(GScope *S); 152 void GScope_postFullName(GTrace *t); 153 154 void ReqScopeTraceRedisplay(void); 155 156 #endif 157