blob: fe85824e5c883e5602b0670ae8871c9186e5dff5 (
plain)
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
|
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;
entity silence_detector is
port
(
max_ticks : in integer;
clk : in std_logic;
d : in std_logic_vector(23 downto 0);
n_reset : in std_logic;
silent : out std_logic
);
end silence_detector;
architecture rtl of silence_detector is
signal ticks : std_logic_vector (31 downto 0);
signal last_d : std_logic_vector (23 downto 0);
signal silent_buf : std_logic;
begin
process (last_d, d, clk, max_ticks, ticks)
begin
if n_reset = '0' then
ticks <= (others => '0');
silent_buf <= '0';
last_d <= (others => '0');
elsif rising_edge(clk) then
last_d <= d;
if last_d = d then
if ticks < max_ticks then
ticks <= ticks +1;
else
silent_buf <= '1';
end if;
else
ticks <= (others => '0');
silent_buf <= '0';
end if;
end if;
end process;
silent <= silent_buf;
end rtl;
|