-
Notifications
You must be signed in to change notification settings - Fork 9
/
Memory.vhdl
executable file
·37 lines (29 loc) · 1.18 KB
/
Memory.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
library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
use work.txt_util.all;
entity Memory is
port (clk : in std_logic;
reset : in std_logic;
WriteData : in std_logic_vector(31 downto 0);
Address : in std_logic_vector(31 downto 0);
MemWrite : in std_logic;
MemRead : in std_logic;
ReadData : out std_logic_vector(31 downto 0));
end Memory;
architecture rtl of Memory is
signal data : std_logic_vector(31 downto 0);
signal nwe, noe, ncs : std_logic;
begin
-- Data Memory
memory: entity work.sram64kx8(sram_behaviour)
port map (ncs, Address, data, nwe, noe);
nwe <= not MemWrite;
noe <= not MemRead;
ncs <= not (MemWrite or MemRead) or (not reset);
-- connect data to reg out 2 with a tristate buffer
GEN_memtris: for n in 31 downto 0 generate
data(n) <= WriteData(n) when MemWrite='1' else 'Z';
end generate GEN_memtris;
ReadData <= data;
end rtl;