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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [timing_linear_interp.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 panda_emc
-----------------------------------------------------------------------------------------------
2
--
3
--    Copyright (C) 2011 Peter Lemmens, PANDA collaboration
4
--              p.j.j.lemmens@rug.nl
5
--    http://www-panda.gsi.de
6
--
7
--    As a reference, please use:
8
--    E. Guliyev, M. Kavatsyuk, P.J.J. Lemmens, G. Tambave, H. Loehner,
9
--    "VHDL Implementation of Feature-Extraction Algorithm for the PANDA Electromagnetic Calorimeter"
10
--    Nuclear Inst. and Methods in Physics Research, A ....
11
--
12
--
13
--    This program is free software; you can redistribute it and/or modify
14
--    it under the terms of the GNU Lesser General Public License as published by
15
--    the Free Software Foundation; either version 3 of the License, or
16
--    (at your option) any later version.
17
--
18
--    This program is distributed in the hope that it will be useful,
19
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
20
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
--    GNU Lesser General Public License for more details.
22
--
23
--    You should have received a copy of the GNU General Public License
24
--    along with this program; if not, write to the Free Software
25
--    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
26
--
27
-----------------------------------------------------------------------------------------------
28
-----------------------------------------------------------------------------------------------
29
-- Company              :       KVI (Kernfysisch Versneller Instituut  -- Groningen, The Netherlands    
30
-- Author               :       P.J.J. Lemmens
31
-- Design Name  :       Feature Extraction
32
-- Module Name  :       timing_linear_interp
33
-- Description  :       calculates a binary time-fraction through linear interpolation between
34
--                                              two neighbouring samples; "INTERP_CYCLES" determines the number of bits
35
--                                              bits are right-alligned with the msb on the left (as usual)
36
--                                              msb=1/2, msb+1=1/4, msb+2=1/8 etc.
37
-----------------------------------------------------------------------------------------------
38
library IEEE;
39
use IEEE.STD_LOGIC_1164.ALL;
40
use IEEE.STD_LOGIC_ARITH.ALL;
41
use IEEE.STD_LOGIC_UNSIGNED.ALL;
42
 
43
entity timing_linear_interp is
44
        generic(        INTERP_CYCLES                   :       natural :=      1);
45
        Port (  rst                                     :       in              STD_LOGIC;
46
                                clk                                     :       in              STD_LOGIC;
47
                                enable                          :       in              STD_LOGIC := '1';
48
                                trigger                         :       in              STD_LOGIC;
49
                                data_in                         :       in              STD_LOGIC_VECTOR;
50
                                samplenr_in                     :       in              STD_LOGIC_VECTOR;
51
                                eventnr_out                     :       out     STD_LOGIC_VECTOR;
52
                                fraction_out            :       out     STD_LOGIC_VECTOR;
53
                                eventdata_valid :       out     STD_LOGIC
54
                        );
55
end timing_linear_interp;
56
 
57
architecture Behavioral of timing_linear_interp is
58
 
59
        constant        WIDTH                           :       natural := data_in'length;
60
--      constant        ZEROX_WINDOW    :       natural := 2**ZEROX_WINDOW_PWR;
61
--      constant        MAX_PIPE_IDX    :       natural :=      ZEROX_WINDOW - 1;
62
        constant FRACTION_SIZE  :       natural := INTERP_CYCLES; --    - ZEROX_WINDOW_PWR; --all  interp bits are fraction now !! interp between 2 samples
63
 
64
        component window_diff
65
--              generic(        DEPTH_PWR       :       natural);
66
                Port (  rst                     : in    STD_LOGIC;
67
                                        clk                     : in    STD_LOGIC;
68
                                        enable          : in  STD_LOGIC := '1';
69
                                        trigger         : in    STD_LOGIC;
70
                                        data_in         : in    STD_LOGIC_VECTOR;
71
                                        base_out                : out   STD_LOGIC_VECTOR;
72
                                        diff_out                : out   STD_LOGIC_VECTOR
73
                                );
74
        end component;
75
 
76
        component successive_interp
77
                generic(        ITERATIONS                      :       natural :=      1
78
                                );
79
                Port (rst                               : in    STD_LOGIC;
80
                                clk                             : in    STD_LOGIC;
81
                                enable                  : in  STD_LOGIC := '1';
82
                                trigger                 : in    STD_LOGIC;
83
                                samplenr_in             : in    STD_LOGIC_VECTOR;
84
                                base_in                 : in    STD_LOGIC_VECTOR;
85
                                diff_in                 : in    STD_LOGIC_VECTOR;
86
                                output_valid    : out   STD_LOGIC;
87
                                fraction_out    : out   STD_LOGIC_VECTOR;
88
                                eventnr_out             : out   STD_LOGIC_VECTOR
89
                                );
90
        end component;
91
 
92
--------------------------------------------------------------------------------------------------
93
        signal rst_S                                    : std_logic := '1';
94
        signal clk_S                                    : std_logic := '0';
95
        signal enable_S                         : std_logic := '0';
96
        signal data_in_S                                : std_logic_vector (WIDTH - 1 downto 0) := (others => '0');
97
        signal trigger_S                                : std_logic := '0';
98
        signal base_val_S                               : std_logic_vector(WIDTH - 1 downto 0) := (others => '0');
99
        signal window_diff_S                    : std_logic_vector(WIDTH - 1 downto 0) := (others => '0');
100
        signal samplenr_in_S                    : std_logic_vector(samplenr_in'high downto 0) := (others => '0');
101
        signal eventdata_valid_S        : std_logic := '0';
102
        signal eventnr_out_S                    : std_logic_vector(samplenr_in'high downto 0) := (others => '0');
103
        signal fraction_out_S           : std_logic_vector(FRACTION_SIZE - 1 downto 0) := (others => '0');
104
--------------------------------------------------------------------------------------------------
105
 
106
        begin
107
 
108
                window_slope : window_diff
109
                        port map        (       rst                     => rst_S,
110
                                                        clk                     => clk_S,
111
                                                        enable          =>      enable_S,                       -- this pipe is allways running !!
112
                                                        trigger         =>      trigger_S,
113
                                                        data_in         =>      data_in_S,
114
                                                        base_out                =>      base_val_S,
115
                                                        diff_out                =>      window_diff_S
116
                                                );
117
 
118
                interp : successive_interp
119
                        generic map     (       ITERATIONS                      =>      INTERP_CYCLES)
120
                        port map        (       rst                             => rst_S,
121
                                                        clk                             => clk_S,
122
                                                        enable                  =>      enable_S,                       -- this pipe is allways running !!
123
                                                        trigger                 =>      trigger_S,
124
                                                        samplenr_in             => samplenr_in_S,
125
                                                        base_in                 =>      base_val_S,
126
                                                        diff_in                 =>      window_diff_S,
127
                                                        output_valid    => eventdata_valid_S,
128
                                                        fraction_out    =>      fraction_out_S,
129
                                                        eventnr_out             => eventnr_out_S
130
                                                );
131
 
132
 
133
                rst_S                                   <=      rst;
134
                clk_S                                   <=      clk;
135
                enable_S                                <=      enable;
136
                data_in_S                       <=      data_in;
137
                samplenr_in_S           <= samplenr_in;
138
                eventnr_out                     <= eventnr_out_S;
139
                fraction_out            <=      fraction_out_S;
140
                eventdata_valid <= eventdata_valid_S;
141
 
142
        sync_proc : process(rst_S, clk_S, enable_S, trigger, eventnr_out_S)
143
                begin
144
                        if (clk_S'event and clk_S = '1') then
145
                                if (rst_S = '1') then
146
                                        trigger_S               <=      '0';
147
                                else
148
                                        if  (enable_S = '1') then
149
                                                trigger_S               <=      trigger;
150
                                        end if;
151
                                end if;
152
                        end if;
153
        end process;
154
 
155
end Behavioral;
156
 

powered by: WebSVN 2.1.0

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