Skip to content

Commit

Permalink
fix(csrs): Support ungrouped CSRs
Browse files Browse the repository at this point in the history
Related to issue IObundle#83
  • Loading branch information
arturum1 committed Nov 25, 2024
1 parent 554b140 commit 956331f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions py2hwsw/lib/hardware/iob_csrs/iob_csrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def setup(py_params_dict):
"snippets": [],
}

params["csrs"] = create_group_for_ungrouped_csrs(params["csrs"])
find_and_update_interrupt_csrs(params["csrs"])
find_and_update_fifo_csrs(params["csrs"], attributes_dict)

Expand Down Expand Up @@ -147,3 +148,26 @@ def setup(py_params_dict):
attributes_dict["confs"][0]["val"] = csr_gen_obj.core_addr_w

return attributes_dict


def create_group_for_ungrouped_csrs(csrs):
general_group = {
"name": "general_operation",
"descr": "General Registers.",
"regs": [],
}
grouped_csrs = []
for csr in csrs:
# Check if csr is already a group
if "csrs" in csr:
grouped_csrs.append(csr)
continue

# Append csr to general group
general_group["regs"].append(csr)

# Append general group if it has any registers
if general_group["regs"]:
grouped_csrs.append(general_group)

return grouped_csrs
4 changes: 3 additions & 1 deletion py2hwsw/scripts/iob_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def create_block_group(core, *args, **kwargs):
block_group = iob_block_group(blocks=block_obj_list, **group_kwargs)
core.blocks.append(block_group)
except Exception:
add_traceback_msg(f"Failed to create block/group '{kwargs['name']}'.")
add_traceback_msg(
f"Failed to create block/group '{kwargs.get('name',None) or kwargs.get('core_name',None)}'."
)
raise


Expand Down

0 comments on commit 956331f

Please sign in to comment.