Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
336 f9daq 1
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date: 13.10.2018 11:17:24
6
-- Design Name: 
7
-- Module Name: single_port_bram - Behavioral
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool Versions: 
11
-- Description: 
12
-- 
13
-- Dependencies: 
14
-- 
15
-- Revision:
16
-- Revision 0.01 - File Created
17
-- Additional Comments:
18
-- 
19
----------------------------------------------------------------------------------
20
 
21
 
22
library IEEE;
23
use IEEE.STD_LOGIC_1164.ALL;
24
 
25
-- Uncomment the following library declaration if using
26
-- arithmetic functions with Signed or Unsigned values
27
use IEEE.NUMERIC_STD.ALL;
28
 
29
-- Uncomment the following library declaration if instantiating
30
-- any Xilinx leaf cells in this code.
31
--library UNISIM;
32
--use UNISIM.VComponents.all;
33
 
34
entity single_port_bram is
35
 
36
    generic (
37
              bit_num : natural := 10; --number of data bits
38
              buffer_size : natural := 26); -- buffer size in bits, 5 bit gets 32 different values 
39
 
40
    port (
41
           clk: in std_logic;
42
           bram_en: in std_logic;
43
           wr_en: in std_logic;
44
           addr: in unsigned ( (buffer_size - 1) downto 0 );
45
           data_in : in unsigned ( (bit_num - 1) downto 0 ); --data from ADC
46
           data_out : out unsigned ( (bit_num - 1) downto 0 ) -- data for PE_unit
47
          );
48
 
49
end single_port_bram;
50
 
51
architecture Behavioral of single_port_bram is
52
 
53
 
54
    type BRAM_ARRAY is array ( 0 to (2**buffer_size - 1)  ) of unsigned ( (bit_num - 1) downto 0 ); -- bin_num * bit num array for hist storage
55
    signal bram : BRAM_ARRAY := (others => (others => '0'));
56
 
57
 
58
 
59
begin
60
 
61
    BRAM_handle: process(clk)
62
 
63
    begin
64
 
65
        if rising_edge(clk) then
66
            if (bram_en = '1') then
67
                if (wr_en = '1') then
68
                    bram(to_integer(addr)) <= data_in;
69
                end if;
70
                data_out <= bram(to_integer(addr));
71
            end if;
72
        end if;
73
    end process;
74
 
75
 
76
end Behavioral;