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

Subversion Repositories ion

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

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 48 ja_rd
-- FIXME this stuff belongs in the cache module where address decoding is made
9
-- (besides, they should be module generics, not package constants)
10
subtype t_addr_decode is std_logic_vector(31 downto 24);
11
constant ADDR_BOOT : t_addr_decode      := X"00";
12
constant ADDR_XRAM : t_addr_decode      := X"80";
13
constant ADDR_IO : t_addr_decode        := X"20";
14 37 ja_rd
 
15
 
16 2 ja_rd
subtype t_addr is std_logic_vector(31 downto 0);
17
subtype t_word is std_logic_vector(31 downto 0);
18
subtype t_dword is std_logic_vector(63 downto 0);
19
subtype t_regnum is std_logic_vector(4 downto 0);
20
 
21
type t_rbank is array(0 to 31) of t_word;
22
 
23
subtype t_pc is std_logic_vector(31 downto 2);
24
 
25
constant ZERO : t_word := (others => '0');
26
 
27
type t_alu_control is record
28
    logic_sel :         std_logic_vector(1 downto 0);
29
    shift_sel :         std_logic_vector(1 downto 0);
30
    shift_amount :      std_logic_vector(4 downto 0);
31
    neg_sel :           std_logic_vector(1 downto 0);
32
    use_arith :         std_logic;
33
    use_logic :         std_logic_vector(1 downto 0);
34
    cy_in :             std_logic;
35
    use_slt :           std_logic;
36
    arith_unsigned :    std_logic;
37
end record t_alu_control;
38
 
39
type t_alu_flags is record
40
    inp1_lt_zero :      std_logic;
41
    inp1_eq_zero :      std_logic;
42
    inp1_lt_inp2 :      std_logic;
43
    inp1_eq_inp2 :      std_logic;
44
end record t_alu_flags;
45
 
46 12 ja_rd
-- 32-cycle mul/div module control. Bits 4-3 & 1-0 of IR.
47
subtype t_mult_function is std_logic_vector(3 downto 0);
48
constant MULT_NOTHING       : t_mult_function := "0000";
49
constant MULT_READ_LO       : t_mult_function := "1010"; -- 18
50
constant MULT_READ_HI       : t_mult_function := "1000"; -- 16
51
constant MULT_WRITE_LO      : t_mult_function := "1011"; -- 19
52
constant MULT_WRITE_HI      : t_mult_function := "1001"; -- 17
53
constant MULT_MULT          : t_mult_function := "1101"; -- 25
54
constant MULT_SIGNED_MULT   : t_mult_function := "1100"; -- 24
55
constant MULT_DIVIDE        : t_mult_function := "1111"; -- 26
56
constant MULT_SIGNED_DIVIDE : t_mult_function := "1110"; -- 27
57
 
58 37 ja_rd
-- Computes ceil(log2(A)), e.g. address width of memory block
59
-- CAN BE USED IN SYNTHESIZABLE CODE as long as called with constant arguments
60
function log2(A : natural) return natural;
61 12 ja_rd
 
62 37 ja_rd
 
63 2 ja_rd
end package;
64 37 ja_rd
 
65
package body mips_pkg is
66
 
67
function log2(A : natural) return natural is
68
begin
69
    for I in 1 to 30 loop -- Works for up to 32 bit integers
70
        if(2**I > A) then
71
            return(I-1);
72
        end if;
73
    end loop;
74
    return(30);
75
end function log2;
76
 
77
end package body;

powered by: WebSVN 2.1.0

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