-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatamem.V4.vhd
66 lines (56 loc) · 2.07 KB
/
Datamem.V4.vhd
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
59
60
61
62
63
64
65
66
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
entity DATAMEMORY is
Generic(words : natural :=64;wordsize: natural :=32; addresssize: natural := 32);
port ( LoadIt: in STD_LOGIC;
INPUT : in STD_LOGIC_VECTOR (wordsize-1 downto 0);
OUTPUT : out STD_LOGIC_VECTOR (wordsize-1 downto 0);
MEM_READ : in STD_LOGIC;
MEM_WRITE : in STD_LOGIC;
ADDRESS : in STD_LOGIC_VECTOR (addresssize-1 downto 0);
CLK : in STD_LOGIC
);
end DATAMEMORY;
architecture BEHAVIORAL of DATAMEMORY is
type MEM is array (0 to words-1) of STD_LOGIC_VECTOR (wordsize-1 downto 0);
signal MEMORY : MEM;
signal OUTS: STD_LOGIC_VECTOR(wordsize-1 downto 0);
signal ADDRover4: STD_LOGIC_VECTOR(addresssize-2 - 1 downto 0);
signal ADDR_int: integer;
begin
process ( MEM_READ, MEM_WRITE, CLK, ADDRESS, INPUT ) is
begin
if LoadIt = '1' then
-----------------------
--Project1 test
-----------------------
memory(0) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(1) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(2) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(3) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(4) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(5) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(6) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(7) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(8) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(9) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(10) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(11) <= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ;
memory(12) <= "00000000000000000000000000001100" ;
memory(13) <= "00000000000000000000000000000001" ;
memory(14) <= "00000000000000000000000000000100" ;
else
if FALLING_EDGE(CLK) then
if MEM_WRITE = '1' then
MEMORY(ADDR_int) <= INPUT;
end if;
end if;
end if;
end process;
ADDRover4 <= ADDRESS(31 downto 2) ;
ADDR_int <= CONV_INTEGER(ADDRover4);
OUTS <= MEMORY(ADDR_int) when MEM_READ = '1' and (ADDR_int < words) else
(others => 'Z') when MEM_READ = '0' ;
OUTPUT <= OUTS;
end BEHAVIORAL;