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

Subversion Repositories c16

[/] [c16/] [trunk/] [vhdl/] [cpu_pack.vhd] - Blame information for rev 33

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

Line No. Rev Author Line
1 2 jsauermann
--      Package File Template
2
--
3
--      Purpose: This package defines supplemental types, subtypes, 
4
--               constants, and functions 
5
 
6
library IEEE;
7
use IEEE.STD_LOGIC_1164.all;
8
 
9
package cpu_pack is
10
 
11
        type cycle is ( M1, M2, M3, M4, M5 );
12
 
13
        type op_category is (
14
                INTR,
15
                HALT_WAIT,
16
 
17
                -- 0X
18
                HALT,
19
                NOP,
20
                JMP_i,
21
                JMP_RRNZ_i,
22
                JMP_RRZ_i,
23
                CALL_i,
24
                CALL_RR,
25
                RET,
26
                MOVE_SPi_RR,
27
                MOVE_SPi_RS,
28
                MOVE_SPi_RU,
29
                MOVE_SPi_LL,
30
                MOVE_SPi_LS,
31
                MOVE_SPi_LU,
32
                MOVE_RR_dSP,
33
                MOVE_R_dSP,
34
 
35
                -- 1X
36
                AND_RR_i,
37
                OR_RR_i,
38
                XOR_RR_i,
39
                SEQ_RR_i,
40
                SNE_RR_i,
41
                SGE_RR_i,
42
                SGT_RR_i,
43
                SLE_RR_i,
44
 
45
                -- 2X
46
                SLT_RR_i,
47
                SHS_RR_i,
48
                SHI_RR_i,
49
                SLS_RR_i,
50
                SLO_RR_i,
51
                CLRW_dSP,
52
                CLRB_dSP,
53
                IN_ci_RU,
54
                OUT_R_ci,
55
 
56
                -- 3X
57
                AND_LL_RR,
58
                OR_LL_RR,
59
                XOR_LL_RR,
60
                SEQ_LL_RR,
61
                SNE_LL_RR,
62
                SGE_LL_RR,
63
                SGT_LL_RR,
64
                SLE_LL_RR,
65
                SLT_LL_RR,
66
                SHS_LL_RR,
67
                SHI_LL_RR,
68
                SLS_LL_RR,
69
                SLO_LL_RR,
70
                LNOT_RR,
71
                NEG_RR,
72
                NOT_RR,
73
 
74
                -- 4X
75
                MOVE_LL_RR,
76
                MOVE_LL_cRR,
77
                MOVE_L_cRR,
78
                MOVE_RR_LL,
79
                MOVE_RR_cLL,
80
                MOVE_R_cLL,
81
                MOVE_cRR_RR,
82
                MOVE_cRR_RS,
83
                MOVE_cRR_RU,
84
                MOVE_ci_RR,
85
                MOVE_ci_RS,
86
                MOVE_ci_RU,
87
                MOVE_ci_LL,
88
                MOVE_ci_LS,
89
                MOVE_ci_LU,
90
                MOVE_RR_SP,
91
 
92
                -- 5X
93
                LSL_RR_i,
94
                ASR_RR_i,
95
                LSR_RR_i,
96
                LSL_LL_RR,
97
                ASR_LL_RR,
98
                LSR_LL_RR,
99
                ADD_LL_RR,
100
                SUB_LL_RR,
101
                MOVE_RR_ci,
102
                MOVE_R_ci,
103
                MOVE_RR_uSP,
104
                MOVE_R_uSP,
105
 
106
                -- 6X
107
                MOVE_uSP_RR,
108
                MOVE_uSP_RS,
109
                MOVE_uSP_RU,
110
                MOVE_uSP_LL,
111
                MOVE_uSP_LS,
112
                MOVE_uSP_LU,
113
                LEA_uSP_RR,
114
                MOVE_dRR_dLL,
115
                MOVE_RRi_LLi,
116
 
117
                -- 7X
118
                MUL_IS,
119
                MUL_IU,
120
                DIV_IS,
121
                DIV_IU,
122
                MD_STEP,
123
                MD_FIN,
124
                MOD_FIN,
125
                EI,
126
                RETI,
127
                DI,
128
 
129
                -- 9X ... FX
130
                ADD_RR_I,
131
                SUB_RR_I,
132
                MOVE_I_RR,
133
                ADD_SP_I,
134
                SEQ_LL_I,
135
                MOVE_I_LL,
136
 
137
                undef );
138
 
