Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rdlexporter/src/rdlexporter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 22 additions & 0 deletions rdlexporter/tests/snapshots/arrays.rdl
Original file line number Diff line number Diff line change
@@ -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;

};
12 changes: 12 additions & 0 deletions rdlexporter/tests/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading