mirror of
https://github.com/antonblanchard/microwatt.git
synced 2026-01-17 00:22:47 +00:00
This adds support for set associativity to the icache. It can still be direct mapped by setting NUM_WAYS to 1. The replacement policy uses a simple tree-PLRU for each set. This is only lightly tested, tests pass but I have to double check that we are using the ways effectively and not creating duplicates. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
47 lines
1.1 KiB
VHDL
47 lines
1.1 KiB
VHDL
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
use ieee.numeric_std.all;
|
|
use ieee.math_real.all;
|
|
|
|
entity cache_ram is
|
|
generic(
|
|
ROW_BITS : integer := 16;
|
|
WIDTH : integer := 64
|
|
);
|
|
|
|
port(
|
|
clk : in std_logic;
|
|
rd_en : in std_logic;
|
|
rd_addr : in std_logic_vector(ROW_BITS - 1 downto 0);
|
|
rd_data : out std_logic_vector(WIDTH - 1 downto 0);
|
|
wr_en : in std_logic;
|
|
wr_addr : in std_logic_vector(ROW_BITS - 1 downto 0);
|
|
wr_data : in std_logic_vector(WIDTH - 1 downto 0)
|
|
);
|
|
|
|
end cache_ram;
|
|
|
|
architecture rtl of cache_ram is
|
|
constant SIZE : integer := 2**ROW_BITS;
|
|
|
|
type ram_type is array (0 to SIZE - 1) of std_logic_vector(WIDTH - 1 downto 0);
|
|
signal ram : ram_type;
|
|
attribute ram_style : string;
|
|
attribute ram_style of ram : signal is "block";
|
|
attribute ram_decomp : string;
|
|
attribute ram_decomp of ram : signal is "power";
|
|
|
|
begin
|
|
process(clk)
|
|
begin
|
|
if rising_edge(clk) then
|
|
if wr_en = '1' then
|
|
ram(to_integer(unsigned(wr_addr))) <= wr_data;
|
|
end if;
|
|
if rd_en = '1' then
|
|
rd_data <= ram(to_integer(unsigned(rd_addr)));
|
|
end if;
|
|
end if;
|
|
end process;
|
|
end;
|