Skip to content

Commit

Permalink
Merge pull request #87 from krcb197/async_enhancement_merge
Browse files Browse the repository at this point in the history
Bring in the new async callback methods
significant enhancements to the typing and static typing checks
  • Loading branch information
krcb197 authored Feb 19, 2023
2 parents c84c3de + 4e42006 commit 0e2820a
Show file tree
Hide file tree
Showing 39 changed files with 2,666 additions and 8,397 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ 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
python generate_testcases.py
mypy testcase_output/raw --config-file=tests/.mypy.ini
# autopep8 is moving some of the #ignore statements around so it no longer passes mypy
# mypy testcase_output/autopep8 --config-file=tests/.mypy.ini
mypy testcase_output --config-file=tests/.mypy.ini
# 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
pytest testcase_output/raw
pytest testcase_output/autopep8
pytest testcase_output
- name: Backward Compatibility Test
run: |
Expand All @@ -106,6 +104,8 @@ jobs:
pytest peakrdl_out/raw
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/autopep8/ --autoformat
pytest peakrdl_out/autopep8
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw_async/ --async
pytest peakrdl_out/raw_async
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/no_test/ --skip_test_case_generation
Expand Down
55 changes: 31 additions & 24 deletions docs/generated_package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,103 +29,103 @@ The Register Model is built from the following classes
Address Maps
^^^^^^^^^^^^

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

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

Register Files
^^^^^^^^^^^^^^

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

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

Memories
^^^^^^^^

.. autoclass:: peakrdl_python.templates.peakrdl_python.memory.MemoryReadOnly
.. autoclass:: peakrdl_python.lib.memory.MemoryReadOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.memory.MemoryWriteOnly
.. autoclass:: peakrdl_python.lib.memory.MemoryWriteOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.memory.MemoryReadWrite
.. autoclass:: peakrdl_python.lib.memory.MemoryReadWrite
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.memory.MemoryReadOnlyArray
.. autoclass:: peakrdl_python.lib.memory.MemoryReadOnlyArray
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.memory.MemoryWriteOnlyArray
.. autoclass:: peakrdl_python.lib.memory.MemoryWriteOnlyArray
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.memory.MemoryReadWriteArray
.. autoclass:: peakrdl_python.lib.memory.MemoryReadWriteArray
:members:
:inherited-members:

Registers
^^^^^^^^^

.. autoclass:: peakrdl_python.templates.peakrdl_python.register.RegReadOnly
.. autoclass:: peakrdl_python.lib.register.RegReadOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.register.RegWriteOnly
.. autoclass:: peakrdl_python.lib.register.RegWriteOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.register.RegReadWrite
.. autoclass:: peakrdl_python.lib.register.RegReadWrite
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.register.RegReadOnlyArray
.. autoclass:: peakrdl_python.lib.register.RegReadOnlyArray
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.register.RegWriteOnlyArray
.. autoclass:: peakrdl_python.lib.register.RegWriteOnlyArray
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.register.RegReadWriteArray
.. autoclass:: peakrdl_python.lib.register.RegReadWriteArray
:members:
:inherited-members:

Register Fields
^^^^^^^^^^^^^^^

.. autoclass:: peakrdl_python.templates.peakrdl_python.fields.FieldReadOnly
.. autoclass:: peakrdl_python.lib.fields.FieldReadOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.fields.FieldWriteOnly
.. autoclass:: peakrdl_python.lib.fields.FieldWriteOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.fields.FieldReadWrite
.. autoclass:: peakrdl_python.lib.fields.FieldReadWrite
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.fields.FieldEnumReadOnly
.. autoclass:: peakrdl_python.lib.fields.FieldEnumReadOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.fields.FieldEnumWriteOnly
.. autoclass:: peakrdl_python.lib.fields.FieldEnumWriteOnly
:members:
:inherited-members:

