write_cxxrtl: avoid undefined behavior on out-of-bounds memory access.
authorwhitequark <whitequark@whitequark.org>
Sat, 4 Apr 2020 22:53:46 +0000 (22:53 +0000)
committerwhitequark <whitequark@whitequark.org>
Thu, 9 Apr 2020 04:08:36 +0000 (04:08 +0000)
commit3376dcf37c02f10552f84a9602b0d05c8f77ba3a
tree9222bce4f9b7315e0ce4d5a607587e4c8a07ffde
parent5157691f0eca5c5312524483491309a7e07d9710
write_cxxrtl: avoid undefined behavior on out-of-bounds memory access.

After this commit, if NDEBUG is not defined, out-of-bounds accesses
cause assertion failures for reads and writes. If NDEBUG is defined,
out-of-bounds reads return zeroes, and out-of-bounds writes are
ignored.

This commit also adds support for memories that start with a non-zero
index (`Memory::start_offset` in RTLIL).
backends/cxxrtl/cxxrtl.cc
backends/cxxrtl/cxxrtl.h