Skip to content

Commit 55a5cad

Browse files
authored
Merge pull request #253 from krcb197/release/3.0.0
Release/3.0.0
2 parents 5dd0505 + 8838329 commit 55a5cad

43 files changed

Lines changed: 3920 additions & 1759 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/action.yaml

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,42 @@ jobs:
134134
run: |
135135
136136
python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test
137+
sleep 10
137138
python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test --async
139+
sleep 10
138140
139141
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map
142+
sleep 10
140143
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --legacy_block_access
144+
sleep 10
141145
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --legacy_enum_type
146+
sleep 10
142147
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --copy_libraries
148+
sleep 10
143149
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --hashing_mode PYTHONHASH
150+
sleep 10
144151
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --hashing_mode SHA256
152+
sleep 10
145153
146154
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include
155+
sleep 10
147156
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include
157+
sleep 10
148158
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include
159+
sleep 10
149160
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include str_property_to_include
161+
sleep 10
150162
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include str_property_to_include struct_property_to_include double_layer_struct_property_to_include
163+
sleep 10
151164
152165
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp_regex "bool_property_to_include|enum_property_to_include|int_property_to_include|str_property_to_include|struct_property_to_include|double_layer_struct_property_to_include"
166+
sleep 10
153167
154168
python -m generate_and_test --RDL_source_file tests/testcases/reserved_elements.rdl --root_node reserved_elements --hide_regex "(?:[\w_\[\]]+\.)+RSVD"
169+
sleep 10
155170
156171
python -m generate_and_test --RDL_source_file tests/testcases/name_desc_all_levels.rdl --root_node name_desc_all_levels --skip_systemrdl_name_and_desc_properties
172+
sleep 10
157173
158174
peakrdl_integration:
159175
needs:
@@ -323,7 +339,6 @@ jobs:
323339
matrix:
324340
python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
325341
lib_copy: [true, false]
326-
hashing_mode: ["PYTHONHASH", "SHA256"]
327342

328343
steps:
329344
- uses: actions/checkout@v4
@@ -349,12 +364,12 @@ jobs:
349364
- name: Generate testcases (lib_copy true)
350365
if: matrix.lib_copy == true
351366
run: |
352-
python generate_testcases.py --copy_libraries --output testcase_output --hashing_mode ${{ matrix.hashing_mode }}
367+
python generate_testcases.py --copy_libraries --output testcase_output
353368
354369
- name: Generate testcases (lib_copy false)
355370
if: matrix.lib_copy == false
356371
run: |
357-
python generate_testcases.py --output testcase_output --hashing_mode ${{ matrix.hashing_mode }}
372+
python generate_testcases.py --output testcase_output
358373
359374
- name: Static checks
360375
run: |
@@ -410,10 +425,47 @@ jobs:
410425
mypy autoformatted_output
411426
python -m unittest discover -s autoformatted_output
412427
428+
pathological:
429+
430+
needs:
431+
- integration_tests
432+
433+
runs-on: ubuntu-latest
434+
435+
steps:
436+
- uses: actions/checkout@v4
437+
- name: Set up Python
438+
uses: actions/setup-python@v5
439+
with:
440+
python-version: "3.13"
441+
442+
- name: Install dependencies
443+
run: |
444+
python -m pip install --upgrade pip
445+
python -m pip install .[peakrdl]
446+
python -m pip install mypy
447+
448+
- name: Prepare System RDL
449+
run: |
450+
mkdir ./pathological_test
451+
python -m tests.pathological_register_maps.pathological_rdl_builder ./pathological_test/deep.rdl deep
452+
453+
- name: build_package
454+
run: |
455+
peakrdl python ./pathological_test/deep.rdl -o ./pathological_test/ --skip_library_copy
456+
457+
- name: type check generated code
458+
run: |
459+
mypy ./pathological_test/deep/
460+
461+
- name: Run unit tests
462+
run: python -m unittest discover -s ./pathological_test/
463+
413464
#-------------------------------------------------------------------------------
414465
build:
415466
needs:
416467
- autoformating
468+
- pathological
417469

418470
name: Build source distribution
419471
runs-on: ubuntu-latest

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ assumes that peakrdl has been installed.
7575
To make use of the RAL with real hardware or a different simulation, the callbacks will need to be
7676
connected to the appropriate access function in order to perform an address space reads and writes
7777

78-
# Upgrading from previous versions (some important changes)
78+
# Some important changes
7979

80-
## Upgrading from pre 0.9.0
80+
## 0.9.0
8181

8282
In order to address a major limitation of peakrdl-python that prevented it from implementing the
8383
full systemRDL specification, a breaking API change was needed for handling blocks:
@@ -88,15 +88,15 @@ Users are encouraged to upgrade in order to avoid this limitation. However, ther
8888
to support users with existing designs, see: _Legacy Block Callback and Block Access_ in the
8989
documentation
9090

91-
## Upgrading from pre 1.2.0
91+
## 1.2.0
9292

