|
|
|
@ -34,6 +34,8 @@ architecture behaviour of decode1 is
|
|
|
|
|
subtype major_opcode_t is unsigned(5 downto 0);
|
|
|
|
|
type major_rom_array_t is array(0 to 63) of decode_rom_t;
|
|
|
|
|
type minor_valid_array_t is array(0 to 1023) of std_ulogic;
|
|
|
|
|
type minor_valid_array_2t is array(0 to 2047) of std_ulogic;
|
|
|
|
|
type op_4_subop_array_t is array(0 to 63) of decode_rom_t;
|
|
|
|
|
type op_19_subop_array_t is array(0 to 7) of decode_rom_t;
|
|
|
|
|
type op_30_subop_array_t is array(0 to 15) of decode_rom_t;
|
|
|
|
|
type op_31_subop_array_t is array(0 to 1023) of decode_rom_t;
|
|
|
|
@ -85,6 +87,24 @@ architecture behaviour of decode1 is
|
|
|
|
|
others => illegal_inst
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-- indexed by bits 5..0 and 10..6 of instruction word
|
|
|
|
|
constant decode_op_4_valid : minor_valid_array_2t := (
|
|
|
|
|
2#11000000000# to 2#11000011111# => '1', -- maddhd
|
|
|
|
|
2#11000100000# to 2#11000111111# => '1', -- maddhdu
|
|
|
|
|
2#11001100000# to 2#11001111111# => '1', -- maddld
|
|
|
|
|
others => '0'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-- indexed by bits 5..0 of instruction word
|
|
|
|
|
constant decode_op_4_array : op_4_subop_array_t := (
|
|
|
|
|
-- unit internal in1 in2 in3 out CR CR inv inv cry cry ldst BR sgn upd rsrv 32b sgn rc lk sgl
|
|
|
|
|
-- op in out A out in out len ext pipe
|
|
|
|
|
2#110000# => (ALU, OP_MUL_H64, RA, RB, RCR, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '1', RC, '0', '0'), -- maddhd
|
|
|
|
|
2#110001# => (ALU, OP_MUL_H64, RA, RB, RCR, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- maddhdu
|
|
|
|
|
2#110011# => (ALU, OP_MUL_L64, RA, RB, RCR, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '1', RC, '0', '0'), -- maddld
|
|
|
|
|
others => decode_rom_init
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-- indexed by bits 10..1 of instruction word
|
|
|
|
|
constant decode_op_19_valid : minor_valid_array_t := (
|
|
|
|
|
-- addpcis, 5 upper bits are part of constant
|
|
|
|
@ -94,7 +114,7 @@ architecture behaviour of decode1 is
|
|
|
|
|
2#1100000010# => '1', 2#1100100010# => '1', 2#1101000010# => '1', 2#1101100010# => '1', 2#1110000010# => '1', 2#1110100010# => '1', 2#1111000010# => '1', 2#1111100010# => '1',
|
|
|
|
|
2#1000010000# => '1', -- bcctr
|
|
|
|
|
2#0000010000# => '1', -- bclr
|
|
|
|
|
2#1000110000# => '0', -- bctar
|
|
|
|
|
2#1000110000# => '1', -- bctar
|
|
|
|
|
2#0100000001# => '1', -- crand
|
|
|
|
|
2#0010000001# => '1', -- crandc
|
|
|
|
|
2#0100100001# => '1', -- creqv
|
|
|
|
@ -152,23 +172,27 @@ architecture behaviour of decode1 is
|
|
|
|
|
2#1000001010# => (ALU, OP_ADD, RA, RB, NONE, RT, '0', '0', '0', '0', ZERO, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addco
|
|
|
|
|
2#0010001010# => (ALU, OP_ADD, RA, RB, NONE, RT, '0', '0', '0', '0', CA, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- adde
|
|
|
|
|
2#1010001010# => (ALU, OP_ADD, RA, RB, NONE, RT, '0', '0', '0', '0', CA, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addeo
|
|
|
|
|
2#0010101010# => (ALU, OP_ADD, RA, RB, NONE, RT, '0', '0', '0', '0', OV, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addex
|
|
|
|
|
2#0001001010# => (ALU, OP_ADDG6S, RA, RB, NONE, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- addg6s
|
|
|
|
|
2#0011101010# => (ALU, OP_ADD, RA, CONST_M1, NONE, RT, '0', '0', '0', '0', CA, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addme
|
|
|
|
|
2#1011101010# => (ALU, OP_ADD, RA, CONST_M1, NONE, RT, '0', '0', '0', '0', CA, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addmeo
|
|
|
|
|
2#0011001010# => (ALU, OP_ADD, RA, NONE, NONE, RT, '0', '0', '0', '0', CA, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addze
|
|
|
|
|
2#1011001010# => (ALU, OP_ADD, RA, NONE, NONE, RT, '0', '0', '0', '0', CA, '1', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- addzeo
|
|
|
|
|
2#0000011100# => (ALU, OP_AND, NONE, RB, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- and
|
|
|
|
|
2#0000111100# => (ALU, OP_AND, NONE, RB, RS, RA, '0', '0', '1', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- andc
|
|
|
|
|
-- 2#0011111100# bperm
|
|
|
|
|
2#0011111100# => (ALU, OP_BPERM, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- bperm
|
|
|
|
|
2#0100111010# => (ALU, OP_BCD, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- cbcdtd
|
|
|
|
|
2#0100011010# => (ALU, OP_BCD, NONE, NONE, RS, RA, '0', '0', '1', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- cdtbcd
|
|
|
|
|
2#0000000000# => (ALU, OP_CMP, RA, RB, NONE, NONE, '0', '1', '1', '0', ONE, '0', NONE, '0', '0', '0', '0', '0', '1', NONE, '0', '0'), -- cmp
|
|
|
|
|
2#0111111100# => (ALU, OP_CMPB, NONE, RB, RS, RA, '0', '1', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- cmpb
|
|
|
|
|
-- 2#0011100000# cmpeqb
|
|
|
|
|
2#0011100000# => (ALU, OP_CMPEQB, RA, RB, NONE, NONE, '0', '1', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- cmpeqb
|
|
|
|
|
2#0000100000# => (ALU, OP_CMP, RA, RB, NONE, NONE, '0', '1', '1', '0', ONE, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- cmpl
|
|
|
|
|
-- 2#0011000000# cmprb
|
|
|
|
|
2#0011000000# => (ALU, OP_CMPRB, RA, RB, NONE, NONE, '0', '1', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- cmprb
|
|
|
|
|
2#0000111010# => (ALU, OP_CNTZ, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- cntlzd
|
|
|
|
|
2#0000011010# => (ALU, OP_CNTZ, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '1', '0', RC, '0', '0'), -- cntlzw
|
|
|
|
|
2#1000111010# => (ALU, OP_CNTZ, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- cnttzd
|
|
|
|
|
2#1000011010# => (ALU, OP_CNTZ, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '1', '0', RC, '0', '0'), -- cnttzw
|
|
|
|
|
-- 2#1011110011# darn
|
|
|
|
|
2#1011110011# => (ALU, OP_DARN, NONE, NONE, NONE, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- darn
|
|
|
|
|
2#0001010110# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '1'), -- dcbf
|
|
|
|
|
2#0000110110# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '1'), -- dcbst
|
|
|
|
|
2#0100010110# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '1'), -- dcbt
|
|
|
|
@ -254,8 +278,7 @@ architecture behaviour of decode1 is
|
|
|
|
|
2#1100010101# => (LDST, OP_LOAD, RA_OR_ZERO, RB, NONE, RT, '0', '0', '0', '0', ZERO, '0', is4B, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- lwzcix
|
|
|
|
|
2#0000110111# => (LDST, OP_LOAD, RA_OR_ZERO, RB, NONE, RT, '0', '0', '0', '0', ZERO, '0', is4B, '0', '0', '1', '0', '0', '0', NONE, '0', '0'), -- lwzux
|
|
|
|
|
2#0000010111# => (LDST, OP_LOAD, RA_OR_ZERO, RB, NONE, RT, '0', '0', '0', '0', ZERO, '0', is4B, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- lwzx
|
|
|
|
|
-- 2#1000000000# mcrxr
|
|
|
|
|
-- 2#1001000000# mcrxrx
|
|
|
|
|
2#1001000000# => (ALU, OP_MCRXRX, NONE, NONE, NONE, NONE, '0', '1', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- mcrxrx
|
|
|
|
|
2#0000010011# => (ALU, OP_MFCR, NONE, NONE, NONE, RT, '1', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- mfcr/mfocrf
|
|
|
|
|
2#0001010011# => (ALU, OP_MFMSR, NONE, NONE, NONE, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '1'), -- mfmsr
|
|
|
|
|
2#0101010011# => (ALU, OP_MFSPR, SPR, NONE, RS, RT, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- mfspr
|
|
|
|
@ -282,6 +305,15 @@ architecture behaviour of decode1 is
|
|
|
|
|
2#0111011100# => (ALU, OP_AND, NONE, RB, RS, RA, '0', '0', '0', '1', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- nand
|
|
|
|
|
2#0001101000# => (ALU, OP_ADD, RA, NONE, NONE, RT, '0', '0', '1', '0', ONE, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- neg
|
|
|
|
|
2#1001101000# => (ALU, OP_ADD, RA, NONE, NONE, RT, '0', '0', '1', '0', ONE, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- nego
|
|
|
|
|
-- next 8 are reserved no-op instructions
|
|
|
|
|
2#1000010010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1000110010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1001010010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1001110010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1010010010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1010110010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1011010010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#1011110010# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- nop
|
|
|
|
|
2#0001111100# => (ALU, OP_OR, NONE, RB, RS, RA, '0', '0', '0', '1', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- nor
|
|
|
|
|
2#0110111100# => (ALU, OP_OR, NONE, RB, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- or
|
|
|
|
|
2#0110011100# => (ALU, OP_OR, NONE, RB, RS, RA, '0', '0', '1', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- orc
|
|
|
|
@ -290,7 +322,7 @@ architecture behaviour of decode1 is
|
|
|
|
|
2#0101111010# => (ALU, OP_POPCNT, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', is4B, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- popcntw
|
|
|
|
|
2#0010111010# => (ALU, OP_PRTY, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', is8B, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- prtyd
|
|
|
|
|
2#0010011010# => (ALU, OP_PRTY, NONE, NONE, RS, RA, '0', '0', '0', '0', ZERO, '0', is4B, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- prtyw
|
|
|
|
|
-- 2#0010000000# setb
|
|
|
|
|
2#0010000000# => (ALU, OP_SETB, NONE, NONE, NONE, RT, '1', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- setb
|
|
|
|
|
2#0111110010# => (LDST, OP_TLBIE, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- slbia
|
|
|
|
|
2#0000011011# => (ALU, OP_SHL, NONE, RB, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- sld
|
|
|
|
|
2#0000011000# => (ALU, OP_SHL, NONE, RB, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '1', '0', RC, '0', '0'), -- slw
|
|
|
|
@ -335,6 +367,7 @@ architecture behaviour of decode1 is
|
|
|
|
|
2#0000000100# => (ALU, OP_TRAP, RA, RB, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '1', '0', NONE, '0', '1'), -- tw
|
|
|
|
|
2#0100110010# => (LDST, OP_TLBIE, NONE, RB, RS, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- tlbie
|
|
|
|
|
2#0100010010# => (LDST, OP_TLBIE, NONE, RB, RS, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'), -- tlbiel
|
|
|
|
|
2#0000011110# => (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '1'), -- wait
|
|
|
|
|
2#0100111100# => (ALU, OP_XOR, NONE, RB, RS, RA, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', RC, '0', '0'), -- xor
|
|
|
|
|
others => illegal_inst
|
|
|
|
|
);
|
|
|
|
@ -391,6 +424,7 @@ begin
|
|
|
|
|
variable v : Decode1ToDecode2Type;
|
|
|
|
|
variable f : Decode1ToFetch1Type;
|
|
|
|
|
variable majorop : major_opcode_t;
|
|
|
|
|
variable minor4op : std_ulogic_vector(10 downto 0);
|
|
|
|
|
variable op_19_bits: std_ulogic_vector(2 downto 0);
|
|
|
|
|
variable sprn : spr_num_t;
|
|
|
|
|
variable br_nia : std_ulogic_vector(61 downto 0);
|
|
|
|
@ -419,6 +453,15 @@ begin
|
|
|
|
|
end if;
|
|
|
|
|
v.decode := fetch_fail_inst;
|
|
|
|
|
|
|
|
|
|
elsif majorop = "000100" then
|
|
|
|
|
-- major opcode 4, mostly VMX/VSX stuff but also some integer ops (madd*)
|
|
|
|
|
minor4op := f_in.insn(5 downto 0) & f_in.insn(10 downto 6);
|
|
|
|
|
if decode_op_4_valid(to_integer(unsigned(minor4op))) = '1' then
|
|
|
|
|
v.decode := decode_op_4_array(to_integer(unsigned(f_in.insn(5 downto 0))));
|
|
|
|
|
else
|
|
|
|
|
v.decode := illegal_inst;
|
|
|
|
|
end if;
|
|
|
|
|
|
|
|
|
|
elsif majorop = "011111" then
|
|
|
|
|
-- major opcode 31, lots of things
|
|
|
|
|
v.decode := decode_op_31_array(to_integer(unsigned(f_in.insn(10 downto 1))));
|
|
|
|
@ -467,11 +510,12 @@ begin
|
|
|
|
|
if f_in.insn(23) = '0' then
|
|
|
|
|
v.ispr1 := fast_spr_num(SPR_CTR);
|
|
|
|
|
end if;
|
|
|
|
|
-- TODO: Add TAR
|
|
|
|
|
if f_in.insn(10) = '0' then
|
|
|
|
|
v.ispr2 := fast_spr_num(SPR_LR);
|
|
|
|
|
else
|
|
|
|
|
elsif f_in.insn(6) = '0' then
|
|
|
|
|
v.ispr2 := fast_spr_num(SPR_CTR);
|
|
|
|
|
else
|
|
|
|
|
v.ispr2 := fast_spr_num(SPR_TAR);
|
|
|
|
|
end if;
|
|
|
|
|
else
|
|
|
|
|
-- Could be OP_RFID
|
|
|
|
|