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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [window_subtractor_programmable.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: window_subtractor_programmable.vhd
33
-- Description: Subtracts a previous sample 'X(n-M) from the current sample 'X(n)' 
34
--                                              or vice-versa.
35
--                                              
36
-----------------------------------------------------------------------------------------------
37
 
38
library IEEE;
39
use IEEE.STD_LOGIC_1164.ALL;
40
use IEEE.STD_LOGIC_ARITH.ALL;
41
use IEEE.STD_LOGIC_SIGNED.ALL;
42
 
43
entity window_subtractor_programmable is
44
        generic(        FORWARD         :       boolean;                        -- if TRUE then (X(n) - X(n-M)) else (X(n-M) - X(n))
45
                                MAX_MWD_PWR     :       natural);               --      Mmax= 2^MAX_MWD_PWR; sets memory-size used for buffer
46
        Port (rst                               : in  STD_LOGIC;
47
                        clk                             : in  STD_LOGIC;
48
                        enable                  : IN    STD_LOGIC ;
49
                        program                 : in  STD_LOGIC;
50
                        window_pwr_in   : in  STD_LOGIC_VECTOR(7 downto 0);
51
                        data_in                 : in  STD_LOGIC_VECTOR;
52
                        data_out                        : out STD_LOGIC_VECTOR
53
                        );
54
end window_subtractor_programmable;
55
 
56
architecture Behavioral of window_subtractor_programmable is
57
 
58
        constant        WIDTH           : natural := data_in'length;
59
 
60
        component progdelay_pipeline
61
                generic (RAM_SIZE_PWR   : natural       := 1;
62
                                        FLEX_RAM_STYLE  : string                := "distributed");
63
                Port (clk                       : in  STD_LOGIC;
64
                                rst                     : in  STD_LOGIC;
65
                                enable          : in  STD_LOGIC;
66
                                program         : in  STD_LOGIC;
67
                                delay_in                : in    STD_LOGIC_VECTOR;
68
                                data_in         : in    STD_LOGIC_VECTOR;
69
                                data_out                : out   STD_LOGIC_VECTOR;
70
                                data_valid      : out   std_logic
71
                        );
72
        end component;
73
 
74
        component SISO_sub_a
75
                generic(        A_MINUS_B       :       boolean
76
                                        );
77
                port (dataa             : IN STD_LOGIC_VECTOR;
78
                                datab           : IN STD_LOGIC_VECTOR;
79
                                result  : OUT STD_LOGIC_VECTOR
80
                                );
81
        end component;
82
 
83
        component dff_re
84
                port (rst                       : in  STD_LOGIC;
85
                                clk                     : in    STD_LOGIC;
86
                                enable          : IN STD_LOGIC ;
87
                                data_valid      : out   STD_LOGIC;
88
                                d                               : in    STD_LOGIC_VECTOR;
89
                                q                               : out   STD_LOGIC_VECTOR
90
                                );
91
        end component;
92
 
93
 
94
   signal rst_S                 : std_logic := '1';
95
        signal clk_S                    : std_logic;
96
        signal enable_S         : std_logic := '1';
97
        signal program_S                : std_logic := '0';
98
        signal window_size_S    : std_logic_vector(7 downto 0)                   := (others => '0');
99
        signal data_in_S                : std_logic_vector(WIDTH - 1 downto 0) := (others => '0');
100
        signal del_data_S               : std_logic_vector(WIDTH - 1 downto 0) := (others => '0');
101
        signal sub_result_S     : std_logic_vector(WIDTH - 1 downto 0) := (others => '0');
102
        signal data_out_S               : std_logic_vector(WIDTH - 1 downto 0) := (others => '0');
103
 
104
        begin
105
                sub_delay_pipe : progdelay_pipeline
106
                        generic map(RAM_SIZE_PWR        =>      MAX_MWD_PWR,
107
                                                        FLEX_RAM_STYLE  => "distributed"
108
                                                )
109
                        PORT MAP(rst                                    => rst_S,
110
                                                clk                                     => clk_S,
111
                                                enable                          => enable_S,
112
                                                program                         => program_S,
113
                                                delay_in                                => window_size_S,
114
                                                data_in                         => data_in_S,
115
                                                data_out                        => del_data_S,
116
                                                data_valid                      => open
117
                                        );
118
 
119
                async_sub : SISO_sub_a
120
                        GENERIC MAP(A_MINUS_B   => FORWARD)
121
                        PORT MAP(dataa                          => data_in_S,
122
                                                datab                           => del_data_S,
123
                                                result                  => sub_result_S
124
                                        );
125
 
126
                output_reg : dff_re
127
                        PORT MAP(rst                                    => rst_S,
128
                                                clk                                     =>      clk_S,
129
                                                enable                          => enable_S,
130
                                                data_valid                      => open,
131
                                                d                                               =>      sub_result_S,
132
                                                q                                               =>      data_out_S
133
                                        );
134
 
135
                rst_S                                   <= rst;
136
                clk_S                                   <= clk;
137
                enable_S                                <= enable;
138
                program_S                       <= program;
139
                window_size_S           <= conv_std_logic_vector((2**conv_integer(unsigned(window_pwr_in))), 8);
140
                data_in_S                       <= data_in;
141
                data_out                                <= data_out_S;
142
 
143
end Behavioral;

powered by: WebSVN 2.1.0

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