Line 211... |
Line 211... |
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- CP0 registers and signals
|
-- CP0 registers and signals
|
|
|
-- CP0[12]: status register, KUo/IEo & KUP/IEp & KU/IE bits
|
-- CP0[12]: status register, KUo/IEo & KUP/IEp & KU/IE bits
|
signal cp0_status : std_logic_vector(5 downto 0);
|
signal cp0_status : std_logic_vector(5 downto 0);
|
|
signal cp0_sr_ku_reg : std_logic;
|
-- CP0[12]: status register, cache control
|
-- CP0[12]: status register, cache control
|
signal cp0_cache_control : std_logic_vector(17 downto 16);
|
signal cp0_cache_control : std_logic_vector(17 downto 16);
|
-- Output of CP0 register bank (only a few regs are implemented)
|
-- Output of CP0 register bank (only a few regs are implemented)
|
signal cp0_reg_read : t_word;
|
signal cp0_reg_read : t_word;
|
-- CP0[14]: EPC register (PC value saved at exceptions)
|
-- CP0[14]: EPC register (PC value saved at exceptions)
|
Line 791... |
Line 792... |
|
|
p1_cp_unavailable <= '1' when
|
p1_cp_unavailable <= '1' when
|
(p1_set_cp='1' and p1_set_cp0='0') or -- mtc1..3
|
(p1_set_cp='1' and p1_set_cp0='0') or -- mtc1..3
|
(p1_get_cp='1' and p1_get_cp0='0') or -- mfc1..3
|
(p1_get_cp='1' and p1_get_cp0='0') or -- mfc1..3
|
((p1_get_cp0='1' or p1_set_cp0='1' or p1_rfe='1')
|
((p1_get_cp0='1' or p1_set_cp0='1' or p1_rfe='1')
|
and cp0_status(1)='0') -- COP0 user mode
|
and cp0_sr_ku_reg='0')
|
|
--and cp0_status(1)='0') -- COP0 user mode
|
|
-- FIXME CP1..3 logic missing
|
else '0';
|
else '0';
|
|
|
--##############################################################################
|
--##############################################################################
|
-- Pipeline registers & pipeline control logic
|
-- Pipeline registers & pipeline control logic
|
|
|
Line 1034... |
Line 1037... |
begin
|
begin
|
if clk'event and clk='1' then
|
if clk'event and clk='1' then
|
if reset='1' then
|
if reset='1' then
|
-- KU/IE="10" ==> mode=kernel; ints=disabled
|
-- KU/IE="10" ==> mode=kernel; ints=disabled
|
cp0_status <= "000010"; -- bits (KUo/IEo & KUp/IEp) reset to zero
|
cp0_status <= "000010"; -- bits (KUo/IEo & KUp/IEp) reset to zero
|
|
cp0_sr_ku_reg <= '1'; -- delayed KU flag
|
cp0_cache_control <= "00";
|
cp0_cache_control <= "00";
|
cp0_cause_exc_code <= "00000";
|
cp0_cause_exc_code <= "00000";
|
cp0_cause_bd <= '0';
|
cp0_cause_bd <= '0';
|
else
|
else
|
if pipeline_stalled='0' then
|
if pipeline_stalled='0' then
|
Line 1066... |
Line 1070... |
end if;
|
end if;
|
end if;
|
end if;
|
-- ... and the BD flag for exceptions in delay slots
|
-- ... and the BD flag for exceptions in delay slots
|
cp0_cause_bd <= cp0_in_delay_slot;
|
cp0_cause_bd <= cp0_in_delay_slot;
|
|
|
-- FIXME RFE missing
|
|
elsif p1_rfe='1' and cp0_status(1)='1' then
|
elsif p1_rfe='1' and cp0_status(1)='1' then
|
-- RFE: restore ('pop') the KU/IE flag values
|
-- RFE: restore ('pop') the KU/IE flag values
|
|
|
cp0_status(3 downto 2) <= cp0_status(5 downto 4);
|
cp0_status(3 downto 2) <= cp0_status(5 downto 4);
|
cp0_status(1 downto 0) <= cp0_status(3 downto 2);
|
cp0_status(1 downto 0) <= cp0_status(3 downto 2);
|
Line 1083... |
Line 1086... |
-- CP0[13].IP1-0 are implemented, check for CP0 reg index.
|
-- CP0[13].IP1-0 are implemented, check for CP0 reg index.
|
cp0_status <= p1_rt(cp0_status'high downto 0);
|
cp0_status <= p1_rt(cp0_status'high downto 0);
|
cp0_cache_control <= p1_rt(17 downto 16);
|
cp0_cache_control <= p1_rt(17 downto 16);
|
end if;
|
end if;
|
end if;
|
end if;
|
|
if stall_pipeline='0' then
|
|
cp0_sr_ku_reg <= cp0_status(1);
|
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process cp0_registers;
|
end process cp0_registers;
|
|
|
cache_enable <= cp0_cache_control(17);
|
cache_enable <= cp0_cache_control(17);
|