-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemory.vhd
More file actions
58 lines (45 loc) · 1.26 KB
/
Memory.vhd
File metadata and controls
58 lines (45 loc) · 1.26 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 08:15:11 12/18/2018
-- Design Name:
-- Module Name: Memory - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Memory is
Port(
reset, rd , wr : in std_logic;
addres_bus : in std_logic_vector(4 downto 0);
data_bus: inout std_logic_vector(7 downto 0));
end entity Memory;
architecture structure of Memory is
type mem_array is array(natural range<>) of std_logic_vector(7 downto 0);
signal memory : mem_array(31 downto 0);
begin
Memory_Process : process(rd,wr,addres_bus,data_bus, reset)
begin
if reset = '1' then
for I in 0 to 31 loop
memory(I) <= "00000000";
end loop;
elsif(rd = '1' and wr ='0') then
data_bus <= memory(to_integer(unsigned(addres_bus)));
elsif(wr = '1' and rd ='0') then
memory(to_integer(unsigned(addres_bus))) <= data_bus;
end if;
end process;
end structure;