-
Notifications
You must be signed in to change notification settings - Fork 4
/
vu_meter.vhd.bak
333 lines (252 loc) · 7.24 KB
/
vu_meter.vhd.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity DE2_Audio_Example is
port (
CLOCK_50 : in std_logic;
SW : in std_logic_vector(3 downto 0);
KEY : in std_logic_vector(3 downto 0);
AUD_ADCDAT : inout std_logic;
AUD_BCLK : inout std_logic;
AUD_ADCLRCK : inout std_logic;
AUD_DACLRCK : inout std_logic;
I2C_SDAT : inout std_logic;
AUD_XCK : out std_logic;
AUD_DACDAT : out std_logic;
I2C_SCLK : out std_logic;
FPGA_CLK_B_N : INOUT STD_LOGIC;
FPGA_CLK_B_P : INOUT STD_LOGIC;
FPGA_CLK_A_N : INOUT STD_LOGIC;
FPGA_CLK_A_P : INOUT STD_LOGIC;
ADA_D : IN STD_LOGIC_VECTOR(13 DOWNTO 0);
ADB_D : IN STD_LOGIC_VECTOR(13 DOWNTO 0);
ADA_DCO : IN STD_LOGIC;
ADB_DCO : IN STD_LOGIC;
ADA_OE : OUT STD_LOGIC;
ADB_OE : OUT STD_LOGIC;
ADA_OR : IN STD_LOGIC;
ADB_OR : IN STD_LOGIC;
AD_SCLK : INOUT STD_LOGIC;
AD_SDIO : INOUT STD_LOGIC;
ADA_SPI_CS : OUT STD_LOGIC;
ADB_SPI_CS : OUT STD_LOGIC;
DA : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
DB : OUT STD_LOGIC_VECTOR(13 DOWNTO 0)
);
end entity DE2_Audio_Example;
architecture rtl of DE2_Audio_Example is
component avconf is
port (
I2C_SCLK : out std_logic;
I2C_SDAT : inout std_logic;
CLOCK_50 : in std_logic;
reset : in std_logic
);
end component avconf;
component Audio_Controller is
-- generic (
-- AUDIO_DATA_WIDTH
-- BIT_COUNTER_INIT
-- );
port (
-- // Inputs
CLOCK_50 : in std_logic;
reset : in std_logic;
clear_audio_in_memory : in std_logic;
read_audio_in : in std_logic;
clear_audio_out_memory : in std_logic;
left_channel_audio_out : in std_logic_vector(32 downto 1);
right_channel_audio_out : in std_logic_vector(32 downto 1);
write_audio_out : in std_logic;
AUD_ADCDAT : in std_logic;
-- // Bidirectionals
AUD_BCLK : inout std_logic;
AUD_ADCLRCK : inout std_logic;
AUD_DACLRCK : inout std_logic;
-- // Outputs
audio_in_available : out std_logic;
left_channel_audio_in : out std_logic_vector(32 downto 1);
right_channel_audio_in : out std_logic_vector(32 downto 1);
audio_out_allowed : out std_logic;
AUD_XCK : out std_logic;
AUD_DACDAT : out std_logic
);
end component Audio_Controller;
constant PHASE_WIDTH : integer := 10;
constant AMPL_WIDTH : integer := 16;
constant ftw_width : integer := 32;
component fifo IS
PORT
(
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
rdreq : IN STD_LOGIC ;
wrreq : IN STD_LOGIC ;
empty : OUT STD_LOGIC ;
full : OUT STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
usedw : OUT STD_LOGIC_VECTOR (1 DOWNTO 0)
);
END component fifo;
component echo is
generic (
DELAY : natural := 4800
);
port (
clk : in std_logic;
ce : in std_logic;
data_in : in std_logic_vector(31 downto 0);
data_out : out std_logic_vector(31 downto 0)
);
end component echo;
component gen48khz is
generic (
CLKCOUNTER : natural := 1041
);
port (
clock : in std_logic;
reset_n : in std_logic;
enable : out std_logic
);
end component gen48khz;
signal audio_in_available : std_logic;
signal left_channel_audio_in : std_logic_vector(32 downto 1);
signal right_channel_audio_in : std_logic_vector(32 downto 1);
signal read_audio_in : std_logic;
signal audio_out_allowed : std_logic;
signal left_channel_audio_out : std_logic_vector(32 downto 1);
signal right_channel_audio_out : std_logic_vector(32 downto 1);
signal write_audio_out : std_logic;
signal delay_cnt : integer;
signal delay : integer;
signal snd : std_logic;
signal sound : std_logic_vector(31 downto 0);
signal s_audio : std_logic_vector(15 downto 0);
signal s_audio2 : std_logic_vector(15 downto 0);
signal s_dds : std_logic_vector(15 downto 0);
signal s_audio_en2 : std_logic;
signal s_right_in : std_logic_vector(31 downto 0);
signal s_left_in : std_logic_vector(31 downto 0);
signal s_right_in_del : std_logic_vector(31 downto 0);
signal s_left_in_del : std_logic_vector(31 downto 0);
signal s_fft_left,s_fft_right : std_logic_vector(15 downto 0);
begin
s_fft_left <= s_left_in(31 downto 16);
s_fft_right <= s_right_in(31 downto 16);
delay <= to_integer(unsigned(SW & "000101110111000"));
--FPGA_CLK_A_P <= sys_clk_180deg;
--FPGA_CLK_A_N <= not sys_clk_180deg;
--FPGA_CLK_B_P <= sys_clk_270deg;
--FPGA_CLK_B_N <= not sys_clk_270deg;
AD_SCLK <= '1'; -- DATA FORMAT SEL.
AD_SDIO <= '0'; -- DUTY CYCLE STAB.
ADA_OE <= '0';
ADA_SPI_CS <= '1';
ADB_OE <= '0';
ADB_SPI_CS <= '1';
--read_audio_in <= audio_in_available and audio_out_allowed;
--left_channel_audio_out <= left_channel_audio_in + sound;
--right_channel_audio_out <= right_channel_audio_in + sound;
--write_audio_out <= audio_in_available and audio_out_allowed;
left_channel_audio_out <= s_left_in_del + s_left_in;
right_channel_audio_out <= s_right_in_del + s_right_in;
read_audio_in <= '1';
sound <= s_audio2 & x"0000" when s_audio2(15) = '0' else
s_audio2 & x"1111" when s_audio2(15) = '1';
write_audio_out <= s_audio_en2 and audio_out_allowed;
--process (CLOCK_50)
--begin
-- if (CLOCK_50'event and CLOCK_50='1') then
-- if (SW="0000") then
-- --sound <= (others=>'0');
-- else
-- if snd='1' then
-- --sound <= "00000000000011110001100111110000";
-- else
-- --sound <= "11111111111100001110011000010000";
-- end if;
-- end if;
-- end if;
--end process;
process (CLOCK_50)
begin
if (CLOCK_50'event and CLOCK_50='1') then
if delay_cnt = delay then
delay_cnt <= 0;
else
delay_cnt <= delay_cnt + 1;
end if;
end if;
end process;
Audio_Controller_i1 : Audio_Controller
port map (
CLOCK_50 => CLOCK_50,
reset => not KEY(0),
clear_audio_in_memory => '0',
read_audio_in => read_audio_in,
clear_audio_out_memory => '0',
left_channel_audio_out => left_channel_audio_out,
right_channel_audio_out => right_channel_audio_out,
write_audio_out => write_audio_out,
AUD_ADCDAT => AUD_ADCDAT,
AUD_BCLK => AUD_BCLK,
AUD_ADCLRCK => AUD_ADCLRCK,
AUD_DACLRCK => AUD_DACLRCK,
audio_in_available => audio_in_available,
left_channel_audio_in => left_channel_audio_in,
right_channel_audio_in => right_channel_audio_in,
audio_out_allowed => audio_out_allowed,
AUD_XCK => AUD_XCK,
AUD_DACDAT => AUD_DACDAT
);
avconf_i1 : avconf
port map (
I2C_SCLK => I2C_SCLK,
I2C_SDAT => I2C_SDAT,
CLOCK_50 => CLOCK_50,
reset => not KEY(0)
);
gen48khz_i1 : gen48khz
port map (
clock => CLOCK_50,
reset_n => KEY(0),
enable => s_audio_en2
);
fifo_left : fifo
port map (
clock => CLOCK_50,
data => left_channel_audio_in,
rdreq => s_audio_en2,
wrreq => audio_in_available,
empty => open,
full => open,
q => s_left_in,
usedw => open
);
fifo_right : fifo
port map (
clock => CLOCK_50,
data => right_channel_audio_in,
rdreq => s_audio_en2,
wrreq => audio_in_available,
empty => open,
full => open,
q => s_right_in,
usedw => open
);
echo_left : echo
port map (
clk => CLOCK_50,
ce => write_audio_out,
data_in => s_left_in,
data_out => s_left_in_del
);
echo_right : echo
port map (
clk => CLOCK_50,
ce => write_audio_out,
data_in => s_right_in,
data_out => s_right_in_del
);
end rtl;