On rising_edge(clk)
both ram
and addr_reg
are updated with the new contents. The effect of this updated contents is visible right after (a delta cycle) the rising edge of clk
through the combinatorial q <= ram(addr_reg)
, which will shown the new values immediately.
So you are reading the value that we just wrote, namely data. The signals for this case are shown below.