-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRam.vhd
52 lines (38 loc) · 1.01 KB
/
Ram.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
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
Use ieee.numeric_std.all ;
entity ram is
port(
rw,en : in std_logic;
clk : in std_logic;
rst : in std_logic;
Adress : in std_logic_vector(7 downto 0);
Data_in : in std_logic_vector(7 downto 0);
Data_out: out std_logic_vector(7 downto 0)
);
end ram;
architecture ram_a of ram is
type ram is array(0 to 255) of std_logic_vector(7 downto 0);
signal Data_Ram : ram ;
--------------- BEGIN -----------------------------------------------------------------
begin
-- rw='1' alors lecture
acces_ram:process(rst, clk)
begin
if rst='1' then
for k in 0 to 255 loop
Data_Ram(k) <= (others=>'0');
end loop;
else
if rising_edge(clk) then
if en='1' then
if(rw='1') then
Data_out <= Data_Ram(to_integer(unsigned(Adress)));
else
Data_Ram(to_integer(unsigned(Adress))) <= Data_in;
end if;
end if;
end if;
end if;
end process acces_ram;
end ram_a;