-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtb_decodificador.vhd
66 lines (54 loc) · 1.66 KB
/
tb_decodificador.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
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity tb_decodificador is
end tb_decodificador;
architecture hardware of tb_decodificador is
signal clk : std_logic := '0';
signal sel_display : std_logic_vector(3 downto 0);
signal segment : std_logic_vector(7 downto 0);
constant dt : time := 25 ns;
component decod_component is
port(
clk : in std_logic; -- Clock signal
A, B, C, D : in std_logic_vector(3 downto 0); -- Input digits (4-bit each)
sel_display: out std_logic_vector(3 downto 0); -- Output to select the display
segment : out std_logic_vector(7 downto 0) -- Output to drive the 7-segment display
);
end component;
SIGNAL A : std_logic_vector(3 downto 0) := X"1";
SIGNAL B : std_logic_vector(3 downto 0) := X"9";
SIGNAL C : std_logic_vector(3 downto 0) := X"8";
SIGNAL D : std_logic_vector(3 downto 0) := X"7";
begin
process
begin
clk <= not clk;
wait for dt;
end process;
process(clk)
variable psc : integer range 0 to 12000001;
variable number : integer range 0 to 65536 := 0;
begin
if clk'event and clk = '1' then
psc := psc + 1;
if psc = 12000001 then
psc := 0;
number := number + 1;
A <= std_logic_vector(to_unsigned(number, 16)(3 downto 0));
B <= std_logic_vector(to_unsigned(number, 16)(7 downto 4));
C <= std_logic_vector(to_unsigned(number, 16)(11 downto 8));
D <= std_logic_vector(to_unsigned(number, 16)(15 downto 12));
end if;
end if;
end process;
uut1 : decod_component port map (
clk => clk,
A => A,
B => B,
C => C,
D => D,
sel_display => sel_display,
segment => segment
);
end hardware;