1 |
d93979b7
|
Arnaud Dieumegard
|
library IEEE;
|
2 |
|
|
|
3 |
|
|
use IEEE.std_logic_1164.all;
|
4 |
|
|
|
5 |
|
|
entity time_wizard is
|
6 |
|
|
port
|
7 |
|
|
(
|
8 |
|
|
i_clock: in std_logic;
|
9 |
|
|
i_reset: in std_logic;
|
10 |
|
|
i_raz: in std_logic;
|
11 |
|
|
i_new_centisecond: in std_logic;
|
12 |
|
|
o_limit_reached: out std_logic;
|
13 |
|
|
o_curr_0001_time: out natural range 0 to 9;
|
14 |
|
|
o_curr_0010_time: out natural range 0 to 9;
|
15 |
|
|
o_curr_0100_time: out natural range 0 to 9;
|
16 |
|
|
o_curr_1000_time: out natural range 0 to 5
|
17 |
|
|
);
|
18 |
|
|
end time_wizard;
|
19 |
|
|
|
20 |
|
|
architecture Behavioral of time_wizard is
|
21 |
|
|
signal limit_reached: std_logic;
|
22 |
|
|
signal t0001: natural range 0 to 9;
|
23 |
|
|
signal t0010: natural range 0 to 9;
|
24 |
|
|
signal t0100: natural range 0 to 9;
|
25 |
|
|
signal t1000: natural range 0 to 5;
|
26 |
|
|
begin
|
27 |
|
|
P_CENTISECOND_COUNTER: process (i_clock, i_raz)
|
28 |
|
|
begin
|
29 |
|
|
if (i_raz = '1')
|
30 |
|
|
then
|
31 |
|
|
t0001 <= 0;
|
32 |
|
|
else
|
33 |
|
|
if (rising_edge(i_clock))
|
34 |
|
|
then
|
35 |
|
|
if ((i_new_centisecond = '1') and (limit_reached = '0'))
|
36 |
|
|
then
|
37 |
|
|
if (t0001 >= 9)
|
38 |
|
|
then
|
39 |
|
|
t0001 <= 0;
|
40 |
|
|
else
|
41 |
|
|
t0001 <= (t0001 + 1);
|
42 |
|
|
end if;
|
43 |
|
|
end if;
|
44 |
|
|
end if;
|
45 |
|
|
end if;
|
46 |
|
|
end process;
|
47 |
|
|
|
48 |
|
|
P_DECISECOND_COUNTER: process (i_clock, i_raz)
|
49 |
|
|
begin
|
50 |
|
|
if (i_raz = '1')
|
51 |
|
|
then
|
52 |
|
|
t0010 <= 0;
|
53 |
|
|
else
|
54 |
|
|
if (rising_edge(i_clock))
|
55 |
|
|
then
|
56 |
|
|
if
|
57 |
|
|
(
|
58 |
|
|
(i_new_centisecond = '1')
|
59 |
|
|
and (limit_reached = '0')
|
60 |
|
|
and (t0001 >= 9)
|
61 |
|
|
)
|
62 |
|
|
then
|
63 |
|
|
if (t0010 >= 9) then
|
64 |
|
|
t0010 <= 0;
|
65 |
|
|
else
|
66 |
|
|
t0010 <= (t0010 + 1);
|
67 |
|
|
end if;
|
68 |
|
|
end if;
|
69 |
|
|
end if;
|
70 |
|
|
end if;
|
71 |
|
|
end process;
|
72 |
|
|
|
73 |
|
|
P_SECOND_COUNTER: process (i_clock, i_raz)
|
74 |
|
|
begin
|
75 |
|
|
if (i_raz = '1')
|
76 |
|
|
then
|
77 |
|
|
t0100 <= 0;
|
78 |
|
|
else
|
79 |
|
|
if (rising_edge(i_clock))
|
80 |
|
|
then
|
81 |
|
|
if
|
82 |
|
|
(
|
83 |
|
|
(i_new_centisecond = '1')
|
84 |
|
|
and (limit_reached = '0')
|
85 |
|
|
and (t0010 >= 9)
|
86 |
|
|
and (t0001 >= 9)
|
87 |
|
|
)
|
88 |
|
|
then
|
89 |
|
|
if (t0100 >= 9) then
|
90 |
|
|
t0100 <= 0;
|
91 |
|
|
else
|
92 |
|
|
t0100 <= (t0100 + 1);
|
93 |
|
|
end if;
|
94 |
|
|
end if;
|
95 |
|
|
end if;
|
96 |
|
|
end if;
|
97 |
|
|
end process;
|
98 |
|
|
|
99 |
|
|
P_DECASECOND_COUNTER: process (i_clock, i_raz)
|
100 |
|
|
begin
|
101 |
|
|
if (i_raz = '1')
|
102 |
|
|
then
|
103 |
|
|
t1000 <= 0;
|
104 |
|
|
else
|
105 |
|
|
if (rising_edge(i_clock))
|
106 |
|
|
then
|
107 |
|
|
if
|
108 |
|
|
(
|
109 |
|
|
(i_new_centisecond = '1')
|
110 |
|
|
and (limit_reached = '0')
|
111 |
|
|
and (t0100 >= 9)
|
112 |
|
|
and (t0010 >= 9)
|
113 |
|
|
and (t0001 >= 9)
|
114 |
|
|
)
|
115 |
|
|
then
|
116 |
|
|
t1000 <= (t1000 + 1);
|
117 |
|
|
end if;
|
118 |
|
|
end if;
|
119 |
|
|
end if;
|
120 |
|
|
end process;
|
121 |
|
|
|
122 |
|
|
limit_reached <=
|
123 |
|
|
'1'
|
124 |
|
|
when
|
125 |
|
|
(
|
126 |
|
|
(t1000 >= 5)
|
127 |
|
|
and (t0100 >= 9)
|
128 |
|
|
and (t0010 >= 9)
|
129 |
|
|
and (t0001 >= 9)
|
130 |
|
|
)
|
131 |
|
|
else '0';
|
132 |
|
|
|
133 |
|
|
-- All the Time Wizard's counting is shown to the world.
|
134 |
|
|
o_curr_0001_time <= t0001;
|
135 |
|
|
o_curr_0010_time <= t0010;
|
136 |
|
|
o_curr_0100_time <= t0100;
|
137 |
|
|
o_curr_1000_time <= t1000;
|
138 |
|
|
o_limit_reached <= limit_reached;
|
139 |
|
|
end;
|