OpenCores
URL https://opencores.org/ocsvn/hicovec/hicovec/trunk

Subversion Repositories hicovec

[/] [hicovec/] [trunk/] [cpu/] [testbenches/] [tb_vector_register.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 hmanske
------------------------------------------------------------------
2 4 hmanske
-- PROJECT:      HiCoVec (highly configurable vector processor)
3 2 hmanske
--
4
-- ENTITY:      tb_vector_register
5
--
6
-- PURPOSE:     testbench of vector_register entity
7
--
8
-- AUTHOR:      harald manske, haraldmanske@gmx.de
9
--
10
-- VERSION:     1.0
11
-----------------------------------------------------------------
12
library ieee;
13
use ieee.std_logic_1164.all;
14
use ieee.std_logic_unsigned.all;
15
 
16
entity tb_vector_register is
17
end tb_vector_register;
18
 
19
architecture testbench of tb_vector_register is
20
    component vector_register
21
        generic (
22
            n : integer range 1 to 256;
23
            slicenr : natural
24
        );
25
 
26
        port (
27
            clk:            in  std_logic;
28
            r_in:           in  std_logic_vector(31 downto 0);
29
            v_out:          out std_logic_vector(31 downto 0);
30
            w_out:          out std_logic_vector(31 downto 0);
31
            load_r:         in  std_logic;
32
            load_select:    in  std_logic;
33
            k_in:           in  std_logic_vector(31 downto 0);
34
            select_v:       in  std_logic_vector(7 downto 0);
35
            select_w:       in  std_logic_vector(2 downto 0);
36
            select_r:       in  std_logic_vector(7 downto 0)
37
        );
38
    end component;
39
 
40
    for impl: vector_register use entity work.vector_register(rtl);
41
 
42
    constant n:        integer range 0 to 256 := 4;
43
    constant slicenr:  natural := 2;
44
 
45
    signal clk:         std_logic;
46
    signal r_in:        std_logic_vector(31 downto 0);
47
    signal v_out:       std_logic_vector(31 downto 0);
48
    signal w_out:       std_logic_vector(31 downto 0);
49
    signal k_in:        std_logic_vector(31 downto 0);
50
    signal load_r:      std_logic;
51
    signal load_select: std_logic;
52
    signal select_v:    std_logic_vector(7 downto 0) := "00000000";
53
    signal select_w:    std_logic_vector(2 downto 0) := "000";
54
    signal select_r:    std_logic_vector(7 downto 0) := "00000000";
55
 
56
    constant period     : time := 2ns;
57
 
58
    begin
59
        impl: vector_register generic map (n => n, slicenr => slicenr)
60
            port map (clk => clk, r_in => r_in, v_out => v_out, w_out => w_out,
61
                load_r => load_r, load_select => load_select, k_in => k_in, select_v =>
62
                select_v, select_w => select_w, select_r => select_r);
63
 
64
    process
65
    begin
66
 
67
            wait for 100ns;
68
 
69
            -- 1: load 00000000, v_out = 00000000, w_out = 00000000
70
 
71
            r_in <= "11010010110111101101001011011110";
72
            select_r <= "00000000";
73
            select_v <= "00000000";
74
            select_w <= "000";
75
            load_r <= '1';
76
            load_select <= '0';
77
 
78
 
79
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
80
 
81
            assert v_out = "11010010110111101101001011011110"
82
                report "1 : v_out"
83
                severity Error;
84
 
85
            assert w_out = "11010010110111101101001011011110"
86
                report "1 : w_out"
87
                severity Error;
88
 
89
 
90
            -- 2: load 00000001, v_out = 00000000, w_out = 00000001
91
 
92
            r_in <= "10010011001110101001001100111010";
93
            select_r <= "00000001";
94
            select_v <= "00000000";
95
            select_w <= "001";
96
            load_r <= '1';
97
            load_select <= '0';
98
 
99
 
100
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
101
 
102
            assert v_out = "11010010110111101101001011011110"
103
                report "2 : v_out"
104
                severity Error;
105
 
106
            assert w_out = "10010011001110101001001100111010"
107
                report "2 : w_out"
108
                severity Error;
109
 
110
 
111
            -- 3: load 00000010, v_out = 00000010, w_out = 00000000
112
 
113
            r_in <= "11110001110000111111000111000011";
114
            select_r <= "00000010";
115
            select_v <= "00000010";
116
            select_w <= "000";
117
            load_r <= '1';
118
            load_select <= '0';
119
 
120
 
121
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
122
 
123
            assert v_out = "11110001110000111111000111000011"
124
                report "3 : v_out"
125
                severity Error;
126
 
127
            assert w_out = "11010010110111101101001011011110"
128
                report "3 : w_out"
129
                severity Error;
130
 
131
            -- 4: load 00000011, v_out = 00000000, w_out = 00000010
132
 
133
            r_in <= "00011110000111100001111000011110";
134
            select_r <= "00000011";
135
            select_v <= "00000000";
136
            select_w <= "010";
137
            load_r <= '1';
138
            load_select <= '0';
139
 
140
 
141
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
142
 
143
            assert v_out = "11010010110111101101001011011110"
144
                report "4 : v_out"
145
                severity Error;
146
 
147
            assert w_out = "11110001110000111111000111000011"
148
                report "4 : w_out"
149
                severity Error;
150
 
151
            -- 5: load 00000000, set slicenr wrong
152
 
153
            r_in <= "11111111000000001111111100000000";
154
            select_r <= "00000000";
155
            select_v <= "00000000";
156
            select_w <= "010";
157
            k_in <= "00000000000000000000000000000000";
158
            load_r <= '1';
159
            load_select <= '1';
160
 
161
 
162
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
163
 
164
            assert v_out = "11010010110111101101001011011110"
165
                report "5 : v_out"
166
                severity Error;
167
 
168
            assert w_out = "11110001110000111111000111000011"
169
                report "5 : w_out"
170
                severity Error;
171
 
172
 
173
            -- 6: load 00000000, set slicenr properly
174
 
175
            r_in <= "11111111000000001111111100000000";
176
            select_r <= "00000000";
177
            select_v <= "00000000";
178
            select_w <= "010";
179
            k_in <= "00000000000000000000000000000010";
180
            load_r <= '1';
181
            load_select <= '1';
182
 
183
 
184
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
185
 
186
            assert v_out = "11111111000000001111111100000000"
187
                report "6 : v_out"
188
                severity Error;
189
 
190
            assert w_out = "11110001110000111111000111000011"
191
                report "6 : w_out"
192
                severity Error;
193
 
194
            wait;
195
    end process;
196
 
197
end;

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.