peakrdl-python 0.7.4__tar.gz → 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. peakrdl_python-0.8.0/.github/workflows/action.yaml +306 -0
  2. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/.gitignore +1 -0
  3. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/PKG-INFO +8 -1
  4. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/api_components.rst +3 -2
  5. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/generated_package.rst +26 -8
  6. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/index.rst +1 -4
  7. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/array_access/demo_array_access.py +5 -17
  8. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/enumerated_fields/demo_enumerated_fields.py +2 -19
  9. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/optimised_access/demo_optimised_access.py +4 -34
  10. peakrdl_python-0.8.0/example/optimised_access/demo_optimised_array_access.py +42 -0
  11. peakrdl_python-0.8.0/example/overridden_names/demo_over_ridden_names.py +17 -0
  12. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/simulating_callbacks/chip_with_a_GPIO.rdl +3 -2
  13. peakrdl_python-0.8.0/example/simulating_callbacks/flashing_the_LED.py +99 -0
  14. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/tranversing_address_map/dumping_register_state_to_json_file.py +4 -39
  15. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/tranversing_address_map/reseting_registers.py +9 -41
  16. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/tranversing_address_map/writing_register_state_from_json_file.py +4 -38
  17. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/why_ral/with_hal.py +2 -4
  18. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/why_ral/with_ral.py +2 -4
  19. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/why_ral/without_ral.py +21 -3
  20. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/generate_and_test.py +30 -51
  21. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/pyproject.toml +10 -1
  22. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/__about__.py +1 -1
  23. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/exporter.py +300 -125
  24. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/async_register.py +77 -26
  25. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/fields.py +1 -4
  26. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/register.py +74 -65
  27. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/__init__.py +0 -0
  28. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/_callbacks.py +95 -0
  29. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/base.py +34 -0
  30. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/dummy_callbacks.py +175 -0
  31. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/field.py +154 -0
  32. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/memory.py +162 -0
  33. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/register.py +221 -0
  34. peakrdl_python-0.8.0/src/peakrdl_python/sim_lib/simulator.py +361 -0
  35. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/addrmap.py.jinja +35 -35
  36. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/addrmap_field.py.jinja +2 -0
  37. peakrdl_python-0.8.0/src/peakrdl_python/templates/addrmap_simulation_tb.py.jinja +409 -0
  38. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/addrmap_tb.py.jinja +22 -22
  39. peakrdl_python-0.8.0/src/peakrdl_python/templates/baseclass_simulation_tb.py.jinja +65 -0
  40. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/baseclass_tb.py.jinja +15 -47
  41. peakrdl_python-0.8.0/src/peakrdl_python/templates/example.py.jinja +13 -0
  42. peakrdl_python-0.8.0/src/peakrdl_python/templates/sim_addrmap.py.jinja +65 -0
  43. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python.egg-info/PKG-INFO +8 -1
  44. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python.egg-info/SOURCES.txt +14 -3
  45. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python.egg-info/requires.txt +9 -0
  46. peakrdl_python-0.8.0/tests/testcases/simulator_test.rdl +44 -0
  47. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/unit_tests/test_reg.py +202 -0
  48. peakrdl-python-0.7.4/.github/workflows/action.yaml +0 -217
  49. peakrdl-python-0.7.4/example/optimised_access/demo_optimised_array_access.py +0 -102
  50. peakrdl-python-0.7.4/example/overridden_names/over_ridden_names.py +0 -32
  51. peakrdl-python-0.7.4/example/simulating_callbacks/flashing_the_LED.py +0 -144
  52. peakrdl-python-0.7.4/example/why_ral/hardware_sim.py +0 -25
  53. peakrdl-python-0.7.4/src/peakrdl_python/templates/addrmap_simulation_tb.jinja +0 -17
  54. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/.readthedocs.yaml +0 -0
  55. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/LICENSE +0 -0
  56. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/MANIFEST.in +0 -0
  57. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/README.md +0 -0
  58. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/api.rst +0 -0
  59. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/command_line.rst +0 -0
  60. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/conf.py +0 -0
  61. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/customisation.rst +0 -0
  62. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/design_decisions.rst +0 -0
  63. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/design_tools.rst +0 -0
  64. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/genindex.rst +0 -0
  65. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/installation.rst +0 -0
  66. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/docs/requirements.txt +0 -0
  67. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/array_access/array_access.rdl +0 -0
  68. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/enumerated_fields/enumerated_fields.rdl +0 -0
  69. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/optimised_access/optimised_access.rdl +0 -0
  70. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/optimised_access/optimised_array_access.rdl +0 -0
  71. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/overridden_names/overridden_names.rdl +0 -0
  72. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/tranversing_address_map/chip_with_registers.rdl +0 -0
  73. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/tranversing_address_map/reg_dump.json +0 -0
  74. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/why_ral/__init__.py +0 -0
  75. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/example/why_ral/gpio.rdl +0 -0
  76. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/generate_testcases.py +0 -0
  77. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/setup.cfg +0 -0
  78. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/.coveragerc +0 -0
  79. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/__init__.py +0 -0
  80. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/__peakrdl__.py +0 -0
  81. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/_node_walkers.py +0 -0
  82. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/__init__.py +0 -0
  83. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/base.py +0 -0
  84. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/callbacks.py +0 -0
  85. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/memory.py +0 -0
  86. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/lib/utility_functions.py +0 -0
  87. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/safe_name_utility.py +0 -0
  88. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/systemrdl_node_utility_functions.py +0 -0
  89. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/__init__.py +0 -0
  90. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/addrmap_memory.py.jinja +0 -0
  91. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/addrmap_register.py.jinja +0 -0
  92. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/addrmap_simulation.py.jinja +0 -0
  93. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/header.py.jinja +0 -0
  94. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/header_tb.py.jinja +0 -0
  95. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python/templates/reg_definitions.py.jinja +0 -0
  96. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python.egg-info/dependency_links.txt +0 -0
  97. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python.egg-info/entry_points.txt +0 -0
  98. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/src/peakrdl_python.egg-info/top_level.txt +0 -0
  99. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/.mypy.ini +0 -0
  100. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/alternative_template_toml/peakrdl.toml +0 -0
  101. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/alternative_templates/header.py.jinja +0 -0
  102. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/alternative_templates/header_tb.py.jinja +0 -0
  103. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/pylint.rc +0 -0
  104. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/RDLFormatCode_example.rdl +0 -0
  105. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/addr_map.rdl +0 -0
  106. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/all_register_access_types.rdl +0 -0
  107. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/basic.rdl +0 -0
  108. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/block_a.xml +0 -0
  109. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/block_b.xml +0 -0
  110. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/different_array_types.rdl +0 -0
  111. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/enum_example.rdl +0 -0
  112. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/example_issue_106.rdl +0 -0
  113. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/field_scope.rdl +0 -0
  114. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/field_with_overridden_reset.rdl +0 -0
  115. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/fields_with_HW_write.rdl +0 -0
  116. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/fields_with_reset_values.rdl +0 -0
  117. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/memories.rdl +0 -0
  118. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/memories_with_registers.rdl +0 -0
  119. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/msb0_and_lsb0.rdl +0 -0
  120. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/multi_block.rdl +0 -0
  121. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/multifile.rdl +0 -0
  122. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/name_clash.rdl +0 -0
  123. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/overridden_python_name.rdl +0 -0
  124. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/parametrised_readonly_and_readwrite.rdl +0 -0
  125. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/regfile_and_arrays.rdl +0 -0
  126. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/same_but_different_enum.rdl +0 -0
  127. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/signals_definitions_at_various_levels.rdl +0 -0
  128. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/simple.rdl +0 -0
  129. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/simple.xml +0 -0
  130. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/sizes_registers.rdl +0 -0
  131. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/sizes_registers_array.rdl +0 -0
  132. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/testcases/write_only_enum_with_undefined_reset.rdl +0 -0
  133. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/unit_tests/__init__.py +0 -0
  134. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/unit_tests/simple_components.py +0 -0
  135. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/unit_tests/test_array_indexing.py +0 -0
  136. {peakrdl-python-0.7.4 → peakrdl_python-0.8.0}/tests/unit_tests/test_optimised_reg_array.py +0 -0
