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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_various_types/] [src/] [tree_adder.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : Hierarchical parametrized block for calculation of sum of
3
--              multiple values
4
-- Project    : 
5
-------------------------------------------------------------------------------
6
-- File       : tree_adder.vhd
7
-- Author     : Wojciech M. Zabolotny ( wzab01<at>gmail.com )
8
-- Company    :
9
-- License    : BSD
10
-- Created    : 2013-11-01
11
-- Last update: 2015-09-24
12
-- Platform   : 
13
-- Standard   : VHDL'93/02
14
-------------------------------------------------------------------------------
15
-- Description: 
16
-------------------------------------------------------------------------------
17
-- Copyright (c) 2014 
18
-------------------------------------------------------------------------------
19
-- Revisions  :
20
-- Date        Version  Author  Description
21
-- 2013-11-01  1.0      WZab    Created
22
-------------------------------------------------------------------------------
23
 
24
library IEEE;
25
use IEEE.STD_LOGIC_1164.all;
26
 
27
use IEEE.NUMERIC_STD.all;
28
library work;
29
use work.lateq_pkg.all;
30
use work.ex1_pkg.all;
31
use work.ex1_trees_pkg.all;
32
 
33
entity tree_adder is
34
  generic(
35
    N_OF_ALL_INS : integer
36
    );
37
  port (
38
    dins  : in  T_CALC_SEL_DATA;
39
    dout  : out T_CALC_DATA_MRK;
40
    clk   : in  std_logic;
41
    rst_p : in  std_logic
42
    );
43
end tree_adder;
44
 
45
architecture beh of tree_adder is
46
 
47
  constant N_OF_LEVELS : integer := ex1_nof_stages(N_OF_ALL_INS, EX1_NOF_INS_IN_ADD);
48
 
49
  -- Due to VHDL limitations, we have to declare the array of signals
50
  -- consisiting of N_OF_LEVELS * MF_NOF_INPUTS elements.
51
  -- Most of them will be removed by the synthesis tools.
52
  constant C_N_OF_INS_1ST_STAGE : integer             := (EX1_NOF_INS_IN_ADD**N_OF_LEVELS);
53
  type T_ADD_INTERNAL_DATUM is array (0 to C_N_OF_INS_1ST_STAGE-1) of T_CALC_DATA_MRK;
54
  type T_ADD_INTERNAL_DATA is array (0 to N_OF_LEVELS) of T_ADD_INTERNAL_DATUM;
55
  signal add_internal_data      : T_ADD_INTERNAL_DATA := (others => (others => C_CALC_DATA_MRK_INIT));
56
 
57
begin
58
 
59
  -- Here we generate tree of adders
60
  g1 : for i in 0 to n_of_levels-1 generate
61
    -- level 0 is the output level
62
    g2 : for j in 0 to (EX1_NOF_INS_IN_ADD**i)-1 generate
63
      signal data_in : T_EX1_ADD_INS;
64
    begin
65
      g3 : for k in 0 to EX1_NOF_INS_IN_ADD-1 generate
66
        --assert false report "indices:" & integer'image(i) & "," & integer'image(j) & "," & integer'image(k) severity note;
67
        data_in(k) <= add_internal_data(i+1)(j*EX1_NOF_INS_IN_ADD+k);
68
      end generate g3;
69
      tree_adder_1st_1 : entity work.tree_adder_1st
70
        port map (
71
          dins  => data_in,
72
          dout  => add_internal_data(i)(j),
73
          clk   => clk,
74
          rst_p => rst_p);
75
    end generate g2;
76
  end generate g1;
77
 
78
  -- Process connecting the inputs
79
  process (dins) is
80
  begin  -- process
81
    for i in 0 to N_OF_ALL_INS-1 loop
82
      -- Here we may need to explicitly copy fields!
83
      add_internal_data(n_of_levels)(i) <= (
84
        -- pragma translate_off
85
        lateq_mrk => dins.lateq_mrk,
86
        -- pragma translate_on        
87
        sum       => dins.data_vec(i),
88
        valid     => true
89
 
90
        );
91
    end loop;  -- i
92
  end process;
93
  dout <= add_internal_data(0)(0);
94
end beh;

powered by: WebSVN 2.1.0

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