Line 257... |
Line 257... |
--
|
--
|
if (bus_err_i = '1') then -- bus error
|
if (bus_err_i = '1') then -- bus error
|
ctrl.state_nxt <= S_BUS_ERROR;
|
ctrl.state_nxt <= S_BUS_ERROR;
|
elsif (bus_ack_i = '1') then -- ACK = write to cache and get next word
|
elsif (bus_ack_i = '1') then -- ACK = write to cache and get next word
|
cache.ctrl_we <= '1'; -- write to cache
|
cache.ctrl_we <= '1'; -- write to cache
|
if (and_all_f(ctrl.addr_reg((2+cache_offset_size_c)-1 downto 2)) = '1') then -- block complete?
|
if (and_reduce_f(ctrl.addr_reg((2+cache_offset_size_c)-1 downto 2)) = '1') then -- block complete?
|
cache.ctrl_tag_we <= '1'; -- current block is valid now
|
cache.ctrl_tag_we <= '1'; -- current block is valid now
|
cache.ctrl_valid_we <= '1'; -- write tag of current address
|
cache.ctrl_valid_we <= '1'; -- write tag of current address
|
ctrl.state_nxt <= S_CACHE_RESYNC_0;
|
ctrl.state_nxt <= S_CACHE_RESYNC_0;
|
else -- get next word
|
else -- get next word
|
ctrl.addr_reg_nxt <= std_ulogic_vector(unsigned(ctrl.addr_reg) + 4);
|
ctrl.addr_reg_nxt <= std_ulogic_vector(unsigned(ctrl.addr_reg) + 4);
|
Line 473... |
Line 473... |
begin
|
begin
|
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
history.re_ff <= host_re_i;
|
history.re_ff <= host_re_i;
|
if (invalidate_i = '1') then -- invalidate whole cache
|
if (invalidate_i = '1') then -- invalidate whole cache
|
history.last_used_set <= (others => '1');
|
history.last_used_set <= (others => '1');
|
elsif (history.re_ff = '1') and (or_all_f(hit) = '1') and (ctrl_en_i = '0') then -- store last accessed set that caused a hit
|
elsif (history.re_ff = '1') and (or_reduce_f(hit) = '1') and (ctrl_en_i = '0') then -- store last accessed set that caused a hit
|
history.last_used_set(to_integer(unsigned(cache_index))) <= not hit(0);
|
history.last_used_set(to_integer(unsigned(cache_index))) <= not hit(0);
|
end if;
|
end if;
|
history.to_be_replaced <= history.last_used_set(to_integer(unsigned(cache_index)));
|
history.to_be_replaced <= history.last_used_set(to_integer(unsigned(cache_index)));
|
end if;
|
end if;
|
end process access_history;
|
end process access_history;
|
Line 544... |
Line 544... |
end if;
|
end if;
|
end loop; -- i
|
end loop; -- i
|
end process comparator;
|
end process comparator;
|
|
|
-- global hit --
|
-- global hit --
|
hit_o <= or_all_f(hit);
|
hit_o <= or_reduce_f(hit);
|
|
|
|
|
-- Cache Data Memory ----------------------------------------------------------------------
|
-- Cache Data Memory ----------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
cache_mem_access: process(clk_i)
|
cache_mem_access: process(clk_i)
|