URL
https://opencores.org/ocsvn/lateq/lateq/trunk
Subversion Repositories lateq
[/] [lateq/] [trunk/] [hdl_single_type/] [src/] [data_sel.vhd] - Rev 2
Compare with Previous | Blame | View Log
------------------------------------------------------------------------------- -- Title : Data selector -- Project : ------------------------------------------------------------------------------- -- File : max_finder.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: This block selects from all available channels those -- which are surrounding channel number "sel" ------------------------------------------------------------------------------- -- 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; library work; use work.lateq_pkg.all; use work.ex1_pkg.all; entity data_sel is generic ( N_SIDE_CHANS : integer); port ( dins : in T_USER_DATA_SET(0 to C_N_CHANNELS-1); dout : out T_USER_DATA_SET(0 to 2*N_SIDE_CHANS); sel : in T_USER_DATA_MRK; clk : in std_logic; rst_p : in std_logic ); end data_sel; architecture beh of data_sel is begin ds1 : process (clk) is variable j : integer; begin -- process ds1 if clk'event and clk = '1' then -- rising clock edge if rst_p = '1' then -- synchronous reset (active high) dout <= (others => C_USER_DATA_MRK_INIT); else -- We select data surrounding the maximum. -- There is a problem if the maximum occures on edges of the detector. -- However in this example we simply add empty data for i in -N_SIDE_CHANS to N_SIDE_CHANS loop j := to_integer(sel.data) + i; if j < 0 then dout(i+N_SIDE_CHANS) <= C_USER_DATA_MRK_INIT; elsif j > C_N_CHANNELS-1 then dout(i+N_SIDE_CHANS) <= C_USER_DATA_MRK_INIT; else dout(i+N_SIDE_CHANS) <= dins(j); end if; end loop; end if; end if; end process ds1; end beh;