1 |
5 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Copyright (C) 2009
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
--
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
LIBRARY IEEE;
|
23 |
|
|
USE IEEE.std_logic_1164.ALL;
|
24 |
|
|
|
25 |
|
|
-- Purpose: Parallel adder tree.
|
26 |
|
|
-- Description:
|
27 |
|
|
-- . Add g_nof_inputs from an input vector in_dat. The number of stages in the
|
28 |
|
|
-- adder tree is ceil_log2(g_nof_inputs). Each amount of pipelining per stage
|
29 |
|
|
-- is set by g_pipeline.
|
30 |
|
|
-- Remarks:
|
31 |
|
|
-- . Use ceil_log2(g_nof_inputs) instead of true_log2() for the number of
|
32 |
|
|
-- stages in the adder tree, to have also for g_nof_inputs = 1 one stage that
|
33 |
|
|
-- effectively adds 0 to the single in_dat. In this way this 'str'
|
34 |
|
|
-- architecture behaves the same as the 'recursive' architecture for
|
35 |
|
|
-- g_nof_inputs = 1. The 'recursive' architecture uses this one bit growth
|
36 |
|
|
-- for g_nof_inputs = 1 to match the bit growth of a parallel adder in the
|
37 |
|
|
-- same stage when g_nof_inputs is odd.
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
ENTITY common_adder_tree IS
|
41 |
|
|
GENERIC (
|
42 |
|
|
g_representation : STRING := "SIGNED";
|
43 |
|
|
g_pipeline : NATURAL := 1; -- amount of pipelining per stage
|
44 |
|
|
g_nof_inputs : NATURAL := 4; -- >= 1, nof stages = ceil_log2(g_nof_inputs)
|
45 |
|
|
g_dat_w : NATURAL := (12+16)+2;
|
46 |
|
|
g_sum_w : NATURAL := (12+16)+4 -- g_dat_w + ceil_log2(g_nof_inputs)
|
47 |
|
|
);
|
48 |
|
|
PORT (
|
49 |
|
|
clk : IN STD_LOGIC;
|
50 |
|
|
clken : IN STD_LOGIC := '1';
|
51 |
|
|
in_dat : IN STD_LOGIC_VECTOR(g_nof_inputs*g_dat_w-1 DOWNTO 0);
|
52 |
|
|
sum : OUT STD_LOGIC_VECTOR( g_sum_w-1 DOWNTO 0)
|
53 |
|
|
);
|
54 |
|
|
END common_adder_tree;
|