New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support FST #1356
Comments
Original Redmine Comment I'm trying to link with libfst.a from GTKWave but autotools is too complicated for me. Steps I've tried:
Now when running make, it tries to link with libfst.a but this file doesn't exist since I don't know how to tell autotools it's a dependency for verilator. I've included the patch for more details. |
Original Redmine Comment Rather than using the shared library are there .h/.cpp files that can be compiled in just as with FXT2? If not, the configure stuff isn't used for post-verilation makefiles, instead do a addLibraryFile call inside Verilator when using FST. Also see the notes on structs just added to "Topic 2601":http://veripool.org/boards/3/topics/2601 |
Original Redmine Comment Thanks, I followed the LXT2 patch and now I have the basic infrastructure for FST setup. Now it's time to use the fstapi. |
Original Redmine Comment Update: I've managed to get a very basic valid FST dump (only dumps bit variables)! Since the FST API supports native SystemVerilog types, I think it's a good moment to start thinking about improving the "declFoo", "chgFoo", etc callback mechanism into some richer one that provides structs, enums, etc definitions. Screenshot: !fst.jpg! |
Original Redmine Comment Here's the initial FST patch, it's just a Proof of concept for now. All the include/fst were copied from GTKWave's SVN, I had to modify fstapi.c to use a custom "fst_config.h" instead of <config.h>. |
Original Redmine Comment Excellent! Your patch didn't show the new fst files (I suspect you forgot to "git add" them), can you attach a new patch when at a good point? I'd suggest we get the FST dumping with old types complete and into trunk, then next step we'll add the new formats. The --trace-fst flag will be sufficient to enable the new API for declarations. For simplicity though I may update the other formats too. verilated.h in VerilatedVarType and VerilatedVarFlags which are currently used for VPI purposes are probably part of what we should pass in. |
Original Redmine Comment Our messages crossed, I see the new files now, seem ok once you obviously extend out the commented code. Please add the appropriate test/*fst files also to match the _lxt2 files. |
Original Redmine Comment I tried to compile pa packed struct example in Icarus Verilog (10.1 included in Ubuntu 18.04), but I only got wires and registers inside the FST file. So I do not think I would be able to use Icarus to generate gold files. I checked GTKWave sources and was not able to find FST examples except for two simple ones. There is some Java code which seems to be FST related, but I did not read it yet. I also think that although GTKWave differentiates between this data types, it might not be able to show the structure. Maybe in the SST window, but not in the Signal and Waveform windows. Professional waveform tools show a structure in the Signal window, where the entire vector value is shown, then the value can be expanded to show its elements and types and values for each element. I do not think GTKWave would be able to show both the value of a structure and its elements. |
Original Redmine Comment Tony Bybell, the author of GTKwave has indicated he's receptive to improvements. Once we have support in Verilator we can work with him to make appropriate improvements to both Verilator and GTKWave to implement whatever extra features make for effective debug. |
Original Redmine Comment I have ported all the supported types of the LXT2 backend to FST and fixed signal aliases since the latest patch. |
Original Redmine Comment Please add the following patch to your set and get the test(s) to pass (test_regress/t/t_trace_fst.pl) The calls in fstapi.cpp need to cast the malloc returns, plus there's probably other stuff. (Once clean, I'll feed this change upstream.) Your patches look good, so once the tests pass I think it's ready to commit if you think so too. |
Original Redmine Comment I've playing around with the fstapi and it's quite useful, for example:
Generates something like:
|
Original Redmine Comment Wilson Snyder wrote:
I'm not sure how to run the tests to be honest, 'make test' gives the following output: https://pastebin.com/raw/pcW3vbDx EDIT: Do you want me to modify fstapi.cpp to make the pointer casts explicit (required by C++)? Although I don't like this idea very much since it's code I've copied from GTKWave and we would have to copy and update it every time GTKWaves changes it instead of copying, I can't think of any other way to silent those warnings. Actually, I had to pass -fpermissive to turn them from errors to warnings. |
Original Redmine Comment Type
Or safer, in case you changed something in the sources,
For more details do a "make info" then see internals.txt in the top level directory. |
Original Redmine Comment Also you should add to your ~/.bashrc or equivalent export VERILATOR_AUTHOR_SITE=1 Then rerun ./configure. Then a "make test" will run every test not just the simple ones, and also warnings will be turned on. |
Original Redmine Comment Wilson Snyder wrote:
test_regress/t/t_trace_fst.pl gives me:
Not sure that's the intended output. I've also tried with VERILATOR_AUTHOR_SITE=1 but it gives the same. Btw I've attached all the patches I've done up to this point (I haven't modified fstapi.cpp to add explicit casts yet, do you want me to do that?, so we can get rid of the warnings and avoid passing -fpermissive). |
Original Redmine Comment Sorry, to test make && test_regress/t/t_trace_fst.pl --vlt Going forward can you please send just a combined patch git diff origin/master...HEAD > combined.patch (This assumes origin/master is the verilator upstream repo. If you're on a branch presumably you know how to modify this.) |
Original Redmine Comment I did push the LTX2 typo fix, thanks. So do a "git pull" before the diff. |
Original Redmine Comment Wilson Snyder wrote:
Now I'm getting tons of errors related to the implicit pointer casts (among other errors). I guess now it's a good point to fix those warnings? Maybe another option would be to compile fstapi using gcc instead of g++. I've also tried including the fstapi.c inside an extern "C" block but g++ spits the same errors. |
Original Redmine Comment Yes, please fix the casts and don't turn off new warnings, nor use non-g++. |
Original Redmine Comment Wilson Snyder wrote:
There are tons of errors, even to things non related to casts such as:
I'll try to fix them as a short-term solution but I think the best would be to make GTKWave install fstapi globally (as libfstapi) along with it, so for example pkg-config would be able to find it. This would not only be useful for Verilator but for all the projects that want to use/use fstapi. Meanwhile this happens (if it ever does), I think we should build libfstapi.a using its own Makefile locally and install it alongside Verilator. Then add addLdLibs("-lfstapi"); to V3Options. |
Original Redmine Comment I've fixed all the errors, now it compiles fine. Now when I run 'make && test_regress/t/t_trace_fst.pl --vlt' I get the following errors (I'll check the outputs and try to figure out what's wrong):
(I renamed all instances of fstvcd to fst2vcd by the way). I also attach the full FST patch. EDIT: After further inspection, I see what's going on: I'm generating SystemVerilog-specific signal types (bit, for instance) and vcddiff only understands regular Verilog types (https://github.com/veripool/vcddiff/blob/master/vcddiff.c#L272). I'll change the FST backend to emit regular Verilog types for now.
|
Original Redmine Comment Great progress, almost there. Does gtkwave provide a diff tool? That would be perfect if so. |
Original Redmine Comment Wilson Snyder wrote:
There's a missing piece, which is making it generate the proper hierarchy (scoping). The name passed to the declXXX functions is a space-separated string containing the full symbol hierarchy up to the new symbol. For the LXT2 backend this is very convenient as you only have to change spaces to '.' and call lxt2_wr_symbol_add. This is trickier for FST because fstWriterSetScope and fstWriterSetUpscope act as a push/pop stack, and if you call SetScope multiple times (given the same name), it creates duplicates, so you have to make sure you create all the vars (fstWriterCreateVar) inside the SetScope/SetUpscope pair. Can I assume that Verilator does that (all the declXXX calls are "in order")? Otherwise handling the current scope gets a bit tricky (list of strings, comparing the list with the new full symbol name, etc). |
Original Redmine Comment They should be in-order. Also I'm thinking we should rename include/fst and include/lxt2 to just include/gtkwave, as more obvious where they come from and then new formats won't need more directories, ok? |
Original Redmine Comment Wilson Snyder wrote:
Sure, I'll move them to include/gtkwave. Implementing the hierarchy in FST is turning out more difficult than expected since I need to know when the variable declarations of the hierarchy are done to be able to call the latest fstWriterSetUpscope. The pseudocode would be like:
|
Original Redmine Comment FYI I moved include/lxt2 to include/gtkwave, please pull. |
Original Redmine Comment Wilson Snyder wrote:
Thanks, pulled! Btw as I said I can't properly finish the FST backend unless we add a way to know when the declarations are done, maybe we could add ->declsStart() and ->declsEnd() callbacks (they would be empty on VCD and LXT2) to be able to close the uppermost context of the hierarchy (needed by FST)? |
Original Redmine Comment The declarations are triggered by the "m_initcb" callback execution. Presently this is called in a loop in VerilatedFst::open(), so you can just add the appropriate start/end calls inside VerilatedFst::open, no Verilator source changes needed. |
Original Redmine Comment Wilson Snyder wrote:
Thanks, that was useful. I think I've managed to get the hierarchy properly working but I don't know why it doesn't pass the test. It might be related to fst2vcd, since it seems like it doesn't output the range ([X:Y]) of buses, for example, the expected output is:
while using FST and then fst2vcd produces:
This makes vcddiff print the following error (it thinks they are two separate signals since the range doesn't match):
I attach my complete FST patch anyways. |
Original Redmine Comment Great, pushed to git plus a few minor changes that GTKwave updated. If you're ready to start on more advanced tracing please open a new bug, and note if you have a proposal for how the Verilator calls should look. |
Original Redmine Comment In 4.004, thanks for your contribution. |
Author Name: Sergi Granell (@xerpi)
Original Redmine Issue: 1356 from https://www.veripool.org
Original Assignee: Sergi Granell (@xerpi)
It seems like this dump format supported by GTKWave would allow to include struct member names and enum names to the dump.
The text was updated successfully, but these errors were encountered: