Problem reading binary chunks from file

Joined
Jul 12, 2010
Messages
2
Reaction score
0
I just want to..lets say read byte by byte (7 downto 0) chunks from binary file.

Once i read them, i want to put them in big array of bytes. Here is how i do it:

Code:
    -- Reading image data from the file and putting it into array
    read_to_memory: process (startread)

    subtype word is std_logic_vector(7 downto 0);
    type storage_array is
    array (natural range 0 to 9) of word;

    variable storage : storage_array;
    variable index : natural;

    type load_file_type is file of word;
    file load_file : load_file_type open read_mode is "mem.dat";
    begin



    index := 0;



if  startread = '0' then

    for i in 0 to 9 loop

    read(load_file, storage(i)); 

    index := index + 1;

    end loop;

else

    pixelcolor <= storage(0);


end if;





    end process read_to_memory;

so as u see from the code, what i do is just read 10 chunks from binary file, when startread is LOW, and once it changes to HIGH, i just display the first chunk out of the array.

Now, functionally it seems to work...however i get weird thing in a waveform of modelsim.

Check the attached picture.

You see ?(103) there? so it is the correct byte which is in the file... BUT, i supposed to see it normally not in such a weird way in the waveform... so it seems like it does the job, but for some reason not displayed correctly there..

it shows weird symbols.. and when i change display Radix to Hex, or Dec it displays X'es...

any ideas?

thanks!
 

Attachments

  • Clipboard01.jpg
    Clipboard01.jpg
    246.2 KB · Views: 245

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top