Reading/Writing pure binary files

Discussion in 'VHDL' started by Daniel Gowans, May 27, 2004.

  1. I am looking for a way to read and write pure binary files in VHDL.
    I have a device that takes real-time snapshots of data streams in
    PCM (binary) format. I want to read this file, send it through a design
    to process it, and have the testbench spit the results back into a
    binary like the incoming. Any tips would be appreciated.

    Thanks!
     
    Daniel Gowans, May 27, 2004
    #1
    1. Advertising

  2. In article <Xns94F667078C658chlumpyahoocom@198.60.22.31>, Daniel Gowans wrote:
    > I am looking for a way to read and write pure binary files in VHDL.
    > I have a device that takes real-time snapshots of data streams in
    > PCM (binary) format. I want to read this file, send it through a design
    > to process it, and have the testbench spit the results back into a
    > binary like the incoming. Any tips would be appreciated.


    I'm doing some image processing design but using a slightly
    different approach: instead of VHDL code reading directly images
    (.png), I wrote a small script in Perl to convert these into
    files containing pixel values in ASCII, which are read into
    memory in the beginning. After simulation, there's another
    script to convert output ASCII values back into binary
    (or in my case to a file suitable for being read by Matlab).

    Maybe you could use similar approach, writing couple of
    converters.
     
    Tuukka Toivonen, May 27, 2004
    #2
    1. Advertising

  3. Daniel Gowans

    lsha Guest

    The following is a partial VHDL code that works for me (at least for
    reading raw data file).

    -- in the architecture declaration part
    -- raw DV file
    type intFileType is file of natural;
    file fileRawDV: intFileType open read_mode is "D:\video\DV\test.DV" ;

    -- in the procedure declaration part
    variable rawDV: natural; -- 32-bit raw DV from the file
    variable leData: std_logic_vector(31 downto 0); -- data from the file
    is little-endian

    -- in the procedure

    read(fileRawDV, rawDV);
    leData := conv_std_logic_vector(rawDV,32);

    Hope this helps.
     
    lsha, Jun 12, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Moree

    Reading and Writing to Binary Files

    Daniel Moree, Nov 23, 2004, in forum: C++
    Replies:
    9
    Views:
    1,022
    Jonathan Mcdougall
    Nov 24, 2004
  2. Todd Aspeotis
    Replies:
    3
    Views:
    498
    Kanenas
    May 30, 2005
  3. Replies:
    4
    Views:
    822
    Ben C
    Mar 29, 2008
  4. Ron Eggler

    writing binary file (ios::binary)

    Ron Eggler, Apr 25, 2008, in forum: C++
    Replies:
    9
    Views:
    966
    James Kanze
    Apr 28, 2008
  5. Patrick Maupin
    Replies:
    2
    Views:
    648
    Patrick Maupin
    Nov 27, 2009
Loading...

Share This Page