aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue1318/ram_blk.vhdl
blob: 85675d38a18c672d532794b400e24b56245c7d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity ram_blk is
    generic (
      AWIDTH : integer := 8;
      DWIDTH : integer := 64
      );

    port (
	clk     : in  std_logic;
	rd_addr : in  std_logic_vector(AWIDTH - 1 downto 0);
	rd_data : out std_logic_vector(DWIDTH - 1 downto 0);
	wr_en   : in  std_logic;
	wr_addr : in  std_logic_vector(AWIDTH - 1 downto 0);
	wr_data : in  std_logic_vector(DWIDTH - 1 downto 0)
	);

end ram_blk;

architecture rtl of ram_blk is
  type ram_type is
    array (0 to 2**AWIDTH - 1) of std_logic_vector(DWIDTH - 1 downto 0);

  signal ram : ram_type;
  attribute ram_style : string;
  attribute ram_style of ram : signal is "block";
  attribute ram_decomp : string;
  attribute ram_decomp of ram : signal is "power";
begin
    process(clk)
    begin
	if rising_edge(clk) then
	    if wr_en = '1' then
              ram(to_integer(unsigned(wr_addr))) <= wr_data;
	    end if;
            rd_data <= ram(to_integer(unsigned(rd_addr)));
	end if;
    end process;
end;