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_cadence_tb is
|
31 |
|
|
port (
|
32 |
|
|
clock_tb : in std_logic
|
33 |
|
|
);
|
34 |
|
|
end alu_analog_cadence_tb;
|
35 |
|
|
|
36 |
|
|
architecture behavioural of alu_analog_cadence_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 |
|
|
reset : 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 |
|
|
|
51 |
|
|
-- ALU test vector record
|
52 |
|
|
-- records to store stimulus for verification
|
53 |
|
|
-- ALU access signals
|
54 |
|
|
signal A : std_logic_vector(7 downto 0) ;
|
55 |
|
|
signal B : std_logic_vector(7 downto 0) ;
|
56 |
|
|
signal S : std_logic_vector(3 downto 0) ;
|
57 |
|
|
signal Y : std_logic_vector(7 downto 0) ;
|
58 |
|
|
signal CLR : std_logic ;
|
59 |
|
|
signal CLK : std_logic ;
|
60 |
|
|
signal C : std_logic ;
|
61 |
|
|
signal V : std_logic ;
|
62 |
|
|
signal Z : std_logic ;
|
63 |
|
|
-- signal clock_tb : std_logic ;
|
64 |
|
|
--
|
65 |
|
|
-- -- finished = '1' indicates end of test run
|
66 |
|
|
--
|
67 |
|
|
-- -- testbench clock half period
|
68 |
|
|
-- constant clock_tb_HALF_PERIOD : time := 10 ns ;
|
69 |
|
|
constant zero : std_logic_vector(7 downto 0)
|
70 |
|
|
:= (others => '0');
|
71 |
|
|
signal finished :std_logic;
|
72 |
|
|
|
73 |
|
|
-- procedure to write a string to the screen
|
74 |
|
|
-- procedure writestr (s : string) is
|
75 |
|
|
-- variable lout : line;
|
76 |
|
|
-- begin
|
77 |
|
|
-- write(lout, s);
|
78 |
|
|
-- writeline(output, lout);
|
79 |
|
|
-- end writestr;
|
80 |
|
|
--
|
81 |
|
|
-- -- procedure to write a character to the screen
|
82 |
|
|
-- procedure writechr (s : character) is
|
83 |
|
|
-- variable lout : line;
|
84 |
|
|
-- begin
|
85 |
|
|
-- write(lout, s);
|
86 |
|
|
-- writeline(output, lout);
|
87 |
|
|
-- end writechr;
|
88 |
|
|
--
|
89 |
|
|
type out_vector is record
|
90 |
|
|
A : std_logic_vector(8 downto 1) ;
|
91 |
|
|
B : std_logic_vector(8 downto 1) ;
|
92 |
|
|
S : std_logic_vector(4 downto 1) ;
|
93 |
|
|
Y : std_logic_vector(8 downto 1) ;
|
94 |
|
|
CLR : std_logic ;
|
95 |
|
|
CLK : std_logic ;
|
96 |
|
|
C : std_logic ;
|
97 |
|
|
V : std_logic ;
|
98 |
|
|
Z : std_logic ;
|
99 |
|
|
end record;
|
100 |
|
|
type out_vectors is array (natural range <>) of out_vector;
|
101 |
|
|
constant vectors : out_vectors := (
|
102 |
|
|
("UUUUUUUU", "UUUUUUUU", "UUUU", "UUUUUUUU", '1', '1', 'U', 'U', 'U'),
|
103 |
|
|
("01010101", "00000001", "0000", "00000000", '1', '1', '0', '0', '0'),
|
104 |
|
|
("01010101", "00000000", "0000", "00000000", '1', '1', '0', '0', '0'),
|
105 |
|
|
("01010101", "00000010", "0000", "00000000", '1', '1', '0', '0', '0'),
|
106 |
|
|
("01010101", "00000000", "0000", "00000000", '1', '1', '0', '0', '0'),
|
107 |
|
|
("01010101", "00000100", "0000", "00000000", '0', '1', '0', '0', '0'),
|
108 |
|
|
("01010101", "00000100", "0000", "00000000", '0', '1', '0', '0', '0'),
|
109 |
|
|
("01010101", "00000100", "0000", "00000000", '0', '1', '0', '0', '0'),
|
110 |
|
|
("01010101", "00000000", "0000", "01011001", '0', '1', '0', '0', '0'),
|
111 |
|
|
("01010101", "00001000", "0000", "01011001", '0', '1', '0', '0', '0'),
|
112 |
|
|
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
|
113 |
|
|
("01010101", "00010000", "0000", "01011101", '0', '1', '0', '0', '0'),
|
114 |
|
|
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
|
115 |
|
|
("01010101", "00100000", "0000", "01100101", '0', '1', '0', '0', '0'),
|
116 |
|
|
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
|
117 |
|
|
("01010101", "01000000", "0000", "01110101", '0', '1', '0', '0', '0'),
|
118 |
|
|
("01010101", "00000000", "0000", "01010101", '0', '1', '0', '0', '0'),
|
119 |
|
|
("01010101", "10000000", "0000", "10010101", '0', '1', '0', '0', '0'),
|
120 |
|
|
("01010101", "00000001", "0010", "01010101", '0', '1', '0', '0', '0'),
|
121 |
|
|
("01010101", "00000000", "0010", "11010101", '0', '1', '0', '0', '0'),
|
122 |
|
|
("01010101", "00000010", "0010", "01010100", '0', '1', '0', '0', '0'),
|
123 |
|
|
("01010101", "00000000", "0010", "01010101", '0', '1', '0', '0', '0'),
|
124 |
|
|
("01010101", "00000100", "0010", "01010011", '0', '1', '0', '0', '0'),
|
125 |
|
|
("01010101", "00010000", "0010", "01010101", '0', '1', '0', '0', '0'),
|
126 |
|
|
("01010101", "01000000", "0010", "01010001", '0', '1', '0', '0', '0'),
|
127 |
|
|
("01010101", "00000000", "0010", "01000101", '0', '1', '0', '0', '0'),
|
128 |
|
|
("01010101", "10000000", "0010", "00010101", '0', '1', '0', '0', '0'),
|
129 |
|
|
("01010101", "00000001", "0100", "01010101", '0', '1', '0', '0', '0'),
|
130 |
|
|
("01010101", "00000000", "0100", "11010101", '0', '1', '0', '0', '0'),
|
131 |
|
|
("01010101", "00000010", "0101", "10101010", '0', '1', '0', '0', '0'),
|
132 |
|
|
("01010101", "00000000", "0101", "01010101", '0', '1', '0', '0', '0'),
|
133 |
|
|
("01010101", "00000100", "0100", "00010101", '0', '1', '0', '0', '0'),
|
134 |
|
|
("01010101", "00010000", "0101", "01010101", '0', '1', '0', '0', '0'),
|
135 |
|
|
("01010101", "01000000", "0010", "01010000", '0', '1', '1', '0', '0'),
|
136 |
|
|
("01010101", "00000000", "0010", "01010101", '0', '1', '0', '0', '0'),
|
137 |
|
|
("01010101", "10000000", "0010", "00010101", '0', '1', '0', '0', '0'),
|
138 |
|
|
("01010101", "10000000", "0010", "01010101", '0', '1', '0', '0', '0'));
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
begin
|
142 |
|
|
|
143 |
|
|
-- instantiate ALU
|
144 |
|
|
alu_inst0 : alu
|
145 |
|
|
port map (
|
146 |
|
|
A ,
|
147 |
|
|
B ,
|
148 |
|
|
S ,
|
149 |
|
|
Y ,
|
150 |
|
|
CLR ,
|
151 |
|
|
CLK ,
|
152 |
|
|
C ,
|
153 |
|
|
V ,
|
154 |
|
|
Z
|
155 |
|
|
);
|
156 |
|
|
|
157 |
|
|
-- apply clock stimulus
|
158 |
|
|
-- clock_stim : process
|
159 |
|
|
-- begin
|
160 |
|
|
-- clock_tb <= '1', '0' after clock_tb_HALF_PERIOD;
|
161 |
|
|
--
|
162 |
|
|
-- if (finished /= '1') then
|
163 |
|
|
-- wait for 2 * clock_tb_HALF_PERIOD;
|
164 |
|
|
-- else
|
165 |
|
|
-- wait; -- end test
|
166 |
|
|
-- end if;
|
167 |
|
|
-- end process clock_stim;
|
168 |
|
|
|
169 |
|
|
vector_stim_in : process ( clock_tb )
|
170 |
|
|
variable i : integer := 0;
|
171 |
|
|
begin
|
172 |
|
|
if (clock_tb'event and clock_tb = '1') then
|
173 |
|
|
if ( i <= vectors'high) then
|
174 |
|
|
A <= vectors(i).A;
|
175 |
|
|
B <= vectors(i).B;
|
176 |
|
|
S <= vectors(i).S;
|
177 |
|
|
--Y <= vectors(i).Y;
|
178 |
|
|
CLR <= vectors(i).CLR;
|
179 |
|
|
CLK <= vectors(i).CLK;
|
180 |
|
|
--C <= vectors(i).C;
|
181 |
|
|
--V <= vectors(i).V;
|
182 |
|
|
--Z <= vectors(i).Z;
|
183 |
|
|
|
184 |
|
|
i := i + 1;
|
185 |
|
|
else
|
186 |
|
|
finished <= '1';
|
187 |
|
|
end if;
|
188 |
|
|
else
|
189 |
|
|
CLK <= clock_tb;
|
190 |
|
|
end if;
|
191 |
|
|
|
192 |
|
|
end process vector_stim_in;
|
193 |
|
|
end behavioural;
|
194 |
|
|
|