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: 12.10.2018 13:26:08
6
-- Design Name: 
7
-- Module Name: dual_port_ram - 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 dual_port_bram is
35
 
36
    generic (
37
              bit_num : natural := 10;
38
              bin_num : natural := 1024; --number of histogram bins
39
              buffer_size : natural := 10 -- buffer size in bits, 5 bit gets 32 different values
40
             );
41
 
42
    port (
43
           -- A side --
44
           clk_A: in std_logic;
45
           bram_en_A: in std_logic;
46
           wr_en_A: in std_logic;
47
           addr_A: in unsigned ( (bit_num - 1) downto 0 );
48
           data_in_A: in unsigned ( buffer_size downto 0 );
49
           data_out_A: out unsigned ( buffer_size downto 0 );
50
 
51
           -- B side --
52
           clk_B: in std_logic;
53
           bram_en_B: in std_logic;
54
           wr_en_B: in std_logic;
55
           addr_B: in unsigned ( (bit_num - 1) downto 0 );
56
           data_in_B: in unsigned ( buffer_size downto 0 );
57
           data_out_B: out unsigned ( buffer_size downto 0 )
58
           );
59
 
60
end dual_port_bram;
61
 
62
architecture Behavioral of dual_port_bram is
63
 
64
    type BRAM_ARRAY is array ( 0 to (bin_num - 1) ) of unsigned ( buffer_size downto 0 );
65
    shared variable bram: BRAM_ARRAY := (others => (others => '0'));
66
 
67
 
68
 
69
 
70
begin
71
 
72
    A_side: process (clk_A)
73
    begin
74
        if (rising_edge(clk_A)) then
75
            if (bram_en_A = '1') then
76
                if (wr_en_A = '1') then
77
                    bram(to_integer(addr_A)) := data_in_A;
78
                end if;
79
                data_out_A <= bram(to_integer(addr_A));
80
            end if;
81
        end if;
82
    end process;
83
 
84
 
85
    B_side: process (clk_B)
86
    begin
87
        if (rising_edge(clk_B)) then
88
            if (bram_en_B = '1') then
89
                if (wr_en_B = '1') then
90
                    bram(to_integer(addr_B)) := data_in_B;
91
                end if;
92
                data_out_B <= bram(to_integer(addr_B));
93
            end if;
94
        end if;
95
    end process;        
96
 
97
end Behavioral;