9393
Version 1.2 introduced a new way to define the enumerations for the field encoding. This allows
9494
metadata from the systemRDL to propagate through to the generated code. This may break advanced
9595
usage of the python enumerations. User are encouraged to use the new feature, however, if there
9696
are problems with the old enumeration types (based on `IntEnum`) can be used, see
9797
_Legacy Enumeration Types_ in the documentation
9898

99-
## Upgrading from pre 2.0.0
99+
## 2.0.0
100100

101101
Version 2.0.0 introduced a significant change to the process for building the register model python
102102
code. This change was intended to reduce the size of the generated code by only generating
@@ -114,4 +114,20 @@ changing each time it was regenerated, version 2.1.0 introduces a option to eith
114114
of large register models but will be consistent, therefore is useful if the resultant code is being
115115
checked into a version control system (such as GIT) and the differences are being reviewed
116116

117+
## 3.0.0
118+
119+
Version 3.0.0 has included a significant refactoring of the generated test cases, moving functions out
120+
of the templates (generated code) in favour of an enhanced test library. On some cases, this
121+
reduced the size of the test case generated code by 90%, significantly improved the time to generate
122+
the code and also improved the time to run the tests by a 30% reduction.
123+
124+
In preparation for the removal of some legacy features from the early versions in release 4.0.0,
125+
the following options were changed:
126+
- Version 1.2 introduced a new custom enumeration type (rather than using `IntEnum`) in order to allow
127+
the content to `name` and `desc` systemRDL properties in be accessible. Until version 3.0.0 the new
128+
type was not the default, it now is. The old enumeration types can still be used by setting `legacy_enum_type`.
129+
- The first versions of PeakRDL Python used the built-in `Array` type for accessing blocks of data efficiently.
130+
This had some restrictions, so the a new methodology based on the `list` type was introduced in version 0.9.
131+
The old array based behaviour is no longer the default but can be turned on using the `legacy_block_access`
132+
117133

docs/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@
4545
# The theme to use for HTML and HTML Help pages. See the documentation for
4646
# a list of builtin themes.
4747
#
48-
html_theme = "sphinx_rtd_theme"
48+
html_theme = "sphinx_book_theme"
49+
50+
html_theme_options = {
51+
"repository_url": "https://github.com/krcb197/PeakRDL-python",
52+
"path_to_docs": "docs",
53+
"use_download_button": False,
54+
"use_source_button": True,
55+
"use_repository_button": True,
56+
"use_issues_button": True,
57+
}
4958

5059
# Add any paths that contain custom static files (such as style sheets) here,
5160
# relative to this directory. They are copied after the builtin static files,

docs/generated_package.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ Legacy Block Callback and Block Access
174174
* ``NormalCallbackSetLegacy`` for standard python function callbacks
175175
* ``AsyncCallbackSetLegacy`` for async python function callbacks, these are called from the library using ``await``
176176

177+
.. versionchanged:: 3.0.0
178+
179+
The ``legacy_block_access`` will now default to ``False``
180+
177181
Legacy Enumeration Types
178182
------------------------
179183

@@ -187,6 +191,10 @@ Legacy Enumeration Types
187191
There was a small risk this may impact some users code, in the case of advanced usage of the
188192
enumeration. The old behaviour can be brought back using the ``legacy_enum_type`` build option.
189193

194+
.. versionchanged:: 3.0.0
195+
196+
The ``legacy_enum_type`` will now default to ``False``
197+
190198

191199
Using the Register Access Layer
192200
===============================

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pygments-systemrdl
22
peakrdl-python
3-
sphinx_rtd_theme
3+
sphinx-book-theme

generate_and_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#from coverage import Coverage
3838

39-
#from peakrdl_ipxact import IPXACTImporter
39+
from peakrdl_ipxact import IPXACTImporter
4040

4141
sys.path.append('src')
4242
from peakrdl_python import PythonExporter
@@ -46,6 +46,8 @@
4646
CommandLineParser = argparse.ArgumentParser(description='Test the framework')
4747
CommandLineParser.add_argument('--RDL_source_file', dest='root_RDL_file',
4848
type=pathlib.Path, required=True)
49+
CommandLineParser.add_argument('--RDL_additional_file', dest='additional_file_RDL_file',
50+
type=pathlib.Path)
4951
CommandLineParser.add_argument('--root_node', dest='root_node',
5052
type=str, required=True)
5153
CommandLineParser.add_argument('--output', dest='output_path',
@@ -195,13 +197,15 @@ def build_logging_cong(logfilepath:str):
195197
else:
196198
raise(RuntimeError('not a list'))
197199

200+
if CommandLineArgs.additional_file_RDL_file is not None:
201+
rdlc.compile_file(CommandLineArgs.additional_file_RDL_file)
198202
rdlc.compile_file(CommandLineArgs.root_RDL_file)
199203
spec = rdlc.elaborate(top_def_name=CommandLineArgs.root_node).top
200204

201205
node_list = []
202206
for node in spec.descendants(unroll=True):
203207
node_list.append(node)
204-
print(node.inst_name)
208+
# print(node.inst_name)
205209

206210
# write out text file of all the nodes names, this can be used to debug regex issues
207211
if CommandLineArgs.full_inst_file is not None:

generate_testcases.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@
4949
'and debugging as multiple copies of the libraries can cause'
5050
'confusion. Therefore by default this script does not copy '
5151
'them over.')
52-
CommandLineParser.add_argument('--hashing_mode',
53-
dest='hashing_mode',
54-
type=str,
55-
choices=[item.name for item in NodeHashingMethod],
56-
default='PYTHONHASH',
57-
help='The method used to generate the hash of the node, in order to '
58-
'deduplicate the register model. Set this to `SHA256` if '
59-
'the python names need to stay consistent one export to the '
60-
'next. However, this mode is slower')
61-
6252

