-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfourdigitsevensegled.vhd
More file actions
101 lines (91 loc) · 3.47 KB
/
fourdigitsevensegled.vhd
File metadata and controls
101 lines (91 loc) · 3.47 KB
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
----------------------------------------------------------------------------------
-- Company: @Home
-- Engineer: Zoltan Pekic (zpekic@hotmail.com)
--
-- Create Date: 15:42:44 02/20/2016
-- Design Name:
-- Module Name: fourdigitsevensegled - Behavioral
-- Project Name: Alarm Clock
-- Target Devices: Mercury FPGA + Baseboard (http://www.micro-nova.com/mercury/)
-- Tool versions: Xilinx ISE 14.7 (nt64)
-- 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 fourdigitsevensegled is
Port ( -- inputs
data : in STD_LOGIC_VECTOR (15 downto 0);
digsel : in STD_LOGIC_VECTOR (1 downto 0);
showdigit : in STD_LOGIC_VECTOR (3 downto 0);
showdot : in STD_LOGIC_VECTOR (3 downto 0);
showsegments : in STD_LOGIC;
-- outputs
anode : out STD_LOGIC_VECTOR (3 downto 0);
segment : out STD_LOGIC_VECTOR (7 downto 0)
);
end fourdigitsevensegled;
architecture structural of fourdigitsevensegled is
component nibble2sevenseg is
Port ( nibble : in STD_LOGIC_VECTOR (3 downto 0);
segment : out STD_LOGIC_VECTOR (6 downto 0)
);
end component;
component mux16to4
Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC_VECTOR (3 downto 0);
c : in STD_LOGIC_VECTOR (3 downto 0);
d : in STD_LOGIC_VECTOR (3 downto 0);
sel : in STD_LOGIC_VECTOR (1 downto 0);
nEnable : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (3 downto 0)
);
end component;
signal internalsegment: std_logic_vector(7 downto 0); -- 7th is the dot!
signal internalsel: std_logic_vector(3 downto 0);
signal digit: std_logic_vector(3 downto 0);
begin
-- decode position
internalsel(3) <= digsel(1) and digsel(0);
internalsel(2) <= digsel(1) and (not digsel(0));
internalsel(1) <= (not digsel(1)) and digsel(0);
internalsel(0) <= (not digsel(1)) and (not digsel(0));
-- select 1 digit out of 4 incoming
digitmux: mux16to4 port map (
a => data(3 downto 0),
b => data(7 downto 4),
c => data(11 downto 8),
d => data(15 downto 12),
nEnable => '0',
sel => digsel,
y => digit
);
-- set the anodes with digit blanking
anode(3) <= not (internalsel(3) and showdigit(3));
anode(2) <= not (internalsel(2) and showdigit(2));
anode(1) <= not (internalsel(1) and showdigit(1));
anode(0) <= not (internalsel(0) and showdigit(0));
-- hook up the cathodes
sevensegdriver: nibble2sevenseg port map (
nibble => digit,
segment => internalsegment(6 downto 0)
);
-- set cathodes with blanking (seg7 == dot)
segment(7) <= (not showsegments) or ((internalsel(3) and not showdot(3)) or (internalsel(2) and not showdot(2)) or (internalsel(1) and not showdot(1)) or (internalsel(0) and not showdot(0)));
segs: for i in 6 downto 0 generate
segment(i) <= (not showsegments) or internalsegment(i);
end generate;
end structural;