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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.