1 |
2 |
bigsascha3 |
----------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
-- Engineer:
|
4 |
|
|
--
|
5 |
|
|
-- Create Date: 17:23:26 03/23/2013
|
6 |
|
|
-- Design Name:
|
7 |
|
|
-- Module Name: hp_maf_5_IEEE - Behavioral
|
8 |
|
|
-- Project Name:
|
9 |
|
|
-- Target Devices:
|
10 |
|
|
-- Tool versions:
|
11 |
|
|
-- Description:
|
12 |
|
|
--
|
13 |
|
|
-- Dependencies:
|
14 |
|
|
--
|
15 |
|
|
-- Revision:
|
16 |
|
|
-- Revision 0.01 - File Created
|
17 |
|
|
-- Additional Comments:
|
18 |
|
|
--
|
19 |
|
|
----------------------------------------------------------------------------------
|
20 |
|
|
library IEEE;
|
21 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
22 |
|
|
use IEEE.std_logic_signed.all;
|
23 |
|
|
use IEEE.std_logic_arith.all;
|
24 |
|
|
use IEEE.math_real.all;
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
-- Uncomment the following library declaration if using
|
28 |
|
|
-- arithmetic functions with Signed or Unsigned values
|
29 |
|
|
--use IEEE.NUMERIC_STD.ALL;
|
30 |
|
|
|
31 |
|
|
-- Uncomment the following library declaration if instantiating
|
32 |
|
|
-- any Xilinx primitives in this code.
|
33 |
|
|
--library UNISIM;
|
34 |
|
|
--use UNISIM.VComponents.all;
|
35 |
|
|
|
36 |
|
|
entity hp_maf_5_IEEE is
|
37 |
|
|
port (clk, rst : in std_logic;
|
38 |
|
|
mantissa_a, mantissa_b : in std_logic_vector(10 downto 0);
|
39 |
|
|
mantissa_c : in std_logic_vector (10 downto 0);
|
40 |
|
|
exp_a, exp_b : in std_logic_vector(4 downto 0);
|
41 |
|
|
exp_c : in std_logic_vector(4 downto 0);
|
42 |
|
|
sign_a, sign_b : in std_logic;
|
43 |
|
|
sign_c : in std_logic;
|
44 |
|
|
sub : in std_logic;
|
45 |
|
|
mantissa_res : out std_logic_vector(10 downto 0);
|
46 |
|
|
exp_res : out std_logic_vector(4 downto 0);
|
47 |
|
|
sign_res : out std_logic);
|
48 |
|
|
end hp_maf_5_IEEE;
|
49 |
|
|
|
50 |
|
|
architecture Behavioral of hp_maf_5_IEEE is
|
51 |
|
|
component exp_add_lzc
|
52 |
|
|
generic( SIZE_EXP : natural := 5;
|
53 |
|
|
SIZE_LZC : natural := 4);
|
54 |
|
|
port (exp_in : in std_logic_vector(SIZE_EXP - 1 downto 0);
|
55 |
|
|
lzc : in std_logic_vector(SIZE_LZC - 1 downto 0);
|
56 |
|
|
exp_out : out std_logic_vector (SIZE_EXP - 1 downto 0));
|
57 |
|
|
end component;
|
58 |
|
|
|
59 |
|
|
component exp_add_norm
|
60 |
|
|
generic (SIZE_EXP : natural := 5;
|
61 |
|
|
PIPELINE : natural := 0);
|
62 |
|
|
port (clk, rst : in std_logic;
|
63 |
|
|
exp_in : in std_logic_vector(SIZE_EXP - 1 downto 0);
|
64 |
|
|
ovf_norm : in std_logic_vector (1 downto 0);
|
65 |
|
|
ovf_rnd : in std_logic;
|
66 |
|
|
exp_out : out std_logic_vector(SIZE_EXP - 1 downto 0));
|
67 |
|
|
end component;
|
68 |
|
|
|
69 |
|
|
component sign_comp
|
70 |
|
|
port (sign_a, sign_b : in std_logic;
|
71 |
|
|
sign_c : in std_logic;
|
72 |
|
|
comp_exp : in std_logic;
|
73 |
|
|
eff_sub : in std_logic;
|
74 |
|
|
sign_add : in std_logic;
|
75 |
|
|
sign_res : out std_logic);
|
76 |
|
|
end component;
|
77 |
|
|
|
78 |
|
|
component exponent_align
|
79 |
|
|
generic (SIZE_EXP : natural := 5;
|
80 |
|
|
PIPELINE : natural := 2); -- nr of pipeline registers -- max 2
|
81 |
|
|
port (clk, rst : in std_logic;
|
82 |
|
|
exp_a, exp_b : in std_logic_vector (SIZE_EXP - 1 downto 0);
|
83 |
|
|
exp_c : in std_logic_vector (SIZE_EXP - 1 downto 0);
|
84 |
|
|
align : out std_logic_vector (SIZE_EXP - 1 downto 0);
|
85 |
|
|
exp_int : out std_logic_vector (SIZE_EXP downto 0);
|
86 |
|
|
comp : out std_logic);
|
87 |
|
|
end component;
|
88 |
|
|
|
89 |
|
|
component effective_op is
|
90 |
|
|
port (sign_a, sign_b, sign_c : in std_logic;
|
91 |
|
|
sub: in std_logic;
|
92 |
|
|
eff_sub : out std_logic);
|
93 |
|
|
end component;
|
94 |
|
|
|
95 |
|
|
component shift
|
96 |
|
|
generic (INPUT_SIZE : natural := 13;
|
97 |
|
|
SHIFT_SIZE : natural := 4;
|
98 |
|
|
OUTPUT_SIZE : natural := 24;
|
99 |
|
|
DIRECTION : natural := 1; -- 1 for left shift; 0 for right shift
|
100 |
|
|
PIPELINE : natural := 1;
|
101 |
|
|
POSITION : std_logic_vector(7 downto 0) := "00000000"); -- number of pipeline registers
|
102 |
|
|
port (clk, rst : in std_logic;
|
103 |
|
|
a : in std_logic_vector (INPUT_SIZE - 1 downto 0);
|
104 |
|
|
arith : in std_logic;
|
105 |
|
|
shft : in std_logic_vector (SHIFT_SIZE - 1 downto 0);
|
106 |
|
|
shifted_a : out std_logic_vector (OUTPUT_SIZE - 1 downto 0));
|
107 |
|
|
end component;
|
108 |
|
|
|
109 |
|
|
component round_norm
|
110 |
|
|
generic ( OPERAND_SIZE : natural := 24;
|
111 |
|
|
MANTISSA_SIZE : natural := 12;
|
112 |
|
|
RND_PREC : natural := 0; --0 RNE, 1 Trunc
|
113 |
|
|
PIPELINE: natural := 1); -- 0 - no pipeline
|
114 |
|
|
port ( clk, rst : std_logic;
|
115 |
|
|
mantissa_in : in std_logic_vector (OPERAND_SIZE + 1 downto 0);
|
116 |
|
|
mantissa_out: out std_logic_vector (MANTISSA_SIZE - 1 downto 0);
|
117 |
|
|
neg : in std_logic;
|
118 |
|
|
ovf_norm : out std_logic_vector(1 downto 0);
|
119 |
|
|
ovf_rnd : out std_logic);
|
120 |
|
|
end component;
|
121 |
|
|
|
122 |
|
|
component dsp_unit
|
123 |
|
|
generic (MULT_REG : natural := 1;
|
124 |
|
|
MULT_STRING : string := "MULT_S");
|
125 |
|
|
port (clk, rst : in std_logic;
|
126 |
|
|
a : in std_logic_vector(23 downto 0);
|
127 |
|
|
b : in std_logic_vector (16 downto 0);
|
128 |
|
|
c : in std_logic_vector (32 downto 0);
|
129 |
|
|
comp : in std_logic; -- 1 for a*b > c ; 0 for a*b <c
|
130 |
|
|
sub : in std_logic;
|
131 |
|
|
acc : in std_logic; -- 0 for add; 1 for accumulate
|
132 |
|
|
p: out std_logic_vector (35 downto 0);
|
133 |
|
|
pattern_detect : out std_logic;
|
134 |
|
|
ovf, udf : out std_logic);
|
135 |
|
|
end component;
|
136 |
|
|
|
137 |
|
|
component d_ff
|
138 |
|
|
generic (N: natural := 8);
|
139 |
|
|
port (clk, rst : in std_logic;
|
140 |
|
|
d : in std_logic_vector (N-1 downto 0);
|
141 |
|
|
q : out std_logic_vector (N-1 downto 0));
|
142 |
|
|
end component;
|
143 |
|
|
|
144 |
|
|
component lzc_tree
|
145 |
|
|
generic (SIZE_INT : natural := 42;
|
146 |
|
|
PIPELINE : natural := 2);
|
147 |
|
|
port (clk, rst : in std_logic;
|
148 |
|
|
a : in std_logic_vector(SIZE_INT - 1 downto 0);
|
149 |
|
|
ovf : in std_logic;
|
150 |
|
|
lz : out std_logic_vector(integer(CEIL(LOG2(real(SIZE_INT)))) - 1 downto 0));
|
151 |
|
|
end component;
|
152 |
|
|
|
153 |
|
|
signal mantissa_a_q : std_logic_vector(10 downto 0) := (others => '0');
|
154 |
|
|
signal mantissa_b_q : std_logic_vector(10 downto 0) := (others => '0');
|
155 |
|
|
signal mantissa_c_q : std_logic_vector(10 downto 0) := (others => '0');
|
156 |
|
|
-- signal sign_a_q : std_logic := '0';
|
157 |
|
|
-- signal sign_b_q : std_logic := '0';
|
158 |
|
|
-- signal sign_c_q : std_logic := '0';
|
159 |
|
|
signal sub_q : std_logic := '0';
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
signal eff_sub : std_logic;
|
163 |
|
|
signal comp : std_logic;
|
164 |
|
|
signal align : std_logic_vector (4 downto 0);
|
165 |
|
|
signal align_q : std_logic_vector (4 downto 0);
|
166 |
|
|
signal exp_int : std_logic_vector (5 downto 0);
|
167 |
|
|
signal exp_int_q0 : std_logic_vector (5 downto 0);
|
168 |
|
|
signal exp_int_q1 : std_logic_vector (5 downto 0);
|
169 |
|
|
signal exp_int_q2 : std_logic_vector (5 downto 0);
|
170 |
|
|
signal exp_int_q3 : std_logic_vector (5 downto 0);
|
171 |
|
|
signal exp_int_q4 : std_logic_vector (5 downto 0);
|
172 |
|
|
signal exp_int_q5 : std_logic_vector (5 downto 0);
|
173 |
|
|
signal exp_lzc_d, exp_lzc_q : std_logic_vector (5 downto 0);
|
174 |
|
|
signal exp_res_int : std_logic_vector (5 downto 0);
|
175 |
|
|
|
176 |
|
|
signal align_a : std_logic_vector(4 downto 0);
|
177 |
|
|
signal align_c : std_logic_vector(4 downto 0);
|
178 |
|
|
|
179 |
|
|
signal aligned_mantissa_a : std_logic_vector(22 downto 0);
|
180 |
|
|
signal a_input: std_logic_vector(23 downto 0);
|
181 |
|
|
signal aligned_mantissa_c_d : std_logic_vector(32 downto 0);
|
182 |
|
|
signal aligned_mantissa_c_q : std_logic_vector(32 downto 0);
|
183 |
|
|
signal b_input : std_logic_vector (16 downto 0);
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
signal sub_vec0, comp_vec0 : std_logic_vector(0 downto 0);
|
187 |
|
|
signal sub_dsp, comp_dsp : std_logic_vector(0 downto 0);
|
188 |
|
|
signal sub_vec, comp_vec : std_logic_vector(0 downto 0);
|
189 |
|
|
signal sub_dsp1, comp_dsp1 : std_logic_vector(0 downto 0);
|
190 |
|
|
signal sub_dsp2, comp_dsp2 : std_logic_vector(0 downto 0);
|
191 |
|
|
signal sign_d: std_logic_vector (2 downto 0);
|
192 |
|
|
signal sign_q0, sign_q1 : std_logic_vector (2 downto 0);
|
193 |
|
|
signal sign_q2, sign_q3 : std_logic_vector (2 downto 0);
|
194 |
|
|
signal acc : std_logic;
|
195 |
|
|
|
196 |
|
|
signal mantissa_mac : std_logic_vector (35 downto 0);
|
197 |
|
|
signal mantissa_abs_d, mantissa_abs_q: std_logic_vector (34 downto 0);
|
198 |
|
|
signal mantissa_abs_q1 : std_logic_vector (34 downto 0);
|
199 |
|
|
signal mantissa_lzc_d : std_logic_vector (34 downto 0);
|
200 |
|
|
signal mantissa_lzc_q : std_logic_vector (34 downto 0);
|
201 |
|
|
signal lzc_d, lzc_q : std_logic_vector (4 downto 0);
|
202 |
|
|
signal mantissa_res_d: std_logic_vector (10 downto 0);
|
203 |
|
|
|
204 |
|
|
signal sign_res1, sign_res2, sign_res3, sign_res4, sign_res5 : std_logic_vector(0 downto 0);
|
205 |
|
|
|
206 |
|
|
signal ovf_round: std_logic;
|
207 |
|
|
signal ovf_norm : std_logic_vector (1 downto 0);
|
208 |
|
|
signal sign_mantissa_add : std_logic;
|
209 |
|
|
signal ovf_mac : std_logic;
|
210 |
|
|
|
211 |
|
|
signal neg1, neg2, neg3, neg4 : std_logic_vector(0 downto 0);
|
212 |
|
|
|
213 |
|
|
signal res_zero1, res_zero2, res_zero3, res_zero4, res_zero5 : std_logic_vector(0 downto 0);
|
214 |
|
|
|
215 |
|
|
signal zero : std_logic;
|
216 |
|
|
|
217 |
|
|
begin
|
218 |
|
|
|
219 |
|
|
zero <= '0';
|
220 |
|
|
|
221 |
|
|
--STAGE 1
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
EFFECTIVE_SUB:
|
225 |
|
|
effective_op port map (sign_a => sign_a, sign_b => sign_b,
|
226 |
|
|
sign_c => sign_c,
|
227 |
|
|
sub => sub, eff_sub => eff_sub);
|
228 |
|
|
|
229 |
|
|
EXP_ALIGN : exponent_align
|
230 |
|
|
generic map (SIZE_EXP => 5, PIPELINE => 0)
|
231 |
|
|
port map (clk => clk, rst => rst,
|
232 |
|
|
exp_a => exp_a, exp_b => exp_b,
|
233 |
|
|
exp_c => exp_c, align => align,
|
234 |
|
|
exp_int => exp_int, comp=>comp);
|
235 |
|
|
|
236 |
|
|
acc <= '0';
|
237 |
|
|
|
238 |
|
|
sub_vec0(0) <= eff_sub;
|
239 |
|
|
comp_vec0(0) <= comp;
|
240 |
|
|
|
241 |
|
|
sign_d(0) <= sign_c;
|
242 |
|
|
sign_d(1) <= sign_b;
|
243 |
|
|
sign_d(2) <= sign_a;
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
mantissa_b_q <= mantissa_b;
|
248 |
|
|
sub_vec <= sub_vec0;
|
249 |
|
|
comp_vec <= comp_vec0;
|
250 |
|
|
sign_q0 <= sign_d;
|
251 |
|
|
exp_int_q0 <= exp_int;
|
252 |
|
|
align_q <= align;
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
align_a(4 downto 1) <= align_q(4 downto 1) when comp_vec(0) = '0' else
|
256 |
|
|
(others => '0');
|
257 |
|
|
|
258 |
|
|
align_a(0 downto 0) <= align(0 downto 0) when comp_vec0(0) = '0' else
|
259 |
|
|
(others => '0');
|
260 |
|
|
|
261 |
|
|
align_c(4 downto 1) <= align_q(4 downto 1) when comp_vec(0) = '1' else
|
262 |
|
|
(others => '0');
|
263 |
|
|
|
264 |
|
|
align_c(0 downto 0) <= align(0 downto 0) when comp_vec0(0) = '1' else
|
265 |
|
|
(others => '0');
|
266 |
|
|
|
267 |
|
|
-- align_a <= align_q(4 downto 0) when comp_vec(0) = '0' else
|
268 |
|
|
-- (others => '0');
|
269 |
|
|
--
|
270 |
|
|
-- align_c <= align_q when comp_vec(0) = '1' else
|
271 |
|
|
-- (others => '0');
|
272 |
|
|
|
273 |
|
|
SHIFT_A : shift
|
274 |
|
|
generic map (INPUT_SIZE => 11,
|
275 |
|
|
SHIFT_SIZE => 5,
|
276 |
|
|
OUTPUT_SIZE => 23,
|
277 |
|
|
DIRECTION => 0,
|
278 |
|
|
PIPELINE => 0,
|
279 |
|
|
POSITION => "00000001")
|
280 |
|
|
port map (clk => clk, rst => rst,
|
281 |
|
|
a => mantissa_a,
|
282 |
|
|
arith => zero,
|
283 |
|
|
shft => align_a,
|
284 |
|
|
shifted_a => aligned_mantissa_a);
|
285 |
|
|
|
286 |
|
|
SHIFT_C : shift
|
287 |
|
|
generic map (INPUT_SIZE => 11,
|
288 |
|
|
SHIFT_SIZE => 5,
|
289 |
|
|
OUTPUT_SIZE => 33,
|
290 |
|
|
DIRECTION => 0,
|
291 |
|
|
PIPELINE => 0,
|
292 |
|
|
POSITION => "00000001")
|
293 |
|
|
port map (clk => clk, rst => rst,
|
294 |
|
|
a => mantissa_c,
|
295 |
|
|
arith => zero,
|
296 |
|
|
shft => align_c,
|
297 |
|
|
shifted_a => aligned_mantissa_c_d);
|
298 |
|
|
|
299 |
|
|
b_input <=(16 downto 11 => '0')& mantissa_b_q;
|
300 |
|
|
a_input <= "0" & aligned_mantissa_a;
|
301 |
|
|
-- first pipeline register
|
302 |
|
|
-- latching mantissa_c, sub_eff, comp, exp_int, signs
|
303 |
|
|
-- a and b are latched inside the dsp block
|
304 |
|
|
|
305 |
|
|
aligned_mantissa_c_q <= aligned_mantissa_c_d;
|
306 |
|
|
sub_dsp <= sub_vec;
|
307 |
|
|
comp_dsp <= comp_vec;
|
308 |
|
|
sign_q1 <= sign_q0;
|
309 |
|
|
exp_int_q1 <= exp_int_q0;
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
-- instantiating dsp
|
313 |
|
|
|
314 |
|
|
DSP: dsp_unit
|
315 |
|
|
generic map(0, "MULT")
|
316 |
|
|
port map(clk => clk, rst => rst,
|
317 |
|
|
a => a_input,
|
318 |
|
|
b => b_input,
|
319 |
|
|
c => aligned_mantissa_c_q,
|
320 |
|
|
comp => comp_dsp(0), -- 1 for a*b > c ; 0 for a*b <c
|
321 |
|
|
sub => sub_dsp(0),
|
322 |
|
|
acc => acc, -- 0 for add; 1 for accumulate
|
323 |
|
|
p => mantissa_mac,
|
324 |
|
|
pattern_detect => res_zero1(0),
|
325 |
|
|
ovf => open, udf => open);
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
--2 pipeline registers for other signals
|
329 |
|
|
-- exp_int, signs, eff_sub
|
330 |
|
|
|
331 |
|
|
LATCH_sub_S2: d_ff
|
332 |
|
|
generic map ( N => 1)
|
333 |
|
|
port map ( clk => clk, rst => rst,
|
334 |
|
|
d=> sub_dsp, q => sub_dsp1);
|
335 |
|
|
|
336 |
|
|
LATCH_comp_S2: d_ff
|
337 |
|
|
generic map ( N => 1)
|
338 |
|
|
port map ( clk => clk, rst => rst,
|
339 |
|
|
d=> comp_dsp, q => comp_dsp1);
|
340 |
|
|
|
341 |
|
|
LATCH_sign_S2 : d_ff
|
342 |
|
|
generic map (N => 3)
|
343 |
|
|
port map (clk => clk, rst => rst,
|
344 |
|
|
d=> sign_q1, q => sign_q2);
|
345 |
|
|
|
346 |
|
|
LATCH_exp_S2 : d_ff
|
347 |
|
|
generic map (N => 6)
|
348 |
|
|
port map (clk => clk, rst => rst,
|
349 |
|
|
d=> exp_int_q1, q => exp_int_q2);
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
LATCH_sub_S3: d_ff
|
353 |
|
|
generic map ( N => 1)
|
354 |
|
|
port map ( clk => clk, rst => rst,
|
355 |
|
|
d=> sub_dsp1, q => sub_dsp2);
|
356 |
|
|
|
357 |
|
|
LATCH_comp_S3: d_ff
|
358 |
|
|
generic map ( N => 1)
|
359 |
|
|
port map ( clk => clk, rst => rst,
|
360 |
|
|
d=> comp_dsp1, q => comp_dsp2);
|
361 |
|
|
|
362 |
|
|
LATCH_sign_S3 : d_ff
|
363 |
|
|
generic map (N => 3)
|
364 |
|
|
port map (clk => clk, rst => rst,
|
365 |
|
|
d=> sign_q2, q => sign_q3);
|
366 |
|
|
|
367 |
|
|
LATCH_exp_S3 : d_ff
|
368 |
|
|
generic map (N => 6)
|
369 |
|
|
port map (clk => clk, rst => rst,
|
370 |
|
|
d=> exp_int_q2, q => exp_int_q3);
|
371 |
|
|
|
372 |
|
|
--absolute value
|
373 |
|
|
sign_mantissa_add <= mantissa_mac(35);
|
374 |
|
|
neg1(0) <= sign_mantissa_add;
|
375 |
|
|
|
376 |
|
|
mantissa_abs_d <= mantissa_mac (34 downto 0) when sign_mantissa_add = '0' else
|
377 |
|
|
not(mantissa_mac(34 downto 0));
|
378 |
|
|
|
379 |
|
|
SIGN_RESULT_COMP :
|
380 |
|
|
sign_comp
|
381 |
|
|
port map(sign_a => sign_q3(2), sign_b => sign_q3(1),
|
382 |
|
|
sign_c => sign_q3(0),
|
383 |
|
|
comp_exp => comp_dsp2(0),
|
384 |
|
|
eff_sub => sub_dsp2(0),
|
385 |
|
|
sign_add => sign_mantissa_add,
|
386 |
|
|
sign_res => sign_res1(0));
|
387 |
|
|
|
388 |
|
|
-- FOURTH PIPELINE REGISTERS
|
389 |
|
|
-- abs value of mantissa, exp_int, sign_res
|
390 |
|
|
|
391 |
|
|
-- FOURTH PIPELINE REGISTERS
|
392 |
|
|
-- abs value of mantissa, exp_int, sign_res
|
393 |
|
|
-- LATCH_MANTISSA_ABS_S4:
|
394 |
|
|
-- d_ff generic map (n => 35)
|
395 |
|
|
-- port map (clk => clk, rst => rst,
|
396 |
|
|
-- d => mantissa_abs_d, q=>mantissa_abs_q);
|
397 |
|
|
|
398 |
|
|
mantissa_abs_q <= mantissa_abs_d;
|
399 |
|
|
|
400 |
|
|
-- LATCH_sign_res_S4 : d_ff
|
401 |
|
|
-- generic map (N => 1)
|
402 |
|
|
-- port map (clk => clk, rst => rst,
|
403 |
|
|
-- d=> sign_res1, q => sign_res2);
|
404 |
|
|
|
405 |
|
|
sign_res2 <= sign_res1;
|
406 |
|
|
|
407 |
|
|
-- LATCH_exp_S4 : d_ff
|
408 |
|
|
-- generic map (N => 6)
|
409 |
|
|
-- port map (clk => clk, rst => rst,
|
410 |
|
|
-- d=> exp_int_q3, q => exp_int_q4);
|
411 |
|
|
|
412 |
|
|
exp_int_q4 <= exp_int_q3;
|
413 |
|
|
|
414 |
|
|
-- LATCH_ZERO_S4: d_ff
|
415 |
|
|
-- generic map(N=>1)
|
416 |
|
|
-- port map(clk => clk, rst =>rst,
|
417 |
|
|
-- d=>res_zero1, q=>res_zero2);
|
418 |
|
|
|
419 |
|
|
res_zero2 <= res_zero1;
|
420 |
|
|
|
421 |
|
|
-- LATCH_NEG_S4: d_ff
|
422 |
|
|
-- generic map(N=>1)
|
423 |
|
|
-- port map(clk => clk, rst =>rst,
|
424 |
|
|
-- d=>neg1, q=>neg2);
|
425 |
|
|
|
426 |
|
|
neg2 <= neg1;
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
--pipeline stage
|
430 |
|
|
ovf_mac <= mantissa_abs_q(34) or mantissa_abs_q(33);
|
431 |
|
|
|
432 |
|
|
LZC_COUNT : lzc_tree
|
433 |
|
|
generic map ( SIZE_INT => 32,
|
434 |
|
|
PIPELINE => 0)
|
435 |
|
|
port map (clk => clk, rst => rst,
|
436 |
|
|
a => mantissa_abs_q(32 downto 1),
|
437 |
|
|
ovf => ovf_mac, lz => lzc_d);
|
438 |
|
|
|
439 |
|
|
--pipeline register
|
440 |
|
|
LATCH_MANTISSA_ABS_S5:
|
441 |
|
|
d_ff generic map (n => 35)
|
442 |
|
|
port map (clk => clk, rst => rst,
|
443 |
|
|
d => mantissa_abs_q, q=>mantissa_abs_q1);
|
444 |
|
|
|
445 |
|
|
LATCH_sign_res_S5 : d_ff
|
446 |
|
|
generic map (N => 1)
|
447 |
|
|
port map (clk => clk, rst => rst,
|
448 |
|
|
d=> sign_res2, q => sign_res3);
|
449 |
|
|
|
450 |
|
|
LATCH_exp_S5 : d_ff
|
451 |
|
|
generic map (N => 6)
|
452 |
|
|
port map (clk => clk, rst => rst,
|
453 |
|
|
d=> exp_int_q4, q => exp_int_q5);
|
454 |
|
|
|
455 |
|
|
LATCH_lzc_S5 : d_ff
|
456 |
|
|
generic map (N => 5)
|
457 |
|
|
port map (clk => clk, rst => rst,
|
458 |
|
|
d=> lzc_d, q => lzc_q);
|
459 |
|
|
|
460 |
|
|
LATCH_ZERO_S5: d_ff
|
461 |
|
|
generic map(N=>1)
|
462 |
|
|
port map(clk => clk, rst =>rst,
|
463 |
|
|
d=>res_zero2, q=>res_zero3);
|
464 |
|
|
|
465 |
|
|
LATCH_NEG_S5: d_ff
|
466 |
|
|
generic map(N=>1)
|
467 |
|
|
port map(clk => clk, rst =>rst,
|
468 |
|
|
d=>neg2, q=>neg3);
|
469 |
|
|
|
470 |
|
|
|
471 |
|
|
|
472 |
|
|
SHIFT_MANTISSA : shift
|
473 |
|
|
generic map (INPUT_SIZE => 35,
|
474 |
|
|
SHIFT_SIZE => 5,
|
475 |
|
|
OUTPUT_SIZE => 35,
|
476 |
|
|
DIRECTION => 1,
|
477 |
|
|
PIPELINE => 0)
|
478 |
|
|
port map (clk => clk, rst => rst,
|
479 |
|
|
a => mantissa_abs_q1,
|
480 |
|
|
arith => neg3(0),
|
481 |
|
|
shft => lzc_q,
|
482 |
|
|
shifted_a => mantissa_lzc_d);
|
483 |
|
|
|
484 |
|
|
SUB_LZC_EXP :
|
485 |
|
|
exp_add_lzc
|
486 |
|
|
generic map(SIZE_EXP => 6, SIZE_LZC => 5)
|
487 |
|
|
port map (exp_in => exp_int_q5, lzc => lzc_q, exp_out => exp_lzc_d);
|
488 |
|
|
|
489 |
|
|
-- pipeline register 6
|
490 |
|
|
-- mantissa_lzc, exp_lzc, sign_res
|
491 |
|
|
LATCH_MANTISSA_LZC_S6:
|
492 |
|
|
d_ff generic map (n => 35)
|
493 |
|
|
port map (clk => clk, rst => rst,
|
494 |
|
|
d => mantissa_lzc_d, q=>mantissa_lzc_q);
|
495 |
|
|
|
496 |
|
|
LATCH_sign_res_S6 : d_ff
|
497 |
|
|
generic map (N => 1)
|
498 |
|
|
port map (clk => clk, rst => rst,
|
499 |
|
|
d=> sign_res3, q => sign_res4);
|
500 |
|
|
|
501 |
|
|
LATCH_exp_S6 : d_ff
|
502 |
|
|
generic map (N => 6)
|
503 |
|
|
port map (clk => clk, rst => rst,
|
504 |
|
|
d=> exp_lzc_d, q => exp_lzc_q);
|
505 |
|
|
|
506 |
|
|
LATCH_ZERO_S6: d_ff
|
507 |
|
|
generic map(N=>1)
|
508 |
|
|
port map(clk => clk, rst =>rst,
|
509 |
|
|
d=>res_zero3, q=>res_zero4);
|
510 |
|
|
|
511 |
|
|
LATCH_NEG_S6: d_ff
|
512 |
|
|
generic map(N=>1)
|
513 |
|
|
port map(clk => clk, rst =>rst,
|
514 |
|
|
d=>neg3, q=>neg4);
|
515 |
|
|
|
516 |
|
|
--rounding
|
517 |
|
|
ROUND:
|
518 |
|
|
round_norm generic map(OPERAND_SIZE => 33,
|
519 |
|
|
MANTISSA_SIZE => 11,
|
520 |
|
|
RND_PREC => 0,
|
521 |
|
|
PIPELINE => 0)
|
522 |
|
|
port map (clk => clk, rst => rst,
|
523 |
|
|
mantissa_in => mantissa_lzc_q,
|
524 |
|
|
mantissa_out => mantissa_res_d,
|
525 |
|
|
neg => neg4(0),
|
526 |
|
|
ovf_norm => ovf_norm,
|
527 |
|
|
ovf_rnd => ovf_round);
|
528 |
|
|
|
529 |
|
|
EXP_UPDATE:
|
530 |
|
|
exp_add_norm generic map (SIZE_EXP => 6, PIPELINE => 0)
|
531 |
|
|
port map (clk => clk, rst => rst,
|
532 |
|
|
exp_in => exp_lzc_q,
|
533 |
|
|
ovf_norm => ovf_norm,
|
534 |
|
|
ovf_rnd => ovf_round,
|
535 |
|
|
exp_out => exp_res_int);
|
536 |
|
|
|
537 |
|
|
|
538 |
|
|
sign_res5 <= sign_res4;
|
539 |
|
|
res_zero5 <= res_zero4;
|
540 |
|
|
|
541 |
|
|
sign_res <= sign_res5(0);
|
542 |
|
|
exp_res <= exp_res_int (4 downto 0) when res_zero5(0) = '0' else
|
543 |
|
|
(others =>'0');
|
544 |
|
|
mantissa_res <= mantissa_res_d when res_zero5(0) = '0' else
|
545 |
|
|
(others => '0');
|
546 |
|
|
|
547 |
|
|
|
548 |
|
|
end Behavioral;
|
549 |
|
|
|