-
Notifications
You must be signed in to change notification settings - Fork 0
/
CD10min.vhd
executable file
·127 lines (115 loc) · 3.12 KB
/
CD10min.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Entity CD10min is
Port(
CLK,Rstb : in std_logic;
i1ms,i1s : in std_logic;
I10,iRe : in std_logic;
o10Digit1,o10Digit2,o10Digit3,o10Digit4 : out std_logic_vector(3 downto 0);
oStart,oFinish : out std_logic
);
End CD10min;
Architecture Behavioral of CD10min is
signal wS10,rCnt : std_logic := '0';
signal w10Digit1 : std_logic_vector(3 downto 0) := "0001";
signal w10Digit2,w10Digit3,w10Digit4 : std_logic_vector(3 downto 0) := "0000";
signal wStart,wFinish : std_logic := '0';
Begin
o10Digit1 <= w10Digit1;
o10Digit2 <= w10Digit2;
o10Digit3 <= w10Digit3;
o10Digit4 <= w10Digit4;
oStart <= wStart;
oFinish <= wFinish;
u_Push : Process(CLK,Rstb,iRe)
Begin
if(Rstb='0' or iRe='1') then
wFinish <= '0';
wS10 <= '0';
rCnt <= '0';
elsif(rising_edge(CLK)) then
if(I10='1' and w10Digit1=0 and w10Digit2=0 and w10Digit3=0 and w10Digit4=0) then
wS10 <= '0';
wFinish <= '0';
rCnt <= '0';
elsif(I10='1') then
wS10 <= not wS10;
wFinish <= '0';
rCnt <= '1';
elsif(i1s='1' and rCnt='0') then
wFinish <= '0';
rCnt <= '0';
elsif(i1ms='1' and w10Digit1=0 and w10Digit2=0 and w10Digit3=0 and w10Digit4=0 and rCnt='1') then
wS10 <= '0';
wFinish <= '1';
rCnt <= '0';
else
wS10 <= wS10;
wFinish <= wFinish;
rCnt <= rCnt;
end if;
end if;
end Process;
u_10min : Process(CLK,Rstb,wS10,iRe)
Begin
if(Rstb='0' or iRe='1') then
w10Digit1 <= "0001";
w10Digit2 <= (others => '0');
w10Digit3 <= (others => '0');
w10Digit4 <= (others => '0');
wStart <= '0';
elsif(rising_edge(CLK) and wS10='1') then
-- Digit1 10 min time standard 4 quarter --
if(i1s='1' and w10Digit1=0) then
w10Digit1 <= w10Digit1;
wStart <= '0';
elsif(i1ms='1' and w10Digit1>=1) then
wStart <= '1';
elsif(i1s='1') then
w10Digit1 <= w10Digit1 - 1;
wStart <= '0';
else
w10Digit1 <= w10Digit1;
wStart <= wStart;
end if;
-- Digit2 10 min --
if(i1s='1' and w10Digit1=0 and w10Digit2=0) then
w10Digit2 <= w10Digit2;
elsif(i1s='1' and w10Digit2=0) then
w10Digit2 <= "1001";
elsif(i1s='1' and w10Digit3=0 and w10Digit4=0) then
w10Digit2 <= w10Digit2 - 1;
else
w10Digit2 <= w10Digit2;
end if;
-- Digit3 10 min --
if(i1s='1' and w10Digit1=0 and w10Digit2=0 and w10Digit3=0) then
w10Digit3 <= w10Digit3;
elsif(i1s='1' and w10Digit3=0 and w10Digit4=0) then
w10Digit3 <= "0101";
elsif(i1s='1' and w10Digit4=0) then
w10Digit3 <= w10Digit3 - 1;
else
w10Digit3 <= w10Digit3;
end if;
-- Digit4 10 min --
if(i1s='1' and w10Digit1=0 and w10Digit2=0 and w10Digit3=0 and w10Digit4=0) then
w10Digit4 <= w10Digit4;
elsif(i1s='1' and w10Digit4=0) then
w10Digit4 <= "1001";
elsif(i1s='1') then
w10Digit4 <= w10Digit4 - 1;
else
w10Digit4 <= w10Digit4;
end if;
else
w10Digit1 <= w10Digit1;
w10Digit2 <= w10Digit2;
w10Digit3 <= w10Digit3;
w10Digit4 <= w10Digit4;
wStart <= wStart;
end if;
end Process;
End Behavioral;