You’ve forked off two threads in parallel with no timing. There’s nothing to synchronize execution of the two loops, so the simulator is free to execute the read loop first before the wright loop ever executes.
To get this to work you need to introduce a clock or some sort of delay so that the write happens before the read.
In reply to kangrh007:
That will not work. The read() task would only read the last addr.
Yes it wont work, but even if I am providing some sort of delay in between write and read task , then also it is reading last address only and read value is x.