1 /****************************************************************************** 2 * DESCRIPTION: Dinotrace source: structure definitions 3 * 4 * This file is part of Dinotrace. 5 * 6 * Author: Wilson Snyder <wsnyder@wsnyder.org> 7 * 8 * Code available from: http://www.veripool.org/dinotrace 9 * 10 ****************************************************************************** 11 * 12 * Some of the code in this file was originally developed for Digital 13 * Semiconductor, a division of Digital Equipment Corporation. They 14 * gratefuly have agreed to share it, and thus the base version has been 15 * released to the public with the following provisions: 16 * 17 * 18 * This software is provided 'AS IS'. 19 * 20 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THE INFORMATION 21 * (INCLUDING ANY SOFTWARE) PROVIDED, INCLUDING ALL IMPLIED WARRANTIES OF 22 * MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE, AND 23 * NON-INFRINGEMENT. DIGITAL NEITHER WARRANTS NOR REPRESENTS THAT THE USE 24 * OF ANY SOURCE, OR ANY DERIVATIVE WORK THEREOF, WILL BE UNINTERRUPTED OR 25 * ERROR FREE. In no event shall DIGITAL be liable for any damages 26 * whatsoever, and in particular DIGITAL shall not be liable for special, 27 * indirect, consequential, or incidental damages, or damages for lost 28 * profits, loss of revenue, or loss of use, arising out of or related to 29 * any use of this software or the information contained in it, whether 30 * such damages arise in contract, tort, negligence, under statute, in 31 * equity, at law or otherwise. This Software is made available solely for 32 * use by end users for information and non-commercial or personal use 33 * only. Any reproduction for sale of this Software is expressly 34 * prohibited. Any rights not expressly granted herein are reserved. 35 * 36 ****************************************************************************** 37 * 38 * Changes made over the basic version are covered by the GNU public licence. 39 * 40 * Dinotrace is free software; you can redistribute it and/or modify 41 * it under the terms of the GNU General Public License as published by 42 * the Free Software Foundation; either version 3, or (at your option) 43 * any later version. 44 * 45 * Dinotrace is distributed in the hope that it will be useful, 46 * but WITHOUT ANY WARRANTY; without even the implied warranty of 47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48 * GNU General Public License for more details. 49 * 50 * You should have received a copy of the GNU General Public License 51 * along with Dinotrace; see the file COPYING. If not, write to 52 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 53 * Boston, MA 02111-1307, USA. 54 * 55 *****************************************************************************/ 56 57 /**********************************************************************/ 58 /* Standard headers required for everybody */ 59 60 #include "config.h" 61 62 #ifndef NDEBUG 63 # ifndef DEBUG 64 # define NDEBUG /* Nullify assert() calls */ 65 # endif 66 #endif 67 68 #include <stdio.h> 69 #include <stdlib.h> 70 #include <string.h> 71 #include <strings.h> 72 #include <ctype.h> 73 #include <memory.h> 74 #include <assert.h> 75 #include <sys/types.h> 76 #include <sys/stat.h> 77 78 #if HAVE_MATH_H 79 # include <math.h> 80 #endif 81 #if HAVE_UNISTD_H 82 # include <unistd.h> 83 #endif 84 #if HAVE_FCNTL_H 85 # include <fcntl.h> 86 #endif 87 #if HAVE_SYS_TIME_H 88 # include <sys/time.h> 89 #endif 90 #include <time.h> 91 92 #ifdef VMS 93 # include <file.h> 94 # include <strdef.h> 95 # include <unixio.h> 96 # include <descrip.h> 97 #endif 98 99 #include <X11/Xlib.h> 100 #include <X11/StringDefs.h> 101 #include <Xm/Xm.h> 102 103 /***********************************************************************/ 104 /* Turn off alignment for any structures that will be read/written onto Disk! */ 105 /* 106 #ifndef __osf__ 107 #pragma member_alignment 108 #endif 109 */ 110 111 #define MAXSIGLEN 256 /* Maximum length of signal names */ 112 #define MAXTIMELEN 20 /* Maximum length of largest time as a string */ 113 #define MAXFNAMELEN 256 /* Maximum length of file names */ 114 #define MAXSTATENAMES 512 /* Maximum number of state name translations */ 115 #define MAXVALUELEN 40 /* Maximum length of values or state names, 32hex digits + 4 sep + NULL */ 116 #define MAXGRIDS 4 /* Maximum number of grids */ 117 #define MAXRADIXS 10 /* Maximum number of number bases on menus */ 118 #define MAXSCREENWIDTH 5000 /* Maximum width of screen */ 119 #define MAXCFGFILES 5 /* Maximum number of config files */ 120 #define RADIX_MAX_MENU 20 /* Maximum number of radix menu entries */ 121 #define MIN_GRID_RES 5 /* Minimum grid resolution, in pixels between grid lines */ 122 #define BLK_SIZE 512 /* Trace data block size (512 transitions/signal == 2K min/sig) */ 123 #define CLICKCLOSE 20 /* Number of pixels that are "close" for click-to-edges */ 124 125 /* Top to bottom: 126 * Y_TOP_BOTTOM grid_time_height Y_TEXT Y_GRID_TOP 127 * signals.... 128 * Y_GRID_BOTTOM [Y_TEXT cursor_rel_height Y_TEXT cursor_abs_height ] Y_TOP_BOTTOM */ 129 #define Y_TOP_BOTTOM 4 /* Y Pixels to leave empty on top and bottom of display */ 130 #define Y_CURSOR_TOP 7 /* Y Pixels cursor drawn before first signal */ 131 #define Y_GRID_TOP 15 /* Y Pixels grid drawn before first signal */ 132 #define Y_DASH_TOP 4 /* Y Pixels margin before first signal */ 133 #define Y_GRID_BOTTOM 2 /* Y Pixels grid drawn after last potential signal */ 134 #define Y_TEXT_SPACE 1 /* Y Pixels between text fields */ 135 #define Y_SIG_SPACE 5 /* Space between high and low adjacent signals */ 136 137 #define RES_SCALE ((float)500.0) /* Scaling factor for entering resolution */ 138 139 /* Cursors for various actions - index into xcursor array */ 140 #define DC_NORMAL 0 /* XC_top_left_arrow Normal cursor */ 141 #define DC_BUSY 1 /* XC_watch Busy cursor */ 142 #define DC_SIG_ADD 2 /* XC_sb_left_arrow Signal Add */ 143 #define DC_SIG_MOVE_2 2 /* XC_sb_left_arrow Signal Move (place) */ 144 #define DC_SIG_MOVE_1 3 /* XC_sb_right_arrow Signal Move (pick) */ 145 #define DC_SIG_COPY_2 2 /* XC_sb_left_arrow Signal Copy (place) */ 146 #define DC_SIG_COPY_1 3 /* XC_sb_right_arrow Signal Copy (pick) */ 147 #define DC_SIG_DELETE 4 /* XC_hand1 Signal Delete */ 148 #define DC_SIG_HIGHLIGHT 10 /* XC_spraycan Signal Highlight */ 149 #define DC_SIG_RADIX 13 /* XC_dotbox Signal Radix */ 150 #define DC_SIG_NOTE 13 /* XC_dotbox Signal Note */ 151 #define DC_CUR_ADD 5 /* XC_center_ptr Cursor Add (and Cursor Add SimView) */ 152 #define DC_CUR_MOVE 6 /* XC_sb_h_double_arrow Cursor Move (drag) */ 153 #define DC_CUR_DELETE 7 /* XC_X_cursor Cursor Delete */ 154 #define DC_CUR_HIGHLIGHT 10 /* XC_spraycan Cursor Highlight */ 155 #define DC_CUR_NOTE 13 /* XC_dotbox Signal Note */ 156 #define DC_ZOOM_1 8 /* XC_left_side Zoom point 1 */ 157 #define DC_ZOOM_2 9 /* XC_right_side Zoom point 2 */ 158 #define DC_VAL_EXAM 11 /* XC_question_arrow Value Examine */ 159 #define DC_VAL_HIGHLIGHT 12 /* XC_cross Value Highlight */ 160 #define DC_MAX 14 161 162 /* All of the states a signal can be in (stored in siglw.state: 8 bits */ 163 #define STATE_0 0 /* MUST=0! All bits 0 */ /* SIGLW TIME */ 164 #define STATE_1 1 /* MUST=1! single-bit 1 */ /* SIGLW TIME */ 165 #define STATE_U 2 /* MUST=2! All bits U */ /* SIGLW TIME */ 166 #define STATE_Z 3 /* MUST=3! All bits Z */ /* SIGLW TIME */ 167 #define STATE_B32 4 /* 2-32 bits */ /* SIGLW TIME V */ 168 #define STATE_F32 5 /* four-state 2-32 bits */ /* SIGLW TIME V T*/ 169 #define STATE_B128 6 /* 33-128 bit vector */ /* SIGLW TIME V V V V*/ 170 #define STATE_F128 7 /* four-state 33-128 bits */ /* SIGLW TIME V T V T V T V T */ 171 /* Size in LWs for each state. Note st may be invalid, which must return a small non-zero value */ 172 #define STATE_SIZE(st) (((st)<=STATE_Z)?2:(((st)<=STATE_B32)?3:\ 173 (((st)==STATE_F32)?4:(((st)==STATE_B128)?6:10)))) 174 175 #define PDASH_HEIGHT 2 /* Heigth of primary dash, <= SIG_SPACE, in pixels */ 176 #define SDASH_HEIGHT 2 /* Heigth of primary dash, <= SIG_SPACE, in pixels */ 177 #define SIG_RF 2 /* Rise fall number of pixels */ 178 #define DELU 5 /* Delta distance for drawing U's */ 179 #define DELU2 10 /* 2x DELU */ 180 181 #define PS_START_Y 600 /* Postscript y starting position */ 182 183 #define IO_GRIDRES 1 184 #define IO_RES 3 185 186 #define XMARGIN 5 /* Space on left margin before signals */ 187 #define XSTART_MIN 50 /* Min Start X pos of signals on display (read_DECSIM) */ 188 #define XSTART_MARGIN 10 /* Additional added fudge factor for xstart */ 189 190 #define DIALOG_WIDTH 75 191 #define DIALOG_HEIGHT 50 192 193 /**********************************************************************/ 194 /* Basic Types */ 195 196 typedef int DTime_t; /* Note "Time" is defined by X.h - some uses of -1 */ 197 typedef char Boolean_t; 198 199 /**********************************************************************/ 200 /* Enums */ 201 202 /* DManageChild keysim or not */ 203 typedef enum { 204 MC_NOKEYS=FALSE, 205 MC_GLOBALKEYS=TRUE 206 } MCKeys_t; 207 208 /* Half/Quarter/Full page enums */ 209 typedef enum { 210 PAGEINC_FULL=1, 211 PAGEINC_HALF=2, 212 PAGEINC_QUARTER=4 213 } PageInc_t; 214 215 /* Annotate trace selection widget enums */ 216 typedef enum { 217 TRACESEL_THIS=0, 218 TRACESEL_ALL=1, 219 TRACESEL_ALLDEL=2 220 } TraceSel_t; 221 222 /* Waveform */ 223 typedef enum { 224 WAVEFORM_DIGITAL=0, 225 WAVEFORM_ANALOG=1, 226 WAVEFORM_ANALOG_SIGNED=2 227 } Waveform_t; 228 229 /* Time representation enums */ 230 #define TIMEREP_FS 0.001 231 #define TIMEREP_PS 1.0 232 #define TIMEREP_NS 1000.0 233 #define TIMEREP_US 1000000.0 234 #define TIMEREP_CYC -1.0 235 typedef double TimeRep_t; 236 237 /* Print page sizes */ 238 typedef enum { 239 PRINTSIZE_A, /* Must be zero */ 240 PRINTSIZE_B, 241 PRINTSIZE_EPSPORT, 242 PRINTSIZE_EPSLAND 243 } PrintSize_t; 244 245 /* Config write sub-item enables */ 246 /* See static character array in dt_customize.c */ 247 typedef enum { 248 CUSWRITEM_COMMENT, 249 CUSWRITEM_PERSONAL, 250 CUSWRITEM_VALSEARCH, 251 CUSWRITEM_CURSORS, 252 CUSWRITEM_GRIDS, 253 CUSWRITEM_FORMAT, 254 CUSWRITEM_SIGHIGHLIGHT, 255 CUSWRITEM_SIGORDER, 256 CUSWRITEM_MAX 257 } CusWrItem_t; 258 259 /* Colors */ 260 #define MAX_SRCH 9 /* Maximum number of search values, or cursor/signal colors */ 261 #define MAXCOLORS 10 /* Maximum number of colors, all types, including bars */ 262 #define COLOR_CURRENT (MAX_SRCH+1) 263 #define COLOR_NEXT (MAX_SRCH+2) 264 typedef int ColorNum_t; 265 typedef int VSearchNum_t; 266 267 extern Boolean_t DTDEBUG; /* Debugging mode */ 268 extern uint_t DTPRINT; /* Information printing mode */ 269 extern int DebugTemp; /* Temp value for trying things */ 270 271 #define DTPRINT_ENTRY (DTPRINT & 0x00000001) /* Print routine entries */ 272 #define DTPRINT_CONFIG (DTPRINT & 0x00000010) /* Print config reading information */ 273 #define DTPRINT_FILE (DTPRINT & 0x00000100) /* Print file reading information */ 274 #define DTPRINT_DISPLAY (DTPRINT & 0x00000200) /* Print dispmgr information */ 275 #define DTPRINT_DRAW (DTPRINT & 0x00000400) /* Print dispmgr information */ 276 #define DTPRINT_PRINT (DTPRINT & 0x00000800) /* Print postscript printing information */ 277 #define DTPRINT_SEARCH (DTPRINT & 0x00001000) /* Print searching value/signal information */ 278 #define DTPRINT_BUSSES (DTPRINT & 0x00002000) /* Print make busses information */ 279 #define DTPRINT_SOCKET (DTPRINT & 0x00010000) /* Print socket connection information */ 280 #define DTPRINT_PRESERVE (DTPRINT & 0x00100000) /* Print signal preservation information */ 281 282 /* File formats. See also hardcoded case statement in dinotrace.c */ 283 #define FF_AUTO 0 /* Automatic selection */ 284 #define FF_DECSIM 1 /* May be ascii or binary */ 285 #define FF_TEMPEST 2 286 #define FF_VERILOG 3 287 #define FF_VERILOG_VPD 4 288 #define FF_DECSIM_BIN 5 289 #define FF_DECSIM_ASCII 6 290 #define FF_NUMFORMATS 7 /* Number of formats */ 291 extern uint_t file_format; /* Type of trace to support */ 292 extern struct st_filetypes { 293 Boolean_t selection; /* True if user can select this format */ 294 char *name; /* Name of this file type */ 295 char *extension; /* File extension */ 296 char *mask; /* File Open mask */ 297 } filetypes[FF_NUMFORMATS]; 298 299 extern char message[1000]; /* generic string for messages */ 300 301 extern XGCValues xgcv; 302 303 extern Arg arglist[20]; 304 305 extern Widget dmanage_last; /* Last DManageChild()'d widget */ 306 307 /* Define some types that are needed before defined */ 308 typedef struct st_trace Trace_t; 309 typedef struct st_dfile DFile_t; 310 typedef struct st_signal Signal_t; 311 312 typedef void (*EventCallback_t)(Widget w, Trace_t* trace, XButtonPressedEvent* ev); 313 typedef void (*MenuCallback_t)(Widget w, void*, void*); 314 315 /**********************************************************************/ 316 /* Widget structures */ 317 318 typedef struct { 319 Widget sep; 320 Widget ok; 321 Widget apply; 322 Widget defaults; 323 Widget cancel; 324 } OkApplyWidgets_t; 325 326 #define MENU_PDE_MAX 13 327 #define MENU_PDM_MAX 81 328 #define MENU_PDS_MAX (8+(MAX_SRCH+2)*5+RADIX_MAX_MENU) 329 #define MENU_PDMSEP_MAX 12 330 typedef struct { 331 Widget menu; 332 Widget pdmenu[MENU_PDE_MAX-1]; 333 Widget pdmenubutton[MENU_PDE_MAX-1]; 334 Widget pdsep[MENU_PDMSEP_MAX-1]; 335 Widget pdentry[MENU_PDM_MAX-1]; 336 Widget pdentrybutton[MENU_PDM_MAX-1]; 337 Widget pdsubbutton[MENU_PDS_MAX-1]; 338 Widget menu_close; /* Pointer to menu_close widget */ 339 uint_t sig_highlight_pds; 340 uint_t sig_radix_pds; 341 uint_t sig_waveform_pds; 342 uint_t cur_highlight_pds; 343 uint_t cur_add_pds; 344 uint_t cur_add_simview_pds; 345 uint_t val_highlight_pds; 346 int pdm, pdmsep, pde, pds; /* Temp for loading structure */ 347 } MenuWidgets_t; 348 349 typedef struct { 350 Widget form; 351 Widget begin_but; 352 Widget goto_but; 353 Widget resdec_but; 354 Widget resfull_but; 355 Widget reschg_but; 356 Widget reszoom_but; 357 Widget resinc_but; 358 Widget end_but; 359 Widget refresh_but; 360 /* Slider */ 361 Widget namescroll; 362 } CommandWidgets_t; 363 364 typedef struct { 365 Widget dialog; 366 Widget page_menu, page_option, page_item[3]; 367 Widget time_menu, time_option, time_item[5]; 368 Widget sighgt_label; 369 Widget s1; 370 Widget rfwid; 371 Widget cursor_state; 372 Widget click_to_edge; 373 Widget refreshing; 374 Widget prefixes; 375 OkApplyWidgets_t okapply; 376 } CustomWidgets_t; 377 378 typedef enum { RANGE_BEGIN=0, RANGE_END=1} RangeType_t; 379 typedef struct { 380 Trace_t *trace; /* Link back, as callbacks won't know without it */ 381 DTime_t dastime; 382 RangeType_t type; 383 /* Begin stuff */ 384 Widget time_label; 385 Widget time_pulldown; 386 Widget time_pulldownbutton[4]; 387 Widget time_option; 388 Widget time_text; 389 } RangeWidgets_t; 390 391 typedef struct { 392 Widget dialog; 393 Widget size_menu; 394 Widget size_option; 395 Widget sizea; 396 Widget sizeb; 397 Widget sizeep; 398 Widget sizeel; 399 Widget text; 400 Widget label; 401 Widget sizelabel; 402 Widget notetext; 403 Widget notelabel; 404 Widget pagelabel; 405 Widget all_signals; 406 RangeWidgets_t begin_range; 407 RangeWidgets_t end_range; 408 OkApplyWidgets_t okapply; 409 } PrintWidgets_t; 410 411 typedef struct { 412 Widget dialog; 413 Widget label1, label2, label3, label4; 414 Widget cursors[MAX_SRCH+1]; 415 Widget cursors_dotted[MAX_SRCH+1]; 416 Widget signals[MAX_SRCH+1]; 417 Widget text; 418 Widget trace_label, trace_option, trace_pulldown; 419 Widget trace_button[TRACESEL_ALLDEL+1]; 420 OkApplyWidgets_t okapply; 421 } AnnotateWidgets_t; 422 423 typedef struct { 424 Widget dialog; 425 Widget add; 426 Widget label1, label2, label3; 427 Widget label4, label5; 428 Widget enable[MAX_SRCH]; 429 Widget text[MAX_SRCH]; 430 OkApplyWidgets_t okapply; 431 } SignalWidgets_t; 432 433 typedef struct { 434 Widget dialog; 435 Widget label1, label2, label3; 436 Widget label4, label5, label6; 437 Widget enable[MAX_SRCH]; 438 Widget cursor[MAX_SRCH]; 439 Widget text[MAX_SRCH]; 440 Widget signal[MAX_SRCH]; 441 OkApplyWidgets_t okapply; 442 } ValueWidgets_t; 443 444 typedef struct { 445 Widget dialog; 446 Widget work_area; 447 Widget format_menu, format_option, format_item[FF_NUMFORMATS]; 448 Widget save_ordering; 449 } FileWidgets_t; 450 451 typedef struct { 452 Widget dialog; 453 Widget form; 454 Widget save_ordering; 455 Widget config_label; 456 Widget config_enable[MAXCFGFILES]; 457 Widget config_filename[MAXCFGFILES]; 458 } CusReadWidgets_t; 459 460 typedef struct { 461 Widget dialog; 462 Widget form; 463 Widget save_ordering; 464 Widget global_label; 465 Widget item[CUSWRITEM_MAX]; 466 Widget trace_label, trace_option, trace_pulldown; 467 Widget trace_button[TRACESEL_ALLDEL+1]; 468 } CusWrWidgets_t; 469 470 typedef struct { 471 Widget popup; 472 Widget rowcol; 473 Widget label; 474 } ExamineWidgets_t; 475 476 typedef struct { 477 Widget dialog; 478 Widget text; 479 Widget label1,label2; 480 Widget pulldown; 481 Widget pulldownbutton[MAX_SRCH+1]; 482 Widget options; 483 Widget notetext; 484 Widget notelabel; 485 OkApplyWidgets_t okapply; 486 } GotoWidgets_t; 487 488 typedef struct { 489 Widget dialog; 490 Widget notetext; 491 Widget notelabel; 492 OkApplyWidgets_t okapply; 493 Boolean_t forcursor; 494 } NoteWidgets_t; 495 496 typedef struct { 497 Widget form; 498 Widget label1; 499 Widget visible; 500 Widget wide_line; 501 Widget siglabel, signal; 502 Widget periodlabel, period; 503 Widget align; 504 /* Auto Period stuff */ 505 Widget autoperiod_pulldown; 506 Widget autoperiod_pulldownbutton[3]; 507 Widget autoperiod_options; 508 /* Auto Align stuff */ 509 Widget autoalign_pulldown; 510 Widget autoalign_pulldownbutton[4]; 511 Widget autoalign_options; 512 /* Color stuff */ 513 Widget pulldown; 514 Widget pulldownbutton[MAX_SRCH+1]; 515 Widget options; 516 } GridWidgets_t; 517 518 typedef struct { 519 Widget dialog; 520 Widget masterForm; 521 GridWidgets_t grid[MAXGRIDS]; 522 OkApplyWidgets_t okapply; 523 } GridsWidgets_t; 524 525 typedef struct { 526 Widget dialog; 527 Widget label1, label2, label3; 528 Widget label4, label5; 529 Widget enable[MAX_SRCH]; 530 Widget cursor[MAX_SRCH]; 531 Widget add_sigs, add_sigs_form, add_pat, add_all; 532 Widget delete_sigs, delete_pat, delete_all; 533 Widget delete_const, delete_const_xz, sort_full, sort_nopath; 534 OkApplyWidgets_t okapply; 535 536 XmString *del_strings; 537 XmString *add_strings; 538 Signal_t **del_signals; 539 Signal_t **add_signals; 540 uint_t del_size; 541 uint_t add_size; 542 } SelectWidgets_t; 543 544 /**********************************************************************/ 545 /* Structures */ 546 547 typedef struct { 548 Position x, y, height, width; 549 Boolean_t xp, yp, heightp, widthp; /* Above element is a percentage */ 550 } Geometry_t; 551 552 /* Structure for each signal-state assignment */ 553 typedef struct st_signalstate { 554 struct st_signalstate *next; /* Next structure in a linked list */ 555 uint_t numstates; /* Number of states in the structure */ 556 char signame[MAXSIGLEN]; /* Signal name to translate, Nil = wildcard */ 557 char statename[MAXSTATENAMES][MAXVALUELEN]; /* Name for each state, nil=keep */ 558 } SignalState_t; 559 560 /* These serve as both a index into the Radix_t structure (if type < MAXRADIX) */ 561 /* and also as a type within Radix_t */ 562 /* This order MUST match the adding order in val_radixs_init */ 563 typedef enum { 564 RADIX_HEX_UN=0, 565 RADIX_OCT_UN, 566 RADIX_BIN_UN, 567 RADIX_DEC_UN, 568 RADIX_DEC_SN, 569 RADIX_ASCII, 570 RADIX_REAL, 571 RADIX_MAX /* Number of radixs, exclusive maximum */ 572 } RadixType_t; 573 574 /* Radix information structure (one per numeric radix) */ 575 /* Signal states may be folded in here at some point */ 576 typedef struct st_radix { 577 struct st_radix *next; /* Forward link to next radix */ 578 char *name; /* Name for putting into menus */ 579 char *prefix; /* Prefix in front of values */ 580 /*struct st_radix *fallback; / * Alternative radix if can't fit width */ 581 RadixType_t type; /* Type for printing */ 582 } Radix_t; 583 584 /* Signal LW: A integer broken down into control fields */ 585 /* 32/64/96/256 state signals have an additional 1, 2, or 3 LWs after this */ 586 typedef union { 587 struct { 588 uint_t pad:7; /* Unused */ 589 uint_t allhigh:1; /* Value is all high bits */ 590 uint_t color:8; /* (>4bits) Color to use when drawing this edge */ 591 uint_t state:8; /* (>4bits) State of this value */ 592 uint_t size_prev:4; /* (>4bits) Size of previous cptr array, 0 if end */ 593 uint_t size:4; /* (>4bits) Size of this cptr array, including header */ 594 } stbits; 595 uint_t number; 596 } SignalLW_t; 597 #define EOT 0x7FFFFFFF /* SignalLW End of time indicator if in .time (max signed) */ 598 599 /* Value: A signal_lw and 3 data elements */ 600 /* A cptr points to at least a SignalLW and at most a Value */ 601 /* since from 0 to all of the uint_ts are dropped in the cptr array */ 602 /* Because of this, you can't just cptr++ to point to the next. USE cptr=CPTR_NEXT(cptr) */ 603 typedef struct { 604 SignalLW_t siglw; /* Header information */ 605 DTime_t time; /* Time of this entry */ 606 uint_t number[8]; /* [0]=bits 31-0, [1]=bits 63-32, [2]=bits 95-64, [3]=bits 127-96 */ 607 /* If 4-state, additional 4, where 10=z, 11=u */ 608 } Value_t; 609 610 /* Value searching structure */ 611 typedef struct { 612 ColorNum_t color; /* Color number (index into trace->xcolornum) 0=OFF*/ 613 ColorNum_t cursor; /* Enable cursors, color or 0=OFF */ 614 Value_t value; /* Value to search for, (128 bit LW format) */ 615 Radix_t *radix; /* Radix user entered */ 616 char signal[MAXSIGLEN]; /* Signal to search for */ 617 } ValSearch_t; 618 619 /* Signal searching structure */ 620 typedef struct { 621 ColorNum_t color; /* Color number (index into trace->xcolornum) 0=OFF*/ 622 char string[MAXSIGLEN]; /* Signal to search for */ 623 } SigSearch_t; 624 625 /* Cursor information structure (one per cursor) */ 626 typedef enum { 627 USER=0, /* User placed it, preserve across rereading traces */ 628 SEARCH, /* Value search, replace as needed */ 629 SEARCHOLD, /* Old search, used by val_update_search only */ 630 CONFIG, /* Config file read in, replace when reread */ 631 SIMVIEW /* Linked to a SimView view */ 632 } CursorType_t; 633 634 typedef struct st_cursor { 635 struct st_cursor *next; /* Forward link to next cursor */ 636 struct st_cursor *prev; /* Backward link to previous cursor */ 637 638 DTime_t time; /* Time cursor is placed at */ 639 ColorNum_t color; /* Color number (index into trace->xcolornum) */ 640 CursorType_t type; /* Type of cursor */ 641 char *note; /* Information for user, or NULL */ 642 int simview_id; /* For SIMVIEW cursors only: an ID number. 643 * ids >= 0 assigned by Dinotrace 644 * ids < 0 assigned by SimView. */ 645 } DCursor_t; /* Not 'Cursor', as that's defined in X11.h */ 646 647 typedef enum { PA_USER=0, PA_AUTO=1, PA_EDGE=2 } PeriodAuto_t; 648 typedef enum { AA_USER=0, AA_ASS=1, AA_DEASS=2, AA_BOTH=3 } AlignAuto_t; 649 650 typedef struct { 651 DTime_t period; /* Grid period (time between ticks) */ 652 DTime_t alignment; /* Grid alignment (time grid starts at) */ 653 int grid_num; /* Number of this grid */ 654 PeriodAuto_t period_auto; /* Status of automatic grid resolution */ 655 AlignAuto_t align_auto; /* Status of automatic grid alignment */ 656 Boolean_t visible; /* True if grid is visible */ 657 Boolean_t wide_line; /* True to draw a double-width line */ 658 char signal[MAXSIGLEN]; /* Signal name of the clock */ 659 Signal_t *signal_synced; /* Which signal grid is synced to */ 660 ColorNum_t color; /* Color to print in, 0 = black */ 661 } Grid_t; 662 663 /* Signal file information */ 664 union sig_file_type_u { 665 struct { 666 uint_t pin_input:1; /* (Tempest) Pin is an input */ 667 uint_t pin_output:1; /* (Tempest) Pin is an output */ 668 uint_t pin_psudo:1; /* (Tempest) Pin is an psudo-pin */ 669 uint_t pin_timestamp:1; /* (Tempest) Pin is a time-stamp */ 670 uint_t four_state:1; /* (Tempest, Binary) Signal is four state (U, Z) */ 671 uint_t perm_vector:1; /* (Verilog) Signal is a permanent vector, don't vectorize */ 672 uint_t real:1; /* (Verilog) Signal known to be real number */ 673 } flag; 674 uint_t flags; 675 }; /* File specific type of signal, two/fourstate, etc */ 676 677 /* Signal information structure (one per each signal in a trace window) */ 678 struct st_signal { 679 struct st_signal *forward; /* Forward link to next signal */ 680 struct st_signal *backward; /* Backward link to previous signal */ 681 682 /* Storage of values. IMPORTANT: You must use CPTR_NEXT and CPTR_PREV to illiterate! */ 683 Value_t *bptr; /* begin of time data ptr */ 684 Value_t *cptr; /* current time data ptr */ 685 686 struct st_signal *copyof; /* Link to signal this is copy of (or NULL) */ 687 DFile_t *dfile; /* File signal belongs to (originally) */ 688 Trace_t *trace; /* Trace signal belongs to (originally) */ 689 struct st_signal *verilog_next; /* Next verilog signal with same coding */ 690 691 char *signame; /* Signal name */ 692 XmString xsigname; /* Signal name as XmString */ 693 char *signame_buspos;/* Signal name portion where bus bits begin (INSIDE signame) */ 694 uint_t signame_hash; /* Hash of name (for dt_signal only) */ 695 char *note; /* Information for user, or NULL */ 696 char *key; /* Sort key for sorting functions (temporary use only) */ 697 698 Radix_t *radix; /* Number radix represtation */ 699 SignalState_t *decode; /* Pointer to decode information, NULL if none */ 700 701 ColorNum_t color; /* Signal line's Color number (index into trace->xcolornum) */ 702 ColorNum_t search; /* Number of search color is for, 0 = manual */ 703 704 Boolean_t deleted; /* Signal is deleted */ 705 Boolean_t deleted_preserve; /* Preserve the deletion of this signal (not deleted because constant) */ 706 Boolean_t preserve_done; /* Preservation process has moved this signal to new link structure */ 707 Boolean_t preserve_match; /* Preservation matched */ 708 Waveform_t waveform; /* Display as analog waveform */ 709 710 uint_t type; /* Type of signal, STATE_B32, _B64, etc */ 711 ulong_t blocks; /* Number of time data blocks allocated, in # of ints */ 712 int msb_index; /* Bit subscript of first index in a signal (<20:10> == 20, <0:2>==0), -1=none */ 713 int lsb_index; /* Bit subscript of last index in a signal (<20:10> == 10, <0:2>==2), -1=none */ 714 int bits; /* Number of bits in a bus, 1=single */ 715 int file_code; /* Code for signal in file (verilog) */ 716 int file_pos; /* Position of the bits in the file line */ 717 int file_end_pos; /* Ending position of the bits in the file line */ 718 Boolean_t file_copy; /* Copyof made automatically by file read */ 719 union sig_file_type_u file_type; /* File specific type of signal, two/fourstate, etc */ 720 uint_t value_mask[4]; /* Value Mask with 1s in bits that are to be set */ 721 uint_t pos_mask; /* Mask to translate file positions */ 722 Value_t file_value; /* current state/time LW information for reading in */ 723 }; /*Signal_t; typedef'd above */ 724 725 /* Signal list structure */ 726 typedef struct st_signal_list { 727 struct st_signal_list *forward; /* Forward link to next signal */ 728 Trace_t *trace; /* Trace signal belongs to (originally) */ 729 Signal_t *signal; /* Selected signal */ 730 } SignalList_t; 731 732 /* File information structure (one per filename that was read) */ 733 struct st_dfile { 734 char filename[MAXFNAMELEN]; /* Current file */ 735 uint_t fileformat; /* Type of trace file (see FF_*) */ 736 737 struct stat filestat; /* Information on the current file */ 738 char hierarchy_separator; /* Hierarchy separator character, usually "." */ 739 char vector_separator; /* Bus separator character, usually "[" */ 740 char vectorend_separator; /* Bus ending separator character, usually "]" */ 741 }; /*DFile_t; typedef'd above */ 742 743 /* Trace information structure (one per window) */ 744 struct st_trace { 745 struct st_trace *next_trace; /* Pointer to the next trace display */ 746 747 DFile_t dfile; /* File trace came from (to be independant later) */ 748 749 Signal_t *firstsig; /* Linked list of all nondeleted signals */ 750 Signal_t *lastsig; /* Linked list of all nondeleted signals */ 751 Signal_t *dispsig; /* Pointer within sigque to first signal on screen */ 752 753 uint_t numsig; /* Total number of signals, excluding deleted */ 754 uint_t numsigvis; /* Maximum number of signals visible on the screen */ 755 uint_t numsigstart; /* signal to start displaying */ 756 757 Window wind; /* X window */ 758 Pixmap pixmap; /* Primary drawable area pixmap */ 759 Pixel xcolornums[MAXCOLORS]; /* X color numbers (pixels) for normal/highlight */ 760 Pixel barcolornum; /* X color number for the signal bar background */ 761 GC gc; 762 763 MenuWidgets_t menu; 764 CommandWidgets_t command; 765 CustomWidgets_t custom; 766 PrintWidgets_t print; 767 AnnotateWidgets_t annotate; 768 SignalWidgets_t signal; 769 ExamineWidgets_t examine; 770 GotoWidgets_t gotos; 771 NoteWidgets_t note; 772 ValueWidgets_t value; 773 GridsWidgets_t gridscus; 774 SelectWidgets_t select; 775 FileWidgets_t fileselect; 776 CusReadWidgets_t cusread; 777 CusWrWidgets_t cuswr; 778 Widget shell; 779 Widget main; 780 Widget work; 781 Widget hscroll; 782 Widget vscroll; 783 Widget customize; /* Customization widget */ 784 Widget toplevel; /* Top level shell */ 785 Widget prompt_popup; /* Data popup widget */ 786 uint_t prompt_type; /* Type of data popup widget */ 787 Widget message; /* Message (error/warn/etc) widget */ 788 Widget help_doc; /* Help documentation */ 789 Widget help_doc_text; /* Help documentation */ 790 791 char printname[MAXFNAMELEN]; /* Print filename */ 792 Boolean_t loaded; /* True if the filename is loaded in */ 793 794 uint_t redraw_needed; /* Need to refresh the screen when get a chance, TRD_* bit fielded */ 795 #define TRD_REDRAW 0x1 796 #define TRD_EXPOSE 0x2 797 798 Dimension width; /* Screen width */ 799 Dimension width_last; /* Last start X pos of signals on display */ 800 801 Position ygridtime; /* Start Y pos of grid times (get_geom) */ 802 Position ystart; /* Start Y pos of signals (get_geom) */ 803 Position yend; /* End Y pos of signals (get_geom) */ 804 Position ycursortimerel; /* Start Y pos of cursor relative times (get_geom) */ 805 Position ycursortimeabs; /* Start Y pos of cursor absolute times (get_geom) */ 806 Dimension height; /* Screen height */ 807 Position xstart_last; /* Last start X pos of signals on display */ 808 809 Grid_t grid[MAXGRIDS]; /* Grid information */ 810 811 DTime_t start_time; /* Time of beginning of trace */ 812 DTime_t end_time; /* Time of ending of trace */ 813 }; /*Trace; typedef'd above */ 814 815 /* SimView use information. */ 816 typedef struct { 817 char * application_name_with_args; 818 Boolean_t handshake; /* TRUE/FALSE. TRUE means Dinotrace only communicates changes, */ 819 /* without altering cursors. SimView replies will alter them. */ 820 } SimViewInfo_t; 821 822 /* Global information */ 823 typedef struct { 824 Trace_t *trace_head; /* Pointer to first trace, set deleted_trace->next too */ 825 Trace_t *preserved_trace; /* Pointer to old trace when reading in new one */ 826 Trace_t *deleted_trace_head; /* Pointer to trace with deleted signals, which then links to teace_head */ 827 828 Signal_t *selected_sig; /* Selected signal to move or add */ 829 Trace_t *selected_trace; /* Selected signal's trace */ 830 Radix_t *selected_radix; /* Selected radix to change to */ 831 DCursor_t *selected_cursor; /* Selected radix to change to */ 832 Waveform_t selected_waveform; /* Selected analog/digital to change to */ 833 CursorType_t selected_curtype; /* Selected cursor type */ 834 SignalList_t *select_head; /* Pointer to selected signal list head */ 835 const char* select_note; /* Current note */ 836 837 DCursor_t *cursor_head; /* Pointer to first cursor */ 838 839 ValSearch_t val_srch[MAX_SRCH]; /* Value search information */ 840 841 SigSearch_t sig_srch[MAX_SRCH]; /* Signal search information */ 842 843 SignalState_t *signalstate_head; /* Head of signal state information */ 844 845 XtAppContext appcontext; /* X App context */ 846 Display *display; /* X display pointer */ 847 Cursor xcursors[DC_MAX]; /* X cursors */ 848 Pixmap dpm,bdpm; /* X pixmaps for the icons */ 849 850 uint_t argc; /* Program argc for X stuff */ 851 char **argv; /* Program argv for X stuff */ 852 853 char directory[MAXFNAMELEN]; /* Current directory name */ 854 855 ColorNum_t highlight_color; /* Color selected for sig/cursor highlight */ 856 ColorNum_t goto_color; /* Cursor color to place on a 'GOTO' -1=none */ 857 char * color_names[MAXCOLORS]; /* Names of the colors from the user */ 858 char * barcolor_name; /* name of the signal bar color */ 859 860 char * signal_font_name; /* name of font for signal names */ 861 char * time_font_name; /* name of font for times */ 862 char * value_font_name; /* name of font for values */ 863 XFontStruct *signal_font; /* Signal Text font */ 864 XFontStruct *time_font; /* Time Text font */ 865 XFontStruct *value_font; /* Value Text font */ 866 867 Geometry_t start_geometry; /* Geometry to open first trace with */ 868 Geometry_t open_geometry; /* Geometry to open later traces with */ 869 Geometry_t shrink_geometry; /* Geometry to shrink trace->open traces with */ 870 871 Trace_t *anno_last_trace; /* Last trace annotated */ 872 TraceSel_t anno_traces; /* Which traces to include */ 873 Boolean_t anno_ena_signal[MAX_SRCH+1]; /* Annotation signal enables */ 874 Boolean_t anno_ena_cursor[MAX_SRCH+1]; /* Annotation cursor enables */ 875 Boolean_t anno_ena_cursor_dotted[MAX_SRCH+1]; /* Annotation cursor enables */ 876 char anno_filename[MAXFNAMELEN]; /* Annotation file name */ 877 char anno_socket[MAXFNAMELEN]; /* Annotation socket number */ 878 879 PageInc_t pageinc; /* Page increment = HPAGE/QPAGE/FPAGE */ 880 Boolean_t click_to_edge; /* True if clicking to edges is enabled */ 881 TimeRep_t time_precision; /* Time precision = TIMEREP_NS/TIMEREP_CYC */ 882 char time_format[12]; /* Time format = printf format or *NULL */ 883 uint_t tempest_time_mult; /* Time multiplier for tempest */ 884 Boolean_t save_duplicates; /* True to save aliased wires */ 885 Boolean_t save_enables; /* True to save enable wires */ 886 Boolean_t save_ordering; /* True to save signal ordering */ 887 Boolean_t cursor_vis; /* True if cursors are visible */ 888 Dimension sighgt; /* Height of signals (customize) */ 889 uint_t sigrf; /* Signal rise/fall time spec */ 890 TimeRep_t timerep; /* Time representation = TIMEREP_NS/TIMEREP_CYC */ 891 892 char printnote[MAXFNAMELEN]; /* Note to print */ 893 PrintSize_t print_size; /* Size of paper for dt_printscreen */ 894 Boolean_t print_all_signals; /* Print all signals in the trace */ 895 DTime_t print_begin_time; /* Starting time for printing */ 896 DTime_t print_end_time; /* Ending time for printing */ 897 898 Boolean_t redraw_manually;/* True if in manual refreshing mode */ 899 uint_t redraw_needed; /* Some trace needs to refresh the screen when get a chance, GRD_* bit fielded */ 900 #define GRD_TRACE 0x1U 901 #define GRD_ALL 0x2U 902 #define GRD_MANUAL 0x4U 903 uint_t updates_needed; /* Things that are out of date and need to be called before redraw */ 904 #define GUD_SIG_START 0x100U /* Call sig_update_start */ 905 #define GUD_SIG_SEARCH 0x200U /* Call sig_update_search */ 906 #define GUD_VAL_SEARCH 0x400U /* Call val_update_search */ 907 #define GUD_VAL_STATES 0x800U /* Call val_update_states */ 908 909 DTime_t time; /* Time of trace at left edge of screen */ 910 float res; /* Resolution of graph width (gadgets) */ 911 Boolean_t res_default; /* True if resolution has never changed from initial value */ 912 Position xstart; /* Start X pos of signals on display */ 913 int namepos; /* Position of first visible character based on xstart */ 914 int namepos_hier; /* Maximum hierarchy width in chars */ 915 int namepos_base; /* Maximum basename width in chars */ 916 int namepos_prefix; /* Maximum characters in prefix hieararchy */ 917 int namepos_visible;/* Visible size of names in chars */ 918 Boolean_t prefix_enable; /* Show entire prefix on screen */ 919 DTime_t click_time; /* time clicked on for res_zoom_click */ 920 Grid_t *click_grid; /* grid being set by grid_align */ 921 922 Radix_t *radixs[RADIX_MAX]; /* Radix storage (standard types only) */ 923 924 Boolean_t config_enable[MAXCFGFILES];/* Read in this config file */ 925 char config_filename[MAXCFGFILES][MAXFNAMELEN]; /* Config files */ 926 char *cuswr_filename; /* Config write filename */ 927 Boolean_t cuswr_item[CUSWRITEM_MAX]; /* Config write item enables */ 928 TraceSel_t cuswr_traces; /* Which traces to include */ 929 930 SimViewInfo_t *simview_info_ptr; /* NULL if SimView not enabled. */ 931 } Global_t; 932 933 extern Global_t *global; 934 935