history: ram modul hinzugefuegt
[hwmod.git] / src / sp_ram.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4 use work.gen_pkg.all;
5
6 -- "synchronous single port RAM
7 entity sp_ram is
8         generic (
9                 ADDR_WIDTH : integer range 1 to integer'high
10         );
11         port (
12                 sys_clk : in std_logic;
13                 sys_res_n : in std_logic;
14                 address : in std_logic_vector(ADDR_WIDTH - 1 downto 0);
15                 data_out : out hbyte;
16                 wr : in std_logic;
17                 data_in : in hbyte
18         );
19 end entity sp_ram;
20
21 architecture beh of sp_ram is
22         subtype RAM_ENTRY_TYPE is hbyte;
23         type RAM_TYPE is array (0 to (2 ** ADDR_WIDTH) - 1) of RAM_ENTRY_TYPE;
24         signal ram : RAM_TYPE := (others => x"00");
25 begin
26         process(sys_clk, sys_res_n)
27         begin
28                 if sys_res_n = '0' then
29                         ram <= (others => x"00");
30                 elsif rising_edge(sys_clk) then
31                         data_out <= ram(to_integer(unsigned(address)));
32                         if wr = '1' then
33                                 ram(to_integer(unsigned(address))) <= data_in;
34                         end if;
35                 end if;
36         end process;
37 end architecture beh;