-
Notifications
You must be signed in to change notification settings - Fork 1
/
Backup 3.txt
157 lines (136 loc) · 3.77 KB
/
Backup 3.txt
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
----------------------------------------------------------------------------------
-- Company: LeTourneau University
-- Engineer:
--
-- Create Date: 19:46:40 04/11/2021
-- Design Name:
-- Module Name: FinalDisplay - Behavioral
-- Project Name: Digital Electronics Clock Display
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity FinalDisplay is
Port ( --SEC_0 : in STD_LOGIC_VECTOR(3 downto 0);
-- clock signal
CLK : in STD_LOGIC;
-- 4 digits on board
AN1 : out STD_LOGIC;
AN2 : out STD_LOGIC;
AN3 : out STD_LOGIC;
AN4 : out STD_LOGIC;
-- 7 outputs for 7 segment display
C_A : out STD_LOGIC;
C_B : out STD_LOGIC;
C_C : out STD_LOGIC;
C_D : out STD_LOGIC;
C_E : out STD_LOGIC;
C_F : out STD_LOGIC;
C_G : out STD_LOGIC);
end FinalDisplay;
architecture Behavioral of FinalDisplay is
-- clock counter
signal CLK_COUNTER : natural range 0 to 50000000 := 0;
-- counter of number to display
signal COUNTER : natural range 0 to 10 := 0;
-- which AN port to trigger
signal AN_NUMBER: natural range 0 to 3 := 0;
-- AN ports
signal AN : std_logic_vector(3 downto 0);
-- information for 7 segment display
signal SEC_1_DISPLAY : std_logic_vector(6 downto 0);
begin
-- do stuff every 1 ms, dividing clock signal
Clock_Divider2 : process (CLK)
begin
if (rising_edge(CLK)) then
CLK_COUNTER <= CLK_COUNTER + 1;
-- every 8000 ticks, so every 1 ms for a 8 MHz clock
if (CLK_COUNTER >= 8000) then
CLK_COUNTER <= 0;
-- increment AN_Number from 1 to 3
AN_NUMBER <= AN_NUMBER + 1;
if (AN_NUMBER > 3) then
AN_NUMBER <= 0;
end if;
end if;
end if;
end process;
-- use AN_NUMBER to modify which AN port is on
Change_AN : process (AN_NUMBER)
begin
case AN_NUMBER is
when 0 => AN <= "1110";
when 1 => AN <= "1101";
when 2 => AN <= "1011";
when 3 => AN <= "0111";
end case;
-- turn AN ports on or off accordingly
AN1 <= AN(3);
AN2 <= AN(2);
AN3 <= AN(1);
AN4 <= AN(0);
end process;
-- change counter (number displayed) based on AN_NUMBER
Change_Counter : process (AN_NUMBER)
begin
case AN_NUMBER is
when 0 => COUNTER <= 1;
when 1 => COUNTER <= 2;
when 2 => COUNTER <= 3;
when 3 => COUNTER <= 4;
end case;
end process;
-- display numbers
Display_LED : process(COUNTER)
begin
case COUNTER is
when 0 =>
SEC_1_DISPLAY <= "0000001"; -- 0
when 1 =>
SEC_1_DISPLAY <= "1001111"; -- 1
when 2 =>
SEC_1_DISPLAY <= "0010010"; -- 2
when 3 =>
SEC_1_DISPLAY <= "0000110"; -- 3
when 4 =>
SEC_1_DISPLAY <= "1001100"; -- 4
when 5 =>
SEC_1_DISPLAY <= "0100100"; -- 5
when 6 =>
SEC_1_DISPLAY <= "0100000"; -- 6
when 7 =>
SEC_1_DISPLAY <= "0001111"; -- 7
when 8 =>
SEC_1_DISPLAY <= "0000000"; -- 8
when 9 =>
SEC_1_DISPLAY <= "0000100"; -- 9
when others =>
SEC_1_DISPLAY <= "1111111"; -- blank when not a digit
end case;
-- send information to board
C_A <= SEC_1_DISPLAY(6);
C_B <= SEC_1_DISPLAY(5);
C_C <= SEC_1_DISPLAY(4);
C_D <= SEC_1_DISPLAY(3);
C_E <= SEC_1_DISPLAY(2);
C_F <= SEC_1_DISPLAY(1);
C_G <= SEC_1_DISPLAY(0);
end process;
end Behavioral;