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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_various_types/] [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      : ex1_trees_pkg package for example1
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : ex1_trees_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-24
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 adder
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
use ieee.numeric_std.all;
27
use std.textio.all;
28
library work;
29
use work.lateq_pkg.all;
30
use work.ex1_pkg.all;
31
 
32
package ex1_trees_pkg is
33
 
34
  -- Constant and type for the "Max Finder" part
35
  constant EX1_NOF_INS_IN_CMP : integer := 3;  -- number of inputs in a single comparator
36
  type T_EX1_CMP_INS is array (0 to EX1_NOF_INS_IN_CMP-1) of T_SINGLE_DATA_WITH_POS;
37
 
38
  -- Constant and type for the "Adder" part
39
  constant EX1_NOF_INS_IN_ADD : integer := 2;  -- number of inputs in a single adder
40
  type T_EX1_ADD_INS is array (0 to EX1_NOF_INS_IN_ADD-1) of T_CALC_DATA_MRK;
41
 
42
 
43
 
44
  function ex1_nof_stages (
45
    constant n_of_all_ins : integer;
46
    constant n_of_ins     : integer)
47
    return integer;
48
 
49
end package ex1_trees_pkg;
50
 
51
package body ex1_trees_pkg is
52
 
53
  -- The function returns number of stages needed to find the
54
  -- maximum element in a tree of comparators
55
  function ex1_nof_stages (
56
    constant n_of_all_ins : integer;
57
    constant n_of_ins     : integer)
58
    return integer is
59
    variable res  : integer := 0;
60
    variable nins : integer := 1;
61
  begin  -- function ex1_nof_stages
62
    nins := 1;
63
    while nins < n_of_all_ins loop
64
      nins := nins * n_of_ins;
65
      res  := res + 1;
66
    end loop;
67
    return res;
68
  end function ex1_nof_stages;
69
 
70
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.