/
test_register.vhdl
94 lines (71 loc) · 2.15 KB
/
test_register.vhdl
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
-- Test the register entity
--
-- David Poole 30-Sep-2012
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all;
entity test_register is
begin
end;
architecture test_bench of test_register is
signal t_clk : std_logic;
signal t_reset : std_logic;
signal t_input_enable : std_logic;
signal t_output_enable : std_logic;
signal t_data_in : std_logic_vector(7 downto 0);
signal t_data_out : std_logic_vector(7 downto 0);
component d_register is
generic (width : integer);
port (clk : in std_logic;
reset : in std_logic := '1';
input_enable : in std_logic;
output_enable : in std_logic;
data_in : in std_logic_vector( width-1 downto 0 );
data_out : out std_logic_vector( width-1 downto 0 )
);
end component d_register;
begin
uut : d_register
generic map( width => 8)
port map( clk => t_clk,
reset => t_reset,
input_enable => t_input_enable,
output_enable => t_output_enable,
data_in => t_data_in,
data_out => t_data_out );
clock : process is
begin
t_clk <= '0'; wait for 10 ns;
t_clk <= '1'; wait for 10 ns;
end process clock;
stimulus : process is
variable str : line;
begin
write( output, string'("hello, world") );
writeline( output, str );
t_reset <= '1';
t_input_enable <= '0';
t_output_enable <= '0';
t_data_in <= (others =>'0');
wait for 15 ns;
t_reset <= '0';
wait for 10 ns;
t_input_enable <= '1';
t_data_in <= std_logic_vector(to_unsigned(42,t_data_in'length));
wait for 10 ns;
t_input_enable <= '0';
wait for 10 ns;
t_output_enable <= '1';
wait for 10 ns;
t_output_enable <= '0';
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
write( str, to_integer(signed(t_data_out)) );
writeline( output, str );
t_reset <= '1';
wait for 10 ns;
wait;
end process stimulus;
end architecture test_bench;