Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reading wave file

181 views
Skip to first unread message

Sasi

unread,
Mar 1, 2003, 9:06:51 PM3/1/03
to
Hi,
Is there any easy way to read wav file as it is in VHDL?
I am trying to write a tb to test fir filter.
Thanks in advance,
Sasi

David Jones

unread,
Mar 2, 2003, 7:43:30 AM3/2/03
to
In article <8a2eb34e.03030...@posting.google.com>,

Google for "WAV file format". The first link describes the file
format well enough to write a reader.

You can read from a binary file by declaring:

type CHAR_FILE is file of CHARACTER;

and using FILE_OPEN, READ, and ENDFILE to perform the reading.

Mikael

unread,
Mar 3, 2003, 3:35:18 PM3/3/03
to
here are programs which convert wav to txt (and txt -> wav) format which you
can simply read in vhdl:
http://lotnisko.net/~mikel/prefmt.exe
http://lotnisko.net/~mikel/postfmt.exe

and some vhdl sources using it to test FIR filter
http://lotnisko.net/~mikel/sources.zip

Użytkownik "David Jones" <d...@inode.org> napisał w wiadomości
news:S%m8a.31$KJ3....@news20.bellglobal.com...

--
Serwis Usenet w portalu Gazeta.pl -> http://www.gazeta.pl/usenet/

Sasi

unread,
Mar 4, 2003, 10:55:13 AM3/4/03
to
Thanks a lot David & Mikael.
I got it working
Thanks
Sasi

Hint for anyone seeking the same information:
This is a example. I have not yet completed the full testbench.
Hope this will give you a idea.....

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.numeric_std.all;
use std.textio.all;

entity test is
end test;

architecture beh of test is

begin

process
type CHAR_FILE is file of character;
file in_file,out_file : CHAR_FILE;
variable fstat,fstat1 : file_open_status;
variable ch : character:= 'a';
variable data : std_logic_vector (15 downto 0);
variable data_size : integer:= 44128 ;


begin
FILE_OPEN(fstat,in_file,"s1.wav",READ_MODE);
FILE_OPEN(fstat1,out_file,"s2.wav",WRITE_MODE);
while not endfile(in_file) loop
read(in_file,ch);

-- this is convert the character to std_logic_vector
data := std_logic_vector(to_unsigned(character'pos(ch),16));

write(out_file,ch);
end loop;
FILE_CLOSE(in_file);
FILE_CLOSE(out_file);
wait for 10 ns;
end process;

end beh;

0 new messages