-
Notifications
You must be signed in to change notification settings - Fork 1
/
DENORMALIZE_TB.vhd
201 lines (144 loc) · 5.46 KB
/
DENORMALIZE_TB.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
library ieee;
use ieee.std_logic_1164.ALL;
entity DENORMALIZE_TB is
end DENORMALIZE_TB;
architecture behavior of DENORMALIZE_TB is
-- Component Declaration for the Unit Under Test (UUT)
component DENORMALIZE is
port(
X : in std_logic_vector(31 downto 0);
Y : in std_logic_vector(31 downto 0);
SUB : in std_logic;
DNORMX : out std_logic_vector(24 downto 0);
DNORMY : out std_logic_vector(24 downto 0);
EXP : out std_logic_vector(7 downto 0)
);
end component;
--Inputs
signal X : std_logic_vector(31 downto 0);
signal Y : std_logic_vector(31 downto 0);
signal SUB : std_logic;
--Outputs
signal DNORMX : std_logic_vector(24 downto 0);
signal DNORMY : std_logic_vector(24 downto 0);
signal EXP : std_logic_vector(7 downto 0);
begin
-- Instantiate the Unit Under Test (UUT)
UUT: DENORMALIZE
port map (
X => X,
Y => Y,
SUB => SUB,
DNORMX => DNORMX,
DNORMY => DNORMY,
EXP => EXP
);
-- Stimulus process
process
begin
X <= "00000000000000000000000000000000";
Y <= "00000000000000000000000000000000";
SUB <= '0';
wait for 100 ns;
-- SUB = 0, X positive, Y positive
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "01000100101001111010000000000000"; -- S = 0, E = 137
SUB <= '0';
-- C should be 0
-- DNORMX should be 0101001111010000000000000 ~ 10985472
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "00111110100111101011100001010010"; -- S = 0, E = 125
SUB <= '0';
-- C should be 0
-- DNORMX should be 0000000000000100111101011 ~ 2539
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "01000000110000000000000000000000"; -- S = 0, E = 129
SUB <= '0';
-- C should be 0
-- DNORMX should be 0000000001100000000000000 ~ 49152
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
-- SUB = 1, X positive, Y positive
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "01000100101001111010000000000000"; -- S = 0, E = 137
SUB <= '1';
-- C should be 0
-- DNORMX should be 1010110000110000000000000 ~ -10985472
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "00111110100111101011100001010010"; -- S = 0, E = 125
SUB <= '1';
-- C should be 0
-- DNORMX should be 1111111111111011000010101 ~ -2539
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "01000000110000000000000000000000"; -- S = 0, E = 129
SUB <= '1';
-- C should be 0
-- DNORMX should be 1111111110100000000000000 ~ -49152
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
-- SUB = 1, X positive, Y negative ~ should work just like SUB = 0, X positive, Y positive
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "11000100101001111010000000000000"; -- S = 0, E = 137
SUB <= '1';
-- C should be 0
-- DNORMX should be 0101001111010000000000000 ~ 10985472
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "10111110100111101011100001010010"; -- S = 0, E = 125
SUB <= '1';
-- C should be 0
-- DNORMX should be 0000000000000100111101011 ~ 2539
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "01000100110110110100000000000000"; -- S = 0, E = 137
Y <= "11000000110000000000000000000000"; -- S = 0, E = 129
SUB <= '1';
-- C should be 0
-- DNORMX should be 0000000001100000000000000 ~ 49152
-- DNORMY should be 0110110110100000000000000 ~ 14368768
-- EXP should be 10001001 - 137
-- SUB = 0, X negative, Y positive
wait for 20 ns;
X <= "11000100110110110100000000000000"; -- S = 0, E = 137
Y <= "01000100101001111010000000000000"; -- S = 0, E = 137
SUB <= '0';
-- C should be 0
-- DNORMX should be 0101001111010000000000000 ~ 10985472
-- DNORMY should be 0110110110100000000000000 ~ -14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "11000100110110110100000000000000"; -- S = 0, E = 137
Y <= "00111110100111101011100001010010"; -- S = 0, E = 125
SUB <= '0';
-- C should be 0
-- DNORMX should be 0000000000000100111101011 ~ 2539
-- DNORMY should be 0110110110100000000000000 ~ -14368768
-- EXP should be 10001001 - 137
wait for 20 ns;
X <= "11000100110110110100000000000000"; -- S = 0, E = 137
Y <= "01000000110000000000000000000000"; -- S = 0, E = 129
SUB <= '0';
-- C should be 0
-- DNORMX should be 0000000001100000000000000 ~ 49152
-- DNORMY should be 0110110110100000000000000 ~ -14368768
-- EXP should be 10001001 - 137
wait;
end process;
end;