Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
caf4337
Optimise the process of making a bitmask (removing a nasty loop) and …
krcb197 Jun 28, 2025
c561d2f
Remove separate storage of lsb0 and msb0 on the field in favour of re…
krcb197 Jun 28, 2025
8351995
Hash calculation added
krcb197 Jul 9, 2025
c44be31
Most of the work needed for registers and fields to be deduplicated
krcb197 Jul 31, 2025
7c33e5f
Updated version number for 1st RC on 2.0.0
krcb197 Aug 1, 2025
3f98fdf
Update the actions to run checks on release candidate branches
krcb197 Aug 1, 2025
fb3f7c3
Simplify calls into get_reg_writable_fields in the test bench
krcb197 Aug 1, 2025
80433e8
Simplify calls into get_reg_writable_fields in the test bench
krcb197 Aug 1, 2025
2f1ad80
Remove wasteful messages
krcb197 Aug 1, 2025
19b7480
Convert print to logging
krcb197 Aug 1, 2025
8fbba4a
Optimisation to only make a field if needed otherwise use the baseclass
krcb197 Aug 1, 2025
896d929
Merge branch 'main' of https://github.com/krcb197/PeakRDL-python into…
krcb197 Aug 1, 2025
38e2a8d
Support finalised for the register fields
krcb197 Aug 1, 2025
56840d5
Added support for hashed regfile and addrmap
krcb197 Aug 1, 2025
a8208e8
Move the register accesswidth and width inside the class definition r…
krcb197 Aug 1, 2025
a4b3885
Clean up linting issues
krcb197 Aug 1, 2025
a4af991
Added a check to catch the issue with arrays with matching hashes not…
krcb197 Aug 1, 2025
84c9959
draft version of the deduplicated components
krcb197 Aug 2, 2025
1cbc240
Fix some linting errors
krcb197 Aug 2, 2025
1aa74a9
Fix a bug with the generation of encoded field names
krcb197 Aug 2, 2025
1d50d64
Fix a bug regfiles within regfiles
krcb197 Aug 2, 2025
241d658
exclude signals inside node instances from hashes
krcb197 Aug 2, 2025
c90626b
Fix problem with the class names generated on the `get_child_by_syste…
krcb197 Aug 2, 2025
3b5bbe2
Fix type in doc string
krcb197 Aug 2, 2025
1f6d015
Optimisation to minimise the number of times a has is recalculated
krcb197 Aug 2, 2025
cdb2f3c
Include the has of an enum in the python class name to avoid issues w…
krcb197 Aug 2, 2025
3a7fd6e
Remove excessive newlines
krcb197 Aug 2, 2025
dea43d0
Fix the optimised access demo due to the change in enum type naming
krcb197 Aug 2, 2025
0abc545
Improve the docstrings in all the example code
krcb197 Aug 2, 2025
1e08613
Fix enum type naming change issues in the RAL and HAL examples
krcb197 Aug 2, 2025
33db755
Improved README.md
krcb197 Aug 2, 2025
a567efc
Remove unnecessary type hinting for the creation of class attributes
krcb197 Aug 5, 2025
e7ac1e8
Revert "Remove unnecessary type hinting for the creation of class att…
krcb197 Aug 8, 2025
ec85c24
Merge pull request #191 from krcb197/190-de-duplicate-field-definitions
krcb197 Aug 9, 2025
61aa306
Bug fix that cases were fields did not need a implementsation (base c…
krcb197 Aug 9, 2025
db3f1f7
Update the version number
krcb197 Aug 9, 2025
39770e2
Simplify the register file instance generation template code, using t…
krcb197 Aug 9, 2025
4ee1610
Add a new walker unique instance children function to help simplify t…
krcb197 Aug 9, 2025
d52cd21
Simplify the addrmap file instance generation template code, using th…
krcb197 Aug 9, 2025
4fc9c5d
Removed the individual types of iterator from within the generated co…
krcb197 Aug 16, 2025
45d4634
Fix linting and class setup issues with the test cases
krcb197 Aug 16, 2025
a627231
Merge branch 'main' of https://github.com/krcb197/PeakRDL-python into…
krcb197 Aug 16, 2025
3c51864
Fix merge from master
krcb197 Aug 16, 2025
0c5886b
Filter out signal nodes
krcb197 Aug 16, 2025
b9c4491
Merge pull request #212 from krcb197/207-move-iterations-to-the-base-…
krcb197 Aug 16, 2025
48c09cc
Fix typo
krcb197 Aug 17, 2025
2a8acad
closes #213: Move all the field enumerations into a separate file
krcb197 Aug 17, 2025
0208c7c
closes #214: Move all the field class definitions into a separate file
krcb197 Aug 17, 2025
ffd68f1
Update version number
krcb197 Aug 17, 2025
b83e53b
Remove unused imports
krcb197 Aug 17, 2025
50ae34e
Fix and tidy up imports
krcb197 Aug 17, 2025
5e9cdc4
Fix typo in comment
krcb197 Aug 17, 2025
a9402ce
Remove unused JINJA context
krcb197 Aug 17, 2025
b3c72c8
Clean up protected methods than can be private noe the width has been…
krcb197 Aug 17, 2025
89baa5c
Fix naming error
krcb197 Aug 17, 2025
16aa666
WIP
krcb197 Aug 23, 2025
c1ae0ec
Move the package classes that represent the built class to a new module
krcb197 Aug 23, 2025
95c7bdc
First version of the code to split the fields, register and field enu…
krcb197 Aug 23, 2025
aa11c90
First version of the code to split the fields, register and field enu…
krcb197 Aug 23, 2025
203eca1
Merge remote-tracking branch 'origin/76-split-the-auto-generated-reg-…
krcb197 Aug 24, 2025
ff3da9f
Added missing doc string
krcb197 Aug 24, 2025
6064849
Added backward compatibility for the batched itertool
krcb197 Aug 24, 2025
af98199
Fix a bug in the new field iterator that hidden fields were not hidden
krcb197 Aug 24, 2025
062e05c
Fix relative paths to the library in the new package structure
krcb197 Aug 24, 2025
0c3442a
Fixed a bug with the typing of the overloaded `get_child_by_system_rd…
krcb197 Aug 24, 2025
8ac9715
Optimised the test code for checking all the valid enumeration values…
krcb197 Aug 24, 2025
b328969
Fix a bug with `legacy_block_access` incorrectly set in the exporter
krcb197 Aug 24, 2025
0aaaa03
Added export parameters and command line arguments to control the gen…
krcb197 Aug 25, 2025
48f1aa1
Updated the documentation to explain the change made in 2.0.0
krcb197 Aug 25, 2025
a749333
Revise version number
krcb197 Aug 25, 2025
11f7e3a
Split the memories into separate files
krcb197 Aug 29, 2025
06b5a6d
Fix a bug with the imports into the memory definitions
krcb197 Aug 29, 2025
d71ca75
Remove unnecessary class name as string from typing
krcb197 Aug 29, 2025
57f032f
Improved the way the class level iteration classifier was handled to …
krcb197 Aug 29, 2025
4280553
Changed the name of the top level import to `RegModel`
krcb197 Aug 29, 2025
a8b476f
Documented the `RegModel` and `Simulator` class alias
krcb197 Aug 29, 2025
6897aee
Added missing memory class per file to the peakrdl exporter help
krcb197 Aug 30, 2025
c827dce
Change everything over to using the `Simulator` class
krcb197 Aug 30, 2025
6feb1fb
Add missing import to the __peakrdl__.py
krcb197 Aug 30, 2025
363f431
Cleaned up an mypy error
krcb197 Aug 30, 2025
eaf422d
Fixed the last error properly
krcb197 Aug 30, 2025
1a06da0
Fix import error on one of the examples
krcb197 Aug 30, 2025
cd58da9
Fix documentation build issue
krcb197 Aug 30, 2025
a7fd2d3
Refactored the test of illegal enum value in a field to only check fo…
krcb197 Sep 14, 2025
a1e9b21
Added support for memories to the pathalogical test
krcb197 Sep 14, 2025
5f11be0
Added support for regfiles and child addrmap to the pathological test
krcb197 Sep 14, 2025
363cda7
Merge pull request #215 from krcb197/76-split-the-auto-generated-reg-…
krcb197 Sep 29, 2025
e5fafcf
Merge branch 'release/2.0.0' of https://github.com/krcb197/PeakRDL-py…
krcb197 Sep 29, 2025
365e9ce
Closes #216 by coverting the inner workings of the arrays to tuples
krcb197 Oct 3, 2025
152218c
Type hinting fixes
krcb197 Oct 3, 2025
9bc091d
Type hinting fixes
krcb197 Oct 3, 2025
444f72d
Fix the support for slicing into arrays of Memories
krcb197 Oct 4, 2025
3ec56ef
Fix the support for slicing into arrays of RegFile and AddressMap
krcb197 Oct 4, 2025
5725128
Update sections.py
krcb197 Oct 4, 2025
dd00c55
Update sections.py to fix line length
krcb197 Oct 4, 2025
ee08839
Added Legacy memory array definitions to the sim package __init__
krcb197 Oct 4, 2025
8b1a144
Fix typing for `_element_datatype` on the Memory, Regfile and Addrmap
krcb197 Oct 5, 2025
c8b1a54
Fix issues with the memory array legacy types
krcb197 Oct 6, 2025
5cfbacd
Fix issues with the memory array legacy types
krcb197 Oct 6, 2025
566870a
Increased the array size coverage for the different array sizes
krcb197 Oct 6, 2025
66c68c2
Improve the export tests to only generate the errors that are being t…
krcb197 Oct 8, 2025
fec9086
Change method for calculation of the product of array dimensions to `…
krcb197 Oct 8, 2025
dac797f
Add test for the array slicing and fix and issue with the RegFile and…
krcb197 Oct 9, 2025
f98cc4d
Add test for slicing into array
krcb197 Oct 10, 2025
509c72d
Super testcase
krcb197 Oct 10, 2025
749d7ee
reduce the addrmap array combinations
krcb197 Oct 10, 2025
f6d28b1
Fix a bug with the definitions of memory arrays
krcb197 Oct 10, 2025
c53e0af
Fix a bug hidden items getting tested
krcb197 Oct 10, 2025
c313593
Merge pull request #217 from krcb197/216-convert-nodearray-to-immutab…
krcb197 Oct 11, 2025
ded511c
Update all the copyright messages to 2025
krcb197 Oct 11, 2025
15fcd73
Delete blank unused templates
krcb197 Oct 11, 2025
2b728cf
Making the simulator template names consistent
krcb197 Oct 11, 2025
f91309b
Update all the copyright messages to 2025
krcb197 Oct 12, 2025
18463c5
Put in the basic support to skip the docstring insertion, with new te…
krcb197 Oct 12, 2025
3ea9202
closes #206
krcb197 Oct 15, 2025
83727aa
Remove references to `suggestion-mode` in the pylint configuration as…
krcb197 Oct 15, 2025
e4d1bea
linting fixes
krcb197 Oct 15, 2025
5df66f1
linting fixes
krcb197 Oct 15, 2025
662f4ca
In order to address a bug that I have fixed before and de-risk the te…
krcb197 Oct 18, 2025
803a793
Fix bug with relative import of libraries caused by previous fix
krcb197 Oct 18, 2025
fc8861d
Fix bug with relative import in the example.py
krcb197 Oct 18, 2025
c1e5526
Consolidate the legacy modes into a single operation to reduce the nu…
krcb197 Oct 18, 2025
809e578
Consolidate the legacy modes into a single operation to reduce the nu…
krcb197 Oct 18, 2025
1321b04
Support for generating tests with and without the library copy and up…
krcb197 Oct 18, 2025
be7b112
Fix bug in the command parameters for the actions
krcb197 Oct 18, 2025
8e4668d
Fix the action file
krcb197 Oct 18, 2025
c9b110c
Another go at fixing the github actions
krcb197 Oct 18, 2025
cb978ae
Merge pull request #224 from krcb197/206-option-remove-the-system-rdl…
krcb197 Oct 18, 2025
842db6a
Add a check to ensure that a bug with property enumerations not being…
krcb197 Oct 19, 2025
e3d54db
Fix for the bug with enumerated UDP not having the enum type pulled t…
krcb197 Oct 19, 2025
97de5c9
Changed the exporter to use a callback function to test if a UDP is n…
krcb197 Oct 19, 2025
cab7a72
Updated the version number for this branch
krcb197 Oct 19, 2025
00117fc
Fix linting errors
krcb197 Oct 22, 2025
fc7f41a
Implement, test and document the regex UDP mode
krcb197 Oct 23, 2025
628087b
Clean up the README.md
krcb197 Oct 23, 2025
fdf517d
Add missing quotes to the REGEX parameter
krcb197 Oct 23, 2025
44db752
Merge pull request #227 from krcb197/219-default-udp-inclusion
krcb197 Oct 23, 2025
28134a5
Updating version to allow release following messup
krcb197 Oct 24, 2025
dbe06db
Merge branch 'main' of https://github.com/krcb197/PeakRDL-python into…
krcb197 Oct 24, 2025
54a6db9
Add a mypy badge
krcb197 Oct 24, 2025
bdc0a6c
Fix problem with dev not installing all of peakrdl
krcb197 Oct 24, 2025
253a320
Fix problem with `assertNotIsSubclass`
krcb197 Oct 24, 2025
c5785f9
Check library version check in the built code
krcb197 Oct 24, 2025
f81613e
Update version check function with depth parameter
krcb197 Oct 24, 2025
ffbae89
Fix working with copied library
krcb197 Oct 24, 2025
50fb475
Add missing endif
krcb197 Oct 24, 2025
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
59 changes: 43 additions & 16 deletions .github/workflows/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
pull_request:
branches:
- main
- 'release/**'
schedule:
- cron: '00 6 1 * *'
release:
Expand Down Expand Up @@ -136,12 +137,15 @@ jobs:
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --legacy_block_access
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --legacy_enum_type
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map --copy_libraries

python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include
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
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
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
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

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"

python -m generate_and_test --RDL_source_file tests/testcases/reserved_elements.rdl --root_node reserved_elements --hide_regex "(?:[\w_\[\]]+\.)+RSVD"

Expand Down Expand Up @@ -179,7 +183,8 @@ jobs:
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw/show_hidden/ --show_hidden
peakrdl python tests/testcases/simple.xml tests/testcases/multifile.rdl -o peakrdl_out/raw
peakrdl python tests/testcases/extended_memories.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/user_defined_properties.rdl -o peakrdl_out/raw/ --udp bool_property_to_include
peakrdl python tests/testcases/user_defined_properties.rdl -o peakrdl_out/raw/list/ --udp bool_property_to_include enum_property_to_include struct_property_to_include str_property_to_include
peakrdl python tests/testcases/user_defined_properties.rdl -o peakrdl_out/raw/regex/ --udp_regex "bool_property_to_include|enum_property_to_include|struct_property_to_include|str_property_to_include"
peakrdl python tests/testcases/reserved_elements.rdl -o peakrdl_out/raw/ --hide_regex "(?:[\w_\[\]]+\.)+RSVD"
peakrdl python tests/testcases/parametrised_top.rdl -o peakrdl_out/raw/ -P MY_PARAM=3
python -m unittest discover -s peakrdl_out/raw
Expand Down Expand Up @@ -257,17 +262,25 @@ jobs:
python -m with_hal

cd ../..

cd example/user_defined_properties/
peakrdl python user_defined_properties.rdl -o . --udp_regex "^(?!python_hide$)(?!python_name$).+"
python -m demo_user_defined_properties

cd ../..



integration_tests:
needs:
- mypy
- lint
- unit_tests
- peakrdl_integration
- dev_runner

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
lib_copy: [true, false]

steps:
- uses: actions/checkout@v4
Expand All @@ -284,32 +297,46 @@ jobs:

# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl

- name: Generate testcases
run: |


# one of the test cases uses IPxact so we need the importer
python -m pip install peakrdl-ipxact
# the generated code is type checked with mypy so this is needed
python -m pip install mypy

python generate_testcases.py
- name: Generate testcases (lib_copy true)
if: matrix.lib_copy == true
run: |
python generate_testcases.py --copy_libraries --output lib_included_testcase_output

- name: Generate testcases (lib_copy false)
if: matrix.lib_copy == false
run: |
python generate_testcases.py --output lib_excluded_testcase_output

- name: Static checks (lib_copy true)
if: matrix.lib_copy == true
run: |
mypy lib_included_testcase_output

- name: Static checks
- name: Static checks (lib_copy false)
if: matrix.lib_copy == false
run: |
mypy lib_excluded_testcase_output

mypy testcase_output
# pylint testcase_output/autopep8 --disable=duplicate-code,line-too-long,too-many-statements,invalid-name,unused-import,too-many-instance-attributes,too-many-arguments,too-many-lines
- name: Run the generated tests (lib_copy true)
if: matrix.lib_copy == true
run: |
python -m unittest discover -s lib_included_testcase_output

- name: Run the generated tests
- name: Run the generated tests (lib_copy false)
if: matrix.lib_copy == false
run: |
python -m unittest discover -s testcase_output
python -m unittest discover -s lib_excluded_testcase_output

autoformating:
needs:
- integration_tests
- peakrdl_integration
- dev_runner


runs-on: ubuntu-latest
strategy:
Expand Down
82 changes: 78 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,82 @@
![CI](https://github.com/krcb197/PeakRDL-python/actions/workflows/action.yaml/badge.svg)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/peakrdl-python.svg)](https://pypi.org/project/peakrdl-python)
[![Documentation Status](https://readthedocs.org/projects/peakrdl-python/badge/?version=latest)](https://peakrdl-python.readthedocs.io/en/latest/?badge=latest)
[![Downloads](https://static.pepy.tech/badge/peakrdl-python)](https://pepy.tech/project/peakrdl-python)

# peakrdl-python
Generate Python Register Access Layer (RAL) from SystemRDL
# Introduction
PeakRDL Python is used to generate a python based Register Access Layer (RAL) from SystemRDL.

## Documentation
See the [peakrdl-python Documentation](https://peakrdl-python.readthedocs.io/) for more details

## Getting Started

### Installation

1. Install a recent version of Python 3
2. Install `peakrdl-python`
```console
python3 -m pip install peakrdl-python
```
3. (Optional) Install `peakrdl`, this is needed if you want to use peakrdl python from the command
line
```console
python3 -m pip install peakrdl
```

### Demo

This demonstration relies on downloading the systemRDL example from Accelera, available here: [accelera-generic_example.rdl](https://github.com/SystemRDL/systemrdl-compiler/blob/main/examples/accelera-generic_example.rdl). This demonstration also
assumes that peakrdl has been installed.

1. Build the Register Access Layer (RAL) from the systemRDL code
```console
peakrdl python accelera-generic_example.rdl -o .
```
This will create a python package called `some_register_map` containing the python RAL
2. In addition to the RAL, peakrdl-python also generates a simulator that can be used to exercise
the RAL without connecting to real hardware. Enter the following code into a file:
```python
"""
A demonstration of using peakrdl-python using the accelera generic example
"""
# import the top level RAL class
from some_register_map.reg_model import RegModel
# import the simulator class
from some_register_map.sim import Simulator

