How to obtain pixel data from file hex form for simulation?

Status
Not open for further replies.

win3y

Member level 1
Joined
Jul 10, 2007
Messages
39
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,542
For simulation, by using verilog how can I code the programme to obtain pixel data from file hex form. Plesea show me the books, syntax, etc...
Thank you very much!
 

Re: How to obtain pixel data from file hex form for simulati

win3y said:
For simulation, by using verilog how can I code the programme to obtain pixel data from file hex form. Plesea show me the books, syntax, etc...
Thank you very much!

Look for $readmemh in google. For custom file read you can also use $fscanf

HTH
Ajeetha, CVC
www.noveldv.com
 

    win3y

    Points: 2
    Helpful Answer Positive Rating
Re: How to obtain pixel data from file hex form for simulati

Here is an example:
initial
begin
$readmemb("mem.dat", mem, 0, totalbytes); //read from addres 0 to 15
for (ii= 0; ii<totalbytes+1; ii=ii+1) $display("mem[%0d] %d", ii, mem[ii]);
end

where mem.dat should have the following format
//Memory Data File
@0 0010_1101
@1 1000_0001
@2 1111_1110
@3 0001_0011
@4 0110_0111
@5 0010_1101
@6 0101_1101
@7 0101_0100
@8 0111_0001
@9 0001_0111
@A 0000_0011
@B 1100_1111
@C 0010_0111
@D 1011_0110
@E 1110_1100
@F 0000_1001

To see the full code:
http://www.vlsiip.com/verilog/rx_tb.v
Kr,
Avi
 

    win3y

    Points: 2
    Helpful Answer Positive Rating
Re: How to obtain pixel data from file hex form for simulati

Hi Avimit and Aj_Vlsi!
Your suggestion helped me so much! Now I really love you and our site .
I have some questions, help me pls!

+ What extension file I can get data from? (hex,xes... is OK?)
+ The simulator shows the error with file "mem.dat" as:

file .xes: (connvert from .bmp to .xes)

+ 10 00000000 FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB
+ 10 00000010 FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB
+ 10 00000020 FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB
+ 10 00000030 FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB
+ 10 00000040 FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB FB

I do not understand because I need to process a file data like a image file. Pls help me!
 

Re: How to obtain pixel data from file hex form for simulati

Send me your testbench, and I will try to find some time to see whats goin on?
Kr,
Avi
http://www.vlsiip.com
 

    win3y

    Points: 2
    Helpful Answer Positive Rating
Re: How to obtain pixel data from file hex form for simulati

avimit said:
Send me your testbench, and I will try to find some time to see whats goin on?
Kr,
Avi
http://www.vlsiip.com
Thank you for your support. Some above problems I have when I test a simple testbench. Maybe I'll need more your help later when I finish my testbench .
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…