Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Image file read/write in verilog/system verilog

Status
Not open for further replies.

rockgarden333

Newbie level 1
Newbie level 1
Joined
Feb 15, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
12
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:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top