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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [arm/] [libs/] [armdecode.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
library ieee;
2
use ieee.std_logic_1164.all;
3
use work.config.all;
4
use work.memdef.all;
5
use work.armpmodel.all;
6
use work.armshiefter.all;
7
 
8
-- PREFIX: ade_xxx
9
package armdecode is
10
 
11
-------------------------------------------------------------------------------
12
 
13
-- Addressing modes:
14
-- DAta PRocessing Addressing Modes      : DAPRAM
15
-- LoaD/STore Addressing Modes           : LDSTAM
16
-- Load/Store misc (V4) Addressing Modes : LSV4AM
17
 
18
-- DAta PRocessing Addressing Modes (DAPRAM):
19
--
20
-- o ade_DAPRAM_simm:
21
--   - DP op2: Register                     : <rm>
22
--   - DP op2: Register <SDIR> by Immediate : <rm>, <SDIR> #<imm>
23
--   - DP op2: Register RRX                 : <rm>, RRX
24
--   - <SDIR>: {LSL}|{LSR}|{ASR}|{ROR}
25
-- o ade_DAPRAM_sreg:
26
--   - DP op2: Register <SDIR> by Register  : <rm>, <SDIR> <rs>
27
--   - <SDIR>: {LSL}|{LSR}|{ASR}|{ROR}
28
-- o ade_DAPRAM_immrot:
29
--   - DP op2: Immediate #<imm>
30
 
31
type ade_DAPRAM is (
32
  ade_DAPRAM_simm,       -- OP2 shieft with imm 
33
  ade_DAPRAM_sreg,       -- OP2 shieft with reg 
34
  ade_DAPRAM_immrot      -- OP2 immidiate rotated
35
);
36
 
37
-- Load/Store  Addressing Modes (LDSTAM) and Load/Store misc (V4) Addressing Modes (LSV4AM) :
38
-- 
39
-- o adm_LDSTAMxLSV4AM_reg:
40
--   * <LSV4AM>
41
--     - L/S W/UB: Register Offset                     : [<rn>, +/-<rm>]
42
--     - L/S W/UB: Register Offset pre-indexed         : [<rn>, +/-<rm>]!
43
--     - L/S W/UB: Register Offset post-indexed        : [<rn>], +/-<rm>
44
--     - L/S W/UB: Scaled Register Offset              : [<rn>, +/-<rm>, <LSAMscale>]
45
--     - L/S W/UB: Scaled Register Offset pre-indexed  : [<rn>, +/-<rm>, <LSAMscale>]!
46
--     - L/S W/UB: Scaled Register Offset post-indexed : [<rn>], +/-<rm>, <LSAMscale>
47
--     - <LSAMscale>: {LSL #<imm>}|{LSR #<imm>}|{ASR #<imm>}|{ROR #<imm>}|{RRX}
48
--   * <LDSTAM>
49
--     - L/S MISC: Register offset            : [<rn>, #+/-<rm>]
50
--     - L/S MISC: Register offset pre-index  : [<rn>, #+/-<rm>] !
51
--     - L/S MISC: Register offset post-index : [<rn>], #+/-<rm>
52
-- o adm_LDSTAMxLSV4AM_imm:
53
--   * <LSV4AM>
54
--     - L/S W/UB: Immediate Offset              : [<rn>, #+/-<offset12>]
55
--     - L/S W/UB: Immediate Offset pre-indexed  : [<rn>, #+/-<offset12>]!
56
--     - L/S W/UB: Immediate Offset post-indexed : [<rn>], #+/-<offset12>
57
--   * <LDSTAM>
58
--     - L/S MISC: Immediate offset            : [<rn>, #+/-<off>]
59
--     - L/S MISC: Immediate offset pre-index  : [<rn>, #+/-<off>] !
60
--     - L/S MISC: Immediate offset post-index : [<rn>], #+/-<off>
61
 
62
type ade_LDSTAMxLSV4AM is (
63
  ade_LDSTAMxLSV4AM_imm,  -- addr v1 imm
64
                          -- addr v4 imm
65
  ade_LDSTAMxLSV4AM_reg   -- addr v1 reg (shieft with imm)
66
                          -- addr v4 reg
67
);
68
 
69
-- Prefix/Postfix
70
type ade_pos is (
71
  ade_pre,      -- pre indexed
72
  ade_post      -- post indexed
73
);
74
 
75
-- Decoded addressing mode
76
type ade_amode is record
77
  DAPRAM_typ           : ade_DAPRAM;
78
  LDSTAM_typ           : ade_LDSTAMxLSV4AM;
79
  LSV4AM_typ           : ade_LDSTAMxLSV4AM;
80
  LDSTAMxLSV4AM_pos    : ade_pos;
81
  DAPRAMxLDSTAM_sdir   : ash_sdir;
82
  LDSTAMxLSV4AM_uacc   : std_logic;
83
  LDSTAMxLSV4AM_wb     : std_logic;
84
end record;
85
 
86
-- Decode addressing mode
87
procedure ade_decode_amode (
88
  insn : in std_logic_vector(31 downto 0);
89
  am   : out ade_amode
90
);
91
 
92
-------------------------------------------------------------------------------
93
 
94
-- Implemented instructions:
95
type ade_decinsn is (
96
  type_arm_invalid,type_arm_nop,    type_arm_mrs,    type_arm_bx,    type_arm_mul,   type_arm_mla,
97
  type_arm_swp,    type_arm_sumull, type_arm_sumlal, type_arm_strhb, type_arm_ldrhb, type_arm_and,
98
  type_arm_sub,    type_arm_eor,    type_arm_rsb,    type_arm_add,   type_arm_sbc,   type_arm_adc,
99
  type_arm_msr,    type_arm_teq,    type_arm_cmn,    type_arm_tst,   type_arm_cmp,   type_arm_orr,
100
  type_arm_mov,    type_arm_mvn,    type_arm_str1,   type_arm_str2,  type_arm_str3,  type_arm_ldr1,
101
  type_arm_stm,    type_arm_ldm,    type_arm_b,      type_arm_swi,   type_arm_cdp,   type_arm_mrc,
102
  type_arm_mcr,    type_arm_stc,    type_arm_ldc,    type_arm_rsc,   type_arm_bic,   type_arm_undefined
103
);
104
 
105
-- Instruction groups
106
type ade_insntyp is (
107
  ade_typmem,
108
  ade_typalu,
109
  ade_typmisc,
110
  ade_typcp
111
);
112
 
113
-- this decoder is automatically generated by "decgen"
114
function ade_decode_v4(
115
  insn_in : in std_logic_vector(31 downto 0)
116
) return ade_decinsn;
117
 
118
-------------------------------------------------------------------------------
119
-- Condition code
120
 
121
constant ADE_COND_U  : integer := 31;
122
constant ADE_COND_D  : integer := 28;
123
constant ADE_COND_EQ : std_logic_vector(3 downto 0) := "0000";
124
constant ADE_COND_NE : std_logic_vector(3 downto 0) := "0001";
125
constant ADE_COND_CS : std_logic_vector(3 downto 0) := "0010";
126
constant ADE_COND_CC : std_logic_vector(3 downto 0) := "0011";
127
constant ADE_COND_MI : std_logic_vector(3 downto 0) := "0100";
128
constant ADE_COND_PL : std_logic_vector(3 downto 0) := "0101";
129
constant ADE_COND_VS : std_logic_vector(3 downto 0) := "0110";
130
constant ADE_COND_VC : std_logic_vector(3 downto 0) := "0111";
131
constant ADE_COND_HI : std_logic_vector(3 downto 0) := "1000";
132
constant ADE_COND_LS : std_logic_vector(3 downto 0) := "1001";
133
constant ADE_COND_GE : std_logic_vector(3 downto 0) := "1010";
134
constant ADE_COND_LT : std_logic_vector(3 downto 0) := "1011";
135
constant ADE_COND_GT : std_logic_vector(3 downto 0) := "1100";
136
constant ADE_COND_LE : std_logic_vector(3 downto 0) := "1101";
137
constant ADE_COND_AL : std_logic_vector(3 downto 0) := "1110";
138
constant ADE_COND_NV : std_logic_vector(3 downto 0) := "1111";
139
 
140
-------------------------------------------------------------------------------
141
-- Alu codes
142
 
143
constant ADE_OP_U : integer := 24;
144
constant ADE_OP_D : integer := 21;
145
constant ADE_OP_AND : std_logic_vector(3 downto 0) := "0000";
146
constant ADE_OP_EOR : std_logic_vector(3 downto 0) := "0001";
147
constant ADE_OP_SUB : std_logic_vector(3 downto 0) := "0010";
148
constant ADE_OP_RSB : std_logic_vector(3 downto 0) := "0011";
149
constant ADE_OP_ADD : std_logic_vector(3 downto 0) := "0100";
150
constant ADE_OP_ADC : std_logic_vector(3 downto 0) := "0101";
151
constant ADE_OP_SBC : std_logic_vector(3 downto 0) := "0110";
152
constant ADE_OP_RSC : std_logic_vector(3 downto 0) := "0111";
153
constant ADE_OP_TST : std_logic_vector(3 downto 0) := "1000";
154
constant ADE_OP_TEQ : std_logic_vector(3 downto 0) := "1001";
155
constant ADE_OP_CMP : std_logic_vector(3 downto 0) := "1010";
156
constant ADE_OP_CMN : std_logic_vector(3 downto 0) := "1011";
157
constant ADE_OP_ORR : std_logic_vector(3 downto 0) := "1100";
158
constant ADE_OP_MOV : std_logic_vector(3 downto 0) := "1101";
159
constant ADE_OP_BIC : std_logic_vector(3 downto 0) := "1110";
160
constant ADE_OP_MVN : std_logic_vector(3 downto 0) := "1111";
161
 
162
constant ADE_SETCPSR_C : integer := 20;  -- set cpsr
163
 
164
-------------------------------------------------------------------------------
165
-- swp, msr, mrs codes
166
 
167
constant ADE_MSR_R : integer := 22;  -- '1' = spsr: '0' = cpsr
168
constant ADE_MRS_R : integer := 22;  -- '1' = spsr: '0' = cpsr
169
constant ADE_MSR_IMM : integer := 16;   -- '1' = imm; '0' = reg
170
 
171
constant ADE_WB_C : integer := 21;      -- same as ADE_LDSTAMxLSV4AM_WB
172
constant ADE_SWPB_C : integer := 22;    -- 1=SWPB,0=SWP
173
 
174
constant ADE_BROFF_U : integer := 23;     -- branch offset
175
constant ADE_BROFF_D : integer := 0;
176
constant ADE_BRLINK_C : integer := 22;
177
 
178
-------------------------------------------------------------------------------
179
-- ld, st codes
180
 
181
constant ADE_LDSTAM_OFF_U : integer := 11;  -- <offset12> of armcmd_l1.vhd LDSSTAM
182
constant ADE_LDSTAM_OFF_D : integer := 0;
183
 
184
constant ADE_LSV4AM_OFF8_HU : integer := 11;  -- <offset8> of armcmd_l4.vhd LSV4AM
185
constant ADE_LSV4AM_OFF8_HD : integer := 8;
186
constant ADE_LSV4AM_OFF8_LU : integer := 3;
187
constant ADE_LSV4AM_OFF8_LD : integer := 0;
188
 
189
constant ADE_LDSTAM_UBYTE  : integer := 22;  -- '1': unsigned byte, '0': word
190
constant ADE_LSV4AM_SIGNED  : integer := 6;  -- '1': unsigned byte, '0': word
191
constant ADE_LSV4AM_HALF    : integer := 5;  -- '1': unsigned byte, '0': word
192
constant ADE_LDSTAMxLSV4AM_ADD    : integer := 23;  -- '1': add, '0': sub
193
 
194
constant ADE_PAB_U : integer := 24;     -- '0': after / '1': before
195
constant ADE_UID_U : integer := 23;     -- '1':increment / '0':decrement
196
 
197
constant ADE_REGLIST_U  : integer := 15;
198
constant ADE_REGLIST_D  : integer := 0;
199
 
200
-------------------------------------------------------------------------------
201
-- coprocessor
202
 
203
constant ADE_MRC_MCR_C : integer := 20;  -- '1':MRC '0':MCR
204
constant ADE_LDC_STC_WB_C : integer := 21;  -- '1': writeback '0': nowriteback (ADE_LDSTAMxLSV4AM_WB)
205
constant ADE_LDC_STC_P_C : integer := 24;  -- '1': Post; '0': Pre (negate ADE_LDSTAMxLSV4AM_POS)
206
 
207
-------------------------------------------------------------------------------
208
-- registers
209
 
210
constant ADE_RN_U : integer := 19;
211
constant ADE_RN_D : integer := 16;
212
constant ADE_RD_U : integer := 15;
213
constant ADE_RD_D : integer := 12;
214
constant ADE_RM_U : integer := 3;
215
constant ADE_RM_D : integer := 0;
216
constant ADE_SREG_U : integer := 11;  -- shieft register
217
constant ADE_SREG_D : integer := 8;
218
 
219
-------------------------------------------------------------------------------
220
 
221
-- festg out insn
222
type ade_feinsn is record
223
  insn    : std_logic_vector(31 downto 0);
224
  pc      : std_logic_vector(31 downto 0);
225
  pc_vir  : std_logic_vector(31 downto 0);
226
  valid   : std_logic;
227
  trap    : std_logic;
228
end record;
229
 
230
-- Decoded insn
231
type ade_insn is record
232
  pc_8    : std_logic_vector(31 downto 0);
233
  insn    : std_logic_vector(31 downto 0);
234
  insntyp : ade_insntyp;
235
  decinsn : ade_decinsn;
236
  am      : ade_amode;
237
  valid   : std_logic;
238
  id      : std_logic_vector(2 downto 0);
239
end record;
240
 
241
-- destg out insn
242
type ade_deinsn is record
243
  insn   : ade_insn;
244
  trap   : std_logic;
245
end record;
246
 
247
-------------------------------------------------------------------------------
248
 
249
end armdecode;
250
 
251
package body armdecode is
252
 
253
-- Addressing mode decode constants
254
-- DAPRAM: am.DAPRAM_typ 
255
constant ADE_DAPRAM_TYP   : integer := 25; -- '1': imm rot, '0': sreg/simm (shiefted)
256
constant ADE_DAPRAM_TYP_P : integer := 4;  -- shiefted: ('0': imm , '1': reg)
257
-- LDSTAM: am.LDSTAM_typ
258
constant ADE_LDSTAM_TYP   : integer := 25; -- '0': adm_LDSTAM_imm, '1': adm_LDSTAM_reg (shiefted)
259
-- LSV4AM: am.LSV4AM_typ
260
constant ADE_LSV4AM_TYP   : integer := 22; -- '1': adm_LSV4AM_imm , '0': adm_LSV4AM_reg
261
-- DAPRAM, LDSTAM: am.DAPRAMxLDSTAM_sdir
262
constant ADE_DAPRAMxLDSTAM_SDIR_U     : integer := 6;  -- shieft type 
263
constant ADE_DAPRAMxLDSTAM_SDIR_D     : integer := 5;
264
constant ADE_DAPRAMxLDSTAM_SDIRNONE_U : integer := 11; -- no shieft
265
constant ADE_DAPRAMxLDSTAM_SDIRNONE_D : integer := 4;
266
constant ADE_DAPRAMxLDSTAM_SDIRROR_U  : integer := 11; -- ror 
267
constant ADE_DAPRAMxLDSTAM_SDIRROR_D  : integer := 7;
268
-- LDSTAM, LSV4AM: am.LDSTAMxLSV4AM_pos
269
-- LDSTAM, LSV4AM: am.LDSTAMxLSV4AM_wb
270
-- LDSTAM, LSV4AM: am.LDSTAMxLSV4AM_uacc
271
constant ADE_LDSTAMxLSV4AM_POS : integer := 24; -- '0': postindexed, '1': preindexed
272
constant ADE_LDSTAMxLSV4AM_WB  : integer := 21; -- postindexed: 0 = normal, 1 = usermode
273
 
274
procedure ade_decode_amode (
275
  insn : in std_logic_vector(31 downto 0);
276
  am   : out ade_amode
277
) is
278
  variable tmp : std_logic_vector(4 downto 0);
279
begin
280
 
281
  -- DAPRAM: typ
282
  am.DAPRAM_typ := ade_DAPRAM_simm;
283
  if insn(ADE_DAPRAM_TYP_P) = '1' then
284
    am.DAPRAM_typ := ade_DAPRAM_sreg;
285
  end if;
286
 
287
  -- DPAM and LSAM: shieft direction
288
  am.DAPRAMxLDSTAM_sdir := ash_sdir_srrx;
289
  case insn(ADE_DAPRAMxLDSTAM_SDIR_U downto ADE_DAPRAMxLDSTAM_SDIR_D) is
290
    when "00" =>
291
      am.DAPRAMxLDSTAM_sdir := ash_sdir_slsl;
292
      if insn(ADE_DAPRAMxLDSTAM_SDIRNONE_U downto ADE_DAPRAMxLDSTAM_SDIRNONE_D) = "00000000" then
293
        am.DAPRAMxLDSTAM_sdir := ash_sdir_snone;
294
      end if;
295
    when "01" => am.DAPRAMxLDSTAM_sdir := ash_sdir_slsr;
296
    when "10" => am.DAPRAMxLDSTAM_sdir := ash_sdir_sasr;
297
    when "11" =>
298
      if not (insn(ADE_DAPRAMxLDSTAM_SDIRROR_U downto ADE_DAPRAMxLDSTAM_SDIRROR_D) = "00000") then
299
        am.DAPRAMxLDSTAM_sdir := ash_sdir_sror;
300
      end if;
301
    when others => null;
302
  end case;
303
 
304
  -- DAPRAM: typ
305
  if insn(ADE_DAPRAM_TYP) = '1' then
306
    am.DAPRAM_typ := ade_DAPRAM_immrot;
307
  end if;
308
 
309
  -- LDSTAM: typ
310
  am.LDSTAM_typ := ade_LDSTAMxLSV4AM_imm;
311
  if insn(ADE_LDSTAM_TYP) = '1' then
312
    am.LDSTAM_typ := ade_LDSTAMxLSV4AM_reg;
313
    -- am.DAPRAMxLDSTAM_sdir := ade_snone;
314
  end if;
315
 
316
  -- LDSTAM and LSV4AM: preindexed / postindexed
317
  am.LDSTAMxLSV4AM_uacc := '0';
318
  am.LDSTAMxLSV4AM_wb := '1';
319
  if insn(ADE_LDSTAMxLSV4AM_POS) = '1' then
320
    am.LDSTAMxLSV4AM_pos := ade_pre;
321
    if insn(ADE_LDSTAMxLSV4AM_WB) = '0' then
322
      am.LDSTAMxLSV4AM_wb := '0';
323
    end if;
324
  else
325
    am.LDSTAMxLSV4AM_pos := ade_post;
326
    if insn(ADE_LDSTAMxLSV4AM_WB) = '1' then
327
      am.LDSTAMxLSV4AM_uacc := '1';
328
    end if;
329
  end if;
330
 
331
  -- LSV4AM: offset, register (not shiefted)
332
  am.LSV4AM_typ := ade_LDSTAMxLSV4AM_imm;
333
  if insn(ADE_LSV4AM_TYP) = '0' then
334
    am.LSV4AM_typ := ade_LDSTAMxLSV4AM_reg;
335
  end if;
336
 
337
end;
338
 
339
 
340
-- todo: remember fixing recursion bug in decgen
341
function ade_decode_v4(
342
  insn_in : in std_logic_vector(31 downto 0)
343
) return ade_decinsn is
344
  variable arm_nop       : std_logic;
345
  variable arm_mrs       : std_logic;
346
  variable arm_bx        : std_logic;
347
  variable arm_mul       : std_logic;
348
  variable arm_mla       : std_logic;
349
  variable arm_swp       : std_logic;
350
  variable arm_sumull    : std_logic;
351
  variable arm_sumlal    : std_logic;
352
  variable arm_strhb     : std_logic;
353
  variable arm_ldrhb     : std_logic;
354
  variable arm_and       : std_logic;
355
  variable arm_sub       : std_logic;
356
  variable arm_eor       : std_logic;
357
  variable arm_rsb       : std_logic;
358
  variable arm_add       : std_logic;
359
  variable arm_sbc       : std_logic;
360
  variable arm_adc       : std_logic;
361
  variable arm_rsc       : std_logic;
362
  variable arm_msr       : std_logic;
363
  variable arm_teq       : std_logic;
364
  variable arm_cmn       : std_logic;
365
  variable arm_tst       : std_logic;
366
  variable arm_cmp       : std_logic;
367
  variable arm_orr       : std_logic;
368
  variable arm_bic       : std_logic;
369
  variable arm_mov       : std_logic;
370
  variable arm_mvn       : std_logic;
371
  variable arm_str1      : std_logic;
372
  variable arm_str2      : std_logic;
373
  variable arm_str3      : std_logic;
374
  variable arm_ldr1      : std_logic;
375
  variable arm_undefined         : std_logic;
376
  variable arm_stm       : std_logic;
377
  variable arm_ldm       : std_logic;
378
  variable arm_b         : std_logic;
379
  variable arm_swi       : std_logic;
380
  variable arm_cdp       : std_logic;
381
  variable arm_mrc       : std_logic;
382
  variable arm_mcr       : std_logic;
383
  variable arm_stc       : std_logic;
384
  variable arm_ldc       : std_logic;
385
  variable vec_1        : std_logic_vector(1 downto 0);
386
  variable vec_2        : std_logic_vector(2 downto 0);
387
  variable vec_3        : std_logic_vector(4 downto 0);
388
  variable vec_4        : std_logic_vector(21 downto 0);
389
  variable vec_5        : std_logic_vector(12 downto 0);
390
  variable vec_6        : std_logic_vector(18 downto 0);
391
  variable vec_7        : std_logic_vector(4 downto 0);
392
  variable vec_8        : std_logic_vector(0 downto 0);
393
  variable vec_9        : std_logic_vector(0 downto 0);
394
  variable vec_10       : std_logic_vector(4 downto 0);
395
  variable vec_11       : std_logic_vector(0 downto 0);
396
  variable vec_12       : std_logic_vector(2 downto 0);
397
  variable vec_13       : std_logic_vector(0 downto 0);
398
  variable vec_14       : std_logic_vector(0 downto 0);
399
  variable vec_15       : std_logic_vector(0 downto 0);
400
  variable vec_16       : std_logic_vector(0 downto 0);
401
  variable vec_17       : std_logic_vector(6 downto 0);
402
  variable vec_18       : std_logic_vector(0 downto 0);
403
  variable vec_19       : std_logic_vector(0 downto 0);
404
  variable vec_20       : std_logic_vector(0 downto 0);
405
  variable vec_21       : std_logic_vector(0 downto 0);
406
  variable vec_22       : std_logic_vector(0 downto 0);
407
  variable vec_23       : std_logic_vector(0 downto 0);
408
  variable vec_24       : std_logic_vector(7 downto 0);
409
  variable vec_25       : std_logic_vector(0 downto 0);
410
  variable vec_26       : std_logic_vector(1 downto 0);
411
  variable vec_27       : std_logic_vector(0 downto 0);
412
  variable vec_28       : std_logic_vector(0 downto 0);
413
  variable vec_29       : std_logic_vector(0 downto 0);
414
  variable vec_30       : std_logic_vector(0 downto 0);
415
  variable vec_31       : std_logic_vector(0 downto 0);
416
  variable vec_32       : std_logic_vector(0 downto 0);
417
  variable vec_33       : std_logic_vector(0 downto 0);
418
  variable insn_return : ade_decinsn;
419
  variable insn : std_logic_vector(31 downto 0);
420
begin
421
  insn := insn_in;
422
  -- decoder assumes littleendian: word[3 2 1 0]
423
  insn := insn_in;
424
  if CFG_BO_PROC = lmd_big then
425
    insn := insn(7 downto 0) & insn(15 downto 8) & insn(23 downto 16) & insn(31 downto 24);
426
  end if;
427
  insn_return := type_arm_invalid;
428
  vec_1  := insn(3 downto 2);
429
  vec_2  := insn(31 downto 31)&insn(28 downto 28)&insn(1 downto 1);
430
  vec_3  := insn(30 downto 29)&insn(15 downto 15)&insn(13 downto 13)&insn(0 downto 0);
431
  vec_4  := insn(27 downto 16)&insn(14 downto 14)&insn(12 downto 4);
432
  arm_nop        := '0';
433
  vec_5  := insn(27 downto 24)&insn(19 downto 16)&insn(12 downto 8);
434
  arm_mrs        := '0';
435
  vec_6  := insn(30 downto 29)&insn(23 downto 8)&insn(0 downto 0);
436
  arm_bx         := '0';
437
  vec_7  := insn(30 downto 29)&insn(15 downto 15)&insn(13 downto 13)&insn(0 downto 0);
438
  vec_8  := insn(14 downto 14);
439
  arm_mul        := '0';
440
  vec_9  := insn(14 downto 14);
441
  arm_mla        := '0';
442
  vec_10         := insn(19 downto 16)&insn(12 downto 12);
443
  arm_swp        := '0';
444
  arm_sumull     := '0';
445
  arm_sumlal     := '0';
446
  vec_11         := insn(12 downto 12);
447
  arm_strhb      := '0';
448
  arm_ldrhb      := '0';
449
  vec_12         := insn(15 downto 15)&insn(13 downto 13)&insn(0 downto 0);
450
  vec_13         := insn(14 downto 14);
451
  arm_and        := '0';
452
  arm_sub        := '0';
453
  vec_14         := insn(14 downto 14);
454
  arm_eor        := '0';
455
  arm_rsb        := '0';
456
  vec_15         := insn(14 downto 14);
457
  arm_add        := '0';
458
  arm_sbc        := '0';
459
  vec_16         := insn(14 downto 14);
460
  arm_adc        := '0';
461
  arm_rsc        := '0';
462
  vec_17         := insn(23 downto 20)&insn(12 downto 12)&insn(10 downto 9);
463
  arm_msr        := '0';
464
  vec_18         := insn(14 downto 14);
465
  arm_teq        := '0';
466
  arm_cmn        := '0';
467
  vec_19         := insn(14 downto 14);
468
  arm_tst        := '0';
469
  arm_cmp        := '0';
470
  vec_20         := insn(14 downto 14);
471
  arm_orr        := '0';
472
  arm_bic        := '0';
473
  vec_21         := insn(14 downto 14);
474
  arm_mov        := '0';
475
  arm_mvn        := '0';
476
  vec_22         := insn(12 downto 12);
477
  vec_23         := insn(1 downto 1);
478
  arm_str1       := '0';
479
  vec_24         := insn(31 downto 28)&insn(19 downto 16);
480
  arm_str2       := '0';
481
  vec_25         := insn(28 downto 28);
482
  arm_str3       := '0';
483
  arm_ldr1       := '0';
484
  vec_26         := insn(28 downto 28)&insn(1 downto 1);
485
  arm_undefined  := '0';
486
  vec_27         := insn(1 downto 1);
487
  vec_28         := insn(12 downto 12);
488
  arm_stm        := '0';
489
  arm_ldm        := '0';
490
  arm_b  := '0';
491
  vec_29         := insn(1 downto 1);
492
  vec_30         := insn(0 downto 0);
493
  arm_swi        := '0';
494
  vec_31         := insn(28 downto 28);
495
  arm_cdp        := '0';
496
  vec_32         := insn(12 downto 12);
497
  arm_mrc        := '0';
498
  arm_mcr        := '0';
499
  vec_33         := insn(12 downto 12);
500
  arm_stc        := '0';
501
  arm_ldc        := '0';
502
case vec_1 is
503
  when "00" =>
504
    case vec_2 is
505
      when "000" =>
506
        case vec_3 is
507
          when "00111" =>
508
            case vec_4 is
509
              when "0000000000000000001110" =>
510
                arm_nop := '1';
511
                if arm_nop = '1' then
512
                insn_return := type_arm_nop;
513
                end if;
514
              when others => null;
515
            end case;
516
          when "00001" =>
517
            case vec_5 is
518
              when "0000000001111" =>
519
                arm_mrs := '1';
520
                if arm_mrs = '1' then
521
                insn_return := type_arm_mrs;
522
                end if;
523
              when others => null;
524
            end case;
525
          when others => null;
526
        end case;
527
      when "010" =>
528
        case vec_6 is
529
          when "0011111111001011111" =>
530
            arm_bx := '1';
531
            if arm_bx = '1' then
532
            insn_return := type_arm_bx;
533
            end if;
534
          when others => null;
535
        end case;
536
      when "110" =>
537
        case vec_7 is
538
          when "00000" =>
539
            case vec_8 is
540
              when "0" =>
541
                arm_mul := '1';
542
                if arm_mul = '1' then
543
                insn_return := type_arm_mul;
544
                end if;
545
              when others => null;
546
            end case;
547
          when "00010" =>
548
            case vec_9 is
549
              when "0" =>
550
                arm_mla := '1';
551
                if arm_mla = '1' then
552
                insn_return := type_arm_mla;
553
                end if;
554
              when others => null;
555
            end case;
556
          when "00001" =>
557
            case vec_10 is
558
              when "00000" =>
559
                arm_swp := '1';
560
                if arm_swp = '1' then
561
                insn_return := type_arm_swp;
562
                end if;
563
              when others => null;
564
            end case;
565
          when "00100" =>
566
            arm_sumull := '1';
567
            if arm_sumull = '1' then
568
            insn_return := type_arm_sumull;
569
            end if;
570
          when "00110" =>
571
            arm_sumlal := '1';
572
            if arm_sumlal = '1' then
573
            insn_return := type_arm_sumlal;
574
            end if;
575
          when others => null;
576
        end case;
577
        case vec_11 is
578
          when "0" =>
579
            arm_strhb := '1' and not (arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal);
580
            if arm_strhb = '1' then
581
            insn_return := type_arm_strhb;
582
            end if;
583
          when "1" =>
584
            arm_ldrhb := '1' and not (arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal);
585
            if arm_ldrhb = '1' then
586
            insn_return := type_arm_ldrhb;
587
            end if;
588
          when others => null;
589
        end case;
590
      when others => null;
591
    end case;
592
    case vec_12 is
593
      when "000" =>
594
        case vec_13 is
595
          when "0" =>
596
            arm_and := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
597
            if arm_and = '1' then
598
            insn_return := type_arm_and;
599
            end if;
600
          when "1" =>
601
            arm_sub := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
602
            if arm_sub = '1' then
603
            insn_return := type_arm_sub;
604
            end if;
605
          when others => null;
606
        end case;
607
      when "010" =>
608
        case vec_14 is
609
          when "0" =>
610
            arm_eor := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
611
            if arm_eor = '1' then
612
            insn_return := type_arm_eor;
613
            end if;
614
          when "1" =>
615
            arm_rsb := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
616
            if arm_rsb = '1' then
617
            insn_return := type_arm_rsb;
618
            end if;
619
          when others => null;
620
        end case;
621
      when "100" =>
622
        case vec_15 is
623
          when "0" =>
624
            arm_add := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
625
            if arm_add = '1' then
626
            insn_return := type_arm_add;
627
            end if;
628
          when "1" =>
629
            arm_sbc := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
630
            if arm_sbc = '1' then
631
            insn_return := type_arm_sbc;
632
            end if;
633
          when others => null;
634
        end case;
635
      when "110" =>
636
        case vec_16 is
637
          when "0" =>
638
            arm_adc := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
639
            if arm_adc = '1' then
640
            insn_return := type_arm_adc;
641
            end if;
642
          when "1" =>
643
            arm_rsc := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
644
            if arm_rsc = '1' then
645
            insn_return := type_arm_rsc;
646
            end if;
647
          when others => null;
648
        end case;
649
      when "011" =>
650
        case vec_17 is
651
          when "1111000" =>
652
            arm_msr := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
653
            if arm_msr = '1' then
654
            insn_return := type_arm_msr;
655
            end if;
656
          when others => null;
657
        end case;
658
        case vec_18 is
659
          when "0" =>
660
            arm_teq := '1' and not (arm_msr or arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
661
            if arm_teq = '1' then
662
            insn_return := type_arm_teq;
663
            end if;
664
          when "1" =>
665
            arm_cmn := '1' and not (arm_msr or arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
666
            if arm_cmn = '1' then
667
            insn_return := type_arm_cmn;
668
            end if;
669
          when others => null;
670
        end case;
671
      when "001" =>
672
        case vec_19 is
673
          when "0" =>
674
            arm_tst := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
675
            if arm_tst = '1' then
676
            insn_return := type_arm_tst;
677
            end if;
678
          when "1" =>
679
            arm_cmp := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
680
            if arm_cmp = '1' then
681
            insn_return := type_arm_cmp;
682
            end if;
683
          when others => null;
684
        end case;
685
      when "101" =>
686
        case vec_20 is
687
          when "0" =>
688
            arm_orr := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
689
            if arm_orr = '1' then
690
            insn_return := type_arm_orr;
691
            end if;
692
          when "1" =>
693
            arm_bic := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
694
            if arm_bic = '1' then
695
            insn_return := type_arm_bic;
696
            end if;
697
          when others => null;
698
        end case;
699
      when "111" =>
700
        case vec_21 is
701
          when "0" =>
702
            arm_mov := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
703
            if arm_mov = '1' then
704
            insn_return := type_arm_mov;
705
            end if;
706
          when "1" =>
707
            arm_mvn := '1' and not (arm_nop or arm_mrs or arm_bx or arm_mul or arm_mla or arm_swp or arm_sumull or arm_sumlal or arm_strhb or arm_ldrhb);
708
            if arm_mvn = '1' then
709
            insn_return := type_arm_mvn;
710
            end if;
711
          when others => null;
712
        end case;
713
      when others => null;
714
    end case;
715
  when "01" =>
716
    case vec_22 is
717
      when "0" =>
718
        case vec_23 is
719
          when "0" =>
720
            arm_str1 := '1';
721
            if arm_str1 = '1' then
722
            insn_return := type_arm_str1;
723
            end if;
724
          when "1" =>
725
            case vec_24 is
726
              when "00000000" =>
727
                arm_str2 := '1';
728
                if arm_str2 = '1' then
729
                insn_return := type_arm_str2;
730
                end if;
731
              when others => null;
732
            end case;
733
          when others => null;
734
        end case;
735
        case vec_25 is
736
          when "0" =>
737
            arm_str3 := '1' and not (arm_str1 or arm_str2);
738
            if arm_str3 = '1' then
739
            insn_return := type_arm_str3;
740
            end if;
741
          when others => null;
742
        end case;
743
      when "1" =>
744
        arm_ldr1 := '1';
745
        if arm_ldr1 = '1' then
746
        insn_return := type_arm_ldr1;
747
        end if;
748
      when others => null;
749
    end case;
750
    case vec_26 is
751
      when "11" =>
752
        arm_undefined := '1' and not (arm_str1 or arm_str2 or arm_str3 or arm_ldr1);
753
        if arm_undefined = '1' then
754
        insn_return := type_arm_undefined;
755
        end if;
756
      when others => null;
757
    end case;
758
  when "10" =>
759
    case vec_27 is
760
      when "0" =>
761
        case vec_28 is
762
          when "0" =>
763
            arm_stm := '1';
764
            if arm_stm = '1' then
765
            insn_return := type_arm_stm;
766
            end if;
767
          when "1" =>
768
            arm_ldm := '1';
769
            if arm_ldm = '1' then
770
            insn_return := type_arm_ldm;
771
            end if;
772
          when others => null;
773
        end case;
774
      when "1" =>
775
        arm_b := '1';
776
        if arm_b = '1' then
777
        insn_return := type_arm_b;
778
        end if;
779
      when others => null;
780
    end case;
781
  when "11" =>
782
    case vec_29 is
783
      when "1" =>
784
        case vec_30 is
785
          when "1" =>
786
            arm_swi := '1';
787
            if arm_swi = '1' then
788
            insn_return := type_arm_swi;
789
            end if;
790
          when "0" =>
791
            case vec_31 is
792
              when "0" =>
793
                arm_cdp := '1';
794
                if arm_cdp = '1' then
795
                insn_return := type_arm_cdp;
796
                end if;
797
              when "1" =>
798
                case vec_32 is
799
                  when "1" =>
800
                    arm_mrc := '1';
801
                    if arm_mrc = '1' then
802
                    insn_return := type_arm_mrc;
803
                    end if;
804
                  when "0" =>
805
                    arm_mcr := '1';
806
                    if arm_mcr = '1' then
807
                    insn_return := type_arm_mcr;
808
                    end if;
809
                  when others => null;
810
                end case;
811
              when others => null;
812
            end case;
813
          when others => null;
814
        end case;
815
      when "0" =>
816
        case vec_33 is
817
          when "0" =>
818
            arm_stc := '1';
819
            if arm_stc = '1' then
820
            insn_return := type_arm_stc;
821
            end if;
822
          when "1" =>
823
            arm_ldc := '1';
824
            if arm_ldc = '1' then
825
            insn_return := type_arm_ldc;
826
            end if;
827
          when others => null;
828
        end case;
829
      when others => null;
830
    end case;
831
  when others => null;
832
end case;
833
return insn_return;
834
end;
835
 
836
end armdecode;

powered by: WebSVN 2.1.0

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