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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_single_type/] [src/] [ex1_trees_pkg.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : max_finder_struct_pkg package for example1
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : max_finder_struct_pkg.vhd
6
-- Author     : Wojciech M. Zabolotny ( wzab01<at>gmail.com )
7
-- Company    :
8
-- License    : BSD
9
-- Created    : 2013-11-01
10
-- Last update: 2015-09-23
11
-- Platform   : 
12
-- Standard   : VHDL'93/02
13
-------------------------------------------------------------------------------
14
-- Description: Package with definitions needed to create the hierarhical
15
--              block for finding the maximum element and hierarchical
16
--              adder.
17
-------------------------------------------------------------------------------
18
-- Copyright (c) 2014 
19
-------------------------------------------------------------------------------
20
-- Revisions  :
21
-- Date        Version  Author  Description
22
-- 2013-11-01  1.0      WZab    Created
23
-------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.numeric_std.all;
28
use std.textio.all;
29
library work;
30
use work.lateq_pkg.all;
31
use work.ex1_pkg.all;
32
 
33
package ex1_trees_pkg is
34
 
35
  -- Constants and types for the "Max Finder" part
36
  constant EX1_NOF_INS_IN_CMP : integer := 3;  -- number of inputs in a single comparator
37
  type T_EX1_CMP_INS is array (0 to EX1_NOF_INS_IN_CMP-1) of T_USER_DATA_WITH_POS;
38
 
39
  -- Constant for the "Adder" part
40
  constant EX1_NOF_INS_IN_ADD : integer := 3;  -- number of inputs in a single adder
41
  type T_EX1_ADD_INS is array (0 to EX1_NOF_INS_IN_ADD-1) of T_USER_DATA_MRK;
42
 
43
 
44
 
45
  function ex1_nof_stages (
46
    constant n_of_all_ins : integer;
47
    constant n_of_ins : integer)
48
    return integer;
49
 
50
end package ex1_trees_pkg;
51
 
52
package body ex1_trees_pkg is
53
 
54
  -- The function returns number of stages needed to find the
55
  -- maximum element in a tree of comparators or adders
56
  function ex1_nof_stages (
57
    constant n_of_all_ins : integer;
58
    constant n_of_ins : integer)
59
    return integer is
60
    variable res : integer := 0;
61
    variable nins : integer := 1;
62
  begin  -- function ex1_nof_stages
63
    nins := 1;
64
    while nins < n_of_all_ins loop
65
      nins := nins * n_of_ins;
66
      res := res + 1;
67
    end loop;
68
    return res;
69
  end function ex1_nof_stages;
70
 
71
end package body ex1_trees_pkg;

powered by: WebSVN 2.1.0

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