-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtb_voltmeter.vhd
More file actions
86 lines (68 loc) · 1.71 KB
/
tb_voltmeter.vhd
File metadata and controls
86 lines (68 loc) · 1.71 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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
entity tb_voltmeter is
end tb_voltmeter;
architecture behaviour of tb_voltmeter is
--define clock period
constant clk_period: time := 20 ns; -- 50 MHz
--declare components
component Voltmeter is
Port (
clk : in STD_LOGIC;
reset : in STD_LOGIC;
S : in STD_LOGIC;
LEDR : out STD_LOGIC_VECTOR (9 downto 0);
HEX0,HEX1,HEX2,HEX3,HEX4,HEX5 : out STD_LOGIC_VECTOR (7 downto 0)
);
end component;
--declare signals
signal clk : STD_LOGIC;
signal reset : STD_LOGIC;
signal S : STD_LOGIC;
signal LEDR : STD_LOGIC_VECTOR (9 downto 0);
signal HEX0,HEX1,HEX2,HEX3,HEX4,HEX5 : STD_LOGIC_VECTOR (7 downto 0);
--instantiate
begin
UUT: Voltmeter
PORT MAP(
clk => clk,
reset => reset,
S => S,
LEDR => LEDR,
HEX0 => HEX0,
HEX1 => HEX1,
HEX2 => HEX2,
HEX3 => HEX3,
HEX4 => HEX4,
HEX5 => HEX5
);
--clock process
clk_process: process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
--mux process
mux_process: process
begin
S <= '0';
wait for 50*clk_period;
S <= '1';
wait for 50*clk_period;
end process;
--stimulus process
stim_process: process
begin
--hold reset state for 100 ns
reset <= '0';
wait for 5*clk_period;
reset <= '1';
wait for 5*clk_period;
reset <= '0';
wait;
--stimulus
end process;
end behaviour;