In SystemVerilog, what happens when an array is accessed with an out-of-b…
In SystemVerilog, what happens when an array is accessed with an out-of-bounds index?
Model answer
A read returns the default value of the element type. The access does not corrupt memory, and a tool may report a warning. 4-state element (logic, reg, integer): x 2-state element (int, bit, byte): 0 string: empty string class handle: null A write to an out-of-bounds index is ignored. The same rules apply to an index containing x or z. There are two related cases: Associative array: reading a nonexistent entry returns the default value, and writing creates the entry. Queue: an invalid read returns the default value, and an invalid write is ignored.