6353
def compile_rdl(infile: str,
6454
incl_search_paths: Optional[List[str]] = None,
@@ -158,19 +148,22 @@ def generate(root: Node, outdir: str,
158148
options = {
159149
'asyncoutput': [True, False],
160150
'legacy': [True, False],
161-
'skip_systemrdl_name_and_desc_in_docstring': [True, False]
151+
'skip_systemrdl_name_and_desc_in_docstring': [True, False],
152+
'hashing': list(NodeHashingMethod)
162153
}
163154

164-
for asyncoutput, legacy, skip_name_and_desc_in_docstring in product(
155+
for asyncoutput, legacy, skip_name_and_desc_in_docstring, hashing_method in product(
165156
options['asyncoutput'], options['legacy'],
166-
options['skip_systemrdl_name_and_desc_in_docstring'] ):
157+
options['skip_systemrdl_name_and_desc_in_docstring'],
158+
options['hashing']):
167159

168160
# test cases that use the extended widths an not be tested in the non-legacy modes
169161
if (testcase_name in ['extended_memories', 'extended_sizes_registers_array']) and \
170162
(legacy is True):
171163
continue
172164

173-
folder_parts = 'raw'
165+
folder_parts = 'raw_'
166+
folder_parts += hashing_method.name
174167
if asyncoutput:
175168
folder_parts += '_async'
176169
if legacy:
@@ -184,7 +177,7 @@ def generate(root: Node, outdir: str,
184177
legacy_enum_type=legacy,
185178
copy_library=CommandLineArgs.copy_libraries,
186179
skip_systemrdl_name_and_desc_in_docstring=skip_name_and_desc_in_docstring,
187-
hashing_mode=NodeHashingMethod[CommandLineArgs.hashing_mode])
180+
hashing_mode=hashing_method)
188181

189182
module_fqfn = output_path / folder_parts / '__init__.py'
190183
with open(module_fqfn, 'w', encoding='utf-8') as fid:

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ dev = [
6363
"mypy",
6464
"pylint",
6565
"coverage",
66-
"peakrdl"
66+
"peakrdl",
67+
# needed for the documentation build
68+
"sphinx-book-theme",
69+
"pygments-systemrdl"
70+
6771
]
6872
peakrdl = [
6973
"peakrdl"

src/peakrdl_python/__about__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Copyright (C) 2021 - 2025
44
55
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Lesser General Public License as
7-
published by the Free Software Foundation, either version 3 of
6+
it under the terms of the GNU Lesser General Public License as
7+
published by the Free Software Foundation, either version 3 of
88
the License, or (at your option) any later version.
99
1010
This program is distributed in the hope that it will be useful,
@@ -17,4 +17,4 @@
1717
1818
Variables that describes the peakrdl-python Package
1919
"""
20-
__version__ = "2.3.0"
20+
__version__ = "3.0.0"

src/peakrdl_python/__peakrdl__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def add_exporter_arguments(self, arg_group: 'argparse._ActionsContainer') -> Non
8080
arg_group.add_argument('--legacy_block_access', action='store_true',
8181
dest='legacy_block_access',
8282
help='peakrdl python has two methods to hold blocks of data, the '
83-
'legacy mode based on array.array or the new mode using lists')
83+
'legacy mode based on array.array or the new mode using '
84+
'lists. This option will be removed in version 4.0')
8485
arg_group.add_argument('--show_hidden', action='store_true',
8586
dest='show_hidden',
8687
help='show addrmap, regfile, memory, register and fields that '
@@ -100,7 +101,8 @@ def add_exporter_arguments(self, arg_group: 'argparse._ActionsContainer') -> Non
100101
dest='legacy_enum_type',
101102
help='peakrdl python has two ways to define field encoding as '
102103
'enums new method and an old method based on IntEnum. '
103-
'Setting this to true will restore the old behaviour')
104+
'Setting this to true will restore the old behaviour.'
105+
' This option will be removed in version 4.0')
104106
arg_group.add_argument('--skip_systemrdl_name_and_desc_properties', action='store_true',
105107
dest='skip_systemrdl_name_and_desc_properties',
106108
help='peakrdl python includes the system RDL name and desc '

0 commit comments

Comments
 (0)