Basic memory unit help

Guest #3864838
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

A question of your own? This thread is over 12 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.