From 65fe418dcc329320ffd093b74c0ae97444718130 Mon Sep 17 00:00:00 2001 From: Harry Callahan Date: Wed, 2 Sep 2026 16:14:21 +0100 Subject: [PATCH 1/2] [rdlexporter] Fix register export on systemrdl-compiler 1.32.2 `RdlExporter._arrays` tested `component.is_array`, but that attribute was removed from the raw *Component* layer in systemrdl-compiler 1.32.2 by commit 25748b96c227 ("Remove .is_array from internal Component layer as it can be trivially derived"). The change is not called out in the 1.32.2 release notes, but its docstring documented `is_array` as simply meaning "``array_dimensions`` and ``array_stride`` are valid". Up to 1.32.1 the exporter relied on `is_array` being present on the Component objects it walks (`rdlc.root.comp_defs`); on 1.32.2, exporting any block with registers raises: AttributeError: 'Reg' object has no attribute 'is_array' The dependency is declared as `systemrdl-compiler~=1.32.1`, so a fresh resolve already picks up the broken 1.32.2. Derive array-ness from `array_dimensions` instead, exactly as upstream intends: it is None for non-array components. Signed-off-by: Harry Callahan --- rdlexporter/src/rdlexporter/exporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdlexporter/src/rdlexporter/exporter.py b/rdlexporter/src/rdlexporter/exporter.py index 6502e0c..de3add4 100644 --- a/rdlexporter/src/rdlexporter/exporter.py +++ b/rdlexporter/src/rdlexporter/exporter.py @@ -131,7 +131,7 @@ def _emit_property(self, properties: dict, assign_op: str = "=", endline: str = print(f"Warning: Type {type(obj)} not implemented, skipping it.") def _arrays(self, component: Reg) -> str: - if not component.is_array: + if component.array_dimensions is None: return "" if len(component.array_dimensions) > 1: From 2041398a248ef31788ab820404516287c0d4f509 Mon Sep 17 00:00:00 2001 From: Harry Callahan Date: Wed, 2 Sep 2026 16:14:21 +0100 Subject: [PATCH 2/2] [rdlexporter] Add register array export regression test Add `test_cli_arrays_from_file`, a focused round-trip snapshot covering both branches of `RdlExporter._arrays`: a plain register (`CTRL`) and a register array (`DATA[4]`). This guards the `is_array` regression fixed in the previous commit, which is functional across old and new versions of systemrdl-compiler. Signed-off-by: Harry Callahan --- rdlexporter/tests/snapshots/arrays.rdl | 22 ++++++++++++++++++++++ rdlexporter/tests/test_exporter.py | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 rdlexporter/tests/snapshots/arrays.rdl diff --git a/rdlexporter/tests/snapshots/arrays.rdl b/rdlexporter/tests/snapshots/arrays.rdl new file mode 100644 index 0000000..9525406 --- /dev/null +++ b/rdlexporter/tests/snapshots/arrays.rdl @@ -0,0 +1,22 @@ +`include "user_defined.rdl" + +addrmap arrays { + reg { + field { + desc = "Enable the block."; + sw = rw; + hw = r; + reset = 0x0; + } EN[0:0]; + } CTRL @ 0x0; + + reg { + field { + desc = "Data word."; + sw = rw; + hw = r; + reset = 0x0; + } VAL[31:0]; + } DATA[4] @ 0x4; + +}; diff --git a/rdlexporter/tests/test_exporter.py b/rdlexporter/tests/test_exporter.py index 42a73e9..dd96469 100644 --- a/rdlexporter/tests/test_exporter.py +++ b/rdlexporter/tests/test_exporter.py @@ -51,6 +51,18 @@ def test_cli_lc_ctrl_from_file(tmp_path: Path) -> None: _run_ip_test_from_file(tmp_path, "lc_ctrl") +def test_cli_arrays_from_file(tmp_path: Path) -> None: + """Regression test for register array export. + + Covers both branches of ``RdlExporter._arrays``: a plain register (``CTRL``) + and a register array (``DATA[4]``). Guards against relying on attributes that + only exist on elaborated ``Node`` objects (e.g. ``is_array``, removed from raw + ``Component`` objects in systemrdl-compiler 1.32.2) rather than ``Component`` + ones (``array_dimensions``). + """ + _run_ip_test_from_file(tmp_path, "arrays") + + def test_importer(tmp_path: Path) -> None: """Test with the SystemRDL importer.""" input_rdl = SNAPSHOTS_DIR / "generic.rdl"