Skip to content

Commit 5f11be0

Browse files
committed
Added support for regfiles and child addrmap to the pathological test
1 parent a1e9b21 commit 5f11be0

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

tests/pathological_register_maps/pathalogical_rdl_builder.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ def registers(self):
7171
yield PathologicalRegisterInstance(name=next(reg_name),
7272
name_prefix=self.child_prefix)
7373

74+
@dataclass
75+
class _PathologicalInstanceWithRegistersAndRegFiles(_PathologicalInstanceWithRegisters):
76+
77+
regfile_recursion_depth: int = 2
78+
79+
@property
80+
def register_files(self):
81+
"""
82+
A generator to make a random set of register files
83+
"""
84+
name = name_generator()
85+
reg_file_instances = random.randint(0, self.regfile_recursion_depth)
86+
for _ in range(reg_file_instances):
87+
yield PathologicalRegFileInstance(name=next(name),
88+
name_prefix=self.child_prefix,
89+
regfile_recursion_depth=self.regfile_recursion_depth-1)
90+
91+
@dataclass
92+
class PathologicalRegFileInstance(_PathologicalInstanceWithRegistersAndRegFiles):
93+
...
94+
7495
@dataclass
7596
class PathologicalFieldEncodingEntry:
7697
value: int
@@ -125,7 +146,20 @@ class PathologicalMemoryInstance(_PathologicalInstanceWithRegisters):
125146

126147

127148
@dataclass
128-
class PathologicalAddrmapInstance(_PathologicalInstanceWithRegisters):
149+
class PathologicalAddrmapInstance(_PathologicalInstanceWithRegistersAndRegFiles):
150+
addrmap_recursion_depth: int = 1
151+
152+
@property
153+
def addrmaps(self):
154+
"""
155+
A generator to make a random set of addrmaps
156+
"""
157+
name = name_generator()
158+
reg_file_instances = random.randint(0, self.addrmap_recursion_depth)
159+
for _ in range(reg_file_instances):
160+
yield PathologicalAddrmapInstance(name=next(name),
161+
name_prefix=self.child_prefix,
162+
addrmap_recursion_depth=self.addrmap_recursion_depth - 1)
129163

130164
@property
131165
def memories(self):

tests/pathological_register_maps/templates/pathological_template.rdl.jinja

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
} mem_{{memory.name_prefix}}_{{memory.name}};
3636
{% endmacro %}
3737

38+
{% macro regfile_definition(regfile) %}
39+
regfile {
40+
name = "{{regfile.name}}";
41+
desc = "{{regfile.name_prefix}}_{{regfile.name}} description";
42+
43+
{% for register in regfile.registers %}
44+
{{ register_definition(register) | indent(4) }}
45+
{% endfor %}
46+
47+
{% for child_regfile in regfile.register_files %}
48+
{{ regfile_definition(child_regfile) | indent(4) }}
49+
{% endfor %}
50+
51+
} regfile_{{regfile.name_prefix}}_{{regfile.name}};
52+
{% endmacro %}
53+
3854
{% macro addmap_defintion(addrmap) %}
3955
addrmap {
4056
{% for register in addrmap.registers %}
@@ -45,6 +61,14 @@
4561
{{ memory_definition(memory) | indent(4) }}
4662
{% endfor %}
4763

64+
{% for regfile in addrmap.register_files %}
65+
{{ regfile_definition(regfile) | indent(4) }}
66+
{% endfor %}
67+
68+
{% for child_addrmap in addrmap.addrmaps %}
69+
{{ addmap_defintion(child_addrmap) | indent(4) }}
70+
{% endfor %}
71+
4872
} addrmap_{{addrmap.name_prefix}}_{{addrmap.name}};
4973
{% endmacro %}
5074

0 commit comments

Comments
 (0)