diff --git a/lib/CPUs/MIPS/src/core/mips_types.vhd b/lib/CPUs/MIPS/src/core/mips_types.vhd index ae8b385..cf18ee7 100644 --- a/lib/CPUs/MIPS/src/core/mips_types.vhd +++ b/lib/CPUs/MIPS/src/core/mips_types.vhd @@ -23,8 +23,8 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; -use IEEE.numeric_std.ALL; - +use IEEE.NUMERIC_STD.ALL; +use IEEE.MATH_REAL.ALL; -------------------------------------------------------------------------- package mips_types is @@ -150,6 +150,29 @@ package mips_types is alu_lts ); + type sdu_t is record + imem_dep : STD_LOGIC; + dmem_dep : STD_LOGIC; + mul_dep : STD_LOGIC; + ID_nop : STD_LOGIC; + EX_nop : STD_LOGIC; + MEM_nop : STD_LOGIC; + WB_nop : STD_LOGIC; + ID_stall : STD_LOGIC; + EX_stall : STD_LOGIC; + MEM_stall : STD_LOGIC; + WB_stall : STD_LOGIC; + end record; + + type hdu_t is record + alu_fwd_a_ex : boolean; + alu_fwd_a_mem : boolean; + alu_fwd_a_wb : boolean; + alu_fwd_b_ex : boolean; + alu_fwd_b_mem : boolean; + alu_fwd_b_wb : boolean; + end record; + type alu_flags_t is record c : STD_LOGIC; uvf : STD_LOGIC; @@ -196,7 +219,9 @@ package mips_types is cause : word_t; end record; - type cop_ctrl_in_t is record + type cop0_ctrl_in_t is record + sdu : sdu_t; + events : event_t; bd_wb : STD_LOGIC; epc_mem : word_t; epc_wb : word_t; @@ -205,43 +230,16 @@ package mips_types is exc_left : STD_LOGIC; end record; - type cop_ctrl_out_t is record + type cop0_ctrl_out_t is record RE : STD_LOGIC; - ee : STD_LOGIC; - ec : STD_LOGIC; exc_commit : STD_LOGIC; exc_pending : STD_LOGIC; exc_exit : STD_LOGIC; - reg_write : STD_LOGIC; - cop_read : STD_LOGIC; user_mode : STD_LOGIC; int : STD_LOGIC; exc_vec : word_t; end record; - type sdu_t is record - imem_dep : STD_LOGIC; - dmem_dep : STD_LOGIC; - mul_dep : STD_LOGIC; - ID_nop : STD_LOGIC; - EX_nop : STD_LOGIC; - MEM_nop : STD_LOGIC; - WB_nop : STD_LOGIC; - ID_stall : STD_LOGIC; - EX_stall : STD_LOGIC; - MEM_stall : STD_LOGIC; - WB_stall : STD_LOGIC; - end record; - - type hdu_t is record - alu_fwd_a_ex : boolean; - alu_fwd_a_mem : boolean; - alu_fwd_a_wb : boolean; - alu_fwd_b_ex : boolean; - alu_fwd_b_mem : boolean; - alu_fwd_b_wb : boolean; - end record; - type alu_ctrl_t is record outsel : alu_outsel_t; add : STD_LOGIC; @@ -307,6 +305,7 @@ package mips_types is shamt : shamt_t; ctrl : ctrl_lines_t; reg_write : STD_LOGIC; + cop_read : STD_LOGIC; reg_a_rptr : reg_ptr_t; reg_b_rptr : reg_ptr_t; reg_a : word_t; @@ -331,6 +330,7 @@ package mips_types is alu_flags : alu_flags_t; result : word_t; reg_write : STD_LOGIC; + cop_read : STD_LOGIC; wreg_we : STD_LOGIC; reg_wptr : reg_ptr_t; reg_a_rptr : reg_ptr_t; @@ -382,6 +382,9 @@ package mips_types is function event_is_active(e : event_t) return std_logic; function "or" (a, b : event_t) return event_t; + function lg2(x : natural) return natural; + function po2(x : natural) return natural; + end mips_types; -------------------------------------------------------------------------- @@ -572,6 +575,7 @@ package body mips_types is end events_clr; +-------------------------------------------------------------------------- function event_is_active(e : event_t) return std_logic is variable result : std_logic; begin @@ -595,6 +599,7 @@ package body mips_types is end event_is_active; +-------------------------------------------------------------------------- function "or" (a, b : event_t) return event_t is variable result : event_t; begin @@ -616,7 +621,18 @@ package body mips_types is end "or"; -------------------------------------------------------------------------- -end mips_types; + function lg2(x : natural) return natural is + begin + return natural(ceil(log2(real(x)))); + end lg2; + +-------------------------------------------------------------------------- + function po2(x : natural) return natural is + begin + + return 2**lg2(x); + end po2; -------------------------------------------------------------------------- --------------------------------------------------------------------------- +end mips_types; +