|
| 1 | +""" |
| 2 | +peakrdl-python is a tool to generate Python Register Access Layer (RAL) from SystemRDL |
| 3 | +Copyright (C) 2021 - 2025 |
| 4 | +
|
| 5 | +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 |
| 8 | +the License, or (at your option) any later version. |
| 9 | +
|
| 10 | +This program is distributed in the hope that it will be useful, |
| 11 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +GNU Lesser General Public License for more details. |
| 14 | +
|
| 15 | +You should have received a copy of the GNU Lesser General Public License |
| 16 | +along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +
|
| 18 | +This package is intended to distributed as part of automatically generated code by the PeakRDL |
| 19 | +Python tool. It provide the base class for the autogenerated tests |
| 20 | +""" |
| 21 | +# this module is very similar to the non-async version, a lot of code has been put into common |
| 22 | +# methods but it did not make sense to do everything as it would destroy readability |
| 23 | +# pylint:disable=duplicate-code |
| 24 | + |
| 25 | +import unittest |
| 26 | +from abc import ABC, abstractmethod |
| 27 | + |
| 28 | +from ._common_base_test_class import CommonTestBase |
| 29 | + |
| 30 | +class AsyncLibTestCommon(unittest.IsolatedAsyncioTestCase, CommonTestBase, ABC): |
| 31 | + """ |
| 32 | + Base Test class for the autogenerated register test when in async mode |
| 33 | + """ |
| 34 | + |
| 35 | + # The following may look odd by a second layer of indirection is required to effectively patch |
| 36 | + # the read and write within tests |
| 37 | + |
| 38 | + # pylint:disable=missing-function-docstring |
| 39 | + |
| 40 | + async def outer_read_callback(self, addr: int, width: int, accesswidth: int) -> int: |
| 41 | + return await self.read_callback(addr=addr, |
| 42 | + width=width, |
| 43 | + accesswidth=accesswidth) |
| 44 | + |
| 45 | + @abstractmethod |
| 46 | + async def read_callback(self, addr: int, width: int, accesswidth: int) -> int: |
| 47 | + ... |
| 48 | + |
| 49 | + async def outer_write_callback(self, addr: int, |
| 50 | + width: int, accesswidth: int, |
| 51 | + data: int) -> None: |
| 52 | + return await self.write_callback(addr=addr, |
| 53 | + width=width, |
| 54 | + accesswidth=accesswidth, |
| 55 | + data=data) |
| 56 | + |
| 57 | + @abstractmethod |
| 58 | + async def write_callback(self, addr: int, width: int, accesswidth: int, data: int) -> None: |
| 59 | + ... |
| 60 | + |
| 61 | + # pylint:enable=missing-function-docstring |
0 commit comments