Import upstream version 3.3.111
Debian Janitor
2 years ago
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. | |
8 | 8 | Some public domain clip art by contributors at http://www.sxc.hu/ website. |
9 | 9 | Hierarchy marker icons from the Silk icons set by Mark James found at the http://www.famfamfam.com/lab/icons/silk/ website. |
10 | 10 | 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. |
2 | 2 | Added user's manual pdf file to distribution in doc/. |
3 | 3 | Added vertex and rtlbrowse for sourcecode annotation. |
4 | 4 | 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() | |
6 | 6 | 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. | |
8 | 8 | 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. | |
10 | 10 | The Courier font is very bad looking and blitter mangled under |
11 | 11 | 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 | |
14 | 14 | this and cause duplicate symbols. |
15 | 15 | Saw there were still problems with courier on debian. Also |
16 | 16 | check for misc-fixed on non-cygwin systems just in case. |
34 | 34 | dumpfile loaders as the string length is known from the rc |
35 | 35 | of sprintf. |
36 | 36 | 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 | |
38 | 38 | (in practice) never really escaped. |
39 | 39 | In tree.c, treenamefix() would recurse more than necessary |
40 | 40 | such that some dotted hierarchies would cause an order of |
56 | 56 | 3.0.6 14jul06 Added "Real" option for data type display as passing around |
57 | 57 | real numbers in Verilog across modules needs to be done |
58 | 58 | with $realtobits and $bitstoreal. |
59 | Added scripting command flag --script in order to allow | |
59 | Added scripting command flag --script in order to allow | |
60 | 60 | autosetup of things that are outside of config file control. |
61 | 61 | This also allows doing things such as automated print jobs. |
62 | 62 | Added --nowm to remove window manager control on most |
67 | 67 | Added --nomenus to remove menus for the case when used in |
68 | 68 | conjunction with --xid and it is desired to create an |
69 | 69 | 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 | |
71 | 71 | 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 | |
73 | 73 | structs in color.c as found by Valgrind. |
74 | 74 | Moved .odt version of the user's guide into doc/ rather than |
75 | 75 | the pdf version as this is a sourcecode distribution so the |
80 | 80 | Found problem with directive-based string embedding in older |
81 | 81 | gcc compiler versions. |
82 | 82 | 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 | |
84 | 84 | shared memory IPC through use of the "twinwave" front end. |
85 | 85 | Updated documentation to add a section on twinwave. |
86 | 86 | 3.0.8 04aug06 Modified order of flags in twinwave as appending flags |
90 | 90 | not including getopt.h. |
91 | 91 | Removed unused "bus" element from struct fac. |
92 | 92 | 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 | |
94 | 94 | this new interactive loading functionality. |
95 | 95 | Added real_parameter vartype (Riviera Aldec 2006.6) in all |
96 | 96 | vcd loaders. |
164 | 164 | Fixed bug in draw_hptr_trace_vector_analog() that would |
165 | 165 | cause crashes on pure real vectors when zoomed out fully. |
166 | 166 | 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 | |
168 | 168 | yet so disabled there). |
169 | 169 | Added preliminary support for changing menu accelerators |
170 | 170 | through the rc file with an "accel" statement. |
172 | 172 | zero in the initial dumpvars. (would be needed anyway for |
173 | 173 | dumpers that for some reason don't as the 1st value |
174 | 174 | 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 | |
176 | 176 | timescale of "ss" being used instead of just "s". |
177 | 177 | Locale problem in printing of floating point numbers fixed |
178 | 178 | by setting up a local fixer routine in config.h for |
180 | 180 | Fix in all vcd loaders to handle "port" (along with other |
181 | 181 | keywords) that appear in non-keyword parts of the $VAR |
182 | 182 | declaration sequence. |
183 | Fixed long standing LXT bug with integer datatype on | |
183 | Fixed long standing LXT bug with integer datatype on | |
184 | 184 | trivial LXT files. (Overflow in lt_buf decoder buffer.) |
185 | 185 | 3.0.19 21dec06 More locale fixing with LC_ALL. |
186 | 186 | Added user patches from NIIBE Yutaka to remove requirement |
195 | 195 | reals. |
196 | 196 | 3.0.21 02feb07 Added support for in/out/inout evcd ports generated by |
197 | 197 | dumpports in ModelSim. |
198 | Fixed problem with hierarchy being out of order as | |
198 | Fixed problem with hierarchy being out of order as | |
199 | 199 | treegraft needed to be followed by treesort. This mostly |
200 | 200 | impacted recursive hierarchy imports by only allowing |
201 | 201 | two signals to import rather than all of them. Also there |
202 | 202 | was an inconsistency with the signal ordering with VCD vs |
203 | 203 | the database formats because of this. |
204 | 204 | 3.0.22 19feb07 Bumped up hash size from 65519 to 500009 entries for VCD |
205 | parsers. | |
205 | parsers. | |
206 | 206 | Bumped up max VCDID fastindex size to 8M entries. |
207 | 207 | Now use gperf for verilog datatypes for some speedup in |
208 | 208 | gtkwave vcd loaders. |
217 | 217 | PATH_MAX set if not defined in verilog.g for Vertex. |
218 | 218 | Regenerated configure for setenv()/unsetenv() presence |
219 | 219 | which impacts Solaris (use putenv() instead). |
220 | Regenerated configure to handle auto detect of -lnsl, | |
220 | Regenerated configure to handle auto detect of -lnsl, | |
221 | 221 | -lrpc, and -lpthread. |
222 | 222 | Added -c to file install in top-level makefile (Solaris). |
223 | 223 | Use _LARGEFILE_SOURCE value from configure with linux |
242 | 242 | that code was leftover from the vzt2vcd). |
243 | 243 | Updated manpages for vzt2vcd, lxt2vcd, and vztminer. |
244 | 244 | 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 | |
246 | 246 | somewhat related to the re-coalesce vectors feature above. |
247 | 247 | Implemented reverse of this for monolithic vectors into |
248 | 248 | 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 | |
250 | 250 | $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 | |
252 | 252 | 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 | |
254 | 254 | length zero are representative of reals with MTI: they don't |
255 | 255 | use real_parameter like Riviera does. |
256 | 256 | Updated vcd_saver.c to handle saving these implicit-var |
304 | 304 | 3.1.1 20sep07 Fixed crash in hierarchy search reload. (Wrong |
305 | 305 | pointer type introduced from code cleanup.) Adding |
306 | 306 | 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 | |
308 | 308 | search windows). Added locking in main iteration |
309 | 309 | loop to detect unexpected context switches and |
310 | 310 | fix/report them (wrong operation if it occurs). |
311 | 311 | 3.1.2 24dec07 Compiler warning cleanups from Sun compile logs. |
312 | 312 | Added named parameter support to vermin parser. |
313 | 313 | 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 | |
315 | 315 | feature of spilling vlists to a tempfile on disk. |
316 | 316 | Fixed vcd loader status bar on files > 2GB. |
317 | 317 | Removed non-growable vlists and also finalize |
327 | 327 | with the vlist_prepack rc variable. |
328 | 328 | Added --giga option to turn on vlist_spill and |
329 | 329 | 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 | |
333 | 333 | to enable the same type behavior for the signal name filter in |
334 | 334 | 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 | |
336 | 336 | reload. |
337 | 337 | 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 | |
339 | 339 | detection due to user requests. |
340 | 340 | Fixed long-standing backward edge seek bug in pattern search. |
341 | 341 | (It would miss the preceeding edge if the marker isn't already |
342 | 342 | on one.) |
343 | Added use_standard_clicking rc variable in order to enable | |
343 | Added use_standard_clicking rc variable in order to enable | |
344 | 344 | "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 | |
346 | 346 | use_standard_clicking is active. |
347 | 347 | 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 | |
349 | 349 | issues. |
350 | 350 | Recalculate signal width on reload as sometimes it was missed. |
351 | 351 | Added input focus capability to signalwindow. |
352 | 352 | 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 | |
354 | 354 | like the signal window. |
355 | 355 | Added left/right scrolling hotkeys in signal window. |
356 | Added use_toolbutton_interface environment variable which | |
356 | Added use_toolbutton_interface environment variable which | |
357 | 357 | 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 | |
359 | 359 | mode. |
360 | 360 | Update configure.ac to handle library order problem with |
361 | 361 | cygwin in rtlbrowse. |
362 | Added scrollwheel support in signal window when focused and | |
362 | Added scrollwheel support in signal window when focused and | |
363 | 363 | standard clicking is active. |
364 | 364 | Added "Use Color" and "Use Black and White" (for screendumps) |
365 | 365 | View menu options from user requests. |
430 | 430 | calls causing similar problems as necessary. |
431 | 431 | 3.1.9 20apr08 Added missing init_filetrans_data() to reload function. |
432 | 432 | 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 | |
435 | 435 | properly. |
436 | 436 | Fixed problem with edgebutton going back two edges on a |
437 | 437 | combined vector. (Cut and paste typo from strace.c.) |
444 | 444 | 3.1.12 14jul08 Compiler warning fixes. |
445 | 445 | Fixed crash in vcd recoder for b vs 01xz mixups in |
446 | 446 | malformed VCD files. |
447 | Fixed abort on VCD load for malformed size vs | |
447 | Fixed abort on VCD load for malformed size vs | |
448 | 448 | [msi:lsi] syntax. NC does this on arrays of wires. |
449 | 449 | Fix to vlist reader with --giga enabled in order to |
450 | 450 | handle reads which go off the end of the file. |
465 | 465 | for the horizontal scroller in the wavewindow. |
466 | 466 | Added sticky click semantics for clicks in signal |
467 | 467 | 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 | |
469 | 469 | view_selection_func() and/or signal handling and |
470 | 470 | 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. | |
472 | 472 | Added timestart command to savefiles which indicates |
473 | 473 | what the leftmost position should be on reload. |
474 | 474 | Added support for as/zs small timescales as well as |
476 | 476 | Adding signal name DnD support from external apps. |
477 | 477 | Force open tree nodes on initial .sav file read. |
478 | 478 | Yet more new warning (-Wall) cleanups. |
479 | Fixed ExtractNodeSingleBit for vectors which do not | |
479 | Fixed ExtractNodeSingleBit for vectors which do not | |
480 | 480 | have a zero in either the msb or lsb (e.g., [1:9]). |
481 | 481 | Added support for dragging files into the viewer |
482 | 482 | (i.e., dumpfile, savefile, stems file) |
483 | 483 | Added DnD of signal names from RTLBrowse source code |
484 | windows directly into gtkwave. | |
484 | windows directly into gtkwave. | |
485 | 485 | GTK1 compiler compatibility fixes. |
486 | 486 | Improved search performance from rtlbrowse initiated |
487 | 487 | DnD searches. |
495 | 495 | Updated -f argument file handling in vermin. |
496 | 496 | Updated tcl_helper code so that signalwindow drags of bit- |
497 | 497 | blasted vectors are properly re-coalesced for client code |
498 | for the drag. | |
498 | for the drag. | |
499 | 499 | Updated task definition in vermin so that identifiers with |
500 | 500 | dots in them can be used as task enable names. |
501 | 501 | Fixed problem in vermin preprocessor where defines in 0x0d0a |
548 | 548 | Added prelim auto-scrolling code for trace adds/copies. |
549 | 549 | Added support for Tcl repscripts. |
550 | 550 | 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 | |
552 | 552 | extremely large number of signals (e.g., 5 million). |
553 | 553 | Compile fixes for rtlbrowse in older versions of GTK2. |
554 | 554 | Remove stray tempfiles created by --giga writer under MinGW. |
555 | 555 | Removed stray file descriptor from lxt on reload. |
556 | 556 | 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 | |
558 | 558 | appropriate menu options. |
559 | 559 | 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 | |
561 | 561 | zoom_dynamic_end rc variables. |
562 | 562 | More mingw compile fixes: the whole tarball compiles now. |
563 | 563 | Use old file chooser (for now) in mingw as the new one seems |
564 | 564 | not to be re-sizeable. |
565 | 565 | Added "copy traces" to toolbar in gtkwave as copy function now |
566 | 566 | exists. |
567 | Added check for "server" in env var CYGWIN before printing | |
567 | Added check for "server" in env var CYGWIN before printing | |
568 | 568 | warning about using shared memory. |
569 | 569 | Added vpi client lxt/lxt2/vzt writers in contrib/vpi, but these |
570 | 570 | currently are not built. |
571 | 571 | 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 | |
573 | 573 | allows adding loaders for unsupported formats via data mining. |
574 | 574 | Added Tcl command setBaselineMarker. |
575 | 575 | Extload hardening on reload. |
601 | 601 | order to avoid unnecessary stack pushing. |
602 | 602 | Fixing reloader crashes in vcd_build_symbols(). |
603 | 603 | 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 | |
605 | 605 | pending more testing. |
606 | 606 | Sort filename lists from DnD in order to allow both a |
607 | 607 | dumpfile and a savefile to be dragged into the viewer and |
639 | 639 | Warning fixes for printf format strings in lxt2/vzt/ghw. |
640 | 640 | Updated VCD parser to handle names like "a[1] [3:0]". |
641 | 641 | 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 | |
643 | 643 | signal ranges. |
644 | 644 | Added extra message for help requester if file type is |
645 | 645 | MISSING_FILE in order to direct users what to do. |
692 | 692 | Fix to attempt_vecmatch_2 when no suffix encountered. |
693 | 693 | 3.3.0 25dec09 Modified unformat_time() so it can also handle floating- |
694 | 694 | point exponential format. |
695 | Integration of a large amount of group handling sourcecode | |
695 | Integration of a large amount of group handling sourcecode | |
696 | 696 | from Don Baltus / Bluespec, Inc. |
697 | 697 | Re-integrated original Simpod repscript handling. |
698 | 698 | Reworked force open tree node and moved to |
733 | 733 | file support as it is obsolete: all scripts are Tcl scripts |
734 | 734 | now. |
735 | 735 | 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 | |
737 | 737 | available. Old VZT files using -z 2 are no longer readable |
738 | 738 | but can be converted using vzt2vcd from an old version of |
739 | 739 | gtkwave. |
744 | 744 | In fstapi.c now use tmpfile() to generate tempfiles in |
745 | 745 | order to speed up operation on networked filesystems. |
746 | 746 | 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 | |
748 | 748 | "tsec uncompress" failure on reads. |
749 | 749 | Fixed missing dependencies in various Makefile.am files. |
750 | 750 | 3.3.2 05jan10 Emergency fix for ghw.c as it was missing a close comment |
791 | 791 | force_open_tree_nodes loop (spotted using an alternate |
792 | 792 | allocator). |
793 | 793 | Added optional preliminary Judy array support. |
794 | Fixed compiler warnings. | |
794 | Fixed compiler warnings. | |
795 | 795 | Fixed toggle max hier so it toggles back and forth between |
796 | 796 | 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. | |
798 | 798 | Remove name field from struct fac. |
799 | 799 | Added missing hierarchy boundary sort for FST in order to |
800 | 800 | allow compatibility with compressed names (-C flag). |
840 | 840 | Compiler warning fix in lxt_write.c/fstapi.c for Open Solaris. |
841 | 841 | Added fstWriterGetDumpSizeLimitReached() to fstapi.c. |
842 | 842 | 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 | |
844 | 844 | rtlbrowse. |
845 | 845 | Moved gtk_grab_add() after gtk_widget_show() in order to work |
846 | 846 | with newer versions of GTK. |
887 | 887 | gtkwave::setCurrentTranslateFile, |
888 | 888 | gtkwave::setCurrentTranslateProc, |
889 | 889 | gtkwave::setCurrentTranslateTransProc, and |
890 | gtkwave::setCurrentTranslateEnums to give Tcl access to these | |
890 | gtkwave::setCurrentTranslateEnums to give Tcl access to these | |
891 | 891 | features. |
892 | 892 | Add write combining in fstWriterEmitValueChange to speed |
893 | 893 | up execution on Cygwin. |
894 | 894 | 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. | |
897 | 897 | Added gtkwavetcl_setvar() for starting to build a framework |
898 | 898 | to support Tcl variable change callbacks. This can be used |
899 | 899 | to closely monitor how a user manipulates the gtkwave GUI. |
935 | 935 | 3.3.15 10nov10 Added check in fstapi.c for corner case where |
936 | 936 | fstWriterEmitSectionHeader could make a file unusable if.hier |
937 | 937 | 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 | |
939 | 939 | malformed files. |
940 | 940 | Add config.h #include to the fstapi.c code. |
941 | 941 | Add detection in vcd2fst for Verilog XL-style VCD identifiers |
952 | 952 | Added Jenkins hash routine to enable dynamic alias detection |
953 | 953 | for when Judy not available. |
954 | 954 | 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 | |
956 | 956 | current blocks doesn't overwrite previous, old block data. |
957 | 957 | 3.3.18 24dec10 Added extra allocation in fstWriterEmitValueChange in case |
958 | 958 | users modify the FST_BREAK_ADD_SIZE to a very small value. |
960 | 960 | into its compile. |
961 | 961 | Fixed x86_64 assembler =q vs =Q problem in lxt.c. |
962 | 962 | Preliminary support for variable length records in FST files. |
963 | Added fstUtilityBinToEsc and fstUtilityEscToBin for | |
963 | Added fstUtilityBinToEsc and fstUtilityEscToBin for | |
964 | 964 | conversion of binary data to C-style strings. |
965 | 965 | Now allow escaped strings in VCD files to encode a richer |
966 | 966 | set of data for non-standard "s" VCD records. |
1020 | 1020 | bug. (Would prevent pattern search from working on |
1021 | 1021 | 64-bit big-endian architectures.) |
1022 | 1022 | 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 | |
1024 | 1024 | stubs). |
1025 | 1025 | Fixed bug where Tcl_GetString was substituted with |
1026 | 1026 | brace removal preprocessing when unnecessary (would break |
1038 | 1038 | Fix in lxt2_read.c/.h for negative msb/lsb indices. |
1039 | 1039 | Fix in vzt_read.c/.h for negative msb/lsb indices. |
1040 | 1040 | 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 | |
1042 | 1042 | fixes (xcode gcc uses stricter warnings). |
1043 | 1043 | More generic warning fixes from recent feature adds. |
1044 | 1044 | 3.3.27 20oct11 Fixes of suspicious NULL pointer warnings from scan-build. |
1049 | 1049 | or will change when files are loaded. |
1050 | 1050 | Added fix for DnD crash when Quartz is the GDK back-end |
1051 | 1051 | on Mac OSX. Enable fix with --enable-quartz in configure. |
1052 | Fixed fstWriterFlushContext() such that invocations | |
1052 | Fixed fstWriterFlushContext() such that invocations | |
1053 | 1053 | outside the fstapi are synced with time changes. |
1054 | 1054 | Modify main window size for twinwave on Quartz: GtkPlug |
1055 | 1055 | window does not fit into GtkSocket as with X11. |
1066 | 1066 | .gtkw itself being able to bring up the original dumpfile. |
1067 | 1067 | Numerous bug fixes. |
1068 | 1068 | Preliminary GConf support supporting session ID-based restore. |
1069 | Preliminary GConf support to emulate OSX "open" | |
1069 | Preliminary GConf support to emulate OSX "open" | |
1070 | 1070 | functionality such that dumpfiles/savefiles can be targeted |
1071 | 1071 | to an open gtkwave viewer / session ID. |
1072 | 1072 | << long descriptions >> |
1073 | 1073 | Fixed size of declaration of render_mutex_renderopt_c_1 as it |
1074 | 1074 | was one element too short. |
1075 | 1075 | Added transition code for shifting away from using |
1076 | GtkItemFactoryEntry (also will help with OSX menubar | |
1076 | GtkItemFactoryEntry (also will help with OSX menubar | |
1077 | 1077 | integration which expects menu shells). |
1078 | 1078 | Added support for native Quartz menu bars. |
1079 | 1079 | Removed --enable-quartz as it is auto detected now if |
1124 | 1124 | Added .gtkw as a new save file extension. When either .sav |
1125 | 1125 | or .gtkw is encountered, the rest of a tab's session adaptively |
1126 | 1126 | 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 | |
1129 | 1129 | file. |
1130 | 1130 | Fixed --autosavename to use .gtkw as a suffix rather than the |
1131 | 1131 | .sav suffix. |
1133 | 1133 | matches gtkwave.icns. |
1134 | 1134 | Renamed .sav examples to .gtkw. |
1135 | 1135 | 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 | |
1137 | 1137 | attempted. |
1138 | 1138 | Added [dumpfile_mtime] and [dumpfile_size] tags to save file. |
1139 | 1139 | Can now specify just an augmented save file at the command |
1152 | 1152 | Disable analog during mutually incompatible mode selection |
1153 | 1153 | (binary, filters, etc). |
1154 | 1154 | 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 + | |
1156 | 1156 | simultaneous reload accelerator key occurs. |
1157 | 1157 | Fix combine direction in transaction filter to down. |
1158 | 1158 | Fix vector analog render/print routine to use skipcnt. |
1178 | 1178 | args to transaction filters via the args $comment. |
1179 | 1179 | Added string value of \000 which renders as high-z. |
1180 | 1180 | 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 | |
1182 | 1182 | clobbered on 2nd tab opening. |
1183 | 1183 | Warning fixes when compiled on Ubuntu. |
1184 | 1184 | 3.3.33 27feb12 Scan-build fix in vcd_recoder.c. |
1185 | 1185 | 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 | |
1188 | 1188 | this. |
1189 | 1189 | Fix for timescale 10s and 100s. |
1190 | 1190 | 3.3.34 12mar12 Fix for marker time deltas when $timezero is used. |
1191 | 1191 | 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 | |
1193 | 1193 | is no/off. Use yes in the rcfile to enable (e.g., for |
1194 | 1194 | viewing interpolated analog waveforms). |
1195 | 1195 | Added vcd_preserve_glitches support to FST as --optimize |
1196 | 1196 | uses FST. |
1197 | 1197 | Added vcd_preserve_glitches_real (for VCD/FST) rcfile |
1198 | 1198 | 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 | |
1200 | 1200 | prevents the case where interpolation of an analog waveform |
1201 | 1201 | is deformed as significant data points were removed by the |
1202 | 1202 | VCD or FST loader. |
1214 | 1214 | introduced in 3.3.19. |
1215 | 1215 | 3.3.37 10jun12 Added patch for savefile.c that corrects an issue in which the |
1216 | 1216 | parser for process filter lines assumed the associated id |
1217 | number was always a single digit. | |
1217 | number was always a single digit. | |
1218 | 1218 | 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. | |
1220 | 1220 | Fix that kills stray pipeio_create() processes on |
1221 | 1221 | pipeio_destroy(). |
1222 | 1222 | Additions to extload to handle hier types, component types, |
1238 | 1238 | broken in the GtkSocket/GtkPlug implementation for Win32. |
1239 | 1239 | 3.3.39 08aug12 Fixed relative pathnames when generated in MinGW and used |
1240 | 1240 | back on Linux. |
1241 | Added --output filename option to fst2vcd, vzt2vcd, and | |
1241 | Added --output filename option to fst2vcd, vzt2vcd, and | |
1242 | 1242 | lxt2vcd. |
1243 | 1243 | Fix crash on OSX if gtk_widget_set_sensitive is called on |
1244 | 1244 | a separator. |
1266 | 1266 | Added scrollwheel support to rtlbrowse code windows. |
1267 | 1267 | Added fseeko() return checking in fstapi.c to prevent |
1268 | 1268 | 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. | |
1271 | 1271 | Added VPD support via vpd2vcd. To use, specify -o |
1272 | 1272 | at the command line. (e.g., gtkwave -o test.vpd) |
1273 | 1273 | Added autodetect for LXT, LXT2, VZT, FST regardless of the |
1277 | 1277 | Added conditional compile for stat() being available. |
1278 | 1278 | 3.3.44 16feb13 gdk_draw_layout assertion `GDK_IS_DRAWABLE (drawable)' |
1279 | 1279 | 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 | |
1281 | 1281 | sometimes occurs for structure identifiers. |
1282 | 1282 | 3.3.46 29apr13 Upgraded to autoconf 2.69. |
1283 | 1283 | Fixed as of yet undetected hdr_incomplete bug when running off |
1302 | 1302 | FSDB fix for new debug info output style to be parsed. |
1303 | 1303 | Added generate as scope type to VCD/FST/FSDB. |
1304 | 1304 | 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 | |
1306 | 1306 | declared as FST_VD_IMPLICIT. |
1307 | 1307 | Fixed GTK warning when hide_sst is enabled and SST is opened |
1308 | 1308 | then closed. |
1338 | 1338 | Fixed ordering of static FSDB libraries for when dynamic ones |
1339 | 1339 | are not present. |
1340 | 1340 | 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 | |
1342 | 1342 | expression adds additional filtering criteria. Direction |
1343 | 1343 | filters are case-insensitive. |
1344 | 1344 | 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 | |
1346 | 1346 | also vcdfst/fst2vcd. |
1347 | 1347 | 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), | |
1349 | 1349 | but there are currently no simulators supporting them. These |
1350 | 1350 | are written by using fstWriterCreateVar2(). |
1351 | 1351 | 3.3.50 15oct13 Limit number of rows that can be displayed in mouseover in |
1355 | 1355 | Added missing $dumpvars emission in fst2vcd. |
1356 | 1356 | Added missing atto and zepto time prefix parsing in vcd2fst. |
1357 | 1357 | 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 | |
1359 | 1359 | 'X' for Verilog. |
1360 | 1360 | Used FST "attribute name" for variable types if specified. |
1361 | 1361 | CRLF fix for save file reading on LF-only systems. |
1372 | 1372 | 3.3.51 27oct13 MAINTAINERS: Please add gedit to the list of dependencies |
1373 | 1373 | for gtkwave in order to enable new function that Icarus |
1374 | 1374 | 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 | |
1377 | 1377 | toolkit for Quartz is broken. |
1378 | 1378 | Updated examples/gtkwaverc accel options to reflect the |
1379 | 1379 | current state of the gtkwave main window main menu. |
1380 | 1380 | Added "Open Source Definition" and "Open Source Instantiation" |
1381 | options that invoke .gtkwaverc variable "editor" (or | |
1381 | options that invoke .gtkwaverc variable "editor" (or | |
1382 | 1382 | $GTKWAVE_EDITOR or gedit or open -t [OSX]) on sourcecode when |
1383 | 1383 | source stems are present in the dumpfile (currently FST only). |
1384 | 1384 | Fixed timezero in vcd2fst as it was only parsing unsigned |
1408 | 1408 | Standardized export feature to write vcd using lower case |
1409 | 1409 | for non 0/1 values. |
1410 | 1410 | 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 | |
1412 | 1412 | compiled or used. |
1413 | 1413 | Corrected non-functional typos in documentation. |
1414 | 1414 | 3.3.54 02jan14 Added LZ4 double compression on hierarchy tree for FST when |
1422 | 1422 | in some cases on x86_64. |
1423 | 1423 | 3.3.55 06feb14 Fixed problem with FST_DYNAMIC_ALIAS_DISABLE enabled when |
1424 | 1424 | 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 | |
1426 | 1426 | signal declarations. |
1427 | Keep FSDB_VT_STREAM (FSDB transaction type) traces from | |
1427 | Keep FSDB_VT_STREAM (FSDB transaction type) traces from | |
1428 | 1428 | attempting to be read (for now) as they aren't yet processed. |
1429 | 1429 | Added more space efficient FST dynamic alias encoding. |
1430 | 1430 | Tempfile creation fix for Windows. Using tmpnam() is not |
1436 | 1436 | VCD formatting. |
1437 | 1437 | Added very fast I/O write capability to fst2vcd. |
1438 | 1438 | 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 | |
1440 | 1440 | compiled or used. |
1441 | 1441 | Fix to treesearch to remove duplicate signal names because of |
1442 | 1442 | faulty dumpers. |
1460 | 1460 | Change [1] at end of struct to C99 [] notation with appropriate |
1461 | 1461 | allocation size modification. |
1462 | 1462 | 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 | |
1464 | 1464 | algorithm in FST writer. |
1465 | 1465 | Warnings fixes from cppcheck. |
1466 | Moved MinGW for FST to using different windows tempfile | |
1466 | Moved MinGW for FST to using different windows tempfile | |
1467 | 1467 | generation instead of tmpfile(). |
1468 | 1468 | Removed fflush() in FST for MinGW in places that can cause |
1469 | 1469 | crashes with read only files. |
1497 | 1497 | -- for example filters all non-ports from search results. |
1498 | 1498 | Updated LZ4 for version r126. |
1499 | 1499 | 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. | |
1502 | 1502 | Removed appending [31:0] to vcd loaded integer names. |
1503 | 1503 | Reduced recursion depth in GHW signal loader to prevent |
1504 | 1504 | stack overflow crashes. |
1505 | 1505 | Added support for synthetic clocks in FST file. |
1506 | 1506 | Update timetrace marking so it runs quicker for large traces. |
1507 | 1507 | 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 | |
1509 | 1509 | declared as bits and a real valued change is encountered for |
1510 | 1510 | the value change. |
1511 | 1511 | Fixed crash in vcd2vzt for vcd files with no value changes |
1518 | 1518 | 3.3.68 18nov15 Update copyright date. |
1519 | 1519 | Added named markers capability to From: and To: time value |
1520 | 1520 | input boxes. |
1521 | Added support for fixed point binary numbers for both signed | |
1521 | Added support for fixed point binary numbers for both signed | |
1522 | 1522 | and unsigned decimal display types. |
1523 | 1523 | 3.3.69 03feb16 Added missing EXTLOAD_CFLAGS declarations in configure.ac for |
1524 | 1524 | FSDB detection when only .a files are present (necessary for |
1535 | 1535 | share/icons/hicolor/scalable/apps/gtkwave.svg directory. |
1536 | 1536 | Make gtkwave interpret values as double precision FP for |
1537 | 1537 | 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 | |
1540 | 1540 | mode). Disabling analog mode can be done using the |
1541 | 1541 | existing Analog->Off menu option. |
1542 | 1542 | Fix broken non-canonical bit ordering (IBM) single bit |
1544 | 1544 | Fixed gtkwave::gtkwave::addSignalsFromList so it can handle |
1545 | 1545 | subset and forward/reverse extractions on signals. |
1546 | 1546 | 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 | |
1548 | 1548 | pthread.h is included. |
1549 | 1549 | Added /Edit/Delete to destroy traces without affecting the |
1550 | 1550 | existing cut buffer. |
1567 | 1567 | it is imported to the waveform display as an integer instead of |
1568 | 1568 | a hex value. This works for dump file formats that show the |
1569 | 1569 | 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 | |
1571 | 1571 | disappearing unexpectedly as well as dynamic resizing being |
1572 | 1572 | stuck in the unset marker width. |
1573 | 1573 | 3.3.75 02aug16 Fix crash when -S and -W are used in tandem. |
1575 | 1575 | Crash fix in fstapi.c on read value at time accessing of |
1576 | 1576 | FST files that use new dynamic aliases, FastLZ, or LZ4. This |
1577 | 1577 | 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 | |
1579 | 1579 | implementation details. |
1580 | 1580 | Removed '!A || (A && B)' is equivalent to '!A || B' redundant |
1581 | 1581 | condition checks where found in source. |
1594 | 1594 | allow copying values into the clipboard so they can be pasted |
1595 | 1595 | into text editors, etc. |
1596 | 1596 | 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. | |
1598 | 1598 | Integrated updated GHW reader code. |
1599 | 1599 | 3.3.82 02jul17 Get sys_fst working with VCS VPI. |
1600 | 1600 | Added string concatenations for vectors. |
1601 | 1601 | Added asserts to ghwlib.c to make scan-view clean. |
1602 | 1602 | 3.3.83 04aug17 Preserve search type for regex search across reloads or |
1603 | 1603 | close/reopens of regex search widget. |
1604 | Update local libz to current version. | |
1604 | Update local libz to current version. | |
1605 | 1605 | 3.3.84 03sep17 Updated FSDB reader with experimental FST tree build |
1606 | 1606 | routines for faster init. |
1607 | 1607 | Removed warnings found when compiling with -Wshadow. |
1615 | 1615 | not stored as a string. This then allows bitwise manipulations |
1616 | 1616 | of integers. |
1617 | 1617 | 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 | |
1620 | 1620 | import more accurately imports recursively. |
1621 | 1621 | Made entrybox taller (using -1) as recent versions of |
1622 | 1622 | gnome have taller window titlebars and the widget was not |
1629 | 1629 | Makefile.am. |
1630 | 1630 | 3.3.88 20feb18 Added --sstexclude command line option to prune unwanted |
1631 | 1631 | 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. | |
1637 | 1637 | Updated v2k input/output declarations to handle unpacked arrays. |
1638 | 1638 | Fix for pattern marks that could overshoot the left marker. |
1639 | 1639 | 3.3.89 17mar18 Added support for 32-bit conversions in BitsToReal. |
1640 | 1640 | Crash fix for pattern search with reals using LXT, LXT2, VZT. |
1641 | 1641 | 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. | |
1644 | 1644 | 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 | |
1646 | 1646 | multiple of the radix size (4 for hex, 3 for oct). |
1647 | 1647 | Warray-bounds warning fix for 32-bit conversions in BitsToReal. |
1648 | 1648 | 3.3.91 29may18 Added support for GSettings for when GConf is removed from |
1667 | 1667 | 3.3.95 07oct18 Added fflush on stdout for help text as fix for possible |
1668 | 1668 | stdout problem with mingw/msys shells. |
1669 | 1669 | 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. | |
1672 | 1672 | Change integer type to "integer" in SST to differentiate it |
1673 | 1673 | from sv ints. |
1674 | 1674 | Premiminary support for enum tables embedded in FST files. |
1675 | 1675 | 3.3.96 15nov18 Changed to standardized zoom in/out/full hotkeys. |
1676 | 1676 | 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). | |
1678 | 1678 | 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. | |
1681 | 1681 | Changed to Dinotrace-like 0s/1s rendering for bit vectors so |
1682 | 1682 | 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(). | |
1685 | 1685 | Changed bsearch_trunc() to run in constant time when monospace |
1686 | 1686 | fonts are in use. |
1687 | 1687 | Added missing GDK_SCROLL_MASK to signal area (need for gtk3, |
1688 | 1688 | but not for other versions for some reason). |
1689 | 1689 | 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.) | |
1693 | 1693 | 3.3.98 27dec18 Removed pccts and vermin. Use xml2stems instead. |
1694 | 1694 | 3.3.99 09feb19 Added visible single bit glitches as a yellow dot (if enabled |
1695 | 1695 | 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. | |
1698 | 1698 | 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. | |
1700 | 1700 | 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. | |
1703 | 1703 | 3.3.101 08may19 Added gtkwave::getFacDir, gtkwave::getFacVtype, and |
1704 | 1704 | gtkwave::getFacDtype Tcl accessor functions that function |
1705 | 1705 | similar to gtkwave::getFacName. |
1706 | 1706 | 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 | |
1708 | 1708 | of 10 roundoff errors. |
1709 | Remove register keyword where applicable as is deprecated. | |
1709 | Remove register keyword where applicable as is deprecated. | |
1710 | 1710 | Added --saveonexit gtkwave command line option. |
1711 | 1711 | 3.3.102 21sep19 Remove redundant TREE_VHDL_ST_PACKAGE from SST exclude. |
1712 | 1712 | Added addCommentTracesFromList tcl command from user patch. |
1714 | 1714 | Preliminary VHDL support for wlf2vcd. |
1715 | 1715 | Add missing return value checks on mmap() in FST writer. |
1716 | 1716 | 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. | |
1720 | 1720 | 3.3.104 24jan20 Added support for loading .vf files (provided FSDB reader |
1721 | 1721 | libraries are enabled). |
1722 | 1722 | Added support for dumping variable types in vcd saveer, not |
1723 | 1723 | just using "wire" for non-reals/strings. |
1724 | 1724 | 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. |
0 | 0 | ########################################################################## |
1 | 1 | |
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. | |
11 | 11 | |
12 | 12 | This program is free software; you can redistribute it and/or modify it |
13 | 13 | under the terms of the GNU General Public License as published by the Free |
0 | 0 | #! /bin/sh |
1 | 1 | # 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. | |
3 | 3 | # |
4 | 4 | # Report bugs to <bybell@rocketmail.com>. |
5 | 5 | # |
579 | 579 | # Identity of this package. |
580 | 580 | PACKAGE_NAME='gtkwave' |
581 | 581 | 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' | |
584 | 584 | PACKAGE_BUGREPORT='bybell@rocketmail.com' |
585 | 585 | PACKAGE_URL='' |
586 | 586 | |
1404 | 1404 | # Omit some internal or obsolete options to make the list less imposing. |
1405 | 1405 | # This message is too long to be a string in the A/UX 3.1 sh. |
1406 | 1406 | 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. | |
1408 | 1408 | |
1409 | 1409 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1410 | 1410 | |
1470 | 1470 | |
1471 | 1471 | if test -n "$ac_init_help"; then |
1472 | 1472 | 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:";; | |
1474 | 1474 | esac |
1475 | 1475 | cat <<\_ACEOF |
1476 | 1476 | |
1629 | 1629 | test -n "$ac_init_help" && exit $ac_status |
1630 | 1630 | if $ac_init_version; then |
1631 | 1631 | cat <<\_ACEOF |
1632 | gtkwave configure 3.3.104 | |
1632 | gtkwave configure 3.3.111 | |
1633 | 1633 | generated by GNU Autoconf 2.69 |
1634 | 1634 | |
1635 | 1635 | Copyright (C) 2012 Free Software Foundation, Inc. |
2273 | 2273 | This file contains any messages produced by compilers while |
2274 | 2274 | running configure, to aid debugging if configure makes a mistake. |
2275 | 2275 | |
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 | |
2277 | 2277 | generated by GNU Autoconf 2.69. Invocation command line was |
2278 | 2278 | |
2279 | 2279 | $ $0 $@ |
3140 | 3140 | |
3141 | 3141 | # Define the identity of the package. |
3142 | 3142 | PACKAGE='gtkwave' |
3143 | VERSION='3.3.104' | |
3143 | VERSION='3.3.111' | |
3144 | 3144 | |
3145 | 3145 | |
3146 | 3146 | cat >>confdefs.h <<_ACEOF |
11498 | 11498 | # report actual input values of CONFIG_FILES etc. instead of their |
11499 | 11499 | # values after options handling. |
11500 | 11500 | 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 | |
11502 | 11502 | generated by GNU Autoconf 2.69. Invocation command line was |
11503 | 11503 | |
11504 | 11504 | CONFIG_FILES = $CONFIG_FILES |
11564 | 11564 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
11565 | 11565 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
11566 | 11566 | ac_cs_version="\\ |
11567 | gtkwave config.status 3.3.104 | |
11567 | gtkwave config.status 3.3.111 | |
11568 | 11568 | configured by $0, generated by GNU Autoconf 2.69, |
11569 | 11569 | with options \\"\$ac_cs_config\\" |
11570 | 11570 |
1 | 1 | # Process this file with autoconf to produce a configure script. |
2 | 2 | |
3 | 3 | AC_PREREQ(2.59) |
4 | AC_INIT(gtkwave, 3.3.104, bybell@rocketmail.com) | |
4 | AC_INIT(gtkwave, 3.3.111, bybell@rocketmail.com) | |
5 | 5 | AC_CONFIG_SRCDIR([src/vcd.c]) |
6 | 6 | AM_INIT_AUTOMAKE |
7 | 7 | AC_CONFIG_HEADER([config.h]) |
7 | 7 | <key>CFBundleExecutable</key> |
8 | 8 | <string>gtkwave</string> |
9 | 9 | <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> | |
11 | 11 | <key>CFBundleIconFile</key> |
12 | 12 | <string>gtkwave.icns</string> |
13 | 13 | <key>CFBundleIdentifier</key> |
17 | 17 | <key>CFBundlePackageType</key> |
18 | 18 | <string>APPL</string> |
19 | 19 | <key>CFBundleShortVersionString</key> |
20 | <string>3.3.104</string> | |
20 | <string>3.3.111</string> | |
21 | 21 | <key>CFBundleSignature</key> |
22 | 22 | <string>????</string> |
23 | 23 | <key>CFBundleVersion</key> |
24 | <string>3.3.104</string> | |
24 | <string>3.3.111</string> | |
25 | 25 | <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> | |
27 | 27 | <key>LSMinimumSystemVersion</key> |
28 | 28 | <string>10.6</string> |
29 | 29 |
25 | 25 | |
26 | 26 | <!-- Comment this out to keep the install names in binaries --> |
27 | 27 | <run-install-name-tool/> |
28 | ||
28 | ||
29 | 29 | <!-- Optionally specify a launcher script to use. If the |
30 | 30 | application sets up everything needed itself, like |
31 | 31 | environment variable, linker paths, etc, a launcher script is |
55 | 55 | <binary>${prefix}/bin/evcd2vcd</binary> |
56 | 56 | <binary>${prefix}/bin/fst2vcd</binary> |
57 | 57 | <binary>${prefix}/bin/vcd2fst</binary> |
58 | <binary>${prefix}/bin/ghwdump</binary> | |
59 | 58 | <binary>${prefix}/bin/lxt2miner</binary> |
60 | 59 | <binary>${prefix}/bin/lxt2vcd</binary> |
61 | 60 | <binary>${prefix}/bin/shmidcat</binary> |
173 | 172 | <data dest="${bundle}/Contents/Resources/man/fst2vcd.1"> |
174 | 173 | ${project}/../../man/fst2vcd.1 |
175 | 174 | </data> |
176 | <data dest="${bundle}/Contents/Resources/man/ghwdump.1"> | |
177 | ${project}/../../man/ghwdump.1 | |
178 | </data> | |
179 | 175 | <data dest="${bundle}/Contents/Resources/man/gtkwave.1"> |
180 | 176 | ${project}/../../man/gtkwave.1 |
181 | 177 | </data> |
271 | 267 | </data> |
272 | 268 | |
273 | 269 | |
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. | |
277 | 273 | --> |
278 | 274 | <data dest="${bundle}/Contents/Resources/share/patches/gtk_diff_against_modulesets.patch"> |
279 | 275 | ${project}/gtk_diff_against_modulesets.patch |
280 | 276 | </data> |
281 | 277 | |
282 | 278 | <!-- 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. | |
284 | 280 | No bug reported yet: this fixes yellow bars from gdk_pixbuf_get_from_drawable() |
285 | 281 | which invokes _gdk_quartz_image_copy_to_image() that attempts to use 24-bit |
286 | 282 | RGB pixels instead of 32-bit RGBA ones. |
107 | 107 | char *txt, *txt2 = NULL; |
108 | 108 | ds_Tree *tdup = malloc(sizeof(ds_Tree)); |
109 | 109 | 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 | } | |
110 | 122 | |
111 | 123 | memcpy(tdup, t, sizeof(ds_Tree)); |
112 | 124 | t = tdup; |
125 | colon = strchr(t->item, ':'); | |
126 | if(colon) | |
127 | { | |
128 | *colon = 0; /* remove generate hack */ | |
129 | } | |
130 | ||
113 | 131 | |
114 | 132 | t->next_flat = flattened_mod_list_root; |
115 | 133 | flattened_mod_list_root = t; |
118 | 136 | { |
119 | 137 | int cnl = strlen(compname_build); |
120 | 138 | |
121 | compname_full = malloc(cnl + 1 + strlen(compname) + 1); | |
139 | compname_full = malloc(cnl + 1 + strlen(compname2) + 1); | |
122 | 140 | strcpy(compname_full, compname_build); |
123 | 141 | compname_full[cnl] = '.'; |
124 | strcpy(compname_full + cnl + 1, compname); | |
142 | strcpy(compname_full + cnl + 1, compname2); | |
125 | 143 | } |
126 | 144 | else |
127 | 145 | { |
129 | 147 | } |
130 | 148 | |
131 | 149 | t->fullname = compname_full; |
132 | txt = compname_build ? compname : t->item; | |
150 | txt = compname_build ? compname2 : t->item; | |
133 | 151 | if(!t->filename) |
134 | 152 | { |
135 | 153 | txt2 = malloc(strlen(txt) + strlen(" [MISSING]") + 1); |
138 | 156 | txt = txt2; |
139 | 157 | } |
140 | 158 | |
159 | if(colon) | |
160 | { | |
161 | *colon = ':'; | |
162 | } | |
163 | ||
141 | 164 | comp = t->comp; |
142 | 165 | if(comp) |
143 | 166 | { |
190 | 213 | comp = comp->next; |
191 | 214 | } |
192 | 215 | #endif |
216 | ||
217 | free(compname2); compname2 = NULL; | |
193 | 218 | |
194 | 219 | return(subtree); |
195 | 220 | } |
9 | 9 | #include <string.h> |
10 | 10 | #include <inttypes.h> |
11 | 11 | #include <time.h> |
12 | #include "wlf_api.h" | |
12 | #include <wlf_api.h> | |
13 | 13 | |
14 | 14 | /* skips using wlfValueToString() and determines string directly from value representation */ |
15 | 15 | #define BYPASS_USING_VALUE_TO_STRING |
27 | 27 | #include <string> |
28 | 28 | #include <map> |
29 | 29 | #include <stack> |
30 | #include <queue> | |
30 | 31 | using namespace std; |
31 | 32 | |
32 | 33 | #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 | ||
33 | 97 | |
34 | 98 | |
35 | 99 | void xml2stems(FILE *fi, FILE *fo, int is_verilator_sim) |
36 | 100 | { |
37 | 101 | std::map <string, string> fId; |
38 | 102 | std::stack<string> mId; |
103 | queue<string> bQueue; | |
104 | int in_files = 0; | |
105 | int geninst = 0; | |
106 | int func_nesting_cnt = 0; | |
39 | 107 | |
40 | 108 | while(!feof(fi)) |
41 | 109 | { |
57 | 125 | |
58 | 126 | switch(*pnt) |
59 | 127 | { |
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 | ||
60 | 183 | case 'm': |
61 | if(!strncmp(pnt, "module", 6)) | |
184 | if(!strncmp(pnt, "module", 6) && strncmp(pnt, "module_files", 12)) | |
62 | 185 | { |
63 | 186 | if(!endtag) |
64 | 187 | { |
65 | char *qts[6]; | |
66 | 188 | 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) | |
73 | 198 | { |
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 | } | |
76 | 216 | } |
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) | |
83 | 252 | { |
84 | numqt = 4; | |
85 | tm = is_verilator_sim; | |
253 | fId.insert(pair <string, string> (cod, fil)); | |
86 | 254 | } |
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 | } | |
145 | 258 | } |
146 | 259 | } |
147 | 260 | break; |
149 | 262 | case 'i': |
150 | 263 | if((!endtag) && (!strncmp(pnt, "instance", 8))) |
151 | 264 | { |
152 | char *qts[6]; | |
153 | 265 | char *s = pnt + 8; |
154 | int numqt = 0; | |
266 | std::map <string, string>*xmt = parse_xml_tags(s, NULL); | |
155 | 267 | |
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) | |
174 | 273 | { |
175 | 274 | fprintf(fo, "++ comp %s type %s parent %s\n", nam, defnam, mId.top().c_str()); |
176 | 275 | } |
276 | ||
277 | delete xmt; | |
177 | 278 | } |
178 | 279 | } |
179 | 280 | break; |
184 | 285 | { |
185 | 286 | if(!endtag) |
186 | 287 | { |
187 | char *qts[4]; | |
188 | 288 | 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) | |
194 | 297 | { |
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 */ | |
197 | 308 | } |
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; | |
217 | 311 | } |
218 | 312 | } |
219 | 313 | else |
Binary diff not shown
0 | 0 | ## -*- makefile -*- |
1 | 1 | ## |
2 | 2 | |
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 \ | |
4 | 4 | lxt2vcd.1 rtlbrowse.1 shmidcat.1 \ |
5 | 5 | twinwave.1 vcd2fst.1 vcd2lxt.1 vcd2lxt2.1 \ |
6 | 6 | vcd2vzt.1 vzt2vcd.1 vztminer.1 fstminer.1 \ |
298 | 298 | top_build_prefix = @top_build_prefix@ |
299 | 299 | top_builddir = @top_builddir@ |
300 | 300 | 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 \ | |
302 | 302 | lxt2vcd.1 rtlbrowse.1 shmidcat.1 \ |
303 | 303 | twinwave.1 vcd2fst.1 vcd2lxt.1 vcd2lxt2.1 \ |
304 | 304 | vcd2vzt.1 vzt2vcd.1 vztminer.1 fstminer.1 \ |
42 | 42 | Anthony Bybell <bybell@rocketmail.com> |
43 | 43 | .SH "SEE ALSO" |
44 | 44 | .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 | .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) |
286 | 286 | \fBlxt_clock_compress_to_z\fR <\fIvalue\fP> |
287 | 287 | For LXT (not LXT2) allows clocks to compress to a 'z' value so that regular/periodic value changes may be noted. |
288 | 288 | .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 | |
289 | 292 | \fBmax_fsdb_trees\fR <\fIvalue\fP> |
290 | 293 | 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. |
291 | 294 | .TP |
37 | 37 | debug.c debug.h discardbuttons.c edgebuttons.c \ |
38 | 38 | entry.c extload.c extload.h fetchbuttons.c fgetdynamic.c fgetdynamic.h file.c fonts.c fonts.h fst.c fst.h \ |
39 | 39 | 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 \ | |
41 | 41 | hierpack.c hierpack.h jrb.c jrb.h help.c helpers/lxt2_read.c \ |
42 | 42 | helpers/lxt_write.c helpers/vzt_read.c hiersearch.c interp.c \ |
43 | 43 | logfile.c lx2.c lx2.h lxt.c lxt.h main.c main.h markerbox.c menu.c menu.h mouseover.c \ |
97 | 97 | entry.$(OBJEXT) extload.$(OBJEXT) fetchbuttons.$(OBJEXT) \ |
98 | 98 | fgetdynamic.$(OBJEXT) file.$(OBJEXT) fonts.$(OBJEXT) \ |
99 | 99 | fst.$(OBJEXT) gconf.$(OBJEXT) getopt.$(OBJEXT) \ |
100 | getopt1.$(OBJEXT) ghw.$(OBJEXT) ghwlib.$(OBJEXT) \ | |
100 | getopt1.$(OBJEXT) ghw.$(OBJEXT) libghw.$(OBJEXT) \ | |
101 | 101 | hierpack.$(OBJEXT) jrb.$(OBJEXT) help.$(OBJEXT) \ |
102 | 102 | lxt2_read.$(OBJEXT) lxt_write.$(OBJEXT) vzt_read.$(OBJEXT) \ |
103 | 103 | hiersearch.$(OBJEXT) interp.$(OBJEXT) logfile.$(OBJEXT) \ |
433 | 433 | debug.c debug.h discardbuttons.c edgebuttons.c \ |
434 | 434 | entry.c extload.c extload.h fetchbuttons.c fgetdynamic.c fgetdynamic.h file.c fonts.c fonts.h fst.c fst.h \ |
435 | 435 | 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 \ | |
437 | 437 | hierpack.c hierpack.h jrb.c jrb.h help.c helpers/lxt2_read.c \ |
438 | 438 | helpers/lxt_write.c helpers/vzt_read.c hiersearch.c interp.c \ |
439 | 439 | logfile.c lx2.c lx2.h lxt.c lxt.h main.c main.h markerbox.c menu.c menu.h mouseover.c \ |
573 | 573 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ |
574 | 574 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ |
575 | 575 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ghw.Po@am__quote@ |
576 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ghwlib.Po@am__quote@ | |
577 | 576 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Po@am__quote@ |
578 | 577 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@ |
579 | 578 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hierpack.Po@am__quote@ |
580 | 579 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hiersearch.Po@am__quote@ |
581 | 580 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interp.Po@am__quote@ |
582 | 581 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@ |
582 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libghw.Po@am__quote@ | |
583 | 583 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logfile.Po@am__quote@ |
584 | 584 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lx2.Po@am__quote@ |
585 | 585 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt.Po@am__quote@ |
220 | 220 | fprintf(stderr, "INTERNAL ERROR: ClearGroupTrace applied to non-group! Exiting.\n"); |
221 | 221 | exit(255); |
222 | 222 | } |
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 | } | |
223 | 239 | } |
224 | 240 | |
225 | 241 | /* |
512 | 512 | unsigned int t_color; /* trace color index */ |
513 | 513 | unsigned char t_fpdecshift; /* for fixed point decimal */ |
514 | 514 | |
515 | unsigned is_cursor : 1; /* set to mark a cursor trace */ | |
515 | 516 | unsigned is_alias : 1; /* set when it's an alias (safe to free t->name then) */ |
516 | 517 | unsigned is_depacked : 1; /* set when it's been depacked from a compressed entry (safe to free t->name then) */ |
517 | 518 | unsigned vector : 1; /* 1 if bit vector, 0 if node */ |
537 | 538 | TR_FPDECSHIFT_B, |
538 | 539 | TR_TIME_B, |
539 | 540 | TR_ENUM_B, |
541 | TR_CURSOR_B, | |
542 | TR_FFO_B, | |
540 | 543 | |
541 | 544 | TR_RSVD_B /* for use internally such as temporary caching of highlighting, not for use in traces */ |
542 | 545 | }; |
573 | 576 | #define TR_REAL2BITS (UINT64_C(1)<<TR_REAL2BITS_B) |
574 | 577 | |
575 | 578 | #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) | |
576 | 580 | |
577 | 581 | #define TR_COLLAPSED (UINT64_C(1)<<TR_COLLAPSED_B) |
578 | 582 | #define TR_ISCOLLAPSED (TR_BLANK|TR_COLLAPSED) |
586 | 590 | |
587 | 591 | #define TR_TIME (UINT64_C(1)<<TR_TIME_B) |
588 | 592 | #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) | |
589 | 596 | |
590 | 597 | #define TR_ANALOGMASK (TR_ANALOG_STEP|TR_ANALOG_INTERPOLATED) |
591 | 598 | |
646 | 653 | void CloseTrace(Trptr t); |
647 | 654 | void ClearTraces(void); |
648 | 655 | void ClearGroupTraces(Trptr t); |
656 | void MarkTraceCursor(Trptr t); | |
649 | 657 | |
650 | 658 | char *varxt_fix(char *s); |
651 | 659 |
28 | 28 | #endif |
29 | 29 | |
30 | 30 | /* |
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 | |
32 | 201 | */ |
33 | 202 | #define cvt_gray(f,p,n) \ |
34 | 203 | 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 | } \ | |
41 | 211 | } while(0) |
42 | 212 | |
43 | 213 | |
167 | 337 | } |
168 | 338 | |
169 | 339 | |
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 | ||
170 | 374 | static void dpr_e16(char *str, double d) |
171 | 375 | { |
172 | 376 | char *buf16; |
195 | 399 | |
196 | 400 | int shamt = t->t_fpdecshift; |
197 | 401 | TimeType lpart = val >> shamt; |
198 | TimeType rmsk = (1 << shamt); | |
402 | TimeType rmsk = (ULLDescriptor(1) << shamt); | |
403 | ||
199 | 404 | TimeType rbit = (val >= 0) ? (val & (rmsk-1)) : ((-val) & (rmsk-1)); |
200 | 405 | double rfrac; |
201 | 406 | int negflag = 0; |
244 | 449 | { |
245 | 450 | int shamt = t->t_fpdecshift; |
246 | 451 | UTimeType lpart = ((UTimeType)val) >> shamt; |
247 | TimeType rmsk = (1 << shamt); | |
452 | TimeType rmsk = (ULLDescriptor(1) << shamt); | |
248 | 453 | TimeType rbit = (val & (rmsk-1)); |
249 | 454 | double rfrac; |
250 | 455 | char dbuf[32]; |
465 | 670 | if(GLOBALS->show_base) { *(pnt++)='"'; } |
466 | 671 | *(pnt)=0x00; /* scan build : remove dead increment */ |
467 | 672 | } |
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))))) | |
469 | 674 | { |
470 | 675 | char *parse; |
471 | 676 | |
893 | 1098 | { |
894 | 1099 | strcpy(rv,"UNDEF"); |
895 | 1100 | } |
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 | } | |
896 | 1125 | } |
897 | 1126 | |
898 | 1127 | return(rv); |
1214 | 1443 | if(GLOBALS->show_base) { *(pnt++)='"'; } |
1215 | 1444 | *(pnt)=0x00; /* scan build : remove dead increment */ |
1216 | 1445 | } |
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))))) | |
1218 | 1447 | { |
1219 | 1448 | char *parse; |
1220 | 1449 | |
1595 | 1824 | } |
1596 | 1825 | |
1597 | 1826 | |
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 | ||
1741 | 1827 | char *convert_ascii_vec(Trptr t, char *vec) |
1742 | 1828 | { |
1743 | 1829 | char *s = convert_ascii_vec_2(t, vec); |
1744 | 1830 | |
1745 | 1831 | if(!(t->f_filter|t->p_filter|t->e_filter)) |
1746 | 1832 | { |
1833 | if(GLOBALS->lz_removal) lzremoval(s); | |
1747 | 1834 | } |
1748 | 1835 | else |
1749 | 1836 | { |
1794 | 1881 | |
1795 | 1882 | if(!(t->f_filter|t->p_filter|t->e_filter)) |
1796 | 1883 | { |
1884 | if(GLOBALS->lz_removal) lzremoval(s); | |
1797 | 1885 | } |
1798 | 1886 | else |
1799 | 1887 | { |
27 | 27 | int i, len; |
28 | 28 | int prefix_idx = 0; |
29 | 29 | |
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 | } | |
31 | 62 | |
32 | 63 | len = strlen(s); |
33 | 64 | for(i=0;i<len;i++) |
19 | 19 | #include "globals.h" |
20 | 20 | #include <config.h> |
21 | 21 | #include "ghw.h" |
22 | #include "ghwlib.h" | |
22 | #include "libghw.h" | |
23 | 23 | #include "tree.h" |
24 | 24 | |
25 | 25 | /************************ splay ************************/ |
172 | 172 | { |
173 | 173 | if(psr) |
174 | 174 | { |
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) | |
181 | 179 | { |
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) | |
183 | 186 | { |
184 | if(!strncmp(fstr1, fstr2, p1)) | |
187 | if((p1>=0)&&(p1==p2)) | |
185 | 188 | { |
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 | } | |
190 | 196 | } |
191 | 197 | } |
192 | } | |
193 | else | |
194 | { | |
195 | if((p1>=0)&&(p1==p2)) | |
198 | else | |
196 | 199 | { |
197 | if(!strncmp(fstr1, fstr2, p1)) | |
200 | if((p1>=0)&&(p1==p2)) | |
198 | 201 | { |
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 | } | |
201 | 211 | } |
202 | 212 | else |
203 | 213 | { |
204 | 214 | root = NULL; |
205 | 215 | } |
206 | 216 | } |
207 | else | |
208 | { | |
209 | root = NULL; | |
210 | } | |
217 | } | |
218 | else | |
219 | { | |
220 | root = NULL; | |
211 | 221 | } |
212 | 222 | } |
213 | 223 | |
232 | 242 | int i; |
233 | 243 | int cnt = 1; |
234 | 244 | struct tree **ar; |
235 | ||
245 | ||
236 | 246 | while((t2 = t2->next)) { cnt++; } |
237 | ||
247 | ||
238 | 248 | ar = malloc_2(cnt * sizeof(struct tree *)); |
239 | 249 | t2 = t; |
240 | 250 | for(i=0;i<cnt;i++) |
243 | 253 | if(t2->child) { recurse_tree_build_whichcache(t2->child); } |
244 | 254 | t2 = t2->next; |
245 | 255 | } |
246 | ||
256 | ||
247 | 257 | for(i=cnt-1;i>=0;i--) |
248 | 258 | { |
249 | 259 | t = ar[i]; |
250 | if(t->t_which >= 0) | |
260 | if(t->t_which >= 0) | |
251 | 261 | { |
252 | 262 | GLOBALS->gwt_ghw_c_1 = ghw_insert(t, GLOBALS->gwt_ghw_c_1, t->t_which, GLOBALS->facs[t->t_which]); |
253 | 263 | } |
254 | 264 | } |
255 | ||
265 | ||
256 | 266 | free_2(ar); |
257 | 267 | } |
258 | 268 | } |
265 | 275 | int i; |
266 | 276 | int cnt = 1; |
267 | 277 | struct tree **ar; |
268 | ||
278 | ||
269 | 279 | while((t2 = t2->next)) { cnt++; } |
270 | ||
280 | ||
271 | 281 | ar = malloc_2(cnt * sizeof(struct tree *)); |
272 | 282 | t2 = t; |
273 | 283 | for(i=0;i<cnt;i++) |
276 | 286 | if(t2->child) { recurse_tree_fix_from_whichcache(t2->child); } |
277 | 287 | t2 = t2->next; |
278 | 288 | } |
279 | ||
289 | ||
280 | 290 | for(i=cnt-1;i>=0;i--) |
281 | 291 | { |
282 | 292 | t = ar[i]; |
284 | 294 | { |
285 | 295 | GLOBALS->gwt_ghw_c_1 = ghw_splay(t, GLOBALS->gwt_ghw_c_1); |
286 | 296 | 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 | ||
288 | 298 | t->t_which = GLOBALS->gwt_corr_ghw_c_1->val_old; |
289 | 299 | } |
290 | 300 | } |
291 | ||
301 | ||
292 | 302 | free_2(ar); |
293 | 303 | } |
294 | 304 | } |
439 | 449 | const char *pfx, struct tree **res, unsigned int **sig) |
440 | 450 | { |
441 | 451 | 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); | |
443 | 454 | char *name = NULL; |
444 | 455 | |
445 | 456 | if ((unsigned int)dim == base->nbr_dim) |
448 | 459 | sprintf (GLOBALS->asbuf, "%s]", pfx); |
449 | 460 | name = strdup_2(GLOBALS->asbuf); |
450 | 461 | |
451 | t = build_hierarchy_type (h, base->el, name, sig); | |
462 | t = build_hierarchy_type (h, arr->sa.el, name, sig); | |
452 | 463 | |
453 | 464 | if (*res != NULL) |
454 | 465 | (*res)->next = t; |
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 | /* 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_ */ |
853 | 853 | NULL, /* toggle3_showchange_c_1 364 */ |
854 | 854 | NULL, /* toggle4_showchange_c_1 364 */ |
855 | 855 | NULL, /* toggle5_showchange_c_1 364 */ |
856 | NULL, /* toggle6_showchange_c_1 364 */ | |
856 | 857 | NULL, /* window_showchange_c_8 365 */ |
857 | 858 | NULL, /* cleanup_showchange_c_6 366 */ |
858 | 859 | NULL, /* tcache_showchange_c_1 367 */ |
1380 | 1381 | 0, /* ruler_origin */ |
1381 | 1382 | 0, /* ruler_step */ |
1382 | 1383 | 0, /* fill_waveform */ |
1384 | 0, /* lz_removal */ | |
1383 | 1385 | FALSE, /*save_on_exit */ |
1384 | 1386 | |
1385 | 1387 | |
1901 | 1903 | new_globals->display_grid = GLOBALS->display_grid; |
1902 | 1904 | new_globals->highlight_wavewindow = GLOBALS->highlight_wavewindow; |
1903 | 1905 | new_globals->fill_waveform = GLOBALS->fill_waveform; |
1906 | new_globals->lz_removal = GLOBALS->lz_removal; | |
1904 | 1907 | new_globals->use_standard_trace_select = GLOBALS->use_standard_trace_select; |
1905 | 1908 | new_globals->use_big_fonts = GLOBALS->use_big_fonts; |
1906 | 1909 | new_globals->use_full_precision = GLOBALS->use_full_precision; |
2848 | 2851 | GLOBALS->display_grid = g_old->display_grid; |
2849 | 2852 | GLOBALS->highlight_wavewindow = g_old->highlight_wavewindow; |
2850 | 2853 | GLOBALS->fill_waveform = g_old->fill_waveform; |
2854 | GLOBALS->lz_removal = g_old->lz_removal; | |
2851 | 2855 | GLOBALS->use_standard_trace_select = g_old->use_standard_trace_select; |
2852 | 2856 | GLOBALS->disable_mouseover = g_old->disable_mouseover; |
2853 | 2857 | GLOBALS->clipboard_mouseover = g_old->clipboard_mouseover; |
856 | 856 | GtkWidget *toggle3_showchange_c_1; /* from showchange.c 390 */ |
857 | 857 | GtkWidget *toggle4_showchange_c_1; /* from showchange.c 391 */ |
858 | 858 | GtkWidget *toggle5_showchange_c_1; /* from showchange.c 391 */ |
859 | GtkWidget *toggle6_showchange_c_1; /* from showchange.c 391 */ | |
859 | 860 | GtkWidget *window_showchange_c_8; /* from showchange.c 392 */ |
860 | 861 | void (*cleanup_showchange_c_6)(void); /* from showchange.c 393 */ |
861 | 862 | struct TraceEnt *tcache_showchange_c_1; /* from showchange.c 394 */ |
1369 | 1370 | TimeType ruler_origin; |
1370 | 1371 | TimeType ruler_step; |
1371 | 1372 | char fill_waveform; |
1373 | char lz_removal; | |
1372 | 1374 | gboolean save_on_exit; |
1373 | 1375 | |
1374 | 1376 |
7 | 7 | |
8 | 8 | 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 |
9 | 9 | |
10 | bin_PROGRAMS= evcd2vcd fst2vcd vcd2fst fstminer ghwdump lxt2miner lxt2vcd \ | |
10 | bin_PROGRAMS= evcd2vcd fst2vcd vcd2fst fstminer lxt2miner lxt2vcd \ | |
11 | 11 | shmidcat vcd2lxt vcd2lxt2 vcd2vzt \ |
12 | 12 | vzt2vcd vztminer |
13 | 13 | |
41 | 41 | lxt2miner_SOURCES= lxt2miner.c lxt2_read.c lxt2_read.h |
42 | 42 | lxt2miner_LDADD= $(LIBZ_LDADD) |
43 | 43 | |
44 | ghwdump_SOURCES= ghwdump.c $(srcdir)/../ghwlib.c | |
45 | ||
46 | 44 | evcd2vcd_SOURCES= evcd2vcd.c $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c |
76 | 76 | PRE_UNINSTALL = : |
77 | 77 | POST_UNINSTALL = : |
78 | 78 | 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) | |
83 | 82 | subdir = src/helpers |
84 | 83 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ |
85 | 84 | $(top_srcdir)/depcomp |
105 | 104 | fastlz.$(OBJEXT) fstapi.$(OBJEXT) |
106 | 105 | fstminer_OBJECTS = $(am_fstminer_OBJECTS) |
107 | 106 | 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) | |
111 | 107 | am_lxt2miner_OBJECTS = lxt2miner.$(OBJEXT) lxt2_read.$(OBJEXT) |
112 | 108 | lxt2miner_OBJECTS = $(am_lxt2miner_OBJECTS) |
113 | 109 | lxt2miner_DEPENDENCIES = $(am__DEPENDENCIES_1) |
179 | 175 | am__v_CCLD_0 = @echo " CCLD " $@; |
180 | 176 | am__v_CCLD_1 = |
181 | 177 | 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) \ | |
183 | 183 | shmidcat.c $(vcd2fst_SOURCES) $(vcd2lxt_SOURCES) \ |
184 | 184 | $(vcd2lxt2_SOURCES) $(vcd2vzt_SOURCES) $(vzt2vcd_SOURCES) \ |
185 | 185 | $(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) | |
191 | 186 | am__can_run_installinfo = \ |
192 | 187 | case $$AM_UPDATE_INFO_DIR in \ |
193 | 188 | n|no|NO) false;; \ |
398 | 393 | vztminer_LDADD = $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBLZMA_LDADD) $(RPC_LDADD) |
399 | 394 | lxt2miner_SOURCES = lxt2miner.c lxt2_read.c lxt2_read.h |
400 | 395 | lxt2miner_LDADD = $(LIBZ_LDADD) |
401 | ghwdump_SOURCES = ghwdump.c $(srcdir)/../ghwlib.c | |
402 | 396 | evcd2vcd_SOURCES = evcd2vcd.c $(srcdir)/../../contrib/rtlbrowse/jrb.h $(srcdir)/../../contrib/rtlbrowse/jrb.c |
403 | 397 | all: all-am |
404 | 398 | |
489 | 483 | @rm -f fstminer$(EXEEXT) |
490 | 484 | $(AM_V_CCLD)$(LINK) $(fstminer_OBJECTS) $(fstminer_LDADD) $(LIBS) |
491 | 485 | |
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 | ||
496 | 486 | lxt2miner$(EXEEXT): $(lxt2miner_OBJECTS) $(lxt2miner_DEPENDENCIES) $(EXTRA_lxt2miner_DEPENDENCIES) |
497 | 487 | @rm -f lxt2miner$(EXEEXT) |
498 | 488 | $(AM_V_CCLD)$(LINK) $(lxt2miner_OBJECTS) $(lxt2miner_LDADD) $(LIBS) |
541 | 531 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fst2vcd.Po@am__quote@ |
542 | 532 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstapi.Po@am__quote@ |
543 | 533 | @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@ | |
546 | 534 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jrb.Po@am__quote@ |
547 | 535 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2_read.Po@am__quote@ |
548 | 536 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxt2_write.Po@am__quote@ |
632 | 620 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/fst/fstapi.c' object='fstapi.obj' libtool=no @AMDEPBACKSLASH@ |
633 | 621 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
634 | 622 | @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` | |
649 | 623 | |
650 | 624 | LzmaLib.o: $(srcdir)/../liblzma/LzmaLib.c |
651 | 625 | @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() |
4 | 4 | |
5 | 5 | noinst_LIBRARIES= libfst.a |
6 | 6 | |
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 | |
8 | 8 | |
9 | EXTRA_DIST= block_format.txt | |
9 | EXTRA_DIST= block_format.txt CMakeLists.txt |
314 | 314 | top_srcdir = @top_srcdir@ |
315 | 315 | AM_CFLAGS = $(LIBZ_CFLAGS) $(LIBJUDY_CFLAGS) |
316 | 316 | 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 | |
319 | 319 | all: all-am |
320 | 320 | |
321 | 321 | .SUFFIXES: |
21 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | 23 | THE SOFTWARE. |
24 | ||
25 | SPDX-License-Identifier: MIT | |
24 | 26 | */ |
25 | 27 | |
26 | 28 | #include "fastlz.h" |
21 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | 23 | THE SOFTWARE. |
24 | ||
25 | SPDX-License-Identifier: MIT | |
24 | 26 | */ |
25 | 27 | |
26 | 28 | #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 |
17 | 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
18 | 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
19 | 19 | * DEALINGS IN THE SOFTWARE. |
20 | * | |
21 | * SPDX-License-Identifier: MIT | |
20 | 22 | */ |
21 | 23 | |
22 | 24 | /* |
77 | 79 | #define PATH_MAX (4096) |
78 | 80 | #endif |
79 | 81 | |
82 | #if defined(_MSC_VER) | |
83 | typedef int64_t fst_off_t; | |
84 | #else | |
85 | typedef off_t fst_off_t; | |
86 | #endif | |
87 | ||
80 | 88 | /* note that Judy versus Jenkins requires more experimentation: they are */ |
81 | 89 | /* functionally equivalent though it appears Jenkins is slightly faster. */ |
82 | 90 | /* in addition, Jenkins is not bound by the LGPL. */ |
152 | 160 | #ifdef __MINGW32__ |
153 | 161 | #include <io.h> |
154 | 162 | #ifndef HAVE_FSEEKO |
155 | #define ftello ftell | |
156 | #define fseeko fseek | |
163 | #define ftello _ftelli64 | |
164 | #define fseeko _fseeki64 | |
157 | 165 | #endif |
158 | 166 | #endif |
159 | 167 | |
281 | 289 | return(fwrite(buf, siz, cnt, fp)); |
282 | 290 | } |
283 | 291 | |
284 | static int fstFtruncate(int fd, off_t length) | |
292 | static int fstFtruncate(int fd, fst_off_t length) | |
285 | 293 | { |
286 | 294 | return(ftruncate(fd, length)); |
287 | 295 | } |
326 | 334 | #define fstMmap(__addr,__len,__prot,__flags,__fd,__off) fstMmap2((__len), (__fd), (__off)) |
327 | 335 | #define fstMunmap(__addr,__len) free(__addr) |
328 | 336 | |
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) | |
330 | 338 | { |
331 | 339 | (void)__off; |
332 | 340 | |
333 | 341 | 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); | |
335 | 343 | size_t i; |
336 | 344 | |
337 | 345 | lseek(__fd, 0, SEEK_SET); |
731 | 739 | |
732 | 740 | unsigned char *vchg_mem; |
733 | 741 | |
734 | off_t hier_file_len; | |
742 | fst_off_t hier_file_len; | |
735 | 743 | |
736 | 744 | uint32_t *valpos_mem; |
737 | 745 | unsigned char *curval_mem; |
751 | 759 | unsigned fastpack : 1; |
752 | 760 | |
753 | 761 | int64_t timezero; |
754 | off_t section_header_truncpos; | |
762 | fst_off_t section_header_truncpos; | |
755 | 763 | uint32_t tchn_cnt, tchn_idx; |
756 | 764 | uint64_t curtime; |
757 | 765 | uint64_t firsttime; |
759 | 767 | uint32_t vchg_alloc_siz; |
760 | 768 | |
761 | 769 | uint32_t secnum; |
762 | off_t section_start; | |
770 | fst_off_t section_start; | |
763 | 771 | |
764 | 772 | uint32_t numscopes; |
765 | 773 | double nan; /* nan value for uninitialized doubles */ |
791 | 799 | pthread_attr_t thread_attr; |
792 | 800 | struct fstWriterContext *xc_parent; |
793 | 801 | #endif |
802 | unsigned in_pthread : 1; | |
794 | 803 | |
795 | 804 | size_t fst_orig_break_size; |
796 | 805 | size_t fst_orig_break_add_size; |
816 | 825 | }; |
817 | 826 | |
818 | 827 | |
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) | |
820 | 829 | { |
821 | 830 | int rc = fseeko(stream, offset, whence); |
822 | 831 | |
983 | 992 | |
984 | 993 | static void fstWriterCreateMmaps(struct fstWriterContext *xc) |
985 | 994 | { |
986 | off_t curpos = ftello(xc->handle); | |
995 | fst_off_t curpos = ftello(xc->handle); | |
987 | 996 | |
988 | 997 | fflush(xc->hier_handle); |
989 | 998 | |
1023 | 1032 | |
1024 | 1033 | static void fstDestroyMmaps(struct fstWriterContext *xc, int is_closing) |
1025 | 1034 | { |
1035 | #if !defined __CYGWIN__ && !defined __MINGW32__ | |
1026 | 1036 | (void)is_closing; |
1037 | #endif | |
1027 | 1038 | |
1028 | 1039 | fstMunmap(xc->valpos_mem, xc->maxhandle * 4 * sizeof(uint32_t)); |
1029 | 1040 | xc->valpos_mem = NULL; |
1035 | 1046 | { |
1036 | 1047 | unsigned char *pnt = xc->curval_mem; |
1037 | 1048 | 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); | |
1039 | 1050 | size_t i; |
1040 | 1051 | size_t __len = xc->maxvalpos; |
1041 | 1052 | |
1276 | 1287 | unsigned int i; |
1277 | 1288 | unsigned char *vchg_mem; |
1278 | 1289 | FILE *f; |
1279 | off_t fpos, indxpos, endpos; | |
1290 | fst_off_t fpos, indxpos, endpos; | |
1280 | 1291 | uint32_t prevpos; |
1281 | 1292 | int zerocnt; |
1282 | 1293 | unsigned char *scratchpad; |
1283 | 1294 | unsigned char *scratchpnt; |
1284 | 1295 | 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 */ | |
1287 | 1298 | unsigned char *packmem; |
1288 | 1299 | unsigned int packmemlen; |
1289 | 1300 | uint32_t *vm4ip; |
1727 | 1738 | unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen)); |
1728 | 1739 | int rc = compress2(dmem, &destlen, tmem, tlen, 9); |
1729 | 1740 | |
1730 | if((rc == Z_OK) && (((off_t)destlen) < tlen)) | |
1741 | if((rc == Z_OK) && (((fst_off_t)destlen) < tlen)) | |
1731 | 1742 | { |
1732 | 1743 | fstFwrite(dmem, destlen, 1, xc->handle); |
1733 | 1744 | } |
1775 | 1786 | xc2->section_header_truncpos = endpos; /* cache in case of need to truncate */ |
1776 | 1787 | if(xc->dump_size_limit) |
1777 | 1788 | { |
1778 | if(endpos >= ((off_t)xc->dump_size_limit)) | |
1789 | if(endpos >= ((fst_off_t)xc->dump_size_limit)) | |
1779 | 1790 | { |
1780 | 1791 | xc2->skip_writing_section_hdr = 1; |
1781 | 1792 | xc2->size_limit_locked = 1; |
1800 | 1811 | static void *fstWriterFlushContextPrivate1(void *ctx) |
1801 | 1812 | { |
1802 | 1813 | struct fstWriterContext *xc = (struct fstWriterContext *)ctx; |
1803 | ||
1814 | struct fstWriterContext *xc_parent; | |
1815 | ||
1816 | pthread_mutex_lock(&(xc->xc_parent->mutex)); | |
1804 | 1817 | fstWriterFlushContextPrivate2(xc); |
1805 | ||
1806 | pthread_mutex_unlock(&(xc->xc_parent->mutex)); | |
1807 | 1818 | |
1808 | 1819 | #ifdef FST_REMOVE_DUPLICATE_VC |
1809 | 1820 | free(xc->curval_mem); |
1811 | 1822 | free(xc->valpos_mem); |
1812 | 1823 | free(xc->vchg_mem); |
1813 | 1824 | tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam); |
1825 | xc_parent = xc->xc_parent; | |
1814 | 1826 | free(xc); |
1827 | ||
1828 | xc_parent->in_pthread = 0; | |
1829 | pthread_mutex_unlock(&(xc_parent->mutex)); | |
1815 | 1830 | |
1816 | 1831 | return(NULL); |
1817 | 1832 | } |
1860 | 1875 | xc->section_header_only = 0; |
1861 | 1876 | xc->secnum++; |
1862 | 1877 | |
1878 | while (xc->in_pthread) | |
1879 | { | |
1880 | pthread_mutex_lock(&xc->mutex); | |
1881 | pthread_mutex_unlock(&xc->mutex); | |
1882 | }; | |
1883 | ||
1863 | 1884 | pthread_mutex_lock(&xc->mutex); |
1885 | xc->in_pthread = 1; | |
1886 | pthread_mutex_unlock(&xc->mutex); | |
1864 | 1887 | |
1865 | 1888 | pthread_create(&xc->thread, &xc->thread_attr, fstWriterFlushContextPrivate1, xc2); |
1866 | 1889 | } |
1913 | 1936 | if(xc && !xc->already_in_close && !xc->already_in_flush) |
1914 | 1937 | { |
1915 | 1938 | unsigned char *tmem = NULL; |
1916 | off_t fixup_offs, tlen, hlen; | |
1939 | fst_off_t fixup_offs, tlen, hlen; | |
1917 | 1940 | |
1918 | 1941 | xc->already_in_close = 1; /* never need to zero this out as it is freed at bottom */ |
1919 | 1942 | |
1942 | 1965 | #ifdef FST_WRITER_PARALLEL |
1943 | 1966 | pthread_mutex_lock(&xc->mutex); |
1944 | 1967 | 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 | }; | |
1945 | 1974 | #endif |
1946 | 1975 | } |
1947 | 1976 | } |
1967 | 1996 | unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen)); |
1968 | 1997 | int rc = compress2(dmem, &destlen, tmem, tlen, 9); |
1969 | 1998 | |
1970 | if((rc != Z_OK) || (((off_t)destlen) > tlen)) | |
1999 | if((rc != Z_OK) || (((fst_off_t)destlen) > tlen)) | |
1971 | 2000 | { |
1972 | 2001 | destlen = tlen; |
1973 | 2002 | } |
1978 | 2007 | fstWriterUint64(xc->handle, tlen); /* uncompressed */ |
1979 | 2008 | /* compressed len is section length - 24 */ |
1980 | 2009 | 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); | |
1982 | 2011 | fflush(xc->handle); |
1983 | 2012 | |
1984 | 2013 | fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET); |
1994 | 2023 | if(xc->num_blackouts) |
1995 | 2024 | { |
1996 | 2025 | uint64_t cur_bl = 0; |
1997 | off_t bpos, eos; | |
2026 | fst_off_t bpos, eos; | |
1998 | 2027 | uint32_t i; |
1999 | 2028 | |
2000 | 2029 | fixup_offs = ftello(xc->handle); |
2027 | 2056 | |
2028 | 2057 | if(xc->compress_hier) |
2029 | 2058 | { |
2030 | off_t hl, eos; | |
2059 | fst_off_t hl, eos; | |
2031 | 2060 | gzFile zhandle; |
2032 | 2061 | int zfd; |
2033 | 2062 | int fourpack_duo = 0; |
2150 | 2179 | if(xc->repack_on_close) |
2151 | 2180 | { |
2152 | 2181 | FILE *fp; |
2153 | off_t offpnt, uclen; | |
2182 | fst_off_t offpnt, uclen; | |
2154 | 2183 | int flen = strlen(xc->filename); |
2155 | 2184 | char *hf = (char *)calloc(1, flen + 5); |
2156 | 2185 | |
2257 | 2286 | if(xc) |
2258 | 2287 | { |
2259 | 2288 | char s[FST_HDR_DATE_SIZE]; |
2260 | off_t fpos = ftello(xc->handle); | |
2289 | fst_off_t fpos = ftello(xc->handle); | |
2261 | 2290 | int len = strlen(dat); |
2262 | 2291 | |
2263 | 2292 | fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_DATE, SEEK_SET); |
2276 | 2305 | if(xc && vers) |
2277 | 2306 | { |
2278 | 2307 | char s[FST_HDR_SIM_VERSION_SIZE]; |
2279 | off_t fpos = ftello(xc->handle); | |
2308 | fst_off_t fpos = ftello(xc->handle); | |
2280 | 2309 | int len = strlen(vers); |
2281 | 2310 | |
2282 | 2311 | fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_SIM_VERSION, SEEK_SET); |
2296 | 2325 | { |
2297 | 2326 | if(/*(filetype >= FST_FT_MIN) &&*/ (filetype <= FST_FT_MAX)) |
2298 | 2327 | { |
2299 | off_t fpos = ftello(xc->handle); | |
2328 | fst_off_t fpos = ftello(xc->handle); | |
2300 | 2329 | |
2301 | 2330 | xc->filetype = filetype; |
2302 | 2331 | |
2437 | 2466 | struct fstWriterContext *xc = (struct fstWriterContext *)ctx; |
2438 | 2467 | if(xc) |
2439 | 2468 | { |
2440 | off_t fpos = ftello(xc->handle); | |
2469 | fst_off_t fpos = ftello(xc->handle); | |
2441 | 2470 | fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_TIMESCALE, SEEK_SET); |
2442 | 2471 | fputc(ts & 255, xc->handle); |
2443 | 2472 | fflush(xc->handle); |
2495 | 2524 | struct fstWriterContext *xc = (struct fstWriterContext *)ctx; |
2496 | 2525 | if(xc) |
2497 | 2526 | { |
2498 | off_t fpos = ftello(xc->handle); | |
2527 | fst_off_t fpos = ftello(xc->handle); | |
2499 | 2528 | fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_TIMEZERO, SEEK_SET); |
2500 | 2529 | fstWriterUint64(xc->handle, (xc->timezero = tim)); |
2501 | 2530 | fflush(xc->handle); |
3337 | 3366 | int64_t timezero; |
3338 | 3367 | |
3339 | 3368 | char *filename, *filename_unpacked; |
3340 | off_t hier_pos; | |
3369 | fst_off_t hier_pos; | |
3341 | 3370 | |
3342 | 3371 | uint32_t num_blackouts; |
3343 | 3372 | uint64_t *blackout_times; |
3352 | 3381 | uint64_t rvat_beg_tim, rvat_end_tim; |
3353 | 3382 | unsigned char *rvat_frame_data; |
3354 | 3383 | uint64_t rvat_frame_maxhandle; |
3355 | off_t *rvat_chain_table; | |
3384 | fst_off_t *rvat_chain_table; | |
3356 | 3385 | uint32_t *rvat_chain_table_lengths; |
3357 | 3386 | uint64_t rvat_vc_maxhandle; |
3358 | off_t rvat_vc_start; | |
3387 | fst_off_t rvat_vc_start; | |
3359 | 3388 | uint32_t *rvat_sig_offs; |
3360 | 3389 | int rvat_packtype; |
3361 | 3390 | |
3394 | 3423 | }; |
3395 | 3424 | |
3396 | 3425 | |
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) | |
3398 | 3427 | { |
3399 | 3428 | int rc = fseeko(stream, offset, whence); |
3400 | 3429 | |
3887 | 3916 | |
3888 | 3917 | if(!xc->fh) |
3889 | 3918 | { |
3890 | off_t offs_cache = ftello(xc->f); | |
3919 | fst_off_t offs_cache = ftello(xc->f); | |
3891 | 3920 | char *fnam = (char *)malloc(strlen(xc->filename) + 6 + 16 + 32 + 1); |
3892 | 3921 | 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; | |
3895 | 3924 | gzFile zhandle = NULL; |
3896 | 3925 | int zfd; |
3897 | 3926 | int htyp = FST_BL_SKIP; |
4511 | 4540 | */ |
4512 | 4541 | int fstReaderInit(struct fstReaderContext *xc) |
4513 | 4542 | { |
4514 | off_t blkpos = 0; | |
4515 | off_t endfile; | |
4543 | fst_off_t blkpos = 0; | |
4544 | fst_off_t endfile; | |
4516 | 4545 | uint64_t seclen; |
4517 | 4546 | int sectype; |
4518 | 4547 | uint64_t vc_section_count_actual = 0; |
4524 | 4553 | if(sectype == FST_BL_ZWRAPPER) |
4525 | 4554 | { |
4526 | 4555 | FILE *fcomp; |
4527 | off_t offpnt, uclen; | |
4556 | fst_off_t offpnt, uclen; | |
4528 | 4557 | char gz_membuf[FST_GZIO_LEN]; |
4529 | 4558 | gzFile zhandle; |
4530 | 4559 | int zfd; |
4957 | 4986 | uint64_t tsec_nitems; |
4958 | 4987 | unsigned int secnum = 0; |
4959 | 4988 | int blocks_skipped = 0; |
4960 | off_t blkpos = 0; | |
4989 | fst_off_t blkpos = 0; | |
4961 | 4990 | uint64_t seclen, beg_tim; |
4962 | #ifdef FST_DEBUG | |
4963 | 4991 | uint64_t end_tim; |
4964 | #endif | |
4965 | 4992 | 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; | |
4969 | 4996 | uint32_t *chain_table_lengths = NULL; |
4970 | 4997 | unsigned char *chain_cmem; |
4971 | 4998 | unsigned char *pnt; |
5028 | 5055 | if(!seclen) break; |
5029 | 5056 | |
5030 | 5057 | beg_tim = fstReaderUint64(xc->f); |
5031 | #ifdef FST_DEBUG | |
5032 | end_tim = | |
5033 | #endif | |
5034 | fstReaderUint64(xc->f); | |
5058 | end_tim = fstReaderUint64(xc->f); | |
5035 | 5059 | |
5036 | 5060 | if(xc->limit_range_valid) |
5037 | 5061 | { |
5038 | if(beg_tim < xc->limit_range_start) | |
5062 | if(end_tim < xc->limit_range_start) | |
5039 | 5063 | { |
5040 | 5064 | blocks_skipped++; |
5041 | 5065 | blkpos += seclen; |
5081 | 5105 | destlen = tsec_uclen; |
5082 | 5106 | sourcelen = tsec_clen; |
5083 | 5107 | |
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); | |
5085 | 5109 | |
5086 | 5110 | if(tsec_uclen != tsec_clen) |
5087 | 5111 | { |
5322 | 5346 | } |
5323 | 5347 | |
5324 | 5348 | 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 */ | |
5330 | 5354 | |
5331 | 5355 | vc_maxhandle = fstReaderVarint64(xc->f); |
5332 | 5356 | vc_start = ftello(xc->f); /* points to '!' character */ |
5356 | 5380 | free(chain_table_lengths); |
5357 | 5381 | |
5358 | 5382 | 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)); | |
5360 | 5384 | chain_table_lengths = (uint32_t *)calloc((vc_maxhandle+1), sizeof(uint32_t)); |
5361 | 5385 | } |
5362 | 5386 | |
5977 | 6001 | char *fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf) |
5978 | 6002 | { |
5979 | 6003 | struct fstReaderContext *xc = (struct fstReaderContext *)ctx; |
5980 | off_t blkpos = 0, prev_blkpos; | |
6004 | fst_off_t blkpos = 0, prev_blkpos; | |
5981 | 6005 | uint64_t beg_tim, end_tim, beg_tim2, end_tim2; |
5982 | 6006 | int sectype; |
5983 | 6007 | unsigned int secnum = 0; |
5988 | 6012 | #ifdef FST_DEBUG |
5989 | 6013 | uint64_t mem_required_for_traversal; |
5990 | 6014 | #endif |
5991 | off_t indx_pntr, indx_pos; | |
6015 | fst_off_t indx_pntr, indx_pos; | |
5992 | 6016 | long chain_clen; |
5993 | 6017 | unsigned char *chain_cmem; |
5994 | 6018 | unsigned char *pnt; |
6050 | 6074 | { |
6051 | 6075 | if((tim == end_tim) && (tim != xc->end_time)) |
6052 | 6076 | { |
6053 | off_t cached_pos = ftello(xc->f); | |
6077 | fst_off_t cached_pos = ftello(xc->f); | |
6054 | 6078 | fstReaderFseeko(xc, xc->f, blkpos, SEEK_SET); |
6055 | 6079 | |
6056 | 6080 | sectype = fgetc(xc->f); |
6112 | 6136 | destlen = tsec_uclen; |
6113 | 6137 | sourcelen = tsec_clen; |
6114 | 6138 | |
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); | |
6116 | 6140 | if(tsec_uclen != tsec_clen) |
6117 | 6141 | { |
6118 | 6142 | cdata = (unsigned char *)malloc(tsec_clen); |
6197 | 6221 | fstReaderFseeko(xc, xc->f, indx_pos, SEEK_SET); |
6198 | 6222 | fstFread(chain_cmem, chain_clen, 1, xc->f); |
6199 | 6223 | |
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)); | |
6201 | 6225 | xc->rvat_chain_table_lengths = (uint32_t *)calloc((xc->rvat_vc_maxhandle+1), sizeof(uint32_t)); |
6202 | 6226 | |
6203 | 6227 | pnt = chain_cmem; |
17 | 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
18 | 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
19 | 19 | * DEALINGS IN THE SOFTWARE. |
20 | * | |
21 | * SPDX-License-Identifier: MIT | |
20 | 22 | */ |
21 | 23 | |
22 | 24 | #ifndef FST_API_H |
32 | 34 | #include <ctype.h> |
33 | 35 | #include <zlib.h> |
34 | 36 | #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 | |
36 | 42 | #include <time.h> |
37 | 43 | |
38 | 44 | #define FST_RDLOAD "FSTLOAD | " |
25 | 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 | 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | ||
29 | SPDX-License-Identifier: BSD-2-Clause | |
28 | 30 | |
29 | 31 | You can contact the author at : |
30 | 32 | - LZ4 source repository : https://github.com/Cyan4973/lz4 |
26 | 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | ||
30 | SPDX-License-Identifier: BSD-2-Clause | |
29 | 31 | |
30 | 32 | You can contact the author at : |
31 | 33 | - LZ4 source repository : https://github.com/Cyan4973/lz4 |
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 |
1153 | 1153 | { |
1154 | 1154 | exp+=2; |
1155 | 1155 | } |
1156 | else | |
1157 | if(tv == 1000) /* nonstandard */ | |
1158 | { | |
1159 | exp+=3; | |
1160 | } | |
1156 | 1161 | |
1157 | 1162 | fstWriterSetTimescale(ctx, exp); |
1158 | 1163 | } |
1858 | 1858 | msk = (~0U << lt->timepos); |
1859 | 1859 | msk_n = ~msk; |
1860 | 1860 | |
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 | ||
1861 | 1872 | for(j=0;j<lt->numfacs;j++) |
1862 | 1873 | { |
1863 | 1874 | 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_ */ |
116 | 116 | GLOBALS->display_grid = g_old->display_grid; |
117 | 117 | GLOBALS->highlight_wavewindow = g_old->highlight_wavewindow; |
118 | 118 | GLOBALS->fill_waveform = g_old->fill_waveform; |
119 | GLOBALS->lz_removal = g_old->lz_removal; | |
119 | 120 | GLOBALS->use_standard_trace_select = g_old->use_standard_trace_select; |
120 | 121 | GLOBALS->disable_mouseover = g_old->disable_mouseover; |
121 | 122 | GLOBALS->clipboard_mouseover = g_old->clipboard_mouseover; |
633 | 634 | GLOBALS->enable_ghost_marker = old_g->enable_ghost_marker; |
634 | 635 | GLOBALS->enable_horiz_grid = old_g->enable_horiz_grid; |
635 | 636 | GLOBALS->fill_waveform = old_g->fill_waveform; |
637 | GLOBALS->lz_removal = old_g->lz_removal; | |
636 | 638 | GLOBALS->make_vcd_save_file = old_g->make_vcd_save_file; |
637 | 639 | GLOBALS->enable_vert_grid = old_g->enable_vert_grid; |
638 | 640 | GLOBALS->force_toolbars = old_g->force_toolbars; |
648 | 650 | GLOBALS->show_base = old_g->show_base; |
649 | 651 | GLOBALS->display_grid = old_g->display_grid; |
650 | 652 | GLOBALS->highlight_wavewindow = old_g->highlight_wavewindow; |
651 | GLOBALS->fill_waveform = old_g->fill_waveform; | |
652 | 653 | GLOBALS->use_standard_trace_select = old_g->use_standard_trace_select; |
653 | 654 | GLOBALS->use_big_fonts = old_g->use_big_fonts; |
654 | 655 | GLOBALS->use_full_precision = old_g->use_full_precision; |
4482 | 4482 | t=GLOBALS->showchangeall_menu_c_1; |
4483 | 4483 | if(t) |
4484 | 4484 | { |
4485 | flags = t->flags & (TR_NUMMASK | TR_HIGHLIGHT); | |
4485 | flags = t->flags & (TR_NUMMASK | TR_HIGHLIGHT | TR_ATTRIBS); | |
4486 | 4486 | while(t) |
4487 | 4487 | { |
4488 | 4488 | if((t->flags&TR_HIGHLIGHT)&&(!(t->flags&(TR_BLANK|TR_ANALOG_BLANK_STRETCH)))&&(t->name)) |
4489 | 4489 | { |
4490 | t->flags = (t->flags & ~(TR_NUMMASK | TR_HIGHLIGHT)) | flags; | |
4490 | t->flags = (t->flags & ~(TR_NUMMASK | TR_HIGHLIGHT | TR_ATTRIBS)) | flags; | |
4491 | 4491 | t->minmax_valid = 0; /* force analog traces to regenerate if necessary */ |
4492 | 4492 | } |
4493 | 4493 | t=t->t_next; |
6770 | 6770 | dataformat( ~(TR_POPCNT), 0 ); |
6771 | 6771 | } |
6772 | 6772 | |
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 | ||
6773 | 6816 | |
6774 | 6817 | void |
6775 | 6818 | menu_dataformat_time(gpointer null_data, guint callback_action, GtkWidget *widget) |
7783 | 7826 | |
7784 | 7827 | #ifndef WAVE_USE_MLIST_T |
7785 | 7828 | 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; | |
7786 | 7865 | #endif |
7787 | 7866 | } |
7788 | 7867 | |
7989 | 8068 | WAVE_GTKIFE("/Edit/Data Format/Gray Filters/None", NULL, menu_dataformat_nogray, WV_MENU_GBNONE, "<Item>"), |
7990 | 8069 | WAVE_GTKIFE("/Edit/Data Format/Popcnt/On", NULL, menu_dataformat_popcnt_on, WV_MENU_POPON, "<Item>"), |
7991 | 8070 | 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>"), | |
7992 | 8073 | WAVE_GTKIFE("/Edit/Data Format/Fixed Point Shift/On", NULL, menu_dataformat_fpshift_on, WV_MENU_FPSHIFTON, "<Item>"), |
7993 | 8074 | WAVE_GTKIFE("/Edit/Data Format/Fixed Point Shift/Off", NULL, menu_dataformat_fpshift_off, WV_MENU_FPSHIFTOFF, "<Item>"), |
7994 | 8075 | WAVE_GTKIFE("/Edit/Data Format/Fixed Point Shift/Specify", NULL, menu_dataformat_fpshift_specify, WV_MENU_FPSHIFTVAL, "<Item>"), |
8107 | 8188 | WAVE_GTKIFE("/View/<separator>", NULL, NULL, WV_MENU_SEP9, "<Separator>"), |
8108 | 8189 | WAVE_GTKIFE("/View/Show Wave Highlight", NULL, menu_show_wave_highlight, WV_MENU_SHW, "<ToggleItem>"), |
8109 | 8190 | 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>"), | |
8110 | 8192 | WAVE_GTKIFE("/View/<separator>", NULL, NULL, WV_MENU_SEP9B, "<Separator>"), |
8111 | 8193 | WAVE_GTKIFE("/View/Show Mouseover", NULL, menu_show_mouseover, WV_MENU_VSMO, "<ToggleItem>"), |
8112 | 8194 | #ifdef WAVE_USE_GTK2 |
8238 | 8320 | |
8239 | 8321 | 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; |
8240 | 8322 | |
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 | ||
8241 | 8325 | 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; |
8242 | 8326 | |
8243 | 8327 | 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; |
8294 | 8378 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_VSG]), GLOBALS->display_grid); |
8295 | 8379 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_SHW]), GLOBALS->highlight_wavewindow); |
8296 | 8380 | 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); | |
8297 | 8382 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_HSWM]), GLOBALS->alt_wheel_mode); |
8298 | 8383 | |
8299 | 8384 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_wlist[WV_MENU_VSMO]), !GLOBALS->disable_mouseover); |
8695 | 8780 | WAVE_GTKIFE("/Data Format/Gray Filters/None", NULL, menu_dataformat_nogray, WV_MENU_GBNONE, "<Item>"), |
8696 | 8781 | WAVE_GTKIFE("/Data Format/Popcnt/On", NULL, menu_dataformat_popcnt_on, WV_MENU_POPON, "<Item>"), |
8697 | 8782 | 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>"), | |
8698 | 8785 | WAVE_GTKIFE("/Data Format/Fixed Point Shift/On", NULL, menu_dataformat_fpshift_on, WV_MENU_FPSHIFTON, "<Item>"), |
8699 | 8786 | WAVE_GTKIFE("/Data Format/Fixed Point Shift/Off", NULL, menu_dataformat_fpshift_off, WV_MENU_FPSHIFTOFF, "<Item>"), |
8700 | 8787 | WAVE_GTKIFE("/Data Format/Fixed Point Shift/Specify", NULL, menu_dataformat_fpshift_specify, WV_MENU_FPSHIFTVAL, "<Item>"), |
166 | 166 | WV_MENU_GBNONE, |
167 | 167 | WV_MENU_POPON, |
168 | 168 | WV_MENU_POPOFF, |
169 | WV_MENU_FFOON, | |
170 | WV_MENU_FFOOFF, | |
169 | 171 | WV_MENU_FPSHIFTON, |
170 | 172 | WV_MENU_FPSHIFTOFF, |
171 | 173 | WV_MENU_FPSHIFTVAL, |
263 | 265 | WV_MENU_SEP9, |
264 | 266 | WV_MENU_SHW, |
265 | 267 | WV_MENU_FILL1, |
268 | WV_MENU_LZ_REMOVAL, | |
266 | 269 | WV_MENU_SEP9B, |
267 | 270 | WV_MENU_VSMO, |
268 | 271 | #ifdef WAVE_USE_GTK2 |
83 | 83 | if((flags & TR_TTRANSLATED) != 0) { ch[pos++] = 'T'; } |
84 | 84 | |
85 | 85 | /* [14] */ |
86 | if((flags & TR_FFO) != 0) { ch[pos++] = 'f'; } | |
87 | ||
88 | /* [15] */ | |
86 | 89 | if((flags & TR_POPCNT) != 0) { ch[pos++] = 'p'; } |
87 | 90 | |
88 | /* [15] */ | |
91 | /* [16] */ | |
89 | 92 | if((flags & TR_FPDECSHIFT) != 0) |
90 | 93 | { |
91 | 94 | int ln = sprintf(ch+pos, "s(%d)", t->t_fpdecshift); |
92 | 95 | pos += ln; |
93 | 96 | } |
94 | 97 | |
95 | /* [16+] */ | |
98 | /* [17+] */ | |
96 | 99 | ch[pos] = 0; |
97 | 100 | |
98 | 101 | return(pos); |
109 | 109 | if((flags & TR_TTRANSLATED) != 0) { ch[pos++] = 'T'; } |
110 | 110 | |
111 | 111 | /* [14] */ |
112 | if((flags & TR_FFO) != 0) { ch[pos++] = 'f'; } | |
113 | ||
114 | /* [15] */ | |
112 | 115 | if((flags & TR_POPCNT) != 0) { ch[pos++] = 'p'; } |
113 | 116 | |
114 | /* [15] */ | |
117 | /* [16] */ | |
115 | 118 | if((flags & TR_FPDECSHIFT) != 0) |
116 | 119 | { |
117 | 120 | int ln = sprintf(ch+pos, "s(%d)", t->t_fpdecshift); |
118 | 121 | pos += ln; |
119 | 122 | } |
120 | 123 | |
121 | /* [16+] */ | |
124 | /* [17+] */ | |
122 | 125 | ch[pos] = 0; |
123 | 126 | |
124 | 127 | if(!t->vector) |
276 | 276 | { |
277 | 277 | DEBUG(printf("f_fill_waveform(\"%s\")\n",str)); |
278 | 278 | 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; | |
279 | 286 | return(0); |
280 | 287 | } |
281 | 288 | |
941 | 948 | { "keep_xz_colors", f_keep_xz_colors }, |
942 | 949 | { "left_justify_sigs", f_left_justify_sigs }, |
943 | 950 | { "lxt_clock_compress_to_z", f_lxt_clock_compress_to_z }, |
951 | { "lz_removal", f_lz_removal }, | |
944 | 952 | { "max_fsdb_trees", f_max_fsdb_trees }, |
945 | 953 | { "page_divisor", f_page_divisor }, |
946 | 954 | { "ps_maxveclen", f_ps_maxveclen }, |
1097 | 1105 | |
1098 | 1106 | void read_rc_file(char *override_rc) |
1099 | 1107 | { |
1100 | FILE *handle; | |
1108 | FILE *handle = NULL; | |
1101 | 1109 | int i; |
1102 | 1110 | int num_rcitems = sizeof(rcitems)/sizeof(struct rc_entry); |
1103 | 1111 | |
1122 | 1130 | #if !defined __MINGW32__ && !defined _MSC_VER |
1123 | 1131 | if(!(handle=fopen(rcname,"rb"))) |
1124 | 1132 | { |
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")) ) | |
1135 | 1157 | { |
1136 | 1158 | #ifdef MAC_INTEGRATION |
1137 | 1159 | const gchar *bundle_id = gtkosx_application_get_bundle_id(); |
59 | 59 | (void)nothing; |
60 | 60 | |
61 | 61 | 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); | |
62 | 68 | } |
63 | 69 | |
64 | 70 | static void enter_callback(GtkWidget *widget, GtkWidget *nothing) |
288 | 294 | gtk_widget_show (GLOBALS->toggle5_showchange_c_1); |
289 | 295 | gtkwave_signal_connect (GTK_OBJECT (GLOBALS->toggle5_showchange_c_1), "toggled", GTK_SIGNAL_FUNC(toggle5_callback), NULL); |
290 | 296 | |
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 | ||
291 | 303 | gtk_container_add (GTK_CONTAINER (main_vbox), hbox); |
292 | 304 | |
293 | 305 | separator = gtk_hseparator_new (); |
18 | 18 | /* GDK_KEY_equal defined from gtk2 2.22 onwards. */ |
19 | 19 | #ifndef GDK_KEY_equal |
20 | 20 | #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 | |
21 | 33 | #endif |
22 | 34 | |
23 | 35 | #undef FOCUS_DEBUG_MSGS |
470 | 482 | int which; |
471 | 483 | gint rc = FALSE; |
472 | 484 | int yscroll; |
485 | int ud_kill = 0; | |
473 | 486 | |
474 | 487 | #ifdef FOCUS_DEBUG_MSGS |
475 | 488 | printf("focus: %d %08x %08x %08x\n", GTK_WIDGET_HAS_FOCUS(GLOBALS->signalarea_event_box), |
548 | 561 | num_traces_displayable=(GLOBALS->signalarea->allocation.height)/(GLOBALS->fontheight); |
549 | 562 | num_traces_displayable--; /* for the time trace that is always there */ |
550 | 563 | |
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)) | |
552 | 686 | { |
553 | 687 | switch(event->keyval) |
554 | 688 | { |
567 | 701 | |
568 | 702 | gtk_signal_emit_by_name (GTK_OBJECT (wadj), "changed"); /* force bar update */ |
569 | 703 | 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); | |
570 | 706 | break; |
571 | 707 | |
572 | 708 | case GDK_Up: |
1227 | 1363 | } |
1228 | 1364 | else |
1229 | 1365 | { |
1230 | t->flags ^= TR_HIGHLIGHT; | |
1366 | t->flags ^= TR_HIGHLIGHT; MarkTraceCursor(t); | |
1231 | 1367 | } |
1232 | 1368 | } |
1233 | 1369 | } |
1234 | 1370 | else |
1235 | 1371 | if((event->state&GDK_SHIFT_MASK)&&(GLOBALS->starting_unshifted_trace)) |
1236 | 1372 | { |
1237 | int src = -1, dst = -1; | |
1373 | int src = -1, dst = -1, dsto = -1; | |
1238 | 1374 | int cnt = 0; |
1239 | 1375 | |
1240 | 1376 | t2=GLOBALS->traces.first; |
1264 | 1400 | cnt++; |
1265 | 1401 | } |
1266 | 1402 | |
1403 | dsto = dst; | |
1267 | 1404 | if(src > dst) { int cpy; cpy = src; src = dst; dst = cpy; } |
1268 | 1405 | cnt = 0; |
1269 | 1406 | t2=GLOBALS->traces.first; |
1274 | 1411 | t2->flags |= TR_HIGHLIGHT; |
1275 | 1412 | } |
1276 | 1413 | |
1414 | if(cnt == dsto) { MarkTraceCursor(t2); } | |
1415 | ||
1277 | 1416 | cnt++; |
1278 | 1417 | t2=t2->t_next; |
1279 | 1418 | } |
1297 | 1436 | t2 = t2->t_next; |
1298 | 1437 | } |
1299 | 1438 | |
1300 | if(t) { t->flags |= TR_HIGHLIGHT; } /* scan-build */ | |
1439 | if(t) { t->flags |= TR_HIGHLIGHT; MarkTraceCursor(t); } /* scan-build */ | |
1301 | 1440 | } |
1302 | 1441 | |
1303 | 1442 | GLOBALS->standard_trace_dnd_degate = 0; |
351 | 351 | |
352 | 352 | while(tnext) |
353 | 353 | { |
354 | if(tnext->child) treenamefix(tnext->child); | |
354 | 355 | if(tnext->name) treenamefix_str(tnext->name); |
355 | 356 | tnext=tnext->next; |
356 | 357 | } |
115 | 115 | uint32_t t_stem; /* source stem (if >0) for Open Hierarchy Source Def, see stem_struct_t */ |
116 | 116 | uint32_t t_istem; /* source stem (if >0) for Open Hierarchy Source Inst, see stem_struct_t */ |
117 | 117 | |
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 */ | |
119 | 119 | 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 */ |
120 | 120 | char name[]; /* C99 */ |
121 | 121 | }; |
370 | 370 | gtk_clist_thaw(GTK_CLIST(ctree)); |
371 | 371 | |
372 | 372 | gtk_ctree_node_moveto(ctree, nodehist[depth-1], |
373 | depth /*column*/, | |
373 | 0, /*column*/ /* was originally depth instead of zero */ | |
374 | 374 | 0.5 /*row_align*/, |
375 | 375 | 0.5 /*col_align*/); |
376 | 376 | /* printf("[treeopennode] '%s' ok\n", name); */ |
2212 | 2212 | str=(slen>max_slen)?(wave_alloca((max_slen=slen)+32)):(str); /* more than enough */ |
2213 | 2213 | strcpy(str,v->name); |
2214 | 2214 | |
2215 | if(v->msi>=0) | |
2215 | if((v->msi>=0)||(v->msi != v->lsi)) | |
2216 | 2216 | { |
2217 | 2217 | strcpy(str+slen,GLOBALS->vcd_hier_delimeter); |
2218 | 2218 | slen++; |
2054 | 2054 | str=(slen>max_slen)?(wave_alloca((max_slen=slen)+32)):(str); /* more than enough */ |
2055 | 2055 | strcpy(str,v->name); |
2056 | 2056 | |
2057 | if(v->msi>=0) | |
2057 | if((v->msi>=0)||(v->msi != v->lsi)) | |
2058 | 2058 | { |
2059 | 2059 | strcpy(str+slen,GLOBALS->vcd_hier_delimeter); |
2060 | 2060 | slen++; |
2447 | 2447 | str=(slen>max_slen)?(wave_alloca((max_slen=slen)+32)):(str); /* more than enough */ |
2448 | 2448 | strcpy(str,v->name); |
2449 | 2449 | |
2450 | if(v->msi>=0) | |
2450 | if((v->msi>=0)||(v->msi != v->lsi)) | |
2451 | 2451 | { |
2452 | 2452 | strcpy(str+slen,GLOBALS->vcd_hier_delimeter); |
2453 | 2453 | slen++; |
17 | 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
18 | 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
19 | 19 | * DEALINGS IN THE SOFTWARE. |
20 | * | |
21 | * SPDX-License-Identifier: MIT | |
20 | 22 | */ |
21 | 23 | |
22 | 24 | #ifndef WAVE_ALLOCA_H |
3236 | 3236 | yu=(_y0+_y1)/2; |
3237 | 3237 | ytext=yu-(GLOBALS->wavefont->ascent/2)+GLOBALS->wavefont->ascent; |
3238 | 3238 | |
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 | |
3239 | 3246 | if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid)&&(!kill_grid)) |
3240 | 3247 | { |
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); | |
3252 | 3250 | } |
3253 | 3251 | |
3254 | 3252 | if((h)&&(GLOBALS->tims.start==h->time)) |
3995 | 3993 | yu=(_y0+_y1)/2; |
3996 | 3994 | ytext=yu-(GLOBALS->wavefont->ascent/2)+GLOBALS->wavefont->ascent; |
3997 | 3995 | |
3998 | if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid)) | |
3996 | if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white)) | |
3999 | 3997 | { |
4000 | 3998 | Trptr tn = GiveNextTrace(t); |
4001 | 3999 | if((t->flags & TR_ANALOGMASK) && (tn) && (tn->flags & TR_ANALOG_BLANK_STRETCH)) |
4002 | 4000 | { |
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); | |
4009 | 4004 | } |
4010 | 4005 | 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); | |
4023 | 4023 | } |
4024 | 4024 | } |
4025 | 4025 | |
4816 | 4816 | yu=(_y0+_y1)/2; |
4817 | 4817 | ytext=yu-(GLOBALS->wavefont->ascent/2)+GLOBALS->wavefont->ascent; |
4818 | 4818 | |
4819 | if((GLOBALS->display_grid)&&(GLOBALS->enable_horiz_grid)) | |
4819 | if((GLOBALS->highlight_wavewindow) && (t) && (t->flags & TR_HIGHLIGHT) && (!GLOBALS->black_and_white)) | |
4820 | 4820 | { |
4821 | 4821 | Trptr tn = GiveNextTrace(t); |
4822 | 4822 | if((t->flags & TR_ANALOGMASK) && (tn) && (tn->flags & TR_ANALOG_BLANK_STRETCH)) |
4823 | 4823 | { |
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); | |
4830 | 4827 | } |
4831 | 4828 | 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); | |
4844 | 4846 | } |
4845 | 4847 | } |
4846 | 4848 |