1 |
2 |
wzab |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : Hierarchical parametrized block for finding of maximum element
|
3 |
|
|
-- Project :
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : max_finder.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: Block for finding of maximum element, version modified for
|
15 |
|
|
-- demonstration of the method for automatic adjustment of delay
|
16 |
|
|
-- in the pipelined architectures
|
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 |
|
|
|
28 |
|
|
use IEEE.NUMERIC_STD.all;
|
29 |
|
|
library work;
|
30 |
|
|
use work.lateq_pkg.all;
|
31 |
|
|
use work.ex1_pkg.all;
|
32 |
|
|
use work.ex1_trees_pkg.all;
|
33 |
|
|
|
34 |
|
|
entity max_finder is
|
35 |
|
|
generic(
|
36 |
|
|
N_OF_ALL_INS : integer
|
37 |
|
|
);
|
38 |
|
|
port (
|
39 |
|
|
dins : in T_INPUT_DATA_MRK;
|
40 |
|
|
dout : out T_SINGLE_DATA_WITH_POS;
|
41 |
|
|
clk : in std_logic;
|
42 |
|
|
rst_p : in std_logic
|
43 |
|
|
);
|
44 |
|
|
end max_finder;
|
45 |
|
|
|
46 |
|
|
architecture beh of max_finder is
|
47 |
|
|
|
48 |
|
|
constant N_OF_LEVELS : integer := ex1_nof_stages(N_OF_ALL_INS, EX1_NOF_INS_IN_CMP);
|
49 |
|
|
|
50 |
|
|
-- Due to VHDL limitations, we have to declare the array of signals
|
51 |
|
|
-- consisiting of N_OF_LEVELS * MF_NOF_INPUTS elements.
|
52 |
|
|
-- Most of them will be removed by the synthesis tools.
|
53 |
|
|
constant C_N_OF_INS_1ST_STAGE : integer := (EX1_NOF_INS_IN_CMP**N_OF_LEVELS);
|
54 |
|
|
type T_MF_INTERNAL_DATUM is array (0 to C_N_OF_INS_1ST_STAGE-1) of T_SINGLE_DATA_WITH_POS;
|
55 |
|
|
type T_MF_INTERNAL_DATA is array (0 to N_OF_LEVELS) of T_MF_INTERNAL_DATUM;
|
56 |
|
|
signal mf_internal_data : T_MF_INTERNAL_DATA := (others => (others => C_SINGLE_DATA_WITH_POS_INIT));
|
57 |
|
|
|
58 |
|
|
begin
|
59 |
|
|
-- Here we generate tree of comparators
|
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_CMP**i)-1 generate
|
63 |
|
|
signal data_in : T_EX1_CMP_INS;
|
64 |
|
|
begin
|
65 |
|
|
g3 : for k in 0 to EX1_NOF_INS_IN_CMP-1 generate
|
66 |
|
|
--assert false report "indices:" & integer'image(i) & "," & integer'image(j) & "," & integer'image(k) severity note;
|
67 |
|
|
data_in(k) <= mf_internal_data(i+1)(j*EX1_NOF_INS_IN_CMP+k);
|
68 |
|
|
end generate g3;
|
69 |
|
|
max_finder_1st_1 : entity work.max_finder_1st
|
70 |
|
|
port map (
|
71 |
|
|
dins => data_in,
|
72 |
|
|
dout => mf_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 |
|
|
--report "mf n of levels=" & integer'image(N_OF_LEVELS) severity note;
|
83 |
|
|
--report "i=" & integer'image(i) severity note;
|
84 |
|
|
mf_internal_data(n_of_levels)(i) <= (
|
85 |
|
|
-- pragma translate_off
|
86 |
|
|
lateq_mrk => dins.lateq_mrk,
|
87 |
|
|
-- pragma translate_on
|
88 |
|
|
position => i,
|
89 |
|
|
valid => true,
|
90 |
|
|
data => dins.data_vec(i)
|
91 |
|
|
);
|
92 |
|
|
end loop; -- i
|
93 |
|
|
end process;
|
94 |
|
|
dout <= mf_internal_data(0)(0);
|
95 |
|
|
end beh;
|
96 |
|
|
|