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? –