D
Dave Gowans
Guest
Hi
I've been trying to read a binary file into memory using the $fread system
task but on both ModelSim and Veritak simulators I get an error telling me
the second parameter/argument is wrong. I can't find any documentation that
specifies exactly how $fread should be used, though, and experimentation has
got me nowhere!
I'm currently using the follwoing code:
`define EOF 32'HFFFF_FFFF
`define MEM_SIZE 200_000
module load_mem;
integer file, i;
reg [7:0] mem[0:`MEM_SIZE];
reg [80*8:1] file_name;
initial
begin
file_name = "data.bin";
file = $fopen(file_name);
i = $fread(file, mem[0]);
$display("Loaded %0d entries \n", i);
// i = $fclose(file);
$stop;
end
endmodule // load_mem
and Veritak gives me the error:
VPI ERROR $fread: invalid second parameter (must be variable).
Loaded 0 entries
I'd appreciate any help anyone could give (or any working $fread code I
could take a look at).
Cheers
Dave
I've been trying to read a binary file into memory using the $fread system
task but on both ModelSim and Veritak simulators I get an error telling me
the second parameter/argument is wrong. I can't find any documentation that
specifies exactly how $fread should be used, though, and experimentation has
got me nowhere!
I'm currently using the follwoing code:
`define EOF 32'HFFFF_FFFF
`define MEM_SIZE 200_000
module load_mem;
integer file, i;
reg [7:0] mem[0:`MEM_SIZE];
reg [80*8:1] file_name;
initial
begin
file_name = "data.bin";
file = $fopen(file_name);
i = $fread(file, mem[0]);
$display("Loaded %0d entries \n", i);
// i = $fclose(file);
$stop;
end
endmodule // load_mem
and Veritak gives me the error:
VPI ERROR $fread: invalid second parameter (must be variable).
Loaded 0 entries
I'd appreciate any help anyone could give (or any working $fread code I
could take a look at).
Cheers
Dave