URL
https://opencores.org/ocsvn/lateq/lateq/trunk
Subversion Repositories lateq
[/] [lateq/] [trunk/] [hdl_single_type/] [src/] [ex1_trees_pkg.vhd] - Rev 2
Compare with Previous | Blame | View Log
------------------------------------------------------------------------------- -- Title : max_finder_struct_pkg package for example1 -- Project : ------------------------------------------------------------------------------- -- File : max_finder_struct_pkg.vhd -- Author : Wojciech M. Zabolotny ( wzab01<at>gmail.com ) -- Company : -- License : BSD -- Created : 2013-11-01 -- Last update: 2015-09-23 -- Platform : -- Standard : VHDL'93/02 ------------------------------------------------------------------------------- -- Description: Package with definitions needed to create the hierarhical -- block for finding the maximum element and hierarchical -- adder. ------------------------------------------------------------------------------- -- Copyright (c) 2014 ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2013-11-01 1.0 WZab Created ------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use std.textio.all; library work; use work.lateq_pkg.all; use work.ex1_pkg.all; package ex1_trees_pkg is -- Constants and types for the "Max Finder" part constant EX1_NOF_INS_IN_CMP : integer := 3; -- number of inputs in a single comparator type T_EX1_CMP_INS is array (0 to EX1_NOF_INS_IN_CMP-1) of T_USER_DATA_WITH_POS; -- Constant for the "Adder" part constant EX1_NOF_INS_IN_ADD : integer := 3; -- number of inputs in a single adder type T_EX1_ADD_INS is array (0 to EX1_NOF_INS_IN_ADD-1) of T_USER_DATA_MRK; function ex1_nof_stages ( constant n_of_all_ins : integer; constant n_of_ins : integer) return integer; end package ex1_trees_pkg; package body ex1_trees_pkg is -- The function returns number of stages needed to find the -- maximum element in a tree of comparators or adders function ex1_nof_stages ( constant n_of_all_ins : integer; constant n_of_ins : integer) return integer is variable res : integer := 0; variable nins : integer := 1; begin -- function ex1_nof_stages nins := 1; while nins < n_of_all_ins loop nins := nins * n_of_ins; res := res + 1; end loop; return res; end function ex1_nof_stages; end package body ex1_trees_pkg;