Fix bug introduced in 95b9a5a4 that broke registers with just 1 byte

This commit is contained in:
Dennis Potter 2021-11-02 23:28:37 -07:00
parent 9be761b53d
commit 85dc71919e
Signed by: Dennis
GPG Key ID: 186A8AD440942BAF
1 changed files with 16 additions and 4 deletions

View File

@ -219,9 +219,15 @@ class Register(Component):
bytes_read_format = []
bytes_read_sorted = sorted(bytes_read, reverse = True)
prev = msb = bytes_read_sorted[0]
for i in bytes_read_sorted[1:]:
try:
prev = msb = bytes_read_sorted[0]
except IndexError:
# Do nothing. bytes_written simply didn't exist
# The loop below will simply not be entered
pass
for i in bytes_read_sorted[0:]:
if prev - i > 1:
bytes_read_format.append(
f"|{wdgt_str}[{msb}:{prev}]" if msb > prev else f"{wdgt_str}[{msb}]")
@ -235,9 +241,15 @@ class Register(Component):
bytes_written_format = []
bytes_written_sorted = sorted(bytes_written, reverse = True)
prev = msb = bytes_written_sorted[0]
for i in bytes_written_sorted[1:]:
try:
prev = msb = bytes_written_sorted[0]
except IndexError:
# Do nothing. bytes_written simply didn't exist
# The loop below will simply not be entered
pass
for i in bytes_written_sorted[0:]:
if prev - i > 1:
bytes_written_format.append(
f"|{wdgt_str}[{msb}:{prev}]" if msb > prev else f"{wdgt_str}[{msb}]")