2021-02-15 23:55:09 +01:00
|
|
|
package cpu_pkg;
|
|
|
|
|
2023-10-02 00:00:56 +02:00
|
|
|
typedef enum logic [2:0] {
|
|
|
|
REG8_B = 3'h00,
|
|
|
|
REG8_C = 3'h01,
|
|
|
|
REG8_D = 3'h02,
|
|
|
|
REG8_E = 3'h03,
|
|
|
|
REG8_H = 3'h04,
|
|
|
|
REG8_L = 3'h05,
|
|
|
|
REG8_PHL = 3'h06,
|
|
|
|
REG8_A = 3'h07
|
|
|
|
} reg8_t;
|
|
|
|
|
|
|
|
typedef enum logic [1:0] {
|
|
|
|
REG16_BC = 2'h00,
|
|
|
|
REG16_DE = 2'h01,
|
|
|
|
REG16_HL = 2'h02,
|
|
|
|
REG16_SP_AF = 2'h03
|
|
|
|
} reg16_t;
|
|
|
|
|
|
|
|
typedef enum logic [1:0] {
|
|
|
|
CC_NZ = 2'h00,
|
|
|
|
CC_Z = 2'h01,
|
|
|
|
CC_NC = 2'h02,
|
|
|
|
CC_C = 2'h03
|
|
|
|
} cc_t;
|
|
|
|
|
|
|
|
typedef enum logic [2:0] {
|
|
|
|
ALU_OP_ADD = 3'h00,
|
|
|
|
ALU_OP_ADC = 3'h01,
|
|
|
|
ALU_OP_SUB = 3'h02,
|
|
|
|
ALU_OP_SBC = 3'h03,
|
|
|
|
ALU_OP_AND = 3'h04,
|
|
|
|
ALU_OP_XOR = 3'h05,
|
|
|
|
ALU_OP_OR = 3'h06,
|
|
|
|
ALU_OP_CP = 3'h07
|
|
|
|
} alu_op_t;
|
|
|
|
|
|
|
|
typedef enum logic [2:0] {
|
|
|
|
SHIFT_OP_RLC = 3'h00,
|
|
|
|
SHIFT_OP_RRC = 3'h01,
|
|
|
|
SHIFT_OP_RL = 3'h02,
|
|
|
|
SHIFT_OP_RR = 3'h03,
|
|
|
|
SHIFT_OP_SLA = 3'h04,
|
|
|
|
SHIFT_OP_SRA = 3'h05,
|
|
|
|
SHIFT_OP_SLL = 3'h06,
|
|
|
|
SHIFT_OP_SRL = 3'h07
|
|
|
|
} shift_op_t;
|
|
|
|
|
|
|
|
typedef struct packed {
|
|
|
|
logic b;
|
|
|
|
logic s;
|
|
|
|
logic r;
|
|
|
|
logic [2:0] operand;
|
|
|
|
} bsr_op_t;
|
|
|
|
|
|
|
|
typedef struct packed {
|
|
|
|
logic inc;
|
|
|
|
logic dec;
|
|
|
|
logic dst_a;
|
|
|
|
} incdec_op_t;
|
|
|
|
|
|
|
|
typedef struct packed {
|
|
|
|
logic update_a;
|
|
|
|
logic update_f;
|
|
|
|
logic alu_op_valid;
|
|
|
|
alu_op_t alu_op;
|
|
|
|
logic shift_op_valid;
|
|
|
|
shift_op_t shift_op;
|
|
|
|
logic bsr_op_valid;
|
|
|
|
bsr_op_t bsr_op;
|
|
|
|
logic incdec_op_valid;
|
|
|
|
incdec_op_t incdec_op;
|
|
|
|
} alu_ctrl_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ADDR_SRC_PC,
|
|
|
|
ADDR_SRC_SP,
|
|
|
|
ADDR_SRC_REG16, // TODO reuse BUS_Q
|
|
|
|
ADDR_SRC_REG8, // TODO reuse BUS_Q
|
|
|
|
ADDR_SRC_OPERAND8,
|
|
|
|
ADDR_SRC_OPERAND16,
|
|
|
|
ADDR_SRC_BUS_P,
|
|
|
|
ADDR_SRC_BUS_Q
|
|
|
|
} addr_src_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BUS_SRC_A,
|
|
|
|
BUS_SRC_F,
|
|
|
|
BUS_SRC_REG8,
|
|
|
|
BUS_SRC_OPERAND8_H,
|
|
|
|
BUS_SRC_OPERAND8_L,
|
|
|
|
BUS_SRC_ALU,
|
|
|
|
BUS_SRC_MEM,
|
|
|
|
BUS_SRC_PC_H,
|
|
|
|
BUS_SRC_PC_L,
|
|
|
|
BUS_SRC_REG16_H,
|
|
|
|
BUS_SRC_REG16_L
|
|
|
|
} bus_src_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BUS_DST_SP_H,
|
|
|
|
BUS_DST_SP_L,
|
|
|
|
BUS_DST_ALU,
|
|
|
|
BUS_DST_REG8,
|
|
|
|
BUS_DST_REG16_H,
|
|
|
|
BUS_DST_REG16_L,
|
|
|
|
BUS_DST_PC_H,
|
|
|
|
BUS_DST_PC_L,
|
|
|
|
BUS_DST_MEM
|
|
|
|
} bus_dst_t;
|
|
|
|
|
|
|
|
typedef struct packed {
|
|
|
|
bus_src_t src;
|
|
|
|
bus_dst_t dst;
|
|
|
|
logic wen;
|
|
|
|
} bus_ctrl_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BUS16_SRC_REG16,
|
|
|
|
BUS16_SRC_ALU16,
|
|
|
|
BUS16_SRC_SP
|
|
|
|
} bus16_src_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BUS16_DST_REG16,
|
|
|
|
BUS16_DST_ALU16,
|
|
|
|
BUS16_DST_SP
|
|
|
|
} bus16_dst_t;
|
|
|
|
|
|
|
|
typedef struct packed {
|
|
|
|
bus16_src_t src;
|
|
|
|
bus16_dst_t dst;
|
|
|
|
logic wen;
|
|
|
|
} bus16_ctrl_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PC_SRC_INC,
|
|
|
|
PC_SRC_OPERAND8,
|
|
|
|
PC_SRC_OPERAND16,
|
|
|
|
PC_SRC_BUS
|
|
|
|
} pc_src_t;
|
|
|
|
|
|
|
|
endpackage : cpu_pkg
|