139
        type SP_OP is ( SP_NOP, SP_INC, SP_LOAD );
140
 
141
        -- ALU codes
142
        --
143
        constant ALU_X_HS_Y   : std_logic_vector(4 downto 0) := "00000";
144
        constant ALU_X_LO_Y   : std_logic_vector(4 downto 0) := "00001";
145
        constant ALU_X_HI_Y   : std_logic_vector(4 downto 0) := "00010";
146
        constant ALU_X_LS_Y   : std_logic_vector(4 downto 0) := "00011";
147
        constant ALU_X_GE_Y   : std_logic_vector(4 downto 0) := "00100";
148
        constant ALU_X_LT_Y   : std_logic_vector(4 downto 0) := "00101";
149
        constant ALU_X_GT_Y   : std_logic_vector(4 downto 0) := "00110";
150
        constant ALU_X_LE_Y   : std_logic_vector(4 downto 0) := "00111";
151
        constant ALU_X_EQ_Y   : std_logic_vector(4 downto 0) := "01000";
152
        constant ALU_X_NE_Y   : std_logic_vector(4 downto 0) := "01001";
153
 
154
        constant ALU_NEG_Y    : std_logic_vector(4 downto 0) := "01100";
155
        constant ALU_X_SUB_Y  : std_logic_vector(4 downto 0) := "01101";
156
        constant ALU_MOVE_Y   : std_logic_vector(4 downto 0) := "01110";
157
        constant ALU_X_ADD_Y  : std_logic_vector(4 downto 0) := "01111";
158
 
159
        constant ALU_X_AND_Y  : std_logic_vector(4 downto 0) := "10000";
160
        constant ALU_X_OR_Y   : std_logic_vector(4 downto 0) := "10001";
161
        constant ALU_X_XOR_Y  : std_logic_vector(4 downto 0) := "10010";
162
        constant ALU_NOT_Y    : std_logic_vector(4 downto 0) := "10011";
163
 
164
        constant ALU_X_LSR_Y  : std_logic_vector(4 downto 0) := "10100";
165
        constant ALU_X_ASR_Y  : std_logic_vector(4 downto 0) := "10101";
166
        constant ALU_X_LSL_Y  : std_logic_vector(4 downto 0) := "10110";
167
        constant ALU_X_MIX_Y  : std_logic_vector(4 downto 0) := "10111";
168
 
169
        constant ALU_MUL_IU  : std_logic_vector(4 downto 0) := "11000";
170
        constant ALU_MUL_IS  : std_logic_vector(4 downto 0) := "11001";
171
        constant ALU_DIV_IU  : std_logic_vector(4 downto 0) := "11010";
172
        constant ALU_DIV_IS  : std_logic_vector(4 downto 0) := "11011";
173
 
174
        constant ALU_MD_STP  : std_logic_vector(4 downto 0) := "11100";
175
        constant ALU_MD_FIN  : std_logic_vector(4 downto 0) := "11101";
176
        constant ALU_MOD_FIN : std_logic_vector(4 downto 0) := "11110";
177
 
178
        constant ALU_ANY     : std_logic_vector(4 downto 0) := ALU_X_AND_Y;
179
--------------------------------------------------------------
180
        constant SA_43_0    : std_logic_vector(1 downto 0) := "00";
181
        constant SA_43_FFFF : std_logic_vector(1 downto 0) := "01";      -- last bit 1 !!!
182
        constant SA_43_I16  : std_logic_vector(1 downto 0) := "10";
183
        constant SA_43_I8S  : std_logic_vector(1 downto 0) := "11";
184
 
185
        constant SA_21_0    : std_logic_vector(1 downto 0) := "00";
186
        constant SA_21_LL   : std_logic_vector(1 downto 0) := "01";
187
        constant SA_21_RR   : std_logic_vector(1 downto 0) := "10";
188
        constant SA_21_SP   : std_logic_vector(1 downto 0) := "11";
189
 
190
        constant ADR_cSP_L  : std_logic_vector(4 downto 0) := SA_43_0    & SA_21_SP & '0';
191
        constant ADR_cRR_L  : std_logic_vector(4 downto 0) := SA_43_0    & SA_21_RR & '0';
192
        constant ADR_cLL_L  : std_logic_vector(4 downto 0) := SA_43_0    & SA_21_LL & '0';
193
        constant ADR_cI16_L : std_logic_vector(4 downto 0) := SA_43_I16  & SA_21_0  & '0';
