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

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_various_types/] [src/] [data_sel.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : Data selector
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: This block selects from all available channels those
15
--              which are surrounding channel number "sel"
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
 
27
use IEEE.NUMERIC_STD.all;
28
library work;
29
use work.lateq_pkg.all;
30
use work.ex1_pkg.all;
31
 
32
entity data_sel is
33
  generic (
34
    N_SIDE_CHANS : integer);
35
  port (
36
    dins  : in  T_INPUT_DATA_MRK;
37
    dout  : out T_SEL_DATA;
38
    sel   : in  integer range 0 to C_N_CHANNELS-1;
39
    clk   : in  std_logic;
40
    rst_p : in  std_logic
41
    );
42
end data_sel;
43
 
44
architecture beh of data_sel is
45
 
46
begin
47
 
48
  ds1 : process (clk) is
49
    variable j : integer;
50
  begin  -- process ds1
51
    if clk'event and clk = '1' then     -- rising clock edge
52
      if rst_p = '1' then               -- synchronous reset (active high)
53
        dout <= C_SEL_DATA_INIT;
54
      else
55
        -- We select data surrounding the maximum.
56
        -- There is a problem if the maximum occures on edges of the detector.
57
        -- However in this example we simply add empty data
58
        for i in -N_SIDE_CHANS to N_SIDE_CHANS loop
59
          j := sel + i;
60
          if j < 0 then
61
            dout.data_vec(i+N_SIDE_CHANS) <= C_SINGLE_DATA_INIT;
62
          elsif j > C_N_CHANNELS-1 then
63
            dout.data_vec(i+N_SIDE_CHANS) <= C_SINGLE_DATA_INIT;
64
          else
65
            dout.data_vec(i+N_SIDE_CHANS) <= dins.data_vec(j);
66
          end if;
67
        end loop;
68
        -- pragma translate_off
69
        dout.lateq_mrk <= dins.lateq_mrk;
70
      -- pragma translate_on
71
      end if;
72
    end if;
73
  end process ds1;
74
 
75
end beh;
76
 

powered by: WebSVN 2.1.0

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