From bdc22cd3e6662df672efbd8f4ed56b5227289c66 Mon Sep 17 00:00:00 2001 From: Ralf Fuest Date: Mon, 4 Dec 2023 19:32:35 +0100 Subject: [PATCH] Remove VCD interactive mode --- CHANGELOG.md | 11 +- man/gtkwave.1 | 6 - man/gtkwaverc.5 | 3 - man/meson.build | 1 - man/shmidcat.1 | 32 - src/currenttime.h | 1 - src/globals.c | 39 - src/globals.h | 39 - src/helpers/meson.build | 1 - src/helpers/shmidcat.c | 303 ----- src/main.c | 101 +- src/meson.build | 1 - src/vcd.h | 4 - src/vcd_partial.c | 2748 --------------------------------------- src/vcd_partial.h | 15 - 15 files changed, 56 insertions(+), 3249 deletions(-) delete mode 100644 man/shmidcat.1 delete mode 100644 src/helpers/shmidcat.c delete mode 100644 src/vcd_partial.c delete mode 100644 src/vcd_partial.h diff --git a/CHANGELOG.md b/CHANGELOG.md index ed79877e..161499b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] +### Current limitations compared to GTKWave LTS 3.3 + +Some features have been removed in this version of GTKWave to make the codebase +easier to refactor. These features might be restored in future versions of GTKWave, +if there is enough interest by users. Please notify us on GitHub if you require any +of these features. + +- Removed the interactive VCD mode. +- Removed support for LXT, LXT2, VZT, and AET2 formats. + ### Changed - Merged in major GUI widget refactoring. @@ -27,7 +37,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Removed - Removed support for GTK 2. -- Removed support for LXT, LXT2, VZT, and AET2 formats. - Removed "Signal Search Hierarchy" dialog. - Removed setting to disable the "Alternate Wheel Mode". - Removed legacy VCD loader. diff --git a/man/gtkwave.1 b/man/gtkwave.1 index 604c14bd..bec9b0e1 100644 --- a/man/gtkwave.1 +++ b/man/gtkwave.1 @@ -123,12 +123,6 @@ Set gtk-application-prefer-dark-theme = TRUE. \fB\-7\fR,\fB\-\-saveonexit\fR At exit, a requester is brought up to prompt user to write a save file. Canceling the requester prevents from writing the file. .TP -\fB\-I\fR,\fB\-\-interactive\fR -Specifies that "interactive" VCD mode is to be used which allows a viewer to navigate a VCD trace while GTKWave is processing the VCD file. -When this option is used, the filename is overloaded such that it is the hexadecimal value for the shared memory ID of a writer. -Note that the shared memory ID can be passed straight from stdin by using the \fB\-\-vcd\fR option; see the manpage for -\fIshmidcat\fP(1) for more details. -.TP \fB\-g\fR,\fB\-\-giga\fR Specifies that the viewer should use gigabyte mempacking when recoding (possibly slower). This is equivalent to setting the vlist_spill and vlist_prepack flags in the rc file. diff --git a/man/gtkwaverc.5 b/man/gtkwaverc.5 index 207cc1f1..8ef1ddf7 100644 --- a/man/gtkwaverc.5 +++ b/man/gtkwaverc.5 @@ -25,9 +25,6 @@ This allows another character in addition to the hier_delimeter to be used to de Specifies how many overlapping analog segments can be drawn for a given X position onscreen. (Default: 20) If there are gaps in analog traces, this value is too low. .TP -\fBappend_vcd_hier\fR <\fIvalue\fP> -Allows the specification of a prefix hierarchy for VCD files. This can be done in "pieces," so that multiple layers of hierarchy are prepended to symbol names with the most significant addition occurring first (see .gtkwaverc in the examples/vcd directory). The intended use of this is to have the ability to add "project" prefixes which allow easier selection of everything from the tree hierarchy. -.TP \fBautocoalesce\fR <\fIvalue\fP> A nonzero value enables autocoalescing of VCD vectors when applicable. This may be toggled dynamically during wave viewer usage. .TP diff --git a/man/meson.build b/man/meson.build index 7eaf8cc3..ba359e7b 100644 --- a/man/meson.build +++ b/man/meson.build @@ -6,7 +6,6 @@ install_man( 'lxt2miner.1', 'lxt2vcd.1', 'rtlbrowse.1', - 'shmidcat.1', 'twinwave.1', 'vcd2fst.1', 'vcd2lxt.1', diff --git a/man/shmidcat.1 b/man/shmidcat.1 deleted file mode 100644 index 693a1fff..00000000 --- a/man/shmidcat.1 +++ /dev/null @@ -1,32 +0,0 @@ -.TH "SHMIDCAT" "1" "3.0.8" "Anthony Bybell" "Shared Memory Trampoline" -.SH "NAME" -.LP -shmidcat \- Copies stdin/file to a shared memory block for \fIgtkwave\fP(1) -.SH "SYNTAX" -.LP -shmidcat [\fIVCDFILE\fP] -.SH "DESCRIPTION" -.LP -Copies either the file specified at the command line or stdin (if no file specified) line by line to a shared memory block. stdout will contain a shared memory ID which should be passed on to \fIgtkwave\fP(1). -.SH "EXAMPLES" -.LP -To run this program the standard way type: -.TP -cat whatever.vcd | shmidcat -The shared memory ID is emitted to stdout. -.TP -shmidcat whatever.vcd | gtkwave \-v \-I whatever.sav -GTKWave directly grabs the ID from stdin. -.SH "LIMITATIONS" -This program is mainly for illustrative and testing purposes only. Its primary use is for people who wish to write -interactive VCD dumpers for \fIgtkwave\fP(1) as its source code may be examined, particularly the emit_string() function. -It can also be used to test if an existing VCD file will load properly in interactive mode. -Note that it can also be used to redirect -VCD files which are written into a pipe to \fIgtkwave\fP(1) in a non-blocking fashion. -.LP -.SH "AUTHORS" -.LP -Anthony Bybell -.SH "SEE ALSO" -.LP -\fIgtkwave\fP(1) diff --git a/src/currenttime.h b/src/currenttime.h index 94efb063..df528875 100644 --- a/src/currenttime.h +++ b/src/currenttime.h @@ -60,7 +60,6 @@ void exponent_to_time_scale(signed char scale); #include "timeentry.h" #include "tree.h" #include "treesearch.h" -#include "vcd_partial.h" #include "wavewindow.h" #include "zoombuttons.h" diff --git a/src/globals.c b/src/globals.c index 5c32557c..68377e7f 100644 --- a/src/globals.c +++ b/src/globals.c @@ -727,45 +727,6 @@ static const struct Global globals_base_values = { NULL, /* he_curr_vcd_c_1 506 */ NULL, /* he_fini */ - /* - * vcd_partial.c - */ - 0, /* vcdbyteno_vcd_partial_c_2 516 */ - 0, /* error_count_vcd_partial_c_2 517 */ - 0, /* header_over_vcd_partial_c_2 518 */ - -1, /* start_time_vcd_partial_c_2 520 */ - -1, /* end_time_vcd_partial_c_2 521 */ - -1, /* current_time_vcd_partial_c_2 522 */ - 0, /* num_glitches_vcd_partial_c_3 523 */ - 0, /* num_glitch_regions_vcd_partial_c_3 524 */ - NULL, /* pv_vcd_partial_c_2 525 */ - NULL, /* rootv */ - NULL, /* vcdbuf_vcd_partial_c_2 526 */ - NULL, /* vst */ - NULL, /* vend */ - NULL, /* consume_ptr_vcd_partial_c_1 527 */ - NULL, /* buf_vcd_partial_c_2 528 */ - 100000, /* consume_countdown_vcd_partial_c_1 529 */ - 1024, /* T_MAX_STR_vcd_partial_c_2 531 */ - NULL, /* yytext_vcd_partial_c_2 532 */ - 0, /* yylen_vcd_partial_c_2 533 */ - 0, /* yylen_cache */ - NULL, /* vcdsymroot_vcd_partial_c_2 534 */ - NULL, /* vcdsymcurr */ - NULL, /* sorted_vcd_partial_c_2 535 */ - NULL, /* indexed_vcd_partial_c_2 536 */ - 0, /* numsyms_vcd_partial_c_2 538 */ - ~0, /* vcd_minid_vcd_partial_c_2 540 */ - 0, /* vcd_maxid_vcd_partial_c_2 541 */ - 0, /* err_vcd_partial_c_2 542 */ - NULL, /* varsplit_vcd_partial_c_2 543 */ - NULL, /* vsplitcurr */ - 0, /* var_prevch_vcd_partial_c_2 544 */ - 0, /* timeset_vcd_partial_c_1 547 */ - 0, /* vcd_hash_max_partial */ - 0, /* vcd_hash_kill_partial */ - NULL, /* sym_chain_partial */ - /* * vcd_recoder.c */ diff --git a/src/globals.h b/src/globals.h index 009bdda6..95899338 100644 --- a/src/globals.h +++ b/src/globals.h @@ -707,45 +707,6 @@ struct Global GwHistEnt *he_curr_vcd_c_1; /* from vcd.c 543 */ GwHistEnt *he_fini_vcd_c_1; /* from vcd.c 544 */ - /* - * vcd_partial.c - */ - off_t vcdbyteno_vcd_partial_c_2; /* from vcd_partial.c 555 */ - int error_count_vcd_partial_c_2; /* from vcd_partial.c 556 */ - int header_over_vcd_partial_c_2; /* from vcd_partial.c 557 */ - GwTime start_time_vcd_partial_c_2; /* from vcd_partial.c 559 */ - GwTime end_time_vcd_partial_c_2; /* from vcd_partial.c 560 */ - GwTime current_time_vcd_partial_c_2; /* from vcd_partial.c 561 */ - int num_glitches_vcd_partial_c_3; /* from vcd_partial.c 562 */ - int num_glitch_regions_vcd_partial_c_3; /* from vcd_partial.c 563 */ - struct vcdsymbol *pv_vcd_partial_c_2; /* from vcd_partial.c 564 */ - struct vcdsymbol *rootv_vcd_partial_c_2; /* from vcd_partial.c 565 */ - char *vcdbuf_vcd_partial_c_2; /* from vcd_partial.c 566 */ - char *vst_vcd_partial_c_2; /* from vcd_partial.c 567 */ - char *vend_vcd_partial_c_2; /* from vcd_partial.c 568 */ - char *consume_ptr_vcd_partial_c_1; /* from vcd_partial.c 569 */ - char *buf_vcd_partial_c_2; /* from vcd_partial.c 570 */ - int consume_countdown_vcd_partial_c_1; /* from vcd_partial.c 571 */ - int T_MAX_STR_vcd_partial_c_2; /* from vcd_partial.c 573 */ - char *yytext_vcd_partial_c_2; /* from vcd_partial.c 574 */ - int yylen_vcd_partial_c_2; /* from vcd_partial.c 575 */ - int yylen_cache_vcd_partial_c_2; /* from vcd_partial.c 576 */ - struct vcdsymbol *vcdsymroot_vcd_partial_c_2; /* from vcd_partial.c 577 */ - struct vcdsymbol *vcdsymcurr_vcd_partial_c_2; /* from vcd_partial.c 578 */ - struct vcdsymbol **sorted_vcd_partial_c_2; /* from vcd_partial.c 579 */ - struct vcdsymbol **indexed_vcd_partial_c_2; /* from vcd_partial.c 580 */ - int numsyms_vcd_partial_c_2; /* from vcd_partial.c 582 */ - unsigned int vcd_minid_vcd_partial_c_2; /* from vcd_partial.c 584 */ - unsigned int vcd_maxid_vcd_partial_c_2; /* from vcd_partial.c 585 */ - int err_vcd_partial_c_2; /* from vcd_partial.c 586 */ - char *varsplit_vcd_partial_c_2; /* from vcd_partial.c 587 */ - char *vsplitcurr_vcd_partial_c_2; /* from vcd_partial.c 588 */ - int var_prevch_vcd_partial_c_2; /* from vcd_partial.c 589 */ - int timeset_vcd_partial_c_1; /* from vcd_partial.c 592 */ - unsigned int vcd_hash_max_partial; - int vcd_hash_kill_partial; - GSList *sym_chain_partial; - /* * vcd_recoder.c */ diff --git a/src/helpers/meson.build b/src/helpers/meson.build index 8eed11b7..10ccd5b8 100644 --- a/src/helpers/meson.build +++ b/src/helpers/meson.build @@ -4,7 +4,6 @@ helpers = [ 'fstminer', 'lxt2miner', 'lxt2vcd', - 'shmidcat', 'vcd2fst', 'vcd2lxt', 'vcd2lxt2', diff --git a/src/helpers/shmidcat.c b/src/helpers/shmidcat.c deleted file mode 100644 index 149e95a8..00000000 --- a/src/helpers/shmidcat.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2006-2009 Tony Bybell. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#if !defined _MSC_VER && !defined __MINGW32__ -#include -#include -#endif -#ifdef __MINGW32__ -#include -#endif -#include -#include -#include - -#ifndef _MSC_VER -#ifndef __MINGW32__ -#include -#else -#include -#endif -#endif - -#include "wave_locale.h" - -#if !defined _MSC_VER - -/* size *must* match in gtkwave */ -#define WAVE_PARTIAL_VCD_RING_BUFFER_SIZE (1024 * 1024) - -char *buf_top, *buf_curr, *buf; -char *consume_ptr; - -unsigned int get_8(char *p) -{ - if (p >= (buf + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - p -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - - return ((unsigned int)((unsigned char)*p)); -} - -unsigned int get_32(char *p) -{ - unsigned int rc; - - rc = (get_8(p++) << 24); - rc |= (get_8(p++) << 16); - rc |= (get_8(p++) << 8); - rc |= (get_8(p) << 0); - - return (rc); -} - -void put_8(char *p, unsigned int v) -{ - if (p >= (buf + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - p -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - - *p = (unsigned char)v; -} - -void put_32(char *p, unsigned int v) -{ - put_8(p++, (v >> 24)); - put_8(p++, (v >> 16)); - put_8(p++, (v >> 8)); - put_8(p, (v >> 0)); -} - -int consume(void) /* for testing only...similar code also is on the receiving end in gtkwave */ -{ - char mybuff[32769]; - int rc; - - if ((rc = *consume_ptr)) { - unsigned int len = get_32(consume_ptr + 1); - unsigned int i; - - for (i = 0; i < len; i++) { - mybuff[i] = get_8(consume_ptr + i + 5); - } - mybuff[i] = 0; - printf("%s", mybuff); - - *consume_ptr = 0; - consume_ptr = consume_ptr + i + 5; - if (consume_ptr >= (buf + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - consume_ptr -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - } - - return (rc); -} - -void emit_string(char *s) -{ - int len = strlen(s); - uintptr_t l_top, l_curr; - int consumed; - int blksiz; - - for (;;) { - while (!*buf_top) { - if ((blksiz = get_32(buf_top + 1))) { - buf_top += 1 + 4 + blksiz; - if (buf_top >= (buf + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - buf_top -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - } else { - break; - } - } - - l_top = (uintptr_t)buf_top; - l_curr = (uintptr_t)buf_curr; - - if (l_curr >= l_top) { - consumed = l_curr - l_top; - } else { - consumed = (l_curr + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE) - l_top; - } - - if ((consumed + len + 16) > - WAVE_PARTIAL_VCD_RING_BUFFER_SIZE) /* just a guardband, it's oversized */ - { -#ifdef __MINGW32__ - Sleep(10); -#else - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 1000000 / 100; - select(0, NULL, NULL, NULL, &tv); -#endif - continue; - } else { - char *ss, *sd; - put_32(buf_curr + 1, len); - - sd = buf_curr + 1 + 4; - ss = s; - while (*ss) { - put_8(sd, *ss); - ss++; - sd++; - } - put_8(sd, 0); /* next valid */ - put_32(sd + 1, 0); /* next len */ - put_8(buf_curr, 1); /* current valid */ - - buf_curr += 1 + 4 + len; - if (buf_curr >= (buf + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - buf_curr -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - - break; - } - } -} - -/* - * example driver code. this merely copies from stdin to the shared memory block. - * emit_string() will ensure that buffer overruns do not occur; all you have to - * do is write the block with the provision that the last character in the block is - * a newline so that the VCD parser doesn't get lost. (in effect, when we run out - * of buffer, gtkwave thinks it's EOF, but we restart again later. if the last - * character is a newline, we EOF on a null string which is OK.) - * the shared memory ID will print on stdout. pass that on to gtkwave for reading. - */ -int main(int argc, char **argv) -{ - int buf_strlen = 0; - char l_buf[32769]; - FILE *f; -#ifdef __MINGW32__ - char mapName[65]; - HANDLE hMapFile; -#else - struct shmid_ds ds; -#endif - int shmid; - - WAVE_LOCALE_FIX - - if (argc != 1) { - f = fopen(argv[1], "rb"); - if (!f) { - fprintf(stderr, "Could not open '%s', exiting.\n", argv[1]); - perror("Why"); - exit(255); - } - } else { - f = stdin; - } - -#ifdef __MINGW32__ - shmid = getpid(); - sprintf(mapName, "shmidcat%d", shmid); - hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, - NULL, - PAGE_READWRITE, - 0, - WAVE_PARTIAL_VCD_RING_BUFFER_SIZE, - mapName); - if (hMapFile != NULL) { - buf_top = buf_curr = buf = - MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, WAVE_PARTIAL_VCD_RING_BUFFER_SIZE); -#else - shmid = shmget(0, WAVE_PARTIAL_VCD_RING_BUFFER_SIZE, IPC_CREAT | 0600); - if (shmid >= 0) { - buf_top = buf_curr = buf = shmat(shmid, NULL, 0); -#endif - memset(buf, 0, WAVE_PARTIAL_VCD_RING_BUFFER_SIZE); - -#ifdef __linux__ - shmctl(shmid, - IPC_RMID, - &ds); /* mark for destroy, linux allows queuing up destruction now */ -#endif - - printf("%08X\n", shmid); - fflush(stdout); - - consume_ptr = buf; - - while (!feof(f)) { - char *s = fgets(l_buf + buf_strlen, 32768 - buf_strlen, f); - - if (!s) { -#ifdef __MINGW32__ - Sleep(200); -#else - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 1000000 / 5; - select(0, NULL, NULL, NULL, &tv); -#endif - continue; - } - - if (strchr(l_buf + buf_strlen, '\n') || strchr(l_buf + buf_strlen, '\r')) { - emit_string(l_buf); - buf_strlen = 0; - } else { - buf_strlen += strlen(l_buf + buf_strlen); - /* fprintf(stderr, "update len to: %d\n", buf_strlen); */ - } - } - -#ifndef __linux__ -#ifdef __MINGW32__ - UnmapViewOfFile(buf); - CloseHandle(hMapFile); -#else - shmctl(shmid, IPC_RMID, &ds); /* mark for destroy */ -#endif -#endif - } - - return (0); -} - -#else - -int main(int argc, char **argv) -{ -#if defined _MSC_VER - fprintf(stderr, "Sorry, this doesn't run under Win32!\n"); -#endif - - fprintf(stderr, - "If you find that this program works on your platform, please report this to the " - "maintainers.\n"); - - return (255); -} - -#endif diff --git a/src/main.c b/src/main.c index 647a4354..b2b568a8 100644 --- a/src/main.c +++ b/src/main.c @@ -278,8 +278,6 @@ static void print_help(char *nam) #define STEMS_GETOPT " -t, --stems=FILE specify stems file for source code annotation\n" #define DUAL_GETOPT " -D, --dualid=WHICH specify multisession identifier\n" -#define INTR_GETOPT \ - " -I, --interactive interactive VCD mode (filename is shared mem ID)\n" #ifdef WAVE_USE_XID #define XID_GETOPT " -X, --xid=XID specify XID of window for GtkPlug to connect to\n" @@ -343,7 +341,7 @@ static void print_help(char *nam) " -4, --rcvar specify single rc variable values individually\n" " -5, --sstexclude specify sst exclusion filter filename\n" " -6, --dark set gtk-application-prefer-dark-theme = TRUE\n" - " -7, --saveonexit prompt user to write save file at exit\n" INTR_GETOPT + " -7, --saveonexit prompt user to write save file at exit\n" " -C, --comphier use compressed hierarchy names (slower)\n" " -g, --giga use gigabyte mempacking when recoding (slower)\n" " -v, --vcd use stdin as a VCD dumpfile\n" OUTPUT_GETOPT @@ -679,7 +677,6 @@ int main_2(int opt_vcd, int argc, char *argv[]) int c; char is_vcd = 0; char is_wish = 0; - char is_interactive = 0; char is_smartsave = 0; char is_giga = 0; char fast_exit = 0; @@ -919,26 +916,43 @@ int main_2(int opt_vcd, int argc, char *argv[]) while (1) { int option_index = 0; - static struct option long_options[] = { - {"dump", 1, 0, 'f'}, {"optimize", 0, 0, 'o'}, - {"nocli", 1, 0, 'n'}, {"save", 1, 0, 'a'}, - {"autosavename", 0, 0, 'A'}, {"rcfile", 1, 0, 'r'}, - {"defaultskip", 0, 0, 'd'}, {"logfile", 1, 0, 'l'}, - {"start", 1, 0, 's'}, {"end", 1, 0, 'e'}, - {"cpus", 1, 0, 'c'}, {"stems", 1, 0, 't'}, - {"nowm", 0, 0, 'N'}, {"script", 1, 0, 'S'}, - {"vcd", 0, 0, 'v'}, {"version", 0, 0, 'V'}, - {"help", 0, 0, 'h'}, {"exit", 0, 0, 'x'}, - {"xid", 1, 0, 'X'}, {"nomenus", 0, 0, 'M'}, - {"dualid", 1, 0, 'D'}, {"interactive", 0, 0, 'I'}, - {"giga", 0, 0, 'g'}, {"comphier", 0, 0, 'C'}, - {"tcl_init", 1, 0, 'T'}, {"wish", 0, 0, 'W'}, - {"repscript", 1, 0, 'R'}, {"repperiod", 1, 0, 'P'}, - {"output", 1, 0, 'O'}, {"slider-zoom", 0, 0, 'z'}, - {"rpcid", 1, 0, '1'}, {"chdir", 1, 0, '2'}, - {"restore", 0, 0, '3'}, {"rcvar", 1, 0, '4'}, - {"sstexclude", 1, 0, '5'}, {"dark", 0, 0, '6'}, - {"saveonexit", 0, 0, '7'}, {0, 0, 0, 0}}; + static struct option long_options[] = {{"dump", 1, 0, 'f'}, + {"optimize", 0, 0, 'o'}, + {"nocli", 1, 0, 'n'}, + {"save", 1, 0, 'a'}, + {"autosavename", 0, 0, 'A'}, + {"rcfile", 1, 0, 'r'}, + {"defaultskip", 0, 0, 'd'}, + {"logfile", 1, 0, 'l'}, + {"start", 1, 0, 's'}, + {"end", 1, 0, 'e'}, + {"cpus", 1, 0, 'c'}, + {"stems", 1, 0, 't'}, + {"nowm", 0, 0, 'N'}, + {"script", 1, 0, 'S'}, + {"vcd", 0, 0, 'v'}, + {"version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {"exit", 0, 0, 'x'}, + {"xid", 1, 0, 'X'}, + {"nomenus", 0, 0, 'M'}, + {"dualid", 1, 0, 'D'}, + {"giga", 0, 0, 'g'}, + {"comphier", 0, 0, 'C'}, + {"tcl_init", 1, 0, 'T'}, + {"wish", 0, 0, 'W'}, + {"repscript", 1, 0, 'R'}, + {"repperiod", 1, 0, 'P'}, + {"output", 1, 0, 'O'}, + {"slider-zoom", 0, 0, 'z'}, + {"rpcid", 1, 0, '1'}, + {"chdir", 1, 0, '2'}, + {"restore", 0, 0, '3'}, + {"rcvar", 1, 0, '4'}, + {"sstexclude", 1, 0, '5'}, + {"dark", 0, 0, '6'}, + {"saveonexit", 0, 0, '7'}, + {0, 0, 0, 0}}; c = getopt_long(argc, argv, @@ -971,10 +985,6 @@ int main_2(int opt_vcd, int argc, char *argv[]) #endif break; - case 'I': - is_interactive = 1; - break; - case 'D': { char *s = optarg; char *plus = strchr(s, '+'); @@ -1491,14 +1501,8 @@ int main_2(int opt_vcd, int argc, char *argv[]) GLOBALS->winname = malloc_2(strlen(winstd) + 4 + 1); strcpy(GLOBALS->winname, winstd); } else { - if (!is_interactive) { - GLOBALS->winname = malloc_2(strlen(GLOBALS->loaded_file_name) + strlen(winprefix) + 1); - strcpy(GLOBALS->winname, winprefix); - } else { - const char *iact = "GTKWave - Interactive Shared Memory ID "; - GLOBALS->winname = malloc_2(strlen(GLOBALS->loaded_file_name) + strlen(iact) + 1); - strcpy(GLOBALS->winname, iact); - } + GLOBALS->winname = malloc_2(strlen(GLOBALS->loaded_file_name) + strlen(winprefix) + 1); + strcpy(GLOBALS->winname, winprefix); } strcat(GLOBALS->winname, GLOBALS->loaded_file_name); @@ -1601,17 +1605,12 @@ int main_2(int opt_vcd, int argc, char *argv[]) #endif - if (is_interactive) { - GLOBALS->loaded_file_type = DUMPLESS_FILE; - vcd_partial_main(GLOBALS->loaded_file_name); + if (strcmp(GLOBALS->loaded_file_name, "-vcd")) { + GLOBALS->loaded_file_type = VCD_RECODER_FILE; } else { - if (strcmp(GLOBALS->loaded_file_name, "-vcd")) { - GLOBALS->loaded_file_type = VCD_RECODER_FILE; - } else { - GLOBALS->loaded_file_type = DUMPLESS_FILE; - } - vcd_recoder_main(GLOBALS->loaded_file_name); + GLOBALS->loaded_file_type = DUMPLESS_FILE; } + vcd_recoder_main(GLOBALS->loaded_file_name); } /* deallocate the symbol hash table */ @@ -2335,12 +2334,8 @@ int main_2(int opt_vcd, int argc, char *argv[]) time_update(); } - if (is_interactive) { - kick_partial_vcd(); - } else { - while (gtk_events_pending()) - gtk_main_iteration(); - } + while (gtk_events_pending()) + gtk_main_iteration(); GLOBALS->dual_race_lock = 0; @@ -2358,10 +2353,6 @@ int main_2(int opt_vcd, int argc, char *argv[]) GLOBALS->dual_attach_id_main_c_1); exit(255); } - } else if (is_interactive) { - for (;;) { - kick_partial_vcd(); - } } else { #if defined(HAVE_LIBTCL) if (is_wish) { diff --git a/src/meson.build b/src/meson.build index 0e79912e..b5bba657 100644 --- a/src/meson.build +++ b/src/meson.build @@ -90,7 +90,6 @@ gtkwave_sources = [ 'tree.c', 'treesearch.c', 'ttranslate.c', - 'vcd_partial.c', 'vcd_recoder.c', 'vcd_saver.c', 'vcd.c', diff --git a/src/vcd.h b/src/vcd.h index eb97b6a3..c54711f7 100644 --- a/src/vcd.h +++ b/src/vcd.h @@ -99,10 +99,6 @@ enum VarTypes GwTime vcd_recoder_main(char *fname); -GwTime vcd_partial_main(char *fname); -void vcd_partial_mark_and_sweep(int mandclear); -void kick_partial_vcd(void); - struct slist { struct slist *next; diff --git a/src/vcd_partial.c b/src/vcd_partial.c deleted file mode 100644 index fa82746c..00000000 --- a/src/vcd_partial.c +++ /dev/null @@ -1,2748 +0,0 @@ -/* - * Copyright (c) Tony Bybell 1999-2017. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - */ - -/* - * vcd.c 23jan99ajb - * evcd parts 29jun99ajb - * profiler optimizations 15jul99ajb - * more profiler optimizations 25jan00ajb - * finsim parameter fix 26jan00ajb - * vector rechaining code 03apr00ajb - * multiple var section code 06apr00ajb - * fix for duplicate nets 19dec00ajb - * support for alt hier seps 23dec00ajb - * fix for rcs identifiers 16jan01ajb - * coredump fix for bad VCD 04apr02ajb - * min/maxid speedup 27feb03ajb - * bugfix on min/maxid speedup 06jul03ajb - * escaped hier modification 20feb06ajb - * added partial loader support 04aug06ajb - * added real_parameter vartype 04aug06ajb - * added in/out port vartype 31jan07ajb - * use gperf for port vartypes 19feb07ajb - * MTI SV implicit-var fix 05apr07ajb - * MTI SV len=0 is real var 05apr07ajb - */ -#include -#include "globals.h" -#include "vcd.h" -#include "hierpack.h" -#include "signal_list.h" -#include "gw-wave-view.h" - -#if !defined __MINGW32__ -#include -#include -#include -#endif - -#ifdef __MINGW32__ -#include -#endif - -#undef VCD_BSEARCH_IS_PERFECT /* bsearch is imperfect under linux, but OK under AIX */ - -static GwHistEnt *add_histent_p(GwTime time, GwNode *n, char ch, int regadd, char *vector); -static void add_tail_histents(void); -static void vcd_build_symbols(void); -static void vcd_cleanup(void); -static void evcd_strcpy(char *dst, char *src); - -/*******************************************************************************/ - -#define WAVE_PARTIAL_VCD_RING_BUFFER_SIZE (1024 * 1024) - -unsigned int get_8(char *p) -{ - if (p >= (GLOBALS->buf_vcd_partial_c_2 + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - p -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - - return ((unsigned int)((unsigned char)*p)); -} - -unsigned int get_32(char *p) -{ - unsigned int rc; - rc = (get_8(p++) << 24); - rc |= (get_8(p++) << 16); - rc |= (get_8(p++) << 8); - rc |= (get_8(p) << 0); - - return (rc); -} - -int consume(void) /* for testing only */ -{ - int len; - - GLOBALS->consume_countdown_vcd_partial_c_1--; - if (!GLOBALS->consume_countdown_vcd_partial_c_1) { - GLOBALS->consume_countdown_vcd_partial_c_1 = 100000; - return (0); - } - - if ((len = *GLOBALS->consume_ptr_vcd_partial_c_1)) { - int i; - - len = get_32(GLOBALS->consume_ptr_vcd_partial_c_1 + 1); - for (i = 0; i < len; i++) { - GLOBALS->vcdbuf_vcd_partial_c_2[i] = - get_8(GLOBALS->consume_ptr_vcd_partial_c_1 + i + 5); - } - GLOBALS->vcdbuf_vcd_partial_c_2[i] = 0; - - *GLOBALS->consume_ptr_vcd_partial_c_1 = 0; - GLOBALS->consume_ptr_vcd_partial_c_1 = GLOBALS->consume_ptr_vcd_partial_c_1 + i + 5; - if (GLOBALS->consume_ptr_vcd_partial_c_1 >= - (GLOBALS->buf_vcd_partial_c_2 + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE)) { - GLOBALS->consume_ptr_vcd_partial_c_1 -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE; - } - } - - return (len); -} - -/******************************************************************/ - -enum Tokens -{ - T_VAR, - T_END, - T_SCOPE, - T_UPSCOPE, - T_COMMENT, - T_DATE, - T_DUMPALL, - T_DUMPOFF, - T_DUMPON, - T_DUMPVARS, - T_ENDDEFINITIONS, - T_DUMPPORTS, - T_DUMPPORTSOFF, - T_DUMPPORTSON, - T_DUMPPORTSALL, - T_TIMESCALE, - T_VERSION, - T_VCDCLOSE, - T_TIMEZERO, - T_EOF, - T_STRING, - T_UNKNOWN_KEY -}; - -static const char *tokens[] = {"var", - "end", - "scope", - "upscope", - "comment", - "date", - "dumpall", - "dumpoff", - "dumpon", - "dumpvars", - "enddefinitions", - "dumpports", - "dumpportsoff", - "dumpportson", - "dumpportsall", - "timescale", - "version", - "vcdclose", - "timezero", - "", - "", - ""}; - -#define NUM_TOKENS 19 - -#define T_GET \ - tok = get_token(); \ - if ((tok == T_END) || (tok == T_EOF)) \ - break; - -/******************************************************************/ - -#define NUM_VTOKENS 23 - -/******************************************************************/ - -static unsigned int vcdid_hash(char *s, int len) -{ - unsigned int val = 0; - int i; - - s += (len - 1); - - for (i = 0; i < len; i++) { - val *= 94; - val += (((unsigned char)*s) - 32); - s--; - } - - return (val); -} - -/******************************************************************/ - -/* - * bsearch compare - */ -static int vcdsymbsearchcompare(const void *s1, const void *s2) -{ - char *v1; - struct vcdsymbol *v2; - - v1 = (char *)s1; - v2 = *((struct vcdsymbol **)s2); - - return (strcmp(v1, v2->id)); -} - -/* - * actual bsearch - */ -static struct vcdsymbol *bsearch_vcd(char *key, int len) -{ - struct vcdsymbol **v; - struct vcdsymbol *t; - - if (GLOBALS->indexed_vcd_partial_c_2) { - unsigned int hsh = vcdid_hash(key, len); - if ((hsh >= GLOBALS->vcd_minid_vcd_partial_c_2) && - (hsh <= GLOBALS->vcd_maxid_vcd_partial_c_2)) { - return (GLOBALS->indexed_vcd_partial_c_2[hsh - GLOBALS->vcd_minid_vcd_partial_c_2]); - } - - return (NULL); - } - - if (GLOBALS->sorted_vcd_partial_c_2) { - v = (struct vcdsymbol **)bsearch(key, - GLOBALS->sorted_vcd_partial_c_2, - GLOBALS->numsyms_vcd_partial_c_2, - sizeof(struct vcdsymbol *), - vcdsymbsearchcompare); - - if (v) { -#ifndef VCD_BSEARCH_IS_PERFECT - for (;;) { - t = *v; - - if ((v == GLOBALS->sorted_vcd_partial_c_2) || (strcmp((*(--v))->id, key))) { - return (t); - } - } -#else - return (*v); -#endif - } else { - return (NULL); - } - } else { - if (!GLOBALS->err_vcd_partial_c_2) { - fprintf(stderr, - "Near byte %d, VCD search table NULL..is this a VCD file?\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2))); - GLOBALS->err_vcd_partial_c_2 = 1; - } - return (NULL); - } -} - -/* - * sort on vcdsymbol pointers - */ -static int vcdsymcompare(const void *s1, const void *s2) -{ - struct vcdsymbol *v1, *v2; - - v1 = *((struct vcdsymbol **)s1); - v2 = *((struct vcdsymbol **)s2); - - return (strcmp(v1->id, v2->id)); -} - -/* - * create sorted (by id) table - */ -static void create_sorted_table(void) -{ - struct vcdsymbol *v; - struct vcdsymbol **pnt; - unsigned int vcd_distance; - - if (GLOBALS->sorted_vcd_partial_c_2) { - free_2(GLOBALS->sorted_vcd_partial_c_2); /* this means we saw a 2nd enddefinition chunk! */ - GLOBALS->sorted_vcd_partial_c_2 = NULL; - } - - if (GLOBALS->indexed_vcd_partial_c_2) { - free_2(GLOBALS->indexed_vcd_partial_c_2); - GLOBALS->indexed_vcd_partial_c_2 = NULL; - } - - if (GLOBALS->numsyms_vcd_partial_c_2) { - vcd_distance = GLOBALS->vcd_maxid_vcd_partial_c_2 - GLOBALS->vcd_minid_vcd_partial_c_2 + 1; - - if ((vcd_distance <= VCD_INDEXSIZ) || (!GLOBALS->vcd_hash_kill_partial)) { - GLOBALS->indexed_vcd_partial_c_2 = - (struct vcdsymbol **)calloc_2(vcd_distance, sizeof(struct vcdsymbol *)); - - /* printf("%d symbols span ID range of %d, using indexing...\n", numsyms, vcd_distance); - */ - - v = GLOBALS->vcdsymroot_vcd_partial_c_2; - while (v) { - if (!GLOBALS->indexed_vcd_partial_c_2[v->nid - GLOBALS->vcd_minid_vcd_partial_c_2]) - GLOBALS->indexed_vcd_partial_c_2[v->nid - GLOBALS->vcd_minid_vcd_partial_c_2] = - v; - v = v->next; - } - } else { - pnt = GLOBALS->sorted_vcd_partial_c_2 = - (struct vcdsymbol **)calloc_2(GLOBALS->numsyms_vcd_partial_c_2, - sizeof(struct vcdsymbol *)); - v = GLOBALS->vcdsymroot_vcd_partial_c_2; - while (v) { - *(pnt++) = v; - v = v->next; - } - - qsort(GLOBALS->sorted_vcd_partial_c_2, - GLOBALS->numsyms_vcd_partial_c_2, - sizeof(struct vcdsymbol *), - vcdsymcompare); - } - } -} - -/******************************************************************/ - -/* - * single char get inlined/optimized - */ -static void getch_alloc(void) -{ - GLOBALS->vend_vcd_partial_c_2 = GLOBALS->vst_vcd_partial_c_2 = GLOBALS->vcdbuf_vcd_partial_c_2 = - (char *)calloc_2(1, VCD_BSIZ); -} - -static int getch_fetch(void) -{ - size_t rd; - - errno = 0; - - GLOBALS->vcdbyteno_vcd_partial_c_2 += - (GLOBALS->vend_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2); - rd = consume(); - GLOBALS->vend_vcd_partial_c_2 = - (GLOBALS->vst_vcd_partial_c_2 = GLOBALS->vcdbuf_vcd_partial_c_2) + rd; - - if (!rd) - return (-1); - - return ((int)(*GLOBALS->vst_vcd_partial_c_2)); -} - -static inline signed char getch(void) -{ - signed char ch = ((GLOBALS->vst_vcd_partial_c_2 != GLOBALS->vend_vcd_partial_c_2) - ? ((int)(*GLOBALS->vst_vcd_partial_c_2)) - : (getch_fetch())); - if (ch >= 0) { - GLOBALS->vst_vcd_partial_c_2++; - }; - return (ch); -} - -static inline signed char getch_peek(void) -{ - signed char ch = ((GLOBALS->vst_vcd_partial_c_2 != GLOBALS->vend_vcd_partial_c_2) - ? ((int)(*GLOBALS->vst_vcd_partial_c_2)) - : (getch_fetch())); - /* no increment */ - return (ch); -} - -static int getch_patched(void) -{ - char ch; - - ch = *GLOBALS->vsplitcurr_vcd_partial_c_2; - if (!ch) { - return (-1); - } else { - GLOBALS->vsplitcurr_vcd_partial_c_2++; - return ((int)ch); - } -} - -/* - * simple tokenizer - */ -static int get_token(void) -{ - int ch; - int i, len = 0; - int is_string = 0; - char *yyshadow; - - for (;;) { - ch = getch(); - if (ch < 0) - return (T_EOF); - if (ch <= ' ') - continue; /* val<=' ' is a quick whitespace check */ - break; /* (take advantage of fact that vcd is text) */ - } - if (ch == '$') { - GLOBALS->yytext_vcd_partial_c_2[len++] = ch; - for (;;) { - ch = getch(); - if (ch < 0) - return (T_EOF); - if (ch <= ' ') - continue; - break; - } - } else { - is_string = 1; - } - - for (GLOBALS->yytext_vcd_partial_c_2[len++] = ch;; - GLOBALS->yytext_vcd_partial_c_2[len++] = ch) { - if (len == GLOBALS->T_MAX_STR_vcd_partial_c_2) { - GLOBALS->yytext_vcd_partial_c_2 = (char *)realloc_2( - GLOBALS->yytext_vcd_partial_c_2, - (GLOBALS->T_MAX_STR_vcd_partial_c_2 = GLOBALS->T_MAX_STR_vcd_partial_c_2 * 2) + 1); - } - ch = getch(); - if (ch <= ' ') - break; - } - GLOBALS->yytext_vcd_partial_c_2[len] = 0; /* terminator */ - GLOBALS->yylen_vcd_partial_c_2 = len; - - if (is_string) { - return (T_STRING); - } - - yyshadow = GLOBALS->yytext_vcd_partial_c_2; - do { - yyshadow++; - for (i = 0; i < NUM_TOKENS; i++) { - if (!strcmp(yyshadow, tokens[i])) { - return (i); - } - } - - } while (*yyshadow == '$'); /* fix for RCS ids in version strings */ - - return (T_UNKNOWN_KEY); -} - -static int get_vartoken_patched(int match_kw) -{ - int ch; - int len = 0; - - if (!GLOBALS->var_prevch_vcd_partial_c_2) { - for (;;) { - ch = getch_patched(); - if (ch < 0) { - free_2(GLOBALS->varsplit_vcd_partial_c_2); - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - return (V_END); - } - if ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r')) - continue; - break; - } - } else { - ch = GLOBALS->var_prevch_vcd_partial_c_2; - GLOBALS->var_prevch_vcd_partial_c_2 = 0; - } - - if (ch == '[') - return (V_LB); - if (ch == ':') - return (V_COLON); - if (ch == ']') - return (V_RB); - - for (GLOBALS->yytext_vcd_partial_c_2[len++] = ch;; - GLOBALS->yytext_vcd_partial_c_2[len++] = ch) { - if (len == GLOBALS->T_MAX_STR_vcd_partial_c_2) { - GLOBALS->yytext_vcd_partial_c_2 = (char *)realloc_2( - GLOBALS->yytext_vcd_partial_c_2, - (GLOBALS->T_MAX_STR_vcd_partial_c_2 = GLOBALS->T_MAX_STR_vcd_partial_c_2 * 2) + 1); - } - ch = getch_patched(); - if (ch < 0) { - free_2(GLOBALS->varsplit_vcd_partial_c_2); - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - break; - } - if ((ch == ':') || (ch == ']')) { - GLOBALS->var_prevch_vcd_partial_c_2 = ch; - break; - } - } - GLOBALS->yytext_vcd_partial_c_2[len] = 0; /* terminator */ - - if (match_kw) { - int vt = vcd_keyword_code(GLOBALS->yytext_vcd_partial_c_2, len); - if (vt != V_STRING) { - if (ch < 0) { - free_2(GLOBALS->varsplit_vcd_partial_c_2); - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - } - return (vt); - } - } - - GLOBALS->yylen_vcd_partial_c_2 = len; - if (ch < 0) { - free_2(GLOBALS->varsplit_vcd_partial_c_2); - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - } - return (V_STRING); -} - -static int get_vartoken(int match_kw) -{ - int ch; - int len = 0; - - if (GLOBALS->varsplit_vcd_partial_c_2) { - int rc = get_vartoken_patched(match_kw); - if (rc != V_END) - return (rc); - GLOBALS->var_prevch_vcd_partial_c_2 = 0; - } - - if (!GLOBALS->var_prevch_vcd_partial_c_2) { - for (;;) { - ch = getch(); - if (ch < 0) - return (V_END); - if ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r')) - continue; - break; - } - } else { - ch = GLOBALS->var_prevch_vcd_partial_c_2; - GLOBALS->var_prevch_vcd_partial_c_2 = 0; - } - - if (ch == '[') - return (V_LB); - if (ch == ':') - return (V_COLON); - if (ch == ']') - return (V_RB); - - if (ch == '#') /* for MTI System Verilog '$var reg 64 >w #implicit-var###VarElem:ram_di[0.0] - [63:0] $end' style declarations */ - { /* debussy simply escapes until the space */ - GLOBALS->yytext_vcd_partial_c_2[len++] = '\\'; - } - - for (GLOBALS->yytext_vcd_partial_c_2[len++] = ch;; - GLOBALS->yytext_vcd_partial_c_2[len++] = ch) { - if (len == GLOBALS->T_MAX_STR_vcd_partial_c_2) { - GLOBALS->yytext_vcd_partial_c_2 = (char *)realloc_2( - GLOBALS->yytext_vcd_partial_c_2, - (GLOBALS->T_MAX_STR_vcd_partial_c_2 = GLOBALS->T_MAX_STR_vcd_partial_c_2 * 2) + 1); - } - - ch = getch(); - if (ch == ' ') { - if (match_kw) - break; - if (getch_peek() == '[') { - ch = getch(); - GLOBALS->varsplit_vcd_partial_c_2 = GLOBALS->yytext_vcd_partial_c_2 + - len; /* keep looping so we get the *last* one */ - continue; - } - } - - if ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r') || (ch < 0)) - break; - if ((ch == '[') && (GLOBALS->yytext_vcd_partial_c_2[0] != '\\')) { - GLOBALS->varsplit_vcd_partial_c_2 = - GLOBALS->yytext_vcd_partial_c_2 + len; /* keep looping so we get the *last* one */ - } else if (((ch == ':') || (ch == ']')) && (!GLOBALS->varsplit_vcd_partial_c_2) && - (GLOBALS->yytext_vcd_partial_c_2[0] != '\\')) { - GLOBALS->var_prevch_vcd_partial_c_2 = ch; - break; - } - } - GLOBALS->yytext_vcd_partial_c_2[len] = 0; /* absolute terminator */ - if ((GLOBALS->varsplit_vcd_partial_c_2) && (GLOBALS->yytext_vcd_partial_c_2[len - 1] == ']')) { - char *vst; - vst = malloc_2(strlen(GLOBALS->varsplit_vcd_partial_c_2) + 1); - strcpy(vst, GLOBALS->varsplit_vcd_partial_c_2); - - *GLOBALS->varsplit_vcd_partial_c_2 = 0x00; /* zero out var name at the left bracket */ - len = GLOBALS->varsplit_vcd_partial_c_2 - GLOBALS->yytext_vcd_partial_c_2; - - GLOBALS->varsplit_vcd_partial_c_2 = GLOBALS->vsplitcurr_vcd_partial_c_2 = vst; - GLOBALS->var_prevch_vcd_partial_c_2 = 0; - } else { - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - } - - if (match_kw) { - int vt = vcd_keyword_code(GLOBALS->yytext_vcd_partial_c_2, len); - if (vt != V_STRING) { - return (vt); - } - } - - GLOBALS->yylen_vcd_partial_c_2 = len; - return (V_STRING); -} - -static int get_strtoken(void) -{ - int ch; - int len = 0; - - if (!GLOBALS->var_prevch_vcd_partial_c_2) { - for (;;) { - ch = getch(); - if (ch < 0) - return (V_END); - if ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r')) - continue; - break; - } - } else { - ch = GLOBALS->var_prevch_vcd_partial_c_2; - GLOBALS->var_prevch_vcd_partial_c_2 = 0; - } - - for (GLOBALS->yytext_vcd_partial_c_2[len++] = ch;; - GLOBALS->yytext_vcd_partial_c_2[len++] = ch) { - if (len == GLOBALS->T_MAX_STR_vcd_partial_c_2) { - GLOBALS->yytext_vcd_partial_c_2 = (char *)realloc_2( - GLOBALS->yytext_vcd_partial_c_2, - (GLOBALS->T_MAX_STR_vcd_partial_c_2 = GLOBALS->T_MAX_STR_vcd_partial_c_2 * 2) + 1); - } - ch = getch(); - if ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r') || (ch < 0)) - break; - } - GLOBALS->yytext_vcd_partial_c_2[len] = 0; /* terminator */ - - GLOBALS->yylen_vcd_partial_c_2 = len; - return (V_STRING); -} - -static void sync_end(const char *hdr) -{ - int tok; - - if (hdr) { - DEBUG(fprintf(stderr, "%s", hdr)); - } - for (;;) { - tok = get_token(); - if ((tok == T_END) || (tok == T_EOF)) - break; - if (hdr) { - DEBUG(fprintf(stderr, " %s", GLOBALS->yytext_vcd_partial_c_2)); - } - } - if (hdr) { - DEBUG(fprintf(stderr, "\n")); - } -} - -static int version_sync_end(const char *hdr) -{ - int tok; - int rc = 0; - - if (hdr) { - DEBUG(fprintf(stderr, "%s", hdr)); - } - for (;;) { - tok = get_token(); - if ((tok == T_END) || (tok == T_EOF)) - break; - if (hdr) { - DEBUG(fprintf(stderr, " %s", GLOBALS->yytext_vcd_partial_c_2)); - } - if (strstr(GLOBALS->yytext_vcd_partial_c_2, - "Icarus")) /* turn off autocoalesce for Icarus */ - { - GLOBALS->autocoalesce = 0; - rc = 1; - } - } - if (hdr) { - DEBUG(fprintf(stderr, "\n")); - } - return (rc); -} - -static void parse_valuechange(void) -{ - struct vcdsymbol *v; - char *vector; - int vlen; - /* hptr hsuf; */ /* scan-build */ - - switch (GLOBALS->yytext_vcd_partial_c_2[0]) { - case '0': - case '1': - case 'x': - case 'X': - case 'z': - case 'Z': - case 'h': - case 'H': - case 'u': - case 'U': - case 'w': - case 'W': - case 'l': - case 'L': - case '-': - if (GLOBALS->yylen_vcd_partial_c_2 > 1) { - v = bsearch_vcd(GLOBALS->yytext_vcd_partial_c_2 + 1, - GLOBALS->yylen_vcd_partial_c_2 - 1); - if (!v) { - fprintf(stderr, - "Near byte %d, Unknown VCD identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2 + 1); - } else { - v->value[0] = GLOBALS->yytext_vcd_partial_c_2[0]; - DEBUG(fprintf(stderr, "%s = '%c'\n", v->name, v->value[0])); - - v->narray[0]->curr = v->app_array[0]; - /* hsuf = */ add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - v->value[0], - 1, - NULL); /* scan-build */ - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - } else { - fprintf(stderr, - "Near byte %d, Malformed VCD identifier\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2))); - } - break; - - case 'b': - case 'B': { - /* extract binary number then.. */ - vector = - malloc_2(GLOBALS->yylen_cache_vcd_partial_c_2 = GLOBALS->yylen_vcd_partial_c_2); - strcpy(vector, GLOBALS->yytext_vcd_partial_c_2 + 1); - vlen = GLOBALS->yylen_vcd_partial_c_2 - 1; - - get_strtoken(); - v = bsearch_vcd(GLOBALS->yytext_vcd_partial_c_2, GLOBALS->yylen_vcd_partial_c_2); - if (!v) { - fprintf(stderr, - "Near byte %d, Unknown identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2); - free_2(vector); - } else { - if ((v->vartype == V_REAL) || (v->vartype == V_STRINGTYPE) || - ((GLOBALS->convert_to_reals) && - ((v->vartype == V_INTEGER) || (v->vartype == V_PARAMETER)))) { - double *d; - char *pnt; - char ch; - GwTime k = 0; - - pnt = vector; - while ((ch = *(pnt++))) { - k = (k << 1) | ((ch == '1') ? 1 : 0); - } - free_2(vector); - - d = malloc_2(sizeof(double)); - *d = (double)k; - - if (!v) { - fprintf( - stderr, - "Near byte %d, Unknown identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2); - free_2(d); - } else { - v->narray[0]->curr = v->app_array[0]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - 'g', - 1, - (char *)d); - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - break; - } - - if (vlen < v->size) /* fill in left part */ - { - char extend; - int i, fill; - - extend = (vector[0] == '1') ? '0' : vector[0]; - - fill = v->size - vlen; - for (i = 0; i < fill; i++) { - v->value[i] = extend; - } - strcpy(v->value + fill, vector); - } else if (vlen == v->size) /* straight copy */ - { - strcpy(v->value, vector); - } else /* too big, so copy only right half */ - { - int skip; - - skip = vlen - v->size; - strcpy(v->value, vector + skip); - } - DEBUG(fprintf(stderr, "%s = '%s'\n", v->name, v->value)); - - if (v->size == 1) { - int i; - for (i = 0; i < v->size; i++) { - v->narray[i]->curr = v->app_array[i]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[i], - v->value[i], - 1, - NULL); - v->app_array[i] = v->narray[i]->curr; - v->narray[i]->curr->next = v->tr_array[i]; - if (v->narray[i]->harray) { - free_2(v->narray[i]->harray); - v->narray[i]->harray = NULL; - } - } - free_2(vector); - } else { - if (GLOBALS->yylen_cache_vcd_partial_c_2 != (v->size + 1)) { - free_2(vector); - vector = malloc_2(v->size + 1); - } - strcpy(vector, v->value); - v->narray[0]->curr = v->app_array[0]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - 0, - 1, - vector); - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - } - break; - } - - case 'p': - /* extract port dump value.. */ - vector = - malloc_2(GLOBALS->yylen_cache_vcd_partial_c_2 = GLOBALS->yylen_vcd_partial_c_2); - strcpy(vector, GLOBALS->yytext_vcd_partial_c_2 + 1); - vlen = GLOBALS->yylen_vcd_partial_c_2 - 1; - - get_strtoken(); /* throw away 0_strength_component */ - get_strtoken(); /* throw away 0_strength_component */ - get_strtoken(); /* this is the id */ - v = bsearch_vcd(GLOBALS->yytext_vcd_partial_c_2, GLOBALS->yylen_vcd_partial_c_2); - if (!v) { - fprintf(stderr, - "Near byte %d, Unknown identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2); - free_2(vector); - } else { - if ((v->vartype == V_REAL) || (v->vartype == V_STRINGTYPE) || - ((GLOBALS->convert_to_reals) && - ((v->vartype == V_INTEGER) || (v->vartype == V_PARAMETER)))) { - double *d; - char *pnt; - char ch; - GwTime k = 0; - - pnt = vector; - while ((ch = *(pnt++))) { - k = (k << 1) | ((ch == '1') ? 1 : 0); - } - free_2(vector); - - d = malloc_2(sizeof(double)); - *d = (double)k; - - if (!v) { - fprintf( - stderr, - "Near byte %d, Unknown identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2); - free_2(d); - } else { - v->narray[0]->curr = v->app_array[0]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - 'g', - 1, - (char *)d); - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - break; - } - - if (vlen < v->size) /* fill in left part */ - { - char extend; - int i, fill; - - extend = '0'; - - fill = v->size - vlen; - for (i = 0; i < fill; i++) { - v->value[i] = extend; - } - evcd_strcpy(v->value + fill, vector); - } else if (vlen == v->size) /* straight copy */ - { - evcd_strcpy(v->value, vector); - } else /* too big, so copy only right half */ - { - int skip; - - skip = vlen - v->size; - evcd_strcpy(v->value, vector + skip); - } - DEBUG(fprintf(stderr, "%s = '%s'\n", v->name, v->value)); - - if (v->size == 1) { - int i; - for (i = 0; i < v->size; i++) { - v->narray[i]->curr = v->app_array[i]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[i], - v->value[i], - 1, - NULL); - v->app_array[i] = v->narray[i]->curr; - v->narray[i]->curr->next = v->tr_array[i]; - if (v->narray[i]->harray) { - free_2(v->narray[i]->harray); - v->narray[i]->harray = NULL; - } - } - free_2(vector); - } else { - if (GLOBALS->yylen_cache_vcd_partial_c_2 < v->size) { - free_2(vector); - vector = malloc_2(v->size + 1); - } - strcpy(vector, v->value); - v->narray[0]->curr = v->app_array[0]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - 0, - 1, - vector); - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - } - break; - - case 'r': - case 'R': { - double *d; - - d = malloc_2(sizeof(double)); - sscanf(GLOBALS->yytext_vcd_partial_c_2 + 1, "%lg", d); - - get_strtoken(); - v = bsearch_vcd(GLOBALS->yytext_vcd_partial_c_2, GLOBALS->yylen_vcd_partial_c_2); - if (!v) { - fprintf(stderr, - "Near byte %d, Unknown identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2); - free_2(d); - } else { - v->narray[0]->curr = v->app_array[0]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - 'g', - 1, - (char *)d); - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - - break; - } - -#ifndef STRICT_VCD_ONLY - case 's': - case 'S': { - char *d; - - d = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2); - vlen = fstUtilityEscToBin((unsigned char *)d, - (unsigned char *)(GLOBALS->yytext_vcd_partial_c_2 + 1), - GLOBALS->yylen_vcd_partial_c_2); /* includes 0 term */ - if (vlen != GLOBALS->yylen_vcd_partial_c_2) { - d = realloc_2(d, vlen); - } - - get_strtoken(); - v = bsearch_vcd(GLOBALS->yytext_vcd_partial_c_2, GLOBALS->yylen_vcd_partial_c_2); - if (!v) { - fprintf(stderr, - "Near byte %d, Unknown identifier: '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2)), - GLOBALS->yytext_vcd_partial_c_2); - free_2(d); - } else { - v->narray[0]->curr = v->app_array[0]; - add_histent_p(GLOBALS->current_time_vcd_partial_c_2, - v->narray[0], - 's', - 1, - (char *)d); - v->app_array[0] = v->narray[0]->curr; - v->narray[0]->curr->next = v->tr_array[0]; - if (v->narray[0]->harray) { - free_2(v->narray[0]->harray); - v->narray[0]->harray = NULL; - } - } - - break; - } -#endif - default: - break; - } -} - -static void evcd_strcpy(char *dst, char *src) -{ - static const char *evcd = "DUNZduLHXTlh01?FAaBbCcf"; - static const char *vcd = "01xz0101xz0101xzxxxxxxz"; - - char ch; - int i; - - while ((ch = *src)) { - for (i = 0; i < 23; i++) { - if (evcd[i] == ch) { - *dst = vcd[i]; - break; - } - } - if (i == 23) - *dst = 'x'; - - src++; - dst++; - } - - *dst = 0; /* null terminate destination */ -} - -static void vcd_parse(void) -{ - int tok; - unsigned char ttype; - int disable_autocoalesce = 0; - - for (;;) { - switch (get_token()) { - case T_COMMENT: - sync_end("COMMENT:"); - break; - case T_DATE: - sync_end("DATE:"); - break; - case T_VERSION: - disable_autocoalesce = version_sync_end("VERSION:"); - break; - case T_TIMEZERO: { - int vtok = get_token(); - if ((vtok == T_END) || (vtok == T_EOF)) - break; - GLOBALS->global_time_offset = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - - DEBUG(fprintf(stderr, - "TIMEZERO: %" GW_TIME_FORMAT "\n", - GLOBALS->global_time_offset)); - sync_end(NULL); - } break; - case T_TIMESCALE: { - int vtok; - int i; - char prefix = ' '; - - vtok = get_token(); - if ((vtok == T_END) || (vtok == T_EOF)) - break; - fractional_timescale_fix(GLOBALS->yytext_vcd_partial_c_2); - GLOBALS->time_scale = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - if (!GLOBALS->time_scale) - GLOBALS->time_scale = 1; - for (i = 0; i < GLOBALS->yylen_vcd_partial_c_2; i++) { - if ((GLOBALS->yytext_vcd_partial_c_2[i] < '0') || - (GLOBALS->yytext_vcd_partial_c_2[i] > '9')) { - prefix = GLOBALS->yytext_vcd_partial_c_2[i]; - break; - } - } - if (prefix == ' ') { - vtok = get_token(); - if ((vtok == T_END) || (vtok == T_EOF)) - break; - prefix = GLOBALS->yytext_vcd_partial_c_2[0]; - } - switch (prefix) { - case ' ': - case 'm': - case 'u': - case 'n': - case 'p': - case 'f': - case 'a': - case 'z': - GLOBALS->time_dimension = prefix; - break; - case 's': - GLOBALS->time_dimension = ' '; - break; - default: /* unknown */ - GLOBALS->time_dimension = 'n'; - break; - } - - DEBUG(fprintf(stderr, - "TIMESCALE: %" GW_TIME_FORMAT " %cs\n", - GLOBALS->time_scale, - GLOBALS->time_dimension)); - sync_end(NULL); - } break; - case T_SCOPE: - T_GET; - { - switch (GLOBALS->yytext_vcd_partial_c_2[0]) { - case 'm': - ttype = GW_TREE_KIND_VCD_ST_MODULE; - break; - case 't': - ttype = GW_TREE_KIND_VCD_ST_TASK; - break; - case 'f': - ttype = (GLOBALS->yytext_vcd_partial_c_2[1] == 'u') - ? GW_TREE_KIND_VCD_ST_FUNCTION - : GW_TREE_KIND_VCD_ST_FORK; - break; - case 'b': - ttype = GW_TREE_KIND_VCD_ST_BEGIN; - break; - case 'g': - ttype = GW_TREE_KIND_VCD_ST_GENERATE; - break; - case 's': - ttype = GW_TREE_KIND_VCD_ST_STRUCT; - break; - case 'u': - ttype = GW_TREE_KIND_VCD_ST_UNION; - break; - case 'c': - ttype = GW_TREE_KIND_VCD_ST_CLASS; - break; - case 'i': - ttype = GW_TREE_KIND_VCD_ST_INTERFACE; - break; - case 'p': - ttype = (GLOBALS->yytext_vcd_partial_c_2[1] == 'r') - ? GW_TREE_KIND_VCD_ST_PROGRAM - : GW_TREE_KIND_VCD_ST_PACKAGE; - break; - - case 'v': { - char *vht = GLOBALS->yytext_vcd_partial_c_2; - if (!strncmp(vht, "vhdl_", 5)) { - switch (vht[5]) { - case 'a': - ttype = GW_TREE_KIND_VHDL_ST_ARCHITECTURE; - break; - case 'r': - ttype = GW_TREE_KIND_VHDL_ST_RECORD; - break; - case 'b': - ttype = GW_TREE_KIND_VHDL_ST_BLOCK; - break; - case 'g': - ttype = GW_TREE_KIND_VHDL_ST_GENERATE; - break; - case 'i': - ttype = GW_TREE_KIND_VHDL_ST_GENIF; - break; - case 'f': - ttype = (vht[6] == 'u') ? GW_TREE_KIND_VHDL_ST_FUNCTION - : GW_TREE_KIND_VHDL_ST_GENFOR; - break; - case 'p': - ttype = (!strncmp(vht + 6, "roces", 5)) - ? GW_TREE_KIND_VHDL_ST_PROCESS - : GW_TREE_KIND_VHDL_ST_PROCEDURE; - break; - default: - ttype = GW_TREE_KIND_UNKNOWN; - break; - } - } else { - ttype = GW_TREE_KIND_UNKNOWN; - } - } break; - - default: - ttype = GW_TREE_KIND_UNKNOWN; - break; - } - } - T_GET; - if (tok != T_END && tok != T_EOF) { - struct slist *s; - s = (struct slist *)calloc_2(1, sizeof(struct slist)); - s->len = GLOBALS->yylen_vcd_partial_c_2; - s->str = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 1); - strcpy(s->str, GLOBALS->yytext_vcd_partial_c_2); - s->mod_tree_parent = GLOBALS->mod_tree_parent; - - allocate_and_decorate_module_tree_node(ttype, - GLOBALS->yytext_vcd_partial_c_2, - NULL, - GLOBALS->yylen_vcd_partial_c_2, - 0, - 0, - 0); - - if (GLOBALS->slistcurr) { - GLOBALS->slistcurr->next = s; - GLOBALS->slistcurr = s; - } else { - GLOBALS->slistcurr = GLOBALS->slistroot = s; - } - - build_slisthier(); - DEBUG(fprintf(stderr, "SCOPE: %s\n", GLOBALS->slisthier)); - } - sync_end(NULL); - break; - case T_UPSCOPE: - if (GLOBALS->slistroot) { - struct slist *s; - - GLOBALS->mod_tree_parent = GLOBALS->slistcurr->mod_tree_parent; - s = GLOBALS->slistroot; - if (!s->next) { - free_2(s->str); - free_2(s); - GLOBALS->slistroot = GLOBALS->slistcurr = NULL; - } else - for (;;) { - if (!s->next->next) { - free_2(s->next->str); - free_2(s->next); - s->next = NULL; - GLOBALS->slistcurr = s; - break; - } - s = s->next; - } - build_slisthier(); - DEBUG(fprintf(stderr, "SCOPE: %s\n", GLOBALS->slisthier)); - } else { - GLOBALS->mod_tree_parent = NULL; - } - sync_end(NULL); - break; - case T_VAR: - if ((GLOBALS->header_over_vcd_partial_c_2) && (0)) { - fprintf( - stderr, - "$VAR encountered after $ENDDEFINITIONS near byte %d. VCD is malformed, " - "exiting.\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - GLOBALS->vcdbuf_vcd_partial_c_2))); - exit(0); - } else { - int vtok; - struct vcdsymbol *v = NULL; - - GLOBALS->var_prevch_vcd_partial_c_2 = 0; - if (GLOBALS->varsplit_vcd_partial_c_2) { - free_2(GLOBALS->varsplit_vcd_partial_c_2); - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - } - vtok = get_vartoken(1); - if (vtok > V_STRINGTYPE) - goto bail; - - v = (struct vcdsymbol *)calloc_2(1, sizeof(struct vcdsymbol)); - v->vartype = vtok; - v->msi = v->lsi = -1; - - if (vtok == V_PORT) { - vtok = get_vartoken(1); - if (vtok == V_STRING) { - v->size = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - if (!v->size) - v->size = 1; - } else if (vtok == V_LB) { - vtok = get_vartoken(1); - if (vtok == V_END) - goto err; - if (vtok != V_STRING) - goto err; - v->msi = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - vtok = get_vartoken(0); - if (vtok == V_RB) { - v->lsi = v->msi; - v->size = 1; - } else { - if (vtok != V_COLON) - goto err; - vtok = get_vartoken(0); - if (vtok != V_STRING) - goto err; - v->lsi = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - vtok = get_vartoken(0); - if (vtok != V_RB) - goto err; - - if (v->msi > v->lsi) { - v->size = v->msi - v->lsi + 1; - } else { - v->size = v->lsi - v->msi + 1; - } - } - } else - goto err; - - vtok = get_strtoken(); - if (vtok == V_END) - goto err; - v->id = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 1); - strcpy(v->id, GLOBALS->yytext_vcd_partial_c_2); - v->nid = vcdid_hash(GLOBALS->yytext_vcd_partial_c_2, - GLOBALS->yylen_vcd_partial_c_2); - - if (v->nid == (GLOBALS->vcd_hash_max_partial + 1)) { - GLOBALS->vcd_hash_max_partial = v->nid; - } else if ((v->nid > 0) && (v->nid <= GLOBALS->vcd_hash_max_partial)) { - /* general case with aliases */ - } else { - GLOBALS->vcd_hash_kill_partial = 1; - } - - if (v->nid < GLOBALS->vcd_minid_vcd_partial_c_2) - GLOBALS->vcd_minid_vcd_partial_c_2 = v->nid; - if (v->nid > GLOBALS->vcd_maxid_vcd_partial_c_2) - GLOBALS->vcd_maxid_vcd_partial_c_2 = v->nid; - - vtok = get_vartoken(0); - if (vtok != V_STRING) - goto err; - if (GLOBALS->slisthier_len) { - v->name = (char *)malloc_2(GLOBALS->slisthier_len + 1 + - GLOBALS->yylen_vcd_partial_c_2 + 1); - strcpy(v->name, GLOBALS->slisthier); - strcpy(v->name + GLOBALS->slisthier_len, GLOBALS->vcd_hier_delimeter); - if (GLOBALS->alt_hier_delimeter) { - strcpy_vcdalt(v->name + GLOBALS->slisthier_len + 1, - GLOBALS->yytext_vcd_partial_c_2, - GLOBALS->alt_hier_delimeter); - } else { - if ((strcpy_delimfix(v->name + GLOBALS->slisthier_len + 1, - GLOBALS->yytext_vcd_partial_c_2)) && - (GLOBALS->yytext_vcd_partial_c_2[0] != '\\')) { - char *sd = (char *)malloc_2(GLOBALS->slisthier_len + 1 + - GLOBALS->yylen_vcd_partial_c_2 + 2); - strcpy(sd, GLOBALS->slisthier); - strcpy(sd + GLOBALS->slisthier_len, - GLOBALS->vcd_hier_delimeter); - sd[GLOBALS->slisthier_len + 1] = '\\'; - strcpy(sd + GLOBALS->slisthier_len + 2, - v->name + GLOBALS->slisthier_len + 1); - free_2(v->name); - v->name = sd; - } - } - } else { - v->name = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 1); - if (GLOBALS->alt_hier_delimeter) { - strcpy_vcdalt(v->name, - GLOBALS->yytext_vcd_partial_c_2, - GLOBALS->alt_hier_delimeter); - } else { - if ((strcpy_delimfix(v->name, GLOBALS->yytext_vcd_partial_c_2)) && - (GLOBALS->yytext_vcd_partial_c_2[0] != '\\')) { - char *sd = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 2); - sd[0] = '\\'; - strcpy(sd + 1, v->name); - free_2(v->name); - v->name = sd; - } - } - } - - if (GLOBALS->pv_vcd_partial_c_2) { - if (!strcmp(GLOBALS->pv_vcd_partial_c_2->name, v->name) && - !disable_autocoalesce && (!strchr(v->name, '\\'))) { - GLOBALS->pv_vcd_partial_c_2->chain = v; - v->root = GLOBALS->rootv_vcd_partial_c_2; - if (GLOBALS->pv_vcd_partial_c_2 == GLOBALS->rootv_vcd_partial_c_2) - GLOBALS->pv_vcd_partial_c_2->root = - GLOBALS->rootv_vcd_partial_c_2; - } else { - GLOBALS->rootv_vcd_partial_c_2 = v; - } - } else { - GLOBALS->rootv_vcd_partial_c_2 = v; - } - GLOBALS->pv_vcd_partial_c_2 = v; - } else /* regular vcd var, not an evcd port var */ - { - vtok = get_vartoken(1); - if (vtok == V_END) - goto err; - v->size = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - vtok = get_strtoken(); - if (vtok == V_END) - goto err; - v->id = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 1); - strcpy(v->id, GLOBALS->yytext_vcd_partial_c_2); - v->nid = vcdid_hash(GLOBALS->yytext_vcd_partial_c_2, - GLOBALS->yylen_vcd_partial_c_2); - - if (v->nid == (GLOBALS->vcd_hash_max_partial + 1)) { - GLOBALS->vcd_hash_max_partial = v->nid; - } else if ((v->nid > 0) && (v->nid <= GLOBALS->vcd_hash_max_partial)) { - /* general case with aliases */ - } else { - GLOBALS->vcd_hash_kill_partial = 1; - } - - if (v->nid < GLOBALS->vcd_minid_vcd_partial_c_2) - GLOBALS->vcd_minid_vcd_partial_c_2 = v->nid; - if (v->nid > GLOBALS->vcd_maxid_vcd_partial_c_2) - GLOBALS->vcd_maxid_vcd_partial_c_2 = v->nid; - - vtok = get_vartoken(0); - if (vtok != V_STRING) - goto err; - if (GLOBALS->slisthier_len) { - v->name = (char *)malloc_2(GLOBALS->slisthier_len + 1 + - GLOBALS->yylen_vcd_partial_c_2 + 1); - strcpy(v->name, GLOBALS->slisthier); - strcpy(v->name + GLOBALS->slisthier_len, GLOBALS->vcd_hier_delimeter); - if (GLOBALS->alt_hier_delimeter) { - strcpy_vcdalt(v->name + GLOBALS->slisthier_len + 1, - GLOBALS->yytext_vcd_partial_c_2, - GLOBALS->alt_hier_delimeter); - } else { - if ((strcpy_delimfix(v->name + GLOBALS->slisthier_len + 1, - GLOBALS->yytext_vcd_partial_c_2)) && - (GLOBALS->yytext_vcd_partial_c_2[0] != '\\')) { - char *sd = (char *)malloc_2(GLOBALS->slisthier_len + 1 + - GLOBALS->yylen_vcd_partial_c_2 + 2); - strcpy(sd, GLOBALS->slisthier); - strcpy(sd + GLOBALS->slisthier_len, - GLOBALS->vcd_hier_delimeter); - sd[GLOBALS->slisthier_len + 1] = '\\'; - strcpy(sd + GLOBALS->slisthier_len + 2, - v->name + GLOBALS->slisthier_len + 1); - free_2(v->name); - v->name = sd; - } - } - } else { - v->name = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 1); - if (GLOBALS->alt_hier_delimeter) { - strcpy_vcdalt(v->name, - GLOBALS->yytext_vcd_partial_c_2, - GLOBALS->alt_hier_delimeter); - } else { - if ((strcpy_delimfix(v->name, GLOBALS->yytext_vcd_partial_c_2)) && - (GLOBALS->yytext_vcd_partial_c_2[0] != '\\')) { - char *sd = (char *)malloc_2(GLOBALS->yylen_vcd_partial_c_2 + 2); - sd[0] = '\\'; - strcpy(sd + 1, v->name); - free_2(v->name); - v->name = sd; - } - } - } - - if (GLOBALS->pv_vcd_partial_c_2) { - if (!strcmp(GLOBALS->pv_vcd_partial_c_2->name, v->name)) { - GLOBALS->pv_vcd_partial_c_2->chain = v; - v->root = GLOBALS->rootv_vcd_partial_c_2; - if (GLOBALS->pv_vcd_partial_c_2 == GLOBALS->rootv_vcd_partial_c_2) - GLOBALS->pv_vcd_partial_c_2->root = - GLOBALS->rootv_vcd_partial_c_2; - } else { - GLOBALS->rootv_vcd_partial_c_2 = v; - } - } else { - GLOBALS->rootv_vcd_partial_c_2 = v; - } - GLOBALS->pv_vcd_partial_c_2 = v; - - vtok = get_vartoken(1); - if (vtok == V_END) - goto dumpv; - if (vtok != V_LB) - goto err; - vtok = get_vartoken(0); - if (vtok != V_STRING) - goto err; - v->msi = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - vtok = get_vartoken(0); - if (vtok == V_RB) { - v->lsi = v->msi; - goto dumpv; - } - if (vtok != V_COLON) - goto err; - vtok = get_vartoken(0); - if (vtok != V_STRING) - goto err; - v->lsi = atoi_64(GLOBALS->yytext_vcd_partial_c_2); - vtok = get_vartoken(0); - if (vtok != V_RB) - goto err; - } - - dumpv: - if (v->size == 0) { - if (v->vartype != V_EVENT) { - if (v->vartype != V_STRINGTYPE) { - v->vartype = V_REAL; - } - } else { - v->size = 1; - } - - } /* MTI fix */ - - if ((v->vartype == V_REAL) || (v->vartype == V_STRINGTYPE) || - ((GLOBALS->convert_to_reals) && - ((v->vartype == V_INTEGER) || (v->vartype == V_PARAMETER)))) { - if (v->vartype != V_STRINGTYPE) { - v->vartype = V_REAL; - } - v->size = 1; /* override any data we parsed in */ - v->msi = v->lsi = 0; - } else if ((v->size > 1) && (v->msi <= 0) && (v->lsi <= 0)) { - if (v->vartype == V_EVENT) { - v->size = 1; - } else { - /* any criteria for the direction here? */ - v->msi = v->size - 1; - v->lsi = 0; - } - } else if ((v->msi > v->lsi) && ((v->msi - v->lsi + 1) != v->size)) { - if ((v->vartype != V_EVENT) && (v->vartype != V_PARAMETER)) { - if ((v->msi - v->lsi + 1) > v->size) /* if() is 2d add */ - { - v->msi = v->size - 1; - v->lsi = 0; - } - /* all this formerly was goto err; */ - } else { - v->size = v->msi - v->lsi + 1; - } - } else if ((v->lsi >= v->msi) && ((v->lsi - v->msi + 1) != v->size)) { - if ((v->vartype != V_EVENT) && (v->vartype != V_PARAMETER)) { - if ((v->lsi - v->msi + 1) > v->size) /* if() is 2d add */ - { - v->lsi = v->size - 1; - v->msi = 0; - } - /* all this formerly was goto err; */ - } else { - v->size = v->lsi - v->msi + 1; - } - } - - /* initial conditions */ - v->value = (char *)malloc_2(v->size + 1); - v->value[v->size] = 0; - v->narray = calloc_2(v->size, sizeof(GwNode *)); - v->tr_array = calloc_2(v->size, sizeof(GwHistEnt *)); - v->app_array = calloc_2(v->size, sizeof(GwHistEnt *)); - { - int i; - for (i = 0; i < v->size; i++) { - v->value[i] = 'x'; - } - v->narray[0] = calloc_2(1, sizeof(GwNode)); - v->narray[0]->head.time = -1; - v->narray[0]->head.v.h_val = AN_X; - } - - if (!GLOBALS->vcdsymroot_vcd_partial_c_2) { - GLOBALS->vcdsymroot_vcd_partial_c_2 = GLOBALS->vcdsymcurr_vcd_partial_c_2 = - v; - } else { - GLOBALS->vcdsymcurr_vcd_partial_c_2->next = v; - GLOBALS->vcdsymcurr_vcd_partial_c_2 = v; - } - GLOBALS->numsyms_vcd_partial_c_2++; - - goto bail; - err: - if (v) { - GLOBALS->error_count_vcd_partial_c_2++; - if (v->name) { - fprintf(stderr, - "Near byte %d, $VAR parse error encountered with '%s'\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - - GLOBALS->vcdbuf_vcd_partial_c_2)), - v->name); - free_2(v->name); - } else { - fprintf(stderr, - "Near byte %d, $VAR parse error encountered\n", - (int)(GLOBALS->vcdbyteno_vcd_partial_c_2 + - (GLOBALS->vst_vcd_partial_c_2 - - GLOBALS->vcdbuf_vcd_partial_c_2))); - } - if (v->id) - free_2(v->id); - if (v->value) - free_2(v->value); - free_2(v); - GLOBALS->pv_vcd_partial_c_2 = NULL; - } - - bail: - if (vtok != V_END) - sync_end(NULL); - break; - } - case T_ENDDEFINITIONS: - GLOBALS->header_over_vcd_partial_c_2 = 1; /* do symbol table management here */ - create_sorted_table(); - if ((!GLOBALS->sorted_vcd_partial_c_2) && (!GLOBALS->indexed_vcd_partial_c_2)) { - fprintf(stderr, "No symbols in VCD file..nothing to do!\n"); - exit(1); - } - if (GLOBALS->error_count_vcd_partial_c_2) { - fprintf(stderr, - "\n%d VCD parse errors encountered, exiting.\n", - GLOBALS->error_count_vcd_partial_c_2); - exit(1); - } - return; - break; - case T_STRING: - if (!GLOBALS->header_over_vcd_partial_c_2) { - GLOBALS->header_over_vcd_partial_c_2 = 1; /* do symbol table management here */ - create_sorted_table(); - if ((!GLOBALS->sorted_vcd_partial_c_2) && (!GLOBALS->indexed_vcd_partial_c_2)) - break; - } - { - /* catchall for events when header over */ - if (GLOBALS->yytext_vcd_partial_c_2[0] == '#') { - GwTime tim; - tim = atoi_64(GLOBALS->yytext_vcd_partial_c_2 + 1); - - if (GLOBALS->start_time_vcd_partial_c_2 < 0) { - GLOBALS->start_time_vcd_partial_c_2 = tim; - } - - GLOBALS->current_time_vcd_partial_c_2 = tim; - if (GLOBALS->end_time_vcd_partial_c_2 < tim) - GLOBALS->end_time_vcd_partial_c_2 = - tim; /* in case of malformed vcd files */ - DEBUG(fprintf(stderr, "#%" GW_TIME_FORMAT "\n", tim)); - } else { - parse_valuechange(); - } - } - break; - case T_DUMPALL: /* dump commands modify vals anyway so */ - case T_DUMPPORTSALL: - break; /* just loop through.. */ - case T_DUMPOFF: - case T_DUMPPORTSOFF: - gw_blackout_regions_add_dumpoff(GLOBALS->blackout_regions, - GLOBALS->current_time_vcd_partial_c_2 * - GLOBALS->time_scale); - break; - case T_DUMPON: - case T_DUMPPORTSON: - gw_blackout_regions_add_dumpon(GLOBALS->blackout_regions, - GLOBALS->current_time_vcd_partial_c_2 * - GLOBALS->time_scale); - break; - case T_DUMPVARS: - case T_DUMPPORTS: - if (GLOBALS->current_time_vcd_partial_c_2 < 0) { - GLOBALS->start_time_vcd_partial_c_2 = GLOBALS->current_time_vcd_partial_c_2 = - GLOBALS->end_time_vcd_partial_c_2 = 0; - } - break; - case T_VCDCLOSE: - sync_end("VCDCLOSE:"); - break; /* next token will be '#' time related followed by $end */ - case T_END: /* either closure for dump commands or */ - break; /* it's spurious */ - case T_UNKNOWN_KEY: - sync_end(NULL); /* skip over unknown keywords */ - break; - case T_EOF: - gw_blackout_regions_add_dumpon(GLOBALS->blackout_regions, - GLOBALS->current_time_vcd_partial_c_2 * - GLOBALS->time_scale); - return; - default: - DEBUG(fprintf(stderr, "UNKNOWN TOKEN\n")); - } - } -} - -/*******************************************************************************/ - -GwHistEnt *add_histent_p(GwTime tim, GwNode *n, char ch, int regadd, char *vector) -{ - GwHistEnt *he; - GwHistEnt *rc; - char heval; - - if (!vector) { - if (!(rc = n->curr)) { - he = histent_calloc(); - he->time = -1; - he->v.h_val = AN_X; - - n->curr = he; - n->head.next = he; - - add_histent_p(tim, n, ch, regadd, vector); - rc = he; - } else { - if (regadd) { - tim *= (GLOBALS->time_scale); - } - - if (ch == '0') - heval = AN_0; - else if (ch == '1') - heval = AN_1; - else if ((ch == 'x') || (ch == 'X')) - heval = AN_X; - else if ((ch == 'z') || (ch == 'Z')) - heval = AN_Z; - else if ((ch == 'h') || (ch == 'H')) - heval = AN_H; - else if ((ch == 'u') || (ch == 'U')) - heval = AN_U; - else if ((ch == 'w') || (ch == 'W')) - heval = AN_W; - else if ((ch == 'l') || (ch == 'L')) - heval = AN_L; - else - /* if(ch=='-') */ heval = AN_DASH; /* default */ - - if ((n->curr->v.h_val != heval) || (tim == GLOBALS->start_time_vcd_partial_c_2) || - (n->vartype == GW_VAR_TYPE_VCD_EVENT) || - (GLOBALS->vcd_preserve_glitches)) /* same region == go skip */ - { - if (n->curr->time == tim) { - DEBUG(printf("Warning: Glitch at time [%" GW_TIME_FORMAT - "] Signal [%p], Value [%c->%c].\n", - tim, - n, - AN_STR[n->curr->v.h_val], - ch)); - n->curr->v.h_val = heval; /* we have a glitch! */ - - GLOBALS->num_glitches_vcd_partial_c_3++; - if (!(n->curr->flags & GW_HIST_ENT_FLAG_GLITCH)) { - n->curr->flags |= GW_HIST_ENT_FLAG_GLITCH; /* set the glitch flag */ - GLOBALS->num_glitch_regions_vcd_partial_c_3++; - } - } else { - he = histent_calloc(); - he->time = tim; - he->v.h_val = heval; - - n->curr->next = he; - if (n->curr->v.h_val == heval) { - n->curr->flags |= GW_HIST_ENT_FLAG_GLITCH; /* set the glitch flag */ - GLOBALS->num_glitch_regions_vcd_partial_c_3++; - } - n->curr = he; - GLOBALS->regions += regadd; - } - } - } - } else { - switch (ch) { - case 's': /* string */ - { - if (!(rc = n->curr)) { - he = histent_calloc(); - he->flags = (GW_HIST_ENT_FLAG_STRING | GW_HIST_ENT_FLAG_REAL); - he->time = -1; - he->v.h_vector = NULL; - - n->curr = he; - n->head.next = he; - - add_histent_p(tim, n, ch, regadd, vector); - rc = he; - } else { - if (regadd) { - tim *= (GLOBALS->time_scale); - } - - if (n->curr->time == tim) { - DEBUG(printf("Warning: String Glitch at time [%" GW_TIME_FORMAT - "] Signal [%p].\n", - tim, - n)); - if (n->curr->v.h_vector) - free_2(n->curr->v.h_vector); - n->curr->v.h_vector = vector; /* we have a glitch! */ - - GLOBALS->num_glitches_vcd_partial_c_3++; - if (!(n->curr->flags & GW_HIST_ENT_FLAG_GLITCH)) { - n->curr->flags |= GW_HIST_ENT_FLAG_GLITCH; /* set the glitch flag */ - GLOBALS->num_glitch_regions_vcd_partial_c_3++; - } - } else { - he = histent_calloc(); - he->flags = (GW_HIST_ENT_FLAG_STRING | GW_HIST_ENT_FLAG_REAL); - he->time = tim; - he->v.h_vector = vector; - - n->curr->next = he; - n->curr = he; - GLOBALS->regions += regadd; - } - } - break; - } - case 'g': /* real number */ - { - if (!(rc = n->curr)) { - he = histent_calloc(); - he->flags = GW_HIST_ENT_FLAG_REAL; - he->time = -1; - he->v.h_double = strtod("NaN", NULL); - n->curr = he; - n->head.next = he; - - add_histent_p(tim, n, ch, regadd, vector); - rc = he; - } else { - if (regadd) { - tim *= (GLOBALS->time_scale); - } - - if ((vector && (n->curr->v.h_double != *(double *)vector)) || - (tim == GLOBALS->start_time_vcd_partial_c_2) || - (GLOBALS->vcd_preserve_glitches) || - (GLOBALS->vcd_preserve_glitches_real)) /* same region == go skip */ - { - if (n->curr->time == tim) { - DEBUG(printf("Warning: Real number Glitch at time [%" GW_TIME_FORMAT - "] Signal [%p].\n", - tim, - n)); - n->curr->v.h_double = *((double *)vector); - GLOBALS->num_glitches_vcd_partial_c_3++; - if (!(n->curr->flags & GW_HIST_ENT_FLAG_GLITCH)) { - n->curr->flags |= GW_HIST_ENT_FLAG_GLITCH; /* set the glitch flag */ - GLOBALS->num_glitch_regions_vcd_partial_c_3++; - } - } else { - he = histent_calloc(); - he->flags = GW_HIST_ENT_FLAG_REAL; - he->time = tim; - he->v.h_double = *((double *)vector); - n->curr->next = he; - n->curr = he; - GLOBALS->regions += regadd; - } - } else { - } - free_2(vector); - } - break; - } - default: { - if (!(rc = n->curr)) { - he = histent_calloc(); - he->time = -1; - he->v.h_vector = NULL; - - n->curr = he; - n->head.next = he; - - add_histent_p(tim, n, ch, regadd, vector); - rc = he; - } else { - if (regadd) { - tim *= (GLOBALS->time_scale); - } - - if ((n->curr->v.h_vector && vector && (strcmp(n->curr->v.h_vector, vector))) || - (tim == GLOBALS->start_time_vcd_partial_c_2) || (!n->curr->v.h_vector) || - (GLOBALS->vcd_preserve_glitches)) /* same region == go skip */ - { - if (n->curr->time == tim) { - DEBUG(printf("Warning: Glitch at time [%" GW_TIME_FORMAT - "] Signal [%p], Value [%c->%c].\n", - tim, - n, - AN_STR[n->curr->v.h_val], - ch)); - if (n->curr->v.h_vector) - free_2(n->curr->v.h_vector); - n->curr->v.h_vector = vector; /* we have a glitch! */ - - GLOBALS->num_glitches_vcd_partial_c_3++; - if (!(n->curr->flags & GW_HIST_ENT_FLAG_GLITCH)) { - n->curr->flags |= GW_HIST_ENT_FLAG_GLITCH; /* set the glitch flag */ - GLOBALS->num_glitch_regions_vcd_partial_c_3++; - } - } else { - he = histent_calloc(); - he->time = tim; - he->v.h_vector = vector; - - n->curr->next = he; - n->curr = he; - GLOBALS->regions += regadd; - } - } else { - free_2(vector); - } - } - break; - } - } - } - - return (rc); -} - -static void add_tail_histents(void) -{ - int j; - struct vcdsymbol *v; - GwHistEnt *rc; - - /* do 'x' trailers */ - - v = GLOBALS->vcdsymroot_vcd_partial_c_2; - while (v) { - if ((v->vartype == V_REAL) || (v->vartype == V_STRINGTYPE)) { - double *d; - - d = malloc_2(sizeof(double)); - *d = 1.0; - rc = add_histent_p(MAX_HISTENT_TIME - 1, v->narray[0], 'g', 0, (char *)d); - set_vcd_vartype(v, v->narray[0]); - v->app_array[0] = rc; - v->tr_array[0] = v->narray[0]->curr; - } else if (v->size == 1) - for (j = 0; j < v->size; j++) { - rc = add_histent_p(MAX_HISTENT_TIME - 1, v->narray[j], 'x', 0, NULL); - set_vcd_vartype(v, v->narray[j]); - v->app_array[j] = rc; - v->tr_array[j] = v->narray[j]->curr; - } - else { - rc = add_histent_p(MAX_HISTENT_TIME - 1, - v->narray[0], - 'x', - 0, - (char *)calloc_2(1, sizeof(char))); - set_vcd_vartype(v, v->narray[0]); - v->app_array[0] = rc; - v->tr_array[0] = v->narray[0]->curr; - } - - v = v->next; - } - - v = GLOBALS->vcdsymroot_vcd_partial_c_2; - while (v) { - if ((v->vartype == V_REAL) || (v->vartype == V_STRINGTYPE)) { - double *d; - - d = malloc_2(sizeof(double)); - *d = 0.0; - add_histent_p(MAX_HISTENT_TIME, v->narray[0], 'g', 0, (char *)d); - } else if (v->size == 1) - for (j = 0; j < v->size; j++) { - add_histent_p(MAX_HISTENT_TIME, v->narray[j], 'z', 0, NULL); - } - else { - add_histent_p(MAX_HISTENT_TIME, - v->narray[0], - 'z', - 0, - (char *)calloc_2(1, sizeof(char))); - } - - v = v->next; - } -} - -/*******************************************************************************/ - -static void vcd_build_symbols(void) -{ - int j; - int max_slen = -1; - GSList *sym_chain = NULL; - int duphier = 0; - char hashdirty; - struct vcdsymbol *v, *vprime; - char *str = g_alloca(1); /* quiet scan-build null pointer warning below */ -#ifdef _WAVE_HAVE_JUDY - int ss_len, longest = 0; -#endif - - v = GLOBALS->vcdsymroot_vcd_partial_c_2; - while (v) { - int msi; - int delta; - - { - int slen; - int substnode; - - msi = v->msi; - delta = ((v->lsi - v->msi) < 0) ? -1 : 1; - substnode = 0; - - slen = strlen(v->name); - str = (slen > max_slen) ? (g_alloca((max_slen = slen) + 32)) - : (str); /* more than enough */ - strcpy(str, v->name); - - if ((v->msi >= 0) || (v->msi != v->lsi)) { - strcpy(str + slen, GLOBALS->vcd_hier_delimeter); - slen++; - } - - if ((vprime = bsearch_vcd(v->id, strlen(v->id))) != v) /* hash mish means dup net */ - { - if (v->size != vprime->size) { - fprintf(stderr, - "ERROR: Duplicate IDs with differing width: %s %s\n", - v->name, - vprime->name); - } else { - substnode = 1; - } - } - - if (((v->size == 1)) && (v->vartype != V_REAL) && (v->vartype != V_STRINGTYPE)) { - struct symbol *s = NULL; - - for (j = 0; j < v->size; j++) { - if (v->msi >= 0) { - sprintf(str + slen - 1, "[%d]", msi); - } - - hashdirty = 0; - if (symfind(str, NULL)) { - char *dupfix = (char *)malloc_2(max_slen + 32); -#ifndef _WAVE_HAVE_JUDY - hashdirty = 1; -#endif - DEBUG(fprintf(stderr, "Warning: %s is a duplicate net name.\n", str)); - - do - sprintf(dupfix, - "$DUP%d%s%s", - duphier++, - GLOBALS->vcd_hier_delimeter, - str); - while (symfind(dupfix, NULL)); - - strcpy(str, dupfix); - free_2(dupfix); - duphier = 0; /* reset for next duplicate resolution */ - } - /* fallthrough */ - { - s = symadd(str, hashdirty ? hash(str) : GLOBALS->hashcache); -#ifdef _WAVE_HAVE_JUDY - ss_len = strlen(str); - if (ss_len >= longest) { - longest = ss_len + 1; - } -#endif - s->n = v->narray[j]; - if (substnode) { - GwNode *n; - GwNode *n2; - - n = s->n; - n2 = vprime->narray[j]; - /* nname stays same */ - n->head = n2->head; - n->curr = n2->curr; - /* harray calculated later */ - n->numhist = n2->numhist; - } - -#ifndef _WAVE_HAVE_JUDY - s->n->nname = s->name; -#endif - GLOBALS->sym_chain_partial = g_slist_prepend(GLOBALS->sym_chain_partial, s); - - GLOBALS->numfacs++; - DEBUG(fprintf(stderr, "Added: %s\n", str)); - } - msi += delta; - } - - if ((j == 1) && (v->root)) { - s->vec_root = (struct symbol *)v->root; /* these will get patched over */ - s->vec_chain = (struct symbol *)v->chain; /* these will get patched over */ - v->sym_chain = s; - - sym_chain = g_slist_prepend(sym_chain, s); - } - } else /* atomic vector */ - { - if ((v->vartype != V_REAL) && (v->vartype != V_STRINGTYPE) && - (v->vartype != V_INTEGER) && (v->vartype != V_PARAMETER)) - /* if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)) */ - { - sprintf(str + slen - 1, "[%d:%d]", v->msi, v->lsi); - /* 2d add */ - if ((v->msi > v->lsi) && ((v->msi - v->lsi + 1) != v->size)) { - if ((v->vartype != V_EVENT) && (v->vartype != V_PARAMETER)) { - v->msi = v->size - 1; - v->lsi = 0; - } - } else if ((v->lsi >= v->msi) && ((v->lsi - v->msi + 1) != v->size)) { - if ((v->vartype != V_EVENT) && (v->vartype != V_PARAMETER)) { - v->lsi = v->size - 1; - v->msi = 0; - } - } - } else { - *(str + slen - 1) = 0; - } - - hashdirty = 0; - if (symfind(str, NULL)) { - char *dupfix = (char *)malloc_2(max_slen + 32); -#ifndef _WAVE_HAVE_JUDY - hashdirty = 1; -#endif - DEBUG(fprintf(stderr, "Warning: %s is a duplicate net name.\n", str)); - - do - sprintf(dupfix, "$DUP%d%s%s", duphier++, GLOBALS->vcd_hier_delimeter, str); - while (symfind(dupfix, NULL)); - - strcpy(str, dupfix); - free_2(dupfix); - duphier = 0; /* reset for next duplicate resolution */ - } - /* fallthrough */ - { - struct symbol *s; - - s = symadd(str, - hashdirty ? hash(str) - : GLOBALS->hashcache); /* cut down on double lookups.. */ -#ifdef _WAVE_HAVE_JUDY - ss_len = strlen(str); - if (ss_len >= longest) { - longest = ss_len + 1; - } -#endif - s->n = v->narray[0]; - if (substnode) { - GwNode *n; - GwNode *n2; - - n = s->n; - n2 = vprime->narray[0]; - /* nname stays same */ - n->head = n2->head; - n->curr = n2->curr; - /* harray calculated later */ - n->numhist = n2->numhist; - n->extvals = n2->extvals; - n->msi = n2->msi; - n->lsi = n2->lsi; - } else { - s->n->msi = v->msi; - s->n->lsi = v->lsi; - - s->n->extvals = 1; - } - -#ifndef _WAVE_HAVE_JUDY - s->n->nname = s->name; -#endif - GLOBALS->sym_chain_partial = g_slist_prepend(GLOBALS->sym_chain_partial, s); - - GLOBALS->numfacs++; - DEBUG(fprintf(stderr, "Added: %s\n", str)); - } - } - } - - v = v->next; - } - -#ifdef _WAVE_HAVE_JUDY - { - Pvoid_t PJArray = GLOBALS->sym_judy; - PPvoid_t PPValue; - char *Index = calloc_2(1, longest); - - for (PPValue = JudySLFirst(PJArray, (uint8_t *)Index, PJE0); PPValue != (PPvoid_t)NULL; - PPValue = JudySLNext(PJArray, (uint8_t *)Index, PJE0)) { - struct symbol *s = *(struct symbol **)PPValue; - s->name = strdup_2(Index); - s->n->nname = s->name; - } - - free_2(Index); - } -#endif - - if (sym_chain != NULL) { - for (GSList *iter = sym_chain; iter != NULL; iter = iter->next) { - struct symbol *s = iter->data; - - s->vec_root = ((struct vcdsymbol *)s->vec_root)->sym_chain; - if ((struct vcdsymbol *)s->vec_chain != NULL) { - s->vec_chain = ((struct vcdsymbol *)s->vec_chain)->sym_chain; - } - - DEBUG(printf("Link: ('%s') '%s' -> '%s'\n", - sym_curr->val->vec_root->name, - sym_curr->val->name, - sym_curr->val->vec_chain ? sym_curr->val->vec_chain->name : "(END)")); - } - - g_slist_free(sym_chain); - } -} - -/*******************************************************************************/ - -static void vcd_cleanup(void) -{ - struct slist *s, *s2; - - if (GLOBALS->slisthier) { - free_2(GLOBALS->slisthier); - GLOBALS->slisthier = NULL; - } - s = GLOBALS->slistroot; - while (s) { - s2 = s->next; - if (s->str) - free_2(s->str); - free_2(s); - s = s2; - } - - GLOBALS->slistroot = GLOBALS->slistcurr = NULL; - GLOBALS->slisthier_len = 0; -} - -/*******************************************************************************/ - -GwTime vcd_partial_main(char *fname) -{ - unsigned int shmidu = ~(0L); - int shmid; - - GLOBALS->pv_vcd_partial_c_2 = GLOBALS->rootv_vcd_partial_c_2 = NULL; - GLOBALS->vcd_hier_delimeter[0] = GLOBALS->hier_delimeter; - - errno = 0; /* reset in case it's set for some reason */ - - GLOBALS->yytext_vcd_partial_c_2 = (char *)malloc_2(GLOBALS->T_MAX_STR_vcd_partial_c_2 + 1); - - if (!GLOBALS->hier_was_explicitly_set) /* set default hierarchy split char */ - { - GLOBALS->hier_delimeter = '.'; - } - -#ifdef __MINGW32__ - if (GetEnvironmentVariable("SHMID", NULL, 0)) { - char sEnv[128]; - GetEnvironmentVariable("SHMID", sEnv, 128); - sscanf(sEnv, "%x", &shmidu); - } else -#endif - { - if (!strcmp(fname, "-vcd")) { - if (!fscanf(stdin, "%x", &shmidu)) - shmidu = ~(0L); /* allow use of -v flag to pass straight from stdin */ - } else { - sscanf(fname, "%x", &shmidu); /* passed as a filename */ - } - } - - shmid = (int)shmidu; - -#ifdef __MINGW32__ - { - HANDLE hMapFile; - char mapName[257]; - - sprintf(mapName, "shmidcat%d", shmid); - hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, mapName); - if (hMapFile == NULL) { - fprintf(stderr, "Could not attach shared memory map name '%s', exiting.\n", mapName); - exit(255); - } - GLOBALS->consume_ptr_vcd_partial_c_1 = GLOBALS->buf_vcd_partial_c_2 = - MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, WAVE_PARTIAL_VCD_RING_BUFFER_SIZE); - if (GLOBALS->consume_ptr_vcd_partial_c_1 == NULL) { - fprintf(stderr, "Could not map view of file '%s', exiting.\n", mapName); - exit(255); - } - } -#else - errno = 0; - GLOBALS->consume_ptr_vcd_partial_c_1 = GLOBALS->buf_vcd_partial_c_2 = shmat(shmid, NULL, 0); - if (errno) { - fprintf(stderr, "Could not attach shared memory ID %08x\n", shmid); - perror("Why"); - exit(255); - } -#endif - - sym_hash_initialize(GLOBALS); - getch_alloc(); /* alloc membuff for vcd getch buffer */ - build_slisthier(); - GLOBALS->blackout_regions = gw_blackout_regions_new(); - - GLOBALS->vcd_preserve_glitches = 1; /* splicing dictates that we override */ - while (!GLOBALS->header_over_vcd_partial_c_2) { - vcd_parse(); - } - - if (GLOBALS->varsplit_vcd_partial_c_2) { - free_2(GLOBALS->varsplit_vcd_partial_c_2); - GLOBALS->varsplit_vcd_partial_c_2 = NULL; - } - - if ((!GLOBALS->sorted_vcd_partial_c_2) && (!GLOBALS->indexed_vcd_partial_c_2)) { - fprintf(stderr, "No symbols in VCD file..is it malformed? Exiting!\n"); - exit(1); - } - - add_tail_histents(); - vcd_build_symbols(); - vcd_sortfacs(GLOBALS->sym_chain_partial); - vcd_cleanup(); - - GLOBALS->min_time = GLOBALS->start_time_vcd_partial_c_2 * GLOBALS->time_scale; - GLOBALS->max_time = GLOBALS->end_time_vcd_partial_c_2 * GLOBALS->time_scale; - GLOBALS->global_time_offset = GLOBALS->global_time_offset * GLOBALS->time_scale; - - if ((GLOBALS->min_time == GLOBALS->max_time) || (GLOBALS->max_time == 0)) { - GLOBALS->min_time = GLOBALS->max_time = 0; - } - - GLOBALS->is_vcd = ~0; - GLOBALS->partial_vcd = ~0; - -#ifdef __linux__ - { - struct shmid_ds ds; - shmctl(shmid, IPC_RMID, &ds); /* mark for destroy */ - } -#endif - - return (GLOBALS->max_time); -} - -/*******************************************************************************/ - -static void regen_harray(GwTrace *t, GwNode *nd) -{ - int i, histcount; - GwHistEnt *histpnt; - GwHistEnt **harray; - - 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 = malloc_2(histcount * sizeof(GwHistEnt *)))) { - fprintf(stderr, "Out of memory, can't add %s to analyzer\n", nd->nname); - free_2(t); - return; /* scan-build : really can't do anything here */ - } - - 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; - } - } -} - -/* mark vectors that need to be regenerated */ -static void regen_trace_mark(GwTrace *t, int mandclear) -{ - if (t->vector) { - GwBitVector *b = t->n.vec; - GwBits *bts = b->bits; - int i; - - if (1) { - for (i = 0; i < bts->nnbits; i++) { - if (!bts->nodes[i]->expansion) { - if (bts->nodes[i]->harray) { - free_2(bts->nodes[i]->harray); - bts->nodes[i]->harray = NULL; - } - } else { - t->interactive_vector_needs_regeneration = 1; - } - } - } - - for (i = 0; i < bts->nnbits; i++) { - if (!bts->nodes[i]->harray) { - t->interactive_vector_needs_regeneration = 1; - return; - } - } - } else { - if (t->n.nd) /* comment and blank traces don't have a valid node */ - if ((t->n.nd->harray) && (mandclear)) { - free_2(t->n.nd->harray); - t->n.nd->harray = NULL; - } - } -} - -/* sweep through and regen nodes/dirty vectors */ -static void regen_trace_sweep(GwTrace *t) -{ - if (!t->vector) { - if (t->n.nd) /* comment and blank traces don't have a valid node */ - if (!t->n.nd->harray) { - regen_harray(t, t->n.nd); - } - } else if (t->interactive_vector_needs_regeneration) { - GwBitVector *b = t->n.vec; - GwBits *bts = b->bits; - int i; - GwBitVector *b2; - - for (i = 0; i < bts->nnbits; i++) { - if (bts->nodes[i]->expansion) { - GwNode *parent = bts->nodes[i]->expansion->parent; - int parentbit = bts->nodes[i]->expansion->parentbit; - - DeleteNode(bts->nodes[i]); - - bts->nodes[i] = ExtractNodeSingleBit(parent, parentbit); - } - - if (!bts->nodes[i]->harray) { - regen_harray(t, bts->nodes[i]); - } - } - - if (!bts->name) { - bts->name = (char *)""; - b2 = bits2vector(bts); - bts->name = NULL; - } else { - b2 = bits2vector(bts); - } - - t->n.vec = b2; - b2->bits = bts; - - free_2(b2->bvname); - b2->bvname = b->bvname; - - for (i = 0; i < b->numregions; i++) { - free_2(b->vectors[i]); - } - - free_2(b); - } -} - -/*******************************************************************************/ - -void kick_partial_vcd(void) -{ - if (GLOBALS->partial_vcd) { -#ifdef __MINGW32__ - Sleep(10); -#else - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 1000000 / 100; - select(0, NULL, NULL, NULL, &tv); -#endif - - GwMarker *primary_marker = gw_project_get_primary_marker(GLOBALS->project); - - while (*GLOBALS->consume_ptr_vcd_partial_c_1) { - int old_maxtime_marker_conflict = - (gw_marker_get_position(primary_marker) > GLOBALS->max_time); - - vcd_parse(); - - GLOBALS->min_time = GLOBALS->start_time_vcd_partial_c_2 * GLOBALS->time_scale; - GLOBALS->max_time = GLOBALS->end_time_vcd_partial_c_2 * GLOBALS->time_scale; - - GLOBALS->tims.last = GLOBALS->max_time; - GLOBALS->tims.end = GLOBALS->tims.last; /* until the configure_event of wavearea */ - - if (!GLOBALS->timeset_vcd_partial_c_1) { - GLOBALS->tims.first = GLOBALS->tims.start = GLOBALS->tims.laststart = - GLOBALS->min_time; - GLOBALS->timeset_vcd_partial_c_1 = 1; - } - - update_endcap_times_for_partial_vcd(); - update_time_box(); - - if (old_maxtime_marker_conflict) { - old_maxtime_marker_conflict = - (gw_marker_get_position(primary_marker) <= - GLOBALS->max_time); /* data is now past what was invisible marker */ - } - - vcd_partial_mark_and_sweep(1); - - if ((GLOBALS->zoom_dyn)) { - gw_marker_set_position(primary_marker, GLOBALS->tims.last); - service_zoom_full(NULL, NULL); - - GLOBALS->signalwindow_width_dirty = 1; - MaxSignalLength(); - gw_signal_list_force_redraw(GW_SIGNAL_LIST(GLOBALS->signalarea)); - } else if ((GLOBALS->zoom_dyne)) { - gw_marker_set_position(primary_marker, GLOBALS->tims.last); - service_zoom_right(NULL, NULL); - - GLOBALS->signalwindow_width_dirty = 1; - MaxSignalLength(); - gw_signal_list_force_redraw(GW_SIGNAL_LIST(GLOBALS->signalarea)); - } else if ((old_maxtime_marker_conflict)) { - GLOBALS->signalwindow_width_dirty = 1; - redraw_signals_and_waves(); - } else { - gw_signal_list_force_redraw(GW_SIGNAL_LIST(GLOBALS->signalarea)); - gw_wave_view_force_redraw(GW_WAVE_VIEW(GLOBALS->wavearea)); - } - - update_time_box(); - - gtkwave_main_iteration(); - } - } - - gtkwave_main_iteration(); -} - -static void vcd_partial_regen_node_expansion(GwTrace *t) -{ - if (!t->vector) { - if (t->n.nd && t->n.nd->expansion) { - GwNode *np_ex = - ExtractNodeSingleBit(t->n.nd->expansion->parent, t->n.nd->expansion->parentbit); - - DeleteNode(t->n.nd); - t->n.nd = np_ex; - t->name_full = np_ex->nname; - t->name = (GLOBALS->hier_max_level) - ? hier_extract(t->name_full, GLOBALS->hier_max_level) - : t->name_full; - } - } -} - -void vcd_partial_mark_and_sweep(int mandclear) -{ - GwTrace *t; - - /* node */ - t = GLOBALS->traces.first; - while (t) { - if (!t->vector) - regen_trace_mark(t, mandclear); - t = t->t_next; - } - t = GLOBALS->traces.buffer; - while (t) { - if (!t->vector) - regen_trace_mark(t, mandclear); - t = t->t_next; - } - - t = GLOBALS->traces.first; - while (t) { - if (!t->vector) - regen_trace_sweep(t); - t = t->t_next; - } - t = GLOBALS->traces.buffer; - while (t) { - if (!t->vector) - regen_trace_sweep(t); - t = t->t_next; - } - - /* node that is single bit extracted */ - t = GLOBALS->traces.first; - while (t) { - vcd_partial_regen_node_expansion(t); - t = t->t_next; - } - t = GLOBALS->traces.buffer; - while (t) { - vcd_partial_regen_node_expansion(t); - t = t->t_next; - } - - /* vector */ - t = GLOBALS->traces.first; - while (t) { - if (t->vector) - regen_trace_mark(t, mandclear); - t = t->t_next; - } - t = GLOBALS->traces.buffer; - while (t) { - if (t->vector) - regen_trace_mark(t, mandclear); - t = t->t_next; - } - - t = GLOBALS->traces.first; - while (t) { - if (t->vector) - regen_trace_sweep(t); - t = t->t_next; - } - t = GLOBALS->traces.buffer; - while (t) { - if (t->vector) - regen_trace_sweep(t); - t = t->t_next; - } - - /* floating point */ - t = GLOBALS->traces.first; - while (t) { - if (t->minmax_valid) - t->minmax_valid = 0; - t = t->t_next; - } - t = GLOBALS->traces.buffer; - while (t) { - if (t->minmax_valid) - t->minmax_valid = 0; - t = t->t_next; - } -} diff --git a/src/vcd_partial.h b/src/vcd_partial.h deleted file mode 100644 index 0baf9d01..00000000 --- a/src/vcd_partial.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Tony Bybell 2010 - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - */ - -#ifndef WAVE_VCD_PARTIAL_H -#define WAVE_VCD_PARTIAL_H - -void update_endcap_times_for_partial_vcd(void); - -#endif