OpenCores
URL https://opencores.org/ocsvn/ima_adpcm_encoder/ima_adpcm_encoder/trunk

Subversion Repositories ima_adpcm_encoder

[/] [ima_adpcm_encoder/] [trunk/] [WAV_header_rom.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 galland
----------------------------------------------------------------------------------
2
-- Company:       VISENGI S.L. (www.visengi.com)
3
-- Engineer:      Victor Lopez Lorenzo (victor.lopez (at) visengi (dot) com)
4
-- 
5 7 galland
-- Create Date:    19:34:36 04/November/2008
6 6 galland
-- Project Name:   IMA ADPCM Encoder
7
-- Tool versions:  Xilinx ISE 9.2i
8
-- Description: 
9
--
10
-- Description: This project features a full-hardware sound compressor using the well known algorithm IMA ADPCM.
11
--              The core acts as a slave WISHBONE device. The output is perfectly compatible with any sound player
12
--              with the IMA ADPCM codec (included by default in every Windows). Includes a testbench that takes
13
--              an uncompressed PCM 16 bits Mono WAV file and outputs an IMA ADPCM compressed WAV file.
14
--              Compression ratio is fixed for IMA-ADPCM, being 4:1.
15
--
16
--
17 7 galland
-- LICENSE TERMS: GNU GENERAL PUBLIC LICENSE Version 3
18
--
19
--     That is you may use it only in NON-COMMERCIAL projects.
20
--     You are only required to include in the copyrights/about section 
21
--     that your system contains a "IMA ADPCM Encoder (C) VISENGI S.L. under GPL license"
22 6 galland
--     This holds also in the case where you modify the core, as the resulting core
23
--     would be a derived work.
24
--     Also, we would like to know if you use this core in a project of yours, just an email will do.
25
--
26 7 galland
--    Please take good note of the disclaimer section of the GPL license, as we don't
27 6 galland
--    take any responsability for anything that this core does.
28
----------------------------------------------------------------------------------
29
 
30
--------------------------------------------------------------------------------
31
--    WAV HEADER ROM
32
--------------------------------------------------------------------------------
33
 
34
library IEEE;
35
use IEEE.STD_LOGIC_1164.all;
36
use ieee.numeric_std.all;
37
 
38
entity WAV_header_rom is
39
        generic (ROMADDR_W : integer := 6;
40
                                ROMDATA_W : integer := 8);
41
        port(
42
       addr0         : in  STD_LOGIC_VECTOR(ROMADDR_W-1 downto 0);
43
       clk           : in  STD_LOGIC;
44
       datao0        : out STD_LOGIC_VECTOR(ROMDATA_W-1 downto 0));
45
end WAV_header_rom;
46
 
47
architecture RTL of WAV_header_rom is
48
 
49
  type ROM_TYPE is array (0 to 2**ROMADDR_W-1)
50
            of STD_LOGIC_VECTOR(ROMDATA_W-1 downto 0);
51
  constant rom : ROM_TYPE :=
52
    (
53
-- Everything little endian:
54
-- 52 49 46 46 00 00 00 00 57 41 56 45 66 6D 74 20 14 00 00 00
55
--  R  I  F  F  x  x  x  x  W  A  V  E  f  m  t     x  x  x  x <-- these last are ok
56
--x             ^  ^  ^  ^ = change these for (file_size-8 or, simply, bytes that follow)
57
-- 11 00 <-- wFormatTag = IMA ADPCM
58
-- 01 00 <-- nChannels = 1 (Mono)
59
--x40 1F 00 00 <-- nSamplesPerSec = 8000
60
--xD7 0F 00 00 <-- nAvgBytesPerSec = 4055
61
--        (505 samples/block -> 8000 samples/sec -> 504/2 + 4 header bytes w. 1 sample = 256 bytes/block -> (8000/505)*256 = 4055 bytes/sec)
62
--        can be an approximate number and still be reproducible (i.e. nAvgBytesPerSec=nSamplesPerSec/512*256=nSamplesPerSec/2)
63
-- 00 01 <-- nBlockAlign = 100h = 256 bytes block size
64
-- 04 00 <-- wBitsPerSample = 4 bits
65
-- 02 00 <-- cbSize = size of extension = 2 bytes
66
-- F9 01 <-- wSamplesPerBlock = 505 samples/block
67
-- 
68
-- 66 61 63 74 04 00 00 00 00 00 00 00 64 61 74 61 00 00 00 00
69
--x f  a  c  t  x  x  x  x  x  x  x  x  d  a  t  a  x  x  x  x <-- change these for (file_size-60 or, simply, bytes that follow)
70
--x                         ^  ^  ^  ^ = # samples per channel in file
71
         "01010010",
72
         "01001001",
73
         "01000110",
74
         "01000110",
75
         "11111111",
76
         "11111111",
77
         "11111111",
78
         "01111111",
79
         "01010111",
80
         "01000001",
81
         "01010110",
82
         "01000101",
83
         "01100110",
84
         "01101101",
85
         "01110100",
86
         "00100000",
87
         "00010100",
88
         "00000000",
89
         "00000000",
90
         "00000000",
91
         "00010001",
92
         "00000000",
93
         "00000001",
94
         "00000000",
95
         "01000000",
96
         "00011111",
97
         "00000000",
98
         "00000000",
99
         "11010111",
100
         "00001111",
101
         "00000000",
102
         "00000000",
103
         "00000000",
104
         "00000001",
105
         "00000100",
106
         "00000000",
107
         "00000010",
108
         "00000000",
109
         "11111001",
110
         "00000001",
111
         "01100110",
112
         "01100001",
113
         "01100011",
114
         "01110100",
115
         "00000100",
116
         "00000000",
117
         "00000000",
118
         "00000000",
119
         "11111111",
120
         "11111111",
121
         "11111111",
122
         "01111111",
123
         "01100100",
124
         "01100001",
125
         "01110100",
126
         "01100001",
127
         "11111111",
128
         "11111111",
129
         "11111111",
130
         "01111111",
131
         --0 stuffing
132
         "00000000",
133
         "00000000",
134
         "00000000",
135
         "00000000");
136
  signal addr_reg0 : STD_LOGIC_VECTOR(ROMADDR_W-1 downto 0);
137
 
138
begin
139
 
140
  datao0 <= rom( TO_INTEGER(UNSIGNED(addr_reg0)) );
141
 
142
  process(clk)
143
  begin
144
   if clk = '1' and clk'event then
145
     addr_reg0 <= addr0;
146
   end if;
147
  end process;
148
 
149
end RTL;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.