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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_single_type/] [src/] [max_finder.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 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-23
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_USER_DATA_SET(0 to N_OF_ALL_INS-1);
40
    dout  : out T_USER_DATA_MRK;
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
 
49
  constant N_OF_LEVELS : integer := ex1_nof_stages(N_OF_ALL_INS, EX1_NOF_INS_IN_CMP);
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_USER_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_USER_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 := (others => C_USER_DATA_WITH_POS_INIT);
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
        d => dins(i),
86
        p => i
87
        );
88
    end loop;  -- i
89
  end process;
90
  -- Copy the output value. Replace data value with its position!
91
  dout <= (
92
    -- pragma translate_off
93
    lateq_mrk => mf_internal_data(0)(0).d.lateq_mrk,
94
    -- pragma translate_on
95
    data => to_signed(mf_internal_data(0)(0).p, C_USER_DATA_WIDTH),
96
    valid => mf_internal_data(0)(0).d.valid
97
    );
98
 
99
end beh;
100
 

powered by: WebSVN 2.1.0

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