Skip to content

Commit 80253d6

Browse files
authored
Merge pull request #309 from krcb197/hidden_instance_bug_fixes
Hidden instance bug fixes
2 parents 46086d0 + 3d337cd commit 80253d6

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/peakrdl_python/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
1818
Variables that describes the peakrdl-python Package
1919
"""
20-
__version__ = "3.1.1"
20+
__version__ = "3.1.2"

src/peakrdl_python/templates/addrmap.py.jinja

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class {{node.python_class_name}}({% if asyncoutput %}Async{% endif %}RegFile):
145145
{{get_table_block(node.instance) | indent}}
146146
"""
147147

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

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

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

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

217-
__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 %}]
217+
__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 %}]
218218

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

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

src/peakrdl_python/templates/addrmap_register.py.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class {{node.python_class_name}}({{node.base_class(asyncoutput)}}):
8282
{{get_table_block(node.instance) | indent}}
8383
"""
8484

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

8787
def __init__(self,
8888
address: int,
@@ -129,12 +129,12 @@ class {{node.python_class_name}}({{node.base_class(asyncoutput)}}):
129129

130130
{% if node.write_only %}
131131
{# if the register has no readable components, all the fields must be writen as one #}
132-
{% 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]
132+
{% 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]
133133
"""
134134
Do a write to the register, updating all fields
135135
"""
136136
reg_value = 0
137-
{%- for child_node in node.instance.fields() %}
137+
{%- for child_node in node.fields() %}
138138
reg_value &= self.{{safe_node_name(child_node)}}.inverse_bitmask
139139
reg_value |= self.{{safe_node_name(child_node)}}._encode_write_value({{safe_node_name(child_node)}})
140140
{% endfor %}

tests/testcases/reserved_elements.rdl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ addrmap reserved_elements {
99
field { fieldwidth=1; } show;
1010
};
1111

12+
reg {
13+
default sw = w;
14+
default hw = r;
15+
field { fieldwidth=1; } RSVD;
16+
field { fieldwidth=1; } field_a;
17+
} write_only_register;
18+
1219
reg {
1320
default sw = rw;
1421
default hw = r;

0 commit comments

Comments
 (0)