![]() |
|
|
|
#1 |
|
I've been playing around with reading binary data into a testbench. I
noticed a lot of people asking questions on the user group over the years, but didn't see a simple expample, so here's some code that might help: constant N : integer := 28671; --Number of bytes in file minus one subtype file_element is std_logic_vector(7 downto 0); type mem_array is array(N downto 0) of file_element; shared variable memory : mem_array; begin ---------------------------------------------------------------------------- -- This code reads a raw binary file one byte at a time. load_memory : process is type bit_vector_file is file of bit_vector; file vectors : bit_vector_file open read_mode is "calconst.bin"; variable next_vector : bit_vector (0 downto 0); variable actual_len : natural; variable index : integer := 0; begin while not endfile(vectors) loop read(vectors, next_vector, actual_len); if actual_len > next_vector'length then report "vector too long"; else memory(index) := conv_std_logic_vector(bit'pos(next_vector(0)), index := index + 1; end if; end loop; wait; end process load_memory; ----------------------------------------------------------------------------- Enjoy, Beanut Beanut |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help .... How to read a log file using c++... | EngSara | Software | 0 | 05-17-2008 06:10 PM |
| SONY DVD RW DW-G120A SOMETIMES FAILS...... | atlantic965 | DVD Video | 0 | 06-18-2006 10:36 PM |
| problems backing up dvds | Lawrence Traub | DVD Video | 11 | 09-27-2005 07:34 PM |
| Re: Ripping DVDs. Please answer the attached question. - Question.txt | Stan Brown | DVD Video | 19 | 02-09-2005 11:19 PM |
| Burn process failed - help! Log file posted for help troubleshooting | Michael Mason | DVD Video | 1 | 08-16-2004 09:24 PM |