-
Notifications
You must be signed in to change notification settings - Fork 175
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
Find solution to translate values to strings for Symbiyosys vcd files #254
Comments
Comment by whitequark Even if reading and altering VCD files was in scope for nMigen (which I don't think it is), the pyvcd library we are using does not support reading VCD files. I believe that the appropriate solution for this is altering SymbiYosys such that it would support symbolic mappings, one way or another. |
Comment by RobertBaruch Do the symbolic names carry over from Python to the IL that Symbiyosys uses? |
Comment by whitequark Right now that only happens for the A proper solution for this issue is quite challenging. Your suggestion of post-processing VCD files is actually not that bad, but there is the very real problem that we can't easily implement it. |
Comment by whitequark I've looked closer at what SymbiYosys is doing. I believe there is a solution that is fairly elegant, would benefit everyone in FOSS FPGA community, and would solve 90% of the problem here. That is:
Would you be interested in tackling this? I could provide guidance and/or review of Yosys patches. |
Comment by RobertBaruch I could try. But I wouldn't even start unless I knew such a feature would be accepted into yosys. |
Comment by whitequark I'm confident it would. SystemVerilog features in general are something Yosys is sorely lacking. |
Comment by RobertBaruch It seems like this has been tried several times already: YosysHQ/yosys#248 so I'm hesitant to spend a lot of time on it. |
Comment by mithro @RobertBaruch You could try a Yosys plugin? FYI -- Google also recently released https://github.com/google/verible which is a SystemVerilog parser, linter and code formatter. It does a pretty good job at https://github.com/SymbiFlow/sv-tests but would still need quite a bit of work to hook into Yosys for synthesis. @hzeller is currently looking at what is needed to make that happen. |
Comment by whitequark @RobertBaruch Looks like we can skip doing anything about SystemVerilog then, and only add an attribute. What do you think? |
Comment by RobertBaruch Perhaps a good starting place would be |
Comment by whitequark I've asked Clifford what would be the best approach here, your suggestion vs an attribute. |
Comment by whitequark @RobertBaruch As I expected Clifford thinks this should be done using just attributes. |
Comment by whitequark @RobertBaruch Friendly ping--have you looked into implementing this? |
Comment by RobertBaruch I have some time next week that I can devote to working on this. |
Comment by whitequark Excellent, thanks! |
Comment by RobertBaruch I did find where the traces for cover mode are written (backends/smt2/smtio.py), and where the actual value is written (bv2bin), but that value appears to come from another process, No clue where that is, or whether those values are always assumed to be integers. Thoughts? |
Comment by RobertBaruch (and really, considering Clifford wrote yosys, wouldn't he be in the best position to just solve this in, like, a few minutes?) |
Comment by RobertBaruch I've written up a proposal at YosysHQ/yosys#1594. Hopefully this will start a discussion about the feature, and whether it's even feasible in yosys. |
Comment by whitequark Thanks. |
@RobertBaruch Yosys now has enum support! |
This is no longer gated on upstream since YosysHQ/yosys#1642 was merged. It should be fairly straightforward to add support for RTLIL enum representation to nMigen, but I have a question about the syntax (YosysHQ/yosys#1594 (comment)). |
Proposed new syntax in YosysHQ/yosys#1918. |
The new syntax was accepted. |
And nMigen now translates the attributes. E.g.: import enum
from nmigen import *
from nmigen.back import verilog
class Color(enum.IntEnum):
RED = 1
GREEN = 2
BLUE = 3
color = Signal(Color)
print(verilog.convert(Module(), ports=[color])) /* Generated by Yosys 0.9+2406 (git sha1 88c622b8f, clang 7.0.1-8 -fPIC -Os) */
(* generator = "nMigen" *)
(* top = 1 *)
(* \nmigen.hierarchy = "top" *)
module top(color);
(* enum_base_type = "Color" *)
(* enum_value_01 = "RED" *)
(* enum_value_10 = "GREEN" *)
(* enum_value_11 = "BLUE" *)
(* src = "bug.py:12" *)
input [1:0] color;
endmodule |
Issue by RobertBaruch
Monday Oct 14, 2019 at 14:23 GMT
Originally opened as m-labs/nmigen#254
When dumping the result of covers and counterexamples, Symbiyosys writes
.vcd
files. However, any signals that were enums or FSM states are no longer strings, but just plain old binary.In
gtkwave
, it's possible to select a signal and then Edit > Data Format > Translate Filter File. You can then select a filter file, which is just a map of original value to string value:The configuration can also be saved in a
.gtkw
file. However, this only affects displayed signals. If you delete the signal and display it again, it is not translated. This is horrible.Proposal:
Better might be to just go into the
vcd
file and edit the values. Although it would require an extra step, I wouldn't object to something like this:This would parse the input
vcd
file, replace numeric values with string values for enum and fsm states, and output the result.The text was updated successfully, but these errors were encountered: