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.

reading image file in verilog

Status
Not open for further replies.

nids

Newbie level 4
Joined
Oct 8, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,332
Hi all,

can anyone tell me how to read .raw image file in verilog ?

Thnaks,
 

Use readmemh/readmemb system functions to read from the .raw file. To confirm what is read is correct or simply see the hex contents of the raw file, use a hex editor where you can simply open the raw file and see the hex numbers.
 
  • Like
Reactions: nids

    nids

    Points: 2
    Helpful Answer Positive Rating
hi,

Thanks for reply :)
can you give me verilog file for the same?
how can i read and write that data?
i am doing project for motion estimation

thanks
 

you're welcome,
just go through how they're doing it here:


essentially they create a memory inside the verilog .
the width of the memory word is depending on your pixel format which you working with (RGB, YCbCr etc.).
 

Hi,

i have one text file which is the output of unsigned value of character of one .raw image file.
can you please tell me which function can i use to read that file?
i used "readmemh" but its only for hex value but i have unsigned character value.
please tell me how can i proceed to read that file?

Thnks,
 

say unsigned character is 'A', looking up the ASCII table, it will have a hex value. That is what will be read by the hex editor. If you want the character back, you'll just have to implement some script in perl or tcl where the conversion back to characters is done.

this seems like a rather roundabout method though, but the only one which to mind from my experience.
 
  • Like
Reactions: nids

    nids

    Points: 2
    Helpful Answer Positive Rating
can i do something like this?


//integer file, char,i;

// initial begin
// file = $fopen("cur_img.txt","rb");
// char =$fgetc(file);
// $display("output_data:");
// for (i=0; i < 10; i=i+1)
// $display("%d:%d",i,char);
// end
 

i don't understand what the for loop is for. just a little reorganization to the rest of the code and you should be good to go:

integer char = 32'b0;
while (char!=EOF) begin
char =$fgetc(file);
$display("%d", char);
end

check tho' how is EOF to be specified in the code.
 
  • Like
Reactions: nids

    nids

    Points: 2
    Helpful Answer Positive Rating
Hi

I did that but now it shows some error that undefined "EOF"
how can i solve that ?
i am using modelsimSE 6.4

thanks

- - - Updated - - -

this is my verilog code :

integer char = 32'b0;
integer file;
`define EOF 32'hffff_ffff

initial begin
file = $fopen("cur_img.txt","rb");
char =$fgetc(file);
while (char!=`EOF)
begin
char =$fgetc(file);
$display("%d", char);
end
end
endmodule


now it gives some interger value in output.
i have attached my .txt file.
it has many characters so i am wondering is my output is true or not?

Again thanks for quick response,
 

Attachments

  • cur_img.txt
    96.9 KB · Views: 76

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top