1
|
library IEEE;
|
2
|
|
3
|
use IEEE.std_logic_1164.all;
|
4
|
|
5
|
entity user_handler is
|
6
|
port
|
7
|
(
|
8
|
i_clock: in std_logic; -- System's clock.
|
9
|
i_reset: in std_logic; -- System reset.
|
10
|
i_synced_start_btn: in std_logic; -- User input. Synchronized.
|
11
|
i_synced_raz_btn: in std_logic; -- User input. Synchronized.
|
12
|
i_limit_reached: in std_logic; -- Time Wizard has reached limit.
|
13
|
o_enable: out std_logic; -- Enable time passing.
|
14
|
o_raz: out std_logic -- Reset system.
|
15
|
);
|
16
|
end user_handler;
|
17
|
|
18
|
architecture Behavioral of user_handler is
|
19
|
-- Previous value of BP_START_STOP (Lustre inspired).
|
20
|
signal synced_start_btn_r1: std_logic;
|
21
|
-- Remember if we are currently counting time or not.
|
22
|
signal time_is_passing: std_logic;
|
23
|
begin
|
24
|
P_ENABLE_TIME: process (i_clock, i_reset)
|
25
|
begin
|
26
|
if (i_reset = '1')
|
27
|
then
|
28
|
time_is_passing <= '0';
|
29
|
else
|
30
|
if (rising_edge(i_clock))
|
31
|
then
|
32
|
if ((synced_start_btn_r1 = '0') and (i_synced_start_btn = '1'))
|
33
|
then
|
34
|
time_is_passing <= (not time_is_passing);
|
35
|
end if;
|
36
|
end if;
|
37
|
end if;
|
38
|
end process;
|
39
|
|
40
|
P_PRE_SYNCED_START_BTN: process (i_clock, i_reset)
|
41
|
begin
|
42
|
if (i_reset = '1')
|
43
|
then
|
44
|
synced_start_btn_r1 <= '0';
|
45
|
else
|
46
|
if (rising_edge(i_clock))
|
47
|
then
|
48
|
synced_start_btn_r1 <= i_synced_start_btn;
|
49
|
end if;
|
50
|
end if;
|
51
|
end process;
|
52
|
|
53
|
o_raz <= (i_synced_raz_btn and time_is_passing);
|
54
|
o_enable <= time_is_passing;
|
55
|
end;
|