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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [flex_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  :       flex_ram 
33
-- Description  :       Inferred like block-RAM but with configurable implementation style
34
--      
35
-----------------------------------------------------------------------------------------------
36
 
37
library IEEE;
38
use IEEE.STD_LOGIC_1164.ALL;
39
use IEEE.STD_LOGIC_ARITH.ALL;
40
use IEEE.STD_LOGIC_UNSIGNED.ALL;
41
library UNISIM;
42
use UNISIM.VComponents.all;
43
 
44
entity flex_ram is
45
        generic (RAM_SIZE_PWR   : natural       := 1;
46
                                FLEX_RAM_STYLE  : string                := "distributed");
47
        Port (clk                       : in  STD_LOGIC := '0';
48
         enable         : in  STD_LOGIC := '1';
49
         write_ptr      : in  STD_LOGIC_VECTOR;
50
         read_ptr               : in  STD_LOGIC_VECTOR;
51
                        data_in         : in    STD_LOGIC_VECTOR;
52
         data_out               : out   STD_LOGIC_VECTOR
53
                        );
54
end flex_ram;
55
 
56
architecture Behavioral of flex_ram is
57
 
58
 
59
        constant        WIDTH                                   : natural := data_in'length;
60
        constant        MAX_RAM_ADDRESS : natural := 2**RAM_SIZE_PWR - 1;
61
        constant ZERO                                   : STD_LOGIC_VECTOR(WIDTH - 1 downto 0) := (others => '0');
62
 
63
        type ram_pipe is array (MAX_RAM_ADDRESS downto 0) of STD_LOGIC_VECTOR(WIDTH - 1 downto 0);
64
        signal mypipe_S : ram_pipe;
65
        attribute ram_style                             : string;
66
        attribute ram_style of mypipe_S : signal is FLEX_RAM_STYLE;
67
 
68
        signal clk_S                    : STD_LOGIC;
69
        signal enable_S         : STD_LOGIC;
70
        signal write_ptr_S      : STD_LOGIC_VECTOR(RAM_SIZE_PWR - 1 downto 0) := (others => '0');
71
        signal read_ptr_S               : STD_LOGIC_VECTOR(RAM_SIZE_PWR - 1 downto 0) := (others => '0');
72
        signal data_in_S                : STD_LOGIC_VECTOR(WIDTH - 1 downto 0) := (others        => '0');
73
        signal data_out_S               : STD_LOGIC_VECTOR(WIDTH - 1 downto 0) := (others        => '0');
74
 
75
begin
76
 
77
        clk_S                   <= clk;
78
        enable_S                <=      enable;
79
        write_ptr_S     <= write_ptr;
80
        read_ptr_S      <= read_ptr;
81
        data_in_S       <= data_in;
82
        data_out                <= data_out_S;
83
 
84
        ram_RW : process (clk_S)
85
        begin
86
                if (clk_S'event and clk_S = '1') then
87
                        if (enable_S = '1') then
88
                                mypipe_S(conv_integer(write_ptr_S)) <= data_in_S;
89
                                data_out_S <= mypipe_S(conv_integer(read_ptr_S));
90
                        end if;
91
                end if;
92
        end process;
93
 
94
end Behavioral;
95
 

powered by: WebSVN 2.1.0

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