95 lines
1.3 KiB
C
95 lines
1.3 KiB
C
#ifndef CPU_HEADER
|
|
#include "simdata.h"
|
|
|
|
struct fetch_data_t{
|
|
|
|
};
|
|
struct decode_data_t{
|
|
uint32_t in_bytecode;
|
|
uint32_t address; // used only for the gui hints (for now)
|
|
};
|
|
|
|
|
|
|
|
|
|
///// EXEC DATA STRUCTURES ///////
|
|
enum EXEC_ACTION_t {
|
|
EXEC_ALU,
|
|
MOVE,
|
|
JUMP,
|
|
CALL,
|
|
NOP,
|
|
HALT,
|
|
RET,
|
|
PUSH,
|
|
POP
|
|
};
|
|
|
|
enum ALU_OP_t {
|
|
ALU_ADD,
|
|
ALU_SUB,
|
|
ALU_SL,
|
|
ALU_SR,
|
|
ALU_CMP,
|
|
ALU_FDIV,
|
|
ALU_FMUL,
|
|
ALU_FADD,
|
|
ALU_FSUB
|
|
};
|
|
|
|
enum OP_ADDR_t {
|
|
IMMEDIATE,
|
|
REGISTER,
|
|
REGISTERL, //low word
|
|
REGISTERH, //high word
|
|
REGISTER_IND
|
|
};
|
|
|
|
struct exec_op_t {
|
|
enum OP_ADDR_t OP_ADDR;
|
|
uint32_t data;
|
|
};
|
|
|
|
enum COND_t{
|
|
NONE,
|
|
ZERO,
|
|
NZERO,
|
|
CARRY,
|
|
NCARRY
|
|
};
|
|
|
|
struct exec_data_t {
|
|
enum EXEC_ACTION_t EXEC_ACTION;
|
|
enum ALU_OP_t ALU_OP;
|
|
enum COND_t COND;
|
|
struct exec_op_t *in_op1;
|
|
struct exec_op_t *in_op2;
|
|
struct exec_op_t *out_op;
|
|
uint32_t address; // used only for the gui hints (for now)
|
|
};
|
|
|
|
|
|
|
|
void cpu_simdata_free(struct simdata_t *simdata);
|
|
int cpu_simdata_malloc(struct simdata_t *simdata);
|
|
int cpu_cycle_clock(struct simdata_t *simdata);
|
|
|
|
// +===================+
|
|
// | BIT | USAGE |
|
|
// |-----+-------------|
|
|
// | 0 | ZERO |
|
|
// |-----+-------------|
|
|
// | 1 | CARRY |
|
|
// |-----+-------------|
|
|
// | 2 | SIGN |
|
|
//
|
|
struct registers_t{
|
|
uint32_t GPR[8];
|
|
uint32_t FLAGS;
|
|
uint32_t PC;
|
|
uint32_t SP;
|
|
};
|
|
|
|
#endif
|
|
#define CPU_HEADER
|