Skip to content

Static Heterogeneous Arrays #322

@krcb197

Description

@krcb197

Currently, the compiler does not support Heterogeneous created with a dynamic property assignment.

Consider the following code:

addrmap heterogeneous_array {

     reg reg_def {
        field { fieldwidth=4; } field_a;
        field { fieldwidth=4; } field_b;
        field { fieldwidth=4; } field_c;
        field { fieldwidth=4; } field_d;
     };

     reg_def reg_array[2];
     // reg_array[0].field_a->name = "Field A in Register Instance";

};

This will fail with a compiler error:

tests\testcases\heterogeneous_array.rdl:27:15: fatal: Use of array suffixes in dynamic property assignments is not supported
     reg_array[0].field_a->name = "Field A in Register Instance";
              ^^^

I know there is some separate discussion about this on #51

I have managed to create a Heterogeneous Array in a different way:

property register_child_pointer {
    type = field[];
    component = reg;
};

addrmap heterogeneous_array_udp {

     reg reg_def {
        field { fieldwidth=4; } field_a;
        field { fieldwidth=4; } field_b;
        field { fieldwidth=4; } field_c;
        field { fieldwidth=4; } field_d;
        register_child_pointer = '{ field_a, field_b, field_c, field_d } ;
     };

     reg_def reg_array[2];
};

The following script demonstrates that the compiler has behaved correctly:

from pathlib import Path

from systemrdl import RDLCompiler

if __name__ == '__main__':
    rdl_path = Path(r'tests\testcases\heterogeneous_array.rdl')
    top_node = 'heterogeneous_array_udp'
    rdlc = RDLCompiler()
    rdlc.compile_file(rdl_path)
    spec = rdlc.elaborate(top_def_name=top_node).top

    reg_array_elements = list(spec.children(unroll=True))

    print(reg_array_elements[0].get_property('register_child_pointer'))
    print(reg_array_elements[1].get_property('register_child_pointer'))

This is causing an issue: the peakrdl-python Python wrapper generator currently assumes that an array can be modelled as a Python class. Is there a way to determine that the reg_array is not homogeneous, without walking the whole structure and checking the properties of interest?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions