D
Dave Gowans
Guest
I've been having some problems using $fread in ModelSim (but the same also
happened in Veritak too).
I'm trying to read Ogg Vorbis files (2MB) from disk using $fread, but for
some reason the system only reads in the first 422 bytes of my file. It
reports no error and the memory I'm reading to is large enough for the whole
file.
Through testing with other files I've observed the following behaviour:
* ASCII files such as php and log files from Latex work fine (I loaded a
220K file fine)
* Another Ogg file loaded to a slightly different number of bytes (still
just over 400) - they used different encoders
* A pdf file loaded to a similar point (around 400 bytes)
* There is no 'common' sequence of characters (as far as I can see) in the
files that may be confusing the system
* Splitting the Ogg file into 400 byte chunks and loading each one after the
other works (but takes far too long!)
* I created a file made up of the first 400 bytes of my Ogg file repeated 10
times, followed by the rest of the Ogg file. The (approximately) 4000 bytes
at the beginning loaded correctly but the rest of the file did not
I'm sure there's something I'm missing here(!) but I just can't work out
what's going wrong. I'm using the following code to read in the data:
module file_reader(data, clk);
input clk;
output [7:0] data;
integer file;
reg [31:0] errno;
reg [31:0] i, j, k, l, m, n;
reg [7:0] data;
reg [80*8:1] file_name;
reg [7:0] variable[0:2000000];
reg [31:0] counter = 0;
reg [639:0] str;
reg [31:0] readto;
initial
begin
file_name = "F:/Cambridge/II/Project/Experimental/k.ogg";
readto = 0;
file = $fopen(file_name,"r");
i = $fread(variable, file);
$display("Loaded %0d entries \n", i);
errno = $ferror ( file, str );
$display("Error string: %s", str);
data = 32'd0;
readto = readto + i;
$display("Data loading completed! %d bytes loaded.", readto);
end
always@(posedge clk)
// Some other code...
endmodule
I'd really appreciate any advice anyone can give, or some alternate code
that will load the file correctly.
Cheers
Dave
happened in Veritak too).
I'm trying to read Ogg Vorbis files (2MB) from disk using $fread, but for
some reason the system only reads in the first 422 bytes of my file. It
reports no error and the memory I'm reading to is large enough for the whole
file.
Through testing with other files I've observed the following behaviour:
* ASCII files such as php and log files from Latex work fine (I loaded a
220K file fine)
* Another Ogg file loaded to a slightly different number of bytes (still
just over 400) - they used different encoders
* A pdf file loaded to a similar point (around 400 bytes)
* There is no 'common' sequence of characters (as far as I can see) in the
files that may be confusing the system
* Splitting the Ogg file into 400 byte chunks and loading each one after the
other works (but takes far too long!)
* I created a file made up of the first 400 bytes of my Ogg file repeated 10
times, followed by the rest of the Ogg file. The (approximately) 4000 bytes
at the beginning loaded correctly but the rest of the file did not
I'm sure there's something I'm missing here(!) but I just can't work out
what's going wrong. I'm using the following code to read in the data:
module file_reader(data, clk);
input clk;
output [7:0] data;
integer file;
reg [31:0] errno;
reg [31:0] i, j, k, l, m, n;
reg [7:0] data;
reg [80*8:1] file_name;
reg [7:0] variable[0:2000000];
reg [31:0] counter = 0;
reg [639:0] str;
reg [31:0] readto;
initial
begin
file_name = "F:/Cambridge/II/Project/Experimental/k.ogg";
readto = 0;
file = $fopen(file_name,"r");
i = $fread(variable, file);
$display("Loaded %0d entries \n", i);
errno = $ferror ( file, str );
$display("Error string: %s", str);
data = 32'd0;
readto = readto + i;
$display("Data loading completed! %d bytes loaded.", readto);
end
always@(posedge clk)
// Some other code...
endmodule
I'd really appreciate any advice anyone can give, or some alternate code
that will load the file correctly.
Cheers
Dave