OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [vhdl/] [mips_pkg.vhdl] - Diff between revs 37 and 48

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 37 Rev 48
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
 
 
package mips_pkg is
package mips_pkg is
 
 
 
-- FIXME this stuff belongs in the cache module where address decoding is made
subtype t_addr_decode is std_logic_vector(31 downto 16);
-- (besides, they should be module generics, not package constants)
constant ADDR_BOOT : t_addr_decode      := X"0000";
subtype t_addr_decode is std_logic_vector(31 downto 24);
constant ADDR_XRAM : t_addr_decode      := X"8000";
constant ADDR_BOOT : t_addr_decode      := X"00";
constant ADDR_IO : t_addr_decode        := X"2000";
constant ADDR_XRAM : t_addr_decode      := X"80";
 
constant ADDR_IO : t_addr_decode        := X"20";
 
 
 
 
subtype t_addr is std_logic_vector(31 downto 0);
subtype t_addr is std_logic_vector(31 downto 0);
subtype t_word is std_logic_vector(31 downto 0);
subtype t_word is std_logic_vector(31 downto 0);
subtype t_dword is std_logic_vector(63 downto 0);
subtype t_dword is std_logic_vector(63 downto 0);
subtype t_regnum is std_logic_vector(4 downto 0);
subtype t_regnum is std_logic_vector(4 downto 0);
 
 
type t_rbank is array(0 to 31) of t_word;
type t_rbank is array(0 to 31) of t_word;
 
 
subtype t_pc is std_logic_vector(31 downto 2);
subtype t_pc is std_logic_vector(31 downto 2);
 
 
constant ZERO : t_word := (others => '0');
constant ZERO : t_word := (others => '0');
 
 
type t_alu_control is record
type t_alu_control is record
    logic_sel :         std_logic_vector(1 downto 0);
    logic_sel :         std_logic_vector(1 downto 0);
    shift_sel :         std_logic_vector(1 downto 0);
    shift_sel :         std_logic_vector(1 downto 0);
    shift_amount :      std_logic_vector(4 downto 0);
    shift_amount :      std_logic_vector(4 downto 0);
    neg_sel :           std_logic_vector(1 downto 0);
    neg_sel :           std_logic_vector(1 downto 0);
    use_arith :         std_logic;
    use_arith :         std_logic;
    use_logic :         std_logic_vector(1 downto 0);
    use_logic :         std_logic_vector(1 downto 0);
    cy_in :             std_logic;
    cy_in :             std_logic;
    use_slt :           std_logic;
    use_slt :           std_logic;
    arith_unsigned :    std_logic;
    arith_unsigned :    std_logic;
end record t_alu_control;
end record t_alu_control;
 
 
type t_alu_flags is record
type t_alu_flags is record
    inp1_lt_zero :      std_logic;
    inp1_lt_zero :      std_logic;
    inp1_eq_zero :      std_logic;
    inp1_eq_zero :      std_logic;
    inp1_lt_inp2 :      std_logic;
    inp1_lt_inp2 :      std_logic;
    inp1_eq_inp2 :      std_logic;
    inp1_eq_inp2 :      std_logic;
end record t_alu_flags;
end record t_alu_flags;
 
 
-- 32-cycle mul/div module control. Bits 4-3 & 1-0 of IR.
-- 32-cycle mul/div module control. Bits 4-3 & 1-0 of IR.
subtype t_mult_function is std_logic_vector(3 downto 0);
subtype t_mult_function is std_logic_vector(3 downto 0);
constant MULT_NOTHING       : t_mult_function := "0000";
constant MULT_NOTHING       : t_mult_function := "0000";
constant MULT_READ_LO       : t_mult_function := "1010"; -- 18
constant MULT_READ_LO       : t_mult_function := "1010"; -- 18
constant MULT_READ_HI       : t_mult_function := "1000"; -- 16
constant MULT_READ_HI       : t_mult_function := "1000"; -- 16
constant MULT_WRITE_LO      : t_mult_function := "1011"; -- 19
constant MULT_WRITE_LO      : t_mult_function := "1011"; -- 19
constant MULT_WRITE_HI      : t_mult_function := "1001"; -- 17
constant MULT_WRITE_HI      : t_mult_function := "1001"; -- 17
constant MULT_MULT          : t_mult_function := "1101"; -- 25
constant MULT_MULT          : t_mult_function := "1101"; -- 25
constant MULT_SIGNED_MULT   : t_mult_function := "1100"; -- 24
constant MULT_SIGNED_MULT   : t_mult_function := "1100"; -- 24
constant MULT_DIVIDE        : t_mult_function := "1111"; -- 26
constant MULT_DIVIDE        : t_mult_function := "1111"; -- 26
constant MULT_SIGNED_DIVIDE : t_mult_function := "1110"; -- 27
constant MULT_SIGNED_DIVIDE : t_mult_function := "1110"; -- 27
 
 
-- Computes ceil(log2(A)), e.g. address width of memory block
-- Computes ceil(log2(A)), e.g. address width of memory block
-- CAN BE USED IN SYNTHESIZABLE CODE as long as called with constant arguments
-- CAN BE USED IN SYNTHESIZABLE CODE as long as called with constant arguments
function log2(A : natural) return natural;
function log2(A : natural) return natural;
 
 
-- Return '1' if address A is within a given memory area
 
-- CAN BE USED IN SYNTHESIZABLE CODE as long as called with constant arguments
 
function addr_decode(A : std_logic_vector; mask : t_addr_decode) return std_logic;
 
 
 
end package;
end package;
 
 
package body mips_pkg is
package body mips_pkg is
 
 
function log2(A : natural) return natural is
function log2(A : natural) return natural is
begin
begin
    for I in 1 to 30 loop -- Works for up to 32 bit integers
    for I in 1 to 30 loop -- Works for up to 32 bit integers
        if(2**I > A) then
        if(2**I > A) then
            return(I-1);
            return(I-1);
        end if;
        end if;
    end loop;
    end loop;
    return(30);
    return(30);
end function log2;
end function log2;
 
 
function addr_decode(A : std_logic_vector; mask : t_addr_decode) return std_logic is
 
begin
 
    if A(mask'high downto mask'low) = mask then
 
        return '1';
 
    else
 
        return '0';
 
    end if;
 
end function addr_decode;
 
 
 
end package body;
end package body;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.