Line 19... |
Line 19... |
-- # RTE instruction (or ERET)
|
-- # RTE instruction (or ERET)
|
-- # Most of the CP0 registers and of course all of the CP1
|
-- # Most of the CP0 registers and of course all of the CP1
|
-- # External interrupts
|
-- # External interrupts
|
--
|
--
|
--### Things implemented but not tested
|
--### Things implemented but not tested
|
-- # Memory pause input -- not tested with a real cache
|
-- # Memory pause input -- only tested with stub cache
|
--
|
--
|
--### Things with provisional implementation
|
--### Things with provisional implementation
|
--
|
--
|
-- 1.- Load interlocks: the pipeline is stalled for every load instruction, even
|
-- 1.- Load interlocks: the pipeline is stalled for every load instruction, even
|
-- if the target register is not used in the following instruction. So that
|
-- if the target register is not used in the following instruction. So that
|
Line 38... |
Line 38... |
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use work.mips_pkg.all;
|
use work.mips_pkg.all;
|
|
|
entity mips_cpu is
|
entity mips_cpu is
|
generic(
|
generic(
|
|
-- Reset vector address minus 4
|
|
RESET_VECTOR_M4 : t_word := RESET_VECTOR_M4;
|
|
-- Trap vector address
|
|
TRAP_VECTOR : t_word := TRAP_VECTOR;
|
|
-- Type of memory to be used for register bank in xilinx HW
|
XILINX_REGBANK : string := "distributed" -- {distributed|block}
|
XILINX_REGBANK : string := "distributed" -- {distributed|block}
|
);
|
);
|
port(
|
port(
|
clk : in std_logic;
|
clk : in std_logic;
|
reset : in std_logic;
|
reset : in std_logic;
|
Line 433... |
Line 438... |
pc_register:
|
pc_register:
|
process(clk)
|
process(clk)
|
begin
|
begin
|
if clk'event and clk='1' then
|
if clk'event and clk='1' then
|
if reset='1' then
|
if reset='1' then
|
-- reset to 0xffffffff so that 1st fetch addr is 0x00000000
|
-- reset to <vector>-4 so that 1st fetch addr is <vector>
|
-- FIXME reset vector is hardcoded
|
p0_pc_reg <= RESET_VECTOR_M4(31 downto 2);
|
p0_pc_reg <= (others => '1');
|
|
else
|
else
|
-- p0_pc_reg holds the same value as external sync ram addr register
|
-- p0_pc_reg holds the same value as external sync ram addr register
|
p0_pc_reg <= p0_pc_next;
|
p0_pc_reg <= p0_pc_next;
|
-- p0_pc_restart = addr saved to EPC on interrupts (@note2)
|
-- p0_pc_restart = addr saved to EPC on interrupts (@note2)
|
-- It's the addr of the instruction triggering the exception,
|
-- It's the addr of the instruction triggering the exception,
|
Line 477... |
Line 481... |
p1_branch_offset <= p1_branch_offset_sex & p1_ir_reg(15 downto 0);
|
p1_branch_offset <= p1_branch_offset_sex & p1_ir_reg(15 downto 0);
|
-- p0_pc_reg is the addr of the instruction in delay slot
|
-- p0_pc_reg is the addr of the instruction in delay slot
|
p0_pc_branch <= p0_pc_reg + p1_branch_offset;
|
p0_pc_branch <= p0_pc_reg + p1_branch_offset;
|
|
|
-- decide which jump target is to be used
|
-- decide which jump target is to be used
|
p0_pc_target <= X"0000003"&"11" when p1_exception='1' else
|
p0_pc_target <=
|
|
TRAP_VECTOR(31 downto 2) when p1_exception='1' else
|
p0_pc_jump when p1_jump_type(0)='1' else
|
p0_pc_jump when p1_jump_type(0)='1' else
|
p0_pc_branch;
|
p0_pc_branch;
|
|
|
|
|
--##############################################################################
|
--##############################################################################
|
Line 957... |
Line 962... |
-- no need to check for stall cycles when loading these
|
-- no need to check for stall cycles when loading these
|
if p1_set_cp0='1' then
|
if p1_set_cp0='1' then
|
-- FIXME check for CP0 reg index
|
-- FIXME check for CP0 reg index
|
cp0_status <= p1_rs(cp0_status'high downto 0);
|
cp0_status <= p1_rs(cp0_status'high downto 0);
|
end if;
|
end if;
|
if p1_exception='1' then
|
if p1_exception='1' and pipeline_stalled='0' then
|
cp0_epc <= p0_pc_restart;
|
cp0_epc <= p0_pc_restart;
|
|
|
if p1_unknown_opcode='1' then
|
if p1_unknown_opcode='1' then
|
cp0_cause_exc_code <= "01010"; -- bad opcode
|
cp0_cause_exc_code <= "01010"; -- bad opcode
|
else
|
else
|