@@ -0,0 +1,306 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CI
4
+
5
+ # Controls when the action will run.
6
+ on:
7
+ # Triggers the workflow on push or pull request events but only for the main branch
8
+ push:
9
+ branches: [ main ]
10
+ pull_request:
11
+ branches: [ main ]
12
+ schedule:
13
+ - cron: '00 6 1 * *'
14
+ release:
15
+ types:
16
+ - published
17
+
18
+ # Allows you to run this workflow manually from the Actions tab
19
+ workflow_dispatch:
20
+
21
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
22
+ jobs:
23
+ lint:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version: "3.11"
31
+
32
+ - name: Install dependencies
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ python -m pip install .
36
+ python -m pip install -U pylint
37
+
38
+ - name: Run Lint
39
+ #run: pylint --rcfile tests/pylint.rc src/peakrdl_python tests/unit_tests
40
+ run: pylint --rcfile tests/pylint.rc src/peakrdl_python
41
+
42
+ mypy:
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - name: Set up Python
47
+ uses: actions/setup-python@v5
48
+ with:
49
+ python-version: "3.11"
50
+
51
+ - name: Install dependencies
52
+ run: |
53
+ python -m pip install --upgrade pip
54
+ python -m pip install .
55
+ python -m pip install -U mypy
56
+ - name: Type Check
57
+ run: mypy src/peakrdl_python --config-file=tests/.mypy.ini
58
+
59
+ unit_tests:
60
+ needs:
61
+ - mypy
62
+ - lint
63
+
64
+ runs-on: ubuntu-latest
65
+ strategy:
66
+ matrix:
67
+ python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11", "3.12" ]
68
+
69
+ steps:
70
+ - uses: actions/checkout@v4
71
+
72
+ - name: Set up Python ${{ matrix.python-version }}
73
+ uses: actions/setup-python@v5
74
+ with:
75
+ python-version: ${{ matrix.python-version }}
76
+
77
+ - name: Install dependencies
78
+ run: |
79
+ python -m pip install --upgrade pip
80
+ python -m pip install .
81
+
82
+ - name: Run Unit Tests
83
+ run: |
84
+ python -m unittest discover -s tests/unit_tests -t .
85
+
86
+ dev_runner:
87
+ needs:
88
+ - mypy
89
+ - lint
90
+ - unit_tests
91
+
92
+ runs-on: ubuntu-latest
93
+ strategy:
94
+ matrix:
95
+ python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11", "3.12" ]
96
+
97
+ steps:
98
+ - uses: actions/checkout@v4
99
+
100
+ - name: Set up Python ${{ matrix.python-version }}
101
+ uses: actions/setup-python@v5
102
+ with:
103
+ python-version: ${{ matrix.python-version }}
104
+
105
+ - name: Install dependencies
106
+ run: |
107
+ python -m pip install --upgrade pip
108
+ python -m pip install .[dev]
109
+ # the generate_and_test script is intended to run directly from source rather than from
110
+ # the installed package
111
+ python -m pip uninstall peakrdl-python -y
112
+ # peakrdl-ipxact is needed for some of the test cases so is imported by the
113
+ # generate_and_test script
114
+
115
+
116
+ # retrieve the example code from the systemRDL compiler
117
+ wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
118
+
119
+ - name: Test Development Runner
120
+ run: |
121
+
122
+ python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test
123
+ python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test --async
124
+
125
+ python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map
126
+
127
+ peakrdl_integration:
128
+ needs:
129
+ - mypy
130
+ - lint
131
+ - unit_tests
132
+
133
+ runs-on: ubuntu-latest
134
+ strategy:
135
+ matrix:
136
+ python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11", "3.12" ]
137
+
138
+ steps:
139
+ - uses: actions/checkout@v4
140
+
141
+ - name: Set up Python ${{ matrix.python-version }}
142
+ uses: actions/setup-python@v5
143
+ with:
144
+ python-version: ${{ matrix.python-version }}
145
+
146
+ - name: Install dependencies
147
+ run: |
148
+ python -m pip install --upgrade pip
149
+ python -m pip install .[peakrdl]
150
+
151
+ - name: Run PeakRDL Case
152
+ run: |
153
+
154
+ peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw/
155
+ peakrdl python tests/testcases/simple.xml tests/testcases/multifile.rdl -o peakrdl_out/raw
156
+ python -m unittest discover -s peakrdl_out/raw
157
+ peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw_async/ --async
158
+ python -m unittest discover -s peakrdl_out/raw_async
159
+
160
+ peakrdl python tests/testcases/basic.rdl -o peakrdl_out/no_test/ --skip_test_case_generation
161
+
162
+ - name: Check Examples
163
+ run: |
164
+
165
+ # build the libraries for the two cases
166
+ cd example/tranversing_address_map/
167
+ peakrdl python chip_with_registers.rdl -o .
168
+ python -m reseting_registers
169
+ python -m dumping_register_state_to_json_file
170
+ python -m writing_register_state_from_json_file
171
+
172
+ cd ../..
173
+
174
+ cd example/simulating_callbacks
175
+
176
+ peakrdl python chip_with_a_GPIO.rdl -o .
177
+ # this example creates a gui that stays up for ever so needs changing before it can be
178
+ # in the test suite
179
+ # python -m flashing_the_LED
180
+
181
+ cd ../..
182
+
183
+ cd example/optimised_access/
184
+ peakrdl python optimised_access.rdl -o .
185
+ python -m demo_optimised_access
186
+
187
+ cd ../..
188
+
189
+ cd example/array_access/
190
+ peakrdl python array_access.rdl -o .
191
+ python -m demo_array_access
192
+
193
+ cd ../..
194
+
195
+ cd example/enumerated_fields/
196
+ peakrdl python enumerated_fields.rdl -o .
197
+ python -m demo_enumerated_fields
198
+
199
+
200
+ cd ../..
201
+
202
+ cd example/why_ral/
203
+ peakrdl python gpio.rdl -o .
204
+ python -m without_ral
205
+ python -m with_ral
206
+ python -m with_hal
207
+
208
+ cd ../..
209
+
210
+ integration_tests:
211
+ needs:
212
+ - mypy
213
+ - lint
214
+ - unit_tests
215
+
216
+ runs-on: ubuntu-latest
217
+ strategy:
218
+ matrix:
219
+ python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
220
+
221
+ steps:
222
+ - uses: actions/checkout@v4
223
+
224
+ - name: Set up Python ${{ matrix.python-version }}
225
+ uses: actions/setup-python@v5
226
+ with:
227
+ python-version: ${{ matrix.python-version }}
228
+
229
+ - name: Install dependencies
230
+ run: |
231
+ python -m pip install --upgrade pip
232
+ python -m pip install .
233
+
234
+ # retrieve the example code from the systemRDL compiler
235
+ wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
236
+
237
+ - name: Generate testcases
238
+ run: |
239
+
240
+ # one of the test cases uses IPxact so we need the importer
241
+ python -m pip install peakrdl-ipxact
242
+ # the generated code is type checked with mypy so this is needed
243
+ python -m pip install mypy
244
+
245
+ python generate_testcases.py
246
+ mypy testcase_output --config-file=tests/.mypy.ini
247
+ # pylint --rcfile tests/pylint.rc 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
248
+
249
+ python -m unittest discover -s testcase_output
250
+
251
+ - name: Test Autoformating
252
+ run: |
253
+ python -m pip install black
254
+ cp testcase_output autoformatted_testcase_output -r
255
+ black autoformatted_testcase_output --line-length 120
256
+ python -m unittest discover -s autoformatted_testcase_output
257
+
258
+ #-------------------------------------------------------------------------------
259
+ build:
260
+ needs:
261
+ - integration_tests
262
+ - dev_runner
263
+ - peakrdl_integration
264
+ name: Build source distribution
265
+ runs-on: ubuntu-latest
266
+ steps:
267
+ - uses: actions/checkout@v4
268
+
269
+ - uses: actions/setup-python@v5
270
+ name: Install Python
271
+ with:
272
+ python-version: "3.11"
273
+
274
+ - name: Install dependencies
275
+ run: |
276
+ python -m pip install -U build
277
+
278
+ - name: Build
279
+ run: python -m build
280
+
281
+ - uses: actions/upload-artifact@v4
282
+ with:
283
+ path: |
284
+ dist/*.tar.gz
285
+ dist/*.whl
286
+
287
+
288
+ #-------------------------------------------------------------------------------
289
+ deploy:
290
+ needs:
291
+ - build
292
+
293
+ runs-on: ubuntu-latest
294
+
295
+ # Only publish when a GitHub Release is created.
296
+ if: github.event_name == 'release'
297
+ steps:
298
+ - uses: actions/download-artifact@v4
299
+ with:
300
+ name: artifact
301
+ path: dist
302
+
303
+ - uses: pypa/gh-action-pypi-publish@release/v1
304
+ with:
305
+ user: __token__
306
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -57,3 +57,4 @@ __pycache__/
57
57
  /example/overridden_names/over_ridden_names/
58
58
  /example/simulating_callbacks/mychip/
59
59
  /example/tranversing_address_map/chip_with_registers/
60
+ /generate_and_test_output/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: peakrdl-python
3
- Version: 0.7.4
3
+ Version: 0.8.0
4
4
  Summary: Generate Python Register Access Layer (RAL) from SystemRDL
5
5
  Author: Keith Brady
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -704,6 +704,13 @@ Requires-Dist: systemrdl-compiler>=1.24.0
704
704
  Requires-Dist: jinja2
705
705
  Requires-Dist: asynctest; python_version < "3.8"
706
706
  Requires-Dist: typing-extensions; python_version < "3.11"
707
+ Provides-Extra: dev
708
+ Requires-Dist: mypy; extra == "dev"
709
+ Requires-Dist: pylint; extra == "dev"
710
+ Requires-Dist: coverage; extra == "dev"
711
+ Requires-Dist: peakrdl-ipxact; extra == "dev"
712
+ Provides-Extra: peakrdl
713
+ Requires-Dist: peakrdl; extra == "peakrdl"
707
714
 
708
715
  ![CI](https://github.com/krcb197/PeakRDL-python/actions/workflows/action.yaml/badge.svg)
709
716
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/peakrdl-python.svg)](https://pypi.org/project/peakrdl-python)
@@ -65,7 +65,7 @@ Memories
65
65
  :inherited-members:
66
66
 
67
67
  Registers
68
- ^^^^^^^^^
68
+ =========
69
69
 
70
70
  .. autoclass:: peakrdl_python.lib.register.RegReadOnly
71
71
  :members:
@@ -93,6 +93,7 @@ Registers
93
93
 
94
94
  Register Fields
95
95
  ^^^^^^^^^^^^^^^
96
+ A register will always have fields within it
96
97
 
97
98
  .. autoclass:: peakrdl_python.lib.fields.FieldReadOnly
98
99
  :members:
@@ -116,4 +117,4 @@ Register Fields
116
117
 
117
118
  .. autoclass:: peakrdl_python.lib.fields.FieldEnumReadWrite
118
119
  :members:
119
- :inherited-members:
120
+ :inherited-members:
@@ -9,8 +9,11 @@ will be based on the top level address map name with the package was generated
9
9
 
10
10
  | ``<root_name>``
11
11
  | ├── ``lib``
12
+ | ├── ``sim_lib``
12
13
  | ├── ``reg_model``
13
14
  | │ └── ``<root_name>.py``
15
+ | ├── ``sim``
16
+ | │ └── ``<root_name>.py``
14
17
  | └── ``tests``
15
18
  | └── ``test_<root_name>.py``
16
19
 
@@ -57,7 +60,7 @@ access layer package so that it can be used from the console:
57
60
  Args:
58
61
  addr: Address to write to
59
62
  width: Width of the register in bits
60
- accesswidth: Minimium access width of the register in bits
63
+ accesswidth: Minimum access width of the register in bits
61
64
 
62
65
  Returns:
63
66
  value inputted by the used
@@ -69,8 +72,8 @@ access layer package so that it can be used from the console:
69
72
 
70
73
  def write_addr_space(addr: int, width: int, accesswidth: int, data: int) -> None:
71
74
  """
72
- Callback to simulate the operation of the package, everytime the read is called, it will
73
- request the user input the value to be read back.
75
+ Callback to simulate the operation of the package, everytime the write is called, it will
76
+ print out the result.
74
77
 
75
78
  Args:
76
79
  addr: Address to write to
@@ -130,11 +133,10 @@ a file called ``chip_with_a_GPIO.rdl``:
130
133
  .. tip:: It is always good practice to run the unittests on the generated code.
131
134
 
132
135
  Once the register access layer has been generated and it can be used. The following example
133
- does not actually use a device driver. Instead it chip simulator with a a Tkinter GUI,
136
+ does not actually use a device driver. Instead it chip simulator with a Tkinter GUI,
134
137
  incorporating a RED circle to represent the LED. The chip simulator has read and write methods (
135
- equivalent to those offered by a device driver), these look at the address of the write and update
136
- the internal state of the simulator accordingly, the LED is then updated based on the state of the
137
- simulator.
138
+ equivalent to those offered by a hardware device driver), in this case they use the simulator
139
+ provided by PeakRDL Python.
138
140
 
139
141
  .. literalinclude :: ../example/simulating_callbacks/flashing_the_LED.py
140
142
  :language: python
@@ -395,7 +397,7 @@ User Defined Property), attributes can be accessed using the ``get_child_by_syst
395
397
  method of any object in the register model. The following example shows both methods to access the
396
398
  field from the example above
397
399
 
398
- .. literalinclude :: ../example/overridden_names/over_ridden_names.py
400
+ .. literalinclude :: ../example/overridden_names/demo_over_ridden_names.py
399
401
  :language: python
400
402
 
401
403
 
@@ -414,3 +416,19 @@ to clean up the generated code. This had two issues:
414
416
  peakrdl-python uses the Black `Black <https://pypi.org/project/black/L>`_ in the CI tests to check
415
417
  that the generated code is compatible with an autoformatter.
416
418
 
419
+
420
+ Simulator
421
+ =========
422
+
423
+ PeakRDL Python also generates an simulator, this can be used to test and develop using the
424
+ generated package. The simulator is used in a the examples shown earlier in this section. The
425
+ simulator has the option to attach a callback to the read and write operations of either a
426
+ register or field. In addition there is a ``value`` property that allows access to the register
427
+ or feild content, this allows the contents to be accessed or updated without activating the
428
+ callbacks, this is intended to allow the simulator to be extended with behaviour that is not
429
+ fully described by the systemRDL.
430
+
431
+ .. warning:: The PeakRDL Python simulator is not intended to replace an RTL simulation of the
432
+ design. It does not simulate the hardware, it is intended as a simple tool for
433
+ development and testing of the python wrappers or code that uses them.
434
+
@@ -68,13 +68,10 @@ set the state to `1`. The device has 8 GPIO pins controlled from two registers.
68
68
  | | | | | | | | | | | GPIO configured as out |
69
69
  +----------+---------+------------+------------+------------+------------+------------+------------+------------+------------+------------------------+
70
70
 
71
- This example uses a simple simulation class to mimic the behaviour of the device offering ``read`` and ``write``
71
+ This example uses the peakrdl python simulator to mimic the behaviour of the device offering ``read`` and ``write``
72
72
  methods to offer register read and write access to the device. In the real work this would likely go
73
73
  via a device driver or JTAG emulator, if the software is running off chip (i.e. a PC).
74
74
 
75
- .. literalinclude :: ../example/why_ral/hardware_sim.py
76
- :language: python
77
-
78
75
  To configure pin 0 and set its state you would need to do the following steps:
79
76
 
80
77
  1. Read the DIR register (to make sure you preserve the states of other pins)
@@ -2,28 +2,16 @@ import json
2
2
  from typing import Union
3
3
 
4
4
  from array_access.reg_model.array_access import array_access_cls
5
+ from array_access.sim.array_access import array_access_simulator_cls
5
6
  from array_access.lib.callbacks import NormalCallbackSet
6
7
 
7
- # dummy functions to demonstrate the class
8
- def read_addr_space(addr: int, width: int, accesswidth: int) -> int:
9
- """
10
- Callback to simulate the operation of the package, everytime the read is called, it return
11
- an integer value of 0
12
-
13
- Args:
14
- addr: Address to write to
15
- width: Width of the register in bits
16
- accesswidth: Minimum access width of the register in bits
17
-
18
- Returns:
19
- value inputted by the used
20
- """
21
- return int(0)
22
-
23
8
  if __name__ == '__main__':
24
9
 
10
+ # setup the simple simulator
11
+ sim = array_access_simulator_cls(0)
12
+
25
13
  # create an instance of the class
26
- regmodel = array_access_cls(callbacks=NormalCallbackSet(read_callback=read_addr_space))
14
+ regmodel = array_access_cls(callbacks=NormalCallbackSet(read_callback=sim.read))
27
15
 
28
16
  # access a entry in the 1D array
29
17
  print(regmodel.reg_array_1D[0].field_a.read())
@@ -4,29 +4,12 @@ A demonstration of using enumeration
4
4
  from enumerated_fields.lib import NormalCallbackSet
5
5
 
6
6
  from enumerated_fields.reg_model.enumerated_fields import enumerated_fields_cls as GPIO
7
-
8
- class HardwareSimulator:
9
- def __init__(self):
10
- # use a python dictionary to simulate the hardware
11
- self._address_space = {0x00: 0, 0x04: 0}
12
-
13
- def read(self, addr: int, width: int = 32, accesswidth: int = 32) -> int:
14
- """
15
- function to simulate a device read
16
- """
17
- return self._address_space[addr]
18
-
19
-
20
- def write(self, addr: int, data: int, width: int=32, accesswidth: int=32) -> None:
21
- """
22
- function to simulate a device read
23
- """
24
- self._address_space[addr] = data
7
+ from enumerated_fields.sim.enumerated_fields import enumerated_fields_simulator_cls as HardwareSimulator
25
8
 
26
9
  if __name__ == '__main__':
27
10
 
28
11
  # create an instance of the hardware simulator
29
- hw = HardwareSimulator()
12
+ hw = HardwareSimulator(0)
30
13
  # create an instance of the RAL with the callbacks directed at the hardware simulator
31
14
  gpio = GPIO(callbacks=NormalCallbackSet(read_callback=hw.read, write_callback=hw.write))
32
15
 
@@ -3,48 +3,18 @@ PeakRDL Python example to show the different methods to access the fields of a r
3
3
  """
4
4
  from optimised_access.reg_model.optimised_access import optimised_access_cls, \
5
5
  optimised_access_gpio_direction_enc_enumcls
6
+ from optimised_access.sim.optimised_access import optimised_access_simulator_cls
6
7
 
7
8
  from optimised_access.lib import NormalCallbackSet
8
9
 
9
- # dummy functions to demonstrate the class
10
- def read_addr_space(addr: int, width: int, accesswidth: int) -> int:
11
- """
12
- Callback to simulate the operation of the package, everytime the read is called, it return
13
- an integer value of 0
14
-
15
- Args:
16
- addr: Address to write to
17
- width: Width of the register in bits
18
- accesswidth: Minimum access width of the register in bits
19
-
20
- Returns:
21
- value inputted by the used
22
- """
23
- return int(0)
24
-
25
-
26
- def write_addr_space(addr: int, width: int, accesswidth: int, data: int) -> None:
27
- """
28
- Callback to simulate the operation of the package, everytime the read is called, it will
29
- request the user input the value to be read back.
30
-
31
- Args:
32
- addr: Address to write to
33
- width: Width of the register in bits
34
- accesswidth: Minimum access width of the register in bits
35
- data: value to be written to the register
36
-
37
- Returns:
38
- None
39
- """
40
- print(f'0x{data:X} written to 0x{addr:X}')
41
10
 
42
11
  if __name__ == '__main__':
43
12
 
44
13
  # create an instance of the address map with the simulated callback necessary to demonstrate
45
14
  # the example
46
- dut = optimised_access_cls(callbacks=NormalCallbackSet(read_callback=read_addr_space,
47
- write_callback=write_addr_space))
15
+ sim = optimised_access_simulator_cls(0)
16
+ dut = optimised_access_cls(callbacks=NormalCallbackSet(read_callback=sim.read,
17
+ write_callback=sim.write))
48
18
 
49
19
  # configure the GPIO 0 and GPIO 1 without affecting the state of the GPIO 2 and GPIO 3
50
20
  # configuration.
@@ -0,0 +1,42 @@
1
+ """
2
+ PeakRDL Python example to show the different methods to access the a register array
3
+ """
4
+ from array import array as Array
5
+
6
+ from optimised_array_access.reg_model.optimised_array_access import optimised_array_access_cls
7
+ from optimised_array_access.sim.optimised_array_access import optimised_array_access_simulator_cls
8
+
9
+ from optimised_array_access.lib import NormalCallbackSet
10
+
11
+
12
+
13
+ if __name__ == '__main__':
14
+
15
+ # create an instance of the address map with the simulated callback necessary to demonstrate
16
+ # the example
17
+ sim = optimised_array_access_simulator_cls(0)
18
+ dut = optimised_array_access_cls(callbacks=NormalCallbackSet(read_block_callback=sim.read_block,
19
+ write_block_callback=sim.write_block,
20
+ read_callback=sim.read,
21
+ write_callback=sim.write))
22
+
23
+ # the following will involve 2 reads and 2 writes (one per feild) for each register (8 in total)
24
+ for idx in range(len(dut.gpio_register)):
25
+ dut.gpio_register[idx].gpio_direction.write(dut.gpio_register[idx].gpio_direction.enum_cls.GPIO_OUT)
26
+ dut.gpio_register[idx].gpio_pullup.write(False)
27
+ # leave the drive strength untouched
28
+
29
+ # the following will involve 1 reads and 1 writes for each register (8 in total)
30
+ # also note the use of the register array iterator (so you don't need range and indexing)
31
+ for gpio_register in dut.gpio_register:
32
+ with gpio_register.single_read_modify_write() as reg:
33
+ reg.gpio_direction.write(reg.gpio_direction.enum_cls.GPIO_OUT)
34
+ reg.gpio_pullup.write(False)
35
+ # leave the drive strength untouched
36
+
37
+ # the following will do one block read and one block write for the same thing
38
+ with dut.gpio_register.single_read_modify_write() as reg_array:
39
+ for reg in reg_array:
40
+ reg.gpio_direction.write(reg.gpio_direction.enum_cls.GPIO_OUT)
41
+ reg.gpio_pullup.write(False)
42
+ # leave the drive strength untouched
@@ -0,0 +1,17 @@
1
+ import json
2
+ from typing import Union
3
+
4
+ from over_ridden_names.reg_model.over_ridden_names import over_ridden_names_cls
5
+ from over_ridden_names.lib import NormalCallbackSet
6
+ from over_ridden_names.sim_lib.dummy_callbacks import dummy_read
7
+
8
+ if __name__ == '__main__':
9
+
10
+ # create an instance of the class
11
+ over_ridden_names = over_ridden_names_cls(callbacks=NormalCallbackSet(read_callback=dummy_read))
12
+
13
+ # access the field value directly
14
+ print(over_ridden_names.overridden_reg_a.overridden_field_a.read())
15
+
16
+ # access the feild value using the original systemRDL names
17
+ print(over_ridden_names.get_child_by_system_rdl_name('reg_a').get_child_by_system_rdl_name('field_a').read())
@@ -18,6 +18,7 @@ addrmap mychip {
18
18
  sw=rw;
19
19
  hw=r;
20
20
  reset={GPIO_direction::dir_in}; };
21
+
21
22
  field GPIO_output_field_type {
22
23
  fieldwidth = 1;
23
24
  sw=rw;
@@ -27,12 +28,12 @@ addrmap mychip {
27
28
  name="GPIO Direction";
28
29
  desc="Register to set the direction of each GPIO pin";
29
30
  GPIO_direction_field_type PIN_0;
30
- } GPIO_dir @ 0x4;
31
+ } GPIO_dir;
31
32
 
32
33
  reg {
33
34
  name="GPIO Set State";
34
35
  desc="Register to set the state of a GPIO Pin";
35
36
  GPIO_output_field_type PIN_0;
36
- } GPIO_state @ 0x8;
37
+ } GPIO_state;
37
38
  } GPIO;
38
39
  };