-
Notifications
You must be signed in to change notification settings - Fork 0
/
nice_time.vhdl
71 lines (64 loc) · 1.75 KB
/
nice_time.vhdl
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
-------------------------------------------------------------------------------------
--
-- Distributed under MIT Licence
-- See https://github.com/JosephAbbey/fpga_clock/blob/main/LICENCE.
--
-------------------------------------------------------------------------------------
--
-- Converts 12 hour clock time to 12 hour and 24 hour clock.
--
-- J D Abbey, 09 October 2022
--
-------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.time_display_pkg.mode_t;
entity nice_time is
port(
idigit : in work.sevseg_pkg.digits_t;
ispm : in std_logic;
tfhr : in std_logic;
digit : out work.sevseg_pkg.digits_t;
am : out std_logic;
pm : out std_logic
);
end entity;
architecture rtl of nice_time is
begin
process(all)
begin
digit(3) <= idigit(3);
digit(2) <= idigit(2);
if tfhr = '1' then
am <= '0';
pm <= '0';
if ispm = '1' then
if idigit(1) = 8 or idigit(1) = 9 then -- prevents the rarely seen case of 1b o'clock
digit(1) <= idigit(1) - 8;
digit(0) <= idigit(0) + 2;
else
if idigit(0) = 1 and idigit(1) = 2 then
digit(1) <= 0;
digit(0) <= 0;
else
digit(1) <= idigit(1) + 2;
digit(0) <= idigit(0) + 1;
end if;
end if;
else
digit(1) <= idigit(1);
digit(0) <= idigit(0);
end if;
else
am <= not ispm;
pm <= ispm;
if ispm = '1' and idigit(1) = 0 and idigit(0) = 0 then
digit(1) <= 2;
digit(0) <= 1;
else
digit(1) <= idigit(1);
digit(0) <= idigit(0);
end if;
end if;
end process;
end architecture;