.. autoclass:: peakrdl_python.templates.peakrdl_python.fields.FieldEnumReadWrite
.. autoclass:: peakrdl_python.lib.fields.FieldEnumReadWrite
:members:
:inherited-members:

Expand Down Expand Up @@ -176,7 +176,7 @@ access layer package so that it can be used from the console:
assert isinstance(accesswidth, int)
return input('value to read from address:0x%X' % addr)
def write_addr_space(addr: int, width: int, accesswidth: int, data: int) -> NoReturn:
def write_addr_space(addr: int, width: int, accesswidth: int, data: int) -> None:
"""
Callback to simulate the operation of the package, everytime the read is called, it will
request the user input the value to be read back.
Expand All @@ -198,10 +198,17 @@ access layer package so that it can be used from the console:
In a real system these call backs will be connected to a driver.

In addition there is also an option to use ``async`` callbacks if the package is built
``asyncoutput`` set to True.

Callback Set
------------

The callbacks are passed into the register abstraction layer using a ``CallbackSet``.
The callbacks are passed into the register abstraction layer using either:

* ``NormalCallbackSet`` for standard python function callbacks
* ``AysncCallbackSet`` for async python function callbacks, these are called from the library using
``await``

Using the Register Abstraction Layer
====================================
Expand Down
6 changes: 3 additions & 3 deletions example/optimised_access/optimised_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from optimised_access.reg_model.optimised_access import optimised_access_cls, \
optimised_access_gpio_direction_enc_enumcls

from optimised_access.lib import CallbackSet
from optimised_access.lib import NormalCallbackSet

# dummy functions to demonstrate the class
def read_addr_space(addr: int, width: int, accesswidth: int) -> int:
Expand Down Expand Up @@ -43,8 +43,8 @@ def write_addr_space(addr: int, width: int, accesswidth: int, data: int) -> None

# create an instance of the address map with the simulated callback necessary to demonstrate
# the example
dut = optimised_access_cls(callbacks=CallbackSet(read_callback=read_addr_space,
write_callback=write_addr_space))
dut = optimised_access_cls(callbacks=NormalCallbackSet(read_callback=read_addr_space,
write_callback=write_addr_space))

# configure the GPIO 0 and GPIO 1 without affecting the state of the GPIO 2 and GPIO 3
# configuration.
Expand Down
4 changes: 2 additions & 2 deletions example/overridden_names/over_ridden_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Union

from over_ridden_names.reg_model.over_ridden_names import over_ridden_names_cls
from over_ridden_names.lib import CallbackSet
from over_ridden_names.lib import NormalCallbackSet

# dummy functions to demonstrate the class
def read_addr_space(addr: int, width: int, accesswidth: int) -> int:
Expand All @@ -23,7 +23,7 @@ def read_addr_space(addr: int, width: int, accesswidth: int) -> int:
if __name__ == '__main__':

# create an instance of the class
over_ridden_names = over_ridden_names_cls(callbacks=CallbackSet(read_callback=read_addr_space))
over_ridden_names = over_ridden_names_cls(callbacks=NormalCallbackSet(read_callback=read_addr_space))

# access the field value directly
print(over_ridden_names.overridden_reg_a.overridden_field_a.read())
Expand Down
6 changes: 3 additions & 3 deletions example/simulating_callbacks/flashing_the_LED.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tkinter as tk

from mychip.reg_model.mychip import mychip_cls
from mychip.lib import CallbackSet
from mychip.lib import NormalCallbackSet

class ChipSim:

Expand Down Expand Up @@ -128,8 +128,8 @@ def write_call_back(addr: int, width: int, accesswidth: int, data: int):
data=data)

# create a callback set for the callbacks
callbacks = CallbackSet(read_callback=read_call_back,
write_callback=write_call_back)
callbacks = NormalCallbackSet(read_callback=read_call_back,
write_callback=write_call_back)

# created an instance of the register model and connect the callbacks to the simulator
mychip = mychip_cls(callbacks=callbacks)
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0e2820a

Please sign in to comment.