from some_register_map.lib import NormalCallbackSet

if __name__ == '__main__':
# create an instance of the RAL with the callbacks directed at the hardware simulator
hw_sim = Simulator(0)
ral = RegModel(callbacks=NormalCallbackSet(read_callback=hw_sim.read,
write_callback=hw_sim.write))

# read chip ID
chip_id_part_number = ral.chip_id_reg.part_num.read()
chip_id_revision_number = ral.chip_id_reg.part_num.read()
print(f'Chip ID:{chip_id_part_number}.{chip_id_revision_number}')
```
save it as `some_register_map_demo.py`
3. Run the example
```commandline
python3 -m some_register_map_demo
```
This will generate the following output on the console:
```commandline
Chip ID:0.0
```

# Usage

To make use of the RAL with real hardware or a different simulation, the callbacks will need to be
connected to the appropriate access function in order to perform an address space reads and writes

# Upgrading from previous versions (some important changes)

## Upgrading from pre 0.9.0

In order to address a major limitation of peakrdl-python that prevented it from implementing the
Expand All @@ -24,9 +91,16 @@ documentation
## Upgrading from pre 1.2.0

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

## Upgrading from pre 2.0.0

Version 2.0 introduced a significant change to the process for building the register model python
code. This change was intended to reduce the size of the generated code by only generating
python classes for systemRDL components that required unique classes. The previous versions were
more conservative and tended to generate a lot of duplicate classes.


8 changes: 4 additions & 4 deletions docs/api_components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ Base Classes
Address Maps
============

.. autoclass:: peakrdl_python.lib.base.AddressMap
.. autoclass:: peakrdl_python.lib.sections.AddressMap
:members:
:inherited-members:

.. autoclass:: peakrdl_python.lib.base.AddressMapArray
.. autoclass:: peakrdl_python.lib.sections.AddressMapArray
:members:
:inherited-members:

Register Files
==============

.. autoclass:: peakrdl_python.lib.base.RegFile
.. autoclass:: peakrdl_python.lib.sections.RegFile
:members:
:inherited-members:

.. autoclass:: peakrdl_python.lib.base.RegFileArray
.. autoclass:: peakrdl_python.lib.sections.RegFileArray
:members:
:inherited-members:

Expand Down
37 changes: 37 additions & 0 deletions docs/generated_package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ In the folder structure above:
- ``lib`` - This is a package of base classes used by the register access layer (The copy of this can be skipped, see :ref:`skipping-lib-copy`)
- ``sim_lib`` - This is a package of base classes used by the register access layer simulator (The copy of this can be skipped, see :ref:`skipping-lib-copy`)

.. versionchanged:: 2.0.0

The ``reg_model`` was changed in version 2.0.0 to split it out into multiple modules rather
than building the whole register model in a single python module. This helps avoid
excessively large files which helps speed up the generation and loading time.

Top Level Classes
-----------------

.. versionchanged:: 2.0.0

A new class aliases were added to the ``reg_model`` and ``sim`` packages to allow the register
model and simulator to be imported more easily. See the example below using ``RegModel`` and
``Simulator``.


Running the Unit Tests
======================

Expand Down Expand Up @@ -402,6 +418,11 @@ Exposing User Defined Properties
SystemRDL allows properties to be added to any component (Field, Memory, Register, Register File,
Address Map), so called *User Defined Properties (UDP)*.

There are two methods to expose user defined properties:

- A list of strings to include in the package
- A Regular Expression which will include any UDP which matches the regular expression

Consider the following systemRDL example with a user defined property: ``component_usage``

.. literalinclude :: ../example/user_defined_properties/user_defined_properties.rdl
Expand All @@ -413,12 +434,28 @@ User Defined Properties are not automatically included they must be specified, a

peakrdl python user_defined_properties.rdl -o . --udp component_usage

Alternatively the User Defined Properties can be included with a regular expression.
In the following case all UDPs are included, except the ones used by PeakRDL python

.. code-block:: bash

peakrdl python user_defined_properties.rdl -o . --udp_regex "^(?!python_hide$)(?!python_name$).+"

.. warning::

Attempting to use both the list and regular expression approach is not supported and will
generate an error

The user defined properties are stored in a ``udp`` property of all component in the generated
register access and can be accessed as follows:

.. literalinclude :: ../example/user_defined_properties/demo_user_defined_properties.py
:language: python

.. versionadded:: 2.0.0

Regular Expression matching for User Defined Properties was added in version 2.0.0

Python Safe Names
=================

Expand Down
14 changes: 7 additions & 7 deletions example/array_access/demo_array_access.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import json
from typing import Union

from array_access.reg_model.array_access import array_access_cls
from array_access.sim.array_access import array_access_simulator_cls
"""
A demonstration of array access for peakrdl-python
"""
from array_access.reg_model import RegModel
from array_access.sim import Simulator
from array_access.lib.callbacks import NormalCallbackSet

if __name__ == '__main__':

# setup the simple simulator
sim = array_access_simulator_cls(0)
sim = Simulator(0)

# create an instance of the class
regmodel = array_access_cls(callbacks=NormalCallbackSet(read_callback=sim.read))
regmodel = RegModel(callbacks=NormalCallbackSet(read_callback=sim.read))

# access a entry in the 1D array
print(regmodel.reg_array_1D[0].field_a.read())
Expand Down
10 changes: 5 additions & 5 deletions example/enumerated_fields/demo_enumerated_fields.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""
A demonstration of using enumeration
A demonstration of using enumeration for peakrdl-python
"""
from enumerated_fields.lib import NormalCallbackSet

from enumerated_fields.reg_model.enumerated_fields import enumerated_fields_cls as GPIO
from enumerated_fields.sim.enumerated_fields import enumerated_fields_simulator_cls as HardwareSimulator
from enumerated_fields.reg_model import RegModel
from enumerated_fields.sim import Simulator

if __name__ == '__main__':

# create an instance of the hardware simulator
hw = HardwareSimulator(0)
hw = Simulator(0)
# create an instance of the RAL with the callbacks directed at the hardware simulator
gpio = GPIO(callbacks=NormalCallbackSet(read_callback=hw.read, write_callback=hw.write))
gpio = RegModel(callbacks=NormalCallbackSet(read_callback=hw.read, write_callback=hw.write))

# get the field values
for field in gpio.gpio_strength.readable_fields:
Expand Down
Loading