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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testRegisterFile.vhd] - Blame information for rev 14

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

Line No. Rev Author Line
1 14 leonardoar
--! @file
2
--! @brief Testbench for Alu
3
 
4
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
5
LIBRARY ieee;
6
use ieee.std_logic_1164.all;
7
use ieee.std_logic_unsigned.all;
8
use ieee.std_logic_arith.all;
9
 
10
--! Use CPU Definitions package
11
use work.pkgOpenCPU32.all;
12
 
13
ENTITY testRegisterFile IS
14
END testRegisterFile;
15
 
16
--! @brief testRegisterFile Testbench file
17
--! @details Test read/write on the registers, testing also the dual port reading feature...
18
ARCHITECTURE behavior OF testRegisterFile IS
19
 
20
        --! Component declaration to instantiate the testRegisterFile circuit
21
    COMPONENT RegisterFile
22
    generic (n : integer := nBits - 1);                                         --! Generic value (Used to easily change the size of the registers)
23
         Port ( clk : in  STD_LOGIC;                                                                    --! Clock signal
24
           writeEn : in  STD_LOGIC;                                                             --! Write enable
25
           writeAddr : in  generalRegisters;                                    --! Write Adress
26
           input : in  STD_LOGIC_VECTOR (n downto 0);            --! Input 
27
           Read_A_En : in  STD_LOGIC;                                                   --! Enable read A
28
           Read_A_Addr : in  generalRegisters;                          --! Read A adress
29
           Read_B_En : in  STD_LOGIC;                                                   --! Enable read A
30
           Read_B_Addr : in  generalRegisters;                          --! Read B adress
31
           A_Out : out  STD_LOGIC_VECTOR (n downto 0);   --! Output A
32
           B_Out : out  STD_LOGIC_VECTOR (n downto 0));  --! Output B
33
    END COMPONENT;
34
 
35
 
36
   --Inputs
37
   signal clk : std_logic := '0';                                                                                                                        --! Wire to connect Test signal to component
38
   signal writeEn : std_logic := '0';                                                                                                            --! Wire to connect Test signal to component
39
   signal writeAddr : generalRegisters := r0;                                                                                   --! Wire to connect Test signal to component
40
   signal input : std_logic_vector((nBits - 1) downto 0) := (others => '0');      --! Wire to connect Test signal to component
41
   signal Read_A_En : std_logic := '0';                                                                                                  --! Wire to connect Test signal to component
42
   signal Read_A_Addr : generalRegisters := r0;                                                                                 --! Wire to connect Test signal to component
43
   signal Read_B_En : std_logic := '0';                                                                                                  --! Wire to connect Test signal to component
44
   signal Read_B_Addr : generalRegisters := r0;                                                                                 --! Wire to connect Test signal to component
45
 
46
        --Outputs
47
   signal A_Out : std_logic_vector((nBits - 1) downto 0);                                                        --! Wire to connect Test signal to component
48
   signal B_Out : std_logic_vector((nBits - 1) downto 0);                                                --! Wire to connect Test signal to component
49
 
50
        constant num_cycles : integer := 320;                                                                                                   --! Number of clock iterations
51
 
52
BEGIN
53
 
