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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [block_ram.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  :       block_ram.vhd
33
-- Description  :       block-RAM inference
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
entity block_ram is
42
        generic (RAM_SIZE_PWR   : natural := 1);
43
        Port (clk                       : in  STD_LOGIC := '0';
44
         enable         : in  STD_LOGIC := '1';
45
         write_ptr      : in  STD_LOGIC_VECTOR;
46
         read_ptr               : in  STD_LOGIC_VECTOR;
47
                        data_in         : in    STD_LOGIC_VECTOR;
48
         data_out               : out   STD_LOGIC_VECTOR
49
                        );
50
end block_ram;
51
 
52
architecture Behavioral of block_ram is
53
 
54
        constant        WIDTH                                   : natural := data_in'length;
55
        constant        MAX_RAM_ADDRESS : natural := 2**RAM_SIZE_PWR - 1;
56
        constant ZERO                                   : STD_LOGIC_VECTOR(WIDTH - 1 downto 0) := (others => '0');
57
 
58
        type ram_pipe is array (MAX_RAM_ADDRESS downto 0) of STD_LOGIC_VECTOR(WIDTH - 1 downto 0);
59
        signal mypipe_S : ram_pipe;
60
 
61
        signal clk_S                    : STD_LOGIC;
62
        signal enable_S         : STD_LOGIC;
63
        signal write_ptr_S      : STD_LOGIC_VECTOR(RAM_SIZE_PWR - 1 downto 0) := (others => '0');
64
        signal read_ptr_S               : STD_LOGIC_VECTOR(RAM_SIZE_PWR - 1 downto 0) := (others => '0');
65
        signal data_in_S                : STD_LOGIC_VECTOR(WIDTH - 1 downto 0) := (others        => '0');
66
        signal data_out_S               : STD_LOGIC_VECTOR(WIDTH - 1 downto 0) := (others        => '0');
67
 
68
begin
69
 
70
        clk_S                   <= clk;
71
        enable_S                <=      enable;
72
        write_ptr_S     <= write_ptr;
73
        read_ptr_S      <= read_ptr;
74
        data_in_S       <= data_in;
75
        data_out                <= data_out_S;
76
 
77
        ram_RW : process (clk_S)
78
        begin
79
                if (clk_S'event and clk_S = '1') then
80
                        if (enable_S = '1') then
81
                                        mypipe_S(conv_integer(write_ptr_S)) <= data_in_S;
82
                        end if;
83
                        data_out_S <= mypipe_S(conv_integer(read_ptr_S));
84
                end if;
85
        end process;
86
 
87
end Behavioral;
88
 

powered by: WebSVN 2.1.0

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