1
我试图使用RAM来读/写。我的地址是一个整数值,它应该是一个整数的内存。这是我的代码在下面,但我不断收到错误。RAM在VHDL中读写
这是从我的数据路径中,地址选择来自整数寄存器。
代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity Mem is
generic( width: integer:=4;
depth: integer:=4;
addr: integer:=2);
port( Clock: in std_logic;
Enable: in std_logic;
Read: in std_logic;
Write: in std_logic;
Read_Addr: in integer;
Write_Addr: in integer;
Data_in: in integer;
Data_out: out integer
);
end Mem;
--------------------------------------------------------------
architecture behav of Mem is
type ram_type is array (0 to 31) of
integer;
signal tmp_ram: ram_type;
begin
-- Read Functional Section
process(Clock, Read)
begin
if (Clock'event and Clock='1') then
if Enable='1' then
if Read='1' then
-- buildin function conv_integer change the type
-- from std_logic_vector to integer
Data_out <= tmp_ram(conv_integer(Read_Addr));
else
Data_out <= (Data_out'range => 'Z');
end if;
end if;
end if;
end process;
-- Write Functional Section
process(Clock, Write)
begin
if (Clock'event and Clock='1') then
if Enable='1' then
if Write='1' then
tmp_ram(conv_integer(Write_Addr)) <= Data_in;
end if;
end if;
end if;
end process;
end behav;
----------------------------------------------------------------
错误:
Error (10514): VHDL aggregate error at Mem.vhd(41): can't determine type of aggregate -- found 0 possible types
如果我想使用双打而不是整数?意味着64位。 –
双重意味着浮点数,所以我假设您的意思是四字,64位整数?它们不是以VHDL中的整数存在,你必须使用'signed/unsigned'或'std_logic_vector'。例如,'signal x:signed(63 downto 0)'。 –
所以信号x:signed(63 downto 0)意味着64位的整数?如双?是不是认为二进制不是int? –