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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [output_mux.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
-- Company              :       KVI (Kernfysisch Versneller Instituut  -- Groningen, The Netherlands    
29
-- Author               :       P.J.J. Lemmens
30
-- Design Name  :       Feature Extraction
31
-- Module Name  :       flex_ram 
32
-- Description  :       multiplexer that collects a set of information of an event(ie.: the features)
33
--                                              This data is then combined in a packet of data to be presented as output
34
--                                              in one block.
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
entity output_mux is
42
        Port (  rst                                     :       in STD_LOGIC;
43
                                clk                                     :       in STD_LOGIC;
44
                                input_valid                     :       in      STD_LOGIC;
45
                                energy_in                       :       in      STD_LOGIC_VECTOR;
46
                                eventnr_in                      :       in      STD_LOGIC_VECTOR;
47
                                fraction_in                     :       in      STD_LOGIC_VECTOR;
48
                                output_valid            :       out     STD_LOGIC;
49
                                outdata16                       :       out     STD_LOGIC_VECTOR(15 downto 0)
50
                        );
51
end output_mux;
52
 
53
architecture Behavioral of output_mux is
54
 
55
        signal rst_S                            : std_logic := '1';
56
        signal clk_S                            : std_logic := '0';
57
        signal input_valid_S            : std_logic := '0';
58
        signal state_count_S            : natural range 0 to 8   := 0;
59
        signal energy_S                 : std_logic_vector(energy_in'high downto 0) := (others => '0');
60
        signal eventnr_S                        : std_logic_vector(63 downto 0) := (others => '0');
61
        signal fraction_S                       : std_logic_vector(15 downto 0) := (others => '0');
62
        signal outdata16_S              : std_logic_vector(15 downto 0) := (others => '0');
63
        signal output_valid_S   : std_logic := '0';
64
 
65
        begin
66
 
67
        rst_S                           <=      rst;
68
        clk_S                           <=      clk;
69
        input_valid_S   <=      input_valid;
70
        outdata16               <= outdata16_S;
71
        output_valid    <= output_valid_S;
72
 
73
 
74
        outmux : process(rst_S, clk_S, input_valid_S)--, energy_in, samplenr_in, fraction_in)
75
                begin
76
                        if (clk_S'event and clk_S= '1') then
77
                                if (rst_S = '1') then
78
                                        state_count_S   <= 0;
79
                                        fraction_S              <= (others => '0');
80
                                        outdata16_S             <= x"0000";
81
                                        output_valid_S  <= '0';
82
                                else
83
                                        if (input_valid_S = '1') then
84
                                                energy_S                                                                                                                                        <=      energy_in;
85
                                                eventnr_S                                                                                                                               <=      eventnr_in;
86
                                                fraction_S(fraction_in'high downto 0)                                                    <=      fraction_in;
87
                                                fraction_S(fraction_S'high downto fraction_in'high + 1) <=      (others => '0');
88
                                                output_valid_S                                                                                                                  <= '0';
89
                                                state_count_S                                                                                                                   <= 8;
90
                                        end if;
91
 
92
                                        case conv_integer(state_count_S) is
93
                                                when 8 =>
94
                                                        output_valid_S                                  <= '1';
95
                                                        outdata16_S(7 downto 0)          <=      x"aa";
96
                                                        outdata16_S(15 downto 8)        <= x"aa";
97
                                                        state_count_S                                   <= state_count_S - 1;
98
                                                when 7 =>
99
                                                        output_valid_S                                  <= '1';
100
                                                        outdata16_S(7 downto 0)          <=      eventnr_S(63 downto 56);
101
                                                        outdata16_S(15 downto 8)        <= eventnr_S(55 downto 48);
102
                                                        state_count_S                                   <= state_count_S - 1;
103
                                                when 6 =>
104
                                                        output_valid_S                                  <= '1';
105
                                                        outdata16_S(7 downto 0)          <=      eventnr_S(47 downto 40);
106
                                                        outdata16_S(15 downto 8)        <= eventnr_S(39 downto 32);
107
                                                        state_count_S                                   <= state_count_S - 1;
108
                                                when 5 =>
109
                                                        output_valid_S                                  <= '1';
110
                                                        outdata16_S(7 downto 0)          <=      eventnr_S(31 downto 24);
111
                                                        outdata16_S(15 downto 8)        <= eventnr_S(23 downto 16);
112
                                                        state_count_S                                   <= state_count_S - 1;
113
                                                when 4 =>
114
                                                        output_valid_S                                  <= '1';
115
                                                        outdata16_S(7 downto 0)          <= eventnr_S(15 downto 8);
116
                                                        outdata16_S(15 downto 8)        <= eventnr_S(7 downto 0);
117
                                                        state_count_S                                   <= state_count_S - 1;
118
                                                when 3 =>
119
                                                        output_valid_S                                  <= '1';
120
                                                        outdata16_S(7 downto 0)          <=      fraction_S(15 downto 8);
121
                                                        outdata16_S(15 downto 8)        <= fraction_S(7 downto 0);
122
                                                        state_count_S                                   <= state_count_S - 1;
123
                                                when 2 =>
124
                                                        output_valid_S                                  <= '1';
125
                                                        outdata16_S(7 downto 0)          <=      energy_S(15 downto 8);  --energy_S(energy_in'high - 8 downto energy_in'high - 15);
126
                                                        outdata16_S(15 downto 8)        <= energy_S(7 downto 0); --energy_S(energy_in'high downto energy_in'high - 7);
127
                                                        state_count_S                                   <= state_count_S - 1;
128
                                                when 1 =>
129
                                                        output_valid_S                                  <= '1';
130
                                                        outdata16_S(7 downto 0)          <=      x"55";
131
                                                        outdata16_S(15 downto 8)        <= x"55";
132
                                                        state_count_S                                   <= state_count_S - 1;
133
                                                when others =>
134
                                                        output_valid_S                                  <= '0';
135
                                                        outdata16_S                                             <=      (others => '0');
136
                                        end case;
137
                                end if;
138
                        end if;
139
        end process;
140
 
141
end Behavioral;
142
 

powered by: WebSVN 2.1.0

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