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

Subversion Repositories fade_ether_protocol

[/] [fade_ether_protocol/] [trunk/] [old_stable_version/] [FPGA_no_MAC/] [src/] [common/] [dpram_inf.vhd] - Blame information for rev 34

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-- A parameterized, inferable, true dual-port, common-clock block RAM in VHDL.
2
-- Original file was taken from: http://danstrother.com/2010/09/11/inferring-rams-in-fpgas/
3
-- No license information were provided by the original author.
4
-- Minimal modifications were introduced by me to make it suitable for my FPGA
5
-- interface.
6
 
7
library ieee;
8
use ieee.std_logic_1164.all;
9
use ieee.std_logic_unsigned.all;
10
 
11
entity dp_ram_scl is
12
  generic (
13
    DATA_WIDTH : integer := 72;
14
    ADDR_WIDTH : integer := 10
15
    );
16
  port (
17
    -- Port A
18 3 wzab
    clk_a    : in  std_logic;
19 2 wzab
    we_a   : in  std_logic;
20
    addr_a : in  std_logic_vector(ADDR_WIDTH-1 downto 0);
21
    data_a : in  std_logic_vector(DATA_WIDTH-1 downto 0);
22
    q_a    : out std_logic_vector(DATA_WIDTH-1 downto 0);
23
 
24
    -- Port B
25 3 wzab
    clk_b    : in  std_logic;
26 2 wzab
    we_b   : in  std_logic;
27
    addr_b : in  std_logic_vector(ADDR_WIDTH-1 downto 0);
28
    data_b : in  std_logic_vector(DATA_WIDTH-1 downto 0);
29
    q_b    : out std_logic_vector(DATA_WIDTH-1 downto 0)
30
    );
31
end dp_ram_scl;
32
 
33
architecture rtl of dp_ram_scl is
34
  -- Shared memory
35
  type mem_type is array ((2**ADDR_WIDTH)-1 downto 0) of std_logic_vector(DATA_WIDTH-1 downto 0);
36
  shared variable mem : mem_type;
37
begin
38
 
39
-- Port A
40 3 wzab
  process(clk_a)
41 2 wzab
  begin
42 3 wzab
    if(clk_a'event and clk_a = '1') then
43 2 wzab
      if(we_a = '1') then
44
        mem(conv_integer(addr_a)) := data_a;
45
      end if;
46
      q_a <= mem(conv_integer(addr_a));
47
    end if;
48
  end process;
49
 
50
-- Port B
51 3 wzab
  process(clk_b)
52 2 wzab
  begin
53 3 wzab
    if(clk_b'event and clk_b = '1') then
54 2 wzab
      if(we_b = '1') then
55
        mem(conv_integer(addr_b)) := data_b;
56
      end if;
57
      q_b <= mem(conv_integer(addr_b));
58 3 wzab
    end if;
59 2 wzab
  end process;
60
 
61
end rtl;

powered by: WebSVN 2.1.0

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