How to find writing and reading wrong into or from the memory

In reply to Subbi Reddy:

 
int mem_aarray[*]; // associative array (AA) to be used as a verification memory 
// to compare with the DUT memory. Info for that comes from the interface 

input bit write, // memory write
    input bit read,  // memory read
    input bit[31:0] wdata, // data written to memory
    input bit[31:0]  addr,  // memory address -- small for simulation 
   
The reset clears the associative array used by the testbench 
if (reset_n==1'b0) mem_aarray.delete; // Clears AA elements