From 4ca35ca18cf990d0dc9d0e7f7ad5c3ab52996066 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 8 Nov 2024 10:29:07 +0100 Subject: [PATCH] fpga: aps6404l device model: Print message instead of failing for out of bounds accesses --- fpga/hdl/device_models/aps6404l.vhd | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fpga/hdl/device_models/aps6404l.vhd b/fpga/hdl/device_models/aps6404l.vhd index e22b976..0ad48a8 100644 --- a/fpga/hdl/device_models/aps6404l.vhd +++ b/fpga/hdl/device_models/aps6404l.vhd @@ -130,8 +130,13 @@ begin print(" Addr: " & to_hstring(bytes(1)) & to_hstring(bytes(2)) & to_hstring(bytes(3))); addr := to_integer(unsigned(std_logic_vector'(bytes(1), bytes(2), bytes(3)))); elsif bytecnt > 4 then - dout := mem(addr); - print(" Read " & integer'image(addr) & ": " & to_hstring(mem(addr))); + if addr < SIZE then + dout := mem(addr); + print(" Read " & integer'image(addr) & ": " & to_hstring(mem(addr))); + else + dout := (others => 'X'); + print(" Read " & integer'image(addr) & ": OUT-OF-BOUNDS"); + end if; addr := addr + 1; end if; @@ -141,8 +146,12 @@ begin addr := to_integer(unsigned(std_logic_vector'(bytes(1), bytes(2), bytes(3)))); elsif bytecnt > 3 then print(" Write " & integer'image(addr) & ": " & to_hstring(bytes(bytecnt))); - mem(addr) := bytes(bytecnt); - addr := addr + 1; + if (addr < SIZE) then + mem(addr) := bytes(bytecnt); + else + print(" Error: OUT OF BOUNDS access! Ignoring write."); + end if; + addr := addr + 1; end if; when COMPLETE =>