Issue #1358

Improve FST support to show enums

Currently, the FST we generate is very limited (basically wires and one kind of scope). As FST actually supports SystermVerilog and VCD types and all kinds of scopes (such as module, package, struct, interface, etc), it would be nice to improve the FST support to make it generate these types.
It looks like this would requiere a major refactoring of the "declFoo" call dumping routines since fstapi needs more info than the currently passed on the current dumping functions parameters.

Some generic pseudo C++ code that would visit all the hierarchy and emit FST would look like:

Ok, for signals, I propose I'll make the decl calls pass the right information. Can you then hook them up to the FST internal library?

For enums can you describe what FST wants?

Enums are a bit more tricky as you can see here: https://sourceforge.net/p/gtkwave/mailman/message/36430944/

If I understand the code correctly (https://github.com/nickg/nvc/blob/master/src/rt/fst.c), what Nick Gasson did is to set the enum variable as an string, and then use FST_VT_GEN_STRING + fstWriterEmitVariableLengthValueChange to change the string value. I guess the trick would be to emit a const lookup table from enum value to its name as an string (ENUM_FOO -> "ENUM_FOO").

I think a good idea would be to add an option to Verilator such as "--fst-emit-enum-names" that toggles between emitting the raw value or the string value. This shouldn't be a lot of trouble to implement when we have the basic infrastructure for the improved FST done.

As to enums, keeping this bug open and on hold until GTKwave upstream's FST format gets the appropriate features to indicate enum information. This is in progress.

Nice! Now it would be really useful if we could add struct support. I think it should be relatively easy: Add a "declStructStart(name?);" then all the "declFoo" called after this function mean that they are inside the struct, and to close the struct add a "declStructEnd()" callback.