Memory length

Hey all, I hope you’re doing well !

int addr_width=32
int mem_len = (2**addr_width)-1;

I created a memory :

bit [7:0] mem [mem_len :0]

when i write a data into the mem, i make uvm_info to dispaly mem content, no data mem dipalys 0 meaning that the write opeartion didn’t succseed.
i tried to lower addr_width(addr_width-4), consequently mem_len is reduced and it worked
how can i fix the problem for d_width=32 since my addr width is 32 ? and why data doesnt get written to mem when addr width is 32 ?
P.S : when i make addr_width=30, i get the error, Memeory too large

In reply to abdelaali_21:

You need to show some more code as we cannot reproduce anything you are saying. You are not allowed to declare the sized of a fixed array with another variable.