Should you always keep hierarchical structure when generating code from SystemRDL? #90
Replies: 2 comments 2 replies
-
My approach has always been to preserve hierarchy as much as possible. The hierarchical structure ends up being useful for many consumers of the output, so its nice to avoid flattening at all costs. If I absolutely have to flatten something, I'll still try to preserve the hierarchical name, so I'll usually do this trick: child_identifier = child_node.get_rel_path(top_node, hier_separator="__", array_suffix="_{index:d}") This would result in the hierarchy for field D in your example to flatten to these identifiers:
Kinda ugly, but it helps avoid name collisions. RTLSystemVerilog introduces the concept of structs which are extraordinarily useful for stuff like this. You can nest structs and arrays of structs arbitrarily to create a signal hierarchy that exactly matches your RDL. This is not possible with Verilog-2005 or older, so you'd be forced to flatten hierarchy. UVM RALDefinitely preserve hierarchy here. Not sure why you'd flatten. DocumentationHTML is totally open-ended, so its pretty intuitive to keep the hierarchy. See: https://systemrdl.github.io/PeakRDL-html/ I considered making a PDF generator, but that actually has the opposite problem - you're attempting to render a hierarchical data structure onto a natively flat medium. @muneebullashariff made a really spiffy PDF generator here https://github.com/muneebullashariff/PeakRDL-pdf. This works great for small RDL definitions, but I imagine the generated output gets cumbersome if you have too many layers of hierarchy. C/C++ headersIf you're emitting The alternative is to avoid the defines entirely and have a C/C++ header generator create a nested struct typedef.
|
Beta Was this translation helpful? Give feedback.
-
Oh and for JSON, see my tutorial here for one of many possible solutions: https://systemrdl-compiler.readthedocs.io/en/latest/examples/json_exporter.html |
Beta Was this translation helpful? Give feedback.
-
What are people's thoughts on hierarchical design structure and code generation?
When I read the SystemRDL specification, I understood that there are two hierarchical components, the
addrmap
and theregfile
. Furthermore, I can specify arrays of instances such asaddrmap
,regfile
andreg
. I would prefer to keep the specified hierarchy in the generated code. But does this always make sense? Are there some contexts where unrolling or flattening the design is intuitive?Consider you want to generate code from this small example in the following contexts. How would you translate the hierarchical structure specified?
Beta Was this translation helpful? Give feedback.
All reactions