-
Notifications
You must be signed in to change notification settings - Fork 0
/
vumetro_it.vhd
58 lines (52 loc) · 1.42 KB
/
vumetro_it.vhd
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
-- Vumetro individual de una entrada
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity vumetro_it is
generic (
defhold : integer := 500
);
port (
clk : in bit;
sin : in signed(15 downto 0);
sout : out unsigned(7 downto 0)
);
end vumetro_it;
architecture arch_vumetro_it of vumetro_it is
signal higher : signed (15 downto 0) := to_signed(0,16);
signal hold : integer := defhold;
signal en_updateupdate : bit := '0';
begin
refresh : process(clk)
variable sample : signed(15 downto 0) := to_signed(0,16);
begin
sample := abs(sin);
if (clk'event and clk = '1') then
if (sample > higher OR hold = 0) then
higher <= sample;
hold <= defhold;
else
hold <= hold -1;
end if;
end if;
if (higher > "0100000000000000") then
sout <= "11111111";
elsif (higher > "0001000000000000") then
sout <= "01111111";
elsif (higher > "0000010000000000") then
sout <= "00111111";
elsif (higher > "0000000100000000") then
sout <= "00011111";
elsif (higher > "0000000001000000") then
sout <= "00001111";
elsif (higher > "0000000000010000") then
sout <= "00000111";
elsif (higher > "0000000000000100") then
sout <= "00000011";
elsif (higher > "0000000000000001") then
sout <= "00000001";
else
sout <= "00000000";
end if;
end process refresh;
end arch_vumetro_it;