-
Notifications
You must be signed in to change notification settings - Fork 22
/
rom_4k_template.vhdl
46 lines (40 loc) · 1.2 KB
/
rom_4k_template.vhdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
--
entity THEROM is
port (Clk : in std_logic;
address : in std_logic_vector(11 downto 0);
-- Yes, we do have a write enable, because we allow modification of ROMs
-- in the running machine, unless purposely disabled. This gives us
-- something like the WOM that the Amiga had.
we : in std_logic;
-- chip select, active low
cs : in std_logic;
data_i : in std_logic_vector(7 downto 0);
data_o : out std_logic_vector(7 downto 0)
);
end THEROM;
architecture Behavioral of THEROM is
-- 8K x 8bit pre-initialised RAM
type ram_t is array (0 to 4095) of std_logic_vector(7 downto 0);
signal ram : ram_t := (ROMDATA);
begin
--process for read and write operation.
PROCESS(Clk,cs,ram)
BEGIN
if(rising_edge(Clk)) then
if cs='1' then
if(we='1') then
ram(to_integer(unsigned(address))) <= data_i;
end if;
data_o <= ram(to_integer(unsigned(address)));
end if;
end if;
if cs='1' then
data_o <= ram(to_integer(unsigned(address)));
else
data_o <= "ZZZZZZZZ";
end if;
END PROCESS;
end Behavioral;