2024-03-14 18:30:15 +03:00
|
|
|
library ieee;
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
use ieee.std_logic_unsigned.all;
|
|
|
|
|
|
|
|
entity RAM9X8 is
|
|
|
|
port(
|
|
|
|
data : inout std_logic_vector(7 downto 0);
|
|
|
|
address : in std_logic_vector(8 downto 0);
|
|
|
|
we : in std_logic;
|
|
|
|
oe : in std_logic;
|
2024-03-19 18:39:41 +03:00
|
|
|
ce : in std_logic
|
2024-03-14 18:30:15 +03:00
|
|
|
);
|
|
|
|
end entity;
|
|
|
|
|
|
|
|
architecture behavorial of RAM9X8 is
|
|
|
|
|
|
|
|
type mem is array (511 downto 0) of std_logic_vector(7 downto 0);
|
2024-03-19 18:39:41 +03:00
|
|
|
signal memory : mem;
|
2024-03-14 18:30:15 +03:00
|
|
|
|
2024-03-19 10:39:11 +03:00
|
|
|
begin
|
|
|
|
|
2024-03-19 18:39:41 +03:00
|
|
|
process (we, oe, ce)
|
2024-03-14 18:30:15 +03:00
|
|
|
variable addr : integer range 0 to 511 := 0;
|
|
|
|
begin
|
2024-03-19 11:40:31 +03:00
|
|
|
if (ce = '0') then -- Если микросхема выбрана
|
2024-03-19 18:39:41 +03:00
|
|
|
addr := conv_integer(address);
|
|
|
|
if (oe = '0') then -- Если сигнал чтения активен
|
2024-03-19 11:40:31 +03:00
|
|
|
case addr is
|
|
|
|
when 0 => data <= x"AA";
|
2024-03-19 18:39:41 +03:00
|
|
|
when 1 => data <= x"BB";
|
|
|
|
when 2 => data <= x"CC";
|
|
|
|
when 3 => data <= x"DD";
|
|
|
|
when 4 => data <= x"EE";
|
|
|
|
when 5 => data <= x"FF";
|
|
|
|
when 6 => data <= x"01";
|
|
|
|
when 7 => data <= x"23";
|
|
|
|
when 8 => data <= x"45";
|
|
|
|
when 9 => data <= x"67";
|
|
|
|
when others => data <= not memory(addr);
|
|
|
|
end case;
|
2024-03-19 11:40:31 +03:00
|
|
|
elsif (we = '0') then -- Если сигнал записи активен
|
|
|
|
memory(addr) <= data;
|
|
|
|
else
|
|
|
|
data <= (others => 'Z'); -- Запретить запись на шину
|
|
|
|
end if;
|
|
|
|
else
|
|
|
|
data <= (others => 'Z'); -- Запретить запись на шину
|
2024-03-14 18:30:15 +03:00
|
|
|
end if;
|
|
|
|
end process;
|
|
|
|
|
|
|
|
end behavorial;
|