1 |
68 |
jlechner |
-------------------------------------------------------------------------------
|
2 |
|
|
-- File: rise_pack.vhd
|
3 |
|
|
-- Author: Jakob Lechner, Urban Stadler, Harald Trinkl, Christian Walter
|
4 |
|
|
-- Created: 2006-11-29
|
5 |
|
|
-- Last updated: 2006-11-29
|
6 |
|
|
|
7 |
|
|
-- Description:
|
8 |
|
|
-- Package for RISE project.
|
9 |
|
|
-------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
library IEEE;
|
13 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
14 |
|
|
use IEEE.STD_LOGIC_ARITH.all;
|
15 |
|
|
use work.RISE_CONST_PACK.all;
|
16 |
|
|
|
17 |
|
|
package RISE_PACK_SPECIFIC is
|
18 |
|
|
|
19 |
|
|
constant OPCODE_WIDTH : integer := CONST_OPCODE_WIDTH;
|
20 |
|
|
constant COND_WIDTH : integer := CONST_COND_WIDTH;
|
21 |
|
|
|
22 |
|
|
-- RISE OPCODES --
|
23 |
|
|
type OPCODE_T is (OPCODE_LD_IMM, OPCODE_LD_IMM_HB, OPCODE_LD_DISP, OPCODE_LD_DISP_MS,
|
24 |
|
|
OPCODE_LD_REG, OPCODE_ST_DISP, OPCODE_ADD, OPCODE_ADD_IMM, OPCODE_SUB,
|
25 |
|
|
OPCODE_SUB_IMM, OPCODE_NEG, OPCODE_ARS, OPCODE_ALS, OPCODE_AND, OPCODE_NOT,
|
26 |
|
|
OPCODE_EOR, OPCODE_LS, OPCODE_RS, OPCODE_JMP, OPCODE_TST, OPCODE_NOP);
|
27 |
|
|
|
28 |
|
|
-- CONDITIONALS --
|
29 |
|
|
type COND_T is (COND_UNCONDITIONAL, COND_NOT_ZERO, COND_ZERO, COND_CARRY, COND_NEGATIVE,
|
30 |
|
|
COND_OVERFLOW, COND_ZERO_NEGATIVE);
|
31 |
|
|
|
32 |
|
|
function svector2opcode (v : std_logic_vector) return OPCODE_T;
|
33 |
|
|
function svector2cond (v : std_logic_vector) return COND_T;
|
34 |
|
|
end RISE_PACK_SPECIFIC;
|
35 |
|
|
|
36 |
|
|
package body RISE_PACK_SPECIFIC is
|
37 |
|
|
|
38 |
|
|
-- purpose: converts std_logic_vector to enum type
|
39 |
|
|
function svector2opcode (v : std_logic_vector) return OPCODE_T is
|
40 |
|
|
variable result : OPCODE_T;
|
41 |
|
|
variable v_tmp : CONST_OPCODE_T;
|
42 |
|
|
begin -- svector2opcode
|
43 |
|
|
v_tmp := v;
|
44 |
|
|
case v_tmp is
|
45 |
|
|
when CONST_OPCODE_LD_IMM => result := OPCODE_LD_IMM;
|
46 |
|
|
when CONST_OPCODE_LD_IMM_HB => result := OPCODE_LD_IMM_HB;
|
47 |
|
|
when CONST_OPCODE_LD_DISP => result := OPCODE_LD_DISP;
|
48 |
|
|
when CONST_OPCODE_LD_DISP_MS => result := OPCODE_LD_DISP_MS;
|
49 |
|
|
when CONST_OPCODE_LD_REG => result := OPCODE_LD_REG;
|
50 |
|
|
when CONST_OPCODE_ST_DISP => result := OPCODE_ST_DISP;
|
51 |
|
|
when CONST_OPCODE_ADD => result := OPCODE_ADD;
|
52 |
|
|
when CONST_OPCODE_ADD_IMM => result := OPCODE_ADD_IMM;
|
53 |
|
|
when CONST_OPCODE_SUB => result := OPCODE_SUB;
|
54 |
|
|
when CONST_OPCODE_SUB_IMM => result := OPCODE_SUB_IMM;
|
55 |
|
|
when CONST_OPCODE_NEG => result := OPCODE_NEG;
|
56 |
|
|
when CONST_OPCODE_ARS => result := OPCODE_ARS;
|
57 |
|
|
when CONST_OPCODE_ALS => result := OPCODE_ALS;
|
58 |
|
|
when CONST_OPCODE_AND => result := OPCODE_AND;
|
59 |
|
|
when CONST_OPCODE_NOT => result := OPCODE_NOT;
|
60 |
|
|
when CONST_OPCODE_EOR => result := OPCODE_EOR;
|
61 |
|
|
when CONST_OPCODE_LS => result := OPCODE_LS;
|
62 |
|
|
when CONST_OPCODE_RS => result := OPCODE_RS;
|
63 |
|
|
when CONST_OPCODE_JMP => result := OPCODE_JMP;
|
64 |
|
|
when CONST_OPCODE_TST => result := OPCODE_TST;
|
65 |
|
|
when CONST_OPCODE_NOP => result := OPCODE_NOP;
|
66 |
|
|
when others => result := OPCODE_NOP;
|
67 |
|
|
end case;
|
68 |
|
|
return result;
|
69 |
|
|
end svector2opcode;
|
70 |
|
|
|
71 |
|
|
-- purpose: converts std_logic_vector to enum type
|
72 |
|
|
function svector2cond (v : std_logic_vector) return COND_T is
|
73 |
|
|
variable result : COND_T;
|
74 |
|
|
variable v_tmp : CONST_COND_T;
|
75 |
|
|
begin -- svector2cond
|
76 |
|
|
v_tmp := v;
|
77 |
|
|
case v_tmp is
|
78 |
|
|
when CONST_COND_UNCONDITIONAL => result := COND_UNCONDITIONAL;
|
79 |
|
|
when CONST_COND_NOT_ZERO => result := COND_NOT_ZERO;
|
80 |
|
|
when CONST_COND_ZERO => result := COND_ZERO;
|
81 |
|
|
when CONST_COND_CARRY => result := COND_CARRY;
|
82 |
|
|
when CONST_COND_NEGATIVE => result := COND_NEGATIVE;
|
83 |
|
|
when CONST_COND_OVERFLOW => result := COND_OVERFLOW;
|
84 |
|
|
when CONST_COND_ZERO_NEGATIVE => result := COND_ZERO_NEGATIVE;
|
85 |
|
|
when others => result := COND_UNCONDITIONAL;
|
86 |
|
|
end case;
|
87 |
|
|
return result;
|
88 |
|
|
end svector2cond;
|
89 |
|
|
|
90 |
|
|
end RISE_PACK_SPECIFIC;
|
91 |
|
|
|