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

Subversion Repositories ion

[/] [ion/] [trunk/] [vhdl/] [mips_pkg.vhdl] - Blame information for rev 37

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ja_rd
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
 
6
package mips_pkg is
7
 
8 37 ja_rd
 
9
subtype t_addr_decode is std_logic_vector(31 downto 16);
10
constant ADDR_BOOT : t_addr_decode      := X"0000";
11
constant ADDR_XRAM : t_addr_decode      := X"8000";
12
constant ADDR_IO : t_addr_decode        := X"2000";
13
 
14
 
15 2 ja_rd
subtype t_addr is std_logic_vector(31 downto 0);
16
subtype t_word is std_logic_vector(31 downto 0);
17
subtype t_dword is std_logic_vector(63 downto 0);
18
subtype t_regnum is std_logic_vector(4 downto 0);
19
 
20
type t_rbank is array(0 to 31) of t_word;
21
 
22
subtype t_pc is std_logic_vector(31 downto 2);
23
 
24
constant ZERO : t_word := (others => '0');
25
 
26
type t_alu_control is record
27
    logic_sel :         std_logic_vector(1 downto 0);
28
    shift_sel :         std_logic_vector(1 downto 0);
29
    shift_amount :      std_logic_vector(4 downto 0);
30
    neg_sel :           std_logic_vector(1 downto 0);
31
    use_arith :         std_logic;
32
    use_logic :         std_logic_vector(1 downto 0);
33
    cy_in :             std_logic;
34
    use_slt :           std_logic;
35
    arith_unsigned :    std_logic;
36
end record t_alu_control;
37
 
38
type t_alu_flags is record
39
    inp1_lt_zero :      std_logic;
40
    inp1_eq_zero :      std_logic;
41
    inp1_lt_inp2 :      std_logic;
42
    inp1_eq_inp2 :      std_logic;
43
end record t_alu_flags;
44
 
45 12 ja_rd
-- 32-cycle mul/div module control. Bits 4-3 & 1-0 of IR.
46
subtype t_mult_function is std_logic_vector(3 downto 0);
47
constant MULT_NOTHING       : t_mult_function := "0000";
48
constant MULT_READ_LO       : t_mult_function := "1010"; -- 18
49
constant MULT_READ_HI       : t_mult_function := "1000"; -- 16
50
constant MULT_WRITE_LO      : t_mult_function := "1011"; -- 19
51
constant MULT_WRITE_HI      : t_mult_function := "1001"; -- 17
52
constant MULT_MULT          : t_mult_function := "1101"; -- 25
53
constant MULT_SIGNED_MULT   : t_mult_function := "1100"; -- 24
54
constant MULT_DIVIDE        : t_mult_function := "1111"; -- 26
55
constant MULT_SIGNED_DIVIDE : t_mult_function := "1110"; -- 27
56
 
57 37 ja_rd
-- Computes ceil(log2(A)), e.g. address width of memory block
58
-- CAN BE USED IN SYNTHESIZABLE CODE as long as called with constant arguments
59
function log2(A : natural) return natural;
60 12 ja_rd
 
61 37 ja_rd
-- Return '1' if address A is within a given memory area
62
-- CAN BE USED IN SYNTHESIZABLE CODE as long as called with constant arguments
63
function addr_decode(A : std_logic_vector; mask : t_addr_decode) return std_logic;
64
 
65 2 ja_rd
end package;
66 37 ja_rd
 
67
package body mips_pkg is
68
 
69
function log2(A : natural) return natural is
70
begin
71
    for I in 1 to 30 loop -- Works for up to 32 bit integers
72
        if(2**I > A) then
73
            return(I-1);
74
        end if;
75
    end loop;
76
    return(30);
77
end function log2;
78
 
79
function addr_decode(A : std_logic_vector; mask : t_addr_decode) return std_logic is
80
begin
81
    if A(mask'high downto mask'low) = mask then
82
        return '1';
83
    else
84
        return '0';
85
    end if;
86
end function addr_decode;
87
 
88
end package body;

powered by: WebSVN 2.1.0

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