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 : sample_counter.vhd
|
33 |
|
|
-- Description : Simple time-stamt generator. Counts samples from reset.
|
34 |
|
|
-----------------------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
library IEEE;
|
37 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
38 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
39 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
entity sample_counter is
|
43 |
|
|
Port ( rst : in STD_LOGIC;
|
44 |
|
|
clk : in STD_LOGIC;
|
45 |
|
|
enable : in STD_LOGIC := '1';
|
46 |
|
|
sample_nr_out : out STD_LOGIC_VECTOR
|
47 |
|
|
);
|
48 |
|
|
end sample_counter;
|
49 |
|
|
|
50 |
|
|
architecture Behavioral of sample_counter is
|
51 |
|
|
|
52 |
|
|
signal rst_S : std_logic := '1';
|
53 |
|
|
signal clk_S : std_logic := '0';
|
54 |
|
|
signal enable_S : std_logic := '1';
|
55 |
|
|
signal sample_nr_S : std_logic_vector (47 downto 0);
|
56 |
|
|
|
57 |
|
|
begin
|
58 |
|
|
|
59 |
|
|
rst_S <= rst;
|
60 |
|
|
clk_S <= clk;
|
61 |
|
|
enable_S <= enable;
|
62 |
|
|
sample_nr_out <= x"0000" & sample_nr_S;
|
63 |
|
|
|
64 |
|
|
process(rst_S, clk_S, enable_S)
|
65 |
|
|
|
66 |
|
|
begin
|
67 |
|
|
if (clk_S'event and clk_S = '1') then
|
68 |
|
|
if (rst_S = '1') then
|
69 |
|
|
sample_nr_S <= x"000000000001"; --(others => '0');
|
70 |
|
|
else
|
71 |
|
|
if (enable_S = '1') then
|
72 |
|
|
sample_nr_S <= sample_nr_S + 1;
|
73 |
|
|
end if;
|
74 |
|
|
end if;
|
75 |
|
|
end if;
|
76 |
|
|
end process;
|
77 |
|
|
|
78 |
|
|
end Behavioral;
|
79 |
|
|
|