summaryrefslogtreecommitdiffstats
path: root/silence_detector.vhd
diff options
context:
space:
mode:
Diffstat (limited to 'silence_detector.vhd')
-rw-r--r--silence_detector.vhd54
1 files changed, 54 insertions, 0 deletions
diff --git a/silence_detector.vhd b/silence_detector.vhd
new file mode 100644
index 0000000..fe85824
--- /dev/null
+++ b/silence_detector.vhd
@@ -0,0 +1,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;
+