Basic memory unit help

Guest #3864838
Rate this post
useful
not useful
I get the following error when comiling:

The symbol to_int does not have a visible declaration.
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4

5

6
entity Mem is
7
generic (N: integer; -- N bits wide (# of columns)
8
         K: integer); -- K bits long (# of rows)
9
port (Din: IN std_logic_vector (N-1 downto 0);
10
      clk,rw_en: IN std_logic;
11
      add_in: IN std_logic_vector (K-1 downto 0);
12
      Dout: OUT std_logic_vector (N-1 downto 0));
13
end Mem;
14

15
architecture behavior of Mem is
16
type mem_array is array (2**K-1 downto 0) of std_logic_vector (N-1 downto 0);
17
signal our_array: mem_array := (others =>(others => '0'));
18

19
begin
20

21
process (clk, Din, rw_en, add_in)
22
--variable address: integer;
23
begin
24
  if (clk = '1' and clk'event) then
25
    if (rw_en = '1') then
26
      our_array (to_int(unsigned(add_in))) <= Din;
27
    else
28
      Dout <= our_array (to_int(unsigned(add_in)));
29
    end if;
30
  end if;
31
end process;
32
end behavior;

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now