READING FROM MEMORY FILE

N

naveend

Guest
hi

i am reading a memory file burst.txt using $readmemh.
the memory file is 16(width)*800(depth)
i have a array in my testbench [15:0]burst[1:200]

depending upon one 2-bit i/ps signal i am reading diffrent location from
the memory file .

my code looks as following
reg [1:0] base; // input signal//
reg [15:0] burst[1:200]
case(base)
2'b00:
begin

$readmemh("burst.txt",burst,1,200);
end
2'b01:
begin
$readmemh("burst.txt",burst,201,400);
end
2'b10:
begin
$readmemh("burst.txt",burst,401,600);
end
2'b11:
begin
$readmemh("burst.txt",burst,601,800);
end
endcase

i am facing a problem is that when i/p base="00" initially then memory
file is read properely and array is updated..but when i change the i/p
base="01" or "10" or 11 then the array is not updated with new values of
memory...

regards
naveen
 
"naveend" <naveen_um@beceem.com> wrote in message news:<1a1cf5db459b47c8292176782c16ecae@localhost.talkaboutprogramming.com>...
depending upon one 2-bit i/ps signal i am reading diffrent location from
the memory file .
You can't do that. It always reads the entire file.

$readmemh("burst.txt",burst,201,400);
This does not read a different part of the file into your memory. It
reads the file into a different part of your memory. And since that
part of the memory does not exist (201:400 is outside the legal address
range of your memory) the result is lost.

Again, the addresses on $readmem are for reading a file into a specific
subset of your memory. They are not for reading a subset of the file
into your memory. You might be able to kludge something by starting
at a negative address, so that only a subset of the file falls into the
legal range of the memory, and the rest is written into out-of-range
portions and thus thrown away. It would be cleaner to put these into
separate input files.
 
hi
Thanks for the reply..
i have only one text file ..and the file is updated on the fly when the
i/ps are changing ....for each i/p 200 words are written ...so for
verification i cannot change the text file on the fly..so i took one text
file of 800 words for each i/p.. so for each i/p i need to read from
different address of the text file ...and assign to memory array which in
turn will be assigned to respective o/p..

how $fread differ from $readmem ...????

someone told me that for such conditions $fread is useful...but my
simulator NC-Verilog gives error if i use $fread...

Thanks
naveen
 

Welcome to EDABoard.com

Sponsor

Back
Top