amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

GTKW files with signal groups

Open tilk opened this issue 2 years ago • 8 comments

For debugging complex circuits, it's useful to have the signal traces grouped according to their function. The popular gtkwave tool supports this, as does the GTKWSave class from the vcd package used by Amaranth to export VCD files. All that remains is to connect this together.

I have implemented an extension to Amaranth's _VCDWriter which does just that. The idea is that the traces argument can be passed other things than lists of signals. My implementation currently accepts the following as traces:

  • Signals, which work as before.
  • Iterables (e.g. lists) of traces, which shows them in gtkwave one after the other, like before.
  • Mappings (e.g. dicts) of traces, which create a new group of traces for each item in the mapping,
  • Amaranth Records, which group the fields of the record.

There is no support in the current implementation for the recently added lib.data classes from RFC 1, but it can be easily added.

Are you interested in merging this functionality to Amaranth?

tilk avatar Mar 09 '23 09:03 tilk

Let's discuss improvements to VCD and GTKW writing functionality after the next release.

whitequark avatar Mar 09 '23 09:03 whitequark

I'm interested in expanding traces= handling with the following behavior:

  • dict: creates a group per dict key.
  • list or tuple: expands into individual elements recursively.
  • data.View: expands into a group with individual parts, unless a single field, in which case the group is omitted.
  • MemoryData: expands into all rows of the memory (requires #1221).
  • wiring interface objects: expands into a group with individual signals recursively.

Note that I've specified dict and list above because I consider the syntax of tracing to be a mini-DSL where I ascribe new meaning to, specifically, the Python {} and []/() syntax. This allows flexibility for later expansion with other objects, which may also be e.g. iterables.

Is this something you're interested in implementing? I'd be happy to merge that in 0.5, but otherwise I may have to bump it to 0.6.

whitequark avatar Mar 22 '24 02:03 whitequark

I could port the implementation of this feature from Coreblocks, adapting the behavior to stated requirements.

tilk avatar Mar 22 '24 11:03 tilk

Sounds good to me.

whitequark avatar Mar 22 '24 14:03 whitequark

It looks like there is a regression on #790: I can't get view field traces on main. I will try to do a bisect later.

tilk avatar Mar 25 '24 11:03 tilk

I bisected the regression to commit 2bf1b4dafc3a5860e532ae8dac31859c3f9c7089.

tilk avatar Mar 25 '24 12:03 tilk

Yeah, I see the problem, I'm going to do a quick fix soon

wanda-phi avatar Mar 25 '24 13:03 wanda-phi

Fixed in #1237.

wanda-phi avatar Mar 25 '24 13:03 wanda-phi