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 =>