3 use IEEE.std_logic_1164.all;
4 use IEEE.numeric_std.all;
9 constant WORD_WIDTH : INTEGER := 32;
10 constant HWORD_WIDTH : INTEGER := 16;
11 constant BYTE_WIDTH : INTEGER := 8;
12 constant OPCODE_WIDTH : INTEGER := 5;
13 constant DISPL_WIDTH : INTEGER := 15;
15 constant REG_ZERO : gp_register_t := (others => '0');
17 constant INSTR_ADDR_WIDTH : INTEGER := 32;
18 constant PHYS_INSTR_ADDR_WIDTH : INTEGER := 11;
19 constant REG_ADDR_WIDTH : INTEGER := 4;
20 constant DATA_ADDR_WIDTH : INTEGER := 32;
21 constant PHYS_DATA_ADDR_WIDTH : INTEGER := 32;
23 subtype byte_t is std_logic_vector(BYTE_WIDTH-1 downto 0);
24 subtype hword_t is std_logic_vector(HWORD_WIDTH-1 downto 0);
25 subtype word_t is std_logic_vector(WORD_WIDTH-1 downto 0);
27 subtype instruction_word_t is std_logic_vector(WORD_WIDTH-1 downto 0);
28 subtype instruction_addr_t is std_logic_vector(INSTR_ADDR_WIDTH-1 downto 0);
30 subtype gp_register_t is word_t;
31 subtype gp_addr_t is unsigned(REG_ADDR_WIDTH-1 downto 0);
32 subtype data_ram_word_t is std_logic_vector(WORD_WIDTH-1 downto 0);
33 subtype data_ram_addr_t is std_logic_vector(DATA_ADDR_WIDTH-1 downto 0);
35 subtype opcode_t is std_logic_vector(OPCODE_WIDTH-1 downto 0);
37 function inc(value : in std_logic_vector; constant by : in integer := 1) return std_logic_vector;
38 function log2c(constant value : in integer range 0 to integer'high) return integer;
39 end package common_pkg;
41 package body common_pkg;
43 function inc(value : in std_logic_vector; constant by : in integer := 1) return std_logic_vector is
45 return std_logic_vector(UNSIGNED(value)+by);
48 function log2c(constant value : in integer range 0 to integer'high) return integer is
49 variable ret_value : integer;
50 variable cur_value : integer;
55 while cur_value < value loop
56 ret_value := ret_value + 1;
57 cur_value := cur_value * 2;
62 end package body common_pkg;