SystemRDL / systemrdl-compiler

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

Enum parsing #130

Closed markcohen32 closed 2 years ago

markcohen32 commented 2 years ago

Hi,

I've been trying recently to import ipxact files that contain enums. I get the following error: "names are reserved for future Enum use" I've tried Python 3.6 & Python 3.9. Is it an issue related to the importer?

amykyta3 commented 2 years ago

Interesting I suspect your IP-XACT file contains enumeration names have an underscore prefix & suffix like: _something_

Internally, the RDL compiler will cast imported enumerations into a Python Enum object. It looks like Python's implementation of enumerations imposes some restrictions on what enum member names can be used so that they do not collide with the built-in (and future) "sunder names": https://docs.python.org/3/library/enum.html#supported-sunder-names

I'll have to think about what the proper fix for this is. For now, I'd recommend editing the IP-XACT file and editing the names that have leading & trailing suffixes.

I will move this issue to the systemrdl-compiler project since the fix will ultimately be there.

tsyw commented 2 years ago

Found this bug two.

markcohen32 commented 2 years ago

Hi, is there an update regarding this bug?

amykyta3 commented 2 years ago

Was on vacation. Will look into it more now that I am back

markcohen32 commented 2 years ago

Hi, any new? :)

amykyta3 commented 2 years ago

I have a plan on how to fix this, but it is more intrusive than I had hoped. The plan is to migrate away from the use of Python's Enum objects to represent user-defined enumerations. This would address this issue, as well as other quirks that result from this (inability to pickle register models). Instead of Enum classes, RDL enumerated types would be represented by more specialized class instances. A similar change would be done for RDL struct representations, but i expect they are less often used.

The biggest challenge is that I need to build a migration path that is not intrusive to the community and do my best to not break compatibility with current usages. I have a general plan for this, but still need to think through some details.

amykyta3 commented 2 years ago

See planned rework details in #132. (changed my mind. fixing a different way) I hope to get this fixed in the next few weeks.

amykyta3 commented 2 years ago

Fixed in v1.24.0