-
Notifications
You must be signed in to change notification settings - Fork 2
/
ghdl_ram108x1k.vhdl
65 lines (56 loc) · 1.88 KB
/
ghdl_ram108x1k.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
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
use WORK.ALL;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
use Std.TextIO.all;
use work.debugtools.all;
use work.icachetypes.all;
ENTITY icache_ram IS
PORT (
clka : IN STD_LOGIC;
wea : IN STD_LOGIC_VECTOR(0 downto 0);
addra : IN std_logic_vector(9 DOWNTO 0);
dina : IN std_logic_vector(107 downto 0);
douta : OUT std_logic_vector(107 downto 0);
clkb : IN STD_LOGIC;
web : in STD_LOGIC_VECTOR(0 downto 0);
dinb : IN std_logic_vector(107 downto 0);
addrb : IN std_logic_vector(9 DOWNTO 0);
doutb : OUT std_logic_vector(107 downto 0)
);
END icache_ram;
architecture behavioural of icache_ram is
type ram_t is array (0 to 1023) of std_logic_vector(107 downto 0);
signal ram : ram_t;
signal doutb_drive : std_logic_vector(107 downto 0);
signal douta_drive : std_logic_vector(107 downto 0);
begin -- behavioural
process(clka,addra,ram)
begin
if(rising_edge(Clka)) then
-- Mimic the one cycle read latency of the coregen generated RAM
doutb <= doutb_drive;
doutb_drive <= ram(to_integer(unsigned(addrb)));
douta <= douta_drive;
douta_drive <= ram(to_integer(unsigned(addra)));
end if;
if(rising_edge(Clka)) then
if(wea(0)='1') then
ram(to_integer(unsigned(addra(9 downto 0)))) <= dina;
report "I-CACHE: A writing to $" & to_hstring(unsigned(addra))
& " = $" & to_hstring(dina);
else
report "I-CACHE: A Reading from $" & to_hstring(unsigned(addra));
end if;
end if;
if(rising_edge(Clkb)) then
if(web(0)='1') then
ram(to_integer(unsigned(addrb(9 downto 0)))) <= dinb;
report "I-CACHE: B writing to $" & to_hstring(unsigned(addrb))
& " = $" & to_hstring(dinb);
else
report "I-CACHE: B Reading from $" & to_hstring(unsigned(addrb));
end if;
end if;
end process;
end behavioural;