llvm / circt

Circuit IR Compilers and Tools
https://circt.org
Other
1.57k stars 277 forks source link

[DebugInfo][HGLDD] Consuming Tywaves annotations containing extra source language information from Chisel and improve HGLDD format #7246

Open rameloni opened 6 days ago

rameloni commented 6 days ago

This PR adds new functionality to CIRCT for emitting source language type information in HGLDD https://github.com/llvm/circt/issues/6983.

This new functionality support the new backend of my project. Tywaves: a type-based waveform viewer. Tywaves adds support for Chisel to Surfer through HGLDD, however it misses of Chisel-type information and a proper documentation.

So, in addition to the changes I made to CIRCT, I also created a library for reading and documenting HGLDD in rust. I noticed that HGLDD misses a formal specification, so the rust documentation is a first attempt to provide more formal description of the fields contained in the file.

Specific contribution to CIRCT

rameloni commented 6 days ago

The related PR in chisel: https://github.com/chipsalliance/chisel/pull/4224

darthscsi commented 1 day ago

Some general comments: We are trying very hard to not add new annotations. I thought the current debug efforts were grabbing chisel types and only falling back to firrtl types if asked. It might be this isn't done yet, in which case the efforts should be coordinated. @fabianschuiki or @prithayan might be able to shed more light.

rameloni commented 1 day ago

Some general comments: We are trying very hard to not add new annotations. I thought the current debug efforts were grabbing chisel types and only falling back to firrtl types if asked. It might be this isn't done yet, in which case the efforts should be coordinated. @fabianschuiki or @prithayan might be able to shed more light.

@darthscsi thanks for the comment. Yeah, I found that Intrinsics might be a better option to do that. However, I'm not sure if I can make it before the deadline of my thesis. That's why I'm using at the moment the annotations, since I've found they were slightly easier to manage on average between Chisel and CIRCT sides

rameloni commented 6 hours ago

I have also noticed another thing. HGLDD also missed reference to enum variants, so I'm trying to add that. I've seen that the hw dialect has a definition of EnumType however it seems not to be generated?!? I'm not sure, am I wrong? Chisel passes the enum variants through 3 annotations (EnumComponentAnnotation, EnumDefAnnotation, and EnumVecAnnotation) but they are dropped in the LowerAnnotations pass, is there a reason for that? Apart from the fact you are trying to replace the annotation mechanism.