Codebase list gtkwave / 2f3904af-9288-4fce-948b-4cc0d242709b/upstream
Import upstream version 3.3.111 Debian Janitor 2 years ago
60 changed file(s) with 4083 addition(s) and 3556 deletion(s). Raw diff Collapse all Expand all
0 GTKWave Wave Viewer is Copyright (C) 1999-2020 Tony Bybell.
1 Windows compatibility and PS/MIF routines are Copyright (C) 1999-2020 Udi Finkelstein.
2 Context support is Copyright (C) 2007-2020 Kermin Elliott Fleming.
3 Trace group support is Copyright (C) 2009-2020 Donald Baltus.
4 GHW and additional GUI support is Copyright (C) 2005-2020 Tristan Gingold.
5 Analog support is Copyright (C) 2005-2020 Thomas Sailer.
6 External DnD support is Copyright (C) 2008-2020 Concept Engineering GmbH.
7 FastLZ is Copyright (C) 2005-2020 Ariya Hidayat.
0 GTKWave Wave Viewer is Copyright (C) 1999-2021 Tony Bybell.
1 Windows compatibility and PS/MIF routines are Copyright (C) 1999-2021 Udi Finkelstein.
2 Context support is Copyright (C) 2007-2021 Kermin Elliott Fleming.
3 Trace group support is Copyright (C) 2009-2021 Donald Baltus.
4 GHW and additional GUI support is Copyright (C) 2005-2021 Tristan Gingold.
5 Analog support is Copyright (C) 2005-2021 Thomas Sailer.
6 External DnD support is Copyright (C) 2008-2021 Concept Engineering GmbH.
7 FastLZ is Copyright (C) 2005-2021 Ariya Hidayat.
88 Some public domain clip art by contributors at http://www.sxc.hu/ website.
99 Hierarchy marker icons from the Silk icons set by Mark James found at the http://www.famfamfam.com/lab/icons/silk/ website.
1010 Portions of the TCL implementation, tcl_np.c and tcl_np.h are copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation, and other parties.
11 NSAlert is Copyright (C) 2011-2020 Philipp Mayerhofer.
12 LZ4 is Copyright (C) 2011-2020 Yann Collet.
11 NSAlert is Copyright (C) 2011-2021 Philipp Mayerhofer.
12 LZ4 is Copyright (C) 2011-2021 Yann Collet.
22 Added user's manual pdf file to distribution in doc/.
33 Added vertex and rtlbrowse for sourcecode annotation.
44 3.0.1 09may06 Automatically add extensions to save filenames in gtkwave.
5 Cygwin compile fixes. Add Cygwin functionality for fork()
5 Cygwin compile fixes. Add Cygwin functionality for fork()
66 related ops that do in fact work properly.
7 3.0.2 09may06 More fixes for full function (except pthreads) in Cygwin.
7 3.0.2 09may06 More fixes for full function (except pthreads) in Cygwin.
88 Requires usage of Cygserver if rtlbrowse is to work.
9 Fixed fonts for Cygwin to improve readability.
9 Fixed fonts for Cygwin to improve readability.
1010 The Courier font is very bad looking and blitter mangled under
1111 cygwin.
12 3.0.3 29may06 Changed yylineno references in vlex.l in rtlbrowse to
13 my_yylineno as newer versions of flex automatically define
12 3.0.3 29may06 Changed yylineno references in vlex.l in rtlbrowse to
13 my_yylineno as newer versions of flex automatically define
1414 this and cause duplicate symbols.
1515 Saw there were still problems with courier on debian. Also
1616 check for misc-fixed on non-cygwin systems just in case.
3434 dumpfile loaders as the string length is known from the rc
3535 of sprintf.
3636 Fixed T_SCOPE rule in vcd.c as dotted hierarchies would
37 throw off the parser as hierarchies themselves are
37 throw off the parser as hierarchies themselves are
3838 (in practice) never really escaped.
3939 In tree.c, treenamefix() would recurse more than necessary
4040 such that some dotted hierarchies would cause an order of
5656 3.0.6 14jul06 Added "Real" option for data type display as passing around
5757 real numbers in Verilog across modules needs to be done
5858 with $realtobits and $bitstoreal.
59 Added scripting command flag --script in order to allow
59 Added scripting command flag --script in order to allow
6060 autosetup of things that are outside of config file control.
6161 This also allows doing things such as automated print jobs.
6262 Added --nowm to remove window manager control on most
6767 Added --nomenus to remove menus for the case when used in
6868 conjunction with --xid and it is desired to create an
6969 embedded wave viewer applet that cannot initiate file I/O
70 on its own. Note that earlier versions of GTK+ cannot
70 on its own. Note that earlier versions of GTK+ cannot
7171 handle menu events properly from a GtkPlug.
72 Fixed problem with dead memory allocations for GtkColor
72 Fixed problem with dead memory allocations for GtkColor
7373 structs in color.c as found by Valgrind.
7474 Moved .odt version of the user's guide into doc/ rather than
7575 the pdf version as this is a sourcecode distribution so the
8080 Found problem with directive-based string embedding in older
8181 gcc compiler versions.
8282 GTK+-1.2 doesn't handle GtkPlug.
83 3.0.7 17jul06 Added support for dualview of waveforms using GtkPlug and
83 3.0.7 17jul06 Added support for dualview of waveforms using GtkPlug and
8484 shared memory IPC through use of the "twinwave" front end.
8585 Updated documentation to add a section on twinwave.
8686 3.0.8 04aug06 Modified order of flags in twinwave as appending flags
9090 not including getopt.h.
9191 Removed unused "bus" element from struct fac.
9292 Added interactive loading of vcd files with the routines in
93 vcd_partial.c. Added shmidcat to the distribition to test
93 vcd_partial.c. Added shmidcat to the distribition to test
9494 this new interactive loading functionality.
9595 Added real_parameter vartype (Riviera Aldec 2006.6) in all
9696 vcd loaders.
164164 Fixed bug in draw_hptr_trace_vector_analog() that would
165165 cause crashes on pure real vectors when zoomed out fully.
166166 Added dynamic tooltips on current marker values for both
167 the left and middle mouse buttons (not tested for Win32
167 the left and middle mouse buttons (not tested for Win32
168168 yet so disabled there).
169169 Added preliminary support for changing menu accelerators
170170 through the rc file with an "accel" statement.
172172 zero in the initial dumpvars. (would be needed anyway for
173173 dumpers that for some reason don't as the 1st value
174174 change collapses into the second)
175 3.0.18 28nov06 Fix in vcd saver for when units are in seconds: keeps
175 3.0.18 28nov06 Fix in vcd saver for when units are in seconds: keeps
176176 timescale of "ss" being used instead of just "s".
177177 Locale problem in printing of floating point numbers fixed
178178 by setting up a local fixer routine in config.h for
180180 Fix in all vcd loaders to handle "port" (along with other
181181 keywords) that appear in non-keyword parts of the $VAR
182182 declaration sequence.
183 Fixed long standing LXT bug with integer datatype on
183 Fixed long standing LXT bug with integer datatype on
184184 trivial LXT files. (Overflow in lt_buf decoder buffer.)
185185 3.0.19 21dec06 More locale fixing with LC_ALL.
186186 Added user patches from NIIBE Yutaka to remove requirement
195195 reals.
196196 3.0.21 02feb07 Added support for in/out/inout evcd ports generated by
197197 dumpports in ModelSim.
198 Fixed problem with hierarchy being out of order as
198 Fixed problem with hierarchy being out of order as
199199 treegraft needed to be followed by treesort. This mostly
200200 impacted recursive hierarchy imports by only allowing
201201 two signals to import rather than all of them. Also there
202202 was an inconsistency with the signal ordering with VCD vs
203203 the database formats because of this.
204204 3.0.22 19feb07 Bumped up hash size from 65519 to 500009 entries for VCD
205 parsers.
205 parsers.
206206 Bumped up max VCDID fastindex size to 8M entries.
207207 Now use gperf for verilog datatypes for some speedup in
208208 gtkwave vcd loaders.
217217 PATH_MAX set if not defined in verilog.g for Vertex.
218218 Regenerated configure for setenv()/unsetenv() presence
219219 which impacts Solaris (use putenv() instead).
220 Regenerated configure to handle auto detect of -lnsl,
220 Regenerated configure to handle auto detect of -lnsl,
221221 -lrpc, and -lpthread.
222222 Added -c to file install in top-level makefile (Solaris).
223223 Use _LARGEFILE_SOURCE value from configure with linux
242242 that code was leftover from the vzt2vcd).
243243 Updated manpages for vzt2vcd, lxt2vcd, and vztminer.
244244 On concatenated vector loads ('#'/':' in savefile), attempts
245 to do a load of a monolithic vector on fail. This is
245 to do a load of a monolithic vector on fail. This is
246246 somewhat related to the re-coalesce vectors feature above.
247247 Implemented reverse of this for monolithic vectors into
248248 the '#' bitstrand variants.
249 3.0.25 10apr07 System Verilog with MTI fix for VCD declarations of form
249 3.0.25 10apr07 System Verilog with MTI fix for VCD declarations of form
250250 $var reg 64 >w #implicit-var###VarElem:ram_di[0.0] [63:0] $end
251 ...debussy implicitly escapes the varname during loading so
251 ...debussy implicitly escapes the varname during loading so
252252 gtkwave does it too now for all VCD loaders.
253 More System Verilog with MTI fixes: VCD (parameter) vars of
253 More System Verilog with MTI fixes: VCD (parameter) vars of
254254 length zero are representative of reals with MTI: they don't
255255 use real_parameter like Riviera does.
256256 Updated vcd_saver.c to handle saving these implicit-var
304304 3.1.1 20sep07 Fixed crash in hierarchy search reload. (Wrong
305305 pointer type introduced from code cleanup.) Adding
306306 start of tabbed browsing support. Put in window
307 select focus switching between tabs (e.g., on
307 select focus switching between tabs (e.g., on
308308 search windows). Added locking in main iteration
309309 loop to detect unexpected context switches and
310310 fix/report them (wrong operation if it occurs).
311311 3.1.2 24dec07 Compiler warning cleanups from Sun compile logs.
312312 Added named parameter support to vermin parser.
313313 Added check for gperf back into configure.ac.
314 Added vlist_spill rc variable to control new
314 Added vlist_spill rc variable to control new
315315 feature of spilling vlists to a tempfile on disk.
316316 Fixed vcd loader status bar on files > 2GB.
317317 Removed non-growable vlists and also finalize
327327 with the vlist_prepack rc variable.
328328 Added --giga option to turn on vlist_spill and
329329 vlist_prepack from the command line.
330 3.1.3 13jan08 Added dynamic keypress detection in the Pattern Search
331 Requester so users do not need to press enter for search
332 strings. Likewise, added the rc variable sst_dynamic_filter
330 3.1.3 13jan08 Added dynamic keypress detection in the Pattern Search
331 Requester so users do not need to press enter for search
332 strings. Likewise, added the rc variable sst_dynamic_filter
333333 to enable the same type behavior for the signal name filter in
334334 the GTK2 signal search tree.
335 Fixed bug where filtered signal names did not reappear on
335 Fixed bug where filtered signal names did not reappear on
336336 reload.
337337 Updated user manual as necessary.
338 Added "edge" left/right buttons for handy single signal edge
338 Added "edge" left/right buttons for handy single signal edge
339339 detection due to user requests.
340340 Fixed long-standing backward edge seek bug in pattern search.
341341 (It would miss the preceeding edge if the marker isn't already
342342 on one.)
343 Added use_standard_clicking rc variable in order to enable
343 Added use_standard_clicking rc variable in order to enable
344344 "normal GTK" shift/click semantics in the signal window.
345 Collapse/uncollapse is now shift-ctrl when
345 Collapse/uncollapse is now shift-ctrl when
346346 use_standard_clicking is active.
347347 Added prelim dnd for use_standard_clicking mode.
348 use_standard_clicking disabled in GTK-1.2 as there are dnd
348 use_standard_clicking disabled in GTK-1.2 as there are dnd
349349 issues.
350350 Recalculate signal width on reload as sometimes it was missed.
351351 Added input focus capability to signalwindow.
352352 Moving menu options to standard GTK accelerator keys.
353 Added Ctrl-A/Shift-Ctrl-A handler to the treeview so it acts
353 Added Ctrl-A/Shift-Ctrl-A handler to the treeview so it acts
354354 like the signal window.
355355 Added left/right scrolling hotkeys in signal window.
356 Added use_toolbutton_interface environment variable which
356 Added use_toolbutton_interface environment variable which
357357 enables new user interface at the top of screen.
358 More modifications to handle globals swapping in multi-tab
358 More modifications to handle globals swapping in multi-tab
359359 mode.
360360 Update configure.ac to handle library order problem with
361361 cygwin in rtlbrowse.
362 Added scrollwheel support in signal window when focused and
362 Added scrollwheel support in signal window when focused and
363363 standard clicking is active.
364364 Added "Use Color" and "Use Black and White" (for screendumps)
365365 View menu options from user requests.
430430 calls causing similar problems as necessary.
431431 3.1.9 20apr08 Added missing init_filetrans_data() to reload function.
432432 Updated manfiles to get them in line with Debian lintian.
433 3.1.10 14may08 Added missing adjustment of t->shift in mouseover.c in
434 order to allow the mouseover on shifted traces to display
433 3.1.10 14may08 Added missing adjustment of t->shift in mouseover.c in
434 order to allow the mouseover on shifted traces to display
435435 properly.
436436 Fixed problem with edgebutton going back two edges on a
437437 combined vector. (Cut and paste typo from strace.c.)
444444 3.1.12 14jul08 Compiler warning fixes.
445445 Fixed crash in vcd recoder for b vs 01xz mixups in
446446 malformed VCD files.
447 Fixed abort on VCD load for malformed size vs
447 Fixed abort on VCD load for malformed size vs
448448 [msi:lsi] syntax. NC does this on arrays of wires.
449449 Fix to vlist reader with --giga enabled in order to
450450 handle reads which go off the end of the file.
465465 for the horizontal scroller in the wavewindow.
466466 Added sticky click semantics for clicks in signal
467467 window. To do this in the treesearch_gtk2 file
468 will require some additional future work with
468 will require some additional future work with
469469 view_selection_func() and/or signal handling and
470470 trapping.
471 3.2.0 16feb09 Fix for strings ('s' type) in recoder.
471 3.2.0 16feb09 Fix for strings ('s' type) in recoder.
472472 Added timestart command to savefiles which indicates
473473 what the leftmost position should be on reload.
474474 Added support for as/zs small timescales as well as
476476 Adding signal name DnD support from external apps.
477477 Force open tree nodes on initial .sav file read.
478478 Yet more new warning (-Wall) cleanups.
479 Fixed ExtractNodeSingleBit for vectors which do not
479 Fixed ExtractNodeSingleBit for vectors which do not
480480 have a zero in either the msb or lsb (e.g., [1:9]).
481481 Added support for dragging files into the viewer
482482 (i.e., dumpfile, savefile, stems file)
483483 Added DnD of signal names from RTLBrowse source code
484 windows directly into gtkwave.
484 windows directly into gtkwave.
485485 GTK1 compiler compatibility fixes.
486486 Improved search performance from rtlbrowse initiated
487487 DnD searches.
495495 Updated -f argument file handling in vermin.
496496 Updated tcl_helper code so that signalwindow drags of bit-
497497 blasted vectors are properly re-coalesced for client code
498 for the drag.
498 for the drag.
499499 Updated task definition in vermin so that identifiers with
500500 dots in them can be used as task enable names.
501501 Fixed problem in vermin preprocessor where defines in 0x0d0a
548548 Added prelim auto-scrolling code for trace adds/copies.
549549 Added support for Tcl repscripts.
550550 Removed warnings found when compiling with -Wshadow.
551 Fix for stack crash in treesort() on dumpfiles with an
551 Fix for stack crash in treesort() on dumpfiles with an
552552 extremely large number of signals (e.g., 5 million).
553553 Compile fixes for rtlbrowse in older versions of GTK2.
554554 Remove stray tempfiles created by --giga writer under MinGW.
555555 Removed stray file descriptor from lxt on reload.
556556 Fixed repeat error problem in lxt.c introduced by -Wshadow fix.
557 Added prelim version of scale_to_time_dimension rc variable and
557 Added prelim version of scale_to_time_dimension rc variable and
558558 appropriate menu options.
559559 Beginning to update user manual to reflect new 3.2 features.
560 Added Partial VCD Dynamic Zoom To End and related
560 Added Partial VCD Dynamic Zoom To End and related
561561 zoom_dynamic_end rc variables.
562562 More mingw compile fixes: the whole tarball compiles now.
563563 Use old file chooser (for now) in mingw as the new one seems
564564 not to be re-sizeable.
565565 Added "copy traces" to toolbar in gtkwave as copy function now
566566 exists.
567 Added check for "server" in env var CYGWIN before printing
567 Added check for "server" in env var CYGWIN before printing
568568 warning about using shared memory.
569569 Added vpi client lxt/lxt2/vzt writers in contrib/vpi, but these
570570 currently are not built.
571571 Compatibility fix for gcc 3.x.
572 Added extload capability which grabs data via popen(). This
572 Added extload capability which grabs data via popen(). This
573573 allows adding loaders for unsupported formats via data mining.
574574 Added Tcl command setBaselineMarker.
575575 Extload hardening on reload.
601601 order to avoid unnecessary stack pushing.
602602 Fixing reloader crashes in vcd_build_symbols().
603603 Adding experimental support for bringing up gtkwave without a
604 trace like "every other" GUI app. This is currently disabled
604 trace like "every other" GUI app. This is currently disabled
605605 pending more testing.
606606 Sort filename lists from DnD in order to allow both a
607607 dumpfile and a savefile to be dragged into the viewer and
639639 Warning fixes for printf format strings in lxt2/vzt/ghw.
640640 Updated VCD parser to handle names like "a[1] [3:0]".
641641 Added VCDNAM_ESCAPE cases in lxt, lxt2, and vzt loaders.
642 Updated VCD writers so they put spaces before bracketed
642 Updated VCD writers so they put spaces before bracketed
643643 signal ranges.
644644 Added extra message for help requester if file type is
645645 MISSING_FILE in order to direct users what to do.
692692 Fix to attempt_vecmatch_2 when no suffix encountered.
693693 3.3.0 25dec09 Modified unformat_time() so it can also handle floating-
694694 point exponential format.
695 Integration of a large amount of group handling sourcecode
695 Integration of a large amount of group handling sourcecode
696696 from Don Baltus / Bluespec, Inc.
697697 Re-integrated original Simpod repscript handling.
698698 Reworked force open tree node and moved to
733733 file support as it is obsolete: all scripts are Tcl scripts
734734 now.
735735 Integrated user-provided rework of rgb.c.
736 Removed local lzma library and now use system xz if
736 Removed local lzma library and now use system xz if
737737 available. Old VZT files using -z 2 are no longer readable
738738 but can be converted using vzt2vcd from an old version of
739739 gtkwave.
744744 In fstapi.c now use tmpfile() to generate tempfiles in
745745 order to speed up operation on networked filesystems.
746746 Fixed problem in fstapi.c with conflict between off_t
747 and unsigned longs on some 32-bit systems which cause a
747 and unsigned longs on some 32-bit systems which cause a
748748 "tsec uncompress" failure on reads.
749749 Fixed missing dependencies in various Makefile.am files.
750750 3.3.2 05jan10 Emergency fix for ghw.c as it was missing a close comment
791791 force_open_tree_nodes loop (spotted using an alternate
792792 allocator).
793793 Added optional preliminary Judy array support.
794 Fixed compiler warnings.
794 Fixed compiler warnings.
795795 Fixed toggle max hier so it toggles back and forth between
796796 the most previously set hierarchy depth.
797 Added ".lxt2" to list of suffixes allowed by gtkwave.
797 Added ".lxt2" to list of suffixes allowed by gtkwave.
798798 Remove name field from struct fac.
799799 Added missing hierarchy boundary sort for FST in order to
800800 allow compatibility with compressed names (-C flag).
840840 Compiler warning fix in lxt_write.c/fstapi.c for Open Solaris.
841841 Added fstWriterGetDumpSizeLimitReached() to fstapi.c.
842842 Fixes to Tcl string handling.
843 Applied user-supplied fixes for null pointer crashes in
843 Applied user-supplied fixes for null pointer crashes in
844844 rtlbrowse.
845845 Moved gtk_grab_add() after gtk_widget_show() in order to work
846846 with newer versions of GTK.
887887 gtkwave::setCurrentTranslateFile,
888888 gtkwave::setCurrentTranslateProc,
889889 gtkwave::setCurrentTranslateTransProc, and
890 gtkwave::setCurrentTranslateEnums to give Tcl access to these
890 gtkwave::setCurrentTranslateEnums to give Tcl access to these
891891 features.
892892 Add write combining in fstWriterEmitValueChange to speed
893893 up execution on Cygwin.
894894 Nested `ifdef fix for Vermin.
895 Fix for free to non-malloc'd address problem in repscripts
896 due to context changing in Tcl scripts when reload occurs.
895 Fix for free to non-malloc'd address problem in repscripts
896 due to context changing in Tcl scripts when reload occurs.
897897 Added gtkwavetcl_setvar() for starting to build a framework
898898 to support Tcl variable change callbacks. This can be used
899899 to closely monitor how a user manipulates the gtkwave GUI.
935935 3.3.15 10nov10 Added check in fstapi.c for corner case where
936936 fstWriterEmitSectionHeader could make a file unusable if.hier
937937 is not present.
938 Added more checks in fstapi reader to prevent crashes on
938 Added more checks in fstapi reader to prevent crashes on
939939 malformed files.
940940 Add config.h #include to the fstapi.c code.
941941 Add detection in vcd2fst for Verilog XL-style VCD identifiers
952952 Added Jenkins hash routine to enable dynamic alias detection
953953 for when Judy not available.
954954 3.3.17 28nov10 Added sanity check in dynamic alias reconstruct routine in
955 FST reader and also fixed bug where alias reconstruction in
955 FST reader and also fixed bug where alias reconstruction in
956956 current blocks doesn't overwrite previous, old block data.
957957 3.3.18 24dec10 Added extra allocation in fstWriterEmitValueChange in case
958958 users modify the FST_BREAK_ADD_SIZE to a very small value.
960960 into its compile.
961961 Fixed x86_64 assembler =q vs =Q problem in lxt.c.
962962 Preliminary support for variable length records in FST files.
963 Added fstUtilityBinToEsc and fstUtilityEscToBin for
963 Added fstUtilityBinToEsc and fstUtilityEscToBin for
964964 conversion of binary data to C-style strings.
965965 Now allow escaped strings in VCD files to encode a richer
966966 set of data for non-standard "s" VCD records.
10201020 bug. (Would prevent pattern search from working on
10211021 64-bit big-endian architectures.)
10221022 Fixed broken "replace" signal option.
1023 3.3.24 03aug11 Improve the searching for the TCL libraries (when using
1023 3.3.24 03aug11 Improve the searching for the TCL libraries (when using
10241024 stubs).
10251025 Fixed bug where Tcl_GetString was substituted with
10261026 brace removal preprocessing when unnecessary (would break
10381038 Fix in lxt2_read.c/.h for negative msb/lsb indices.
10391039 Fix in vzt_read.c/.h for negative msb/lsb indices.
10401040 3.3.26 25sep11 Mac OSX fixes: removed restrictions for twinwave on OSX,
1041 OSX compile fixes for Tcl detection, printf warning
1041 OSX compile fixes for Tcl detection, printf warning
10421042 fixes (xcode gcc uses stricter warnings).
10431043 More generic warning fixes from recent feature adds.
10441044 3.3.27 20oct11 Fixes of suspicious NULL pointer warnings from scan-build.
10491049 or will change when files are loaded.
10501050 Added fix for DnD crash when Quartz is the GDK back-end
10511051 on Mac OSX. Enable fix with --enable-quartz in configure.
1052 Fixed fstWriterFlushContext() such that invocations
1052 Fixed fstWriterFlushContext() such that invocations
10531053 outside the fstapi are synced with time changes.
10541054 Modify main window size for twinwave on Quartz: GtkPlug
10551055 window does not fit into GtkSocket as with X11.
10661066 .gtkw itself being able to bring up the original dumpfile.
10671067 Numerous bug fixes.
10681068 Preliminary GConf support supporting session ID-based restore.
1069 Preliminary GConf support to emulate OSX "open"
1069 Preliminary GConf support to emulate OSX "open"
10701070 functionality such that dumpfiles/savefiles can be targeted
10711071 to an open gtkwave viewer / session ID.
10721072 << long descriptions >>
10731073 Fixed size of declaration of render_mutex_renderopt_c_1 as it
10741074 was one element too short.
10751075 Added transition code for shifting away from using
1076 GtkItemFactoryEntry (also will help with OSX menubar
1076 GtkItemFactoryEntry (also will help with OSX menubar
10771077 integration which expects menu shells).
10781078 Added support for native Quartz menu bars.
10791079 Removed --enable-quartz as it is auto detected now if
11241124 Added .gtkw as a new save file extension. When either .sav
11251125 or .gtkw is encountered, the rest of a tab's session adaptively
11261126 follows in expecting it as the save file suffix.
1127 Added [savefile] tag to save files. The intended use is to
1128 allow reconstruction of relative paths between dump and save
1127 Added [savefile] tag to save files. The intended use is to
1128 allow reconstruction of relative paths between dump and save
11291129 file.
11301130 Fixed --autosavename to use .gtkw as a suffix rather than the
11311131 .sav suffix.
11331133 matches gtkwave.icns.
11341134 Renamed .sav examples to .gtkw.
11351135 Added relative path comparisons for --save so when dumpfiles
1136 and savefiles move in tandem, a successful load can be
1136 and savefiles move in tandem, a successful load can be
11371137 attempted.
11381138 Added [dumpfile_mtime] and [dumpfile_size] tags to save file.
11391139 Can now specify just an augmented save file at the command
11521152 Disable analog during mutually incompatible mode selection
11531153 (binary, filters, etc).
11541154 Added F/P/T flags to mouseover for the filters.
1155 Fix problem where ungrab doesn't occur if button pressed +
1155 Fix problem where ungrab doesn't occur if button pressed +
11561156 simultaneous reload accelerator key occurs.
11571157 Fix combine direction in transaction filter to down.
11581158 Fix vector analog render/print routine to use skipcnt.
11781178 args to transaction filters via the args $comment.
11791179 Added string value of \000 which renders as high-z.
11801180 Integrated alt_wheel_mode code provided by Tom Browne.
1181 Fixes for some rc file variables to keep them from getting
1181 Fixes for some rc file variables to keep them from getting
11821182 clobbered on 2nd tab opening.
11831183 Warning fixes when compiled on Ubuntu.
11841184 3.3.33 27feb12 Scan-build fix in vcd_recoder.c.
11851185 Added $timezero tag to VCD files which allows offsetting all
1186 the values in a trace to provide ability for negative time
1187 values. Currently only VCD, LXT, LXT2, VZT, and FST support
1186 the values in a trace to provide ability for negative time
1187 values. Currently only VCD, LXT, LXT2, VZT, and FST support
11881188 this.
11891189 Fix for timescale 10s and 100s.
11901190 3.3.34 12mar12 Fix for marker time deltas when $timezero is used.
11911191 Reduced size of alert requester icons to 64x64 pixels.
1192 3.3.35 04apr12 Polarity fix for vcd_preserve_glitches in rcfile. Default
1192 3.3.35 04apr12 Polarity fix for vcd_preserve_glitches in rcfile. Default
11931193 is no/off. Use yes in the rcfile to enable (e.g., for
11941194 viewing interpolated analog waveforms).
11951195 Added vcd_preserve_glitches support to FST as --optimize
11961196 uses FST.
11971197 Added vcd_preserve_glitches_real (for VCD/FST) rcfile
11981198 variable that turns off deglitching only for real signals.
1199 This removes the need for #define TRACK_AND_HOLD_FIX and
1199 This removes the need for #define TRACK_AND_HOLD_FIX and
12001200 prevents the case where interpolation of an analog waveform
12011201 is deformed as significant data points were removed by the
12021202 VCD or FST loader.
12141214 introduced in 3.3.19.
12151215 3.3.37 10jun12 Added patch for savefile.c that corrects an issue in which the
12161216 parser for process filter lines assumed the associated id
1217 number was always a single digit.
1217 number was always a single digit.
12181218 Added patch to bitvec.c catches one more case when locating
1219 bitblasted signals in vcd files created by modelsim.
1219 bitblasted signals in vcd files created by modelsim.
12201220 Fix that kills stray pipeio_create() processes on
12211221 pipeio_destroy().
12221222 Additions to extload to handle hier types, component types,
12381238 broken in the GtkSocket/GtkPlug implementation for Win32.
12391239 3.3.39 08aug12 Fixed relative pathnames when generated in MinGW and used
12401240 back on Linux.
1241 Added --output filename option to fst2vcd, vzt2vcd, and
1241 Added --output filename option to fst2vcd, vzt2vcd, and
12421242 lxt2vcd.
12431243 Fix crash on OSX if gtk_widget_set_sensitive is called on
12441244 a separator.
12661266 Added scrollwheel support to rtlbrowse code windows.
12671267 Added fseeko() return checking in fstapi.c to prevent
12681268 errors with dynamically updated files.
1269 3.3.43 26jan13 Fix for rtlbrowse for gtk_adjustment_get_page_increment and
1270 gtk_adjustment_get_step_increment introduced in 2.14.
1269 3.3.43 26jan13 Fix for rtlbrowse for gtk_adjustment_get_page_increment and
1270 gtk_adjustment_get_step_increment introduced in 2.14.
12711271 Added VPD support via vpd2vcd. To use, specify -o
12721272 at the command line. (e.g., gtkwave -o test.vpd)
12731273 Added autodetect for LXT, LXT2, VZT, FST regardless of the
12771277 Added conditional compile for stat() being available.
12781278 3.3.44 16feb13 gdk_draw_layout assertion `GDK_IS_DRAWABLE (drawable)'
12791279 assertion fix.
1280 3.3.45 28feb13 Fix for VCDNAM_ESCAPE character in treesearch window. This
1280 3.3.45 28feb13 Fix for VCDNAM_ESCAPE character in treesearch window. This
12811281 sometimes occurs for structure identifiers.
12821282 3.3.46 29apr13 Upgraded to autoconf 2.69.
12831283 Fixed as of yet undetected hdr_incomplete bug when running off
13021302 FSDB fix for new debug info output style to be parsed.
13031303 Added generate as scope type to VCD/FST/FSDB.
13041304 Preliminary add for module port direction for FSDB and FST.
1305 Display signal direction column in SST if not all signals are
1305 Display signal direction column in SST if not all signals are
13061306 declared as FST_VD_IMPLICIT.
13071307 Fixed GTK warning when hide_sst is enabled and SST is opened
13081308 then closed.
13381338 Fixed ordering of static FSDB libraries for when dynamic ones
13391339 are not present.
13401340 Added direction filters to SST name filter search. That is,
1341 adding +I+, +O+, +IO+, +B+, or +L+ before the regular
1341 adding +I+, +O+, +IO+, +B+, or +L+ before the regular
13421342 expression adds additional filtering criteria. Direction
13431343 filters are case-insensitive.
13441344 Relax FSDB loader to allow VHDL and mixed-language files.
1345 Added VHDL hierarchy types to FST, internal VCD loaders and
1345 Added VHDL hierarchy types to FST, internal VCD loaders and
13461346 also vcdfst/fst2vcd.
13471347 Added in VHDL to FST (which will also allow other languages):
1348 gtkwave can process these types (e.g., signal + std_ulogic),
1348 gtkwave can process these types (e.g., signal + std_ulogic),
13491349 but there are currently no simulators supporting them. These
13501350 are written by using fstWriterCreateVar2().
13511351 3.3.50 15oct13 Limit number of rows that can be displayed in mouseover in
13551355 Added missing $dumpvars emission in fst2vcd.
13561356 Added missing atto and zepto time prefix parsing in vcd2fst.
13571357 Added VHDL package type to FST.
1358 Added red box around 'U' vector values for VHDL similar to
1358 Added red box around 'U' vector values for VHDL similar to
13591359 'X' for Verilog.
13601360 Used FST "attribute name" for variable types if specified.
13611361 CRLF fix for save file reading on LF-only systems.
13721372 3.3.51 27oct13 MAINTAINERS: Please add gedit to the list of dependencies
13731373 for gtkwave in order to enable new function that Icarus
13741374 Verilog dumps into FST files.
1375 Fix "/File/Grab To File" on OSX with an OSX patch as the
1376 _gdk_quartz_image_copy_to_image() function in the GTK
1375 Fix "/File/Grab To File" on OSX with an OSX patch as the
1376 _gdk_quartz_image_copy_to_image() function in the GTK
13771377 toolkit for Quartz is broken.
13781378 Updated examples/gtkwaverc accel options to reflect the
13791379 current state of the gtkwave main window main menu.
13801380 Added "Open Source Definition" and "Open Source Instantiation"
1381 options that invoke .gtkwaverc variable "editor" (or
1381 options that invoke .gtkwaverc variable "editor" (or
13821382 $GTKWAVE_EDITOR or gedit or open -t [OSX]) on sourcecode when
13831383 source stems are present in the dumpfile (currently FST only).
13841384 Fixed timezero in vcd2fst as it was only parsing unsigned
14081408 Standardized export feature to write vcd using lower case
14091409 for non 0/1 values.
14101410 Added perror() on errno-related exits in vcd loaders.
1411 Added experimental wlf2vcd in contrib. It is not currently
1411 Added experimental wlf2vcd in contrib. It is not currently
14121412 compiled or used.
14131413 Corrected non-functional typos in documentation.
14141414 3.3.54 02jan14 Added LZ4 double compression on hierarchy tree for FST when
14221422 in some cases on x86_64.
14231423 3.3.55 06feb14 Fixed problem with FST_DYNAMIC_ALIAS_DISABLE enabled when
14241424 Judy arrays are not present.
1425 FST writer performance tweaks for traces with millions of
1425 FST writer performance tweaks for traces with millions of
14261426 signal declarations.
1427 Keep FSDB_VT_STREAM (FSDB transaction type) traces from
1427 Keep FSDB_VT_STREAM (FSDB transaction type) traces from
14281428 attempting to be read (for now) as they aren't yet processed.
14291429 Added more space efficient FST dynamic alias encoding.
14301430 Tempfile creation fix for Windows. Using tmpnam() is not
14361436 VCD formatting.
14371437 Added very fast I/O write capability to fst2vcd.
14381438 Added support for FSDB_BYTES_PER_BIT_2B (EVCD) in FSDB loader.
1439 Added experimental fsdb2vcd in contrib. It is not currently
1439 Added experimental fsdb2vcd in contrib. It is not currently
14401440 compiled or used.
14411441 Fix to treesearch to remove duplicate signal names because of
14421442 faulty dumpers.
14601460 Change [1] at end of struct to C99 [] notation with appropriate
14611461 allocation size modification.
14621462 System_profiler speed fix for OSX.
1463 3.3.59 26apr14 Use Duff's Device for 8 byte -> 1 byte binary value compression
1463 3.3.59 26apr14 Use Duff's Device for 8 byte -> 1 byte binary value compression
14641464 algorithm in FST writer.
14651465 Warnings fixes from cppcheck.
1466 Moved MinGW for FST to using different windows tempfile
1466 Moved MinGW for FST to using different windows tempfile
14671467 generation instead of tmpfile().
14681468 Removed fflush() in FST for MinGW in places that can cause
14691469 crashes with read only files.
14971497 -- for example filters all non-ports from search results.
14981498 Updated LZ4 for version r126.
14991499 Minor warnings fixes.
1500 Moved TCL_LDADD/TK_LDADD before FSDB_LDADD to avoid stale
1501 Tcl library version conflicts.
1500 Moved TCL_LDADD/TK_LDADD before FSDB_LDADD to avoid stale
1501 Tcl library version conflicts.
15021502 Removed appending [31:0] to vcd loaded integer names.
15031503 Reduced recursion depth in GHW signal loader to prevent
15041504 stack overflow crashes.
15051505 Added support for synthetic clocks in FST file.
15061506 Update timetrace marking so it runs quicker for large traces.
15071507 3.3.66 05jul15 Faster fsdb initialization.
1508 Fix vcd recoder loader crash for malformed vcd if signal is
1508 Fix vcd recoder loader crash for malformed vcd if signal is
15091509 declared as bits and a real valued change is encountered for
15101510 the value change.
15111511 Fixed crash in vcd2vzt for vcd files with no value changes
15181518 3.3.68 18nov15 Update copyright date.
15191519 Added named markers capability to From: and To: time value
15201520 input boxes.
1521 Added support for fixed point binary numbers for both signed
1521 Added support for fixed point binary numbers for both signed
15221522 and unsigned decimal display types.
15231523 3.3.69 03feb16 Added missing EXTLOAD_CFLAGS declarations in configure.ac for
15241524 FSDB detection when only .a files are present (necessary for
15351535 share/icons/hicolor/scalable/apps/gtkwave.svg directory.
15361536 Make gtkwave interpret values as double precision FP for
15371537 plotting when BitsToReal is enabled. Also keeps analog mode
1538 enabled when selecting numerical formats (which allows
1539 enabling/disabling BitsToReal without going out of analog
1538 enabled when selecting numerical formats (which allows
1539 enabling/disabling BitsToReal without going out of analog
15401540 mode). Disabling analog mode can be done using the
15411541 existing Analog->Off menu option.
15421542 Fix broken non-canonical bit ordering (IBM) single bit
15441544 Fixed gtkwave::gtkwave::addSignalsFromList so it can handle
15451545 subset and forward/reverse extractions on signals.
15461546 Remove FST_WRITER_PARALLEL from MinGW CFLAGS as some recent
1547 versions of MinGW have issues with struct timespec when
1547 versions of MinGW have issues with struct timespec when
15481548 pthread.h is included.
15491549 Added /Edit/Delete to destroy traces without affecting the
15501550 existing cut buffer.
15671567 it is imported to the waveform display as an integer instead of
15681568 a hex value. This works for dump file formats that show the
15691569 datatype in the SST window.
1570 Added code that should prevent the primary marker from
1570 Added code that should prevent the primary marker from
15711571 disappearing unexpectedly as well as dynamic resizing being
15721572 stuck in the unset marker width.
15731573 3.3.75 02aug16 Fix crash when -S and -W are used in tandem.
15751575 Crash fix in fstapi.c on read value at time accessing of
15761576 FST files that use new dynamic aliases, FastLZ, or LZ4. This
15771577 primarily affects rtlbrowse.
1578 3.3.77 03oct16 Updated documentation to include an appendix on FST
1578 3.3.77 03oct16 Updated documentation to include an appendix on FST
15791579 implementation details.
15801580 Removed '!A || (A && B)' is equivalent to '!A || B' redundant
15811581 condition checks where found in source.
15941594 allow copying values into the clipboard so they can be pasted
15951595 into text editors, etc.
15961596 3.3.81 09jun17 Added max_fsdb_trees environment variable.
1597 Fixed -C option so it is persistent across new tabs.
1597 Fixed -C option so it is persistent across new tabs.
15981598 Integrated updated GHW reader code.
15991599 3.3.82 02jul17 Get sys_fst working with VCS VPI.
16001600 Added string concatenations for vectors.
16011601 Added asserts to ghwlib.c to make scan-view clean.
16021602 3.3.83 04aug17 Preserve search type for regex search across reloads or
16031603 close/reopens of regex search widget.
1604 Update local libz to current version.
1604 Update local libz to current version.
16051605 3.3.84 03sep17 Updated FSDB reader with experimental FST tree build
16061606 routines for faster init.
16071607 Removed warnings found when compiling with -Wshadow.
16151615 not stored as a string. This then allows bitwise manipulations
16161616 of integers.
16171617 3.3.86 03oct17 Added recurse import function (found before only in the hier
1618 search) into the SST.
1619 Removed obsolete bundle functionality from SST as recurse
1618 search) into the SST.
1619 Removed obsolete bundle functionality from SST as recurse
16201620 import more accurately imports recursively.
16211621 Made entrybox taller (using -1) as recent versions of
16221622 gnome have taller window titlebars and the widget was not
16291629 Makefile.am.
16301630 3.3.88 20feb18 Added --sstexclude command line option to prune unwanted
16311631 clutter from the SST window.
1632 Updated "/View/Mouseover Copies To Clipboard" menu option to
1633 copying signal names into the clipboard so they can be pasted
1634 into text editors, etc.
1635 Fixed Write Save File to handle getting confused by initial
1636 cancel then retry.
1632 Updated "/View/Mouseover Copies To Clipboard" menu option to
1633 copying signal names into the clipboard so they can be pasted
1634 into text editors, etc.
1635 Fixed Write Save File to handle getting confused by initial
1636 cancel then retry.
16371637 Updated v2k input/output declarations to handle unpacked arrays.
16381638 Fix for pattern marks that could overshoot the left marker.
16391639 3.3.89 17mar18 Added support for 32-bit conversions in BitsToReal.
16401640 Crash fix for pattern search with reals using LXT, LXT2, VZT.
16411641 3.3.90 08may18 For Cut Traces, fix up scroll position if there are traces
1642 above the current row being cut.
1643 Bits to real crash fix for very large floats.
1642 above the current row being cut.
1643 Bits to real crash fix for very large floats.
16441644 Fixed gray code conversions that were incomplete for right
1645 justified vectors such that the vector length is not a
1645 justified vectors such that the vector length is not a
16461646 multiple of the radix size (4 for hex, 3 for oct).
16471647 Warray-bounds warning fix for 32-bit conversions in BitsToReal.
16481648 3.3.91 29may18 Added support for GSettings for when GConf is removed from
16671667 3.3.95 07oct18 Added fflush on stdout for help text as fix for possible
16681668 stdout problem with mingw/msys shells.
16691669 Added preliminary support for Time datatype.
1670 Warnings fixes for Verilator integration.
1671 Fixed install_proc_filter usage for Tcl invocation.
1670 Warnings fixes for Verilator integration.
1671 Fixed install_proc_filter usage for Tcl invocation.
16721672 Change integer type to "integer" in SST to differentiate it
16731673 from sv ints.
16741674 Premiminary support for enum tables embedded in FST files.
16751675 3.3.96 15nov18 Changed to standardized zoom in/out/full hotkeys.
16761676 Added time backtracking warning (for partial mode) to lxt2vcd.
1677 VCD time backtracking fix (not for interactive mode).
1677 VCD time backtracking fix (not for interactive mode).
16781678 Added drag_failed handling (can press ESC) to DnD operations.
1679 Prevent missing file in savefile from causing savefile to be
1680 read as VCD by mistake.
1679 Prevent missing file in savefile from causing savefile to be
1680 read as VCD by mistake.
16811681 Changed to Dinotrace-like 0s/1s rendering for bit vectors so
16821682 values can be discerned without seeing the full value text.
1683 Removed unneeded pango_layout_get_extents() inside call for
1684 font_engine_draw_string().
1683 Removed unneeded pango_layout_get_extents() inside call for
1684 font_engine_draw_string().
16851685 Changed bsearch_trunc() to run in constant time when monospace
16861686 fonts are in use.
16871687 Added missing GDK_SCROLL_MASK to signal area (need for gtk3,
16881688 but not for other versions for some reason).
16891689 3.3.97 23nov18 Need to set menu_wlist entry NULL on gtk_widget_destroy().
1690 Fix on vtype()/vtype2() to detect 'x' and make the coloration
1691 red on newly-displayed traces. (Bug new from Dinotrace-like
1692 rendering in 3.3.96.)
1690 Fix on vtype()/vtype2() to detect 'x' and make the coloration
1691 red on newly-displayed traces. (Bug new from Dinotrace-like
1692 rendering in 3.3.96.)
16931693 3.3.98 27dec18 Removed pccts and vermin. Use xml2stems instead.
16941694 3.3.99 09feb19 Added visible single bit glitches as a yellow dot (if enabled
16951695 with --rcvar 'vcd_preserve_glitches on').
1696 Fixed print routine broken by bsearch_trunc() optimization in
1697 version 3.3.96.
1696 Fixed print routine broken by bsearch_trunc() optimization in
1697 version 3.3.96.
16981698 3.3.100 20mar19 FSDB fix for variable declarations of array of reals.
1699 Added Real, Time, Enum, and Popcnt flags to Edit/Show-Change.
1699 Added Real, Time, Enum, and Popcnt flags to Edit/Show-Change.
17001700 Ensure Show-Change regenerates analog traces.
1701 Added braces inside Tcl source command to allow spaces in
1702 filenames for Tcl scripts.
1701 Added braces inside Tcl source command to allow spaces in
1702 filenames for Tcl scripts.
17031703 3.3.101 08may19 Added gtkwave::getFacDir, gtkwave::getFacVtype, and
17041704 gtkwave::getFacDtype Tcl accessor functions that function
17051705 similar to gtkwave::getFacName.
17061706 Pair $end with $dumpvars in VCD writers.
1707 Make %.16g printing in baseconvert.c more resistant to power
1707 Make %.16g printing in baseconvert.c more resistant to power
17081708 of 10 roundoff errors.
1709 Remove register keyword where applicable as is deprecated.
1709 Remove register keyword where applicable as is deprecated.
17101710 Added --saveonexit gtkwave command line option.
17111711 3.3.102 21sep19 Remove redundant TREE_VHDL_ST_PACKAGE from SST exclude.
17121712 Added addCommentTracesFromList tcl command from user patch.
17141714 Preliminary VHDL support for wlf2vcd.
17151715 Add missing return value checks on mmap() in FST writer.
17161716 3.3.103 03nov19 Fix MAP_FAILED missing for MinGW.
1717 Fix to make the coloration red on 'u' traces. (Bug from
1718 Dinotrace-like rendering in 3.3.96.)
1719 Typo fix on missing group start on vectors.
1717 Fix to make the coloration red on 'u' traces. (Bug from
1718 Dinotrace-like rendering in 3.3.96.)
1719 Typo fix on missing group start on vectors.
17201720 3.3.104 24jan20 Added support for loading .vf files (provided FSDB reader
17211721 libraries are enabled).
17221722 Added support for dumping variable types in vcd saveer, not
17231723 just using "wire" for non-reals/strings.
17241724 Fix for uninitialized values at time 0 for FST, FSDB loaders.
1725 3.3.105 01jul20 Fix bad (void) of is_closing in fstDestroyMmaps when using
1726 Cygwin or MinGW.
1727 Fix left shift overflow in cvt_fpsdec().
1728 Add in missing file/translate/process filter for reals.
1729 Fix for bitvec merging in GHW so integers arrays can be viewed.
1730 Added Shift-Up/Down highlight with scroll in order to assist
1731 with left/right arrow based transition movement.
1732 Fix Show Wave Highlight so it is not dependent on Show Grid.
1733 Fix negative MSBs on VCD loaders for vectors.
1734 Fix getpwuid() null pointer exception.
1735 Add missing recursion case to treenamefix().
1736 Fix lock/unlock misuse of pthread mutexes across threads.
1737 Examine env var $HOME for home dir on geteuid failure.
1738 3.3.106 06jul20 Fix for GDK_KEY_* definitions missing in older GDK versions.
1739 Fix Shift-Up/Down highlight to traverse inside groups.
1740 Resync ghwlib to handled unbounded arrays.
1741 3.3.107 30sep20 Fix left shift overflow in cvt_fpsudec for fixed point.
1742 Added Find First One trace type options.
1743 Fixed bug in Show-Change All Highlighted.
1744 3.3.108 30dec20 Fix VZT writer crash when dumpoff is invoked before first
1745 timestep.
1746 Fix convert_ffo() that scanned in wrong direction.
1747 Fix use after free in fstapi.c.
1748 3.3.109 10apr21 gtk_ctree_node_moveto bugfix in SST.
1749 MSVC compiler fix for fstapi.
1750 Update xml2stems and rtlbrowse to support generate.
1751 3.3.110 22may21 Removed ghwdump and ghwdump.1 from the distribution (now
1752 provided with GHDL).
1753 Minor scan-build fixes.
1754 3.3.111 01sep21 Fix in fstapi for read start limit time.
1755 Fix xml2stems when begin blocks are in functions.
1756 Skip over decimal point in timescale in viewer.
00 ##########################################################################
11
2 GTKWave 3.3.104 Wave Viewer is Copyright (C) 1999-2020 Tony Bybell.
3 Portions of GTKWave are Copyright (C) 1999-2020 Udi Finkelstein.
4 Context support is Copyright (C) 2007-2020 Kermin Elliott Fleming.
5 Trace group support is Copyright (C) 2009-2020 Donald Baltus.
6 GHW and additional GUI support is Copyright (C) 2005-2020 Tristan Gingold.
7 Analog support is Copyright (C) 2005-2020 Thomas Sailer.
8 External DnD support is Copyright (C) 2008-2020 Concept Engineering GmbH.
9 FastLZ is Copyright (C) 2005-2020 Ariya Hidayat.
10 LZ4 is Copyright (C) 2011-2020 Yann Collet.
2 GTKWave 3.3.111 Wave Viewer is Copyright (C) 1999-2021 Tony Bybell.
3 Portions of GTKWave are Copyright (C) 1999-2021 Udi Finkelstein.
4 Context support is Copyright (C) 2007-2021 Kermin Elliott Fleming.
5 Trace group support is Copyright (C) 2009-2021 Donald Baltus.
6 GHW and additional GUI support is Copyright (C) 2005-2021 Tristan Gingold.
7 Analog support is Copyright (C) 2005-2021 Thomas Sailer.
8 External DnD support is Copyright (C) 2008-2021 Concept Engineering GmbH.
9 FastLZ is Copyright (C) 2005-2021 Ariya Hidayat.
10 LZ4 is Copyright (C) 2011-2021 Yann Collet.
1111
1212 This program is free software; you can redistribute it and/or modify it
1313 under the terms of the GNU General Public License as published by the Free
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for gtkwave 3.3.104.
2 # Generated by GNU Autoconf 2.69 for gtkwave 3.3.111.
33 #
44 # Report bugs to <bybell@rocketmail.com>.
55 #
579579 # Identity of this package.
580580 PACKAGE_NAME='gtkwave'
581581 PACKAGE_TARNAME='gtkwave'
582 PACKAGE_VERSION='3.3.104'
583 PACKAGE_STRING='gtkwave 3.3.104'
582 PACKAGE_VERSION='3.3.111'
583 PACKAGE_STRING='gtkwave 3.3.111'
584584 PACKAGE_BUGREPORT='bybell@rocketmail.com'
585585 PACKAGE_URL=''
586586
14041404 # Omit some internal or obsolete options to make the list less imposing.
14051405 # This message is too long to be a string in the A/UX 3.1 sh.
14061406 cat <<_ACEOF
1407 \`configure' configures gtkwave 3.3.104 to adapt to many kinds of systems.
1407 \`configure' configures gtkwave 3.3.111 to adapt to many kinds of systems.
14081408
14091409 Usage: $0 [OPTION]... [VAR=VALUE]...
14101410
14701470
14711471 if test -n "$ac_init_help"; then
14721472 case $ac_init_help in
1473 short | recursive ) echo "Configuration of gtkwave 3.3.104:";;
1473 short | recursive ) echo "Configuration of gtkwave 3.3.111:";;
14741474 esac
14751475 cat <<\_ACEOF
14761476
16291629 test -n "$ac_init_help" && exit $ac_status
16301630 if $ac_init_version; then
16311631 cat <<\_ACEOF
1632 gtkwave configure 3.3.104
1632 gtkwave configure 3.3.111
16331633 generated by GNU Autoconf 2.69
16341634
16351635 Copyright (C) 2012 Free Software Foundation, Inc.
22732273 This file contains any messages produced by compilers while
22742274 running configure, to aid debugging if configure makes a mistake.
22752275
2276 It was created by gtkwave $as_me 3.3.104, which was
2276 It was created by gtkwave $as_me 3.3.111, which was
22772277 generated by GNU Autoconf 2.69. Invocation command line was
22782278
22792279 $ $0 $@
31403140
31413141 # Define the identity of the package.
31423142 PACKAGE='gtkwave'
3143 VERSION='3.3.104'
3143 VERSION='3.3.111'
31443144
31453145
31463146 cat >>confdefs.h <<_ACEOF
1149811498 # report actual input values of CONFIG_FILES etc. instead of their
1149911499 # values after options handling.
1150011500 ac_log="
11501 This file was extended by gtkwave $as_me 3.3.104, which was
11501 This file was extended by gtkwave $as_me 3.3.111, which was
1150211502 generated by GNU Autoconf 2.69. Invocation command line was
1150311503
1150411504 CONFIG_FILES = $CONFIG_FILES
1156411564 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1156511565 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1156611566 ac_cs_version="\\
11567 gtkwave config.status 3.3.104
11567 gtkwave config.status 3.3.111
1156811568 configured by $0, generated by GNU Autoconf 2.69,
1156911569 with options \\"\$ac_cs_config\\"
1157011570
11 # Process this file with autoconf to produce a configure script.
22
33 AC_PREREQ(2.59)
4 AC_INIT(gtkwave, 3.3.104, bybell@rocketmail.com)
4 AC_INIT(gtkwave, 3.3.111, bybell@rocketmail.com)
55 AC_CONFIG_SRCDIR([src/vcd.c])
66 AM_INIT_AUTOMAKE
77 AC_CONFIG_HEADER([config.h])
77 <key>CFBundleExecutable</key>
88 <string>gtkwave</string>
99 <key>CFBundleGetInfoString</key>
10 <string>3.3.104, (C) 1999-2020 Tony Bybell http://gtkwave.sourceforge.net</string>
10 <string>3.3.111, (C) 1999-2021 Tony Bybell http://gtkwave.sourceforge.net</string>
1111 <key>CFBundleIconFile</key>
1212 <string>gtkwave.icns</string>
1313 <key>CFBundleIdentifier</key>
1717 <key>CFBundlePackageType</key>
1818 <string>APPL</string>
1919 <key>CFBundleShortVersionString</key>
20 <string>3.3.104</string>
20 <string>3.3.111</string>
2121 <key>CFBundleSignature</key>
2222 <string>????</string>
2323 <key>CFBundleVersion</key>
24 <string>3.3.104</string>
24 <string>3.3.111</string>
2525 <key>NSHumanReadableCopyright</key>
26 <string>Copyright 1999 - 2020 Tony Bybell, GNU General Public License.</string>
26 <string>Copyright 1999 - 2021 Tony Bybell, GNU General Public License.</string>
2727 <key>LSMinimumSystemVersion</key>
2828 <string>10.6</string>
2929
2525
2626 <!-- Comment this out to keep the install names in binaries -->
2727 <run-install-name-tool/>
28
28
2929 <!-- Optionally specify a launcher script to use. If the
3030 application sets up everything needed itself, like
3131 environment variable, linker paths, etc, a launcher script is
5555 <binary>${prefix}/bin/evcd2vcd</binary>
5656 <binary>${prefix}/bin/fst2vcd</binary>
5757 <binary>${prefix}/bin/vcd2fst</binary>
58 <binary>${prefix}/bin/ghwdump</binary>
5958 <binary>${prefix}/bin/lxt2miner</binary>
6059 <binary>${prefix}/bin/lxt2vcd</binary>
6160 <binary>${prefix}/bin/shmidcat</binary>
173172 <data dest="${bundle}/Contents/Resources/man/fst2vcd.1">
174173 ${project}/../../man/fst2vcd.1
175174 </data>
176 <data dest="${bundle}/Contents/Resources/man/ghwdump.1">
177 ${project}/../../man/ghwdump.1
178 </data>
179175 <data dest="${bundle}/Contents/Resources/man/gtkwave.1">
180176 ${project}/../../man/gtkwave.1
181177 </data>
271267 </data>
272268
273269
274 <!-- Copy in the patches so users can recreate gtk from source.
275 This might be obsolete in future versions of gtk.
276 See bug #664894.
270 <!-- Copy in the patches so users can recreate gtk from source.
271 This might be obsolete in future versions of gtk.
272 See bug #664894.
277273 -->
278274 <data dest="${bundle}/Contents/Resources/share/patches/gtk_diff_against_modulesets.patch">
279275 ${project}/gtk_diff_against_modulesets.patch
280276 </data>
281277
282278 <!-- Copy in the patches so users can recreate gtk from source.
283 This might be obsolete in future versions of gtk.
279 This might be obsolete in future versions of gtk.
284280 No bug reported yet: this fixes yellow bars from gdk_pixbuf_get_from_drawable()
285281 which invokes _gdk_quartz_image_copy_to_image() that attempts to use 24-bit
286282 RGB pixels instead of 32-bit RGBA ones.
107107 char *txt, *txt2 = NULL;
108108 ds_Tree *tdup = malloc(sizeof(ds_Tree));
109109 int numcomps;
110 char *colon;
111 char *compname2 = compname ? strdup(compname) : NULL;
112 char *compname_colon = NULL;
113
114 if(compname2)
115 {
116 compname_colon = strchr(compname2, ':');
117 if(compname_colon)
118 {
119 *compname_colon = 0;
120 }
121 }
110122
111123 memcpy(tdup, t, sizeof(ds_Tree));
112124 t = tdup;
125 colon = strchr(t->item, ':');
126 if(colon)
127 {
128 *colon = 0; /* remove generate hack */
129 }
130
113131
114132 t->next_flat = flattened_mod_list_root;
115133 flattened_mod_list_root = t;
118136 {
119137 int cnl = strlen(compname_build);
120138
121 compname_full = malloc(cnl + 1 + strlen(compname) + 1);
139 compname_full = malloc(cnl + 1 + strlen(compname2) + 1);
122140 strcpy(compname_full, compname_build);
123141 compname_full[cnl] = '.';
124 strcpy(compname_full + cnl + 1, compname);
142 strcpy(compname_full + cnl + 1, compname2);
125143 }
126144 else
127145 {
129147 }
130148
131149 t->fullname = compname_full;
132 txt = compname_build ? compname : t->item;
150 txt = compname_build ? compname2 : t->item;
133151 if(!t->filename)
134152 {
135153 txt2 = malloc(strlen(txt) + strlen(" [MISSING]") + 1);
138156 txt = txt2;
139157 }
140158
159 if(colon)
160 {
161 *colon = ':';
162 }
163
141164 comp = t->comp;
142165 if(comp)
143166 {
190213 comp = comp->next;
191214 }
192215 #endif
216
217 free(compname2); compname2 = NULL;
193218
194219 return(subtree);
195220 }
99 #include <string.h>
1010 #include <inttypes.h>
1111 #include <time.h>
12 #include "wlf_api.h"
12 #include <wlf_api.h>
1313
1414 /* skips using wlfValueToString() and determines string directly from value representation */
1515 #define BYPASS_USING_VALUE_TO_STRING
2727 #include <string>
2828 #include <map>
2929 #include <stack>
30 #include <queue>
3031 using namespace std;
3132
3233 #define BUF_SIZ 65536
34
35 std::map <string, string>* parse_xml_tags(char *s, int *oneline)
36 {
37 char sprev;
38 std::map <string, string> *fId = new std::map <string, string>;
39 if(oneline) *oneline = 0;
40
41 while(*s)
42 {
43 if(!isspace(*s))
44 {
45 char *tag_s = s;
46 char *tag_e = NULL;
47 char *val_s = NULL;
48 char *val_e = NULL;
49
50 sprev = 0;
51 while(*s)
52 {
53 if(!s) goto bot;
54
55 if(*s == '>')
56 {
57 if(sprev == '/')
58 {
59 if(oneline) *oneline = 1;
60 }
61
62 goto bot;
63 }
64 sprev = *s;
65
66 if(*s == '=') { tag_e = s; break; }
67 s++;
68 }
69
70 while(*s)
71 {
72 if(!s) goto bot;
73 if(*s == '"') { val_s = ++s; break; }
74 s++;
75 }
76
77 while(*s)
78 {
79 if(!s) goto bot;
80 if(*s == '"') { val_e = s; break; }
81 s++;
82 }
83
84 if(tag_e && val_e)
85 {
86 *tag_e = 0;
87 *val_e = 0;
88 fId->insert(pair <string, string> (tag_s, val_s));
89 }
90 }
91 s++;
92 }
93
94 bot: return(fId);
95 }
96
3397
3498
3599 void xml2stems(FILE *fi, FILE *fo, int is_verilator_sim)
36100 {
37101 std::map <string, string> fId;
38102 std::stack<string> mId;
103 queue<string> bQueue;
104 int in_files = 0;
105 int geninst = 0;
106 int func_nesting_cnt = 0;
39107
40108 while(!feof(fi))
41109 {
57125
58126 switch(*pnt)
59127 {
128 case 'b':
129 if(!strncmp(pnt, "begin", 5) && !func_nesting_cnt)
130 {
131 if(!endtag)
132 {
133 char *s = pnt + 5;
134 int oneline = 0;
135 std::map <string, string>*xmt = parse_xml_tags(s, &oneline);
136 if(xmt)
137 {
138 const char *nam = (*xmt)[string("name")].c_str();
139 const char *fl = (*xmt)[string("fl")].c_str();
140
141 if(!oneline)
142 {
143 bQueue.push((*xmt)[string("name")]);
144 if(fl && nam && nam[0])
145 {
146 char fl_dup[strlen(fl)+1];
147 const char *s = fl; char *d = fl_dup;
148 while(isalpha(*s)) { *(d++) = *(s++); }
149 *d = 0;
150
151 unsigned int lineno = atoi(s);
152 const char *mnam = fId[fl_dup].c_str();
153
154 fprintf(fo, "++ begin %s file %s line %d\n", nam, mnam, lineno);
155
156 char *genname = (char *)malloc(strlen(nam) + 32);
157 sprintf(genname, "%s:G%d", nam, geninst++);
158 fprintf(fo, "++ comp %s type %s parent %s\n", genname, genname, mId.top().c_str());
159 fprintf(fo, "++ module %s file %s lines %d - %d\n", genname, mnam, lineno, lineno); /* don't need line number it truly ends at */
160 mId.push(genname);
161 free(genname);
162 }
163 }
164
165 delete xmt;
166 }
167 }
168 else
169 {
170 string bs = bQueue.front();
171 bQueue.pop();
172 const char *nam = bs.c_str();
173 if(nam && nam[0])
174 {
175 mId.pop();
176 fprintf(fo, "++ endbegin %s\n", nam);
177 }
178 }
179
180 }
181 break;
182
60183 case 'm':
61 if(!strncmp(pnt, "module", 6))
184 if(!strncmp(pnt, "module", 6) && strncmp(pnt, "module_files", 12))
62185 {
63186 if(!endtag)
64187 {
65 char *qts[6];
66188 char *s = pnt + 6;
67 int numqt = 0;
68 int tm = 0;
69
70 while(*s)
71 {
72 if(*s == '"')
189
190 std::map <string, string>*xmt = parse_xml_tags(s, NULL);
191 if(xmt)
192 {
193 const char *fl = (*xmt)[string("fl")].c_str();
194 const char *nam = (*xmt)[string("name")].c_str();
195 const char *tms = (*xmt)[string("topModule")].c_str();
196
197 if(fl && nam && tms)
73198 {
74 qts[numqt++] = s;
75 if(numqt == 6) break;
199 int tm = (tms[0] == '1') ? is_verilator_sim : 0;
200
201 mId.push(nam);
202
203 char fl_dup[strlen(fl)+1];
204 const char *s = fl; char *d = fl_dup;
205 while(isalpha(*s)) { *(d++) = *(s++); }
206 *d = 0;
207
208 unsigned int lineno = atoi(s);
209 const char *mnam = fId[fl_dup].c_str();
210 fprintf(fo, "++ module %s file %s lines %d - %d\n", nam, mnam, lineno, lineno); /* don't need line number it truly ends at */
211 if(tm)
212 {
213 fprintf(fo, "++ module TOP file %s lines %d - %d\n", "(VerilatorTop)", 1, 1);
214 fprintf(fo, "++ comp %s type %s parent TOP\n", nam, nam);
215 }
76216 }
77 s++;
78 }
79
80 if(numqt == 6)
81 {
82 if(strstr(qts[3]+1, "topModule=\"1\""))
217 delete xmt;
218 }
219 }
220 else
221 {
222 if(!mId.empty())
223 {
224 mId.pop();
225 }
226 }
227 }
228
229 case 'f':
230 if(!strncmp(pnt, "func", 4))
231 {
232 func_nesting_cnt = (!endtag) ? (func_nesting_cnt+1) : (func_nesting_cnt-1);
233 }
234 else
235 if(!strncmp(pnt, "files", 5))
236 {
237 in_files = (!endtag);
238 }
239 else
240 {
241 if((!endtag) && (in_files) && (!strncmp(pnt, "file", 4)))
242 {
243 char *s = pnt + 4;
244 std::map <string, string>*xmt = parse_xml_tags(s, NULL);
245
246 if(xmt)
247 {
248 const char *cod = (*xmt)[string("id")].c_str();
249 const char *fil = (*xmt)[string("filename")].c_str();
250
251 if(cod && fil)
83252 {
84 numqt = 4;
85 tm = is_verilator_sim;
253 fId.insert(pair <string, string> (cod, fil));
86254 }
87 }
88
89 if(numqt == 4)
90 {
91 char *fl = qts[0] + 1;
92 char *nam = qts[2] + 1;
93 qts[1][0] = qts[3][0] = 0;
94
95 mId.push(nam);
96
97 char fl_dup[strlen(fl)+1];
98 char *s = fl; char *d = fl_dup;
99 while(isalpha(*s)) { *(d++) = *(s++); }
100 *d = 0;
101
102 unsigned int lineno = atoi(s);
103 const char *mnam = fId[fl_dup].c_str();
104 fprintf(fo, "++ module %s file %s lines %d - %d\n", nam, mnam, lineno, lineno); /* don't need line number it truly ends at */
105 if(tm)
106 {
107 fprintf(fo, "++ module TOP file %s lines %d - %d\n", "(VerilatorTop)", 1, 1);
108 fprintf(fo, "++ comp %s type %s parent TOP\n", nam, nam);
109 }
110 }
111 }
112 else
113 {
114 if(!mId.empty())
115 {
116 mId.pop();
117 }
118 }
119 }
120
121 case 'f':
122 if((!endtag) && (!strncmp(pnt, "file id", 7)))
123 {
124 char *qts[4];
125 char *s = pnt + 7;
126 int numqt = 0;
127
128 while(*s)
129 {
130 if(*s == '"')
131 {
132 qts[numqt++] = s;
133 if(numqt == 4) break;
134 }
135 s++;
136 }
137
138 if(numqt == 4)
139 {
140 char *cod = qts[0] + 1;
141 char *fil = qts[2] + 1;
142 qts[1][0] = qts[3][0] = 0;
143
144 fId.insert(pair <string, string> (cod, fil));
255
256 delete xmt;
257 }
145258 }
146259 }
147260 break;
149262 case 'i':
150263 if((!endtag) && (!strncmp(pnt, "instance", 8)))
151264 {
152 char *qts[6];
153265 char *s = pnt + 8;
154 int numqt = 0;
266 std::map <string, string>*xmt = parse_xml_tags(s, NULL);
155267
156 while(*s)
157 {
158 if(*s == '"')
159 {
160 qts[numqt++] = s;
161 if(numqt == 6) break;
162 }
163 s++;
164 }
165
166 if(numqt == 6)
167 {
168 char *cod = qts[0] + 1;
169 char *nam = qts[2] + 1;
170 char *defnam = qts[4] + 1;
171 qts[1][0] = qts[3][0] = qts[5][0] = 0;
172
173 if(!mId.empty())
268 if(xmt)
269 {
270 const char *nam = (*xmt)[string("name")].c_str();
271 const char *defnam = (*xmt)[string("defName")].c_str();
272 if(!mId.empty() && nam && defnam)
174273 {
175274 fprintf(fo, "++ comp %s type %s parent %s\n", nam, defnam, mId.top().c_str());
176275 }
276
277 delete xmt;
177278 }
178279 }
179280 break;
184285 {
185286 if(!endtag)
186287 {
187 char *qts[4];
188288 char *s = pnt + 9;
189 int numqt = 0;
190
191 while(*s)
192 {
193 if(*s == '"')
289
290 std::map <string, string>*xmt = parse_xml_tags(s, NULL);
291 if(xmt)
292 {
293 const char *fl = (*xmt)[string("fl")].c_str();
294 const char *nam = (*xmt)[string("name")].c_str();
295
296 if(fl && nam)
194297 {
195 qts[numqt++] = s;
196 if(numqt == 6) break;
298 mId.push(nam);
299
300 char fl_dup[strlen(fl)+1];
301 const char *s = fl; char *d = fl_dup;
302 while(isalpha(*s)) { *(d++) = *(s++); }
303 *d = 0;
304
305 unsigned int lineno = atoi(s);
306 const char *mnam = fId[fl_dup].c_str();
307 fprintf(fo, "++ udp %s file %s lines %d - %d\n", nam, mnam, lineno, lineno); /* don't need line number it truly ends at */
197308 }
198 s++;
199 }
200
201 if(numqt == 4)
202 {
203 char *fl = qts[0] + 1;
204 char *nam = qts[2] + 1;
205 qts[1][0] = qts[3][0] = 0;
206
207 mId.push(nam);
208
209 char fl_dup[strlen(fl)+1];
210 char *s = fl; char *d = fl_dup;
211 while(isalpha(*s)) { *(d++) = *(s++); }
212 *d = 0;
213
214 unsigned int lineno = atoi(s);
215 const char *mnam = fId[fl_dup].c_str();
216 fprintf(fo, "++ udp %s file %s lines %d - %d\n", nam, mnam, lineno, lineno); /* don't need line number it truly ends at */
309
310 delete xmt;
217311 }
218312 }
219313 else
Binary diff not shown
00 ## -*- makefile -*-
11 ##
22
3 dist_man_MANS= evcd2vcd.1 fst2vcd.1 ghwdump.1 gtkwave.1 gtkwaverc.5 lxt2miner.1 \
3 dist_man_MANS= evcd2vcd.1 fst2vcd.1 gtkwave.1 gtkwaverc.5 lxt2miner.1 \
44 lxt2vcd.1 rtlbrowse.1 shmidcat.1 \
55 twinwave.1 vcd2fst.1 vcd2lxt.1 vcd2lxt2.1 \
66 vcd2vzt.1 vzt2vcd.1 vztminer.1 fstminer.1 \
298298 top_build_prefix = @top_build_prefix@
299299 top_builddir = @top_builddir@
300300 top_srcdir = @top_srcdir@
301 dist_man_MANS = evcd2vcd.1 fst2vcd.1 ghwdump.1 gtkwave.1 gtkwaverc.5 lxt2miner.1 \
301 dist_man_MANS = evcd2vcd.1 fst2vcd.1 gtkwave.1 gtkwaverc.5 lxt2miner.1 \
302302 lxt2vcd.1 rtlbrowse.1 shmidcat.1 \
303303 twinwave.1 vcd2fst.1 vcd2lxt.1 vcd2lxt2.1 \
304304 vcd2vzt.1 vzt2vcd.1 vztminer.1 fstminer.1 \
4242 Anthony Bybell <bybell@rocketmail.com>
4343 .SH "SEE ALSO"
4444 .LP
45 \fIvztminer\fP(1) \fIlxt2miner\fP(1) \fIfst2vcd\fP(1) \fIvcd2fst2\fP(1) \fIgtkwave\fP(1)
45 \fIvztminer\fP(1) \fIlxt2miner\fP(1) \fIfst2vcd\fP(1) \fIvcd2fst\fP(1) \fIgtkwave\fP(1)
+0
-39
man/ghwdump.1 less more
0 .TH "GHWDUMP" "1" "1.0" "Tristan Gingold" "GHW File Debugging Information"
1 .SH "NAME"
2 .LP
3 ghwdump \- Dumps info contained in GHW files
4 .SH "SYNTAX"
5 .LP
6 ghwdump [\fIoption\fP]... \fIGHWFILE\fP [[\fIGHWFILE\fP]...]
7
8 .SH "DESCRIPTION"
9 .LP
10 Dumps information contained in GHW files for debugging purposes.
11 .SH "OPTIONS"
12 .LP
13 .TP
14
15 \fB\-t\fR
16 Display types
17 .TP
18 \fB\-h\fR
19 Display hierarchy
20 .TP
21 \fB\-T\fR
22 Display time
23 .TP
24 \fB\-s\fR
25 Display signals (and time)
26 .TP
27 \fB\-l\fR
28 Display list of sections
29 .TP
30 \fB\-v\fR
31 Verbose
32
33 .SH "AUTHORS"
34 .LP
35 Tristan Gingold
36 .SH "SEE ALSO"
37 .LP
38 \fIgtkwave\fP(1)
286286 \fBlxt_clock_compress_to_z\fR <\fIvalue\fP>
287287 For LXT (not LXT2) allows clocks to compress to a 'z' value so that regular/periodic value changes may be noted.
288288 .TP
289 \fBlz_removal\fR <\fIvalue\fP>
290 When nonzero, suppresses the display of leading zeros on non-filtered traces. This has no effect on filtered traces.
291 .TP
289292 \fBmax_fsdb_trees\fR <\fIvalue\fP>
290293 sets the maximum number of hierarchy and signal trees to process for an FSDB file. Default = 0 = unlimited. The intent of this is to work around sim environments that accidentally call fsdbDumpVars multiple times.
291294 .TP
3737 debug.c debug.h discardbuttons.c edgebuttons.c \
3838 entry.c extload.c extload.h fetchbuttons.c fgetdynamic.c fgetdynamic.h file.c fonts.c fonts.h fst.c fst.h \
3939 gconf.c gconf.h getopt.c \
40 getopt1.c ghw.c ghw.h ghwlib.c ghwlib.h gnu-getopt.h gnu_regex.h gtk12compat.h \
40 getopt1.c ghw.c ghw.h libghw.c libghw.h gnu-getopt.h gnu_regex.h gtk12compat.h \
4141 hierpack.c hierpack.h jrb.c jrb.h help.c helpers/lxt2_read.c \
4242 helpers/lxt_write.c helpers/vzt_read.c hiersearch.c interp.c \
4343 logfile.c lx2.c lx2.h lxt.c lxt.h main.c main.h markerbox.c menu.c menu.h mouseover.c \
9797 entry.$(OBJEXT) extload.$(OBJEXT) fetchbuttons.$(OBJEXT) \
9898 fgetdynamic.$(OBJEXT) file.$(OBJEXT) fonts.$(OBJEXT) \
9999 fst.$(OBJEXT) gconf.$(OBJEXT) getopt.$(OBJEXT) \
100 getopt1.$(OBJEXT) ghw.$(OBJEXT) ghwlib.$(OBJEXT) \
100 getopt1.$(OBJEXT) ghw.$(OBJEXT) libghw.$(OBJEXT) \
101101 hierpack.$(OBJEXT) jrb.$(OBJEXT) help.$(OBJEXT) \
102102 lxt2_read.$(OBJEXT) lxt_write.$(OBJEXT) vzt_read.$(OBJEXT) \
103103 hiersearch.$(OBJEXT) interp.$(OBJEXT) logfile.$(OBJEXT) \
433433 debug.c debug.h discardbuttons.c edgebuttons.c \
434434 entry.c extload.c extload.h fetchbuttons.c fgetdynamic.c fgetdynamic.h file.c fonts.c fonts.h fst.c fst.h \
435435 gconf.c gconf.h getopt.c \
436 getopt1.c ghw.c ghw.h ghwlib.c ghwlib.h gnu-getopt.h gnu_regex.h gtk12compat.h \
436 getopt1.c ghw.c ghw.h libghw.c libghw.h gnu-getopt.h gnu_regex.h gtk12compat.h \
437437 hierpack.c hierpack.h jrb.c jrb.h help.c helpers/lxt2_read.c \
438438 helpers/lxt_write.c helpers/vzt_read.c hiersearch.c interp.c \
439439 logfile.c lx2.c lx2.h lxt.c lxt.h main.c main.h markerbox.c menu.c menu.h mouseover.c \
573573 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
574574 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
575575 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ghw.Po@am__quote@
576 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ghwlib.Po@am__quote@
577576 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Po@am__quote@
578577 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@
579578 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hierpack.Po@am__quote@
580579 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hiersearch.Po@am__quote@
581580 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interp.Po@am__quote@
582581 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@
582 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libghw.Po@am__quote@
583583 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logfile.Po@am__quote@
584584 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lx2.Po@am__quote@
585585 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt.Po@am__quote@
220220 fprintf(stderr, "INTERNAL ERROR: ClearGroupTrace applied to non-group! Exiting.\n");
221221 exit(255);
222222 }
223 }
224
225 void MarkTraceCursor(Trptr t_curs)
226 {
227 if(t_curs)
228 {
229 Trptr t=GLOBALS->traces.first;
230
231 while(t)
232 {
233 t->is_cursor = 0;
234 t=t->t_next;
235 }
236
237 t_curs->is_cursor = 1;
238 }
223239 }
224240
225241 /*
512512 unsigned int t_color; /* trace color index */
513513 unsigned char t_fpdecshift; /* for fixed point decimal */
514514
515 unsigned is_cursor : 1; /* set to mark a cursor trace */
515516 unsigned is_alias : 1; /* set when it's an alias (safe to free t->name then) */
516517 unsigned is_depacked : 1; /* set when it's been depacked from a compressed entry (safe to free t->name then) */
517518 unsigned vector : 1; /* 1 if bit vector, 0 if node */
537538 TR_FPDECSHIFT_B,
538539 TR_TIME_B,
539540 TR_ENUM_B,
541 TR_CURSOR_B,
542 TR_FFO_B,
540543
541544 TR_RSVD_B /* for use internally such as temporary caching of highlighting, not for use in traces */
542545 };
573576 #define TR_REAL2BITS (UINT64_C(1)<<TR_REAL2BITS_B)
574577
575578 #define TR_NUMMASK (TR_ASCII|TR_HEX|TR_DEC|TR_BIN|TR_OCT|TR_SIGNED|TR_REAL|TR_TIME|TR_ENUM)
579 #define TR_ATTRIBS (TR_RJUSTIFY|TR_INVERT|TR_REVERSE|TR_EXCLUDE|TR_POPCNT|TR_FFO)
576580
577581 #define TR_COLLAPSED (UINT64_C(1)<<TR_COLLAPSED_B)
578582 #define TR_ISCOLLAPSED (TR_BLANK|TR_COLLAPSED)
586590
587591 #define TR_TIME (UINT64_C(1)<<TR_TIME_B)
588592 #define TR_ENUM (UINT64_C(1)<<TR_ENUM_B)
593
594 #define TR_CURSOR (UINT64_C(1)<<TR_CURSOR_B)
595 #define TR_FFO (UINT64_C(1)<<TR_FFO_B)
589596
590597 #define TR_ANALOGMASK (TR_ANALOG_STEP|TR_ANALOG_INTERPOLATED)
591598
646653 void CloseTrace(Trptr t);
647654 void ClearTraces(void);
648655 void ClearGroupTraces(Trptr t);
656 void MarkTraceCursor(Trptr t);
649657
650658 char *varxt_fix(char *s);
651659
2828 #endif
2929
3030 /*
31 * convert binary <=> gray/popcnt in place
31 * filters mutually exclusive with file/translate/process filters
32 */
33 static char *lzremoval(char *s)
34 {
35 char *p = s;
36
37 if(*p)
38 {
39 while((*p=='0') && *(p+1))
40 {
41 p++;
42 }
43 }
44
45 if(p != s)
46 {
47 memmove(s, p, strlen(p) + 1);
48 }
49
50 return(s);
51 }
52
53 /*
54 * file/translate/process filters
55 */
56 static char *dofilter(Trptr t, char *s)
57 {
58 GLOBALS->xl_file_filter[t->f_filter] = xl_splay(s, GLOBALS->xl_file_filter[t->f_filter]);
59
60 if(!strcasecmp(s, GLOBALS->xl_file_filter[t->f_filter]->item))
61 {
62 free_2(s);
63 s = malloc_2(strlen(GLOBALS->xl_file_filter[t->f_filter]->trans) + 1);
64 strcpy(s, GLOBALS->xl_file_filter[t->f_filter]->trans);
65 }
66
67 if((*s == '?') && (!GLOBALS->color_active_in_filter))
68 {
69 char *s2a;
70 char *s2 = strchr(s+1, '?');
71 if(s2)
72 {
73 s2++;
74 s2a = malloc_2(strlen(s2)+1);
75 strcpy(s2a, s2);
76 free_2(s);
77 s = s2a;
78 }
79 }
80
81 return(s);
82 }
83
84 static char *edofilter(Trptr t, char *s)
85 {
86 if(t->flags & TR_ENUM)
87 {
88 int filt = t->e_filter - 1;
89
90 #ifdef _WAVE_HAVE_JUDY
91 PPvoid_t pv = JudyHSGet(GLOBALS->xl_enum_filter[filt], s, strlen(s));
92 if(pv)
93 {
94 free_2(s);
95 s = malloc_2(strlen(*pv) + 1);
96 strcpy(s, *pv);
97 }
98 #else
99 GLOBALS->xl_enum_filter[filt] = xl_splay(s, GLOBALS->xl_enum_filter[filt]);
100
101 if(!strcasecmp(s, GLOBALS->xl_enum_filter[filt]->item))
102 {
103 free_2(s);
104 s = malloc_2(strlen(GLOBALS->xl_enum_filter[filt]->trans) + 1);
105 strcpy(s, GLOBALS->xl_enum_filter[filt]->trans);
106 }
107 #endif
108 else
109 {
110 char *zerofind = s;
111 char *dst = s, *src;
112 while(*zerofind == '0') zerofind++;
113 if(zerofind != s)
114 {
115 src = (!*zerofind) ? (zerofind-1) : zerofind;
116 while(*src)
117 {
118 *(dst++) = *(src++);
119 }
120 *dst = 0;
121 }
122 }
123 }
124
125 return(s);
126 }
127
128 static char *pdofilter(Trptr t, char *s)
129 {
130 struct pipe_ctx *p = GLOBALS->proc_filter[t->p_filter];
131 char buf[1025];
132 int n;
133
134 if(p)
135 {
136 #if !defined _MSC_VER && !defined __MINGW32__
137 fputs(s, p->sout);
138 fputc('\n', p->sout);
139 fflush(p->sout);
140
141 buf[0] = 0;
142
143 n = fgets(buf, 1024, p->sin) ? strlen(buf) : 0;
144 buf[n] = 0;
145 #else
146 {
147 BOOL bSuccess;
148 DWORD dwWritten, dwRead;
149
150 WriteFile(p->g_hChildStd_IN_Wr, s, strlen(s), &dwWritten, NULL);
151 WriteFile(p->g_hChildStd_IN_Wr, "\n", 1, &dwWritten, NULL);
152
153 for(n=0;n<1024;n++)
154 {
155 do {
156 bSuccess = ReadFile(p->g_hChildStd_OUT_Rd, buf+n, 1, &dwRead, NULL);
157 if((!bSuccess)||(buf[n]=='\n'))
158 {
159 goto ex;
160 }
161
162 } while(buf[n]=='\r');
163 }
164 ex: buf[n] = 0;
165 }
166
167 #endif
168
169 if(n)
170 {
171 if(buf[n-1] == '\n') { buf[n-1] = 0; n--; }
172 }
173
174 if(buf[0])
175 {
176 free_2(s);
177 s = malloc_2(n + 1);
178 strcpy(s, buf);
179 }
180 }
181
182 if((*s == '?') && (!GLOBALS->color_active_in_filter))
183 {
184 char *s2a;
185 char *s2 = strchr(s+1, '?');
186 if(s2)
187 {
188 s2++;
189 s2a = malloc_2(strlen(s2)+1);
190 strcpy(s2a, s2);
191 free_2(s);
192 s = s2a;
193 }
194 }
195 return(s);
196 }
197
198
199 /*
200 * convert binary <=> gray/ffo/popcnt in place
32201 */
33202 #define cvt_gray(f,p,n) \
34203 do { \
35 if((f)&(TR_GRAYMASK|TR_POPCNT)) \
36 { \
37 if((f)&TR_BINGRAY) { convert_bingray((p),(n)); } \
38 if((f)&TR_GRAYBIN) { convert_graybin((p),(n)); } \
39 if((f)&TR_POPCNT) { convert_popcnt((p),(n)); } \
40 } \
204 if((f)&(TR_GRAYMASK|TR_POPCNT|TR_FFO)) \
205 { \
206 if((f)&TR_BINGRAY) { convert_bingray((p),(n)); } \
207 if((f)&TR_GRAYBIN) { convert_graybin((p),(n)); } \
208 if((f)&TR_FFO) { convert_ffo((p),(n)); } \
209 if((f)&TR_POPCNT) { convert_popcnt((p),(n)); } \
210 } \
41211 } while(0)
42212
43213
167337 }
168338
169339
340 static void convert_ffo(char *pnt, int nbits)
341 {
342 int i;
343 int ffo = -1;
344
345 for(i=(nbits-1);i>=0;i--)
346 {
347 char ch = pnt[i];
348
349 if((ch == AN_1) || (ch == AN_H))
350 {
351 ffo = (nbits-1) - i;
352 break;
353 }
354 }
355
356 if(ffo >= 0)
357 {
358 for(i=nbits-1;i>=0;i--) /* always requires less number of bits */
359 {
360 pnt[i] = (ffo & 1) ? AN_1 : AN_0;
361 ffo >>= 1;
362 }
363 }
364 else
365 {
366 for(i=nbits-1;i>=0;i--) /* always requires less number of bits */
367 {
368 pnt[i] = AN_X;
369 }
370 }
371 }
372
373
170374 static void dpr_e16(char *str, double d)
171375 {
172376 char *buf16;
195399
196400 int shamt = t->t_fpdecshift;
197401 TimeType lpart = val >> shamt;
198 TimeType rmsk = (1 << shamt);
402 TimeType rmsk = (ULLDescriptor(1) << shamt);
403
199404 TimeType rbit = (val >= 0) ? (val & (rmsk-1)) : ((-val) & (rmsk-1));
200405 double rfrac;
201406 int negflag = 0;
244449 {
245450 int shamt = t->t_fpdecshift;
246451 UTimeType lpart = ((UTimeType)val) >> shamt;
247 TimeType rmsk = (1 << shamt);
452 TimeType rmsk = (ULLDescriptor(1) << shamt);
248453 TimeType rbit = (val & (rmsk-1));
249454 double rfrac;
250455 char dbuf[32];
465670 if(GLOBALS->show_base) { *(pnt++)='"'; }
466671 *(pnt)=0x00; /* scan build : remove dead increment */
467672 }
468 else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)&&(!(flags&TR_POPCNT))))
673 else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)&&(!(flags&(TR_POPCNT|TR_FFO)))))
469674 {
470675 char *parse;
471676
8931098 {
8941099 strcpy(rv,"UNDEF");
8951100 }
1101 }
1102
1103 if(t)
1104 {
1105 if(!(t->f_filter|t->p_filter|t->e_filter))
1106 {
1107 if(GLOBALS->lz_removal) lzremoval(rv);
1108 }
1109 else
1110 {
1111 if(t->e_filter)
1112 {
1113 rv = edofilter(t, rv);
1114 }
1115 else
1116 if(t->f_filter)
1117 {
1118 rv = dofilter(t, rv);
1119 }
1120 else
1121 {
1122 rv = pdofilter(t, rv);
1123 }
1124 }
8961125 }
8971126
8981127 return(rv);
12141443 if(GLOBALS->show_base) { *(pnt++)='"'; }
12151444 *(pnt)=0x00; /* scan build : remove dead increment */
12161445 }
1217 else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)&&(!(flags&TR_POPCNT))))
1446 else if((flags&TR_HEX)||((flags&(TR_DEC|TR_SIGNED))&&(nbits>64)&&(!(flags&(TR_POPCNT|TR_FFO)))))
12181447 {
12191448 char *parse;
12201449
15951824 }
15961825
15971826
1598 static char *dofilter(Trptr t, char *s)
1599 {
1600 GLOBALS->xl_file_filter[t->f_filter] = xl_splay(s, GLOBALS->xl_file_filter[t->f_filter]);
1601
1602 if(!strcasecmp(s, GLOBALS->xl_file_filter[t->f_filter]->item))
1603 {
1604 free_2(s);
1605 s = malloc_2(strlen(GLOBALS->xl_file_filter[t->f_filter]->trans) + 1);
1606 strcpy(s, GLOBALS->xl_file_filter[t->f_filter]->trans);
1607 }
1608
1609 if((*s == '?') && (!GLOBALS->color_active_in_filter))
1610 {
1611 char *s2a;
1612 char *s2 = strchr(s+1, '?');
1613 if(s2)
1614 {
1615 s2++;
1616 s2a = malloc_2(strlen(s2)+1);
1617 strcpy(s2a, s2);
1618 free_2(s);
1619 s = s2a;
1620 }
1621 }
1622
1623 return(s);
1624 }
1625
1626 static char *edofilter(Trptr t, char *s)
1627 {
1628 if(t->flags & TR_ENUM)
1629 {
1630 int filt = t->e_filter - 1;
1631
1632 #ifdef _WAVE_HAVE_JUDY
1633 PPvoid_t pv = JudyHSGet(GLOBALS->xl_enum_filter[filt], s, strlen(s));
1634 if(pv)
1635 {
1636 free_2(s);
1637 s = malloc_2(strlen(*pv) + 1);
1638 strcpy(s, *pv);
1639 }
1640 #else
1641 GLOBALS->xl_enum_filter[filt] = xl_splay(s, GLOBALS->xl_enum_filter[filt]);
1642
1643 if(!strcasecmp(s, GLOBALS->xl_enum_filter[filt]->item))
1644 {
1645 free_2(s);
1646 s = malloc_2(strlen(GLOBALS->xl_enum_filter[filt]->trans) + 1);
1647 strcpy(s, GLOBALS->xl_enum_filter[filt]->trans);
1648 }
1649 #endif
1650 else
1651 {
1652 char *zerofind = s;
1653 char *dst = s, *src;
1654 while(*zerofind == '0') zerofind++;
1655 if(zerofind != s)
1656 {
1657 src = (!*zerofind) ? (zerofind-1) : zerofind;
1658 while(*src)
1659 {
1660 *(dst++) = *(src++);
1661 }
1662 *dst = 0;
1663 }
1664 }
1665 }
1666
1667 return(s);
1668 }
1669
1670 static char *pdofilter(Trptr t, char *s)
1671 {
1672 struct pipe_ctx *p = GLOBALS->proc_filter[t->p_filter];
1673 char buf[1025];
1674 int n;
1675
1676 if(p)
1677 {
1678 #if !defined _MSC_VER && !defined __MINGW32__
1679 fputs(s, p->sout);
1680 fputc('\n', p->sout);
1681 fflush(p->sout);
1682
1683 buf[0] = 0;
1684
1685 n = fgets(buf, 1024, p->sin) ? strlen(buf) : 0;
1686 buf[n] = 0;
1687 #else
1688 {
1689 BOOL bSuccess;
1690 DWORD dwWritten, dwRead;
1691
1692 WriteFile(p->g_hChildStd_IN_Wr, s, strlen(s), &dwWritten, NULL);
1693 WriteFile(p->g_hChildStd_IN_Wr, "\n", 1, &dwWritten, NULL);
1694
1695 for(n=0;n<1024;n++)
1696 {
1697 do {
1698 bSuccess = ReadFile(p->g_hChildStd_OUT_Rd, buf+n, 1, &dwRead, NULL);
1699 if((!bSuccess)||(buf[n]=='\n'))
1700 {
1701 goto ex;
1702 }
1703
1704 } while(buf[n]=='\r');
1705 }
1706 ex: buf[n] = 0;
1707 }
1708
1709 #endif
1710
1711 if(n)
1712 {
1713 if(buf[n-1] == '\n') { buf[n-1] = 0; n--; }
1714 }
1715
1716 if(buf[0])
1717 {
1718 free_2(s);
1719 s = malloc_2(n + 1);
1720 strcpy(s, buf);
1721 }
1722 }
1723
1724 if((*s == '?') && (!GLOBALS->color_active_in_filter))
1725 {
1726 char *s2a;
1727 char *s2 = strchr(s+1, '?');
1728 if(s2)
1729 {
1730 s2++;
1731 s2a = malloc_2(strlen(s2)+1);
1732 strcpy(s2a, s2);
1733 free_2(s);
1734 s = s2a;
1735 }
1736 }
1737 return(s);
1738 }
1739
1740
17411827 char *convert_ascii_vec(Trptr t, char *vec)
17421828 {
17431829 char *s = convert_ascii_vec_2(t, vec);
17441830
17451831 if(!(t->f_filter|t->p_filter|t->e_filter))
17461832 {
1833 if(GLOBALS->lz_removal) lzremoval(s);
17471834 }
17481835 else
17491836 {
17941881
17951882 if(!(t->f_filter|t->p_filter|t->e_filter))
17961883 {
1884 if(GLOBALS->lz_removal) lzremoval(s);
17971885 }
17981886 else
17991887 {
2727 int i, len;
2828 int prefix_idx = 0;
2929
30 if(*s != '0') return;
30 if(*s != '0')
31 {
32 unsigned char *dot = strchr(s, '.');
33 unsigned char *src, *dst;
34 if(dot)
35 {
36 unsigned char *pnt = dot+1;
37 int alpha_found = 0;
38 while(*pnt)
39 {
40 if(isalpha(*pnt))
41 {
42 alpha_found = 1;
43 break;
44 }
45 pnt++;
46 }
47
48 if(alpha_found)
49 {
50 src = pnt;
51 dst = dot;
52 while(*src)
53 {
54 *dst = *src;
55 dst++; src++;
56 }
57 *dst = 0;
58 }
59 }
60 return;
61 }
3162
3263 len = strlen(s);
3364 for(i=0;i<len;i++)
1919 #include "globals.h"
2020 #include <config.h>
2121 #include "ghw.h"
22 #include "ghwlib.h"
22 #include "libghw.h"
2323 #include "tree.h"
2424
2525 /************************ splay ************************/
172172 {
173173 if(psr)
174174 {
175 char *fstr1 = GLOBALS->facs[i-1]->name;
176 char *fstr2 = GLOBALS->facs[i]->name;
177 int p1 = strand_pnt(fstr1);
178 int p2 = strand_pnt(fstr2);
179
180 if(!root)
175 int ev1 = GLOBALS->facs[i-1]->n->extvals;
176 int ev2 = GLOBALS->facs[i]->n->extvals;
177
178 if(!ev1 && !ev2)
181179 {
182 if((p1>=0)&&(p1==p2))
180 char *fstr1 = GLOBALS->facs[i-1]->name;
181 char *fstr2 = GLOBALS->facs[i]->name;
182 int p1 = strand_pnt(fstr1);
183 int p2 = strand_pnt(fstr2);
184
185 if(!root)
183186 {
184 if(!strncmp(fstr1, fstr2, p1))
187 if((p1>=0)&&(p1==p2))
185188 {
186 root = GLOBALS->facs[i-1];
187 root->vec_root = root;
188 root->vec_chain = GLOBALS->facs[i];
189 GLOBALS->facs[i]->vec_root = root;
189 if(!strncmp(fstr1, fstr2, p1))
190 {
191 root = GLOBALS->facs[i-1];
192 root->vec_root = root;
193 root->vec_chain = GLOBALS->facs[i];
194 GLOBALS->facs[i]->vec_root = root;
195 }
190196 }
191197 }
192 }
193 else
194 {
195 if((p1>=0)&&(p1==p2))
198 else
196199 {
197 if(!strncmp(fstr1, fstr2, p1))
200 if((p1>=0)&&(p1==p2))
198201 {
199 psr->vec_chain = GLOBALS->facs[i];
200 GLOBALS->facs[i]->vec_root = root;
202 if(!strncmp(fstr1, fstr2, p1))
203 {
204 psr->vec_chain = GLOBALS->facs[i];
205 GLOBALS->facs[i]->vec_root = root;
206 }
207 else
208 {
209 root = NULL;
210 }
201211 }
202212 else
203213 {
204214 root = NULL;
205215 }
206216 }
207 else
208 {
209 root = NULL;
210 }
217 }
218 else
219 {
220 root = NULL;
211221 }
212222 }
213223
232242 int i;
233243 int cnt = 1;
234244 struct tree **ar;
235
245
236246 while((t2 = t2->next)) { cnt++; }
237
247
238248 ar = malloc_2(cnt * sizeof(struct tree *));
239249 t2 = t;
240250 for(i=0;i<cnt;i++)
243253 if(t2->child) { recurse_tree_build_whichcache(t2->child); }
244254 t2 = t2->next;
245255 }
246
256
247257 for(i=cnt-1;i>=0;i--)
248258 {
249259 t = ar[i];
250 if(t->t_which >= 0)
260 if(t->t_which >= 0)
251261 {
252262 GLOBALS->gwt_ghw_c_1 = ghw_insert(t, GLOBALS->gwt_ghw_c_1, t->t_which, GLOBALS->facs[t->t_which]);
253263 }
254264 }
255
265
256266 free_2(ar);
257267 }
258268 }
265275 int i;
266276 int cnt = 1;
267277 struct tree **ar;
268
278
269279 while((t2 = t2->next)) { cnt++; }
270
280
271281 ar = malloc_2(cnt * sizeof(struct tree *));
272282 t2 = t;
273283 for(i=0;i<cnt;i++)
276286 if(t2->child) { recurse_tree_fix_from_whichcache(t2->child); }
277287 t2 = t2->next;
278288 }
279
289
280290 for(i=cnt-1;i>=0;i--)
281291 {
282292 t = ar[i];
284294 {
285295 GLOBALS->gwt_ghw_c_1 = ghw_splay(t, GLOBALS->gwt_ghw_c_1);
286296 GLOBALS->gwt_corr_ghw_c_1 = ghw_splay(GLOBALS->gwt_ghw_c_1->sym, GLOBALS->gwt_corr_ghw_c_1); /* all facs are in this tree so this is OK */
287
297
288298 t->t_which = GLOBALS->gwt_corr_ghw_c_1->val_old;
289299 }
290300 }
291
301
292302 free_2(ar);
293303 }
294304 }
439449 const char *pfx, struct tree **res, unsigned int **sig)
440450 {
441451 union ghw_type *idx;
442 struct ghw_type_array *base = arr->sa.base;
452 struct ghw_type_array *base =
453 (struct ghw_type_array *) ghw_get_base_type (arr->sa.base);
443454 char *name = NULL;
444455
445456 if ((unsigned int)dim == base->nbr_dim)
448459 sprintf (GLOBALS->asbuf, "%s]", pfx);
449460 name = strdup_2(GLOBALS->asbuf);
450461
451 t = build_hierarchy_type (h, base->el, name, sig);
462 t = build_hierarchy_type (h, arr->sa.el, name, sig);
452463
453464 if (*res != NULL)
454465 (*res)->next = t;
+0
-2183
src/ghwlib.c less more
0 /* GHDL Wavefile reader library.
1 Copyright (C) 2005 Tristan Gingold
2
3 GHDL is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 2, or (at your option) any later
6 version.
7
8 GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with GCC; see the file COPYING. If not, write to the Free
15 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
16 02111-1307, USA.
17 */
18
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <assert.h>
24
25 #include "ghwlib.h"
26
27 /* Reopen H through decompressor DECOMP. */
28
29 static int
30 ghw_openz (struct ghw_handler *h, const char *decomp, const char *filename)
31 {
32 int plen = strlen (decomp) + 1 + strlen(filename) + 1;
33 char *p = malloc (plen);
34
35 snprintf (p, plen, "%s %s", decomp, filename);
36 fclose (h->stream);
37 h->stream = popen(p, "r");
38 free (p);
39
40 if (h->stream == NULL)
41 return -1;
42
43 h->stream_ispipe = 1;
44
45 return 0;
46 }
47
48 int
49 ghw_open (struct ghw_handler *h, const char *filename)
50 {
51 char hdr[16];
52
53 h->stream = fopen (filename, "rb");
54 if (h->stream == NULL)
55 return -1;
56
57 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
58 return -1;
59
60 /* Check compression layer. */
61 if (!memcmp (hdr, "\x1f\x8b", 2))
62 {
63 if (ghw_openz (h, "gzip -cd", filename) < 0)
64 return -1;
65 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
66 return -1;
67 }
68 else if (!memcmp (hdr, "BZ", 2))
69 {
70 if (ghw_openz (h, "bzip2 -cd", filename) < 0)
71 return -1;
72 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
73 return -1;
74 }
75 else
76 {
77 h->stream_ispipe = 0;
78 }
79
80 /* Check magic. */
81 if (memcmp (hdr, "GHDLwave\n", 9) != 0)
82 return -2;
83 /* Check version. */
84 if (hdr[9] != 16
85 || hdr[10] != 0)
86 return -2;
87 h->version = hdr[11];
88 if (h->version > 1)
89 return -3;
90 if (hdr[12] == 1)
91 h->word_be = 0;
92 else if (hdr[12] == 2)
93 h->word_be = 1;
94 else
95 return -4;
96 #if 0
97 /* Endianness. */
98 {
99 int endian;
100 union { unsigned char b[4]; uint32_t i;} v;
101 v.i = 0x11223344;
102 if (v.b[0] == 0x11)
103 endian = 2;
104 else if (v.b[0] == 0x44)
105 endian = 1;
106 else
107 return -3;
108
109 if (hdr[12] != 1 && hdr[12] != 2)
110 return -3;
111 if (hdr[12] != endian)
112 h->swap_word = 1;
113 else
114 h->swap_word = 0;
115 }
116 #endif
117 h->word_len = hdr[13];
118 h->off_len = hdr[14];
119
120 if (hdr[15] != 0)
121 return -5;
122
123 h->hie = NULL;
124 return 0;
125 }
126
127 int32_t
128 ghw_get_i32 (struct ghw_handler *h, unsigned char *b)
129 {
130 if (h->word_be)
131 return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3] << 0);
132 else
133 return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0] << 0);
134 }
135
136 int64_t
137 ghw_get_i64 (struct ghw_handler *ghw_h, unsigned char *b)
138 {
139 int l, h;
140
141 if (ghw_h->word_be)
142 {
143 h = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3] << 0);
144 l = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7] << 0);
145 }
146 else
147 {
148 l = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0] << 0);
149 h = (b[7] << 24) | (b[6] << 16) | (b[5] << 8) | (b[4] << 0);
150 }
151 return (((int64_t)h) << 32) | l;
152 }
153
154 int
155 ghw_read_byte (struct ghw_handler *h, unsigned char *res)
156 {
157 int v;
158
159 v = fgetc (h->stream);
160 if (v == EOF)
161 return -1;
162 *res = v;
163 return 0;
164 }
165
166 int
167 ghw_read_uleb128 (struct ghw_handler *h, uint32_t *res)
168 {
169 uint32_t r = 0;
170 unsigned int off = 0;
171
172 while (1)
173 {
174 int v = fgetc (h->stream);
175 if (v == EOF)
176 return -1;
177 r |= (v & 0x7f) << off;
178 if ((v & 0x80) == 0)
179 break;
180 off += 7;
181 }
182 *res = r;
183 return 0;
184 }
185
186 int
187 ghw_read_sleb128 (struct ghw_handler *h, int32_t *res)
188 {
189 int32_t r = 0;
190 unsigned int off = 0;
191
192 while (1)
193 {
194 int v = fgetc (h->stream);
195 if (v == EOF)
196 return -1;
197 r |= ((int32_t)(v & 0x7f)) << off;
198 off += 7;
199 if ((v & 0x80) == 0)
200 {
201 if ((v & 0x40) && off < 32)
202 r |= ~0U << off;
203 break;
204 }
205 }
206 *res = r;
207 return 0;
208 }
209
210 int
211 ghw_read_lsleb128 (struct ghw_handler *h, int64_t *res)
212 {
213 static const int64_t r_mask = -1;
214 int64_t r = 0;
215 unsigned int off = 0;
216
217 while (1)
218 {
219 int v = fgetc (h->stream);
220 if (v == EOF)
221 return -1;
222 r |= ((int64_t)(v & 0x7f)) << off;
223 off += 7;
224 if ((v & 0x80) == 0)
225 {
226 if ((v & 0x40) && off < 64)
227 r |= r_mask << off;
228 break;
229 }
230 }
231 *res = r;
232 return 0;
233 }
234
235 int
236 ghw_read_f64 (struct ghw_handler *h, double *res)
237 {
238 /* FIXME: handle byte order. */
239 if (fread (res, sizeof (*res), 1, h->stream) != 1)
240 return -1;
241 return 0;
242 }
243
244 const char *
245 ghw_read_strid (struct ghw_handler *h)
246 {
247 uint32_t id;
248
249 if (ghw_read_uleb128 (h, &id) != 0)
250 return NULL;
251 return h->str_table[id];
252 }
253
254 union ghw_type *
255 ghw_read_typeid (struct ghw_handler *h)
256 {
257 uint32_t id;
258
259 if (ghw_read_uleb128 (h, &id) != 0)
260 return NULL;
261 return h->types[id - 1];
262 }
263
264 union ghw_range *
265 ghw_read_range (struct ghw_handler *h)
266 {
267 int t = fgetc (h->stream);
268 if (t == EOF)
269 return NULL;
270 switch (t & 0x7f)
271 {
272 case ghdl_rtik_type_b2:
273 {
274 struct ghw_range_b2 *r;
275 r = malloc (sizeof (struct ghw_range_b2));
276 r->kind = t & 0x7f;
277 r->dir = (t & 0x80) != 0;
278 if (ghw_read_byte (h, &r->left) != 0)
279 goto err_b2;
280 if (ghw_read_byte (h, &r->right) != 0)
281 goto err_b2;
282 return (union ghw_range *)r;
283 err_b2:
284 free (r);
285 return NULL;
286 }
287 case ghdl_rtik_type_e8:
288 {
289 struct ghw_range_e8 *r;
290 r = malloc (sizeof (struct ghw_range_e8));
291 r->kind = t & 0x7f;
292 r->dir = (t & 0x80) != 0;
293 if (ghw_read_byte (h, &r->left) != 0)
294 goto err_e8;
295 if (ghw_read_byte (h, &r->right) != 0)
296 goto err_e8;
297 return (union ghw_range *)r;
298 err_e8:
299 free (r);
300 return NULL;
301 }
302 case ghdl_rtik_type_i32:
303 case ghdl_rtik_type_p32:
304 {
305 struct ghw_range_i32 *r;
306 r = malloc (sizeof (struct ghw_range_i32));
307 r->kind = t & 0x7f;
308 r->dir = (t & 0x80) != 0;
309 if (ghw_read_sleb128 (h, &r->left) != 0)
310 goto err_i32;
311 if (ghw_read_sleb128 (h, &r->right) != 0)
312 goto err_i32;
313 return (union ghw_range *)r;
314 err_i32:
315 free (r);
316 return NULL;
317 }
318 case ghdl_rtik_type_i64:
319 case ghdl_rtik_type_p64:
320 {
321 struct ghw_range_i64 *r;
322 r = malloc (sizeof (struct ghw_range_i64));
323 r->kind = t & 0x7f;
324 r->dir = (t & 0x80) != 0;
325 if (ghw_read_lsleb128 (h, &r->left) != 0)
326 goto err_i64;
327 if (ghw_read_lsleb128 (h, &r->right) != 0)
328 goto err_i64;
329 return (union ghw_range *)r;
330 err_i64:
331 free (r);
332 return NULL;
333 }
334 case ghdl_rtik_type_f64:
335 {
336 struct ghw_range_f64 *r;
337 r = malloc (sizeof (struct ghw_range_f64));
338 r->kind = t & 0x7f;
339 r->dir = (t & 0x80) != 0;
340 if (ghw_read_f64 (h, &r->left) != 0)
341 goto err_f64;
342 if (ghw_read_f64 (h, &r->right) != 0)
343 goto err_f64;
344 return (union ghw_range *)r;
345 err_f64:
346 free (r);
347 return NULL;
348 }
349 default:
350 fprintf (stderr, "ghw_read_range: type %d unhandled\n", t & 0x7f);
351 return NULL;
352 }
353 }
354
355 int
356 ghw_read_str (struct ghw_handler *h)
357 {
358 unsigned char hdr[12];
359 unsigned i;
360 char *p;
361 int prev_len;
362
363 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
364 return -1;
365
366 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
367 return -1;
368 h->nbr_str = ghw_get_i32 (h, &hdr[4]);
369 h->nbr_str++;
370 h->str_size = ghw_get_i32 (h, &hdr[8]);
371 h->str_table = (char **)malloc ((h->nbr_str + 1) * sizeof (char *));
372 h->str_content = (char *)malloc (h->str_size + h->nbr_str + 1);
373
374 if (h->flag_verbose)
375 {
376 printf ("Number of strings: %u\n", h->nbr_str - 1);
377 printf ("String table size: %u\n", h->str_size);
378 }
379
380 h->str_table[0] = "<anon>";
381 p = h->str_content;
382 prev_len = 0;
383 for (i = 1; i < h->nbr_str; i++)
384 {
385 int j;
386 int c;
387 char *prev;
388 int sh;
389
390 h->str_table[i] = p;
391 prev = h->str_table[i - 1];
392 for (j = 0; j < prev_len; j++)
393 *p++ = prev[j];
394
395 while (1)
396 {
397 c = fgetc (h->stream);
398 if (c == EOF)
399 return -1;
400 if ((c >= 0 && c <= 31)
401 || (c >= 128 && c <= 159))
402 break;
403 *p++ = c;
404 }
405 *p++ = 0;
406
407 if (h->flag_verbose > 1)
408 printf (" string %u (pl=%d): %s\n", i, prev_len, h->str_table[i]);
409
410 prev_len = c & 0x1f;
411 sh = 5;
412 while (c >= 128)
413 {
414 c = fgetc (h->stream);
415 if (c == EOF)
416 return -1;
417 prev_len |= (c & 0x1f) << sh;
418 sh += 5;
419 }
420 }
421 if (fread (hdr, 4, 1, h->stream) != 1)
422 return -1;
423 if (memcmp (hdr, "EOS", 4) != 0)
424 return -1;
425 return 0;
426 }
427
428 union ghw_type *
429 ghw_get_base_type (union ghw_type *t)
430 {
431 switch (t->kind)
432 {
433 case ghdl_rtik_type_b2:
434 case ghdl_rtik_type_e8:
435 case ghdl_rtik_type_e32:
436 case ghdl_rtik_type_i32:
437 case ghdl_rtik_type_i64:
438 case ghdl_rtik_type_f64:
439 case ghdl_rtik_type_p32:
440 case ghdl_rtik_type_p64:
441 return t;
442 case ghdl_rtik_subtype_scalar:
443 return t->ss.base;
444 case ghdl_rtik_subtype_array:
445 return (union ghw_type*)(t->sa.base);
446 default:
447 fprintf (stderr, "ghw_get_base_type: cannot handle type %d\n", t->kind);
448 abort ();
449 }
450 }
451
452 /* Return -1 for unbounded types. */
453 static int
454 get_nbr_elements (union ghw_type *t)
455 {
456 switch (t->kind)
457 {
458 case ghdl_rtik_type_b2:
459 case ghdl_rtik_type_e8:
460 case ghdl_rtik_type_e32:
461 case ghdl_rtik_type_i32:
462 case ghdl_rtik_type_i64:
463 case ghdl_rtik_type_f64:
464 case ghdl_rtik_type_p32:
465 case ghdl_rtik_type_p64:
466 case ghdl_rtik_subtype_scalar:
467 return 1;
468 case ghdl_rtik_type_array:
469 return -1;
470 case ghdl_rtik_subtype_array:
471 return t->sa.nbr_scalars;
472 case ghdl_rtik_type_record:
473 return t->rec.nbr_scalars;
474 case ghdl_rtik_subtype_record:
475 return t->sr.nbr_scalars;
476 default:
477 fprintf (stderr, "get_nbr_elements: unhandled type %d\n", t->kind);
478 abort ();
479 }
480 }
481
482 int
483 ghw_get_range_length (union ghw_range *rng)
484 {
485 int res;
486
487 assert (rng != NULL);
488
489 switch (rng->kind)
490 {
491 case ghdl_rtik_type_i32:
492 if (rng->i32.dir)
493 res = rng->i32.left - rng->i32.right + 1;
494 else
495 res = rng->i32.right - rng->i32.left + 1;
496 break;
497 case ghdl_rtik_type_b2:
498 if (rng->b2.dir)
499 res = rng->b2.left - rng->b2.right + 1;
500 else
501 res = rng->b2.right - rng->b2.left + 1;
502 break;
503 case ghdl_rtik_type_e8:
504 if (rng->e8.dir)
505 res = rng->e8.left - rng->e8.right + 1;
506 else
507 res = rng->e8.right - rng->e8.left + 1;
508 break;
509 default:
510 fprintf (stderr, "get_range_length: unhandled kind %d\n", rng->kind);
511 abort ();
512 }
513 /* The length of a null range is 0. */
514 return (res <= 0) ? 0 : res;
515 }
516
517 /* Create an array subtype using BASE and ranges read from H. */
518
519 struct ghw_subtype_array *
520 ghw_read_array_subtype (struct ghw_handler *h, struct ghw_type_array *base)
521 {
522 struct ghw_subtype_array *sa;
523 unsigned j;
524 int nbr_scalars;
525
526 sa = malloc (sizeof (struct ghw_subtype_array));
527 sa->kind = ghdl_rtik_subtype_array;
528 sa->name = NULL;
529 sa->base = base;
530 nbr_scalars = get_nbr_elements (base->el);
531 sa->rngs = malloc (base->nbr_dim * sizeof (union ghw_range *));
532 for (j = 0; j < base->nbr_dim; j++)
533 {
534 sa->rngs[j] = ghw_read_range (h);
535 nbr_scalars *= ghw_get_range_length (sa->rngs[j]);
536 }
537 sa->nbr_scalars = nbr_scalars;
538 return sa;
539 }
540
541 struct ghw_subtype_record *
542 ghw_read_record_subtype (struct ghw_handler *h, struct ghw_type_record *base)
543 {
544 struct ghw_subtype_record *sr;
545
546 sr = malloc (sizeof (struct ghw_subtype_record));
547 sr->kind = ghdl_rtik_subtype_record;
548 sr->name = NULL;
549 sr->base = base;
550 if (base->nbr_scalars >= 0)
551 {
552 /* Record base type is bounded. */
553 sr->nbr_scalars = base->nbr_scalars;
554 sr->els = base->els;
555 }
556 else
557 {
558 /* Read subtypes. */
559 unsigned j;
560 int nbr_scalars;
561
562 sr->els = malloc (base->nbr_fields * sizeof (struct ghw_record_element));
563 nbr_scalars = 0;
564 for (j = 0; j < base->nbr_fields; j++)
565 {
566 union ghw_type *btype = base->els[j].type;
567 int el_nbr_scalars = get_nbr_elements (btype);
568
569 sr->els[j].name = base->els[j].name;
570 if (el_nbr_scalars >= 0)
571 {
572 /* Element is constrained. */
573 sr->els[j].type = btype;
574 }
575 else
576 {
577 switch (btype->kind)
578 {
579 case ghdl_rtik_type_array:
580 sr->els[j].type = (union ghw_type *)
581 ghw_read_array_subtype (h, &btype->ar);
582 break;
583 case ghdl_rtik_type_record:
584 sr->els[j].type = (union ghw_type *)
585 ghw_read_record_subtype (h, &btype->rec);
586 break;
587 default:
588 fprintf
589 (stderr, "ghw_read_record_subtype: unhandled kind %d\n",
590 btype->kind);
591 return NULL;
592 }
593 el_nbr_scalars = get_nbr_elements (sr->els[j].type);
594 }
595 nbr_scalars += el_nbr_scalars;
596 }
597 sr->nbr_scalars = nbr_scalars;
598 }
599 return sr;
600 }
601
602 int
603 ghw_read_type (struct ghw_handler *h)
604 {
605 unsigned char hdr[8];
606 unsigned i;
607
608 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
609 return -1;
610
611 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
612 return -1;
613 h->nbr_types = ghw_get_i32 (h, &hdr[4]);
614 h->types = (union ghw_type **)
615 malloc (h->nbr_types * sizeof (union ghw_type *));
616
617 for (i = 0; i < h->nbr_types; i++)
618 {
619 int t;
620
621 t = fgetc (h->stream);
622 if (t == EOF)
623 return -1;
624 /* printf ("type[%d]= %d\n", i, t); */
625 switch (t)
626 {
627 case ghdl_rtik_type_b2:
628 case ghdl_rtik_type_e8:
629 {
630 struct ghw_type_enum *e;
631 unsigned j;
632
633 e = malloc (sizeof (struct ghw_type_enum));
634 e->kind = t;
635 e->wkt = ghw_wkt_unknown;
636 e->name = ghw_read_strid (h);
637 if (ghw_read_uleb128 (h, &e->nbr) != 0)
638 goto err_b2;
639 e->lits = (const char **) malloc (e->nbr * sizeof (char *));
640 if (h->flag_verbose > 1)
641 printf ("enum %s:", e->name);
642 for (j = 0; j < e->nbr; j++)
643 {
644 e->lits[j] = ghw_read_strid (h);
645 if (h->flag_verbose > 1)
646 printf (" %s", e->lits[j]);
647 }
648 if (h->flag_verbose > 1)
649 printf ("\n");
650 h->types[i] = (union ghw_type *)e;
651 break;
652 err_b2:
653 free (e);
654 return -1;
655 }
656 break;
657 case ghdl_rtik_type_i32:
658 case ghdl_rtik_type_i64:
659 case ghdl_rtik_type_f64:
660 {
661 struct ghw_type_scalar *sc;
662
663 sc = malloc (sizeof (struct ghw_type_scalar));
664 sc->kind = t;
665 sc->name = ghw_read_strid (h);
666 if (h->flag_verbose > 1)
667 printf ("scalar: %s\n", sc->name);
668 h->types[i] = (union ghw_type *)sc;
669 }
670 break;
671 case ghdl_rtik_type_p32:
672 case ghdl_rtik_type_p64:
673 {
674 struct ghw_type_physical *ph;
675
676 ph = malloc (sizeof (struct ghw_type_physical));
677 ph->kind = t;
678 ph->name = ghw_read_strid (h);
679 ph->units = NULL;
680 if (h->version == 0)
681 ph->nbr_units = 0;
682 else
683 {
684 unsigned j;
685
686 if (ghw_read_uleb128 (h, &ph->nbr_units) != 0)
687 goto err_p32;
688 ph->units = malloc (ph->nbr_units * sizeof (struct ghw_unit));
689 for (j = 0; j < ph->nbr_units; j++)
690 {
691 ph->units[j].name = ghw_read_strid (h);
692 if (ghw_read_lsleb128 (h, &ph->units[j].val) < 0)
693 goto err_p32;
694 }
695 }
696 if (h->flag_verbose > 1)
697 printf ("physical: %s\n", ph->name);
698 h->types[i] = (union ghw_type *)ph;
699 break;
700 err_p32:
701 free (ph->units);
702 free (ph);
703 return -1;
704 }
705 break;
706 case ghdl_rtik_subtype_scalar:
707 {
708 struct ghw_subtype_scalar *ss;
709
710 ss = malloc (sizeof (struct ghw_subtype_scalar));
711 ss->kind = t;
712 ss->name = ghw_read_strid (h);
713 ss->base = ghw_read_typeid (h);
714 ss->rng = ghw_read_range (h);
715 if (h->flag_verbose > 1)
716 printf ("subtype scalar: %s\n", ss->name);
717 h->types[i] = (union ghw_type *)ss;
718 }
719 break;
720 case ghdl_rtik_type_array:
721 {
722 struct ghw_type_array *arr;
723 unsigned j;
724
725 arr = malloc (sizeof (struct ghw_type_array));
726 arr->kind = t;
727 arr->name = ghw_read_strid (h);
728 arr->el = ghw_read_typeid (h);
729 if (ghw_read_uleb128 (h, &arr->nbr_dim) != 0)
730 goto err_array;
731 arr->dims = (union ghw_type **)
732 malloc (arr->nbr_dim * sizeof (union ghw_type *));
733 for (j = 0; j < arr->nbr_dim; j++)
734 arr->dims[j] = ghw_read_typeid (h);
735 if (h->flag_verbose > 1)
736 printf ("array: %s\n", arr->name);
737 h->types[i] = (union ghw_type *)arr;
738 break;
739 err_array:
740 free (arr);
741 return -1;
742 }
743 break;
744 case ghdl_rtik_subtype_array:
745 {
746 struct ghw_subtype_array *sa;
747 const char *name;
748 struct ghw_type_array *base;
749
750 name = ghw_read_strid (h);
751 base = (struct ghw_type_array *)ghw_read_typeid (h);
752
753 sa = ghw_read_array_subtype (h, base);
754 sa->name = name;
755 h->types[i] = (union ghw_type *)sa;
756 if (h->flag_verbose > 1)
757 printf ("subtype array: %s (nbr_scalars=%d)\n",
758 sa->name, sa->nbr_scalars);
759 }
760 break;
761 case ghdl_rtik_type_record:
762 {
763 struct ghw_type_record *rec;
764 unsigned j;
765 int nbr_scalars;
766
767 rec = malloc (sizeof (struct ghw_type_record));
768 rec->kind = t;
769 rec->name = ghw_read_strid (h);
770 rec->els = NULL;
771 if (ghw_read_uleb128 (h, &rec->nbr_fields) != 0)
772 goto err_record;
773 rec->els = malloc
774 (rec->nbr_fields * sizeof (struct ghw_record_element));
775 nbr_scalars = 0;
776 for (j = 0; j < rec->nbr_fields; j++)
777 {
778 rec->els[j].name = ghw_read_strid (h);
779 rec->els[j].type = ghw_read_typeid (h);
780 if (nbr_scalars != -1)
781 {
782 int field_nbr_scalars = get_nbr_elements (rec->els[j].type);
783 if (field_nbr_scalars == -1)
784 nbr_scalars = -1;
785 else
786 nbr_scalars += field_nbr_scalars;
787 }
788 }
789 rec->nbr_scalars = nbr_scalars;
790 if (h->flag_verbose > 1)
791 printf ("record type: %s (nbr_scalars=%d)\n",
792 rec->name, rec->nbr_scalars);
793 h->types[i] = (union ghw_type *)rec;
794 break;
795 err_record:
796 free (rec->els);
797 free (rec);
798 return -1;
799 }
800 break;
801 case ghdl_rtik_subtype_record:
802 {
803 struct ghw_subtype_record *sr;
804 const char *name;
805 struct ghw_type_record *base;
806
807 name = ghw_read_strid (h);
808 base = (struct ghw_type_record *)ghw_read_typeid (h);
809
810 sr = ghw_read_record_subtype (h, base);
811 sr->name = name;
812 h->types[i] = (union ghw_type *)sr;
813 if (h->flag_verbose > 1)
814 printf ("subtype record: %s (nbr_scalars=%d)\n",
815 sr->name, sr->nbr_scalars);
816 }
817 break;
818 default:
819 fprintf (stderr, "ghw_read_type: unknown type %d\n", t);
820 return -1;
821 }
822 }
823 if (fgetc (h->stream) != 0)
824 return -1;
825 return 0;
826 }
827
828 int
829 ghw_read_wk_types (struct ghw_handler *h)
830 {
831 char hdr[4];
832
833 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
834 return -1;
835
836 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
837 return -1;
838
839 while (1)
840 {
841 int t;
842 union ghw_type *tid;
843
844 t = fgetc (h->stream);
845 if (t == EOF)
846 return -1;
847 else if (t == 0)
848 break;
849
850 tid = ghw_read_typeid (h);
851 if (tid->kind == ghdl_rtik_type_b2
852 || tid->kind == ghdl_rtik_type_e8)
853 {
854 if (h->flag_verbose > 0)
855 printf ("%s: wkt=%d\n", tid->en.name, t);
856 tid->en.wkt = t;
857 }
858 }
859 return 0;
860 }
861
862 void
863 ghw_disp_typename (struct ghw_handler *h, union ghw_type *t)
864 {
865 (void)h;
866 printf ("%s", t->common.name);
867 }
868
869 /* Read a signal composed of severals elements.
870 Return 0 for success. */
871 int
872 ghw_read_signal (struct ghw_handler *h, unsigned int *sigs, union ghw_type *t)
873 {
874 switch (t->kind)
875 {
876 case ghdl_rtik_type_b2:
877 case ghdl_rtik_type_e8:
878 case ghdl_rtik_type_e32:
879 case ghdl_rtik_subtype_scalar:
880 {
881 unsigned int sig_el;
882
883 if (ghw_read_uleb128 (h, &sig_el) < 0)
884 return -1;
885 *sigs = sig_el;
886 if (sig_el == 0 || sig_el >= h->nbr_sigs)
887 return -1;
888 if (h->sigs[sig_el].type == NULL)
889 h->sigs[sig_el].type = ghw_get_base_type (t);
890 }
891 return 0;
892 case ghdl_rtik_subtype_array:
893 {
894 int i;
895 int stride;
896 int len;
897
898 len = t->sa.nbr_scalars;
899 stride = get_nbr_elements (t->sa.base->el);
900
901 for (i = 0; i < len; i += stride)
902 if (ghw_read_signal (h, &sigs[i], t->sa.base->el) < 0)
903 return -1;
904 }
905 return 0;
906 case ghdl_rtik_type_record:
907 {
908 struct ghw_type_record *r = &t->rec;
909 int nbr_fields = r->nbr_fields;
910 int i;
911 int off;
912
913 off = 0;
914 for (i = 0; i < nbr_fields; i++)
915 {
916 if (ghw_read_signal (h, &sigs[off], r->els[i].type) < 0)
917 return -1;
918 off += get_nbr_elements (r->els[i].type);
919 }
920 }
921 return 0;
922 case ghdl_rtik_subtype_record:
923 {
924 struct ghw_subtype_record *sr = &t->sr;
925 int nbr_fields = sr->base->nbr_fields;
926 int i;
927 int off;
928
929 off = 0;
930 for (i = 0; i < nbr_fields; i++)
931 {
932 if (ghw_read_signal (h, &sigs[off], sr->els[i].type) < 0)
933 return -1;
934 off += get_nbr_elements (sr->els[i].type);
935 }
936 }
937 return 0;
938 default:
939 fprintf (stderr, "ghw_read_signal: type kind %d unhandled\n", t->kind);
940 abort ();
941 }
942 }
943
944
945 int
946 ghw_read_value (struct ghw_handler *h,
947 union ghw_val *val, union ghw_type *type)
948 {
949 switch (ghw_get_base_type (type)->kind)
950 {
951 case ghdl_rtik_type_b2:
952 {
953 int v;
954 v = fgetc (h->stream);
955 if (v == EOF)
956 return -1;
957 val->b2 = v;
958 }
959 break;
960 case ghdl_rtik_type_e8:
961 {
962 int v;
963 v = fgetc (h->stream);
964 if (v == EOF)
965 return -1;
966 val->e8 = v;
967 }
968 break;
969 case ghdl_rtik_type_i32:
970 case ghdl_rtik_type_p32:
971 {
972 int32_t v;
973 if (ghw_read_sleb128 (h, &v) < 0)
974 return -1;
975 val->i32 = v;
976 }
977 break;
978 case ghdl_rtik_type_f64:
979 {
980 double v;
981 if (ghw_read_f64 (h, &v) < 0)
982 return -1;
983 val->f64 = v;
984 }
985 break;
986 case ghdl_rtik_type_p64:
987 {
988 int64_t v;
989 if (ghw_read_lsleb128 (h, &v) < 0)
990 return -1;
991 val->i64 = v;
992 }
993 break;
994 default:
995 fprintf (stderr, "read_value: cannot handle format %d\n", type->kind);
996 abort ();
997 }
998 return 0;
999 }
1000
1001 int
1002 ghw_read_hie (struct ghw_handler *h)
1003 {
1004 unsigned char hdr[16];
1005 int nbr_scopes;
1006 int nbr_sigs;
1007 unsigned i;
1008 struct ghw_hie *blk;
1009 struct ghw_hie **last;
1010
1011 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1012 return -1;
1013
1014 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
1015 return -1;
1016 nbr_scopes = ghw_get_i32 (h, &hdr[4]);
1017 /* Number of declared signals (which may be composite). */
1018 nbr_sigs = ghw_get_i32 (h, &hdr[8]);
1019 /* Number of basic signals. */
1020 h->nbr_sigs = ghw_get_i32 (h, &hdr[12]);
1021
1022 if (h->flag_verbose)
1023 printf ("%u scopes, %u signals, %u signal elements\n",
1024 nbr_scopes, nbr_sigs, h->nbr_sigs);
1025
1026 blk = (struct ghw_hie *)malloc (sizeof (struct ghw_hie));
1027 blk->kind = ghw_hie_design;
1028 blk->name = NULL;
1029 blk->parent = NULL;
1030 blk->brother = NULL;
1031 blk->u.blk.child = NULL;
1032
1033 last = &blk->u.blk.child;
1034 h->hie = blk;
1035
1036 h->nbr_sigs++;
1037 h->skip_sigs = NULL;
1038 h->flag_full_names = 0;
1039 h->sigs = (struct ghw_sig *) malloc (h->nbr_sigs * sizeof (struct ghw_sig));
1040 memset (h->sigs, 0, h->nbr_sigs * sizeof (struct ghw_sig));
1041
1042 while (1)
1043 {
1044 int t;
1045 struct ghw_hie *el;
1046 unsigned int str;
1047
1048 t = fgetc (h->stream);
1049 if (t == EOF)
1050 return -1;
1051 if (t == 0)
1052 break;
1053
1054 if (t == ghw_hie_eos)
1055 {
1056 blk = blk->parent;
1057 if (blk->u.blk.child == NULL)
1058 last = &blk->u.blk.child;
1059 else
1060 {
1061 struct ghw_hie *l = blk->u.blk.child;
1062 while (l->brother != NULL)
1063 l = l->brother;
1064 last = &l->brother;
1065 }
1066
1067 continue;
1068 }
1069
1070 el = (struct ghw_hie *) malloc (sizeof (struct ghw_hie));
1071 el->kind = t;
1072 el->parent = blk;
1073 el->brother = NULL;
1074
1075 /* Link. */
1076 *last = el;
1077 last = &el->brother;
1078
1079 /* Read name. */
1080 if (ghw_read_uleb128 (h, &str) != 0)
1081 return -1;
1082 el->name = h->str_table[str];
1083
1084 switch (t)
1085 {
1086 case ghw_hie_eoh:
1087 case ghw_hie_design:
1088 case ghw_hie_eos:
1089 /* Should not be here. */
1090 abort ();
1091 case ghw_hie_process:
1092 break;
1093 case ghw_hie_block:
1094 case ghw_hie_generate_if:
1095 case ghw_hie_generate_for:
1096 case ghw_hie_instance:
1097 case ghw_hie_generic:
1098 case ghw_hie_package:
1099 /* Create a block. */
1100 el->u.blk.child = NULL;
1101
1102 if (t == ghw_hie_generate_for)
1103 {
1104 el->u.blk.iter_type = ghw_read_typeid (h);
1105 el->u.blk.iter_value = malloc (sizeof (union ghw_val));
1106 if (ghw_read_value (h, el->u.blk.iter_value,
1107 el->u.blk.iter_type) < 0)
1108 return -1;
1109 }
1110 blk = el;
1111 last = &el->u.blk.child;
1112 break;
1113 case ghw_hie_signal:
1114 case ghw_hie_port_in:
1115 case ghw_hie_port_out:
1116 case ghw_hie_port_inout:
1117 case ghw_hie_port_buffer:
1118 case ghw_hie_port_linkage:
1119 /* For a signal, read type. */
1120 {
1121 int nbr_el;
1122 unsigned int *sigs;
1123
1124 el->u.sig.type = ghw_read_typeid (h);
1125 nbr_el = get_nbr_elements (el->u.sig.type);
1126 if (nbr_el < 0)
1127 return -1;
1128 sigs = (unsigned int *) malloc
1129 ((nbr_el + 1) * sizeof (unsigned int));
1130 el->u.sig.sigs = sigs;
1131 /* Last element is NULL. */
1132 sigs[nbr_el] = 0;
1133
1134 if (h->flag_verbose > 1)
1135 printf ("signal %s: %d el [", el->name, nbr_el);
1136 if (ghw_read_signal (h, sigs, el->u.sig.type) < 0)
1137 return -1;
1138 if (h->flag_verbose > 1)
1139 {
1140 int j;
1141 for (j = 0; j < nbr_el; j++)
1142 printf (" #%u", sigs[j]);
1143 printf ("]\n");
1144 }
1145 }
1146 break;
1147 default:
1148 fprintf (stderr, "ghw_read_hie: unhandled kind %d\n", t);
1149 abort ();
1150 }
1151 }
1152
1153 /* Allocate values. */
1154 for (i = 0; i < h->nbr_sigs; i++)
1155 if (h->sigs[i].type != NULL)
1156 h->sigs[i].val = (union ghw_val *) malloc (sizeof (union ghw_val));
1157 return 0;
1158 }
1159
1160 const char *
1161 ghw_get_hie_name (struct ghw_hie *h)
1162 {
1163 switch (h->kind)
1164 {
1165 case ghw_hie_eoh:
1166 return "eoh";
1167 case ghw_hie_design:
1168 return "design";
1169 case ghw_hie_block:
1170 return "block";
1171 case ghw_hie_generate_if:
1172 return "generate-if";
1173 case ghw_hie_generate_for:
1174 return "generate-for";
1175 case ghw_hie_instance:
1176 return "instance";
1177 case ghw_hie_package:
1178 return "package";
1179 case ghw_hie_process:
1180 return "process";
1181 case ghw_hie_generic:
1182 return "generic";
1183 case ghw_hie_eos:
1184 return "eos";
1185 case ghw_hie_signal:
1186 return "signal";
1187 case ghw_hie_port_in:
1188 return "port-in";
1189 case ghw_hie_port_out:
1190 return "port-out";
1191 case ghw_hie_port_inout:
1192 return "port-inout";
1193 case ghw_hie_port_buffer:
1194 return "port-buffer";
1195 case ghw_hie_port_linkage:
1196 return "port-linkage";
1197 default:
1198 return "??";
1199 }
1200 }
1201
1202 void
1203 ghw_disp_value (union ghw_val *val, union ghw_type *type);
1204
1205 static void
1206 print_name (struct ghw_hie *hie, int full_names)
1207 {
1208 int i;
1209 int depth;
1210 struct ghw_hie *p;
1211 struct ghw_hie **buf;
1212 struct ghw_hie **end;
1213
1214 /* HIE must be valid. */
1215 assert (hie->name != NULL);
1216
1217 if (0 == full_names)
1218 {
1219 printf (" %s: ", hie->name);
1220 return;
1221 }
1222
1223 p = hie;
1224 depth = 0;
1225 while (p && p->name)
1226 {
1227 p = p->parent;
1228 ++depth;
1229 }
1230 buf = (struct ghw_hie **) malloc (depth * sizeof (struct ghw_hie *));
1231
1232 p = hie;
1233 end = depth + buf;
1234 while (p && p->name)
1235 {
1236 *(--end) = p;
1237 p = p->parent;
1238 }
1239
1240 putchar (' ');
1241 putchar ('/');
1242 for (i = 0; i < depth; ++i)
1243 {
1244 printf ("%s%s", i ? "/" : "", buf[i]->name);
1245 if (ghw_hie_generate_for == buf[i]->kind)
1246 {
1247 putchar ('(');
1248 ghw_disp_value (buf[i]->u.blk.iter_value, buf[i]->u.blk.iter_type);
1249 putchar (')');
1250 }
1251 }
1252 putchar (':');
1253 putchar (' ');
1254 free (buf);
1255 }
1256
1257 void
1258 ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
1259 {
1260 int i;
1261 int indent;
1262 struct ghw_hie *hie;
1263 struct ghw_hie *n;
1264
1265 hie = top;
1266 indent = 0;
1267
1268 while (1)
1269 {
1270 if (0 == h->flag_full_names)
1271 for (i = 0; i < indent; i++)
1272 fputc (' ', stdout);
1273 printf ("%s", ghw_get_hie_name (hie));
1274
1275 switch (hie->kind)
1276 {
1277 case ghw_hie_design:
1278 case ghw_hie_block:
1279 case ghw_hie_generate_if:
1280 case ghw_hie_generate_for:
1281 case ghw_hie_instance:
1282 case ghw_hie_process:
1283 case ghw_hie_package:
1284 if (hie->name)
1285 print_name (hie, h->flag_full_names);
1286 if (hie->kind == ghw_hie_generate_for)
1287 {
1288 printf ("(");
1289 ghw_disp_value (hie->u.blk.iter_value, hie->u.blk.iter_type);
1290 printf (")");
1291 }
1292 n = hie->u.blk.child;
1293 if (n == NULL)
1294 n = hie->brother;
1295 else
1296 indent++;
1297 break;
1298 case ghw_hie_generic:
1299 case ghw_hie_eos:
1300 abort ();
1301 case ghw_hie_signal:
1302 case ghw_hie_port_in:
1303 case ghw_hie_port_out:
1304 case ghw_hie_port_inout:
1305 case ghw_hie_port_buffer:
1306 case ghw_hie_port_linkage:
1307 {
1308 unsigned int *sigs = hie->u.sig.sigs;
1309 unsigned int k, num;
1310
1311 print_name (hie, h->flag_full_names);
1312 ghw_disp_subtype_indication (h, hie->u.sig.type);
1313 printf (":");
1314 k = 0;
1315 assert (sigs[0] != GHW_NO_SIG);
1316 while (1)
1317 {
1318 /* First signal of the range. */
1319 printf (" #%u", sigs[k]);
1320 for (num = 1; sigs[k + num] != GHW_NO_SIG; num++)
1321 if (sigs[k + num] != sigs[k + num - 1] + 1)
1322 break;
1323 if (num > 1)
1324 printf ("-#%u", sigs[k + num - 1]);
1325 k += num;
1326 /* End of signals ? */
1327 if (sigs[k] == GHW_NO_SIG)
1328 break;
1329 }
1330 n = hie->brother;
1331 }
1332 break;
1333 default:
1334 abort ();
1335 }
1336 printf ("\n");
1337
1338 while (n == NULL)
1339 {
1340 if (hie->parent == NULL)
1341 return;
1342 hie = hie->parent;
1343 indent--;
1344 n = hie->brother;
1345 }
1346 hie = n;
1347 }
1348 }
1349
1350 int
1351 ghw_read_eoh (struct ghw_handler *h)
1352 {
1353 (void)h;
1354 return 0;
1355 }
1356
1357 int
1358 ghw_read_base (struct ghw_handler *h)
1359 {
1360 unsigned char hdr[4];
1361 int res;
1362
1363 while (1)
1364 {
1365 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1366 return -1;
1367 if (memcmp (hdr, "STR", 4) == 0)
1368 res = ghw_read_str (h);
1369 else if (memcmp (hdr, "HIE", 4) == 0)
1370 res = ghw_read_hie (h);
1371 else if (memcmp (hdr, "TYP", 4) == 0)
1372 res = ghw_read_type (h);
1373 else if (memcmp (hdr, "WKT", 4) == 0)
1374 res = ghw_read_wk_types (h);
1375 else if (memcmp (hdr, "EOH", 4) == 0)
1376 return 0;
1377 else
1378 {
1379 fprintf (stderr, "ghw_read_base: unknown GHW section %c%c%c%c\n",
1380 hdr[0], hdr[1], hdr[2], hdr[3]);
1381 return -1;
1382 }
1383 if (res != 0)
1384 {
1385 fprintf (stderr, "ghw_read_base: error in section %s\n", hdr);
1386 return res;
1387 }
1388 }
1389 }
1390
1391 int
1392 ghw_read_signal_value (struct ghw_handler *h, struct ghw_sig *s)
1393 {
1394 return ghw_read_value (h, s->val, s->type);
1395 }
1396
1397 int
1398 ghw_read_snapshot (struct ghw_handler *h)
1399 {
1400 unsigned char hdr[12];
1401 unsigned i;
1402 struct ghw_sig *s;
1403
1404 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1405 return -1;
1406
1407 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
1408 return -1;
1409 h->snap_time = ghw_get_i64 (h, &hdr[4]);
1410 if (h->flag_verbose > 1)
1411 printf ("Time is " GHWPRI64 " fs\n", h->snap_time);
1412
1413 for (i = 0; i < h->nbr_sigs; i++)
1414 {
1415 s = &h->sigs[i];
1416 if (s->type != NULL)
1417 {
1418 if (h->flag_verbose > 1)
1419 printf ("read type %d for sig %u\n", s->type->kind, i);
1420 if (ghw_read_signal_value (h, s) < 0)
1421 return -1;
1422 }
1423 }
1424 if (fread (hdr, 4, 1, h->stream) != 1)
1425 return -1;
1426
1427 if (memcmp (hdr, "ESN", 4))
1428 return -1;
1429
1430 return 0;
1431 }
1432
1433 void ghw_disp_values (struct ghw_handler *h);
1434
1435 int
1436 ghw_read_cycle_start (struct ghw_handler *h)
1437 {
1438 unsigned char hdr[8];
1439
1440 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1441 return -1;
1442
1443 h->snap_time = ghw_get_i64 (h, hdr);
1444 return 0;
1445 }
1446
1447 int
1448 ghw_read_cycle_cont (struct ghw_handler *h, int *list)
1449 {
1450 int i;
1451 int *list_p;
1452
1453 i = 0;
1454 list_p = list;
1455 while (1)
1456 {
1457 uint32_t d;
1458
1459 /* Read delta to next signal. */
1460 if (ghw_read_uleb128 (h, &d) < 0)
1461 return -1;
1462 if (d == 0)
1463 {
1464 /* Last signal reached. */
1465 break;
1466 }
1467
1468 /* Find next signal. */
1469 while (d > 0)
1470 {
1471 i++;
1472 if (h->sigs[i].type != NULL)
1473 d--;
1474 }
1475
1476 if (ghw_read_signal_value (h, &h->sigs[i]) < 0)
1477 return -1;
1478 if (list_p)
1479 *list_p++ = i;
1480 }
1481
1482 if (list_p)
1483 *list_p = 0;
1484 return 0;
1485 }
1486
1487 int
1488 ghw_read_cycle_next (struct ghw_handler *h)
1489 {
1490 int64_t d_time;
1491
1492 if (ghw_read_lsleb128 (h, &d_time) < 0)
1493 return -1;
1494 if (d_time == -1)
1495 return 0;
1496 h->snap_time += d_time;
1497 return 1;
1498 }
1499
1500
1501 int
1502 ghw_read_cycle_end (struct ghw_handler *h)
1503 {
1504 char hdr[4];
1505
1506 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1507 return -1;
1508 if (memcmp (hdr, "ECY", 4))
1509 return -1;
1510
1511 return 0;
1512 }
1513
1514 static const char *
1515 ghw_get_lit (union ghw_type *type, unsigned e)
1516 {
1517 if (e >= type->en.nbr)
1518 return "??";
1519 else
1520 return type->en.lits[e];
1521 }
1522
1523 static void
1524 ghw_disp_lit (union ghw_type *type, unsigned e)
1525 {
1526 printf ("%s (%u)", ghw_get_lit (type, e), e);
1527 }
1528
1529 void
1530 ghw_disp_value (union ghw_val *val, union ghw_type *type)
1531 {
1532 switch (ghw_get_base_type (type)->kind)
1533 {
1534 case ghdl_rtik_type_b2:
1535 ghw_disp_lit (type, val->b2);
1536 break;
1537 case ghdl_rtik_type_e8:
1538 ghw_disp_lit (type, val->e8);
1539 break;
1540 case ghdl_rtik_type_i32:
1541 printf (GHWPRI32, val->i32);
1542 break;
1543 case ghdl_rtik_type_p64:
1544 printf (GHWPRI64, val->i64);
1545 break;
1546 case ghdl_rtik_type_f64:
1547 printf ("%g", val->f64);
1548 break;
1549 default:
1550 fprintf (stderr, "ghw_disp_value: cannot handle type %d\n",
1551 type->kind);
1552 abort ();
1553 }
1554 }
1555
1556 /* Put the ASCII representation of VAL into BUF, whose size if LEN.
1557 A NUL is always written to BUF.
1558 */
1559 void
1560 ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type)
1561 {
1562 union ghw_type *base = ghw_get_base_type (type);
1563
1564 switch (base->kind)
1565 {
1566 case ghdl_rtik_type_b2:
1567 if (val->b2 <= 1)
1568 {
1569 strncpy (buf, base->en.lits[val->b2], len - 1);
1570 buf[len - 1] = 0;
1571 }
1572 else
1573 {
1574 snprintf (buf, len, "?%d", val->b2);
1575 }
1576 break;
1577 case ghdl_rtik_type_e8:
1578 if (val->b2 <= base->en.nbr)
1579 {
1580 strncpy (buf, base->en.lits[val->e8], len - 1);
1581 buf[len - 1] = 0;
1582 }
1583 else
1584 {
1585 snprintf (buf, len, "?%d", val->e8);
1586 }
1587 break;
1588 case ghdl_rtik_type_i32:
1589 snprintf (buf, len, GHWPRI32, val->i32);
1590 break;
1591 case ghdl_rtik_type_p64:
1592 snprintf (buf, len, GHWPRI64, val->i64);
1593 break;
1594 case ghdl_rtik_type_f64:
1595 snprintf (buf, len, "%g", val->f64);
1596 break;
1597 default:
1598 snprintf (buf, len, "?bad type %d?", type->kind);
1599 }
1600 }
1601
1602 static char
1603 is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal)
1604 {
1605 int i;
1606 for (i = 0; i < nb_signals_to_keep; ++i)
1607 {
1608 if (signal == signals_to_keep[i])
1609 {
1610 return 0;
1611 }
1612 }
1613 return 1;
1614 }
1615
1616 void
1617 ghw_filter_signals (struct ghw_handler *h,
1618 int *signals_to_keep, int nb_signals_to_keep)
1619 {
1620 unsigned i;
1621
1622 if (0 < nb_signals_to_keep && 0 != signals_to_keep)
1623 {
1624 if (0 == h->skip_sigs)
1625 {
1626 h->skip_sigs = (char *) malloc (sizeof (char) * h->nbr_sigs);
1627 }
1628 for (i = 0; i < h->nbr_sigs; ++i)
1629 {
1630 h->skip_sigs[i] = is_skip_signal (signals_to_keep,
1631 nb_signals_to_keep, i);
1632 }
1633 }
1634 else
1635 {
1636 if (0 != h->skip_sigs)
1637 {
1638 free (h->skip_sigs);
1639 h->skip_sigs = 0;
1640 }
1641 }
1642 }
1643
1644 void
1645 ghw_disp_values (struct ghw_handler *h)
1646 {
1647 unsigned i;
1648 for (i = 0; i < h->nbr_sigs; i++)
1649 {
1650 struct ghw_sig *s = &h->sigs[i];
1651 int skip = (0 != h->skip_sigs && (0 != h->skip_sigs[i]));
1652 if (s->type != NULL && !skip)
1653 {
1654 printf ("#%u: ", i);
1655 ghw_disp_value (s->val, s->type);
1656 printf ("\n");
1657 }
1658 }
1659 }
1660 int
1661 ghw_read_directory (struct ghw_handler *h)
1662 {
1663 unsigned char hdr[8];
1664 int nbr_entries;
1665 int i;
1666
1667 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1668 return -1;
1669
1670 nbr_entries = ghw_get_i32 (h, &hdr[4]);
1671
1672 if (h->flag_verbose)
1673 printf ("Directory (%d entries):\n", nbr_entries);
1674
1675 for (i = 0; i < nbr_entries; i++)
1676 {
1677 unsigned char ent[8];
1678 int pos;
1679
1680 if (fread (ent, sizeof (ent), 1, h->stream) != 1)
1681 return -1;
1682
1683 pos = ghw_get_i32 (h, &ent[4]);
1684 if (h->flag_verbose)
1685 printf (" %s at %d\n", ent, pos);
1686 }
1687
1688 if (fread (hdr, 4, 1, h->stream) != 1)
1689 return -1;
1690 if (memcmp (hdr, "EOD", 4))
1691 return -1;
1692 return 0;
1693 }
1694
1695 int
1696 ghw_read_tailer (struct ghw_handler *h)
1697 {
1698 unsigned char hdr[8];
1699 int pos;
1700
1701 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1702 return -1;
1703
1704 pos = ghw_get_i32 (h, &hdr[4]);
1705
1706 if (h->flag_verbose)
1707 printf ("Tailer: directory at %d\n", pos);
1708 return 0;
1709 }
1710
1711 enum ghw_res
1712 ghw_read_sm_hdr (struct ghw_handler *h, int *list)
1713 {
1714 unsigned char hdr[4];
1715 int res;
1716
1717 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1718 {
1719 if (feof (h->stream))
1720 return ghw_res_eof;
1721 else
1722 return ghw_res_error;
1723 }
1724 if (memcmp (hdr, "SNP", 4) == 0)
1725 {
1726 res = ghw_read_snapshot (h);
1727 if (res < 0)
1728 return res;
1729 return ghw_res_snapshot;
1730 }
1731 else if (memcmp (hdr, "CYC", 4) == 0)
1732 {
1733 res = ghw_read_cycle_start (h);
1734 if (res < 0)
1735 return res;
1736 res = ghw_read_cycle_cont (h, list);
1737 if (res < 0)
1738 return res;
1739
1740 return ghw_res_cycle;
1741 }
1742 else if (memcmp (hdr, "DIR", 4) == 0)
1743 {
1744 res = ghw_read_directory (h);
1745 }
1746 else if (memcmp (hdr, "TAI", 4) == 0)
1747 {
1748 res = ghw_read_tailer (h);
1749 }
1750 else
1751 {
1752 fprintf (stderr, "unknown GHW section %c%c%c%c\n",
1753 hdr[0], hdr[1], hdr[2], hdr[3]);
1754 return -1;
1755 }
1756 if (res != 0)
1757 return res;
1758 return ghw_res_other;
1759 }
1760
1761 int
1762 ghw_read_sm (struct ghw_handler *h, enum ghw_sm_type *sm)
1763 {
1764 int res;
1765
1766 while (1)
1767 {
1768 /* printf ("sm: state = %d\n", *sm); */
1769 switch (*sm)
1770 {
1771 case ghw_sm_init:
1772 case ghw_sm_sect:
1773 res = ghw_read_sm_hdr (h, NULL);
1774 switch (res)
1775 {
1776 case ghw_res_other:
1777 break;
1778 case ghw_res_snapshot:
1779 *sm = ghw_sm_sect;
1780 return res;
1781 case ghw_res_cycle:
1782 *sm = ghw_sm_cycle;
1783 return res;
1784 default:
1785 return res;
1786 }
1787 break;
1788 case ghw_sm_cycle:
1789 if (0)
1790 printf ("Time is " GHWPRI64 " fs\n", h->snap_time);
1791 if (0)
1792 ghw_disp_values (h);
1793
1794 res = ghw_read_cycle_next (h);
1795 if (res < 0)
1796 return res;
1797 if (res == 1)
1798 {
1799 res = ghw_read_cycle_cont (h, NULL);
1800 if (res < 0)
1801 return res;
1802 return ghw_res_cycle;
1803 }
1804 res = ghw_read_cycle_end (h);
1805 if (res < 0)
1806 return res;
1807 *sm = ghw_sm_sect;
1808 break;
1809 }
1810 }
1811 }
1812
1813 int
1814 ghw_read_cycle (struct ghw_handler *h)
1815 {
1816 int res;
1817
1818 res = ghw_read_cycle_start (h);
1819 if (res < 0)
1820 return res;
1821 while (1)
1822 {
1823 res = ghw_read_cycle_cont (h, NULL);
1824 if (res < 0)
1825 return res;
1826
1827 if (0)
1828 printf ("Time is " GHWPRI64 " fs\n", h->snap_time);
1829 if (0)
1830 ghw_disp_values (h);
1831
1832
1833 res = ghw_read_cycle_next (h);
1834 if (res < 0)
1835 return res;
1836 if (res == 0)
1837 break;
1838 }
1839 res = ghw_read_cycle_end (h);
1840 return res;
1841 }
1842
1843 int
1844 ghw_read_dump (struct ghw_handler *h)
1845 {
1846 unsigned char hdr[4];
1847 int res;
1848
1849 while (1)
1850 {
1851 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1852 {
1853 if (feof (h->stream))
1854 return 0;
1855 else
1856 return -1;
1857 }
1858 if (memcmp (hdr, "SNP", 4) == 0)
1859 {
1860 res = ghw_read_snapshot (h);
1861 if (0 && res >= 0)
1862 ghw_disp_values (h);
1863 }
1864 else if (memcmp (hdr, "CYC", 4) == 0)
1865 {
1866 res = ghw_read_cycle (h);
1867 }
1868 else if (memcmp (hdr, "DIR", 4) == 0)
1869 {
1870 res = ghw_read_directory (h);
1871 }
1872 else if (memcmp (hdr, "TAI", 4) == 0)
1873 {
1874 res = ghw_read_tailer (h);
1875 }
1876 else
1877 {
1878 fprintf (stderr, "unknown GHW section %c%c%c%c\n",
1879 hdr[0], hdr[1], hdr[2], hdr[3]);
1880 return -1;
1881 }
1882 if (res != 0)
1883 return res;
1884 }
1885 }
1886
1887 struct ghw_section ghw_sections[] = {
1888 { "\0\0\0", NULL },
1889 { "STR", ghw_read_str },
1890 { "HIE", ghw_read_hie },
1891 { "TYP", ghw_read_type },
1892 { "WKT", ghw_read_wk_types },
1893 { "EOH", ghw_read_eoh },
1894 { "SNP", ghw_read_snapshot },
1895 { "CYC", ghw_read_cycle },
1896 { "DIR", ghw_read_directory },
1897 { "TAI", ghw_read_tailer }
1898 };
1899
1900 int
1901 ghw_read_section (struct ghw_handler *h)
1902 {
1903 unsigned char hdr[4];
1904 unsigned i;
1905
1906 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1907 {
1908 if (feof (h->stream))
1909 return -2;
1910 else
1911 return -1;
1912 }
1913
1914 for (i = 1; i < sizeof (ghw_sections) / sizeof (*ghw_sections); i++)
1915 if (memcmp (hdr, ghw_sections[i].name, 4) == 0)
1916 return i;
1917
1918 fprintf (stderr, "ghw_read_section: unknown GHW section %c%c%c%c\n",
1919 hdr[0], hdr[1], hdr[2], hdr[3]);
1920 return 0;
1921 }
1922
1923 void
1924 ghw_close (struct ghw_handler *h)
1925 {
1926 if (h->stream)
1927 {
1928 if (h->stream_ispipe)
1929 pclose (h->stream);
1930 else
1931 fclose (h->stream);
1932
1933 h->stream = NULL;
1934 }
1935 }
1936
1937 const char *
1938 ghw_get_dir (int is_downto)
1939 {
1940 return is_downto ? "downto" : "to";
1941 }
1942
1943 void
1944 ghw_disp_range (union ghw_type *type, union ghw_range *rng)
1945 {
1946 switch (rng->kind)
1947 {
1948 case ghdl_rtik_type_b2:
1949 printf ("%s %s %s", ghw_get_lit (type, rng->b2.left),
1950 ghw_get_dir (rng->b2.dir), ghw_get_lit (type, rng->b2.right));
1951 break;
1952 case ghdl_rtik_type_e8:
1953 printf ("%s %s %s", ghw_get_lit (type, rng->e8.left),
1954 ghw_get_dir (rng->e8.dir), ghw_get_lit (type, rng->e8.right));
1955 break;
1956 case ghdl_rtik_type_i32:
1957 case ghdl_rtik_type_p32:
1958 printf (GHWPRI32 " %s " GHWPRI32,
1959 rng->i32.left, ghw_get_dir (rng->i32.dir), rng->i32.right);
1960 break;
1961 case ghdl_rtik_type_i64:
1962 case ghdl_rtik_type_p64:
1963 printf (GHWPRI64 " %s " GHWPRI64,
1964 rng->i64.left, ghw_get_dir (rng->i64.dir), rng->i64.right);
1965 break;
1966 case ghdl_rtik_type_f64:
1967 printf ("%g %s %g",
1968 rng->f64.left, ghw_get_dir (rng->f64.dir), rng->f64.right);
1969 break;
1970 default:
1971 printf ("?(%d)", rng->kind);
1972 }
1973 }
1974
1975 static void
1976 ghw_disp_array_subtype_bounds (struct ghw_subtype_array *a)
1977 {
1978 unsigned i;
1979
1980 printf (" (");
1981 for (i = 0; i < a->base->nbr_dim; i++)
1982 {
1983 if (i != 0)
1984 printf (", ");
1985 ghw_disp_range (a->base->dims[i], a->rngs[i]);
1986 }
1987 printf (")");
1988 }
1989
1990 static void
1991 ghw_disp_record_subtype_bounds (struct ghw_subtype_record *sr)
1992 {
1993 struct ghw_type_record *base = sr->base;
1994 int is_first = 1;
1995 unsigned i;
1996
1997 for (i = 0; i < base->nbr_fields; i++)
1998 {
1999 if (sr->els[i].type != base->els[i].type)
2000 {
2001 if (is_first)
2002 {
2003 printf ("(");
2004 is_first = 0;
2005 }
2006 else
2007 printf (", ");
2008 printf ("%s", base->els[i].name);
2009 switch (sr->els[i].type->kind)
2010 {
2011 case ghdl_rtik_subtype_array:
2012 ghw_disp_array_subtype_bounds (&sr->els[i].type->sa);
2013 break;
2014 case ghdl_rtik_subtype_record:
2015 ghw_disp_record_subtype_bounds (&sr->els[i].type->sr);
2016 break;
2017 default:
2018 printf ("??? (%d)", sr->els[i].type->kind);
2019 }
2020 }
2021 }
2022 if (!is_first)
2023 printf (")");
2024 }
2025
2026 static void
2027 ghw_disp_subtype_definition (struct ghw_handler *h, union ghw_type *t)
2028 {
2029 switch (t->kind)
2030 {
2031 case ghdl_rtik_subtype_scalar:
2032 {
2033 struct ghw_subtype_scalar *s = &t->ss;
2034 ghw_disp_typename (h, s->base);
2035 printf (" range ");
2036 ghw_disp_range (s->base, s->rng);
2037 }
2038 break;
2039 case ghdl_rtik_subtype_array:
2040 {
2041 struct ghw_subtype_array *a = &t->sa;
2042
2043 ghw_disp_typename (h, (union ghw_type *)a->base);
2044 ghw_disp_array_subtype_bounds (a);
2045 }
2046 break;
2047 case ghdl_rtik_subtype_record:
2048 {
2049 struct ghw_subtype_record *sr = &t->sr;
2050
2051 ghw_disp_typename (h, (union ghw_type *)sr->base);
2052 ghw_disp_record_subtype_bounds (sr);
2053 }
2054 break;
2055 default:
2056 printf ("ghw_disp_subtype_definition: unhandled type kind %d\n",
2057 t->kind);
2058 }
2059 }
2060
2061 static int
2062 ghw_is_anonymous_type (struct ghw_handler *h, union ghw_type *t)
2063 {
2064 return t->common.name == h->str_table[0];
2065 }
2066
2067 void
2068 ghw_disp_subtype_indication (struct ghw_handler *h, union ghw_type *t)
2069 {
2070 if (ghw_is_anonymous_type (h, t))
2071 {
2072 /* Anonymous subtype. */
2073 ghw_disp_subtype_definition (h, t);
2074 }
2075 else
2076 ghw_disp_typename (h, t);
2077 }
2078
2079 void
2080 ghw_disp_type (struct ghw_handler *h, union ghw_type *t)
2081 {
2082 switch (t->kind)
2083 {
2084 case ghdl_rtik_type_b2:
2085 case ghdl_rtik_type_e8:
2086 {
2087 struct ghw_type_enum *e = &t->en;
2088 unsigned i;
2089
2090 printf ("type %s is (", e->name);
2091 for (i = 0; i < e->nbr; i++)
2092 {
2093 if (i != 0)
2094 printf (", ");
2095 printf ("%s", e->lits[i]);
2096 }
2097 printf (");");
2098 if (e->wkt != ghw_wkt_unknown)
2099 printf (" -- WKT:%d", e->wkt);
2100 printf ("\n");
2101 }
2102 break;
2103 case ghdl_rtik_type_i32:
2104 case ghdl_rtik_type_f64:
2105 {
2106 struct ghw_type_scalar *s = &t->sc;
2107 printf ("type %s is range <>;\n", s->name);
2108 }
2109 break;
2110 case ghdl_rtik_type_p32:
2111 case ghdl_rtik_type_p64:
2112 {
2113 unsigned i;
2114
2115 struct ghw_type_physical *p = &t->ph;
2116 printf ("type %s is range <> units\n", p->name);
2117 for (i = 0; i < p->nbr_units; i++)
2118 {
2119 struct ghw_unit *u = &p->units[i];
2120 printf (" %s = " GHWPRI64 " %s;\n",
2121 u->name, u->val, p->units[0].name);
2122 }
2123 printf ("end units\n");
2124 }
2125 break;
2126 case ghdl_rtik_type_array:
2127 {
2128 struct ghw_type_array *a = &t->ar;
2129 unsigned i;
2130
2131 printf ("type %s is array (", a->name);
2132 for (i = 0; i < a->nbr_dim; i++)
2133 {
2134 if (i != 0)
2135 printf (", ");
2136 ghw_disp_typename (h, a->dims[i]);
2137 printf (" range <>");
2138 }
2139 printf (") of ");
2140 ghw_disp_subtype_indication (h, a->el);
2141 printf (";\n");
2142 }
2143 break;
2144 case ghdl_rtik_type_record:
2145 {
2146 struct ghw_type_record *r = &t->rec;
2147 unsigned i;
2148
2149 printf ("type %s is record\n", r->name);
2150 for (i = 0; i < r->nbr_fields; i++)
2151 {
2152 printf (" %s: ", r->els[i].name);
2153 ghw_disp_subtype_indication (h, r->els[i].type);
2154 printf (";\n");
2155 }
2156 printf ("end record;\n");
2157 }
2158 break;
2159 case ghdl_rtik_subtype_array:
2160 case ghdl_rtik_subtype_scalar:
2161 case ghdl_rtik_subtype_record:
2162 {
2163 struct ghw_type_common *c = &t->common;
2164 printf ("subtype %s is ", c->name);
2165 ghw_disp_subtype_definition (h, t);
2166 printf (";\n");
2167 }
2168 break;
2169 default:
2170 printf ("ghw_disp_type: unhandled type kind %d\n", t->kind);
2171 }
2172 }
2173
2174 void
2175 ghw_disp_types (struct ghw_handler *h)
2176 {
2177 unsigned i;
2178
2179 for (i = 0; i < h->nbr_types; i++)
2180 if (h->flag_verbose || !ghw_is_anonymous_type (h, h->types[i]))
2181 ghw_disp_type (h, h->types[i]);
2182 }
+0
-445
src/ghwlib.h less more
0 /* GHDL Wavefile reader library.
1 Copyright (C) 2005-2017 Tristan Gingold
2
3 GHDL is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 2, or (at your option) any later
6 version.
7
8 GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with GCC; see the file COPYING. If not, write to the Free
15 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
16 02111-1307, USA.
17 */
18
19
20 #ifndef _GHWLIB_H_
21 #define _GHWLIB_H_
22
23 #include <stdio.h>
24 #include <stdlib.h>
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 /* The ghwlib uses the standard c99 int32_t and int64_t. They are declared
31 in stdint.h. Header inttypes.h includes stdint.h and provides macro for
32 printf and co specifiers. Use it if known to be available. */
33
34 #if defined(__cplusplus) \
35 || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
36 || defined(HAVE_INTTYPES_H)
37 /* Use C99 standard header. */
38 # include <inttypes.h>
39 # define GHWPRI64 "%"PRId64
40 # define GHWPRI32 "%"PRId32
41 #else
42 # include <stdint.h>
43 # define GHWPRI64 "%lld"
44 # define GHWPRI32 "%d"
45 #endif
46
47 enum ghdl_rtik {
48 ghdl_rtik_top, /* 0 */
49 ghdl_rtik_library,
50 ghdl_rtik_package,
51 ghdl_rtik_package_body,
52 ghdl_rtik_entity,
53 ghdl_rtik_architecture, /* 5 */
54 ghdl_rtik_process,
55 ghdl_rtik_block,
56 ghdl_rtik_if_generate,
57 ghdl_rtik_for_generate,
58 ghdl_rtik_instance,
59 ghdl_rtik_constant,
60 ghdl_rtik_iterator,
61 ghdl_rtik_variable,
62 ghdl_rtik_signal,
63 ghdl_rtik_file,
64 ghdl_rtik_port,
65 ghdl_rtik_generic,
66 ghdl_rtik_alias,
67 ghdl_rtik_guard,
68 ghdl_rtik_component,
69 ghdl_rtik_attribute,
70 ghdl_rtik_type_b2, /* 22 */
71 ghdl_rtik_type_e8,
72 ghdl_rtik_type_e32,
73 ghdl_rtik_type_i32, /* 25 */
74 ghdl_rtik_type_i64,
75 ghdl_rtik_type_f64,
76 ghdl_rtik_type_p32,
77 ghdl_rtik_type_p64,
78 ghdl_rtik_type_access, /* 30 */
79 ghdl_rtik_type_array,
80 ghdl_rtik_type_record,
81 ghdl_rtik_type_file,
82 ghdl_rtik_subtype_scalar,
83 ghdl_rtik_subtype_array, /* 35 */
84 ghdl_rtik_subtype_array_ptr, /* Obsolete. */
85 ghdl_rtik_subtype_unconstrained_array, /* Obsolete. */
86 ghdl_rtik_subtype_record,
87 ghdl_rtik_subtype_access,
88 ghdl_rtik_type_protected,
89 ghdl_rtik_element,
90 ghdl_rtik_unit,
91 ghdl_rtik_attribute_transaction,
92 ghdl_rtik_attribute_quiet,
93 ghdl_rtik_attribute_stable,
94 ghdl_rtik_error
95 };
96
97 /* Well-known types. */
98 enum ghw_wkt_type {
99 ghw_wkt_unknown,
100 ghw_wkt_boolean,
101 ghw_wkt_bit,
102 ghw_wkt_std_ulogic
103 };
104
105 struct ghw_range_b2
106 {
107 enum ghdl_rtik kind : 8;
108 int dir : 8; /* 0: to, !0: downto. */
109 unsigned char left;
110 unsigned char right;
111 };
112
113 struct ghw_range_e8
114 {
115 enum ghdl_rtik kind : 8;
116 int dir : 8; /* 0: to, !0: downto. */
117 unsigned char left;
118 unsigned char right;
119 };
120
121 struct ghw_range_i32
122 {
123 enum ghdl_rtik kind : 8;
124 int dir : 8; /* 0: to, !0: downto. */
125 int32_t left;
126 int32_t right;
127 };
128
129 struct ghw_range_i64
130 {
131 enum ghdl_rtik kind : 8;
132 int dir : 8;
133 int64_t left;
134 int64_t right;
135 };
136
137 struct ghw_range_f64
138 {
139 enum ghdl_rtik kind : 8;
140 int dir : 8;
141 double left;
142 double right;
143 };
144
145 union ghw_range
146 {
147 enum ghdl_rtik kind : 8;
148 struct ghw_range_b2 b2;
149 struct ghw_range_e8 e8;
150 struct ghw_range_i32 i32;
151 struct ghw_range_i64 i64;
152 struct ghw_range_f64 f64;
153 };
154
155 /* Note: the first two fields must be kind and name. */
156 union ghw_type;
157
158 struct ghw_type_common
159 {
160 enum ghdl_rtik kind;
161 const char *name;
162 };
163
164 struct ghw_type_enum
165 {
166 enum ghdl_rtik kind;
167 const char *name;
168
169 enum ghw_wkt_type wkt;
170 unsigned int nbr;
171 const char **lits;
172 };
173
174 struct ghw_type_scalar
175 {
176 enum ghdl_rtik kind;
177 const char *name;
178 };
179
180 struct ghw_unit
181 {
182 const char *name;
183 int64_t val;
184 };
185
186 struct ghw_type_physical
187 {
188 enum ghdl_rtik kind;
189 const char *name;
190 uint32_t nbr_units;
191 struct ghw_unit *units;
192 };
193
194 struct ghw_type_array
195 {
196 enum ghdl_rtik kind;
197 const char *name;
198
199 unsigned int nbr_dim;
200 union ghw_type *el;
201 union ghw_type **dims;
202 };
203
204 struct ghw_subtype_array
205 {
206 enum ghdl_rtik kind;
207 const char *name;
208
209 struct ghw_type_array *base;
210 int nbr_scalars;
211 union ghw_range **rngs;
212 };
213
214 struct ghw_subtype_scalar
215 {
216 enum ghdl_rtik kind;
217 const char *name;
218
219 union ghw_type *base;
220 union ghw_range *rng;
221 };
222
223 struct ghw_record_element
224 {
225 const char *name;
226 union ghw_type *type;
227 };
228
229 struct ghw_type_record
230 {
231 enum ghdl_rtik kind;
232 const char *name;
233
234 unsigned int nbr_fields;
235 int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
236 struct ghw_record_element *els;
237 };
238
239 struct ghw_subtype_record
240 {
241 enum ghdl_rtik kind;
242 const char *name;
243
244 struct ghw_type_record *base;
245 int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
246 struct ghw_record_element *els;
247 };
248
249 union ghw_type
250 {
251 enum ghdl_rtik kind;
252 struct ghw_type_common common;
253 struct ghw_type_enum en;
254 struct ghw_type_scalar sc;
255 struct ghw_type_physical ph;
256 struct ghw_subtype_scalar ss;
257 struct ghw_subtype_array sa;
258 struct ghw_subtype_record sr;
259 struct ghw_type_array ar;
260 struct ghw_type_record rec;
261 };
262
263 union ghw_val
264 {
265 unsigned char b2;
266 unsigned char e8;
267 int32_t i32;
268 int64_t i64;
269 double f64;
270 };
271
272 /* A non-composite signal. */
273 struct ghw_sig
274 {
275 union ghw_type *type;
276 union ghw_val *val;
277 };
278
279 enum ghw_hie_kind {
280 ghw_hie_eoh = 0,
281 ghw_hie_design = 1,
282 ghw_hie_block = 3,
283 ghw_hie_generate_if = 4,
284 ghw_hie_generate_for = 5,
285 ghw_hie_instance = 6,
286 ghw_hie_package = 7,
287 ghw_hie_process = 13,
288 ghw_hie_generic = 14,
289 ghw_hie_eos = 15,
290 ghw_hie_signal = 16,
291 ghw_hie_port_in = 17,
292 ghw_hie_port_out = 18,
293 ghw_hie_port_inout = 19,
294 ghw_hie_port_buffer = 20,
295 ghw_hie_port_linkage = 21
296 };
297
298 #define GHW_NO_SIG 0
299
300 struct ghw_hie
301 {
302 enum ghw_hie_kind kind;
303 struct ghw_hie *parent;
304 const char *name;
305 struct ghw_hie *brother;
306 union
307 {
308 struct
309 {
310 struct ghw_hie *child;
311 union ghw_type *iter_type;
312 union ghw_val *iter_value;
313 } blk;
314 struct
315 {
316 union ghw_type *type;
317 /* Array of signal elements.
318 Last element is GHW_NO_SIG (0). */
319 unsigned int *sigs;
320 } sig;
321 } u;
322 };
323
324 struct ghw_handler
325 {
326 FILE *stream;
327 /* True if STREAM was popen, else was fopen. */
328 unsigned char stream_ispipe;
329 /* True if words are big-endian. */
330 unsigned char word_be;
331 unsigned char word_len;
332 unsigned char off_len;
333 /* Minor version. */
334 int version;
335
336 /* Set by user. */
337 int flag_verbose;
338
339 /* String table. */
340 /* Number of strings. */
341 unsigned nbr_str;
342 /* Size of the strings (without nul). */
343 unsigned str_size;
344 /* String table. */
345 char **str_table;
346 /* Array containing strings. */
347 char *str_content;
348
349 /* Type table. */
350 unsigned nbr_types;
351 union ghw_type **types;
352
353 /* Non-composite (or basic) signals. */
354 unsigned nbr_sigs;
355 char *skip_sigs;
356 int flag_full_names;
357 struct ghw_sig *sigs;
358
359 /* Hierarchy. */
360 struct ghw_hie *hie;
361
362 /* Time of the next cycle. */
363 int64_t snap_time;
364 };
365
366 /* Open a GHW file with H.
367 Return < 0 in case of error. */
368 int ghw_open (struct ghw_handler *h, const char *filename);
369
370 /* Return base type of T. */
371 union ghw_type *ghw_get_base_type (union ghw_type *t);
372
373 /* Return length of RNG. */
374 int ghw_get_range_length (union ghw_range *rng);
375
376 /* Put the ASCII representation of VAL into BUF, whose size if LEN.
377 A NUL is always written to BUF. */
378 void ghw_get_value (char *buf, int len,
379 union ghw_val *val, union ghw_type *type);
380
381 const char *ghw_get_hie_name (struct ghw_hie *h);
382
383 void ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top);
384
385 int ghw_read_base (struct ghw_handler *h);
386
387 void ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep);
388
389 void ghw_disp_values (struct ghw_handler *h);
390
391 int ghw_read_cycle_start (struct ghw_handler *h);
392
393 int ghw_read_cycle_cont (struct ghw_handler *h, int *list);
394
395 int ghw_read_cycle_next (struct ghw_handler *h);
396
397 int ghw_read_cycle_end (struct ghw_handler *h);
398
399 enum ghw_sm_type {
400 /* At init;
401 Read section name. */
402 ghw_sm_init = 0,
403 ghw_sm_sect = 1,
404 ghw_sm_cycle = 2
405 };
406
407 enum ghw_res {
408 ghw_res_error = -1,
409 ghw_res_eof = -2,
410 ghw_res_ok = 0,
411 ghw_res_snapshot = 1,
412 ghw_res_cycle = 2,
413 ghw_res_other = 3
414 };
415
416 int ghw_read_sm (struct ghw_handler *h, enum ghw_sm_type *sm);
417
418 int ghw_read_dump (struct ghw_handler *h);
419
420 struct ghw_section {
421 const char name[4];
422 int (*handler)(struct ghw_handler *h);
423 };
424
425 extern struct ghw_section ghw_sections[];
426
427 int ghw_read_section (struct ghw_handler *h);
428
429 void ghw_close (struct ghw_handler *h);
430
431 const char *ghw_get_dir (int is_downto);
432
433 void ghw_disp_subtype_indication (struct ghw_handler *h, union ghw_type *t);
434
435 /* Note: TYPE must be a base type (used only to display literals). */
436 void ghw_disp_range (union ghw_type *type, union ghw_range *rng);
437
438 void ghw_disp_type (struct ghw_handler *h, union ghw_type *t);
439
440 void ghw_disp_types (struct ghw_handler *h);
441
442 enum ghw_res ghw_read_sm_hdr (struct ghw_handler *h, int *list);
443
444 #endif /* _GHWLIB_H_ */
853853 NULL, /* toggle3_showchange_c_1 364 */
854854 NULL, /* toggle4_showchange_c_1 364 */
855855 NULL, /* toggle5_showchange_c_1 364 */
856 NULL, /* toggle6_showchange_c_1 364 */
856857 NULL, /* window_showchange_c_8 365 */
857858 NULL, /* cleanup_showchange_c_6 366 */
858859 NULL, /* tcache_showchange_c_1 367 */
13801381 0, /* ruler_origin */
13811382 0, /* ruler_step */
13821383 0, /* fill_waveform */
1384 0, /* lz_removal */
13831385 FALSE, /*save_on_exit */
13841386
13851387
19011903 new_globals->display_grid = GLOBALS->display_grid;
19021904 new_globals->highlight_wavewindow = GLOBALS->highlight_wavewindow;
19031905 new_globals->fill_waveform = GLOBALS->fill_waveform;
1906 new_globals->lz_removal = GLOBALS->lz_removal;
19041907 new_globals->use_standard_trace_select = GLOBALS->use_standard_trace_select;
19051908 new_globals->use_big_fonts = GLOBALS->use_big_fonts;
19061909 new_globals->use_full_precision = GLOBALS->use_full_precision;
28482851 GLOBALS->display_grid = g_old->display_grid;
28492852 GLOBALS->highlight_wavewindow = g_old->highlight_wavewindow;
28502853 GLOBALS->fill_waveform = g_old->fill_waveform;
2854 GLOBALS->lz_removal = g_old->lz_removal;
28512855 GLOBALS->use_standard_trace_select = g_old->use_standard_trace_select;
28522856 GLOBALS->disable_mouseover = g_old->disable_mouseover;
28532857 GLOBALS->clipboard_mouseover = g_old->clipboard_mouseover;
856856 GtkWidget *toggle3_showchange_c_1; /* from showchange.c 390 */
857857 GtkWidget *toggle4_showchange_c_1; /* from showchange.c 391 */
858858 GtkWidget *toggle5_showchange_c_1; /* from showchange.c 391 */
859 GtkWidget *toggle6_showchange_c_1; /* from showchange.c 391 */
859860 GtkWidget *window_showchange_c_8; /* from showchange.c 392 */
860861 void (*cleanup_showchange_c_6)(void); /* from showchange.c 393 */
861862 struct TraceEnt *tcache_showchange_c_1; /* from showchange.c 394 */
13691370 TimeType ruler_origin;
13701371 TimeType ruler_step;
13711372 char fill_waveform;
1373 char lz_removal;
13721374 gboolean save_on_exit;
13731375
13741376
77
88 AM_CFLAGS= -I$(srcdir)/.. -I$(srcdir)/../.. $(LIBZ_CFLAGS) $(LIBBZ2_CFLAGS) $(LIBLZMA_CFLAGS) $(LIBJUDY_CFLAGS) $(EXTLOAD_CFLAGS) $(RPC_CFLAGS) -I$(srcdir)/fst -I$(srcdir)/../../contrib/rtlbrowse
99
10 bin_PROGRAMS= evcd2vcd fst2vcd vcd2fst fstminer ghwdump lxt2miner lxt2vcd \
10 bin_PROGRAMS= evcd2vcd fst2vcd vcd2fst fstminer lxt2miner lxt2vcd \
1111 shmidcat vcd2lxt vcd2lxt2 vcd2vzt \
1212 vzt2vcd vztminer
1313
4141 lxt2miner_SOURCES= lxt2miner.c lxt2_read.c lxt2_read.h
4242 lxt2miner_LDADD= $(LIBZ_LDADD)
4343
44 ghwdump_SOURCES= ghwdump.c $(srcdir)/../ghwlib.c
45
4644 evcd2vcd_SOURCES= evcd2vcd.c $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
7676 PRE_UNINSTALL = :
7777 POST_UNINSTALL = :
7878 bin_PROGRAMS = evcd2vcd$(EXEEXT) fst2vcd$(EXEEXT) vcd2fst$(EXEEXT) \
79 fstminer$(EXEEXT) ghwdump$(EXEEXT) lxt2miner$(EXEEXT) \
80 lxt2vcd$(EXEEXT) shmidcat$(EXEEXT) vcd2lxt$(EXEEXT) \
81 vcd2lxt2$(EXEEXT) vcd2vzt$(EXEEXT) vzt2vcd$(EXEEXT) \
82 vztminer$(EXEEXT)
79 fstminer$(EXEEXT) lxt2miner$(EXEEXT) lxt2vcd$(EXEEXT) \
80 shmidcat$(EXEEXT) vcd2lxt$(EXEEXT) vcd2lxt2$(EXEEXT) \
81 vcd2vzt$(EXEEXT) vzt2vcd$(EXEEXT) vztminer$(EXEEXT)
8382 subdir = src/helpers
8483 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
8584 $(top_srcdir)/depcomp
105104 fastlz.$(OBJEXT) fstapi.$(OBJEXT)
106105 fstminer_OBJECTS = $(am_fstminer_OBJECTS)
107106 fstminer_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
108 am_ghwdump_OBJECTS = ghwdump.$(OBJEXT) ghwlib.$(OBJEXT)
109 ghwdump_OBJECTS = $(am_ghwdump_OBJECTS)
110 ghwdump_LDADD = $(LDADD)
111107 am_lxt2miner_OBJECTS = lxt2miner.$(OBJEXT) lxt2_read.$(OBJEXT)
112108 lxt2miner_OBJECTS = $(am_lxt2miner_OBJECTS)
113109 lxt2miner_DEPENDENCIES = $(am__DEPENDENCIES_1)
179175 am__v_CCLD_0 = @echo " CCLD " $@;
180176 am__v_CCLD_1 =
181177 SOURCES = $(evcd2vcd_SOURCES) $(fst2vcd_SOURCES) $(fstminer_SOURCES) \
182 $(ghwdump_SOURCES) $(lxt2miner_SOURCES) $(lxt2vcd_SOURCES) \
178 $(lxt2miner_SOURCES) $(lxt2vcd_SOURCES) shmidcat.c \
179 $(vcd2fst_SOURCES) $(vcd2lxt_SOURCES) $(vcd2lxt2_SOURCES) \
180 $(vcd2vzt_SOURCES) $(vzt2vcd_SOURCES) $(vztminer_SOURCES)
181 DIST_SOURCES = $(evcd2vcd_SOURCES) $(fst2vcd_SOURCES) \
182 $(fstminer_SOURCES) $(lxt2miner_SOURCES) $(lxt2vcd_SOURCES) \
183183 shmidcat.c $(vcd2fst_SOURCES) $(vcd2lxt_SOURCES) \
184184 $(vcd2lxt2_SOURCES) $(vcd2vzt_SOURCES) $(vzt2vcd_SOURCES) \
185185 $(vztminer_SOURCES)
186 DIST_SOURCES = $(evcd2vcd_SOURCES) $(fst2vcd_SOURCES) \
187 $(fstminer_SOURCES) $(ghwdump_SOURCES) $(lxt2miner_SOURCES) \
188 $(lxt2vcd_SOURCES) shmidcat.c $(vcd2fst_SOURCES) \
189 $(vcd2lxt_SOURCES) $(vcd2lxt2_SOURCES) $(vcd2vzt_SOURCES) \
190 $(vzt2vcd_SOURCES) $(vztminer_SOURCES)
191186 am__can_run_installinfo = \
192187 case $$AM_UPDATE_INFO_DIR in \
193188 n|no|NO) false;; \
398393 vztminer_LDADD = $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBLZMA_LDADD) $(RPC_LDADD)
399394 lxt2miner_SOURCES = lxt2miner.c lxt2_read.c lxt2_read.h
400395 lxt2miner_LDADD = $(LIBZ_LDADD)
401 ghwdump_SOURCES = ghwdump.c $(srcdir)/../ghwlib.c
402396 evcd2vcd_SOURCES = evcd2vcd.c $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c
403397 all: all-am
404398
489483 @rm -f fstminer$(EXEEXT)
490484 $(AM_V_CCLD)$(LINK) $(fstminer_OBJECTS) $(fstminer_LDADD) $(LIBS)
491485
492 ghwdump$(EXEEXT): $(ghwdump_OBJECTS) $(ghwdump_DEPENDENCIES) $(EXTRA_ghwdump_DEPENDENCIES)
493 @rm -f ghwdump$(EXEEXT)
494 $(AM_V_CCLD)$(LINK) $(ghwdump_OBJECTS) $(ghwdump_LDADD) $(LIBS)
495
496486 lxt2miner$(EXEEXT): $(lxt2miner_OBJECTS) $(lxt2miner_DEPENDENCIES) $(EXTRA_lxt2miner_DEPENDENCIES)
497487 @rm -f lxt2miner$(EXEEXT)
498488 $(AM_V_CCLD)$(LINK) $(lxt2miner_OBJECTS) $(lxt2miner_LDADD) $(LIBS)
541531 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fst2vcd.Po@am__quote@
542532 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstapi.Po@am__quote@
543533 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstminer.Po@am__quote@
544 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ghwdump.Po@am__quote@
545 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ghwlib.Po@am__quote@
546534 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@
547535 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2_read.Po@am__quote@
548536 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2_write.Po@am__quote@
632620 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/fst/fstapi.c' object='fstapi.obj' libtool=no @AMDEPBACKSLASH@
633621 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
634622 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fstapi.obj `if test -f '$(srcdir)/fst/fstapi.c'; then $(CYGPATH_W) '$(srcdir)/fst/fstapi.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/fst/fstapi.c'; fi`
635
636 ghwlib.o: $(srcdir)/../ghwlib.c
637 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ghwlib.o -MD -MP -MF $(DEPDIR)/ghwlib.Tpo -c -o ghwlib.o `test -f '$(srcdir)/../ghwlib.c' || echo '$(srcdir)/'`$(srcdir)/../ghwlib.c
638 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ghwlib.Tpo $(DEPDIR)/ghwlib.Po
639 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../ghwlib.c' object='ghwlib.o' libtool=no @AMDEPBACKSLASH@
640 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
641 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ghwlib.o `test -f '$(srcdir)/../ghwlib.c' || echo '$(srcdir)/'`$(srcdir)/../ghwlib.c
642
643 ghwlib.obj: $(srcdir)/../ghwlib.c
644 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ghwlib.obj -MD -MP -MF $(DEPDIR)/ghwlib.Tpo -c -o ghwlib.obj `if test -f '$(srcdir)/../ghwlib.c'; then $(CYGPATH_W) '$(srcdir)/../ghwlib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../ghwlib.c'; fi`
645 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ghwlib.Tpo $(DEPDIR)/ghwlib.Po
646 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../ghwlib.c' object='ghwlib.obj' libtool=no @AMDEPBACKSLASH@
647 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
648 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ghwlib.obj `if test -f '$(srcdir)/../ghwlib.c'; then $(CYGPATH_W) '$(srcdir)/../ghwlib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../ghwlib.c'; fi`
649623
650624 LzmaLib.o: $(srcdir)/../liblzma/LzmaLib.c
651625 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT LzmaLib.o -MD -MP -MF $(DEPDIR)/LzmaLib.Tpo -c -o LzmaLib.o `test -f '$(srcdir)/../liblzma/LzmaLib.c' || echo '$(srcdir)/'`$(srcdir)/../liblzma/LzmaLib.c
0 cmake_minimum_required (VERSION 3.0)
1
2 project (fstlib)
3
4 ########################################################################################################################
5 # Easiest way to get ZLib on windows is using vcpkg, to load vcpkg:
6 # cmake -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
7 if(CMAKE_TOOLCHAIN_FILE)
8 message(STATUS "Using VCPKG from ${CMAKE_TOOLCHAIN_FILE}")
9 endif()
10 ########################################################################################################################
11 find_package(ZLIB REQUIRED)
12
13 add_library(fstapi fstapi.c fstapi.h fst_win_unistd.h)
14 target_link_libraries(fstapi PRIVATE ZLIB::ZLIB)
15 # hack to avoid creating dummy config.h
16 target_compile_definitions(fstapi PRIVATE -DFST_CONFIG_INCLUDE="fstapi.h")
17
18 if(MSVC)
19 # define __MINGW32__ to minimize changes to upstream
20 target_compile_definitions(fstapi PRIVATE __MINGW32__ _CRT_SECURE_NO_WARNINGS FST_DO_MISALIGNED_OPS)
21 target_compile_options(fstapi PRIVATE /wd4244 /wd4267 /wd4146 /wd4996)
22 endif()
44
55 noinst_LIBRARIES= libfst.a
66
7 libfst_a_SOURCES= fastlz.c fastlz.h lz4.c lz4.h fstapi.c fstapi.h
7 libfst_a_SOURCES= fastlz.c fastlz.h lz4.c lz4.h fstapi.c fstapi.h fst_win_unistd.h
88
9 EXTRA_DIST= block_format.txt
9 EXTRA_DIST= block_format.txt CMakeLists.txt
314314 top_srcdir = @top_srcdir@
315315 AM_CFLAGS = $(LIBZ_CFLAGS) $(LIBJUDY_CFLAGS)
316316 noinst_LIBRARIES = libfst.a
317 libfst_a_SOURCES = fastlz.c fastlz.h lz4.c lz4.h fstapi.c fstapi.h
318 EXTRA_DIST = block_format.txt
317 libfst_a_SOURCES = fastlz.c fastlz.h lz4.c lz4.h fstapi.c fstapi.h fst_win_unistd.h
318 EXTRA_DIST = block_format.txt CMakeLists.txt
319319 all: all-am
320320
321321 .SUFFIXES:
2121 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323 THE SOFTWARE.
24
25 SPDX-License-Identifier: MIT
2426 */
2527
2628 #include "fastlz.h"
2121 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323 THE SOFTWARE.
24
25 SPDX-License-Identifier: MIT
2426 */
2527
2628 #ifndef FASTLZ_H
0 /*
1 * Copyright (c) 2009-2018 Tony Bybell.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 *
21 * SPDX-License-Identifier: MIT
22 */
23
24 #ifndef WIN_UNISTD_H
25 #define WIN_UNISTD_H
26
27 #include <stdlib.h>
28 #ifdef _WIN64
29 #include <io.h>
30 #else
31 #include <sys/io.h>
32 #endif
33
34 #include <process.h>
35
36 #define ftruncate _chsize_s
37 #define unlink _unlink
38 #define fileno _fileno
39 #define lseek _lseeki64
40
41 #ifdef _WIN64
42 #define ssize_t __int64
43 #define SSIZE_MAX 9223372036854775807i64
44 #else
45 #define ssize_t long
46 #define SSIZE_MAX 2147483647L
47 #endif
48
49 #include "stdint.h"
50
51 #endif //WIN_UNISTD_H
1717 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1818 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1919 * DEALINGS IN THE SOFTWARE.
20 *
21 * SPDX-License-Identifier: MIT
2022 */
2123
2224 /*
7779 #define PATH_MAX (4096)
7880 #endif
7981
82 #if defined(_MSC_VER)
83 typedef int64_t fst_off_t;
84 #else
85 typedef off_t fst_off_t;
86 #endif
87
8088 /* note that Judy versus Jenkins requires more experimentation: they are */
8189 /* functionally equivalent though it appears Jenkins is slightly faster. */
8290 /* in addition, Jenkins is not bound by the LGPL. */
152160 #ifdef __MINGW32__
153161 #include <io.h>
154162 #ifndef HAVE_FSEEKO
155 #define ftello ftell
156 #define fseeko fseek
163 #define ftello _ftelli64
164 #define fseeko _fseeki64
157165 #endif
158166 #endif
159167
281289 return(fwrite(buf, siz, cnt, fp));
282290 }
283291
284 static int fstFtruncate(int fd, off_t length)
292 static int fstFtruncate(int fd, fst_off_t length)
285293 {
286294 return(ftruncate(fd, length));
287295 }
326334 #define fstMmap(__addr,__len,__prot,__flags,__fd,__off) fstMmap2((__len), (__fd), (__off))
327335 #define fstMunmap(__addr,__len) free(__addr)
328336
329 static void *fstMmap2(size_t __len, int __fd, off_t __off)
337 static void *fstMmap2(size_t __len, int __fd, fst_off_t __off)
330338 {
331339 (void)__off;
332340
333341 unsigned char *pnt = (unsigned char *)malloc(__len);
334 off_t cur_offs = lseek(__fd, 0, SEEK_CUR);
342 fst_off_t cur_offs = lseek(__fd, 0, SEEK_CUR);
335343 size_t i;
336344
337345 lseek(__fd, 0, SEEK_SET);
731739
732740 unsigned char *vchg_mem;
733741
734 off_t hier_file_len;
742 fst_off_t hier_file_len;
735743
736744 uint32_t *valpos_mem;
737745 unsigned char *curval_mem;
751759 unsigned fastpack : 1;
752760
753761 int64_t timezero;
754 off_t section_header_truncpos;
762 fst_off_t section_header_truncpos;
755763 uint32_t tchn_cnt, tchn_idx;
756764 uint64_t curtime;
757765 uint64_t firsttime;
759767 uint32_t vchg_alloc_siz;
760768
761769 uint32_t secnum;
762 off_t section_start;
770 fst_off_t section_start;
763771
764772 uint32_t numscopes;
765773 double nan; /* nan value for uninitialized doubles */
791799 pthread_attr_t thread_attr;
792800 struct fstWriterContext *xc_parent;
793801 #endif
802 unsigned in_pthread : 1;
794803
795804 size_t fst_orig_break_size;
796805 size_t fst_orig_break_add_size;
816825 };
817826
818827
819 static int fstWriterFseeko(struct fstWriterContext *xc, FILE *stream, off_t offset, int whence)
828 static int fstWriterFseeko(struct fstWriterContext *xc, FILE *stream, fst_off_t offset, int whence)
820829 {
821830 int rc = fseeko(stream, offset, whence);
822831
983992
984993 static void fstWriterCreateMmaps(struct fstWriterContext *xc)
985994 {
986 off_t curpos = ftello(xc->handle);
995 fst_off_t curpos = ftello(xc->handle);
987996
988997 fflush(xc->hier_handle);
989998
10231032
10241033 static void fstDestroyMmaps(struct fstWriterContext *xc, int is_closing)
10251034 {
1035 #if !defined __CYGWIN__ && !defined __MINGW32__
10261036 (void)is_closing;
1037 #endif
10271038
10281039 fstMunmap(xc->valpos_mem, xc->maxhandle * 4 * sizeof(uint32_t));
10291040 xc->valpos_mem = NULL;
10351046 {
10361047 unsigned char *pnt = xc->curval_mem;
10371048 int __fd = fileno(xc->curval_handle);
1038 off_t cur_offs = lseek(__fd, 0, SEEK_CUR);
1049 fst_off_t cur_offs = lseek(__fd, 0, SEEK_CUR);
10391050 size_t i;
10401051 size_t __len = xc->maxvalpos;
10411052
12761287 unsigned int i;
12771288 unsigned char *vchg_mem;
12781289 FILE *f;
1279 off_t fpos, indxpos, endpos;
1290 fst_off_t fpos, indxpos, endpos;
12801291 uint32_t prevpos;
12811292 int zerocnt;
12821293 unsigned char *scratchpad;
12831294 unsigned char *scratchpnt;
12841295 unsigned char *tmem;
1285 off_t tlen;
1286 off_t unc_memreq = 0; /* for reader */
1296 fst_off_t tlen;
1297 fst_off_t unc_memreq = 0; /* for reader */
12871298 unsigned char *packmem;
12881299 unsigned int packmemlen;
12891300 uint32_t *vm4ip;
17271738 unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen));
17281739 int rc = compress2(dmem, &destlen, tmem, tlen, 9);
17291740
1730 if((rc == Z_OK) && (((off_t)destlen) < tlen))
1741 if((rc == Z_OK) && (((fst_off_t)destlen) < tlen))
17311742 {
17321743 fstFwrite(dmem, destlen, 1, xc->handle);
17331744 }
17751786 xc2->section_header_truncpos = endpos; /* cache in case of need to truncate */
17761787 if(xc->dump_size_limit)
17771788 {
1778 if(endpos >= ((off_t)xc->dump_size_limit))
1789 if(endpos >= ((fst_off_t)xc->dump_size_limit))
17791790 {
17801791 xc2->skip_writing_section_hdr = 1;
17811792 xc2->size_limit_locked = 1;
18001811 static void *fstWriterFlushContextPrivate1(void *ctx)
18011812 {
18021813 struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
1803
1814 struct fstWriterContext *xc_parent;
1815
1816 pthread_mutex_lock(&(xc->xc_parent->mutex));
18041817 fstWriterFlushContextPrivate2(xc);
1805
1806 pthread_mutex_unlock(&(xc->xc_parent->mutex));
18071818
18081819 #ifdef FST_REMOVE_DUPLICATE_VC
18091820 free(xc->curval_mem);
18111822 free(xc->valpos_mem);
18121823 free(xc->vchg_mem);
18131824 tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
1825 xc_parent = xc->xc_parent;
18141826 free(xc);
1827
1828 xc_parent->in_pthread = 0;
1829 pthread_mutex_unlock(&(xc_parent->mutex));
18151830
18161831 return(NULL);
18171832 }
18601875 xc->section_header_only = 0;
18611876 xc->secnum++;
18621877
1878 while (xc->in_pthread)
1879 {
1880 pthread_mutex_lock(&xc->mutex);
1881 pthread_mutex_unlock(&xc->mutex);
1882 };
1883
18631884 pthread_mutex_lock(&xc->mutex);
1885 xc->in_pthread = 1;
1886 pthread_mutex_unlock(&xc->mutex);
18641887
18651888 pthread_create(&xc->thread, &xc->thread_attr, fstWriterFlushContextPrivate1, xc2);
18661889 }
19131936 if(xc && !xc->already_in_close && !xc->already_in_flush)
19141937 {
19151938 unsigned char *tmem = NULL;
1916 off_t fixup_offs, tlen, hlen;
1939 fst_off_t fixup_offs, tlen, hlen;
19171940
19181941 xc->already_in_close = 1; /* never need to zero this out as it is freed at bottom */
19191942
19421965 #ifdef FST_WRITER_PARALLEL
19431966 pthread_mutex_lock(&xc->mutex);
19441967 pthread_mutex_unlock(&xc->mutex);
1968
1969 while (xc->in_pthread)
1970 {
1971 pthread_mutex_lock(&xc->mutex);
1972 pthread_mutex_unlock(&xc->mutex);
1973 };
19451974 #endif
19461975 }
19471976 }
19671996 unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen));
19681997 int rc = compress2(dmem, &destlen, tmem, tlen, 9);
19691998
1970 if((rc != Z_OK) || (((off_t)destlen) > tlen))
1999 if((rc != Z_OK) || (((fst_off_t)destlen) > tlen))
19712000 {
19722001 destlen = tlen;
19732002 }
19782007 fstWriterUint64(xc->handle, tlen); /* uncompressed */
19792008 /* compressed len is section length - 24 */
19802009 fstWriterUint64(xc->handle, xc->maxhandle); /* maxhandle */
1981 fstFwrite((((off_t)destlen) != tlen) ? dmem : tmem, destlen, 1, xc->handle);
2010 fstFwrite((((fst_off_t)destlen) != tlen) ? dmem : tmem, destlen, 1, xc->handle);
19822011 fflush(xc->handle);
19832012
19842013 fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET);
19942023 if(xc->num_blackouts)
19952024 {
19962025 uint64_t cur_bl = 0;
1997 off_t bpos, eos;
2026 fst_off_t bpos, eos;
19982027 uint32_t i;
19992028
20002029 fixup_offs = ftello(xc->handle);
20272056
20282057 if(xc->compress_hier)
20292058 {
2030 off_t hl, eos;
2059 fst_off_t hl, eos;
20312060 gzFile zhandle;
20322061 int zfd;
20332062 int fourpack_duo = 0;
21502179 if(xc->repack_on_close)
21512180 {
21522181 FILE *fp;
2153 off_t offpnt, uclen;
2182 fst_off_t offpnt, uclen;
21542183 int flen = strlen(xc->filename);
21552184 char *hf = (char *)calloc(1, flen + 5);
21562185
22572286 if(xc)
22582287 {
22592288 char s[FST_HDR_DATE_SIZE];
2260 off_t fpos = ftello(xc->handle);
2289 fst_off_t fpos = ftello(xc->handle);
22612290 int len = strlen(dat);
22622291
22632292 fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_DATE, SEEK_SET);
22762305 if(xc && vers)
22772306 {
22782307 char s[FST_HDR_SIM_VERSION_SIZE];
2279 off_t fpos = ftello(xc->handle);
2308 fst_off_t fpos = ftello(xc->handle);
22802309 int len = strlen(vers);
22812310
22822311 fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_SIM_VERSION, SEEK_SET);
22962325 {
22972326 if(/*(filetype >= FST_FT_MIN) &&*/ (filetype <= FST_FT_MAX))
22982327 {
2299 off_t fpos = ftello(xc->handle);
2328 fst_off_t fpos = ftello(xc->handle);
23002329
23012330 xc->filetype = filetype;
23022331
24372466 struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
24382467 if(xc)
24392468 {
2440 off_t fpos = ftello(xc->handle);
2469 fst_off_t fpos = ftello(xc->handle);
24412470 fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_TIMESCALE, SEEK_SET);
24422471 fputc(ts & 255, xc->handle);
24432472 fflush(xc->handle);
24952524 struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
24962525 if(xc)
24972526 {
2498 off_t fpos = ftello(xc->handle);
2527 fst_off_t fpos = ftello(xc->handle);
24992528 fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_TIMEZERO, SEEK_SET);
25002529 fstWriterUint64(xc->handle, (xc->timezero = tim));
25012530 fflush(xc->handle);
33373366 int64_t timezero;
33383367
33393368 char *filename, *filename_unpacked;
3340 off_t hier_pos;
3369 fst_off_t hier_pos;
33413370
33423371 uint32_t num_blackouts;
33433372 uint64_t *blackout_times;
33523381 uint64_t rvat_beg_tim, rvat_end_tim;
33533382 unsigned char *rvat_frame_data;
33543383 uint64_t rvat_frame_maxhandle;
3355 off_t *rvat_chain_table;
3384 fst_off_t *rvat_chain_table;
33563385 uint32_t *rvat_chain_table_lengths;
33573386 uint64_t rvat_vc_maxhandle;
3358 off_t rvat_vc_start;
3387 fst_off_t rvat_vc_start;
33593388 uint32_t *rvat_sig_offs;
33603389 int rvat_packtype;
33613390
33943423 };
33953424
33963425
3397 int fstReaderFseeko(struct fstReaderContext *xc, FILE *stream, off_t offset, int whence)
3426 int fstReaderFseeko(struct fstReaderContext *xc, FILE *stream, fst_off_t offset, int whence)
33983427 {
33993428 int rc = fseeko(stream, offset, whence);
34003429
38873916
38883917 if(!xc->fh)
38893918 {
3890 off_t offs_cache = ftello(xc->f);
3919 fst_off_t offs_cache = ftello(xc->f);
38913920 char *fnam = (char *)malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
38923921 unsigned char *mem = (unsigned char *)malloc(FST_GZIO_LEN);
3893 off_t hl, uclen;
3894 off_t clen = 0;
3922 fst_off_t hl, uclen;
3923 fst_off_t clen = 0;
38953924 gzFile zhandle = NULL;
38963925 int zfd;
38973926 int htyp = FST_BL_SKIP;
45114540 */
45124541 int fstReaderInit(struct fstReaderContext *xc)
45134542 {
4514 off_t blkpos = 0;
4515 off_t endfile;
4543 fst_off_t blkpos = 0;
4544 fst_off_t endfile;
45164545 uint64_t seclen;
45174546 int sectype;
45184547 uint64_t vc_section_count_actual = 0;
45244553 if(sectype == FST_BL_ZWRAPPER)
45254554 {
45264555 FILE *fcomp;
4527 off_t offpnt, uclen;
4556 fst_off_t offpnt, uclen;
45284557 char gz_membuf[FST_GZIO_LEN];
45294558 gzFile zhandle;
45304559 int zfd;
49574986 uint64_t tsec_nitems;
49584987 unsigned int secnum = 0;
49594988 int blocks_skipped = 0;
4960 off_t blkpos = 0;
4989 fst_off_t blkpos = 0;
49614990 uint64_t seclen, beg_tim;
4962 #ifdef FST_DEBUG
49634991 uint64_t end_tim;
4964 #endif
49654992 uint64_t frame_uclen, frame_clen, frame_maxhandle, vc_maxhandle;
4966 off_t vc_start;
4967 off_t indx_pntr, indx_pos;
4968 off_t *chain_table = NULL;
4993 fst_off_t vc_start;
4994 fst_off_t indx_pntr, indx_pos;
4995 fst_off_t *chain_table = NULL;
49694996 uint32_t *chain_table_lengths = NULL;
49704997 unsigned char *chain_cmem;
49714998 unsigned char *pnt;
50285055 if(!seclen) break;
50295056
50305057 beg_tim = fstReaderUint64(xc->f);
5031 #ifdef FST_DEBUG
5032 end_tim =
5033 #endif
5034 fstReaderUint64(xc->f);
5058 end_tim = fstReaderUint64(xc->f);
50355059
50365060 if(xc->limit_range_valid)
50375061 {
5038 if(beg_tim < xc->limit_range_start)
5062 if(end_tim < xc->limit_range_start)
50395063 {
50405064 blocks_skipped++;
50415065 blkpos += seclen;
50815105 destlen = tsec_uclen;
50825106 sourcelen = tsec_clen;
50835107
5084 fstReaderFseeko(xc, xc->f, -24 - ((off_t)tsec_clen), SEEK_CUR);
5108 fstReaderFseeko(xc, xc->f, -24 - ((fst_off_t)tsec_clen), SEEK_CUR);
50855109
50865110 if(tsec_uclen != tsec_clen)
50875111 {
53225346 }
53235347
53245348 free(mu);
5325 fstReaderFseeko(xc, xc->f, -((off_t)frame_clen), SEEK_CUR);
5326 }
5327 }
5328
5329 fstReaderFseeko(xc, xc->f, (off_t)frame_clen, SEEK_CUR); /* skip past compressed data */
5349 fstReaderFseeko(xc, xc->f, -((fst_off_t)frame_clen), SEEK_CUR);
5350 }
5351 }
5352
5353 fstReaderFseeko(xc, xc->f, (fst_off_t)frame_clen, SEEK_CUR); /* skip past compressed data */
53305354
53315355 vc_maxhandle = fstReaderVarint64(xc->f);
53325356 vc_start = ftello(xc->f); /* points to '!' character */
53565380 free(chain_table_lengths);
53575381
53585382 vc_maxhandle_largest = vc_maxhandle;
5359 chain_table = (off_t *)calloc((vc_maxhandle+1), sizeof(off_t));
5383 chain_table = (fst_off_t *)calloc((vc_maxhandle+1), sizeof(fst_off_t));
53605384 chain_table_lengths = (uint32_t *)calloc((vc_maxhandle+1), sizeof(uint32_t));
53615385 }
53625386
59776001 char *fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf)
59786002 {
59796003 struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
5980 off_t blkpos = 0, prev_blkpos;
6004 fst_off_t blkpos = 0, prev_blkpos;
59816005 uint64_t beg_tim, end_tim, beg_tim2, end_tim2;
59826006 int sectype;
59836007 unsigned int secnum = 0;
59886012 #ifdef FST_DEBUG
59896013 uint64_t mem_required_for_traversal;
59906014 #endif
5991 off_t indx_pntr, indx_pos;
6015 fst_off_t indx_pntr, indx_pos;
59926016 long chain_clen;
59936017 unsigned char *chain_cmem;
59946018 unsigned char *pnt;
60506074 {
60516075 if((tim == end_tim) && (tim != xc->end_time))
60526076 {
6053 off_t cached_pos = ftello(xc->f);
6077 fst_off_t cached_pos = ftello(xc->f);
60546078 fstReaderFseeko(xc, xc->f, blkpos, SEEK_SET);
60556079
60566080 sectype = fgetc(xc->f);
61126136 destlen = tsec_uclen;
61136137 sourcelen = tsec_clen;
61146138
6115 fstReaderFseeko(xc, xc->f, -24 - ((off_t)tsec_clen), SEEK_CUR);
6139 fstReaderFseeko(xc, xc->f, -24 - ((fst_off_t)tsec_clen), SEEK_CUR);
61166140 if(tsec_uclen != tsec_clen)
61176141 {
61186142 cdata = (unsigned char *)malloc(tsec_clen);
61976221 fstReaderFseeko(xc, xc->f, indx_pos, SEEK_SET);
61986222 fstFread(chain_cmem, chain_clen, 1, xc->f);
61996223
6200 xc->rvat_chain_table = (off_t *)calloc((xc->rvat_vc_maxhandle+1), sizeof(off_t));
6224 xc->rvat_chain_table = (fst_off_t *)calloc((xc->rvat_vc_maxhandle+1), sizeof(fst_off_t));
62016225 xc->rvat_chain_table_lengths = (uint32_t *)calloc((xc->rvat_vc_maxhandle+1), sizeof(uint32_t));
62026226
62036227 pnt = chain_cmem;
1717 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1818 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1919 * DEALINGS IN THE SOFTWARE.
20 *
21 * SPDX-License-Identifier: MIT
2022 */
2123
2224 #ifndef FST_API_H
3234 #include <ctype.h>
3335 #include <zlib.h>
3436 #include <inttypes.h>
35 #include <unistd.h>
37 #if defined(_MSC_VER)
38 #include "fst_win_unistd.h"
39 #else
40 #include <unistd.h>
41 #endif
3642 #include <time.h>
3743
3844 #define FST_RDLOAD "FSTLOAD | "
2525 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2626 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 SPDX-License-Identifier: BSD-2-Clause
2830
2931 You can contact the author at :
3032 - LZ4 source repository : https://github.com/Cyan4973/lz4
2626 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2727 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 SPDX-License-Identifier: BSD-2-Clause
2931
3032 You can contact the author at :
3133 - LZ4 source repository : https://github.com/Cyan4973/lz4
+0
-203
src/helpers/ghwdump.c less more
0 /* Display a GHDL Wavefile for debugging.
1 Copyright (C) 2005-2008 Tristan Gingold
2
3 GHDL is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 2, or (at your option) any later
6 version.
7
8 GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with GCC; see the file COPYING. If not, write to the Free
15 Software Foundation, 51 Franklin Street - Suite 500, Boston, MA
16 02110-1335, USA.
17 */
18
19 #include <config.h>
20 #include <stdio.h>
21 #if HAVE_STDINT_H
22 #include <stdint.h>
23 #endif
24 #include <string.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27
28 #include "ghwlib.h"
29
30 #include "wave_locale.h"
31
32 static const char *progname;
33 void
34 usage (void)
35 {
36 printf ("usage: %s [OPTIONS] FILEs...\n", progname);
37 printf ("Options are:\n"
38 " -t display types\n"
39 " -h display hierarchy\n"
40 " -T display time\n"
41 " -s display signals (and time)\n"
42 " -l display list of sections\n"
43 " -v verbose\n");
44 }
45
46 int
47 main (int argc, char **argv)
48 {
49 int i;
50 int flag_disp_types;
51 int flag_disp_hierarchy;
52 int flag_disp_time;
53 int flag_disp_signals;
54 int flag_list;
55 int flag_verbose;
56 int eof;
57 enum ghw_sm_type sm;
58
59 progname = argv[0];
60 flag_disp_types = 0;
61 flag_disp_hierarchy = 0;
62 flag_disp_time = 0;
63 flag_disp_signals = 0;
64 flag_list = 0;
65 flag_verbose = 0;
66
67 WAVE_LOCALE_FIX
68
69 while (1)
70 {
71 int c;
72
73 c = getopt (argc, argv, "thTslv");
74 if (c == -1)
75 break;
76 switch (c)
77 {
78 case 't':
79 flag_disp_types = 1;
80 break;
81 case 'h':
82 flag_disp_hierarchy = 1;
83 break;
84 case 'T':
85 flag_disp_time = 1;
86 break;
87 case 's':
88 flag_disp_signals = 1;
89 flag_disp_time = 1;
90 break;
91 case 'l':
92 flag_list = 1;
93 break;
94 case 'v':
95 flag_verbose++;
96 break;
97 default:
98 usage ();
99 exit (2);
100 }
101 }
102
103 if (optind >= argc)
104 {
105 usage ();
106 return 1;
107 }
108
109 for (i = optind; i < argc; i++)
110 {
111 struct ghw_handler h;
112 struct ghw_handler *hp = &h;
113
114 hp->flag_verbose = flag_verbose;
115
116 if (ghw_open (hp, argv[i]) != 0)
117 {
118 fprintf (stderr, "cannot open ghw file %s\n", argv[i]);
119 return 1;
120 }
121 if (flag_list)
122 {
123 while (1)
124 {
125 int section;
126
127 section = ghw_read_section (hp);
128 if (section == -2)
129 {
130 printf ("eof of file\n");
131 break;
132 }
133 else if (section < 0)
134 {
135 printf ("Error in file\n");
136 break;
137 }
138 else if (section == 0)
139 {
140 printf ("Unknown section\n");
141 break;
142 }
143 printf ("Section %s\n", ghw_sections[section].name);
144 if ((*ghw_sections[section].handler)(hp) < 0)
145 break;
146 }
147 }
148 else
149 {
150 if (ghw_read_base (hp) < 0)
151 {
152 fprintf (stderr, "cannot read ghw file\n");
153 return 2;
154 }
155 if (0)
156 {
157 unsigned ix;
158 printf ("String table:\n");
159
160 for (ix = 1; ix < hp->nbr_str; ix++)
161 printf (" %s\n", hp->str_table[ix]);
162 }
163 if (flag_disp_types)
164 ghw_disp_types (hp);
165 if (flag_disp_hierarchy)
166 ghw_disp_hie (hp, hp->hie);
167
168 #if 1
169 sm = ghw_sm_init;
170 eof = 0;
171 while (!eof)
172 {
173 switch (ghw_read_sm (hp, &sm))
174 {
175 case ghw_res_snapshot:
176 case ghw_res_cycle:
177 if (flag_disp_time)
178 printf ("Time is "GHWPRI64" fs\n", hp->snap_time);
179 if (flag_disp_signals)
180 ghw_disp_values (hp);
181 break;
182 case ghw_res_eof:
183 eof = 1;
184 break;
185 default:
186 abort ();
187 }
188 }
189
190 #else
191 if (ghw_read_dump (hp) < 0)
192 {
193 fprintf (stderr, "error in ghw dump\n");
194 return 3;
195 }
196 #endif
197 }
198 ghw_close (&h);
199 }
200 return 0;
201 }
202
11531153 {
11541154 exp+=2;
11551155 }
1156 else
1157 if(tv == 1000) /* nonstandard */
1158 {
1159 exp+=3;
1160 }
11561161
11571162 fstWriterSetTimescale(ctx, exp);
11581163 }
18581858 msk = (~0U << lt->timepos);
18591859 msk_n = ~msk;
18601860
1861 if(!lt->emitted)
1862 {
1863 vzt_wr_emitfacs(lt);
1864 lt->emitted = 1;
1865
1866 if(!lt->timeset)
1867 {
1868 vzt_wr_set_time(lt, 0);
1869 }
1870 }
1871
18611872 for(j=0;j<lt->numfacs;j++)
18621873 {
18631874 struct vzt_wr_symbol *s = lt->sorted_facs[j];
0 /* GHDL Wavefile reader library.
1 Copyright (C) 2005 Tristan Gingold
2
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <gnu.org/licenses>.
15 */
16
17 #include <assert.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22
23 #include "libghw.h"
24
25 /* Reopen H through decompressor DECOMP. */
26
27 static int
28 ghw_openz (struct ghw_handler *h, const char *decomp, const char *filename)
29 {
30 int plen = strlen (decomp) + 1 + strlen (filename) + 1;
31 char *p = malloc (plen);
32
33 snprintf (p, plen, "%s %s", decomp, filename);
34 fclose (h->stream);
35 h->stream = popen (p, "r");
36 free (p);
37
38 if (h->stream == NULL)
39 return -1;
40
41 h->stream_ispipe = 1;
42
43 return 0;
44 }
45
46 int
47 ghw_open (struct ghw_handler *h, const char *filename)
48 {
49 char hdr[16];
50
51 h->stream = fopen (filename, "rb");
52 if (h->stream == NULL)
53 return -1;
54
55 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
56 return -1;
57
58 /* Check compression layer. */
59 if (!memcmp (hdr, "\x1f\x8b", 2))
60 {
61 if (ghw_openz (h, "gzip -cd", filename) < 0)
62 return -1;
63 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
64 return -1;
65 }
66 else if (!memcmp (hdr, "BZ", 2))
67 {
68 if (ghw_openz (h, "bzip2 -cd", filename) < 0)
69 return -1;
70 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
71 return -1;
72 }
73 else
74 {
75 h->stream_ispipe = 0;
76 }
77
78 /* Check magic. */
79 if (memcmp (hdr, "GHDLwave\n", 9) != 0)
80 return -2;
81 /* Check version. */
82 if (hdr[9] != 16 || hdr[10] != 0)
83 return -2;
84 h->version = hdr[11];
85 if (h->version > 1)
86 return -3;
87 if (hdr[12] == 1)
88 h->word_be = 0;
89 else if (hdr[12] == 2)
90 h->word_be = 1;
91 else
92 return -4;
93 #if 0
94 /* Endianness. */
95 {
96 int endian;
97 union
98 {
99 unsigned char b[4];
100 uint32_t i;
101 } v;
102 v.i = 0x11223344;
103 if (v.b[0] == 0x11)
104 endian = 2;
105 else if (v.b[0] == 0x44)
106 endian = 1;
107 else
108 return -3;
109
110 if (hdr[12] != 1 && hdr[12] != 2)
111 return -3;
112 if (hdr[12] != endian)
113 h->swap_word = 1;
114 else
115 h->swap_word = 0;
116 }
117 #endif
118 h->word_len = hdr[13];
119 h->off_len = hdr[14];
120
121 if (hdr[15] != 0)
122 return -5;
123
124 h->hie = NULL;
125 return 0;
126 }
127
128 int32_t
129 ghw_get_i32 (struct ghw_handler *h, unsigned char *b)
130 {
131 if (h->word_be)
132 return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3] << 0);
133 else
134 return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0] << 0);
135 }
136
137 int64_t
138 ghw_get_i64 (struct ghw_handler *ghw_h, unsigned char *b)
139 {
140 int l, h;
141
142 if (ghw_h->word_be)
143 {
144 h = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3] << 0);
145 l = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7] << 0);
146 }
147 else
148 {
149 l = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0] << 0);
150 h = (b[7] << 24) | (b[6] << 16) | (b[5] << 8) | (b[4] << 0);
151 }
152 return (((int64_t) h) << 32) | l;
153 }
154
155 int
156 ghw_read_byte (struct ghw_handler *h, unsigned char *res)
157 {
158 int v;
159
160 v = fgetc (h->stream);
161 if (v == EOF)
162 return -1;
163 *res = v;
164 return 0;
165 }
166
167 int
168 ghw_read_uleb128 (struct ghw_handler *h, uint32_t * res)
169 {
170 uint32_t r = 0;
171 unsigned int off = 0;
172
173 while (1)
174 {
175 int v = fgetc (h->stream);
176 if (v == EOF)
177 return -1;
178 r |= (v & 0x7f) << off;
179 if ((v & 0x80) == 0)
180 break;
181 off += 7;
182 }
183 *res = r;
184 return 0;
185 }
186
187 int
188 ghw_read_sleb128 (struct ghw_handler *h, int32_t * res)
189 {
190 int32_t r = 0;
191 unsigned int off = 0;
192
193 while (1)
194 {
195 int v = fgetc (h->stream);
196 if (v == EOF)
197 return -1;
198 r |= ((int32_t) (v & 0x7f)) << off;
199 off += 7;
200 if ((v & 0x80) == 0)
201 {
202 if ((v & 0x40) && off < 32)
203 r |= ~0U << off;
204 break;
205 }
206 }
207 *res = r;
208 return 0;
209 }
210
211 int
212 ghw_read_lsleb128 (struct ghw_handler *h, int64_t * res)
213 {
214 static const int64_t r_mask = -1;
215 int64_t r = 0;
216 unsigned int off = 0;
217
218 while (1)
219 {
220 int v = fgetc (h->stream);
221 if (v == EOF)
222 return -1;
223 r |= ((int64_t) (v & 0x7f)) << off;
224 off += 7;
225 if ((v & 0x80) == 0)
226 {
227 if ((v & 0x40) && off < 64)
228 r |= r_mask << off;
229 break;
230 }
231 }
232 *res = r;
233 return 0;
234 }
235
236 int
237 ghw_read_f64 (struct ghw_handler *h, double *res)
238 {
239 /* FIXME: handle byte order. */
240 if (fread (res, sizeof (*res), 1, h->stream) != 1)
241 return -1;
242 return 0;
243 }
244
245 const char *
246 ghw_read_strid (struct ghw_handler *h)
247 {
248 uint32_t id;
249
250 if (ghw_read_uleb128 (h, &id) != 0)
251 return NULL;
252 return h->str_table[id];
253 }
254
255 union ghw_type *
256 ghw_read_typeid (struct ghw_handler *h)
257 {
258 uint32_t id;
259
260 if (ghw_read_uleb128 (h, &id) != 0)
261 return NULL;
262 return h->types[id - 1];
263 }
264
265 union ghw_range *
266 ghw_read_range (struct ghw_handler *h)
267 {
268 int t = fgetc (h->stream);
269 if (t == EOF)
270 return NULL;
271 switch (t & 0x7f)
272 {
273 case ghdl_rtik_type_b2:
274 {
275 struct ghw_range_b2 *r;
276 r = malloc (sizeof (struct ghw_range_b2));
277 r->kind = t & 0x7f;
278 r->dir = (t & 0x80) != 0;
279 if (ghw_read_byte (h, &r->left) != 0)
280 goto err_b2;
281 if (ghw_read_byte (h, &r->right) != 0)
282 goto err_b2;
283 return (union ghw_range *) r;
284 err_b2:
285 free (r);
286 return NULL;
287 }
288 case ghdl_rtik_type_e8:
289 {
290 struct ghw_range_e8 *r;
291 r = malloc (sizeof (struct ghw_range_e8));
292 r->kind = t & 0x7f;
293 r->dir = (t & 0x80) != 0;
294 if (ghw_read_byte (h, &r->left) != 0)
295 goto err_e8;
296 if (ghw_read_byte (h, &r->right) != 0)
297 goto err_e8;
298 return (union ghw_range *) r;
299 err_e8:
300 free (r);
301 return NULL;
302 }
303 case ghdl_rtik_type_i32:
304 case ghdl_rtik_type_p32:
305 {
306 struct ghw_range_i32 *r;
307 r = malloc (sizeof (struct ghw_range_i32));
308 r->kind = t & 0x7f;
309 r->dir = (t & 0x80) != 0;
310 if (ghw_read_sleb128 (h, &r->left) != 0)
311 goto err_i32;
312 if (ghw_read_sleb128 (h, &r->right) != 0)
313 goto err_i32;
314 return (union ghw_range *) r;
315 err_i32:
316 free (r);
317 return NULL;
318 }
319 case ghdl_rtik_type_i64:
320 case ghdl_rtik_type_p64:
321 {
322 struct ghw_range_i64 *r;
323 r = malloc (sizeof (struct ghw_range_i64));
324 r->kind = t & 0x7f;
325 r->dir = (t & 0x80) != 0;
326 if (ghw_read_lsleb128 (h, &r->left) != 0)
327 goto err_i64;
328 if (ghw_read_lsleb128 (h, &r->right) != 0)
329 goto err_i64;
330 return (union ghw_range *) r;
331 err_i64:
332 free (r);
333 return NULL;
334 }
335 case ghdl_rtik_type_f64:
336 {
337 struct ghw_range_f64 *r;
338 r = malloc (sizeof (struct ghw_range_f64));
339 r->kind = t & 0x7f;
340 r->dir = (t & 0x80) != 0;
341 if (ghw_read_f64 (h, &r->left) != 0)
342 goto err_f64;
343 if (ghw_read_f64 (h, &r->right) != 0)
344 goto err_f64;
345 return (union ghw_range *) r;
346 err_f64:
347 free (r);
348 return NULL;
349 }
350 default:
351 fprintf (stderr, "ghw_read_range: type %d unhandled\n", t & 0x7f);
352 return NULL;
353 }
354 }
355
356 int
357 ghw_read_str (struct ghw_handler *h)
358 {
359 unsigned char hdr[12];
360 unsigned i;
361 char *p;
362 int prev_len;
363
364 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
365 return -1;
366
367 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
368 return -1;
369 h->nbr_str = ghw_get_i32 (h, &hdr[4]);
370 h->nbr_str++;
371 h->str_size = ghw_get_i32 (h, &hdr[8]);
372 h->str_table = (char **) malloc ((h->nbr_str + 1) * sizeof (char *));
373 h->str_content = (char *) malloc (h->str_size + h->nbr_str + 1);
374
375 if (h->flag_verbose)
376 {
377 printf ("Number of strings: %u\n", h->nbr_str - 1);
378 printf ("String table size: %u\n", h->str_size);
379 }
380
381 h->str_table[0] = "<anon>";
382 p = h->str_content;
383 prev_len = 0;
384 for (i = 1; i < h->nbr_str; i++)
385 {
386 int j;
387 int c;
388 char *prev;
389 int sh;
390
391 h->str_table[i] = p;
392 prev = h->str_table[i - 1];
393 for (j = 0; j < prev_len; j++)
394 *p++ = prev[j];
395
396 while (1)
397 {
398 c = fgetc (h->stream);
399 if (c == EOF)
400 return -1;
401 if ((c >= 0 && c <= 31) || (c >= 128 && c <= 159))
402 break;
403 *p++ = c;
404 }
405 *p++ = 0;
406
407 if (h->flag_verbose > 1)
408 printf (" string %u (pl=%d): %s\n", i, prev_len, h->str_table[i]);
409
410 prev_len = c & 0x1f;
411 sh = 5;
412 while (c >= 128)
413 {
414 c = fgetc (h->stream);
415 if (c == EOF)
416 return -1;
417 prev_len |= (c & 0x1f) << sh;
418 sh += 5;
419 }
420 }
421 if (fread (hdr, 4, 1, h->stream) != 1)
422 return -1;
423 if (memcmp (hdr, "EOS", 4) != 0)
424 return -1;
425 return 0;
426 }
427
428 union ghw_type *
429 ghw_get_base_type (union ghw_type *t)
430 {
431 switch (t->kind)
432 {
433 case ghdl_rtik_type_b2:
434 case ghdl_rtik_type_e8:
435 case ghdl_rtik_type_e32:
436 case ghdl_rtik_type_i32:
437 case ghdl_rtik_type_i64:
438 case ghdl_rtik_type_f64:
439 case ghdl_rtik_type_p32:
440 case ghdl_rtik_type_p64:
441 case ghdl_rtik_type_array:
442 return t;
443 case ghdl_rtik_subtype_scalar:
444 return t->ss.base;
445 case ghdl_rtik_subtype_array:
446 return t->sa.base;
447 case ghdl_rtik_subtype_unbounded_array:
448 return t->sua.base;
449 default:
450 fprintf (stderr, "ghw_get_base_type: cannot handle type %d\n", t->kind);
451 abort ();
452 }
453 }
454
455 /* Return -1 for unbounded types. */
456 static int
457 get_nbr_elements (union ghw_type *t)
458 {
459 switch (t->kind)
460 {
461 case ghdl_rtik_type_b2:
462 case ghdl_rtik_type_e8:
463 case ghdl_rtik_type_e32:
464 case ghdl_rtik_type_i32:
465 case ghdl_rtik_type_i64:
466 case ghdl_rtik_type_f64:
467 case ghdl_rtik_type_p32:
468 case ghdl_rtik_type_p64:
469 case ghdl_rtik_subtype_scalar:
470 return 1;
471 case ghdl_rtik_type_array:
472 return -1;
473 case ghdl_rtik_subtype_array:
474 return t->sa.nbr_scalars;
475 case ghdl_rtik_type_record:
476 return t->rec.nbr_scalars;
477 case ghdl_rtik_subtype_record:
478 return t->sr.nbr_scalars;
479 case ghdl_rtik_subtype_unbounded_record:
480 case ghdl_rtik_subtype_unbounded_array:
481 return -1;
482 default:
483 fprintf (stderr, "get_nbr_elements: unhandled type %d\n", t->kind);
484 abort ();
485 }
486 }
487
488 int
489 ghw_get_range_length (union ghw_range *rng)
490 {
491 int res;
492
493 assert (rng != NULL);
494
495 switch (rng->kind)
496 {
497 case ghdl_rtik_type_i32:
498 if (rng->i32.dir)
499 res = rng->i32.left - rng->i32.right + 1;
500 else
501 res = rng->i32.right - rng->i32.left + 1;
502 break;
503 case ghdl_rtik_type_b2:
504 if (rng->b2.dir)
505 res = rng->b2.left - rng->b2.right + 1;
506 else
507 res = rng->b2.right - rng->b2.left + 1;
508 break;
509 case ghdl_rtik_type_e8:
510 if (rng->e8.dir)
511 res = rng->e8.left - rng->e8.right + 1;
512 else
513 res = rng->e8.right - rng->e8.left + 1;
514 break;
515 default:
516 fprintf (stderr, "get_range_length: unhandled kind %d\n", rng->kind);
517 abort ();
518 }
519 /* The length of a null range is 0. */
520 return (res <= 0) ? 0 : res;
521 }
522
523 static union ghw_type *ghw_read_type_bounds (struct ghw_handler *h,
524 union ghw_type *base);
525
526 /* Create an array subtype using BASE and ranges read from H. */
527
528 struct ghw_subtype_array *
529 ghw_read_array_subtype (struct ghw_handler *h, union ghw_type *base)
530 {
531 struct ghw_type_array *arr =
532 (struct ghw_type_array *) ghw_get_base_type (base);
533 struct ghw_subtype_array *sa;
534 unsigned j;
535 int nbr_scalars;
536 int nbr_els;
537
538 sa = malloc (sizeof (struct ghw_subtype_array));
539 sa->kind = ghdl_rtik_subtype_array;
540 sa->name = NULL;
541 sa->base = base;
542 nbr_els = get_nbr_elements (arr->el);
543 nbr_scalars = 1;
544 sa->rngs = malloc (arr->nbr_dim * sizeof (union ghw_range *));
545 for (j = 0; j < arr->nbr_dim; j++)
546 {
547 sa->rngs[j] = ghw_read_range (h);
548 nbr_scalars *= ghw_get_range_length (sa->rngs[j]);
549 }
550 if (nbr_els >= 0)
551 {
552 /* Element type is bounded. */
553 sa->el = arr->el;
554 }
555 else
556 {
557 /* Read bounds for the elements. */
558 sa->el = ghw_read_type_bounds (h, arr->el);
559 nbr_els = get_nbr_elements (sa->el);
560 }
561 sa->nbr_scalars = nbr_scalars * nbr_els;
562 return sa;
563 }
564
565 struct ghw_subtype_record *
566 ghw_read_record_subtype (struct ghw_handler *h, struct ghw_type_record *base)
567 {
568 struct ghw_subtype_record *sr;
569
570 sr = malloc (sizeof (struct ghw_subtype_record));
571 sr->kind = ghdl_rtik_subtype_record;
572 sr->name = NULL;
573 sr->base = base;
574 if (base->nbr_scalars >= 0)
575 {
576 /* Record base type is bounded. */
577 sr->nbr_scalars = base->nbr_scalars;
578 sr->els = base->els;
579 }
580 else
581 {
582 /* Read subtypes. */
583 unsigned j;
584 int nbr_scalars;
585
586 sr->els =
587 malloc (base->nbr_fields * sizeof (struct ghw_record_element));
588 nbr_scalars = 0;
589 for (j = 0; j < base->nbr_fields; j++)
590 {
591 union ghw_type *btype = base->els[j].type;
592 int el_nbr_scalars = get_nbr_elements (btype);
593
594 sr->els[j].name = base->els[j].name;
595 if (el_nbr_scalars >= 0)
596 {
597 /* Element is constrained. */
598 sr->els[j].type = btype;
599 }
600 else
601 {
602 sr->els[j].type = ghw_read_type_bounds (h, btype);
603 el_nbr_scalars = get_nbr_elements (sr->els[j].type);
604 }
605 nbr_scalars += el_nbr_scalars;
606 }
607 sr->nbr_scalars = nbr_scalars;
608 }
609 return sr;
610 }
611
612 /* Read bounds for BASE and create a subtype. */
613
614 static union ghw_type *
615 ghw_read_type_bounds (struct ghw_handler *h, union ghw_type *base)
616 {
617 switch (base->kind)
618 {
619 case ghdl_rtik_type_array:
620 case ghdl_rtik_subtype_unbounded_array:
621 return (union ghw_type *) ghw_read_array_subtype (h, base);
622 break;
623 case ghdl_rtik_type_record:
624 case ghdl_rtik_subtype_unbounded_record:
625 return (union ghw_type *) ghw_read_record_subtype (h, &base->rec);
626 break;
627 default:
628 fprintf (stderr, "ghw_read_type_bounds: unhandled kind %d\n",
629 base->kind);
630 return NULL;
631 }
632 }
633
634 int
635 ghw_read_type (struct ghw_handler *h)
636 {
637 unsigned char hdr[8];
638 unsigned i;
639
640 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
641 return -1;
642
643 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
644 return -1;
645 h->nbr_types = ghw_get_i32 (h, &hdr[4]);
646 h->types =
647 (union ghw_type **) malloc (h->nbr_types * sizeof (union ghw_type *));
648
649 for (i = 0; i < h->nbr_types; i++)
650 {
651 int t;
652
653 t = fgetc (h->stream);
654 if (t == EOF)
655 return -1;
656 if (h->flag_verbose > 1)
657 printf ("type[%d]= %d\n", i, t);
658 switch (t)
659 {
660 case ghdl_rtik_type_b2:
661 case ghdl_rtik_type_e8:
662 {
663 struct ghw_type_enum *e;
664 unsigned j;
665
666 e = malloc (sizeof (struct ghw_type_enum));
667 e->kind = t;
668 e->wkt = ghw_wkt_unknown;
669 e->name = ghw_read_strid (h);
670 if (ghw_read_uleb128 (h, &e->nbr) != 0)
671 goto err_b2;
672 e->lits = (const char **) malloc (e->nbr * sizeof (char *));
673 if (h->flag_verbose > 1)
674 printf ("enum %s:", e->name);
675 for (j = 0; j < e->nbr; j++)
676 {
677 e->lits[j] = ghw_read_strid (h);
678 if (h->flag_verbose > 1)
679 printf (" %s", e->lits[j]);
680 }
681 if (h->flag_verbose > 1)
682 printf ("\n");
683 h->types[i] = (union ghw_type *) e;
684 break;
685 err_b2:
686 free (e);
687 return -1;
688 }
689 break;
690 case ghdl_rtik_type_i32:
691 case ghdl_rtik_type_i64:
692 case ghdl_rtik_type_f64:
693 {
694 struct ghw_type_scalar *sc;
695
696 sc = malloc (sizeof (struct ghw_type_scalar));
697 sc->kind = t;
698 sc->name = ghw_read_strid (h);
699 if (h->flag_verbose > 1)
700 printf ("scalar: %s\n", sc->name);
701 h->types[i] = (union ghw_type *) sc;
702 } break;
703 case ghdl_rtik_type_p32:
704 case ghdl_rtik_type_p64:
705 {
706 struct ghw_type_physical *ph;
707
708 ph = malloc (sizeof (struct ghw_type_physical));
709 ph->kind = t;
710 ph->name = ghw_read_strid (h);
711 ph->units = NULL;
712 if (h->version == 0)
713 ph->nbr_units = 0;
714 else
715 {
716 unsigned j;
717
718 if (ghw_read_uleb128 (h, &ph->nbr_units) != 0)
719 goto err_p32;
720 ph->units = malloc (ph->nbr_units * sizeof (struct ghw_unit));
721 for (j = 0; j < ph->nbr_units; j++)
722 {
723 ph->units[j].name = ghw_read_strid (h);
724 if (ghw_read_lsleb128 (h, &ph->units[j].val) < 0)
725 goto err_p32;
726 }
727 }
728 if (h->flag_verbose > 1)
729 printf ("physical: %s\n", ph->name);
730 h->types[i] = (union ghw_type *) ph;
731 break;
732 err_p32:
733 free (ph->units);
734 free (ph);
735 return -1;
736 }
737 break;
738 case ghdl_rtik_subtype_scalar:
739 {
740 struct ghw_subtype_scalar *ss;
741
742 ss = malloc (sizeof (struct ghw_subtype_scalar));
743 ss->kind = t;
744 ss->name = ghw_read_strid (h);
745 ss->base = ghw_read_typeid (h);
746 ss->rng = ghw_read_range (h);
747 if (h->flag_verbose > 1)
748 printf ("subtype scalar: %s\n", ss->name);
749 h->types[i] = (union ghw_type *) ss;
750 } break;
751 case ghdl_rtik_type_array:
752 {
753 struct ghw_type_array *arr;
754 unsigned j;
755
756 arr = malloc (sizeof (struct ghw_type_array));
757 arr->kind = t;
758 arr->name = ghw_read_strid (h);
759 arr->el = ghw_read_typeid (h);
760 if (ghw_read_uleb128 (h, &arr->nbr_dim) != 0)
761 goto err_array;
762 arr->dims =
763 (union ghw_type **) malloc (arr->nbr_dim *
764 sizeof (union ghw_type *));
765 for (j = 0; j < arr->nbr_dim; j++)
766 arr->dims[j] = ghw_read_typeid (h);
767 if (h->flag_verbose > 1)
768 printf ("array: %s (ndim=%u) of %s\n", arr->name, arr->nbr_dim,
769 arr->el->common.name);
770 h->types[i] = (union ghw_type *) arr;
771 break;
772 err_array:
773 free (arr);
774 return -1;
775 }
776 break;
777 case ghdl_rtik_subtype_array:
778 {
779 struct ghw_subtype_array *sa;
780 const char *name;
781 union ghw_type *base;
782
783 name = ghw_read_strid (h);
784 base = ghw_read_typeid (h);
785
786 sa = ghw_read_array_subtype (h, base);
787 sa->name = name;
788 h->types[i] = (union ghw_type *) sa;
789 if (h->flag_verbose > 1)
790 printf ("subtype array: %s (nbr_scalars=%d)\n", sa->name,
791 sa->nbr_scalars);
792 }
793 break;
794 case ghdl_rtik_subtype_unbounded_array:
795 {
796 struct ghw_subtype_unbounded_array *sua;
797
798 sua = malloc (sizeof (struct ghw_subtype_unbounded_array));
799 sua->kind = t;
800 sua->name = ghw_read_strid (h);
801 sua->base = ghw_read_typeid (h);
802 h->types[i] = (union ghw_type *) sua;
803 if (h->flag_verbose > 1)
804 printf ("subtype unbounded array: %s\n", sua->name);
805 }
806 break;
807 case ghdl_rtik_type_record:
808 {
809 struct ghw_type_record *rec;
810 unsigned j;
811 int nbr_scalars;
812
813 rec = malloc (sizeof (struct ghw_type_record));
814 rec->kind = t;
815 rec->name = ghw_read_strid (h);
816 rec->els = NULL;
817 if (ghw_read_uleb128 (h, &rec->nbr_fields) != 0)
818 goto err_record;
819 rec->els =
820 malloc (rec->nbr_fields * sizeof (struct ghw_record_element));
821 nbr_scalars = 0;
822 for (j = 0; j < rec->nbr_fields; j++)
823 {
824 rec->els[j].name = ghw_read_strid (h);
825 rec->els[j].type = ghw_read_typeid (h);
826 if (nbr_scalars != -1)
827 {
828 int field_nbr_scalars =
829 get_nbr_elements (rec->els[j].type);
830 if (field_nbr_scalars == -1)
831 nbr_scalars = -1;
832 else
833 nbr_scalars += field_nbr_scalars;
834 }
835 }
836 rec->nbr_scalars = nbr_scalars;
837 if (h->flag_verbose > 1)
838 printf ("record type: %s (nbr_scalars=%d)\n", rec->name,
839 rec->nbr_scalars);
840 h->types[i] = (union ghw_type *) rec;
841 break;
842 err_record:
843 free (rec->els);
844 free (rec);
845 return -1;
846 }
847 break;
848 case ghdl_rtik_subtype_record:
849 {
850 struct ghw_subtype_record *sr;
851 const char *name;
852 struct ghw_type_record *base;
853
854 name = ghw_read_strid (h);
855 base = (struct ghw_type_record *) ghw_read_typeid (h);
856
857 sr = ghw_read_record_subtype (h, base);
858 sr->name = name;
859 h->types[i] = (union ghw_type *) sr;
860 if (h->flag_verbose > 1)
861 printf ("subtype record: %s (nbr_scalars=%d)\n", sr->name,
862 sr->nbr_scalars);
863 }
864 break;
865 case ghdl_rtik_subtype_unbounded_record:
866 {
867 struct ghw_subtype_unbounded_record *sur;
868
869 sur = malloc (sizeof (struct ghw_subtype_unbounded_record));
870 sur->kind = t;
871 sur->name = ghw_read_strid (h);
872 sur->base = (struct ghw_type_record *) ghw_read_typeid (h);
873 h->types[i] = (union ghw_type *) sur;
874 if (h->flag_verbose > 1)
875 printf ("subtype unbounded record: %s\n", sur->name);
876 }
877 break;
878 default:
879 fprintf (stderr, "ghw_read_type: unknown type %d\n", t);
880 return -1;
881 }
882 }
883 if (fgetc (h->stream) != 0)
884 return -1;
885 return 0;
886 }
887
888 int
889 ghw_read_wk_types (struct ghw_handler *h)
890 {
891 char hdr[4];
892
893 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
894 return -1;
895
896 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
897 return -1;
898
899 while (1)
900 {
901 int t;
902 union ghw_type *tid;
903
904 t = fgetc (h->stream);
905 if (t == EOF)
906 return -1;
907 else if (t == 0)
908 break;
909
910 tid = ghw_read_typeid (h);
911 if (tid->kind == ghdl_rtik_type_b2 || tid->kind == ghdl_rtik_type_e8)
912 {
913 if (h->flag_verbose > 0)
914 printf ("%s: wkt=%d\n", tid->en.name, t);
915 tid->en.wkt = t;
916 }
917 }
918 return 0;
919 }
920
921 void
922 ghw_disp_typename (struct ghw_handler *h, union ghw_type *t)
923 {
924 (void) h;
925 printf ("%s", t->common.name);
926 }
927
928 /* Read a signal composed of severals elements.
929 Return 0 for success. */
930 int
931 ghw_read_signal (struct ghw_handler *h, unsigned int *sigs, union ghw_type *t)
932 {
933 switch (t->kind)
934 {
935 case ghdl_rtik_type_b2:
936 case ghdl_rtik_type_e8:
937 case ghdl_rtik_type_e32:
938 case ghdl_rtik_subtype_scalar:
939 {
940 unsigned int sig_el;
941
942 if (ghw_read_uleb128 (h, &sig_el) < 0)
943 return -1;
944 *sigs = sig_el;
945 if (sig_el == 0 || sig_el >= h->nbr_sigs)
946 return -1;
947 if (h->sigs[sig_el].type == NULL)
948 h->sigs[sig_el].type = ghw_get_base_type (t);
949 }
950 return 0;
951 case ghdl_rtik_subtype_array:
952 {
953 int i;
954 int stride;
955 int len;
956
957 len = t->sa.nbr_scalars;
958 stride = get_nbr_elements (t->sa.el);
959
960 for (i = 0; i < len; i += stride)
961 if (ghw_read_signal (h, &sigs[i], t->sa.el) < 0)
962 return -1;
963 }
964 return 0;
965 case ghdl_rtik_type_record:
966 {
967 struct ghw_type_record *r = &t->rec;
968 int nbr_fields = r->nbr_fields;
969 int i;
970 int off;
971
972 off = 0;
973 for (i = 0; i < nbr_fields; i++)
974 {
975 if (ghw_read_signal (h, &sigs[off], r->els[i].type) < 0)
976 return -1;
977 off += get_nbr_elements (r->els[i].type);
978 }
979 }
980 return 0;
981 case ghdl_rtik_subtype_record:
982 {
983 struct ghw_subtype_record *sr = &t->sr;
984 int nbr_fields = sr->base->nbr_fields;
985 int i;
986 int off;
987
988 off = 0;
989 for (i = 0; i < nbr_fields; i++)
990 {
991 if (ghw_read_signal (h, &sigs[off], sr->els[i].type) < 0)
992 return -1;
993 off += get_nbr_elements (sr->els[i].type);
994 }
995 }
996 return 0;
997 default:
998 fprintf (stderr, "ghw_read_signal: type kind %d unhandled\n", t->kind);
999 abort ();
1000 }
1001 }
1002
1003 int
1004 ghw_read_value (struct ghw_handler *h, union ghw_val *val,
1005 union ghw_type *type)
1006 {
1007 switch (ghw_get_base_type (type)->kind)
1008 {
1009 case ghdl_rtik_type_b2:
1010 {
1011 int v;
1012 v = fgetc (h->stream);
1013 if (v == EOF)
1014 return -1;
1015 val->b2 = v;
1016 }
1017 break;
1018 case ghdl_rtik_type_e8:
1019 {
1020 int v;
1021 v = fgetc (h->stream);
1022 if (v == EOF)
1023 return -1;
1024 val->e8 = v;
1025 }
1026 break;
1027 case ghdl_rtik_type_i32:
1028 case ghdl_rtik_type_p32:
1029 {
1030 int32_t v;
1031 if (ghw_read_sleb128 (h, &v) < 0)
1032 return -1;
1033 val->i32 = v;
1034 }
1035 break;
1036 case ghdl_rtik_type_f64:
1037 {
1038 double v;
1039 if (ghw_read_f64 (h, &v) < 0)
1040 return -1;
1041 val->f64 = v;
1042 }
1043 break;
1044 case ghdl_rtik_type_p64:
1045 {
1046 int64_t v;
1047 if (ghw_read_lsleb128 (h, &v) < 0)
1048 return -1;
1049 val->i64 = v;
1050 }
1051 break;
1052 default:
1053 fprintf (stderr, "read_value: cannot handle format %d\n", type->kind);
1054 abort ();
1055 }
1056 return 0;
1057 }
1058
1059 int
1060 ghw_read_hie (struct ghw_handler *h)
1061 {
1062 unsigned char hdr[16];
1063 int nbr_scopes;
1064 int nbr_sigs;
1065 unsigned i;
1066 struct ghw_hie *blk;
1067 struct ghw_hie **last;
1068
1069 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1070 return -1;
1071
1072 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
1073 return -1;
1074 nbr_scopes = ghw_get_i32 (h, &hdr[4]);
1075 /* Number of declared signals (which may be composite). */
1076 nbr_sigs = ghw_get_i32 (h, &hdr[8]);
1077 /* Number of basic signals. */
1078 h->nbr_sigs = ghw_get_i32 (h, &hdr[12]);
1079
1080 if (h->flag_verbose)
1081 printf ("%u scopes, %u signals, %u signal elements\n", nbr_scopes,
1082 nbr_sigs, h->nbr_sigs);
1083
1084 blk = (struct ghw_hie *) malloc (sizeof (struct ghw_hie));
1085 blk->kind = ghw_hie_design;
1086 blk->name = NULL;
1087 blk->parent = NULL;
1088 blk->brother = NULL;
1089 blk->u.blk.child = NULL;
1090
1091 last = &blk->u.blk.child;
1092 h->hie = blk;
1093
1094 h->nbr_sigs++;
1095 h->skip_sigs = NULL;
1096 h->flag_full_names = 0;
1097 h->sigs = (struct ghw_sig *) malloc (h->nbr_sigs * sizeof (struct ghw_sig));
1098 memset (h->sigs, 0, h->nbr_sigs * sizeof (struct ghw_sig));
1099
1100 while (1)
1101 {
1102 int t;
1103 struct ghw_hie *el;
1104 unsigned int str;
1105
1106 t = fgetc (h->stream);
1107 if (t == EOF)
1108 return -1;
1109 if (t == 0)
1110 break;
1111
1112 if (t == ghw_hie_eos)
1113 {
1114 blk = blk->parent;
1115 if (blk->u.blk.child == NULL)
1116 last = &blk->u.blk.child;
1117 else
1118 {
1119 struct ghw_hie *l = blk->u.blk.child;
1120 while (l->brother != NULL)
1121 l = l->brother;
1122 last = &l->brother;
1123 }
1124
1125 continue;
1126 }
1127
1128 el = (struct ghw_hie *) malloc (sizeof (struct ghw_hie));
1129 el->kind = t;
1130 el->parent = blk;
1131 el->brother = NULL;
1132
1133 /* Link. */
1134 *last = el;
1135 last = &el->brother;
1136
1137 /* Read name. */
1138 if (ghw_read_uleb128 (h, &str) != 0)
1139 return -1;
1140 el->name = h->str_table[str];
1141
1142 switch (t)
1143 {
1144 case ghw_hie_eoh:
1145 case ghw_hie_design:
1146 case ghw_hie_eos:
1147 /* Should not be here. */
1148 abort ();
1149 case ghw_hie_process:
1150 el->u.blk.child = NULL;
1151 break;
1152 case ghw_hie_block:
1153 case ghw_hie_generate_if:
1154 case ghw_hie_generate_for:
1155 case ghw_hie_instance:
1156 case ghw_hie_generic:
1157 case ghw_hie_package:
1158 /* Create a block. */
1159 el->u.blk.child = NULL;
1160
1161 if (t == ghw_hie_generate_for)
1162 {
1163 el->u.blk.iter_type = ghw_read_typeid (h);
1164 el->u.blk.iter_value = malloc (sizeof (union ghw_val));
1165 if (ghw_read_value
1166 (h, el->u.blk.iter_value, el->u.blk.iter_type) < 0)
1167 return -1;
1168 }
1169 blk = el;
1170 last = &el->u.blk.child;
1171 break;
1172 case ghw_hie_signal:
1173 case ghw_hie_port_in:
1174 case ghw_hie_port_out:
1175 case ghw_hie_port_inout:
1176 case ghw_hie_port_buffer:
1177 case ghw_hie_port_linkage:
1178 /* For a signal, read type. */
1179 {
1180 int nbr_el;
1181 unsigned int *sigs;
1182
1183 el->u.sig.type = ghw_read_typeid (h);
1184 nbr_el = get_nbr_elements (el->u.sig.type);
1185 if (nbr_el < 0)
1186 return -1;
1187 sigs =
1188 (unsigned int *) malloc ((nbr_el + 1) * sizeof (unsigned int));
1189 el->u.sig.sigs = sigs;
1190 /* Last element is NULL. */
1191 sigs[nbr_el] = 0;
1192
1193 if (h->flag_verbose > 1)
1194 printf ("signal %s: %d el [", el->name, nbr_el);
1195 if (ghw_read_signal (h, sigs, el->u.sig.type) < 0)
1196 return -1;
1197 if (h->flag_verbose > 1)
1198 {
1199 int j;
1200 for (j = 0; j < nbr_el; j++)
1201 printf (" #%u", sigs[j]);
1202 printf ("]\n");
1203 }
1204 }
1205 break;
1206 default:
1207 fprintf (stderr, "ghw_read_hie: unhandled kind %d\n", t);
1208 abort ();
1209 }
1210 }
1211
1212 /* Allocate values. */
1213 for (i = 0; i < h->nbr_sigs; i++)
1214 if (h->sigs[i].type != NULL)
1215 h->sigs[i].val = (union ghw_val *) malloc (sizeof (union ghw_val));
1216 return 0;
1217 }
1218
1219 const char *
1220 ghw_get_hie_name (struct ghw_hie *h)
1221 {
1222 switch (h->kind)
1223 {
1224 case ghw_hie_eoh:
1225 return "eoh";
1226 case ghw_hie_design:
1227 return "design";
1228 case ghw_hie_block:
1229 return "block";
1230 case ghw_hie_generate_if:
1231 return "generate-if";
1232 case ghw_hie_generate_for:
1233 return "generate-for";
1234 case ghw_hie_instance:
1235 return "instance";
1236 case ghw_hie_package:
1237 return "package";
1238 case ghw_hie_process:
1239 return "process";
1240 case ghw_hie_generic:
1241 return "generic";
1242 case ghw_hie_eos:
1243 return "eos";
1244 case ghw_hie_signal:
1245 return "signal";
1246 case ghw_hie_port_in:
1247 return "port-in";
1248 case ghw_hie_port_out:
1249 return "port-out";
1250 case ghw_hie_port_inout:
1251 return "port-inout";
1252 case ghw_hie_port_buffer:
1253 return "port-buffer";
1254 case ghw_hie_port_linkage:
1255 return "port-linkage";
1256 default:
1257 return "??";
1258 }
1259 }
1260
1261 void ghw_disp_value (union ghw_val *val, union ghw_type *type);
1262
1263 static void
1264 print_name (struct ghw_hie *hie, int full_names)
1265 {
1266 int i;
1267 int depth;
1268 struct ghw_hie *p;
1269 struct ghw_hie **buf;
1270 struct ghw_hie **end;
1271
1272 /* HIE must be valid. */
1273 assert (hie->name != NULL);
1274
1275 if (0 == full_names)
1276 {
1277 printf (" %s: ", hie->name);
1278 return;
1279 }
1280
1281 p = hie;
1282 depth = 0;
1283 while (p && p->name)
1284 {
1285 p = p->parent;
1286 ++depth;
1287 }
1288 buf = (struct ghw_hie **) malloc (depth * sizeof (struct ghw_hie *));
1289
1290 p = hie;
1291 end = depth + buf;
1292 while (p && p->name)
1293 {
1294 *(--end) = p;
1295 p = p->parent;
1296 }
1297
1298 putchar (' ');
1299 putchar ('/');
1300 for (i = 0; i < depth; ++i)
1301 {
1302 printf ("%s%s", i ? "/" : "", buf[i]->name);
1303 if (ghw_hie_generate_for == buf[i]->kind)
1304 {
1305 putchar ('(');
1306 ghw_disp_value (buf[i]->u.blk.iter_value, buf[i]->u.blk.iter_type);
1307 putchar (')');
1308 }
1309 }
1310 putchar (':');
1311 putchar (' ');
1312 free (buf);
1313 }
1314
1315 void
1316 ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
1317 {
1318 int i;
1319 int indent;
1320 struct ghw_hie *hie;
1321 struct ghw_hie *n;
1322
1323 hie = top;
1324 indent = 0;
1325
1326 while (1)
1327 {
1328 if (0 == h->flag_full_names)
1329 for (i = 0; i < indent; i++)
1330 fputc (' ', stdout);
1331 printf ("%s", ghw_get_hie_name (hie));
1332
1333 switch (hie->kind)
1334 {
1335 case ghw_hie_design:
1336 case ghw_hie_block:
1337 case ghw_hie_generate_if:
1338 case ghw_hie_generate_for:
1339 case ghw_hie_instance:
1340 case ghw_hie_process:
1341 case ghw_hie_package:
1342 if (hie->name)
1343 print_name (hie, h->flag_full_names);
1344 if (hie->kind == ghw_hie_generate_for)
1345 {
1346 printf ("(");
1347 ghw_disp_value (hie->u.blk.iter_value, hie->u.blk.iter_type);
1348 printf (")");
1349 }
1350 n = hie->u.blk.child;
1351 if (n == NULL)
1352 n = hie->brother;
1353 else
1354 indent++;
1355 break;
1356 case ghw_hie_generic:
1357 case ghw_hie_eos:
1358 abort ();
1359 case ghw_hie_signal:
1360 case ghw_hie_port_in:
1361 case ghw_hie_port_out:
1362 case ghw_hie_port_inout:
1363 case ghw_hie_port_buffer:
1364 case ghw_hie_port_linkage:
1365 {
1366 unsigned int *sigs = hie->u.sig.sigs;
1367 unsigned int k, num;
1368
1369 print_name (hie, h->flag_full_names);
1370 ghw_disp_subtype_indication (h, hie->u.sig.type);
1371 printf (":");
1372 k = 0;
1373 /* There can be 0-length signals. */
1374 while (sigs[k] != GHW_NO_SIG)
1375 {
1376 /* First signal of the range. */
1377 printf (" #%u", sigs[k]);
1378 for (num = 1; sigs[k + num] != GHW_NO_SIG; num++)
1379 if (sigs[k + num] != sigs[k + num - 1] + 1)
1380 break;
1381 if (num > 1)
1382 printf ("-#%u", sigs[k + num - 1]);
1383 k += num;
1384 }
1385 n = hie->brother;
1386 }
1387 break;
1388 default:
1389 abort ();
1390 }
1391 printf ("\n");
1392
1393 while (n == NULL)
1394 {
1395 if (hie->parent == NULL)
1396 return;
1397 hie = hie->parent;
1398 indent--;
1399 n = hie->brother;
1400 }
1401 hie = n;
1402 }
1403 }
1404
1405 int
1406 ghw_read_eoh (struct ghw_handler *h)
1407 {
1408 (void) h;
1409 return 0;
1410 }
1411
1412 int
1413 ghw_read_base (struct ghw_handler *h)
1414 {
1415 unsigned char hdr[4];
1416 int res;
1417
1418 while (1)
1419 {
1420 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1421 return -1;
1422 if (memcmp (hdr, "STR", 4) == 0)
1423 res = ghw_read_str (h);
1424 else if (memcmp (hdr, "HIE", 4) == 0)
1425 res = ghw_read_hie (h);
1426 else if (memcmp (hdr, "TYP", 4) == 0)
1427 res = ghw_read_type (h);
1428 else if (memcmp (hdr, "WKT", 4) == 0)
1429 res = ghw_read_wk_types (h);
1430 else if (memcmp (hdr, "EOH", 4) == 0)
1431 return 0;
1432 else
1433 {
1434 fprintf (stderr, "ghw_read_base: unknown GHW section %c%c%c%c\n",
1435 hdr[0], hdr[1], hdr[2], hdr[3]);
1436 return -1;
1437 }
1438 if (res != 0)
1439 {
1440 fprintf (stderr, "ghw_read_base: error in section %s\n", hdr);
1441 return res;
1442 }
1443 }
1444 }
1445
1446 int
1447 ghw_read_signal_value (struct ghw_handler *h, struct ghw_sig *s)
1448 {
1449 return ghw_read_value (h, s->val, s->type);
1450 }
1451
1452 int
1453 ghw_read_snapshot (struct ghw_handler *h)
1454 {
1455 unsigned char hdr[12];
1456 unsigned i;
1457 struct ghw_sig *s;
1458
1459 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1460 return -1;
1461
1462 if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
1463 return -1;
1464 h->snap_time = ghw_get_i64 (h, &hdr[4]);
1465 if (h->flag_verbose > 1)
1466 printf ("Time is " GHWPRI64 " fs\n", h->snap_time);
1467
1468 for (i = 0; i < h->nbr_sigs; i++)
1469 {
1470 s = &h->sigs[i];
1471 if (s->type != NULL)
1472 {
1473 if (h->flag_verbose > 1)
1474 printf ("read type %d for sig %u\n", s->type->kind, i);
1475 if (ghw_read_signal_value (h, s) < 0)
1476 return -1;
1477 }
1478 }
1479 if (fread (hdr, 4, 1, h->stream) != 1)
1480 return -1;
1481
1482 if (memcmp (hdr, "ESN", 4))
1483 return -1;
1484
1485 return 0;
1486 }
1487
1488 void ghw_disp_values (struct ghw_handler *h);
1489
1490 int
1491 ghw_read_cycle_start (struct ghw_handler *h)
1492 {
1493 unsigned char hdr[8];
1494
1495 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1496 return -1;
1497
1498 h->snap_time = ghw_get_i64 (h, hdr);
1499 return 0;
1500 }
1501
1502 int
1503 ghw_read_cycle_cont (struct ghw_handler *h, int *list)
1504 {
1505 int i;
1506 int *list_p;
1507
1508 i = 0;
1509 list_p = list;
1510 while (1)
1511 {
1512 uint32_t d;
1513
1514 /* Read delta to next signal. */
1515 if (ghw_read_uleb128 (h, &d) < 0)
1516 return -1;
1517 if (d == 0)
1518 {
1519 /* Last signal reached. */
1520 break;
1521 }
1522
1523 /* Find next signal. */
1524 while (d > 0)
1525 {
1526 i++;
1527 if (h->sigs[i].type != NULL)
1528 d--;
1529 }
1530
1531 if (ghw_read_signal_value (h, &h->sigs[i]) < 0)
1532 return -1;
1533 if (list_p)
1534 *list_p++ = i;
1535 }
1536
1537 if (list_p)
1538 *list_p = 0;
1539 return 0;
1540 }
1541
1542 int
1543 ghw_read_cycle_next (struct ghw_handler *h)
1544 {
1545 int64_t d_time;
1546
1547 if (ghw_read_lsleb128 (h, &d_time) < 0)
1548 return -1;
1549 if (d_time == -1)
1550 return 0;
1551 h->snap_time += d_time;
1552 return 1;
1553 }
1554
1555 int
1556 ghw_read_cycle_end (struct ghw_handler *h)
1557 {
1558 char hdr[4];
1559
1560 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1561 return -1;
1562 if (memcmp (hdr, "ECY", 4))
1563 return -1;
1564
1565 return 0;
1566 }
1567
1568 static const char *
1569 ghw_get_lit (union ghw_type *type, unsigned e)
1570 {
1571 if (e >= type->en.nbr)
1572 return "??";
1573 else
1574 return type->en.lits[e];
1575 }
1576
1577 static void
1578 ghw_disp_lit (union ghw_type *type, unsigned e)
1579 {
1580 printf ("%s (%u)", ghw_get_lit (type, e), e);
1581 }
1582
1583 void
1584 ghw_disp_value (union ghw_val *val, union ghw_type *type)
1585 {
1586 switch (ghw_get_base_type (type)->kind)
1587 {
1588 case ghdl_rtik_type_b2:
1589 ghw_disp_lit (type, val->b2);
1590 break;
1591 case ghdl_rtik_type_e8:
1592 ghw_disp_lit (type, val->e8);
1593 break;
1594 case ghdl_rtik_type_i32:
1595 printf (GHWPRI32, val->i32);
1596 break;
1597 case ghdl_rtik_type_p64:
1598 printf (GHWPRI64, val->i64);
1599 break;
1600 case ghdl_rtik_type_f64:
1601 printf ("%g", val->f64);
1602 break;
1603 default:
1604 fprintf (stderr, "ghw_disp_value: cannot handle type %d\n", type->kind);
1605 abort ();
1606 }
1607 }
1608
1609 /* Put the ASCII representation of VAL into BUF, whose size if LEN.
1610 A NUL is always written to BUF.
1611 */
1612 void
1613 ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type)
1614 {
1615 union ghw_type *base = ghw_get_base_type (type);
1616
1617 switch (base->kind)
1618 {
1619 case ghdl_rtik_type_b2:
1620 if (val->b2 <= 1)
1621 {
1622 strncpy (buf, base->en.lits[val->b2], len - 1);
1623 buf[len - 1] = 0;
1624 }
1625 else
1626 {
1627 snprintf (buf, len, "?%d", val->b2);
1628 }
1629 break;
1630 case ghdl_rtik_type_e8:
1631 if (val->b2 <= base->en.nbr)
1632 {
1633 strncpy (buf, base->en.lits[val->e8], len - 1);
1634 buf[len - 1] = 0;
1635 }
1636 else
1637 {
1638 snprintf (buf, len, "?%d", val->e8);
1639 }
1640 break;
1641 case ghdl_rtik_type_i32:
1642 snprintf (buf, len, GHWPRI32, val->i32);
1643 break;
1644 case ghdl_rtik_type_p64:
1645 snprintf (buf, len, GHWPRI64, val->i64);
1646 break;
1647 case ghdl_rtik_type_f64:
1648 snprintf (buf, len, "%g", val->f64);
1649 break;
1650 default:
1651 snprintf (buf, len, "?bad type %d?", type->kind);
1652 }
1653 }
1654
1655 static char
1656 is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal)
1657 {
1658 int i;
1659 for (i = 0; i < nb_signals_to_keep; ++i)
1660 {
1661 if (signal == signals_to_keep[i])
1662 {
1663 return 0;
1664 }
1665 }
1666 return 1;
1667 }
1668
1669 void
1670 ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep,
1671 int nb_signals_to_keep)
1672 {
1673 unsigned i;
1674
1675 if (0 < nb_signals_to_keep && 0 != signals_to_keep)
1676 {
1677 if (0 == h->skip_sigs)
1678 {
1679 h->skip_sigs = (char *) malloc (sizeof (char) * h->nbr_sigs);
1680 }
1681 for (i = 0; i < h->nbr_sigs; ++i)
1682 {
1683 h->skip_sigs[i] =
1684 is_skip_signal (signals_to_keep, nb_signals_to_keep, i);
1685 }
1686 }
1687 else
1688 {
1689 if (0 != h->skip_sigs)
1690 {
1691 free (h->skip_sigs);
1692 h->skip_sigs = 0;
1693 }
1694 }
1695 }
1696
1697 void
1698 ghw_disp_values (struct ghw_handler *h)
1699 {
1700 unsigned i;
1701 for (i = 0; i < h->nbr_sigs; i++)
1702 {
1703 struct ghw_sig *s = &h->sigs[i];
1704 int skip = (0 != h->skip_sigs && (0 != h->skip_sigs[i]));
1705 if (s->type != NULL && !skip)
1706 {
1707 printf ("#%u: ", i);
1708 ghw_disp_value (s->val, s->type);
1709 printf ("\n");
1710 }
1711 }
1712 }
1713
1714 int
1715 ghw_read_directory (struct ghw_handler *h)
1716 {
1717 unsigned char hdr[8];
1718 int nbr_entries;
1719 int i;
1720
1721 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1722 return -1;
1723
1724 nbr_entries = ghw_get_i32 (h, &hdr[4]);
1725
1726 if (h->flag_verbose)
1727 printf ("Directory (%d entries):\n", nbr_entries);
1728
1729 for (i = 0; i < nbr_entries; i++)
1730 {
1731 unsigned char ent[8];
1732 int pos;
1733
1734 if (fread (ent, sizeof (ent), 1, h->stream) != 1)
1735 return -1;
1736
1737 pos = ghw_get_i32 (h, &ent[4]);
1738 if (h->flag_verbose)
1739 printf (" %s at %d\n", ent, pos);
1740 }
1741
1742 if (fread (hdr, 4, 1, h->stream) != 1)
1743 return -1;
1744 if (memcmp (hdr, "EOD", 4))
1745 return -1;
1746 return 0;
1747 }
1748
1749 int
1750 ghw_read_tailer (struct ghw_handler *h)
1751 {
1752 unsigned char hdr[8];
1753 int pos;
1754
1755 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1756 return -1;
1757
1758 pos = ghw_get_i32 (h, &hdr[4]);
1759
1760 if (h->flag_verbose)
1761 printf ("Tailer: directory at %d\n", pos);
1762 return 0;
1763 }
1764
1765 enum ghw_res
1766 ghw_read_sm_hdr (struct ghw_handler *h, int *list)
1767 {
1768 unsigned char hdr[4];
1769 int res;
1770
1771 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1772 {
1773 if (feof (h->stream))
1774 return ghw_res_eof;
1775 else
1776 return ghw_res_error;
1777 }
1778 if (memcmp (hdr, "SNP", 4) == 0)
1779 {
1780 res = ghw_read_snapshot (h);
1781 if (res < 0)
1782 return res;
1783 return ghw_res_snapshot;
1784 }
1785 else if (memcmp (hdr, "CYC", 4) == 0)
1786 {
1787 res = ghw_read_cycle_start (h);
1788 if (res < 0)
1789 return res;
1790 res = ghw_read_cycle_cont (h, list);
1791 if (res < 0)
1792 return res;
1793
1794 return ghw_res_cycle;
1795 }
1796 else if (memcmp (hdr, "DIR", 4) == 0)
1797 {
1798 res = ghw_read_directory (h);
1799 }
1800 else if (memcmp (hdr, "TAI", 4) == 0)
1801 {
1802 res = ghw_read_tailer (h);
1803 }
1804 else
1805 {
1806 fprintf (stderr, "unknown GHW section %c%c%c%c\n", hdr[0], hdr[1],
1807 hdr[2], hdr[3]);
1808 return -1;
1809 }
1810 if (res != 0)
1811 return res;
1812 return ghw_res_other;
1813 }
1814
1815 int
1816 ghw_read_sm (struct ghw_handler *h, enum ghw_sm_type *sm)
1817 {
1818 int res;
1819
1820 while (1)
1821 {
1822 /* printf ("sm: state = %d\n", *sm); */
1823 switch (*sm)
1824 {
1825 case ghw_sm_init:
1826 case ghw_sm_sect:
1827 res = ghw_read_sm_hdr (h, NULL);
1828 switch (res)
1829 {
1830 case ghw_res_other:
1831 break;
1832 case ghw_res_snapshot:
1833 *sm = ghw_sm_sect;
1834 return res;
1835 case ghw_res_cycle:
1836 *sm = ghw_sm_cycle;
1837 return res;
1838 default:
1839 return res;
1840 }
1841 break;
1842 case ghw_sm_cycle:
1843 if (0)
1844 printf ("Time is " GHWPRI64 " fs\n", h->snap_time);
1845 if (0)
1846 ghw_disp_values (h);
1847
1848 res = ghw_read_cycle_next (h);
1849 if (res < 0)
1850 return res;
1851 if (res == 1)
1852 {
1853 res = ghw_read_cycle_cont (h, NULL);
1854 if (res < 0)
1855 return res;
1856 return ghw_res_cycle;
1857 }
1858 res = ghw_read_cycle_end (h);
1859 if (res < 0)
1860 return res;
1861 *sm = ghw_sm_sect;
1862 break;
1863 }
1864 }
1865 }
1866
1867 int
1868 ghw_read_cycle (struct ghw_handler *h)
1869 {
1870 int res;
1871
1872 res = ghw_read_cycle_start (h);
1873 if (res < 0)
1874 return res;
1875 while (1)
1876 {
1877 res = ghw_read_cycle_cont (h, NULL);
1878 if (res < 0)
1879 return res;
1880
1881 if (0)
1882 printf ("Time is " GHWPRI64 " fs\n", h->snap_time);
1883 if (0)
1884 ghw_disp_values (h);
1885
1886 res = ghw_read_cycle_next (h);
1887 if (res < 0)
1888 return res;
1889 if (res == 0)
1890 break;
1891 }
1892 res = ghw_read_cycle_end (h);
1893 return res;
1894 }
1895
1896 int
1897 ghw_read_dump (struct ghw_handler *h)
1898 {
1899 unsigned char hdr[4];
1900 int res;
1901
1902 while (1)
1903 {
1904 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1905 {
1906 if (feof (h->stream))
1907 return 0;
1908 else
1909 return -1;
1910 }
1911 if (memcmp (hdr, "SNP", 4) == 0)
1912 {
1913 res = ghw_read_snapshot (h);
1914 if (0 && res >= 0)
1915 ghw_disp_values (h);
1916 }
1917 else if (memcmp (hdr, "CYC", 4) == 0)
1918 {
1919 res = ghw_read_cycle (h);
1920 }
1921 else if (memcmp (hdr, "DIR", 4) == 0)
1922 {
1923 res = ghw_read_directory (h);
1924 }
1925 else if (memcmp (hdr, "TAI", 4) == 0)
1926 {
1927 res = ghw_read_tailer (h);
1928 }
1929 else
1930 {
1931 fprintf (stderr, "unknown GHW section %c%c%c%c\n", hdr[0], hdr[1],
1932 hdr[2], hdr[3]);
1933 return -1;
1934 }
1935 if (res != 0)
1936 return res;
1937 }
1938 }
1939
1940 struct ghw_section ghw_sections[] = { {"\0\0\0", NULL},
1941 {"STR", ghw_read_str},
1942 {"HIE", ghw_read_hie},
1943 {"TYP", ghw_read_type},
1944 {"WKT", ghw_read_wk_types},
1945 {"EOH", ghw_read_eoh},
1946 {"SNP", ghw_read_snapshot},
1947 {"CYC", ghw_read_cycle},
1948 {"DIR", ghw_read_directory},
1949 {"TAI", ghw_read_tailer}
1950 };
1951
1952 int
1953 ghw_read_section (struct ghw_handler *h)
1954 {
1955 unsigned char hdr[4];
1956 unsigned i;
1957
1958 if (fread (hdr, sizeof (hdr), 1, h->stream) != 1)
1959 {
1960 if (feof (h->stream))
1961 return -2;
1962 else
1963 return -1;
1964 }
1965
1966 for (i = 1; i < sizeof (ghw_sections) / sizeof (*ghw_sections); i++)
1967 if (memcmp (hdr, ghw_sections[i].name, 4) == 0)
1968 return i;
1969
1970 fprintf (stderr, "ghw_read_section: unknown GHW section %c%c%c%c\n", hdr[0],
1971 hdr[1], hdr[2], hdr[3]);
1972 return 0;
1973 }
1974
1975 void
1976 ghw_close (struct ghw_handler *h)
1977 {
1978 if (h->stream)
1979 {
1980 if (h->stream_ispipe)
1981 pclose (h->stream);
1982 else
1983 fclose (h->stream);
1984
1985 h->stream = NULL;
1986 }
1987 }
1988
1989 const char *
1990 ghw_get_dir (int is_downto)
1991 {
1992 return is_downto ? "downto" : "to";
1993 }
1994
1995 void
1996 ghw_disp_range (union ghw_type *type, union ghw_range *rng)
1997 {
1998 switch (rng->kind)
1999 {
2000 case ghdl_rtik_type_b2:
2001 printf ("%s %s %s", ghw_get_lit (type, rng->b2.left),
2002 ghw_get_dir (rng->b2.dir), ghw_get_lit (type, rng->b2.right));
2003 break;
2004 case ghdl_rtik_type_e8:
2005 printf ("%s %s %s", ghw_get_lit (type, rng->e8.left),
2006 ghw_get_dir (rng->e8.dir), ghw_get_lit (type, rng->e8.right));
2007 break;
2008 case ghdl_rtik_type_i32:
2009 case ghdl_rtik_type_p32:
2010 printf (GHWPRI32 " %s " GHWPRI32, rng->i32.left,
2011 ghw_get_dir (rng->i32.dir), rng->i32.right);
2012 break;
2013 case ghdl_rtik_type_i64:
2014 case ghdl_rtik_type_p64:
2015 printf (GHWPRI64 " %s " GHWPRI64, rng->i64.left,
2016 ghw_get_dir (rng->i64.dir), rng->i64.right);
2017 break;
2018 case ghdl_rtik_type_f64:
2019 printf ("%g %s %g", rng->f64.left, ghw_get_dir (rng->f64.dir),
2020 rng->f64.right);
2021 break;
2022 default:
2023 printf ("?(%d)", rng->kind);
2024 }
2025 }
2026
2027 static void
2028 ghw_disp_array_subtype_bounds (struct ghw_subtype_array *a)
2029 {
2030 unsigned i;
2031 struct ghw_type_array *base =
2032 (struct ghw_type_array *) ghw_get_base_type (a->base);
2033
2034 printf (" (");
2035 for (i = 0; i < base->nbr_dim; i++)
2036 {
2037 if (i != 0)
2038 printf (", ");
2039 ghw_disp_range (base->dims[i], a->rngs[i]);
2040 }
2041 printf (")");
2042 }
2043
2044 static void
2045 ghw_disp_record_subtype_bounds (struct ghw_subtype_record *sr)
2046 {
2047 struct ghw_type_record *base = sr->base;
2048 int is_first = 1;
2049 unsigned i;
2050
2051 for (i = 0; i < base->nbr_fields; i++)
2052 {
2053 if (sr->els[i].type != base->els[i].type)
2054 {
2055 if (is_first)
2056 {
2057 printf ("(");
2058 is_first = 0;
2059 }
2060 else
2061 printf (", ");
2062 printf ("%s", base->els[i].name);
2063 switch (sr->els[i].type->kind)
2064 {
2065 case ghdl_rtik_subtype_array:
2066 ghw_disp_array_subtype_bounds (&sr->els[i].type->sa);
2067 break;
2068 case ghdl_rtik_subtype_record:
2069 ghw_disp_record_subtype_bounds (&sr->els[i].type->sr);
2070 break;
2071 default:
2072 printf ("??? (%d)", sr->els[i].type->kind);
2073 }
2074 }
2075 }
2076 if (!is_first)
2077 printf (")");
2078 }
2079
2080 static void
2081 ghw_disp_subtype_definition (struct ghw_handler *h, union ghw_type *t)
2082 {
2083 switch (t->kind)
2084 {
2085 case ghdl_rtik_subtype_scalar:
2086 {
2087 struct ghw_subtype_scalar *s = &t->ss;
2088 ghw_disp_typename (h, s->base);
2089 printf (" range ");
2090 ghw_disp_range (s->base, s->rng);
2091 } break;
2092 case ghdl_rtik_subtype_array:
2093 {
2094 struct ghw_subtype_array *a = &t->sa;
2095
2096 ghw_disp_typename (h, (union ghw_type *) a->base);
2097 ghw_disp_array_subtype_bounds (a);
2098 } break;
2099 case ghdl_rtik_subtype_record:
2100 {
2101 struct ghw_subtype_record *sr = &t->sr;
2102
2103 ghw_disp_typename (h, (union ghw_type *) sr->base);
2104 ghw_disp_record_subtype_bounds (sr);
2105 } break;
2106 case ghdl_rtik_subtype_unbounded_array:
2107 case ghdl_rtik_subtype_unbounded_record:
2108 {
2109 struct ghw_subtype_unbounded_record *sur = &t->sur;
2110
2111 ghw_disp_typename (h, (union ghw_type *) sur->base);
2112 } break;
2113 default:
2114 printf ("ghw_disp_subtype_definition: unhandled type kind %d\n",
2115 t->kind);
2116 }
2117 }
2118
2119 static int
2120 ghw_is_anonymous_type (struct ghw_handler *h, union ghw_type *t)
2121 {
2122 return t->common.name == h->str_table[0];
2123 }
2124
2125 void
2126 ghw_disp_subtype_indication (struct ghw_handler *h, union ghw_type *t)
2127 {
2128 if (ghw_is_anonymous_type (h, t))
2129 {
2130 /* Anonymous subtype. */
2131 ghw_disp_subtype_definition (h, t);
2132 }
2133 else
2134 ghw_disp_typename (h, t);
2135 }
2136
2137 void
2138 ghw_disp_type (struct ghw_handler *h, union ghw_type *t)
2139 {
2140 switch (t->kind)
2141 {
2142 case ghdl_rtik_type_b2:
2143 case ghdl_rtik_type_e8:
2144 {
2145 struct ghw_type_enum *e = &t->en;
2146 unsigned i;
2147
2148 printf ("type %s is (", e->name);
2149 for (i = 0; i < e->nbr; i++)
2150 {
2151 if (i != 0)
2152 printf (", ");
2153 printf ("%s", e->lits[i]);
2154 }
2155 printf (");");
2156 if (e->wkt != ghw_wkt_unknown)
2157 printf (" -- WKT:%d", e->wkt);
2158 printf ("\n");
2159 }
2160 break;
2161 case ghdl_rtik_type_i32:
2162 case ghdl_rtik_type_f64:
2163 {
2164 struct ghw_type_scalar *s = &t->sc;
2165 printf ("type %s is range <>;\n", s->name);
2166 } break;
2167 case ghdl_rtik_type_p32:
2168 case ghdl_rtik_type_p64:
2169 {
2170 unsigned i;
2171
2172 struct ghw_type_physical *p = &t->ph;
2173 printf ("type %s is range <> units\n", p->name);
2174 for (i = 0; i < p->nbr_units; i++)
2175 {
2176 struct ghw_unit *u = &p->units[i];
2177 printf (" %s = " GHWPRI64 " %s;\n", u->name, u->val,
2178 p->units[0].name);
2179 }
2180 printf ("end units\n");
2181 } break;
2182 case ghdl_rtik_type_array:
2183 {
2184 struct ghw_type_array *a = &t->ar;
2185 unsigned i;
2186
2187 printf ("type %s is array (", a->name);
2188 for (i = 0; i < a->nbr_dim; i++)
2189 {
2190 if (i != 0)
2191 printf (", ");
2192 ghw_disp_typename (h, a->dims[i]);
2193 printf (" range <>");
2194 }
2195 printf (") of ");
2196 ghw_disp_subtype_indication (h, a->el);
2197 printf (";\n");
2198 }
2199 break;
2200 case ghdl_rtik_type_record:
2201 {
2202 struct ghw_type_record *r = &t->rec;
2203 unsigned i;
2204
2205 printf ("type %s is record\n", r->name);
2206 for (i = 0; i < r->nbr_fields; i++)
2207 {
2208 printf (" %s: ", r->els[i].name);
2209 ghw_disp_subtype_indication (h, r->els[i].type);
2210 printf (";\n");
2211 }
2212 printf ("end record;\n");
2213 }
2214 break;
2215 case ghdl_rtik_subtype_array:
2216 case ghdl_rtik_subtype_scalar:
2217 case ghdl_rtik_subtype_record:
2218 case ghdl_rtik_subtype_unbounded_array:
2219 case ghdl_rtik_subtype_unbounded_record:
2220 {
2221 struct ghw_type_common *c = &t->common;
2222 printf ("subtype %s is ", c->name);
2223 ghw_disp_subtype_definition (h, t);
2224 printf (";\n");
2225 } break;
2226 default:
2227 printf ("ghw_disp_type: unhandled type kind %d\n", t->kind);
2228 }
2229 }
2230
2231 void
2232 ghw_disp_types (struct ghw_handler *h)
2233 {
2234 unsigned i;
2235
2236 for (i = 0; i < h->nbr_types; i++)
2237 if (h->flag_verbose || !ghw_is_anonymous_type (h, h->types[i]))
2238 ghw_disp_type (h, h->types[i]);
2239 }
0 /* GHDL Wavefile reader library.
1 Copyright (C) 2005-2017 Tristan Gingold
2
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <gnu.org/licenses>.
15 */
16
17 #ifndef _LIBGHW_H_
18 #define _LIBGHW_H_
19
20 #include <stdio.h>
21 #include <stdlib.h>
22
23 /* To be libraries friendly. */
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 /* The libghw uses the standard c99 int32_t and int64_t. They are declared
29 in stdint.h. Header inttypes.h includes stdint.h and provides macro for
30 printf and co specifiers. Use it if known to be available. */
31
32 #if defined(__cplusplus) || \
33 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
34 defined(HAVE_INTTYPES_H)
35 /* Use C99 standard header. */
36 #include <inttypes.h>
37 #define GHWPRI64 "%" PRId64
38 #define GHWPRI32 "%" PRId32
39 #else
40 #include <stdint.h>
41 #define GHWPRI64 "%lld"
42 #define GHWPRI32 "%d"
43 #endif
44
45 enum ghdl_rtik
46 {
47 ghdl_rtik_top, /* 0 */
48 ghdl_rtik_library,
49 ghdl_rtik_package,
50 ghdl_rtik_package_body,
51 ghdl_rtik_entity,
52 ghdl_rtik_architecture, /* 5 */
53 ghdl_rtik_process,
54 ghdl_rtik_block,
55 ghdl_rtik_if_generate,
56 ghdl_rtik_for_generate,
57 ghdl_rtik_instance,
58 ghdl_rtik_constant,
59 ghdl_rtik_iterator,
60 ghdl_rtik_variable,
61 ghdl_rtik_signal,
62 ghdl_rtik_file,
63 ghdl_rtik_port,
64 ghdl_rtik_generic,
65 ghdl_rtik_alias,
66 ghdl_rtik_guard,
67 ghdl_rtik_component,
68 ghdl_rtik_attribute,
69 ghdl_rtik_type_b2, /* 22 */
70 ghdl_rtik_type_e8,
71 ghdl_rtik_type_e32,
72 ghdl_rtik_type_i32, /* 25 */
73 ghdl_rtik_type_i64,
74 ghdl_rtik_type_f64,
75 ghdl_rtik_type_p32,
76 ghdl_rtik_type_p64,
77 ghdl_rtik_type_access, /* 30 */
78 ghdl_rtik_type_array,
79 ghdl_rtik_type_record,
80 ghdl_rtik_type_file,
81 ghdl_rtik_subtype_scalar,
82 ghdl_rtik_subtype_array, /* 35 */
83 ghdl_rtik_subtype_array_ptr, /* Obsolete. */
84 ghdl_rtik_subtype_unbounded_array,
85 ghdl_rtik_subtype_record,
86 ghdl_rtik_subtype_unbounded_record,
87 #if 0
88 ghdl_rtik_subtype_access, /* 40 */
89 ghdl_rtik_type_protected,
90 ghdl_rtik_element,
91 ghdl_rtik_unit,
92 ghdl_rtik_attribute_transaction,
93 ghdl_rtik_attribute_quiet,
94 ghdl_rtik_attribute_stable,
95 #endif
96 ghdl_rtik_error
97 };
98
99 /* Well-known types. */
100 enum ghw_wkt_type
101 {
102 ghw_wkt_unknown,
103 ghw_wkt_boolean,
104 ghw_wkt_bit,
105 ghw_wkt_std_ulogic
106 };
107
108 struct ghw_range_b2
109 {
110 enum ghdl_rtik kind:8;
111 int dir:8; /* 0: to, !0: downto. */
112 unsigned char left;
113 unsigned char right;
114 };
115
116 struct ghw_range_e8
117 {
118 enum ghdl_rtik kind:8;
119 int dir:8; /* 0: to, !0: downto. */
120 unsigned char left;
121 unsigned char right;
122 };
123
124 struct ghw_range_i32
125 {
126 enum ghdl_rtik kind:8;
127 int dir:8; /* 0: to, !0: downto. */
128 int32_t left;
129 int32_t right;
130 };
131
132 struct ghw_range_i64
133 {
134 enum ghdl_rtik kind:8;
135 int dir:8;
136 int64_t left;
137 int64_t right;
138 };
139
140 struct ghw_range_f64
141 {
142 enum ghdl_rtik kind:8;
143 int dir:8;
144 double left;
145 double right;
146 };
147
148 union ghw_range
149 {
150 enum ghdl_rtik kind:8;
151 struct ghw_range_b2 b2;
152 struct ghw_range_e8 e8;
153 struct ghw_range_i32 i32;
154 struct ghw_range_i64 i64;
155 struct ghw_range_f64 f64;
156 };
157
158 /* Note: the first two fields must be kind and name. */
159 union ghw_type;
160
161 struct ghw_type_common
162 {
163 enum ghdl_rtik kind;
164 const char *name;
165 };
166
167 struct ghw_type_enum
168 {
169 enum ghdl_rtik kind;
170 const char *name;
171
172 enum ghw_wkt_type wkt;
173 unsigned int nbr;
174 const char **lits;
175 };
176
177 struct ghw_type_scalar
178 {
179 enum ghdl_rtik kind;
180 const char *name;
181 };
182
183 struct ghw_unit
184 {
185 const char *name;
186 int64_t val;
187 };
188
189 struct ghw_type_physical
190 {
191 enum ghdl_rtik kind;
192 const char *name;
193 uint32_t nbr_units;
194 struct ghw_unit *units;
195 };
196
197 struct ghw_type_array
198 {
199 enum ghdl_rtik kind;
200 const char *name;
201
202 unsigned int nbr_dim;
203 union ghw_type *el;
204 union ghw_type **dims;
205 };
206
207 struct ghw_subtype_unbounded_array
208 {
209 enum ghdl_rtik kind;
210 const char *name;
211
212 union ghw_type *base;
213 };
214
215 struct ghw_subtype_array
216 {
217 enum ghdl_rtik kind;
218 const char *name;
219
220 union ghw_type *base;
221 int nbr_scalars;
222 union ghw_range **rngs;
223 union ghw_type *el;
224 };
225
226 struct ghw_subtype_scalar
227 {
228 enum ghdl_rtik kind;
229 const char *name;
230
231 union ghw_type *base;
232 union ghw_range *rng;
233 };
234
235 struct ghw_record_element
236 {
237 const char *name;
238 union ghw_type *type;
239 };
240
241 struct ghw_type_record
242 {
243 enum ghdl_rtik kind;
244 const char *name;
245
246 unsigned int nbr_fields;
247 int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
248 struct ghw_record_element *els;
249 };
250
251 struct ghw_subtype_record
252 {
253 enum ghdl_rtik kind;
254 const char *name;
255
256 struct ghw_type_record *base;
257 int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
258 struct ghw_record_element *els;
259 };
260
261 struct ghw_subtype_unbounded_record
262 {
263 enum ghdl_rtik kind;
264 const char *name;
265
266 struct ghw_type_record *base;
267 };
268
269 union ghw_type
270 {
271 enum ghdl_rtik kind;
272 struct ghw_type_common common;
273 struct ghw_type_enum en;
274 struct ghw_type_scalar sc;
275 struct ghw_type_physical ph;
276 struct ghw_subtype_scalar ss;
277 struct ghw_type_array ar;
278 struct ghw_type_record rec;
279 struct ghw_subtype_array sa;
280 struct ghw_subtype_unbounded_array sua;
281 struct ghw_subtype_record sr;
282 struct ghw_subtype_unbounded_record sur;
283 };
284
285 union ghw_val
286 {
287 unsigned char b2;
288 unsigned char e8;
289 int32_t i32;
290 int64_t i64;
291 double f64;
292 };
293
294 /* A non-composite signal. */
295 struct ghw_sig
296 {
297 union ghw_type *type;
298 union ghw_val *val;
299 };
300
301 enum ghw_hie_kind
302 {
303 ghw_hie_eoh = 0,
304 ghw_hie_design = 1,
305 ghw_hie_block = 3,
306 ghw_hie_generate_if = 4,
307 ghw_hie_generate_for = 5,
308 ghw_hie_instance = 6,
309 ghw_hie_package = 7,
310 ghw_hie_process = 13,
311 ghw_hie_generic = 14,
312 ghw_hie_eos = 15,
313 ghw_hie_signal = 16,
314 ghw_hie_port_in = 17,
315 ghw_hie_port_out = 18,
316 ghw_hie_port_inout = 19,
317 ghw_hie_port_buffer = 20,
318 ghw_hie_port_linkage = 21
319 };
320
321 #define GHW_NO_SIG 0
322
323 struct ghw_hie
324 {
325 enum ghw_hie_kind kind;
326 struct ghw_hie *parent;
327 const char *name;
328 struct ghw_hie *brother;
329 union
330 {
331 struct
332 {
333 struct ghw_hie *child;
334 union ghw_type *iter_type;
335 union ghw_val *iter_value;
336 } blk;
337 struct
338 {
339 union ghw_type *type;
340 /* Array of signal elements.
341 Last element is GHW_NO_SIG (0). */
342 unsigned int *sigs;
343 } sig;
344 } u;
345 };
346
347 struct ghw_handler
348 {
349 FILE *stream;
350 /* True if STREAM was popen, else was fopen. */
351 unsigned char stream_ispipe;
352 /* True if words are big-endian. */
353 unsigned char word_be;
354 unsigned char word_len;
355 unsigned char off_len;
356 /* Minor version. */
357 int version;
358
359 /* Set by user. */
360 int flag_verbose;
361
362 /* String table. */
363 /* Number of strings. */
364 unsigned nbr_str;
365 /* Size of the strings (without nul). */
366 unsigned str_size;
367 /* String table. */
368 char **str_table;
369 /* Array containing strings. */
370 char *str_content;
371
372 /* Type table. */
373 unsigned nbr_types;
374 union ghw_type **types;
375
376 /* Non-composite (or basic) signals. */
377 unsigned nbr_sigs;
378 char *skip_sigs;
379 int flag_full_names;
380 struct ghw_sig *sigs;
381
382 /* Hierarchy. */
383 struct ghw_hie *hie;
384
385 /* Time of the next cycle. */
386 int64_t snap_time;
387 };
388
389 /* Open a GHW file with H.
390 Return < 0 in case of error. */
391 int ghw_open (struct ghw_handler *h, const char *filename);
392
393 /* Return base type of T. */
394 union ghw_type *ghw_get_base_type (union ghw_type *t);
395
396 /* Return length of RNG. */
397 int ghw_get_range_length (union ghw_range *rng);
398
399 /* Put the ASCII representation of VAL into BUF, whose size if LEN.
400 A NUL is always written to BUF. */
401 void ghw_get_value (char *buf, int len, union ghw_val *val,
402 union ghw_type *type);
403
404 const char *ghw_get_hie_name (struct ghw_hie *h);
405
406 void ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top);
407
408 int ghw_read_base (struct ghw_handler *h);
409
410 void ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep,
411 int nb_signals_to_keep);
412
413 void ghw_disp_values (struct ghw_handler *h);
414
415 int ghw_read_cycle_start (struct ghw_handler *h);
416
417 int ghw_read_cycle_cont (struct ghw_handler *h, int *list);
418
419 int ghw_read_cycle_next (struct ghw_handler *h);
420
421 int ghw_read_cycle_end (struct ghw_handler *h);
422
423 enum ghw_sm_type
424 {
425 /* At init;
426 Read section name. */
427 ghw_sm_init = 0,
428 ghw_sm_sect = 1,
429 ghw_sm_cycle = 2
430 };
431
432 enum ghw_res
433 {
434 ghw_res_error = -1,
435 ghw_res_eof = -2,
436 ghw_res_ok = 0,
437 ghw_res_snapshot = 1,
438 ghw_res_cycle = 2,
439 ghw_res_other = 3
440 };
441
442 enum ghw_res ghw_read_sm_hdr (struct ghw_handler *h, int *list);
443
444 int ghw_read_sm (struct ghw_handler *h, enum ghw_sm_type *sm);
445
446 int ghw_read_dump (struct ghw_handler *h);
447
448 struct ghw_section
449 {
450 const char name[4];
451 int (*handler) (struct ghw_handler * h);
452 };
453
454 extern struct ghw_section ghw_sections[];
455
456 int ghw_read_section (struct ghw_handler *h);
457
458 void ghw_close (struct ghw_handler *h);
459
460 const char *ghw_get_dir (int is_downto);
461
462 void ghw_disp_subtype_indication (struct ghw_handler *h, union ghw_type *t);
463
464 /* Note: TYPE must be a base type (used only to display literals). */
465 void ghw_disp_range (union ghw_type *type, union ghw_range *rng);
466
467 void ghw_disp_type (struct ghw_handler *h, union ghw_type *t);
468
469 void ghw_disp_types (struct ghw_handler *h);
470 #endif /* _LIBGHW_H_ */
116116 GLOBALS->display_grid = g_old->display_grid;
117117 GLOBALS->highlight_wavewindow = g_old->highlight_wavewindow;
118118 GLOBALS->fill_waveform = g_old->fill_waveform;
119 GLOBALS->lz_removal = g_old->lz_removal;
119120 GLOBALS->use_standard_trace_select = g_old->use_standard_trace_select;
120121 GLOBALS->disable_mouseover = g_old->disable_mouseover;
121122 GLOBALS->clipboard_mouseover = g_old->clipboard_mouseover;
633634 GLOBALS->enable_ghost_marker = old_g->enable_ghost_marker;
634635 GLOBALS->enable_horiz_grid = old_g->enable_horiz_grid;
635636 GLOBALS->fill_waveform = old_g->fill_waveform;
637 GLOBALS->lz_removal = old_g->lz_removal;
636638 GLOBALS->make_vcd_save_file = old_g->make_vcd_save_file;
637639 GLOBALS->enable_vert_grid = old_g->enable_vert_grid;
638640 GLOBALS->force_toolbars = old_g->force_toolbars;
648650 GLOBALS->show_base = old_g->show_base;
649651 GLOBALS->display_grid = old_g->display_grid;
650652 GLOBALS->highlight_wavewindow = old_g->highlight_wavewindow;
651 GLOBALS->fill_waveform = old_g->fill_waveform;
652653 GLOBALS->use_standard_trace_select = old_g->use_standard_trace_select;
653654 GLOBALS->use_big_fonts = old_g->use_big_fonts;
654655 GLOBALS->use_full_precision = old_g->use_full_precision;
44824482 t=GLOBALS->showchangeall_menu_c_1;
44834483 if(t)
44844484 {
4485 flags = t->flags & (TR_NUMMASK | TR_HIGHLIGHT);
4485 flags = t->flags & (TR_NUMMASK | TR_HIGHLIGHT | TR_ATTRIBS);
44864486 while(t)
44874487 {
44884488 if((t->flags&TR_HIGHLIGHT)&&(!(t->flags&(TR_BLANK|TR_ANALOG_BLANK_STRETCH)))&&(t->name))
44894489 {
4490 t->flags = (t->flags & ~(TR_NUMMASK | TR_HIGHLIGHT)) | flags;
4490 t->flags = (t->flags & ~(TR_NUMMASK | TR_HIGHLIGHT | TR_ATTRIBS)) | flags;
44914491 t->minmax_valid = 0; /* force analog traces to regenerate if necessary */
44924492 }
44934493 t=t->t_next;
67706770 dataformat( ~(TR_POPCNT), 0 );
67716771 }
67726772
6773 void
6774 menu_dataformat_ffo_on(gpointer null_data, guint callback_action, GtkWidget *widget)
6775 {
6776 (void)null_data;
6777 (void)callback_action;
6778 (void)widget;
6779
6780 if(GLOBALS->helpbox_is_active)
6781 {
6782 help_text_bold("\n\nData Format-Find First Rightmost One Index-On");
6783 help_text(
6784 " will step through all highlighted traces and ensure that"
6785 " bits and vectors with this qualifier will be displayed after"
6786 " going through a right->left FFO index conversion. This is a filter"
6787 " which sits before other Data Format options such as hex, etc."
6788 );
6789 return;
6790 }
6791
6792 dataformat( ~(TR_FFO), TR_FFO );
6793 }
6794
6795 void
6796 menu_dataformat_ffo_off(gpointer null_data, guint callback_action, GtkWidget *widget)
6797 {
6798 (void)null_data;
6799 (void)callback_action;
6800 (void)widget;
6801
6802 if(GLOBALS->helpbox_is_active)
6803 {
6804 help_text_bold("\n\nData Format-Find First Rightmost One Index-Off");
6805 help_text(
6806 " will step through all highlighted traces and ensure that"
6807 " bits and vectors with this qualifier will be displayed with"
6808 " normal encoding."
6809 );
6810 return;
6811 }
6812
6813 dataformat( ~(TR_FFO), 0 );
6814 }
6815
67736816
67746817 void
67756818 menu_dataformat_time(gpointer null_data, guint callback_action, GtkWidget *widget)
77837826
77847827 #ifndef WAVE_USE_MLIST_T
77857828 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(GLOBALS->item_factory_menu_c_1, menu_items[WV_MENU_FILL1].path))->active=(GLOBALS->fill_waveform)?TRUE:FALSE;
7829 #endif
7830 }
7831
7832 /**/
7833 void menu_lz_removal(gpointer null_data, guint callback_action, GtkWidget *widget)
7834 {
7835 (void)null_data;
7836 (void)callback_action;
7837 (void)widget;
7838
7839 if(GLOBALS->helpbox_is_active)
7840 {
7841 help_text_bold("\n\nShow Filled High Values");
7842 help_text(
7843 " toggles the display of leading zeros on non-filtered traces. This has no effect on filtered traces."
7844 );
7845 }
7846 else
7847 {
7848 #ifndef WAVE_USE_MLIST_T
7849 GLOBALS->lz_removal=(GLOBALS->lz_removal)?0:~0;
7850 #else
7851 GLOBALS->lz_removal = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_LZ_REMOVAL]));
7852 #endif
7853 if(GLOBALS->signalarea && GLOBALS->wavearea)
7854 {
7855 GLOBALS->signalwindow_width_dirty=1;
7856 MaxSignalLength();
7857 signalarea_configure_event(GLOBALS->signalarea, NULL);
7858 wavearea_configure_event(GLOBALS->wavearea, NULL);
7859 }
7860 DEBUG(printf("Leading Zero Removal\n"));
7861 }
7862
7863 #ifndef WAVE_USE_MLIST_T
7864 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(GLOBALS->item_factory_menu_c_1, menu_items[WV_MENU_LZ_REMOVAL].path))->active=(GLOBALS->lz_removal)?TRUE:FALSE;
77867865 #endif
77877866 }
77887867
79898068 WAVE_GTKIFE("/Edit/Data Format/Gray Filters/None", NULL, menu_dataformat_nogray, WV_MENU_GBNONE, "<Item>"),
79908069 WAVE_GTKIFE("/Edit/Data Format/Popcnt/On", NULL, menu_dataformat_popcnt_on, WV_MENU_POPON, "<Item>"),
79918070 WAVE_GTKIFE("/Edit/Data Format/Popcnt/Off", NULL, menu_dataformat_popcnt_off, WV_MENU_POPOFF, "<Item>"),
8071 WAVE_GTKIFE("/Edit/Data Format/Find First One/On", NULL, menu_dataformat_ffo_on, WV_MENU_FFOON, "<Item>"),
8072 WAVE_GTKIFE("/Edit/Data Format/Find First One/Off", NULL, menu_dataformat_ffo_off, WV_MENU_FFOOFF, "<Item>"),
79928073 WAVE_GTKIFE("/Edit/Data Format/Fixed Point Shift/On", NULL, menu_dataformat_fpshift_on, WV_MENU_FPSHIFTON, "<Item>"),
79938074 WAVE_GTKIFE("/Edit/Data Format/Fixed Point Shift/Off", NULL, menu_dataformat_fpshift_off, WV_MENU_FPSHIFTOFF, "<Item>"),
79948075 WAVE_GTKIFE("/Edit/Data Format/Fixed Point Shift/Specify", NULL, menu_dataformat_fpshift_specify, WV_MENU_FPSHIFTVAL, "<Item>"),
81078188 WAVE_GTKIFE("/View/<separator>", NULL, NULL, WV_MENU_SEP9, "<Separator>"),
81088189 WAVE_GTKIFE("/View/Show Wave Highlight", NULL, menu_show_wave_highlight, WV_MENU_SHW, "<ToggleItem>"),
81098190 WAVE_GTKIFE("/View/Show Filled High Values", NULL, menu_show_filled_high_values, WV_MENU_FILL1, "<ToggleItem>"),
8191 WAVE_GTKIFE("/View/Leading Zero Removal", NULL, menu_lz_removal, WV_MENU_LZ_REMOVAL, "<ToggleItem>"),
81108192 WAVE_GTKIFE("/View/<separator>", NULL, NULL, WV_MENU_SEP9B, "<Separator>"),
81118193 WAVE_GTKIFE("/View/Show Mouseover", NULL, menu_show_mouseover, WV_MENU_VSMO, "<ToggleItem>"),
81128194 #ifdef WAVE_USE_GTK2
82388320
82398321 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(GLOBALS->item_factory_menu_c_1, menu_items[WV_MENU_FILL1].path))->active=(GLOBALS->fill_waveform)?TRUE:FALSE;
82408322
8323 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(GLOBALS->item_factory_menu_c_1, menu_items[WV_MENU_LZ_REMOVAL].path))->active=(GLOBALS->lz_removal)?TRUE:FALSE;
8324
82418325 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(GLOBALS->item_factory_menu_c_1, menu_items[WV_MENU_HSWM].path))->active=(GLOBALS->alt_wheel_mode)?TRUE:FALSE;
82428326
82438327 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(GLOBALS->item_factory_menu_c_1,menu_items[WV_MENU_VSMO].path))->active=(GLOBALS->disable_mouseover)?FALSE:TRUE;
82948378 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_VSG]), GLOBALS->display_grid);
82958379 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_SHW]), GLOBALS->highlight_wavewindow);
82968380 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_FILL1]), GLOBALS->fill_waveform);
8381 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_LZ_REMOVAL]), GLOBALS->lz_removal);
82978382 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_HSWM]), GLOBALS->alt_wheel_mode);
82988383
82998384 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_VSMO]), !GLOBALS->disable_mouseover);
86958780 WAVE_GTKIFE("/Data Format/Gray Filters/None", NULL, menu_dataformat_nogray, WV_MENU_GBNONE, "<Item>"),
86968781 WAVE_GTKIFE("/Data Format/Popcnt/On", NULL, menu_dataformat_popcnt_on, WV_MENU_POPON, "<Item>"),
86978782 WAVE_GTKIFE("/Data Format/Popcnt/Off", NULL, menu_dataformat_popcnt_off, WV_MENU_POPOFF, "<Item>"),
8783 WAVE_GTKIFE("/Data Format/Find First One/On", NULL, menu_dataformat_ffo_on, WV_MENU_FFOON, "<Item>"),
8784 WAVE_GTKIFE("/Data Format/Find First One/Off", NULL, menu_dataformat_ffo_off, WV_MENU_FFOOFF, "<Item>"),
86988785 WAVE_GTKIFE("/Data Format/Fixed Point Shift/On", NULL, menu_dataformat_fpshift_on, WV_MENU_FPSHIFTON, "<Item>"),
86998786 WAVE_GTKIFE("/Data Format/Fixed Point Shift/Off", NULL, menu_dataformat_fpshift_off, WV_MENU_FPSHIFTOFF, "<Item>"),
87008787 WAVE_GTKIFE("/Data Format/Fixed Point Shift/Specify", NULL, menu_dataformat_fpshift_specify, WV_MENU_FPSHIFTVAL, "<Item>"),
166166 WV_MENU_GBNONE,
167167 WV_MENU_POPON,
168168 WV_MENU_POPOFF,
169 WV_MENU_FFOON,
170 WV_MENU_FFOOFF,
169171 WV_MENU_FPSHIFTON,
170172 WV_MENU_FPSHIFTOFF,
171173 WV_MENU_FPSHIFTVAL,
263265 WV_MENU_SEP9,
264266 WV_MENU_SHW,
265267 WV_MENU_FILL1,
268 WV_MENU_LZ_REMOVAL,
266269 WV_MENU_SEP9B,
267270 WV_MENU_VSMO,
268271 #ifdef WAVE_USE_GTK2
8383 if((flags & TR_TTRANSLATED) != 0) { ch[pos++] = 'T'; }
8484
8585 /* [14] */
86 if((flags & TR_FFO) != 0) { ch[pos++] = 'f'; }
87
88 /* [15] */
8689 if((flags & TR_POPCNT) != 0) { ch[pos++] = 'p'; }
8790
88 /* [15] */
91 /* [16] */
8992 if((flags & TR_FPDECSHIFT) != 0)
9093 {
9194 int ln = sprintf(ch+pos, "s(%d)", t->t_fpdecshift);
9295 pos += ln;
9396 }
9497
95 /* [16+] */
98 /* [17+] */
9699 ch[pos] = 0;
97100
98101 return(pos);
109109 if((flags & TR_TTRANSLATED) != 0) { ch[pos++] = 'T'; }
110110
111111 /* [14] */
112 if((flags & TR_FFO) != 0) { ch[pos++] = 'f'; }
113
114 /* [15] */
112115 if((flags & TR_POPCNT) != 0) { ch[pos++] = 'p'; }
113116
114 /* [15] */
117 /* [16] */
115118 if((flags & TR_FPDECSHIFT) != 0)
116119 {
117120 int ln = sprintf(ch+pos, "s(%d)", t->t_fpdecshift);
118121 pos += ln;
119122 }
120123
121 /* [16+] */
124 /* [17+] */
122125 ch[pos] = 0;
123126
124127 if(!t->vector)
276276 {
277277 DEBUG(printf("f_fill_waveform(\"%s\")\n",str));
278278 GLOBALS->fill_waveform=atoi_64(str)?1:0;
279 return(0);
280 }
281
282 int f_lz_removal(char *str)
283 {
284 DEBUG(printf("f_lz_removal(\"%s\")\n",str));
285 GLOBALS->lz_removal=atoi_64(str)?1:0;
279286 return(0);
280287 }
281288
941948 { "keep_xz_colors", f_keep_xz_colors },
942949 { "left_justify_sigs", f_left_justify_sigs },
943950 { "lxt_clock_compress_to_z", f_lxt_clock_compress_to_z },
951 { "lz_removal", f_lz_removal },
944952 { "max_fsdb_trees", f_max_fsdb_trees },
945953 { "page_divisor", f_page_divisor },
946954 { "ps_maxveclen", f_ps_maxveclen },
10971105
10981106 void read_rc_file(char *override_rc)
10991107 {
1100 FILE *handle;
1108 FILE *handle = NULL;
11011109 int i;
11021110 int num_rcitems = sizeof(rcitems)/sizeof(struct rc_entry);
11031111
11221130 #if !defined __MINGW32__ && !defined _MSC_VER
11231131 if(!(handle=fopen(rcname,"rb")))
11241132 {
1125 char *home;
1126 char *rcpath;
1127
1128 home=getpwuid(geteuid())->pw_dir;
1129 rcpath=(char *)alloca(strlen(home)+1+strlen(rcname)+1);
1130 strcpy(rcpath,home);
1131 strcat(rcpath,"/");
1132 strcat(rcpath,rcname);
1133
1134 if(!(handle=fopen(rcpath,"rb")))
1133 struct passwd *pw = NULL;
1134 char *home = NULL;
1135 char *rcpath = NULL;
1136
1137 pw=getpwuid(geteuid());
1138 if(pw)
1139 {
1140 home=pw->pw_dir;
1141 }
1142
1143 if(!home)
1144 {
1145 home = getenv("HOME");
1146 }
1147
1148 if(home)
1149 {
1150 rcpath=(char *)alloca(strlen(home)+1+strlen(rcname)+1);
1151 strcpy(rcpath,home);
1152 strcat(rcpath,"/");
1153 strcat(rcpath,rcname);
1154 }
1155
1156 if( !rcpath || !(handle=fopen(rcpath,"rb")) )
11351157 {
11361158 #ifdef MAC_INTEGRATION
11371159 const gchar *bundle_id = gtkosx_application_get_bundle_id();
5959 (void)nothing;
6060
6161 toggle_generic(widget, TR_POPCNT);
62 }
63 static void toggle6_callback(GtkWidget *widget, GtkWidget *nothing)
64 {
65 (void)nothing;
66
67 toggle_generic(widget, TR_FFO);
6268 }
6369
6470 static void enter_callback(GtkWidget *widget, GtkWidget *nothing)
288294 gtk_widget_show (GLOBALS->toggle5_showchange_c_1);
289295 gtkwave_signal_connect (GTK_OBJECT (GLOBALS->toggle5_showchange_c_1), "toggled", GTK_SIGNAL_FUNC(toggle5_callback), NULL);
290296
297 GLOBALS->toggle6_showchange_c_1=gtk_check_button_new_with_label("Find First One");
298 gtk_box_pack_start (GTK_BOX (box1), GLOBALS->toggle6_showchange_c_1, TRUE, TRUE, 0);
299 if(GLOBALS->flags_showchange_c_1&TR_FFO)gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(GLOBALS->toggle6_showchange_c_1), TRUE);
300 gtk_widget_show (GLOBALS->toggle6_showchange_c_1);
301 gtkwave_signal_connect (GTK_OBJECT (GLOBALS->toggle6_showchange_c_1), "toggled", GTK_SIGNAL_FUNC(toggle6_callback), NULL);
302
291303 gtk_container_add (GTK_CONTAINER (main_vbox), hbox);
292304
293305 separator = gtk_hseparator_new ();
1818 /* GDK_KEY_equal defined from gtk2 2.22 onwards. */
1919 #ifndef GDK_KEY_equal
2020 #define GDK_KEY_equal GDK_equal
21 #endif
22 #ifndef GDK_KEY_Up
23 #define GDK_KEY_Up GDK_Up
24 #endif
25 #ifndef GDK_KEY_KP_Up
26 #define GDK_KEY_KP_Up GDK_KP_Up
27 #endif
28 #ifndef GDK_KEY_Down
29 #define GDK_KEY_Down GDK_Down
30 #endif
31 #ifndef GDK_KEY_KP_Down
32 #define GDK_KEY_KP_Down GDK_KP_Down
2133 #endif
2234
2335 #undef FOCUS_DEBUG_MSGS
470482 int which;
471483 gint rc = FALSE;
472484 int yscroll;
485 int ud_kill = 0;
473486
474487 #ifdef FOCUS_DEBUG_MSGS
475488 printf("focus: %d %08x %08x %08x\n", GTK_WIDGET_HAS_FOCUS(GLOBALS->signalarea_event_box),
548561 num_traces_displayable=(GLOBALS->signalarea->allocation.height)/(GLOBALS->fontheight);
549562 num_traces_displayable--; /* for the time trace that is always there */
550563
551 if(num_traces_displayable<GLOBALS->traces.visible)
564 if(event->state & GDK_SHIFT_MASK)
565 {
566 Trptr t = NULL, t2 = NULL;
567 Trptr tc = NULL, th = NULL;
568 int num_high = 0;
569
570 if((event->keyval == GDK_KEY_Up) || (event->keyval == GDK_KEY_KP_Up))
571 {
572 ud_kill = 1;
573 for(t=GLOBALS->traces.first;t;t=t->t_next)
574 {
575 if(t->flags&TR_HIGHLIGHT)
576 {
577 if(!th) th = t;
578 num_high++;
579 }
580
581 if(t->is_cursor)
582 {
583 tc = t;
584 }
585 }
586
587 if(num_high <= 1)
588 {
589 t = th ? GivePrevTrace(th) : GLOBALS->topmost_trace;
590 }
591 else
592 {
593 t = tc ? GivePrevTrace(tc) : GLOBALS->topmost_trace;
594 }
595
596 MarkTraceCursor(t);
597 }
598 else
599 if((event->keyval == GDK_KEY_Down) || (event->keyval == GDK_KEY_KP_Down))
600 {
601 ud_kill = 1;
602 for(t=GLOBALS->traces.first;t;t=t->t_next)
603 {
604 if(t->flags&TR_HIGHLIGHT)
605 {
606 th = t;
607 num_high++;
608 }
609 if(t->is_cursor)
610 {
611 tc = t;
612 }
613 }
614
615 if(num_high <= 1)
616 {
617 t = th ? GiveNextTrace(th) : GLOBALS->topmost_trace;
618 }
619 else
620 {
621 if(tc)
622 {
623 t = GiveNextTrace(tc);
624 }
625 else
626 {
627 t = th ? GiveNextTrace(th) : GLOBALS->topmost_trace;
628 }
629 }
630
631 MarkTraceCursor(t);
632 }
633
634 if(t)
635 {
636 int top_target = 0;
637 target = 0;
638 which=num_traces_displayable-1;
639
640 ClearTraces();
641 t->flags |= TR_HIGHLIGHT;
642 t2 = t;
643
644 for(t=GLOBALS->traces.first;t;t=GiveNextTrace(t))
645 {
646 if(t == GLOBALS->topmost_trace) break;
647 top_target++;
648 }
649
650 for(t=GLOBALS->traces.first;t;t=GiveNextTrace(t))
651 {
652 if(t2 == t) break;
653 target++;
654 }
655
656 if((target >= top_target) && (target <= top_target+which))
657 {
658 /* nothing */
659 }
660 else
661 {
662 if((event->keyval == GDK_KEY_Up) || (event->keyval == GDK_KEY_KP_Up))
663 {
664 if(target<0) target=0;
665 }
666 else
667 if((event->keyval == GDK_KEY_Down) || (event->keyval == GDK_KEY_KP_Down))
668 {
669 target = target - which;
670 if(target+which>=(GLOBALS->traces.visible-1)) target=GLOBALS->traces.visible-which-1;
671 }
672
673 wadj->value = target;
674 }
675
676 if(GLOBALS->cachedwhich_signalwindow_c_1==which) GLOBALS->cachedwhich_signalwindow_c_1=which-1; /* force update */
677
678 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "changed"); /* force bar update */
679 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "value_changed"); /* force text update */
680 signalarea_configure_event(GLOBALS->signalarea, NULL);
681 wavearea_configure_event(GLOBALS->wavearea, NULL);
682 }
683 }
684
685 if((num_traces_displayable<GLOBALS->traces.visible) && (!ud_kill))
552686 {
553687 switch(event->keyval)
554688 {
567701
568702 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "changed"); /* force bar update */
569703 gtk_signal_emit_by_name (GTK_OBJECT (wadj), "value_changed"); /* force text update */
704 signalarea_configure_event(GLOBALS->signalarea, NULL);
705 wavearea_configure_event(GLOBALS->wavearea, NULL);
570706 break;
571707
572708 case GDK_Up:
12271363 }
12281364 else
12291365 {
1230 t->flags ^= TR_HIGHLIGHT;
1366 t->flags ^= TR_HIGHLIGHT; MarkTraceCursor(t);
12311367 }
12321368 }
12331369 }
12341370 else
12351371 if((event->state&GDK_SHIFT_MASK)&&(GLOBALS->starting_unshifted_trace))
12361372 {
1237 int src = -1, dst = -1;
1373 int src = -1, dst = -1, dsto = -1;
12381374 int cnt = 0;
12391375
12401376 t2=GLOBALS->traces.first;
12641400 cnt++;
12651401 }
12661402
1403 dsto = dst;
12671404 if(src > dst) { int cpy; cpy = src; src = dst; dst = cpy; }
12681405 cnt = 0;
12691406 t2=GLOBALS->traces.first;
12741411 t2->flags |= TR_HIGHLIGHT;
12751412 }
12761413
1414 if(cnt == dsto) { MarkTraceCursor(t2); }
1415
12771416 cnt++;
12781417 t2=t2->t_next;
12791418 }
12971436 t2 = t2->t_next;
12981437 }
12991438
1300 if(t) { t->flags |= TR_HIGHLIGHT; } /* scan-build */
1439 if(t) { t->flags |= TR_HIGHLIGHT; MarkTraceCursor(t); } /* scan-build */
13011440 }
13021441
13031442 GLOBALS->standard_trace_dnd_degate = 0;
351351
352352 while(tnext)
353353 {
354 if(tnext->child) treenamefix(tnext->child);
354355 if(tnext->name) treenamefix_str(tnext->name);
355356 tnext=tnext->next;
356357 }
115115 uint32_t t_stem; /* source stem (if >0) for Open Hierarchy Source Def, see stem_struct_t */
116116 uint32_t t_istem; /* source stem (if >0) for Open Hierarchy Source Inst, see stem_struct_t */
117117
118 unsigned kind : 7; /* Kind of the leaf: ghwlib reads this as val & 0x7f so only 7 bits needed */
118 unsigned kind : 7; /* Kind of the leaf: libghw reads this as val & 0x7f so only 7 bits needed */
119119 unsigned children_in_gui : 1; /* indicates that the child nodes are in the gtk2 tree, but gets borrowed during tree creation for fast judy sort */
120120 char name[]; /* C99 */
121121 };
370370 gtk_clist_thaw(GTK_CLIST(ctree));
371371
372372 gtk_ctree_node_moveto(ctree, nodehist[depth-1],
373 depth /*column*/,
373 0, /*column*/ /* was originally depth instead of zero */
374374 0.5 /*row_align*/,
375375 0.5 /*col_align*/);
376376 /* printf("[treeopennode] '%s' ok\n", name); */
22122212 str=(slen>max_slen)?(wave_alloca((max_slen=slen)+32)):(str); /* more than enough */
22132213 strcpy(str,v->name);
22142214
2215 if(v->msi>=0)
2215 if((v->msi>=0)||(v->msi != v->lsi))
22162216 {
22172217 strcpy(str+slen,GLOBALS->vcd_hier_delimeter);
22182218 slen++;
20542054 str=(slen>max_slen)?(wave_alloca((max_slen=slen)+32)):(str); /* more than enough */
20552055 strcpy(str,v->name);
20562056
2057 if(v->msi>=0)
2057 if((v->msi>=0)||(v->msi != v->lsi))
20582058 {
20592059 strcpy(str+slen,GLOBALS->vcd_hier_delimeter);
20602060 slen++;
24472447 str=(slen>max_slen)?(wave_alloca((max_slen=slen)+32)):(str); /* more than enough */
24482448 strcpy(str,v->name);
24492449
2450 if(v->msi>=0)
2450 if((v->msi>=0)||(v->msi != v->lsi))
24512451 {
24522452 strcpy(str+slen,GLOBALS->vcd_hier_delimeter);
24532453 slen++;
1717 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1818 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1919 * DEALINGS IN THE SOFTWARE.
20 *
21 * SPDX-License-Identifier: MIT
2022 */
2123
2224 #ifndef WAVE_ALLOCA_H
32363236 yu=(_y0+_y1)/2;
32373237 ytext=yu-(GLOBALS->wavefont->ascent/2)+GLOBALS->wavefont->ascent;
32383238
3239 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white)&&(!kill_grid))
3240 {
3241 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
3242 TRUE,0, liney - GLOBALS->fontheight,
3243 GLOBALS->wavewidth, GLOBALS->fontheight);
3244 }
3245 else
32393246 if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid)&&(!kill_grid))
32403247 {
3241 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
3242 {
3243 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
3244 TRUE,0, liney - GLOBALS->fontheight,
3245 GLOBALS->wavewidth, GLOBALS->fontheight);
3246 }
3247 else
3248 {
3249 gdk_draw_line(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
3250 (GLOBALS->tims.start<GLOBALS->tims.first)?(GLOBALS->tims.first-GLOBALS->tims.start)*GLOBALS->pxns:0, liney,(GLOBALS->tims.last<=GLOBALS->tims.end)?(GLOBALS->tims.last-GLOBALS->tims.start)*GLOBALS->pxns:GLOBALS->wavewidth-1, liney);
3251 }
3248 gdk_draw_line(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
3249 (GLOBALS->tims.start<GLOBALS->tims.first)?(GLOBALS->tims.first-GLOBALS->tims.start)*GLOBALS->pxns:0, liney,(GLOBALS->tims.last<=GLOBALS->tims.end)?(GLOBALS->tims.last-GLOBALS->tims.start)*GLOBALS->pxns:GLOBALS->wavewidth-1, liney);
32523250 }
32533251
32543252 if((h)&&(GLOBALS->tims.start==h->time))
39953993 yu=(_y0+_y1)/2;
39963994 ytext=yu-(GLOBALS->wavefont->ascent/2)+GLOBALS->wavefont->ascent;
39973995
3998 if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid))
3996 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
39993997 {
40003998 Trptr tn = GiveNextTrace(t);
40013999 if((t->flags & TR_ANALOGMASK) && (tn) && (tn->flags & TR_ANALOG_BLANK_STRETCH))
40024000 {
4003 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
4004 {
4005 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4006 TRUE,0, liney - GLOBALS->fontheight,
4007 GLOBALS->wavewidth, GLOBALS->fontheight);
4008 }
4001 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4002 TRUE,0, liney - GLOBALS->fontheight,
4003 GLOBALS->wavewidth, GLOBALS->fontheight);
40094004 }
40104005 else
4011 {
4012 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
4013 {
4014 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4015 TRUE,0, liney - GLOBALS->fontheight,
4016 GLOBALS->wavewidth, GLOBALS->fontheight);
4017 }
4018 else
4019 {
4020 gdk_draw_line(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4021 (GLOBALS->tims.start<GLOBALS->tims.first)?(GLOBALS->tims.first-GLOBALS->tims.start)*GLOBALS->pxns:0, liney,(GLOBALS->tims.last<=GLOBALS->tims.end)?(GLOBALS->tims.last-GLOBALS->tims.start)*GLOBALS->pxns:GLOBALS->wavewidth-1, liney);
4022 }
4006 {
4007 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4008 TRUE,0, liney - GLOBALS->fontheight,
4009 GLOBALS->wavewidth, GLOBALS->fontheight);
4010 }
4011 }
4012 else
4013 if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid))
4014 {
4015 Trptr tn = GiveNextTrace(t);
4016 if((t->flags & TR_ANALOGMASK) && (tn) && (tn->flags & TR_ANALOG_BLANK_STRETCH))
4017 {
4018 }
4019 else
4020 {
4021 gdk_draw_line(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4022 (GLOBALS->tims.start<GLOBALS->tims.first)?(GLOBALS->tims.first-GLOBALS->tims.start)*GLOBALS->pxns:0, liney,(GLOBALS->tims.last<=GLOBALS->tims.end)?(GLOBALS->tims.last-GLOBALS->tims.start)*GLOBALS->pxns:GLOBALS->wavewidth-1, liney);
40234023 }
40244024 }
40254025
48164816 yu=(_y0+_y1)/2;
48174817 ytext=yu-(GLOBALS->wavefont->ascent/2)+GLOBALS->wavefont->ascent;
48184818
4819 if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid))
4819 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
48204820 {
48214821 Trptr tn = GiveNextTrace(t);
48224822 if((t->flags & TR_ANALOGMASK) && (tn) && (tn->flags & TR_ANALOG_BLANK_STRETCH))
48234823 {
4824 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
4825 {
4826 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4827 TRUE,0, liney - GLOBALS->fontheight,
4828 GLOBALS->wavewidth, GLOBALS->fontheight);
4829 }
4824 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4825 TRUE,0, liney - GLOBALS->fontheight,
4826 GLOBALS->wavewidth, GLOBALS->fontheight);
48304827 }
48314828 else
4832 {
4833 if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white))
4834 {
4835 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4836 TRUE,0, liney - GLOBALS->fontheight,
4837 GLOBALS->wavewidth, GLOBALS->fontheight);
4838 }
4839 else
4840 {
4841 gdk_draw_line(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4842 (GLOBALS->tims.start<GLOBALS->tims.first)?(GLOBALS->tims.first-GLOBALS->tims.start)*GLOBALS->pxns:0, liney,(GLOBALS->tims.last<=GLOBALS->tims.end)?(GLOBALS->tims.last-GLOBALS->tims.start)*GLOBALS->pxns:GLOBALS->wavewidth-1, liney);
4843 }
4829 {
4830 gdk_draw_rectangle(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4831 TRUE,0, liney - GLOBALS->fontheight,
4832 GLOBALS->wavewidth, GLOBALS->fontheight);
4833 }
4834 }
4835 else
4836 if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid))
4837 {
4838 Trptr tn = GiveNextTrace(t);
4839 if((t->flags & TR_ANALOGMASK) && (tn) && (tn->flags & TR_ANALOG_BLANK_STRETCH))
4840 {
4841 }
4842 else
4843 {
4844 gdk_draw_line(GLOBALS->wavepixmap_wavewindow_c_1, GLOBALS->gc.gc_grid_wavewindow_c_1,
4845 (GLOBALS->tims.start<GLOBALS->tims.first)?(GLOBALS->tims.first-GLOBALS->tims.start)*GLOBALS->pxns:0, liney,(GLOBALS->tims.last<=GLOBALS->tims.end)?(GLOBALS->tims.last-GLOBALS->tims.start)*GLOBALS->pxns:GLOBALS->wavewidth-1, liney);
48444846 }
48454847 }
48464848