blob: 408051f645c290b23f38cac8d7e021d2bc6a91c4 (
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
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity mem is
generic(
addr_width : integer := 6;
bus_width : integer := 14
);
port (
clk : in std_logic;
rstn : in std_logic; -- not implemented
en : in std_logic;
cs : in std_logic; -- not implemented
addr : in unsigned(addr_width-1 downto 0);
din : in unsigned(bus_width-1 downto 0);
dout : out unsigned(bus_width-1 downto 0)
);
end entity;
architecture rtl of mem is
type mem_Type is array (255 downto 0) of unsigned(bus_width-1 downto 0);
signal mem : mem_Type;
signal al : unsigned(addr_width-1 downto 0) := X"00";
begin
dout <= mem(to_integer(al));
process (clk) is
begin
if rising_edge(clk) then
al <= addr;
if en = '1' then
mem(to_integer(addr)) <= din;
end if;
end if;
end process;
end architecture;
|