Formatting memory input file

Any inputs/ideas on how to divide the below input file based on wr_data width (WR_DATA_WIDTH =64/72/32), the below file shows the wr_data starting at memory address 2 , BUT the data has to be divided based on the WR_DATA_WIDTH parameter and after that output few UVM memory calls to write to the address (offset calculated from the data_width)…

Input file: readmemh format file

@2
feef25fffff557edddcabdcbaaff7edddcabdcbaafffffff557eddcbaaff7edddcabdcbaafffffff557eddcbaaff7edddcabdcbaafffffff557edfeef25fffff557edddcabdcbaaff7edddca

Output should be below calls, mem.write (address,data) assuming WR_DATA_WIDTH =64

mem.write (2,feef25fffff557ed)
mem.write (3,ddcabdcbaaff7edd)

In reply to n347:

There a two ways I can think of to accomplish this. You can use $readmemh to read the file into a fixed width memory. You would know which addresses were not written to because they would still be X’s. Or you could parse the file yourself with $fscanf.

Either way you will wind up with a very large word (I’m not going to count the bits) and you’ll have to use a for loop to select the bits from the word

logic [0:big_word_size] wr_data];

for (int i=0;i*WR_DATA_SIZE<big_word_size;i++)
    mem.write(starting_address+i,wr_data[i*WR_DATA_SIZE+:WR_DATA_SIZE]);