--RAM module
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.numeric_std.all;
entity RAM is
generic(
address_length, data_length : integer);
port(
addr : in std_logic_vector(address_length-1 downto 0);
dat : inout std_logic_vector(data_length-1 downto 0);
rd, wr, en : in bit);
end entity RAM;
architecture RAM_impl of RAM is
type mem is array(2**address_length-1 downto 0) of std_logic_vector(data_length-1 downto 0);
begin
process(rd, wr, en)is
variable cont : mem;
begin
if(en = '1')then
if(wr = '1' and rd = '0')then
cont(to_integer(unsigned(addr))) := dat;
end if;
if(rd = '1' and wr = '0')then
dat <= cont(to_integer(unsigned(addr)));
end if;
end if;
end process;
end architecture RAM_impl;
--Test module
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.numeric_std.all;
entity Example4RAM is
end entity Example4RAM;
architecture Tester of Example4RAM is
signal rd, wr, en : bit;
signal str : std_logic_vector(15 downto 0);
signal ext : std_logic_vector(7 downto 0);
begin
module : entity work.RAM(RAM_impl)
generic map(
address_length => 16,
data_length => 8)
port map(str, ext, rd, wr, en);
tt : process is
begin
str <= X"0001";
ext <= "00000000";
rd <= '0'; wr <= '1';
wait for 5 ns;
en <= '1';
wait for 5 ns;
rd <= '0'; wr <= '0';
wait for 10 ns;
rd <= '1'; wr <= '0';
end process;
end architecture Tester;
있습니다. RAM 모듈에서 str은 벡터에 있고 ext는 inout 벡터입니다. 이것은 어떻게 든 문제를 만들고 있으며 누구나 해결책을 알고 있습니까? (어제부터 소스를 변경했으나 여전히 작동하지 않습니다.)
RAM 엔티티 (및 아키텍처)를 보지 않고서는 어둠 속에서만 추측 할 수 있습니다. 두 번째 매개 변수 (명명 된 연결을 사용하지 않는 이유는 무엇입니까?)가 "out"또는 "inout"모드이면 대답이있을 것입니다. –
Brian은 ext가 RAM에 대한 데이터 연결이고 연결된 드라이버 (예 : 모드 inout)에 ext (RAM, process tt) 용 두 개의 드라이버가 있다고 암시합니다. ext의 유효 값은 두 드라이버의 해상도입니다. 모든 'U'와 '모두'0이 모두 'U'로 변환됩니다. std_logic_vector는 확인 된 유형 또는 하위 유형 (-2008)입니다. RAM 설계 설명이 없으면 성공을 달성하는 방법을 예측하기 어렵습니다. 즉, RAM을 읽기 전에 모든 Z를 처리하지 않고 RAM이 아닐 수도 있습니다. – user1155120
위의 코드를 수정하고 RAM을 확인하십시오. VHDL의 초보자이므로 어떤 제안이 도움이 될 것입니다. – Dejan