025ff1a6
rduhr
7Segment_display ...
|
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
|
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 27.09.2023 17:03:49
-- Design Name:
-- Module Name: display - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.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 leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity display is
port (
clk_fpga : in STD_LOGIC;
reset : in STD_LOGIC;
aff : out STD_LOGIC_VECTOR(7 downto 0);
an : out STD_LOGIC_VECTOR(3 downto 0)
);
end display;
architecture Behavioral of display is
signal count_int : integer range 3 downto 0 := 0;
signal clk_enable : integer range 4999 downto 0 := 0;
signal clk_counter : integer range 2999999 downto 0 := 0;
constant nb0 : std_logic_vector(7 downto 0) := "11000000";
constant nb1 : std_logic_vector(7 downto 0) := "11111001";
constant nb2 : std_logic_vector(7 downto 0) := "10100100";
constant nb3 : std_logic_vector(7 downto 0) := "10110000";
constant nb4 : std_logic_vector(7 downto 0) := "10011001";
constant nb5 : std_logic_vector(7 downto 0) := "10010010";
constant nb6 : std_logic_vector(7 downto 0) := "10000010";
constant nb7 : std_logic_vector(7 downto 0) := "11111000";
constant nb8 : std_logic_vector(7 downto 0) := "10000000";
constant nb9 : std_logic_vector(7 downto 0) := "10010000";
constant seg0 : std_logic_vector(3 downto 0) := "1110";
constant seg1 : std_logic_vector(3 downto 0) := "1101";
constant seg2 : std_logic_vector(3 downto 0) := "1011";
constant seg3 : std_logic_vector(3 downto 0) := "0111";
signal chiffre4 : integer range 9 downto 0 := 0;
signal chiffre3 : integer range 9 downto 0 := 0;
signal chiffre2 : integer range 9 downto 0 := 0;
signal chiffre1 : integer range 9 downto 0 := 0;
type mynumbers is array(9 downto 0) of std_logic_vector(7 downto 0);
signal numbers : mynumbers := (nb9,nb8,nb7,nb6,nb5,nb4,nb3,nb2,nb1,nb0);
begin
process(clk_fpga)
begin
if clk_fpga'event and clk_fpga = '1' then
-- clock d'affichage
if clk_enable = 4999 then
clk_enable <= 0;
if count_int = 0 then
aff <= numbers(chiffre4);
an <= seg0;
count_int <= count_int + 1;
elsif count_int = 1 then
aff <= numbers(chiffre3);
an <= seg1;
count_int <= count_int + 1;
elsif count_int = 2 then
aff <= numbers(chiffre2);
an <= seg2;
count_int <= count_int + 1;
elsif count_int = 3 then
aff <= numbers(chiffre1);
an <= seg3;
count_int <= 0;
end if;
else
clk_enable <= clk_enable + 1;
end if;
-- clock de compteur
if clk_counter = 2999999 then
clk_counter <= 0;
if reset = '1' then
chiffre1 <= 0;
chiffre2 <= 0;
chiffre3 <= 0;
chiffre4 <= 0;
else if chiffre4 = 9 then
chiffre4 <= 0;
if chiffre3 = 9 then
chiffre3 <= 0;
if chiffre2 = 9 then
chiffre2 <= 0;
if chiffre1 = 9 then
chiffre1 <= 0;
else
chiffre1 <= chiffre1 + 1;
end if;
else
chiffre2 <= chiffre2 + 1;
end if;
else
chiffre3 <= chiffre3 + 1;
end if;
else
chiffre4 <= chiffre4 + 1;
end if;
else
clk_counter <= clk_counter + 1;
end if;
end if;
end process;
end Behavioral;
|