-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory_inst.vhd
More file actions
39 lines (28 loc) · 889 Bytes
/
memory_inst.vhd
File metadata and controls
39 lines (28 loc) · 889 Bytes
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
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use STD.textio.all;
use IEEE.std_logic_textio.all;
entity memory_inst is
port (
address : in std_logic_vector(7 downto 0);
instr_out : out std_logic_vector(31 downto 0)
);
end entity memory_inst;
architecture memI_arch of memory_inst is
type rom is array (0 to 255) of std_logic_vector(31 downto 0);
impure function init_rom_hex return rom is
file text_file : text open read_mode is "ROM_inst.txt";
variable text_line : line;
variable rom_content : rom;
begin
for i in 0 to 255 loop
readline(text_file, text_line);
hread(text_line, rom_content(i));
end loop;
return rom_content;
end function;
signal mem : rom := init_rom_hex;
begin
instr_out <= mem(to_integer(unsigned(address))/4);
end memI_arch ;