Skip to content

Commit e606139

Browse files
authored
Merge pull request #90 from krcb197/fix_async_callback_naming
Fix async callback naming
2 parents 0e2820a + cefd09e commit e606139

11 files changed

Lines changed: 41 additions & 38 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ __pycache__/
5454

5555
# Vim swapfiles
5656
.*.sw[a-p]
57+
/example/overridden_names/over_ridden_names/
58+
/example/simulating_callbacks/mychip/
59+
/example/tranversing_address_map/chip_with_registers/

docs/generated_package.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Callback Set
207207
The callbacks are passed into the register abstraction layer using either:
208208

209209
* ``NormalCallbackSet`` for standard python function callbacks
210-
* ``AysncCallbackSet`` for async python function callbacks, these are called from the library using
210+
* ``AsyncCallbackSet`` for async python function callbacks, these are called from the library using
211211
``await``
212212

213213
Using the Register Abstraction Layer

src/peakrdl_python/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
Variables that describes the PeakRDL Python Package
33
"""
4-
__version__ = "0.4.0"
4+
__version__ = "0.4.1"

src/peakrdl_python/lib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .callbacks import WriteCallback
99
from .callbacks import WriteBlockCallback
1010
from .callbacks import NormalCallbackSet
11-
from .callbacks import AysncCallbackSet
11+
from .callbacks import AsyncCallbackSet
1212
from .callbacks import CallbackSet
1313

1414
from .base import AddressMap

src/peakrdl_python/lib/callbacks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def write_block_callback(self) -> Optional[WriteBlockCallback]:
157157
"""
158158
return self.__write_block_callback
159159

160-
class AysncCallbackSet:
160+
class AsyncCallbackSet:
161161
"""
162162
Class to hold a set of callbacks, this reduces the number of callback that need to be passed
163163
around
@@ -217,4 +217,4 @@ def write_block_callback(self) -> Optional[AsyncWriteBlockCallback]:
217217
"""
218218
return self.__write_block_callback
219219

220-
CallbackSet = Union[AysncCallbackSet, NormalCallbackSet]
220+
CallbackSet = Union[AsyncCallbackSet, NormalCallbackSet]

src/peakrdl_python/lib/memory.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from .base import Node, AddressMap, BaseArray, get_array_typecode
1010

11-
from .callbacks import CallbackSet, NormalCallbackSet, AysncCallbackSet
11+
from .callbacks import CallbackSet, NormalCallbackSet, AsyncCallbackSet
1212

1313
if TYPE_CHECKING:
1414
from .register import ReadableRegister, WritableRegister
@@ -371,7 +371,7 @@ class MemoryAsyncReadOnly(Memory, ABC):
371371