54
        --! Instantiate the Unit Under Test (RegisterFile) (Doxygen bug if it's not commented!)
55
   uut: RegisterFile PORT MAP (
56
          clk => clk,
57
          writeEn => writeEn,
58
          writeAddr => writeAddr,
59
          input => input,
60
          Read_A_En => Read_A_En,
61
          Read_A_Addr => Read_A_Addr,
62
          Read_B_En => Read_B_En,
63
          Read_B_Addr => Read_B_Addr,
64
          A_Out => A_Out,
65
          B_Out => B_Out
66
        );
67
 
68
   --! Process that will stimulate all register assignments, and reads...
69
   stim_proc: process
70
   begin
71
                -- r0=1 ... r15=16---------------------------------------------------------------------------
72
                clk <= '0';
73
                REPORT "Write r0 := 1" SEVERITY NOTE;
74
                writeEn <= '1';
75
                writeAddr <= r0;
76
                input <= conv_std_logic_vector(1, nBits);
77
                wait for 1 ns;
78
                clk <= '1';
79
                wait for 1 ns;  -- Wait to stabilize the response
80
 
81
                clk <= '0';
82
                REPORT "Write r1 := 2" SEVERITY NOTE;
83
                writeEn <= '1';
84
                writeAddr <= r1;
85
                input <= conv_std_logic_vector(2, nBits);
86
                wait for 1 ns;
87
                clk <= '1';
88
                wait for 1 ns;  -- Wait to stabilize the response
89
 
90
                clk <= '0';
91
                REPORT "Write r2 := 3" SEVERITY NOTE;
92
                writeEn <= '1';
93
                writeAddr <= r2;
94
                input <= conv_std_logic_vector(3, nBits);
95
                wait for 1 ns;
96
                clk <= '1';
97
                wait for 1 ns;  -- Wait to stabilize the response
98
 
99
                clk <= '0';
100
                REPORT "Write r3 := 4" SEVERITY NOTE;
101
                writeEn <= '1';
102
                writeAddr <= r3;
103
                input <= conv_std_logic_vector(4, nBits);
104
                wait for 1 ns;
105
                clk <= '1';
106
                wait for 1 ns;  -- Wait to stabilize the response
107
 
108
                clk <= '0';
109
                REPORT "Write r4 := 5" SEVERITY NOTE;
110
                writeEn <= '1';
111
                writeAddr <= r4;
112
                input <= conv_std_logic_vector(5, nBits);
113
                wait for 1 ns;
114
                clk <= '1';
115
                wait for 1 ns;  -- Wait to stabilize the response
116
 
117
                clk <= '0';
118
                writeEn <= '0';
119
                wait for 1 ns;  -- Wait to stabilize the response               
120
                -- Read r0..r15 PortA-------------------------------------------------------------------------
121
                REPORT "Check r0 = 1" SEVERITY NOTE;
122
                Read_A_En <= '1';
123
                Read_A_Addr <= r0;
124
                wait for 1 ns;  -- Wait to stabilize the response
125
                assert A_Out = conv_std_logic_vector(1, nBits) report "Invalid value r0" severity FAILURE;
126
 
127
                REPORT "Check r1 = 2" SEVERITY NOTE;
128
                Read_A_En <= '1';
129
                Read_A_Addr <= r1;
130
                wait for 1 ns;  -- Wait to stabilize the response
131
                assert A_Out = conv_std_logic_vector(2, nBits) report "Invalid value r1" severity FAILURE;
132
 
133
                REPORT "Check r2 = 3" SEVERITY NOTE;
134
                Read_A_En <= '1';
135
                Read_A_Addr <= r2;
136
                wait for 1 ns;  -- Wait to stabilize the response
137
                assert A_Out = conv_std_logic_vector(3, nBits) report "Invalid value r2" severity FAILURE;
138
 
139
                REPORT "Check r3 = 4" SEVERITY NOTE;
140
                Read_A_En <= '1';
141
                Read_A_Addr <= r3;
142
                wait for 1 ns;  -- Wait to stabilize the response
143
                assert A_Out = conv_std_logic_vector(4, nBits) report "Invalid value r3" severity FAILURE;
144
 
145
                REPORT "Check r4 = 5" SEVERITY NOTE;
146
                Read_A_En <= '1';
147
                Read_A_Addr <= r4;
148
                wait for 1 ns;  -- Wait to stabilize the response
149
                assert A_Out = conv_std_logic_vector(5, nBits) report "Invalid value r4" severity FAILURE;
150
 
151
      wait;
152
   end process;
153
 
154
END;

powered by: WebSVN 2.1.0

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