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 src/peakrdl_python/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

Variables that describes the peakrdl-python Package
"""
__version__ = "3.1.1"
__version__ = "3.1.2"
8 changes: 4 additions & 4 deletions src/peakrdl_python/templates/addrmap.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class {{node.python_class_name}}({% if asyncoutput %}Async{% endif %}RegFile):
{{get_table_block(node.instance) | indent}}
"""

__slots__ : list[str] = [{%- for child_node in node.instance.children(unroll=False) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{%- endfor %}]
__slots__ : list[str] = [{%- for child_node in node.children(unroll=False) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{%- endfor %}]

def __init__(self,
address: int,
Expand All @@ -159,7 +159,7 @@ class {{node.python_class_name}}({% if asyncoutput %}Async{% endif %}RegFile):
parent=parent)

# instance of objects within the class
{% for child_node in node.instance.children(unroll=False) -%}
{% for child_node in node.children(unroll=False) -%}
{{ regfile_or_addr_instance(child_node) | indent }}
{% endfor %}

Expand Down Expand Up @@ -214,7 +214,7 @@ class {{node.python_class_name}}({% if asyncoutput %}Async{% endif %}AddressMap)
{{get_table_block(node.instance) | indent}}
"""

__slots__ : list[str] = [{%- for child_node in node.instance.children(unroll=False) -%}{%- if isinstance(child_node, systemrdlRegNode) or isinstance(child_node, systemrdlRegfileNode) or isinstance(child_node, systemrdlAddrmapNode) or isinstance(child_node, systemrdlMemNode) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{% endif %}{%- endfor %}]
__slots__ : list[str] = [{%- for child_node in node.children(unroll=False) -%}{%- if isinstance(child_node, systemrdlRegNode) or isinstance(child_node, systemrdlRegfileNode) or isinstance(child_node, systemrdlAddrmapNode) or isinstance(child_node, systemrdlMemNode) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{% endif %}{%- endfor %}]

def __init__(self, *,
address:int {%- if node.instance == top_node -%}={{top_node.absolute_address}}{%- endif -%},
Expand All @@ -233,7 +233,7 @@ class {{node.python_class_name}}({% if asyncoutput %}Async{% endif %}AddressMap)
inst_name=inst_name,
parent=parent)

{% for child_node in node.instance.children(unroll=False) -%}
{% for child_node in node.children(unroll=False) -%}
{{ regfile_or_addr_instance(child_node) | indent }}
{% endfor %}

Expand Down
6 changes: 3 additions & 3 deletions src/peakrdl_python/templates/addrmap_register.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class {{node.python_class_name}}({{node.base_class(asyncoutput)}}):
{{get_table_block(node.instance) | indent}}
"""

__slots__ : list[str] = [{%- for child_node in node.instance.children(unroll=False) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{%- endfor %}]
__slots__ : list[str] = [{%- for child_node in node.children(unroll=False) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{%- endfor %}]

def __init__(self,
address: int,
Expand Down Expand Up @@ -129,12 +129,12 @@ class {{node.python_class_name}}({{node.base_class(asyncoutput)}}):

{% if node.write_only %}
{# if the register has no readable components, all the fields must be writen as one #}
{% if asyncoutput %}async {% endif %}def write_fields(self, {%- for child_node in node.instance.fields() -%} {{safe_node_name(child_node)}} : {{node.lookup_field_data_python_class(child_node)}}{%- if not loop.last -%},{%- endif -%}{%- endfor -%}) -> None: # type: ignore[override]
{% if asyncoutput %}async {% endif %}def write_fields(self, {%- for child_node in node.fields() -%} {{safe_node_name(child_node)}} : {{node.lookup_field_data_python_class(child_node)}}{%- if not loop.last -%},{%- endif -%}{%- endfor -%}) -> None: # type: ignore[override]
"""
Do a write to the register, updating all fields
"""
reg_value = 0
{%- for child_node in node.instance.fields() %}
{%- for child_node in node.fields() %}
reg_value &= self.{{safe_node_name(child_node)}}.inverse_bitmask
reg_value |= self.{{safe_node_name(child_node)}}._encode_write_value({{safe_node_name(child_node)}})
{% endfor %}
Expand Down
7 changes: 7 additions & 0 deletions tests/testcases/reserved_elements.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ addrmap reserved_elements {
field { fieldwidth=1; } show;
};

reg {
default sw = w;
default hw = r;
field { fieldwidth=1; } RSVD;
field { fieldwidth=1; } field_a;
} write_only_register;

reg {
default sw = rw;
default hw = r;
Expand Down
Loading