Написал описание однопортового синхронного ОЗУс проверкой синдрома четности. Порт data объявлен как inout, но при моделировании testbench запись в ОЗУ происходит нормально, а вот с чтением проблемы. Когда "дебагил" увидел что при выполнении инструкции "data <= xRAM(conv_integer(addr))(word_size-1 downto 0);" data не меняет своего значения, т.е. в него не записывается значение полученное из xRAM, а сохраняет старое.
Тот же код исправил на 2 порта, один in и один out, все прекрасно работает, но надо написать с использованием inout.
Помогите, плиз, может кто знает в чем проблема???
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
use work.mylib.all;
entity RAM is
generic (
bw : integer := 3; --разрядность шины адреса
word_size : integer := 4; --разрядность шины данных
ram_size : integer := 8 --ёмкость ОЗУ в словах
);
port (
addr : in std_logic_vector(bw-1 downto 0);
ce, wr, oe, clk : in std_logic;
data : inout std_logic_vector(word_size-1 downto 0)
);
end RAM;
architecture Beh of RAM is
subtype ram_word is std_logic_vector(word_size downto 0);
type ram_table is array(0 to ram_size-1) of ram_word;
signal xRAM : ram_table;
begin
write : process(clk, addr, data, ce, wr)
variable bch : std_logic :='1';
begin
if clk'event and clk='1' then
if ce = '1' then
if wr = '0' then
bch:=bitchet(data);
xRAM(conv_integer(addr))(word_size) <= bch;
xRAM(conv_integer(addr))(word_size-1 downto 0) <= data;
end if;
end if;
end if;
end process;
read : process(clk, addr, ce, oe, wr)
variable bch : std_logic :='1';
begin
if clk'event and clk='1' then
if ce = '1' then
if wr = '1' then
if oe = '1' then
data <= xRAM(conv_integer(addr))(word_size-1 downto 0);
bch:=bitchet(data);
if xRAM(conv_integer(addr))(word_size) /= bch then
data<= (others => 'X');
end if;
else
data <= (others => 'Z');
end if;
end if;
end if;
end if;
end process;
end Beh;