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

Subversion Repositories ecpu_alu

[/] [ecpu_alu/] [trunk/] [alu/] [rtl/] [vhdl/] [alu_analog_tb.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 leonous
--------------------------------------------------------------------------------
2
--------------------------------------------------------------------------------
3
-- Module   - Introduction to VLSI Design [03ELD005]
4
-- Lecturer - Dr V. M. Dwyer
5
-- Course   - MEng Electronic and Electrical Engineering
6
-- Year     - Part D
7
-- Student  - Sahrfili Leonous Matturi A028459 [elslm]
8
--------------------------------------------------------------------------------
9
--------------------------------------------------------------------------------
10
-- Final coursework 2004
11
-- 
12
-- Details:     Design and Layout of an ALU
13
--------------------------------------------------------------------------------
14
--------------------------------------------------------------------------------
15
 
16
--      Description     :       ALU testbench
17
--  Entity                      :       alu_tb
18
--      Architecture    :       behavioural
19
--  Created on          :       07/03/2004
20
 
21
library ieee;
22
 
23
use ieee.std_logic_1164.all;
24
--use   ieee.std_logic_unsigned.all;    
25
--use ieee.std_logic_arith.all;                 -- for unsigned()
26
 
27
-- use std.textio.all;                                  -- for file i/o
28
-- use work.txt_util.all;                               -- for string<->other types conversions
29
 
30
entity alu_analog_tb is
31
--     port    (
32
--                      clock_tb                        : in    std_logic
33
--             );
34
end alu_analog_tb;
35
 
36
architecture behavioural of alu_analog_tb is
37
component alu
38
        port    (
39
                        A                       : in    std_logic_vector(7 downto 0);
40
                        B                       : in    std_logic_vector(7 downto 0);
41
                        S                       : in    std_logic_vector(3 downto 0);
42
                        Y                       : out   std_logic_vector(7 downto 0);
43
                        CLR             : in    std_logic                                       ;
44
                        CLK                     : in    std_logic                                       ;
45
                        C                       : out   std_logic                                       ;
46
                        V                       : out   std_logic                                       ;
47
                        Z                       : out   std_logic
48
                        );
49
end component;
50
component mtest IS
51
        PORT(
52
            clock_tb: IN STD_LOGIC;
53
            A : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
54
            B : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
55
            S : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
56
            CLR : OUT STD_LOGIC;
57
            ground_in    : IN STD_LOGIC;
58
            CLK : OUT STD_LOGIC
59
            );
60
END component;
61
 
62
-- ALU test vector record
63
--      records to store stimulus for verification
64
-- ALU access signals
65
signal                  A                       : std_logic_vector(7 downto 0)   ;
66
signal                  B                       : std_logic_vector(7 downto 0)   ;
67
signal                  S                       : std_logic_vector(3 downto 0)   ;
68
signal                  Y                       : std_logic_vector(7 downto 0)   ;
69
signal                  CLR                     : std_logic                                             ;
70
signal                  CLK                     : std_logic                                             ;
71
signal                  C                       : std_logic                                             ;
72
signal                  V                       : std_logic                                             ;
73
signal                  Z                       : std_logic                                             ;
74
signal                  clock_tb                        : std_logic                                             ;
75
signal                  ground_in                       : std_logic                                             ;
76
 
77
-- finished = '1' indicates end of test run
78
 
79
-- testbench clock half period                                  
80
constant        clock_tb_HALF_PERIOD    : time  := 10 ns                                ;
81
constant        zero                    : std_logic_vector(7 downto 0)
82
                                                                        := (others => '0');
83
signal  finished :std_logic;
84
 
85
-- procedure to write a string to the screen
86
-- procedure writestr (s : string) is
87
--      variable lout : line;
88
--      begin
89
--              write(lout, s);
90
--              writeline(output, lout);
91
--      end writestr;
92
-- 
93
-- -- procedure to write a character to the screen
94
-- procedure writechr (s : character) is
95
--      variable lout : line;
96
--      begin
97
--              write(lout, s);
98
--              writeline(output, lout);
99
--      end writechr;
100
-- 
101
type out_vector is record
102
      A           : std_logic_vector(8 downto 1)    ;
103
      B           : std_logic_vector(8 downto 1)    ;
104
      S           : std_logic_vector(4 downto 1)    ;
105
      Y           : std_logic_vector(8 downto 1)    ;
106
      CLR         : std_logic                       ;
107
      CLK         : std_logic                       ;
108
      C           : std_logic                       ;
109
      V           : std_logic                       ;
110
      Z           : std_logic                       ;
111
 end record;
112
type out_vectors is array (natural range <>) of out_vector;
113
constant vectors  : out_vectors :=  (
114
("UUUUUUUU", "UUUUUUUU", "UUUU", "UUUUUUUU", '1', '1', 'U', 'U', 'U'),
115
("01010101", "00000001", "0000", "00000000", '1', '1', '0', '0', '0'),
116
("01010101", "00000000", "0000", "00000000", '1', '1', '0', '0', '0'),
117
("01010101", "00000010", "0000", "00000000", '1', '1', '0', '0', '0'),
118
("01010101", "00000000", "0000", "00000000", '1', '1', '0', '0', '0'),
119
("01010101", "00000100", "0000", "00000000", '0', '1', '0', '0', '0'),
120
("01010101", "00000100", "0000", "00000000", '0', '1', '0', '0', '0'),
121
("01010101", "00000100", "0000", "00000000", '0', '1', '0', '0', '0'),
122
("01010101", "00000000", "0000", "01011001", '0', '1', '0', '0', '0'),
123
("01010101", "00001000", "0000", "01011001", '0', '1', '0', '0', '0'),
124
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
125
("01010101", "00010000", "0000", "01011101", '0', '1', '0', '0', '0'),
126
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
127
("01010101", "00100000", "0000", "01100101", '0', '1', '0', '0', '0'),
128
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
129
("01010101", "01000000", "0000", "01110101", '0', '1', '0', '0', '0'),
130
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
131
("01010101", "10000000", "0000", "10010101", '0', '1', '0', '0', '0'),
132
("01010101", "00000001", "0010", "01010101", '0', '1', '0', '0', '0'),
133
("01010101", "00000000", "0010", "11010101", '0', '1', '0', '0', '0'),
134
("01010101", "00000010", "0010", "01010100", '0', '1', '0', '0', '0'),
135
("01010101", "00000000", "0010", "01010101", '0', '1', '0', '0', '0'),
136
("01010101", "00000100", "0010", "01010011", '0', '1', '0', '0', '0'),
137
("01010101", "00010000", "0010", "01010101", '0', '1', '0', '0', '0'),
138
("01010101", "01000000", "0010", "01010001", '0', '1', '0', '0', '0'),
139
("01010101", "00000000", "0010", "01000101", '0', '1', '0', '0', '0'),
140
("01010101", "10000000", "0010", "00010101", '0', '1', '0', '0', '0'),
141
("01010101", "00000001", "0100", "01010101", '0', '1', '0', '0', '0'),
142
("01010101", "00000000", "0100", "11010101", '0', '1', '0', '0', '0'),
143
("01010101", "00000010", "0101", "10101010", '0', '1', '0', '0', '0'),
144
("01010101", "00000000", "0101", "01010101", '0', '1', '0', '0', '0'),
145
("01010101", "00000100", "0100", "00010101", '0', '1', '0', '0', '0'),
146
("01010101", "00010000", "0101", "01010101", '0', '1', '0', '0', '0'),
147
("01010101", "01000000", "0010", "01010000", '0', '1', '1', '0', '0'),
148
("01010101", "00000000", "0010", "01010101", '0', '1', '0', '0', '0'),
149
("01010101", "10000000", "0010", "00010101", '0', '1', '0', '0', '0'),
150
("01010101", "10000000", "0010", "01010101", '0', '1', '0', '0', '0'));
151
 
152
 
153
begin
154
 
155
        -- instantiate ALU
156
        alu_inst0       :       alu
157
                port map        (
158
                                        A                       ,
159
                                        B                       ,
160
                                        S                       ,
161
                                        Y                       ,
162
                                        CLR                     ,
163
                                        CLK                     ,
164
                                        C                       ,
165
                                        V                       ,
166
                                        Z
167
                                        );
168
mtester: mtest
169
        PORT MAP (
170
            clock_tb,
171
            A ,
172
            B ,
173
            S ,
174
            CLR,
175
            ground_in,
176
            CLK
177
            );
178
 
179
    ground_in   <= '1', '0' after 100 ns;
180
        -- apply clock stimulus
181
        clock_stim      :       process
182
                                        begin
183
                                                clock_tb        <= '1', '0' after clock_tb_HALF_PERIOD;
184
 
185
                                                if (finished /= '1') then
186
                                                        wait for 2 * clock_tb_HALF_PERIOD;
187
                                                else
188
                                                        wait; -- end test
189
                                                end if;
190
                                        end process clock_stim;
191
 
192
end behavioural;
193
 

powered by: WebSVN 2.1.0

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