372372
# pylint: disable=too-many-arguments
373373
def __init__(self,
374-
callbacks: AysncCallbackSet,
374+
callbacks: AsyncCallbackSet,
375375
address: int,
376376
width: int,
377377
accesswidth: int,
@@ -380,7 +380,7 @@ def __init__(self,
380380
inst_name: str,
381381
parent: AddressMap):
382382

383-
if not isinstance(callbacks, AysncCallbackSet):
383+
if not isinstance(callbacks, AsyncCallbackSet):
384384
raise TypeError(f'callback set type is wrong, got {type(callbacks)}')
385385

386386
super().__init__(callbacks=callbacks,
@@ -394,9 +394,9 @@ def __init__(self,
394394

395395
# pylint: enable=too-many-arguments
396396
@property
397-
def _callbacks(self) -> AysncCallbackSet:
397+
def _callbacks(self) -> AsyncCallbackSet:
398398
# This cast is OK because the type was checked in the __init__
399-
return cast(AysncCallbackSet, super()._callbacks)
399+
return cast(AsyncCallbackSet, super()._callbacks)
400400

401401
async def read(self, start_entry: int, number_entries: int) -> Array:
402402
"""
@@ -480,7 +480,7 @@ class MemoryAsyncWriteOnly(Memory, ABC):
480480

481481
# pylint: disable=too-many-arguments
482482
def __init__(self,
483-
callbacks: AysncCallbackSet,
483+
callbacks: AsyncCallbackSet,
484484
address: int,
485485
width: int,
486486
accesswidth: int,
@@ -489,7 +489,7 @@ def __init__(self,
489489
inst_name: str,
490490
parent: AddressMap):
491491

492-
if not isinstance(callbacks, AysncCallbackSet):
492+
if not isinstance(callbacks, AsyncCallbackSet):
493493
raise TypeError(f'callback set type is wrong, got {type(callbacks)}')
494494

495495
super().__init__(callbacks=callbacks,
@@ -503,9 +503,9 @@ def __init__(self,
503503

504504
# pylint: enable=too-many-arguments
505505
@property
506-
def _callbacks(self) -> AysncCallbackSet:
506+
def _callbacks(self) -> AsyncCallbackSet:
507507
# This cast is OK because the type was checked in the __init__
508-
return cast(AysncCallbackSet, super()._callbacks)
508+
return cast(AsyncCallbackSet, super()._callbacks)
509509

510510
async def write(self, start_entry: int, data: Array) -> None:
511511
"""

src/peakrdl_python/lib/register.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from .base import Node, AddressMap, RegFile, BaseArray, get_array_typecode
1313
from .memory import Memory
14-
from .callbacks import CallbackSet, NormalCallbackSet, AysncCallbackSet
14+
from .callbacks import CallbackSet, NormalCallbackSet, AsyncCallbackSet
1515

1616
if TYPE_CHECKING:
1717
from .fields import FieldReadOnly, FieldWriteOnly, FieldReadWrite
@@ -404,15 +404,15 @@ class for an async read only register
404404

405405
# pylint: disable=too-many-arguments, duplicate-code
406406
def __init__(self,
407-
callbacks: AysncCallbackSet,
407+
callbacks: AsyncCallbackSet,
408408
address: int,
409409
width: int,
410410
accesswidth: int,
411411
logger_handle: str,
412412
inst_name: str,
413413
parent: Union[AddressMap, RegFile, Memory]):
414414

415-
if not isinstance(callbacks, AysncCallbackSet):
415+
if not isinstance(callbacks, AsyncCallbackSet):
416416
raise TypeError(f'callback set type is wrong, got {type(callbacks)}')
417417

418418
super().__init__(callbacks=callbacks,
@@ -425,9 +425,9 @@ def __init__(self,
425425
self.__register_state: int = 0
426426

427427
@property
428-
def _callbacks(self) -> AysncCallbackSet:
428+
def _callbacks(self) -> AsyncCallbackSet:
429429
# This cast is OK because the type was checked in the __init__
430-
return cast(AysncCallbackSet, super()._callbacks)
430+
return cast(AsyncCallbackSet, super()._callbacks)
431431

432432
# pylint: enable=too-many-arguments, duplicate-code
433433

@@ -502,15 +502,15 @@ class for an asynchronous write only register
502502

503503
# pylint: disable=too-many-arguments, duplicate-code
504504
def __init__(self,
505-
callbacks: AysncCallbackSet,
505+
callbacks: AsyncCallbackSet,
506506
address: int,
507507
width: int,
508508
accesswidth: int,
509509
logger_handle: str,
510510
inst_name: str,
511511
parent: Union[AddressMap, RegFile, Memory]):
512512

513-
if not isinstance(callbacks, AysncCallbackSet):
513+
if not isinstance(callbacks, AsyncCallbackSet):
514514
raise TypeError(f'callback set type is wrong, got {type(callbacks)}')
515515

516516
super().__init__(callbacks=callbacks,
@@ -520,9 +520,9 @@ def __init__(self,
520520
parent=parent, width=width, accesswidth=accesswidth)
521521

522522
@property
523-
def _callbacks(self) -> AysncCallbackSet:
523+
def _callbacks(self) -> AsyncCallbackSet:
524524
# This cast is OK because the type was checked in the __init__
525-
return cast(AysncCallbackSet, super()._callbacks)
525+
return cast(AsyncCallbackSet, super()._callbacks)
526526

527527
# pylint: enable=too-many-arguments, duplicate-code
528528

@@ -596,7 +596,7 @@ class for an async read and write only register
596596

597597
# pylint: disable=too-many-arguments, duplicate-code
598598
def __init__(self,
599-
callbacks: AysncCallbackSet,
599+
callbacks: AsyncCallbackSet,
600600
address: int,
601601
width: int,
602602
accesswidth: int,

src/peakrdl_python/templates/addrmap.py.jinja

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ from ..lib import ReadableRegisterArray, WritableRegisterArray
4444
from ..lib import FieldSizeProps, FieldMiscProps
4545

4646
{% if asyncoutput %}
47-
from ..lib import AysncCallbackSet
47+
from ..lib import AsyncCallbackSet
4848
{% else %}
4949
from ..lib import NormalCallbackSet
5050
{% endif %}
@@ -112,10 +112,10 @@ class {{get_fully_qualified_type_name(node)}}_cls(RegFile):
112112

113113
__slots__ : List[str] = [{%- for child_node in node.children(unroll=False) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{%- endfor %}]
114114

115-
{% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %}
115+
{% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %}
116116

117117
def __init__(self,
118-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %},
118+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %},
119119
address: int,
120120
logger_handle:str,
121121
inst_name:str,
@@ -191,7 +191,7 @@ class {{get_fully_qualified_type_name(node)}}_array_cls(RegFileArray):
191191
address: int,
192192
length: int,
193193
stride: int,
194-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %}):
194+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %}):
195195

196196
elements = tuple([{{get_fully_qualified_type_name(node)}}_cls(callbacks=callbacks,address=address+(index * stride),
197197
logger_handle=f'{logger_handle}.{inst_name}[{index:d}]',
@@ -217,7 +217,7 @@ class {{get_fully_qualified_type_name(node)}}_cls(AddressMap):
217217
__slots__ : List[str] = [{%- for child_node in node.children(unroll=False) -%}{%- if isinstance(child_node, systemrdlRegNode) or isinstance(child_node, systemrdlRegfileNode) or isinstance(child_node, systemrdlAddrmapNode) or isinstance(child_node, systemrdlMemNode) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{% endif %}{%- endfor %}]
218218

219219
def __init__(self,
220-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %},
220+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %},
221221
address:int {%- if node == top_node -%}={{top_node.absolute_address}}{%- endif -%},
222222
logger_handle:str {%- if node == top_node -%}='reg_model.{{top_node.get_path()}}'{%- endif -%},
223223
inst_name:str{%- if node == top_node -%}='{{node.inst_name}}'{%- endif -%},
@@ -300,7 +300,7 @@ class {{get_fully_qualified_type_name(node)}}_array_cls(AddressMapArray):
300300
address: int,
301301
length: int,
302302
stride: int,
303-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %}):
303+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %}):
304304

305305
elements = tuple([{{get_fully_qualified_type_name(node)}}_cls(callbacks=callbacks,address=address+(index * stride),
306306
logger_handle=f'{logger_handle}.{inst_name}[{index:d}]',
@@ -425,5 +425,5 @@ if __name__ == '__main__':
425425
print('write data:0x%X to address:0x%X'%(data, addr))
426426

427427
# create an instance of the class
428-
{{top_node.inst_name}} = {{get_fully_qualified_type_name(top_node)}}_cls(callbacks = {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %}(read_callback=read_addr_space,
428+
{{top_node.inst_name}} = {{get_fully_qualified_type_name(top_node)}}_cls(callbacks = {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %}(read_callback=read_addr_space,
429429
write_callback=write_addr_space))

src/peakrdl_python/templates/addrmap_memory.py.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class {{get_fully_qualified_type_name(node)}}_cls(Memory{% if asyncoutput %}Asyn
2020
__slots__ : List[str] = [{%- for child_node in node.children(unroll=False) -%}{%- if isinstance(child_node, systemrdlRegNode) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{% endif %}{%- endfor %}]
2121

2222
def __init__(self,
23-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %},
23+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %},
2424
address: int,
2525
logger_handle: str,
2626
inst_name: str,
@@ -95,7 +95,7 @@ class {{get_fully_qualified_type_name(node)}}_array_cls(Memory{% if asyncoutput
9595
address: int,
9696
length: int,
9797
stride: int,
98-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %}):
98+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %}):
9999

100100
elements = tuple([{{get_fully_qualified_type_name(node)}}_cls(callbacks=callbacks,address=address+(index * stride),
101101
logger_handle=f'{logger_handle}.{inst_name}[{index:d}]',

src/peakrdl_python/templates/addrmap_register.py.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class {{get_fully_qualified_type_name(node)}}_cls(Reg{% if asyncoutput %}Async{%
1616
__slots__ : List[str] = [{%- for child_node in node.children(unroll=False) -%}'__{{child_node.inst_name}}'{% if not loop.last %}, {% endif %}{%- endfor %}]
1717

1818
def __init__(self,
19-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %},
19+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %},
2020
address: int,
2121
logger_handle: str,
2222
inst_name: str,
@@ -197,7 +197,7 @@ class {{get_fully_qualified_type_name(node)}}_array_cls(Reg{% if asyncoutput %}A
197197
address: int,
198198
length: int,
199199
stride: int,
200-
callbacks: {% if asyncoutput %}AysncCallbackSet{% else %}NormalCallbackSet{% endif %}):
200+
callbacks: {% if asyncoutput %}AsyncCallbackSet{% else %}NormalCallbackSet{% endif %}):
201201

202202

203203
elements = tuple([{{get_fully_qualified_type_name(node)}}_cls(callbacks=callbacks,address=address+(index * stride),

0 commit comments

Comments
 (0)