3 use IEEE.std_logic_1164.all;
4 use IEEE.numeric_std.all;
10 constant WORD_WIDTH : INTEGER := 32;
11 constant HWORD_WIDTH : INTEGER := 16;
12 constant BYTE_WIDTH : INTEGER := 8;
13 constant OPCODE_WIDTH : INTEGER := 5;
14 constant DISPL_WIDTH : INTEGER := 15;
16 subtype byte_t is std_logic_vector(BYTE_WIDTH-1 downto 0);
17 subtype hword_t is std_logic_vector(HWORD_WIDTH-1 downto 0);
18 subtype word_t is std_logic_vector(WORD_WIDTH-1 downto 0);
20 subtype gp_register_t is word_t;
23 constant REG_ZERO : gp_register_t := (others => '0');
25 constant INSTR_ADDR_WIDTH : INTEGER := 32;
26 constant PHYS_INSTR_ADDR_WIDTH : INTEGER := 11;
27 constant REG_ADDR_WIDTH : INTEGER := 4;
28 constant DATA_ADDR_WIDTH : INTEGER := 32;
29 constant PHYS_DATA_ADDR_WIDTH : INTEGER := 32;
31 constant NUM_OP_OPT_WIDTH : INTEGER := 6;
32 constant COND_WIDTH : INTEGER := 4;
35 subtype instruction_word_t is std_logic_vector(WORD_WIDTH-1 downto 0);
36 subtype instruction_addr_t is std_logic_vector(INSTR_ADDR_WIDTH-1 downto 0);
38 subtype gp_addr_t is unsigned(REG_ADDR_WIDTH-1 downto 0);
39 subtype data_ram_word_t is std_logic_vector(WORD_WIDTH-1 downto 0);
40 subtype data_ram_addr_t is std_logic_vector(DATA_ADDR_WIDTH-1 downto 0);
42 subtype opcode_t is std_logic_vector(OPCODE_WIDTH-1 downto 0);
43 subtype condition_t is std_logic_vector(COND_WIDTH-1 downto 0);
45 --Opcode consits of decoded group information type and option bits
46 --currently not complete, might need option increase too.
47 --IMMEDIATE always in right_operand (src2)
49 constant IMM_OPT : integer := 0; -- no sharing
51 constant SUB_OPT : integer := 1;
52 constant LOG_OPT : integer := 1;
54 constant CARRY_OPT : integer := 2;
56 constant LEFT_OPT : integer := 3;
58 constant NO_PSW_OPT : integer := 4;--no sharing
59 constant NO_DST_OPT : integer := 5; --no sharing
61 type op_info_t is (ADDSUB_OP,AND_OP,OR_OP, XOR_OP,SHIFT_OP);
62 subtype op_opt_t is std_logic_vector(NUM_OP_OPT_WIDTH-1 downto 0);
65 type instruction_rec is record
67 predicates : std_logic_vector(3 downto 0);
71 reg_dest_addr : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
72 reg_src1_addr : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
73 reg_src2_addr : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
75 immediate : std_logic_vector(WORD_WIDTH-1 downto 0);
76 displacement : std_logic_vector(DISPL_WIDTH-1 downto 0);
78 jmptype : std_logic_vector(1 downto 0);
80 carry, sreg_update, high_low, fill, signext, bp, arith, left_right : std_logic;
85 type read_through_write_rec is record
87 rtw_reg : gp_register_t;
94 condition : condition_t;
100 src2 : gp_register_t;
112 function inc(value : in std_logic_vector; constant by : in integer := 1) return std_logic_vector;
113 function log2c(constant value : in integer range 0 to integer'high) return integer;
114 end package common_pkg;
116 package body common_pkg is
118 function inc(value : in std_logic_vector; constant by : in integer := 1) return std_logic_vector is
120 return std_logic_vector(UNSIGNED(value)+by);
123 function log2c(constant value : in integer range 0 to integer'high) return integer is
124 variable ret_value : integer;
125 variable cur_value : integer;
130 while cur_value < value loop
131 ret_value := ret_value + 1;
132 cur_value := cur_value * 2;
137 end package body common_pkg;