Skip to content

Commit

Permalink
Merge pull request #2270 from openXC7/warn-invalid-wordaddr
Browse files Browse the repository at this point in the history
print a human readable warning when encountering invalid word addresses
  • Loading branch information
mithro authored Jan 4, 2024
2 parents 31e117f + 50aa679 commit 248db01
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions prjxray/fasm_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
# SPDX-License-Identifier: ISC
import fasm
import sys

from prjxray import bitstream


Expand Down Expand Up @@ -56,6 +58,10 @@ def get_frames(self, sparse=False):
for (frame_addr, word_addr, bit_index), is_set in self.frames.items():
init_frame_at_address(frames, frame_addr)

if word_addr >= 101:
print(f"get_frames: invalid word address {word_addr} in line: {self.frames_line[(frame_addr, word_addr, bit_index)]}", file=sys.stderr)
if frame_addr not in frames:
print(f"get_frames: invalid frame address {frame_addr:x8}", file=sys.stderr)
if is_set:
frames[frame_addr][word_addr] |= 1 << bit_index

Expand All @@ -77,6 +83,9 @@ def frame_set(self, frame_addr, word_addr, bit_index, line):
assert bit_index is not None

key = (frame_addr, word_addr, bit_index)
if word_addr >= 101:
print(f"frame_set: invalid word address {word_addr} in line: {line}", file=sys.stderr)
return
if key in self.frames:
if self.frames[key] != 1:
raise FasmInconsistentBits(
Expand All @@ -96,6 +105,9 @@ def frame_clear(self, frame_addr, word_addr, bit_index, line):
assert bit_index is not None

key = (frame_addr, word_addr, bit_index)
if word_addr >= 101:
print(f"frame_clear: invalid word address {word_addr} in line: {line}", file=sys.stderr)
return
if key in self.frames:
if self.frames[key] != 0:
raise FasmInconsistentBits(
Expand All @@ -119,6 +131,7 @@ def update_segbit(bit):
frame_addr = bit.word_column
word_addr = bit.word_bit // bitstream.WORD_SIZE_BITS
bit_index = bit.word_bit % bitstream.WORD_SIZE_BITS

if bit.isset:
self.frame_set(frame_addr, word_addr, bit_index, line)
else:
Expand Down

0 comments on commit 248db01

Please sign in to comment.