aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/mem02/dpram2.vhdl
blob: d7e98d6b7ad1bbfc186aec860f07af4641ca175f (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
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity dpram1 is
  port (raddr : std_logic_vector (3 downto 0);
        rdat : out std_logic_vector (7 downto 0);
        waddr : std_logic_vector (3 downto 0);
        wdat : std_logic_vector (7 downto 0);
        clk : std_logic);
end dpram1;

architecture behav of dpram1 is
  subtype memtype is std_logic_vector (16 * 8 - 1 downto 0);
  signal mem : memtype;
begin
  process (clk)
    variable ra : natural;
    variable wa : natural;
    variable rlo, rhi : natural;
  begin
    if rising_edge (clk) then
      ra := to_integer(unsigned (raddr));
      rlo := ra * 8;
      rhi := rlo + 7;
      rdat <= mem (rhi downto rlo);
      wa := to_integer(unsigned (waddr));
      mem (wa * 8 + 7 downto wa * 8) <= wdat;
    end if;
  end process;
end behav;