Make working with packed objects easier #3857
Labels
category:codebase:handle
relating to handles or handle types (BinaryValue)
type:feature
new or enhanced functionality
Based on #3608 where I realized that we really shouldn't be indexing into packed object (this includes packed structs), and that there are multi-dimensional packed objects (such as arrays of structs) where accessing fields in the packed object is currently quite obtuse. One way to resolve that is to introduce a some types to make this easier. This should work with the existing
LogicArray
object.One possible UI is by creating something similar to
dataclass
. There would be a class decorator that would create an object that maps to a packed struct in SystemVerilog by using type annotations to describe the structure.This does not necessary need to reuse
LogicArray
for the description. But it would need to be able to be constructed fromLogicArray
and converted back to it.In addition simply describing the fields, supporting methods would be ideal, but non-"packable" attributes and custom
__init__
s would not be supported. We can support overriding generated methods by making the result type the child type of the implementation base class and the given type, so thatsuper()
resolves to the implementation base class. I think this would end up requiring a metaclass approach to make mypy happy.This would support field access, individual bit access, and everything else.
This will require a series of "view" objects that maintain a reference to the underlying value and the current partially-applied indexing value.
The text was updated successfully, but these errors were encountered: