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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [gate_generator.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  :       gate_generator.vhd 
33
-- Description  :       Generate 2 independent gating signals upon event-detection
34
--                                              bl-gate == '1' enables collection of baseline data/samples
35
--                                              ed-gate == '1' enables event detection
36
--                                              Both are disabled at an event and remain inactive for seperate counts
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
use IEEE.numeric_std.ALL;
43
 
44
entity gate_generator is
45
        Port (  rst                                                     : in  STD_LOGIC;
46
                                clk                                                     : in  STD_LOGIC;
47
                                enable                                          : in  STD_LOGIC;
48
                                program                                         : in  STD_LOGIC;
49
                                baseline_enable                 : in  STD_LOGIC;
50
                                event_in                                                : in    STD_LOGIC;
51
                                baseline_inhibit_cnt_in : in STD_LOGIC_VECTOR;
52
                                event_inhibit_cnt_in            : in STD_LOGIC_VECTOR;
53
                                bl_gate_out                                     : out   STD_LOGIC;                      -- baseline gate-signal
54
                                ed_gate_out                                     : out   STD_LOGIC                       -- baseline gating inhibited because of event
55
                        );
56
end gate_generator;
57
 
58
architecture Behavioral of gate_generator is
59
 
60
        type Gate_state_type is (gate_idle, gate_inhibit, gate_enable);
61
 
62
        signal rst_S                                            : std_logic := '1';
63
        signal clk_S                                            : std_logic := '0';
64
        signal enable_S                                 : std_logic := '0';
65
        signal program_S                                        : std_logic := '0';
66
        signal baseline_enable_S                : std_logic := '0';
67
        signal event_in_S                                       : std_logic := '0';
68
--      signal baseline_inhibit_set_S   : STD_LOGIC_VECTOR(7 downto 0)  := conv_std_logic_vector(32,    8);     -- original default value
69
--      signal event_inhibit_set_S              : STD_LOGIC_VECTOR(7 downto 0)  := conv_std_logic_vector(20,    8);     -- original default value
70
        signal bl_gate_S                                        : std_logic := '0';
71
        signal ed_gate_S                                        : std_logic := '0';
72
--      baseline_inhibit_counter; inhibits baseline sampling at reset or event
73
--      signal bl_inhibit_cnt_S                 : std_logic_vector(M4_PWR+ 1 downto 0) := conv_std_logic_vector(BL_GATE_COUNT,M4_PWR + 2);
74
        signal bl_inhibit_cnt_S                 : std_logic_vector(7 downto 0)   := conv_std_logic_vector(32,    8);     -- original default value;
75
        signal bl_inhibit_val_S                 : std_logic_vector(7 downto 0)   := conv_std_logic_vector(32,    8);     -- original default value;
76
--      signal bl_gate_cnt_S                            : std_logic_vector(M4_PWR+ 1 downto 0) := (others => '0'); --conv_std_logic_vector(BL_GATE_COUNT,M4_PWR + 2);
77
--      event_detect_inhibit_counter; inhibits baseline sampling during event
78
--      signal ed_inhib_cnt_S                   : std_logic_vector(BASE_WINDOW_PWR+ 1 downto 0) := (others => '0'); -- conv_std_logic_vector(ED_INHIBIT_COUNT,BASE_WINDOW_PWR + 2);
79
        signal ed_inhibit_cnt_S                 : std_logic_vector(7 downto 0)   := conv_std_logic_vector(32,    8);     -- original default value;
80
        signal ed_inhibit_val_S                 : std_logic_vector(7 downto 0)   := conv_std_logic_vector(32,    8);     -- original default value;
81
 
82
begin
83
 
84
        rst_S                                                   <=      rst;
85
        clk_S                                                   <=      clk;
86
        enable_S                                        <= enable;
87
        program_S                                       <=      program;
88
        baseline_enable_S                       <=      baseline_enable;        -- allready clocked in Feature_extraction.vhd
89
        event_in_S                                      <= event_in;
90
        bl_gate_out                                     <= bl_gate_S;
91
        ed_gate_out                                     <= ed_gate_S;
92
 
93
 
94
        gate_count : process(clk_S, enable_S, event_in_S, baseline_enable_S)
95
        begin
96
                if (clk_S'event and clk_S = '1') then
97
                        if (rst_S = '1') or (program_S = '1') then
98
                                bl_inhibit_val_S                <= baseline_inhibit_cnt_in;
99
                                ed_inhibit_val_S                <= event_inhibit_cnt_in;
100
                        elsif enable_S = '1' then
101
 
102
                                if (baseline_enable_S = '1') then
103
                                --      on eventdetect, initialize event_inhibition for a fixed period
104
                                        if (event_in_S = '1') then
105
                                                ed_inhibit_cnt_S                <= ed_inhibit_val_S;
106
                                --      event_inhibition for a fixed period
107
                                        elsif (ed_inhibit_cnt_S > 0) then
108
                                                ed_inhibit_cnt_S <= ed_inhibit_cnt_S - 1;
109
                                        end if;
110
                                --      on eventdetect, initialize baseline_inhibition for a fixed period
111
                                        if (event_in_S = '1') then
112
                                                bl_inhibit_cnt_S                <= bl_inhibit_val_S;
113
                                --      event_inhibition for a fixed period
114
                                        elsif (bl_inhibit_cnt_S > 0) then
115
                                                bl_inhibit_cnt_S <= bl_inhibit_cnt_S - 1;
116
                                        end if;
117
                                end if;
118
                        end if;
119
                end if;
120
        end process;
121
 
122
        gate : process(clk_S, enable_S, event_in_S)
123
        begin
124
                if (clk_S'event and clk_S = '1') then
125
                        if (enable_S = '1') and (bl_inhibit_cnt_S = 0) and (event_in_S = '0') and (baseline_enable_S = '1') then
126
                                bl_gate_S <= '1';
127
                        else
128
                                bl_gate_S <= '0';
129
                        end if;
130
 
131
                        if (enable_S = '1') and (ed_inhibit_cnt_S = 0) and (event_in_S = '0')  and (baseline_enable_S = '1') then
132
                                ed_gate_S <= '1';
133
                        else
134
                                ed_gate_S <= '0';
135
                        end if;
136
                end if;
137
        end process;
138
 
139
end Behavioral;
140
 

powered by: WebSVN 2.1.0

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