SystemRDL / systemrdl-compiler

SystemRDL 2.0 language compiler front-end
http://systemrdl-compiler.readthedocs.io
MIT License
232 stars 68 forks source link

Set abbreviated Node.type_name for long parameterized types #198

Open erang20 opened 9 months ago

erang20 commented 9 months ago

RDL parameterized types translate to Node.type that contains the list of parameters and their values. For example:

regfile some_regfile #(
    longint unsigned PARAM_A,
    longint unsigned PARAM_B,
) {
...
}

Might be instantiated as a Node with type_name = some_regfile_PARAM_A_200_PARAM_B_300

The list of parameters might be very long in some cases, so it would be helpful to add an option (e.g. max_node_type_param_lengh to abbreviate a long parameters list to a 32 bit hash hex, e.g. some_regfile_2d8fa187 instead of a very long type name.

amykyta3 commented 9 months ago

Agree that type names can get pretty absurdly verbose. I have been noticing the same in some of the designs I have been involved in.

The current type name generation is actually according to what the SystemRDL spec defines (Section 5.1.1.4). I also extended the semantics for this to cover dynamic assignments.

I was actually thinking of addressing this in a similar way you suggested - to provide an option to generate shortened hashed type names. This is important since some languages that PeakRDL exports to may have a character limit on identifiers that is quite easy to reach with this behavior.

Since this is something that would be changed in the compiler, I will migrate this issue there.