2 use ieee.std_logic_1164.all;
4 package decode_types is
5 type insn_type_t is (OP_ILLEGAL, OP_NOP, OP_ADD,
6 OP_ATTN, OP_B, OP_BC, OP_BCREG,
7 OP_BCD, OP_BPERM, OP_BREV,
8 OP_CMP, OP_CMPB, OP_CMPEQB, OP_CMPRB,
10 OP_DARN, OP_DCBF, OP_DCBST, OP_DCBT, OP_DCBTST,
11 OP_DCBZ, OP_ICBI, OP_ICBT,
12 OP_FP_CMP, OP_FP_ARITH, OP_FP_MOVE, OP_FP_MISC,
13 OP_DIV, OP_DIVE, OP_MOD,
18 OP_MCRXRX, OP_MFCR, OP_MFMSR, OP_MFSPR,
19 OP_MTCRF, OP_MTMSRD, OP_MTSPR, OP_MUL_L64,
20 OP_MUL_H64, OP_MUL_H32,
21 OP_POPCNT, OP_PRTY, OP_RFID,
22 OP_RLC, OP_RLCL, OP_RLCR, OP_SC, OP_SETB,
24 OP_SYNC, OP_TLBIE, OP_TRAP,
30 -- The following list is ordered in such a way that we can know some
31 -- things about which registers are accessed by an instruction by its place
32 -- in the list. In other words we can decide whether an instruction
33 -- accesses FPRs and whether it has an RB operand by doing simple
34 -- comparisons of the insn_code for the instruction with a few constants.
36 -- The following instructions don't have an RB operand or access FPRs
134 -- Non-prefixed instructions that have a MLS:D prefixed form and
135 -- their corresponding prefixed instructions.
136 -- The non-prefixed versions have even indexes so that we can
137 -- convert them to the prefixed version by setting bit 0
155 -- Slots for non-prefixed opcodes that are 8LS:D when prefixed
163 -- pad to 128 to simplify comparison logic
165 INSN_078, INSN_079, INSN_07a, INSN_07b, INSN_07c, INSN_07d, INSN_07e, INSN_07f,
167 -- The following instructions have an RB operand but don't access FPRs
272 -- pad to 232 to simplify comparison logic
275 -- The following instructions have a third input addressed by RC
280 -- pad to 256 to simplify comparison logic
282 INSN_236, INSN_237, INSN_238, INSN_239,
283 INSN_240, INSN_241, INSN_242, INSN_243,
284 INSN_244, INSN_245, INSN_246, INSN_247,
285 INSN_248, INSN_249, INSN_250, INSN_251,
286 INSN_252, INSN_253, INSN_254, INSN_255,
288 -- The following instructions access floating-point registers
289 -- They have an FRS operand, but RA/RB are GPRs
291 -- Non-prefixed floating-point loads and stores that have a MLS:D
292 -- prefixed form, and their corresponding prefixed instructions.
302 -- opcodes that can't have a prefix
310 -- These ones don't actually have an FRS operand (rather an FRT destination)
311 -- but are here so that all FP instructions are >= INST_first_frs.
320 -- These are here in order to keep the FP instructions together
331 -- The following instructions access FRA and/or FRB operands
376 INSN_330, INSN_331, INSN_332, INSN_333, INSN_334, INSN_335,
378 -- The following instructions access FRA, FRB (possibly) and FRC operands
392 constant INSN_first_rb : insn_code := INSN_add;
393 constant INSN_first_rc : insn_code := INSN_maddld;
394 constant INSN_first_frs : insn_code := INSN_stfd;
395 constant INSN_first_frab : insn_code := INSN_fabs;
396 constant INSN_first_frabc : insn_code := INSN_fmul;
397 constant INSN_first_mls : insn_code := INSN_addi;
398 constant INSN_first_8ls : insn_code := INSN_lhzu;
399 constant INSN_first_fp_mls : insn_code := INSN_stfd;
400 constant INSN_first_fp_nonmls : insn_code := INSN_stfdu;
402 type input_reg_a_t is (NONE, RA, RA_OR_ZERO, RA0_OR_CIA, CIA, FRA);
403 type input_reg_b_t is (NONE, RB, CONST_UI, CONST_SI, CONST_SI_HI, CONST_UI_HI, CONST_LI, CONST_BD,
404 CONST_DXHI4, CONST_DS, CONST_DQ, CONST_M1, CONST_SH, CONST_SH32, CONST_PSI, FRB);
405 type input_reg_c_t is (NONE, RS, RCR, FRC, FRS);
406 type output_reg_a_t is (NONE, RT, RA, FRT);
407 type rc_t is (NONE, ONE, RC, RCOE);
408 type carry_in_t is (ZERO, CA, OV, ONE);
410 constant SH_OFFSET : integer := 0;
411 constant MB_OFFSET : integer := 1;
412 constant ME_OFFSET : integer := 1;
413 constant SH32_OFFSET : integer := 0;
414 constant MB32_OFFSET : integer := 1;
415 constant ME32_OFFSET : integer := 2;
417 constant FXM_OFFSET : integer := 0;
419 constant BO_OFFSET : integer := 0;
420 constant BI_OFFSET : integer := 1;
421 constant BH_OFFSET : integer := 2;
423 constant BF_OFFSET : integer := 0;
424 constant L_OFFSET : integer := 1;
426 constant TOO_OFFSET : integer := 0;
428 type unit_t is (ALU, LDST, FPU);
429 type facility_t is (NONE, FPU);
430 type length_t is (NONE, is1B, is2B, is4B, is8B);
432 type repeat_t is (NONE, -- instruction is not repeated
433 DUPD); -- update-form load
435 type decode_rom_t is record
437 facility : facility_t;
438 insn_type : insn_type_t;
439 input_reg_a : input_reg_a_t;
440 input_reg_b : input_reg_b_t;
441 input_reg_c : input_reg_c_t;
442 output_reg_a : output_reg_a_t;
444 input_cr : std_ulogic;
445 output_cr : std_ulogic;
447 invert_a : std_ulogic;
448 invert_out : std_ulogic;
449 input_carry : carry_in_t;
450 output_carry : std_ulogic;
452 -- load/store signals
454 byte_reverse : std_ulogic;
455 sign_extend : std_ulogic;
457 reserve : std_ulogic;
459 -- multiplier and ALU signals
460 is_32bit : std_ulogic;
461 is_signed : std_ulogic;
466 sgl_pipe : std_ulogic;
469 constant decode_rom_init : decode_rom_t := (unit => ALU, facility => NONE,
470 insn_type => OP_ILLEGAL, input_reg_a => NONE,
471 input_reg_b => NONE, input_reg_c => NONE,
472 output_reg_a => NONE, input_cr => '0', output_cr => '0',
473 invert_a => '0', invert_out => '0', input_carry => ZERO, output_carry => '0',
474 length => NONE, byte_reverse => '0', sign_extend => '0',
475 update => '0', reserve => '0', is_32bit => '0',
476 is_signed => '0', rc => NONE, lr => '0', sgl_pipe => '0', repeat => NONE);
480 package body decode_types is