Skip to content

Array index reset - #334

Open
davekeeshan wants to merge 3 commits into
SystemRDL:mainfrom
daxzio:array_index_reset
Open

Array index reset#334
davekeeshan wants to merge 3 commits into
SystemRDL:mainfrom
daxzio:array_index_reset

Conversation

@davekeeshan

Copy link
Copy Markdown

Summary

I raised this as a possibility in the comment thread of #51, but there was no feedback, I figured I open a PR so we can address it properly. I have made this change locally and it is working for my team

Adds limited support for heterogeneous instance arrays via indexed dynamic property assignments (DPAs), addressing the use case in #51 Support for heterogeneous-arrays.:

Example:

GPIO_INSTANCE GPIO[4];
GPIO[0].CFG.CFG->reset = CFG_DEFAULT_3;
GPIO[3].CFG.CFG->reset = gpio_enum::PLL_BYPASS;

Support is intentionally limited to the reset property only. Other properties, array sub-ranges, and references that index more than one array in the same path remain unsupported.

Implementation

Indexed DPAs that target a single array element create a per-element component override in AddressableComponent.array_element_overrides. Elements without an override continue to share the array's component tree, preserving structural identity (size, addressing, field layout).

  • Parse/elaborate: resolve array indices and create element overrides; defer bounds checking when array dimensions are not yet known (parameterized arrays)
  • Elaboration: evaluate expressions, sync structure/addresses (including nested reg arrays), and propagate array metadata to overrides
  • Validation: validate override subtrees so invalid reset values are rejected consistently with whole-array assignments
  • Node API: consistent is_array, addressing, and path behaviour for unrolled elements; extended DPA type names on override subtrees (e.g. CFG_reset_b vs CFG_reset_a)
  • DPA ordering: propagate subsequent whole-array DPAs into existing element overrides

Limitations

  • Only reset may be assigned via an indexed DPA reference
  • Only one array index per reference path (e.g. rf[0].r1[1].f->reset is rejected)
  • Array sub-ranges (my_inst[1:4]) are not supported

Documentation

Updates docs/known_issues.rst and docs/dev_notes/instance_arrays.rst to describe the supported subset and internal representation.

Test plan

  • test/test_dpas.py — indexed reset on regfile arrays, reg arrays, parameterized dimensions, whole-array DPA propagation, type-name differentiation, array API consistency
  • Error cases: non-reset property, OOB index, multi-array path, dimension mismatch, invalid reset width

Partially addresses #51 (reset-only heterogeneous arrays).

davekeeshan and others added 3 commits June 11, 2026 14:06
…ues.

Complete elaboration, validation, and node API support for heterogeneous
array element overrides so indexed reset DPAs work on reg arrays,
parameterized dimensions, and downstream type-name generation (SystemRDL#51).

Co-authored-by: Cursor <cursoragent@cursor.com>
Add _copy_for_array_element() with an explicit opt-out from copying
sibling override dicts, preserving array metadata for path and address
resolution. Add a 32-element regression test.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant