-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSirene.vhd
75 lines (70 loc) · 1.58 KB
/
Sirene.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
library IEEE;
use ieee.std_logic_1164.all;
use work.all;
entity Sirene is
generic(
max : in integer := 0;
max2 : in integer := 0);
port(
clk : in std_logic;
selec : in std_logic_vector(0 to 1);
buzzer : out std_logic;
valeur : in integer);
end Sirene;
architecture structural of Sirene is
begin
process(clk)
variable temp : integer := 0;
variable temp2 : integer := 0;
variable switch : std_logic := '1';
begin
if rising_edge(clk) then
if valeur <= 5 and (selec = "00" or selec = "01") then
if temp2 <= (valeur * 5000000) then
temp2 := temp2+1;
switch := '1';
elsif temp2 > (valeur * 5000000) and temp2 < (valeur * 10000000) then
temp2 := temp2 +1;
switch := '0';
elsif temp2 >= (valeur * 10000000) then
temp2 := 0;
switch := '0';
end if;
elsif valeur = 0 then
switch := '0';
else
switch := '0';
end if;
if selec = "00" then
if temp <= (max/2) then
temp := temp + 1;
if switch = '1' then
buzzer <= '1';
end if;
elsif temp > (max/2) and temp < max then
buzzer <= '0';
temp := temp + 1;
elsif temp >= max then
temp := 0;
buzzer <= '0';
end if;
elsif selec = "01" then
if temp <= (max2/2) then
temp := temp + 1;
if switch = '1' then
buzzer <= '1';
end if;
elsif temp > (max2/2) and temp < max2 then
buzzer <= '0';
temp := temp + 1;
elsif temp >= max2 then
temp := 0;
buzzer <= '0';
end if;
elsif selec = "11" then
temp := 0;
buzzer <= '0';
end if;
end if;
end process;
end structural;