194
        constant ADR_16SP_L : std_logic_vector(4 downto 0) := SA_43_I16  & SA_21_SP & '0';
195
        constant ADR_8SP_L  : std_logic_vector(4 downto 0) := SA_43_I8S  & SA_21_SP & '0';
196
        constant ADR_IO     : std_logic_vector(4 downto 0) := SA_43_I8S  & SA_21_0  & '0';
197
 
198
        constant ADR_cSP_H  : std_logic_vector(4 downto 0) := SA_43_0    & SA_21_SP & '1';
199
        constant ADR_cRR_H  : std_logic_vector(4 downto 0) := SA_43_0    & SA_21_RR & '1';
200
        constant ADR_cLL_H  : std_logic_vector(4 downto 0) := SA_43_0    & SA_21_LL & '1';
201
        constant ADR_cI16_H : std_logic_vector(4 downto 0) := SA_43_I16  & SA_21_0  & '1';
202
        constant ADR_16SP_H : std_logic_vector(4 downto 0) := SA_43_I16  & SA_21_SP & '1';
203
        constant ADR_8SP_H  : std_logic_vector(4 downto 0) := SA_43_I8S  & SA_21_SP & '1';
204
 
205
        constant ADR_dSP    : std_logic_vector(4 downto 0) := SA_43_FFFF & SA_21_SP & '0';
206
        constant ADR_dRR    : std_logic_vector(4 downto 0) := SA_43_FFFF & SA_21_RR & '0';
207
        constant ADR_dLL    : std_logic_vector(4 downto 0) := SA_43_FFFF & SA_21_LL & '0';
208
        constant ADR_SPi    : std_logic_vector(4 downto 0) := SA_43_FFFF & SA_21_SP & '1';
209
        constant ADR_RRi    : std_logic_vector(4 downto 0) := ADR_cRR_L;
210
        constant ADR_LLi    : std_logic_vector(4 downto 0) := ADR_cLL_L;
211
--------------------------------------------------------------
212
        constant SX_LL   : std_logic_vector(1 downto 0) := "00";
213
        constant SX_RR   : std_logic_vector(1 downto 0) := "01";
214
        constant SX_SP   : std_logic_vector(1 downto 0) := "10";
215
        constant SX_PC   : std_logic_vector(1 downto 0) := "11";
216
        constant SX_ANY  : std_logic_vector(1 downto 0) := SX_RR;
217
--------------------------------------------------------------
218
        constant SY_SY0  : std_logic_vector(3 downto 0) := "0000";
219
        constant SY_SY1  : std_logic_vector(3 downto 0) := "0001";
220
        constant SY_SY2  : std_logic_vector(3 downto 0) := "0010";
221
        constant SY_SY3  : std_logic_vector(3 downto 0) := "0011";
222
        constant SY_I16  : std_logic_vector(3 downto 0) := "0100";
223
        constant SY_RR   : std_logic_vector(3 downto 0) := "0101";
224
 
225
        constant SY_SI8  : std_logic_vector(3 downto 0) := "1000";
226
        constant SY_UI8  : std_logic_vector(3 downto 0) := "1001";
227
        constant SY_SQ   : std_logic_vector(3 downto 0) := "1010";
228
        constant SY_UQ   : std_logic_vector(3 downto 0) := "1011";
229
        constant SY_SM   : std_logic_vector(3 downto 0) := "1100";
230
        constant SY_UM   : std_logic_vector(3 downto 0) := "1101";
231
        constant SY_ANY  : std_logic_vector(3 downto 0) := SY_RR;
232
--------------------------------------------------------------
233
        constant PC_NEXT : std_logic_vector(2 downto 0) := "000";        -- count up
234
        constant PC_JMP  : std_logic_vector(2 downto 0) := "001";        -- JMP/CALL
235
        constant PC_RETH : std_logic_vector(2 downto 0) := "010";        -- RET (H)
236
        constant PC_RETL : std_logic_vector(2 downto 0) := "011";        -- RET (L)
237
        constant PC_WAIT : std_logic_vector(2 downto 0) := "100";        -- WAIT
238
        constant PC_JPRR : std_logic_vector(2 downto 0) := "101";        -- JMP (RR)
239
        constant PC_INT  : std_logic_vector(2 downto 0) := "110";        -- INT
240
--------------------------------------------------------------
241
 
242
end cpu_pack;
243
 
244
package body cpu_pack is
245
 
246
end cpu_pack;

powered by: WebSVN 2.1.0

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