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
|
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity test_bench is
end test_bench;
architecture test_counter_4 of test_bench is
signal CLK : STD_LOGIC;
signal CQ: STD_LOGIC_VECTOR(3 DOWNTO 0);
begin
counter: entity work.counter_4(behavior)
port map (CLK, CQ);
stimulus: process is
begin
for count_value in 0 to 2 ** 4 - 1 loop
if count_value mod 2 = 0 then
CLK <= '1';
wait for 5 ns;
else
CLK <= '0';
wait for 5 ns;
end if;
end loop;
end process stimulus;
end architecture test_counter_4;
architecture test_full_adder_1 of test_bench is
subtype v3 is std_logic_vector(2 downto 0);
signal I: v3 := B"000";
signal S, CO : STD_LOGIC;
begin
adder: entity work.full_adder_1(behavior)
port map (I(2), I(1), I(0), S, CO);
stimulus: process is
variable ii : v3 := B"000";
begin
loop
ii := ii + 1;
I <= ii;
wait for 5 ns;
end loop;
end process stimulus;
end architecture test_full_adder_1;
architecture test_multiplexer_32_2 of test_bench is
signal A0: std_logic_vector(31 downto 0) := B"11111111111111111111111111111111";
signal A1: std_logic_vector(31 downto 0) := B"00000000000000000000000000000000";
signal S: std_logic;
signal Y: std_logic_vector(31 downto 0);
begin
multiplexer: entity work.multiplexer_32_2(behaviour)
port map (A0, A1, S, Y);
stimulus: process is
begin
loop
S <= '0';
wait for 5 ns;
S <= '1';
wait for 5 ns;
end loop;
end process stimulus;
end architecture test_multiplexer_32_2;
architecture test_adder_32 of test_bench is
signal A: std_logic_vector(31 downto 0) := B"00000000000000000000000000000000";
signal B: std_logic_vector(31 downto 0) := B"00000000000000000000000000000000";
signal CIN: std_logic;
signal S: std_logic_vector(31 downto 0);
signal COUT: std_logic;
begin
adder: entity work.adder_32(behavior)
port map (A, B, CIN, S, COUT);
stimulus: process is
begin
loop
A <= A + 1;
B <= B + 2;
CIN <= '0';
wait for 5 ns;
CIN <= '1';
wait for 5 ns;
end loop;
end process stimulus;
end architecture test_adder_32;
architecture test_shift_32 of test_bench is
signal D: std_logic_vector(31 downto 0) := B"00000000000000000000000000000011";
signal SA: std_logic_vector(4 downto 0) := B"00000";
signal Right: std_logic;
signal Arith: std_logic;
signal SH: std_logic_vector(31 downto 0);
begin
shift: entity work.shift_32(behavioral)
port map (D, SA, Right, Arith, SH);
stimulus: process is
begin
loop
D <= B"00000000000000000000000000000011" and D;
Right <= '0';
Arith <= '0';
wait for 5 ns;
Arith <= '1';
wait for 5 ns;
Right <= '1';
Arith <= '0';
wait for 5 ns;
Arith <= '1';
wait for 5 ns;
D <= B"10000000000000000000000000000000" or D;
Right <= '0';
Arith <= '0';
wait for 5 ns;
Arith <= '1';
wait for 5 ns;
Right <= '1';
Arith <= '0';
wait for 5 ns;
Arith <= '1';
wait for 5 ns;
SA <= SA + 1;
end loop;
end process stimulus;
end architecture test_shift_32;
|