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

Subversion Repositories hicovec

[/] [hicovec/] [trunk/] [cpu/] [testbenches/] [tb_instructioncounter.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 hmanske
------------------------------------------------------------------
2
-- PROJECT:     clvp (configurable lightweight vector processor)
3
--
4
-- ENTITY:      tb_addressgroup
5
--
6
-- PURPOSE:     testbench of instruction counter 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_instructioncounter is
17
end tb_instructioncounter;
18
 
19
architecture testbench of tb_instructioncounter is
20
    component instructioncounter
21
        port(   clk:        in std_logic;
22
                load:       in std_logic;
23
                inc:        in std_logic;
24
                reset:      in std_logic;
25
                data_in:    in std_logic_vector(31 downto 0);
26
                data_out:   out std_logic_vector(31 downto 0)
27
            );
28
    end component;
29
 
30
    for impl: instructioncounter use entity work.instructioncounter(rtl);
31
 
32
    signal clk:        std_logic;
33
    signal load:       std_logic;
34
    signal inc:        std_logic;
35
    signal reset:      std_logic := '0';
36
    signal data_in:    std_logic_vector(31 downto 0);
37
    signal data_out:   std_logic_vector(31 downto 0);
38
 
39
    constant period     : time := 2ns;
40
 
41
    begin
42
        impl: instructioncounter port map (clk => clk, load => load, inc => inc, reset => reset,
43
                                           data_in => data_in, data_out => data_out);
44
    process
45
    begin
46
            wait for 100ns;
47
 
48
            -- load 1
49
            data_in <= "11001100110011001100110011001100";
50
            load <= '1';
51
            inc <= '0';
52
 
53
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
54
 
55
            assert data_out = "11001100110011001100110011001100"
56
                report "load 1 : data_out"
57
                severity Error;
58
 
59
 
60
            -- load = inc = 0
61
            data_in <= "01010101010101010101010101010101";
62
            load <= '0';
63
            inc <= '0';
64
 
65
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
66
 
67
            assert data_out = "11001100110011001100110011001100"
68
                report "load=inc=0: data_out"
69
                severity Error;
70
 
71
 
72
            -- load 2
73
            data_in <= "10101010101010101010101010101010";
74
            load <= '1';
75
            inc <= '0';
76
 
77
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
78
 
79
            assert data_out = "10101010101010101010101010101010"
80
                report "load 2 : data_out"
81
                severity Error;
82
 
83
 
84
            -- load = inc = 1
85
            data_in <= "01110001011100010111000101110001";
86
            load <= '1';
87
            inc <= '1';
88
 
89
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
90
 
91
            assert data_out = "10101010101010101010101010101010"
92
                report "load=inc=1 : data_out"
93
                severity Error;
94
 
95
 
96
            -- load 3
97
            data_in <= "11111111111111111111111111111110";
98
            load <= '1';
99
            inc <= '0';
100
 
101
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
102
 
103
            assert data_out = "11111111111111111111111111111110"
104
                report "load 3 : data_out"
105
                severity Error;
106
 
107
            -- inc
108
            data_in <= "10101010101010101010101010101010";
109
            load <= '0';
110
            inc <= '1';
111
 
112
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
113
 
114
            assert data_out = "11111111111111111111111111111111"
115
                report "inc : data_out"
116
                severity Error;
117
 
118
 
119
            -- inc overflow
120
            data_in <= "10101010101010101010101010101010";
121
            load <= '0';
122
            inc <= '1';
123
 
124
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
125
 
126
            assert data_out = "00000000000000000000000000000000"
127
                report "inc overflow: data_out"
128
                severity Error;
129
 
130
 
131
            -- reset
132
            data_in <= "10101010101010101010101010101010";
133
            load <= '1';
134
            inc <= '0';
135
 
136
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
137
 
138
            reset <= '1';
139
 
140
            clk <= '0'; wait for period / 2; clk <= '1'; wait for period / 2;
141
 
142
            assert data_out = "00000000000000000000000000000000"
143
                report "reset: data_out"
144
                severity Error;
145
 
146
            wait;
147
 
148
    end process;
149
 
150
end;

powered by: WebSVN 2.1.0

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