Open morrowsend opened 4 years ago
Thanks for this pull request.
I thought a bit more about this, and felt that it would be better to not store the VCD data multiple times in the object by default. Sorry if this is not what we had discussed previously.
So I updated the API to expose a streaming/callback version of things, which should allow you to achieve what you want. Can you double check the examples at PrintDeltasStreamParserCallbacks and PrintDumpsStreamParserCallbacks? https://github.com/cirosantilli/vcdvcd/blob/13735291e2fb6a7482ca51673c238d359b0444c6/vcdvcd/vcdvcd.py#L270
You can then just create your own class based on them to achieve your goals. Let me know if this solves your use case.
I am not a great python coder, so I implemented what was the simplest possible solution with my given skillset. I'm trying to make a simple GUI to simulate SIMPLE VHDL code graphically. I'm not writing a simulator because they already exist. I just want to make it graphically display outputs on LEDs given a set of inputs the user clicks on as the inputs. This can be used for folks without access to hardware due to quarantine.
Users generate a VCD for waveform generation already, but the graphical GUI will make understanding what's going on in the code more intuitive. When I say your original print_dumps result, I visualized what I thought the best way to do it would be. My thought was to take the results given by my implementation of vcdvcd's dumps. I returned them as a list of signal names (sorted and numbered) then a list of the list of data. I planned to get the index of the signal name from the first list, then use that to seek out what the corresponding outputs would have been in the list of lists of the signals. With the new implementation, I don't know how to visualize a solution. Does that make sense? Do you have a any suggestions?
EDIT: Thinking further, I could make a dict with all the inputs as keys to quickly return the output values, then use those to set/clear LEDs on the GUI.
I understand, learning new technologies is hard for everyone.
Note that the new setup is very similar to the old one, just slightly cleaner.
If you copy either PrintDeltasStreamParserCallbacks
or PrintDumpsStreamParserCallbacks
on your own class, and print the fields they use more explicitly key=value
, it should be easy to figure out what you need to add to a map created on the __init__
method of your class to achieve the exact data you want.
Ok, great. I'll do that once I flesh out a more complete implementation of all my I/Os on the GUI and test for more complicated VCD files. I currently have a minimal implementation working enough to do some tests for the remaining I/Os at least. Since time is of the essence on certain features (only a couple of weeks before I need something working at this point) I really need to get them implemented, then I can integrate the PrintDumpsStreamParserCallbacks
. When I was looking at the exampl.py I thought it printed only the times that signal changes occurred instead of the full table of signals all timestamped. Given shortness on time I didn't investigate too much.
I'm mostly used to C and Java and so it isn't all too different but certain syntax things have tripped me up. Once I realized dict is like a hashMap in Java the rest of the project fell into place after my last reply. Like I said it is far from ready for prime time, but at least I am twiddling switched and LEDs are flashing based on the VCD file at the moment. Once I get a bit further along with it, I'll make it public and you can see what a hack I am at python : )
BTW, I changed the interface a bit on https://github.com/cirosantilli/vcdvcd/commit/ba56abd7119b7e28329c6608724c357153bc9025 (2.0.0 release), now you have to do vcd.data['signalname'].tv
instead of vcd.data['signalname']['tv']
to allow nice random access to signals: https://github.com/cirosantilli/vcdvcd/#api-usage
As discussed in an issue, I refactored the code to return the sorted list of signals and the corresponding values of all the signals in that same sorted order. You can still use the print_dumps tag to have vcdvcd automatically print to the console if needed. I modified the version number in setup.py but did not try to push as described in your release procedure.