Skip to content

Commit bfe6107

Browse files
committed
Handle the case where the hardware array sizes are larger than needed.
1 parent cc05bbb commit bfe6107

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/peakrdl_python/lib_test/async_reg_base_test_class.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,9 +1067,17 @@ async def __single_memory_write_test(
10671067
if self.legacy_block_access:
10681068
if not isinstance(mut, (MemoryAsyncWriteOnlyLegacy, MemoryAsyncReadWriteLegacy)):
10691069
raise TypeError(f'Memory should be legacy type but got {type(mut)}')
1070-
with self.assertRaises(OverflowError):
1071-
await mut.write(start_entry=0, data=Array(mut.array_typecode,
1072-
[mut.max_entry_value + 1]))
1070+
# depending the hardware array sizes the error may be at the point the array is
1071+
# constructed on internal
1072+
dummy_array = Array(mut.array_typecode,[0])
1073+
if dummy_array.itemsize > mut.width_in_bytes:
1074+
with self.assertRaises(ValueError):
1075+
await mut.write(start_entry=0, data=Array(mut.array_typecode,
1076+
[mut.max_entry_value + 1]))
1077+
else:
1078+
with self.assertRaises(OverflowError):
1079+
await mut.write(start_entry=0, data=Array(mut.array_typecode,
1080+
[mut.max_entry_value + 1]))
10731081
with self.assertRaises(OverflowError):
10741082
await mut.write(start_entry=0, data=Array(mut.array_typecode,
10751083
[-1]))

src/peakrdl_python/lib_test/base_reg_test_class.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,17 @@ def __single_memory_write_test(
10581058
if self.legacy_block_access:
10591059
if not isinstance(mut, (MemoryWriteOnlyLegacy, MemoryReadWriteLegacy)):
10601060
raise TypeError(f'Memory should be legacy type but got {type(mut)}')
1061-
with self.assertRaises(OverflowError):
1062-
mut.write(start_entry=0, data=Array(mut.array_typecode,
1063-
[mut.max_entry_value + 1]))
1061+
# depending the hardware array sizes the error may be at the point the array is
1062+
# constructed on internal
1063+
dummy_array = Array(mut.array_typecode, [0])
1064+
if dummy_array.itemsize > mut.width_in_bytes:
1065+
with self.assertRaises(ValueError):
1066+
mut.write(start_entry=0, data=Array(mut.array_typecode,
1067+
[mut.max_entry_value + 1]))
1068+
else:
1069+
with self.assertRaises(OverflowError):
1070+
mut.write(start_entry=0, data=Array(mut.array_typecode,
1071+
[mut.max_entry_value + 1]))
10641072
with self.assertRaises(OverflowError):
10651073
mut.write(start_entry=0, data=Array(mut.array_typecode,[-1]))
10661074
else:

0 commit comments

Comments
 (0)