Hi,
I have written system verilog code for reading data from an image file (800*600 - *.raw).
The file actually contains 800 * 600 * 3 bytes. But my code can only read upto almost half the data.
After that the read data seems to be "00".
Valuable suggestions for resolving this is appreciated..
My code is as follows.
Code Verilog - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//`define EOF 32'hFFFF_FFFF
//`define EOF \n
reg [ 7 : 0 ] data_byte;
class input_video_IF;
int count;
integer input_file, fread_return, output_file;
function new ( ) ;
input_file = $fopen ( "test_800.raw" , "r" ) ;
if ( input_file)
begin
$display ( "File OPENED" ) ;
end
else
begin
$display ( "File error" ) ;
end
output_file = $fopen ( "output_800.raw" , "w" ) ;
endfunction : new
task image_file_read( ) ;
count = 0 ;
//while (!$feof(input_file))
while ( count != 1440000 )
begin
fread_return = $fread ( data_byte, input_file) ;
count++;
$display ( "%d %h" , count, data_byte) ;
//$fwrite(output_file,data_byte);
end
$finish ;
$fclose ( input_file) ;
endtask : image_file_read
endclass
program Image_read_test;
int input_file;
input_video_IF In_IF = new ( ) ;
initial
In_IF.image_file_read( ) ;
endprogram
Last edited by a moderator: Aug 20, 2014