2024-02-03 22:54:20 +00:00
|
|
|
#ifndef CPU_HEADER
|
|
|
|
#include "simdata.h"
|
|
|
|
|
|
|
|
struct fetch_data_t{
|
|
|
|
|
|
|
|
};
|
|
|
|
struct decode_data_t{
|
|
|
|
uint32_t in_bytecode;
|
2024-02-07 00:31:23 +00:00
|
|
|
uint32_t address; // used only for the gui hints (for now)
|
2024-02-03 22:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// EXEC DATA STRUCTURES ///////
|
|
|
|
enum EXEC_ACTION_t {
|
|
|
|
EXEC_ALU,
|
2024-02-06 21:53:42 +00:00
|
|
|
MOVE,
|
2024-02-06 23:14:33 +00:00
|
|
|
JUMP,
|
2024-02-12 13:43:13 +00:00
|
|
|
CALL,
|
2024-02-06 23:14:33 +00:00
|
|
|
NOP,
|
2024-02-12 13:43:13 +00:00
|
|
|
HALT,
|
2024-02-12 19:42:27 +00:00
|
|
|
RET,
|
|
|
|
PUSH,
|
|
|
|
POP
|
2024-02-03 22:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ALU_OP_t {
|
|
|
|
ALU_ADD,
|
|
|
|
ALU_SUB,
|
|
|
|
ALU_SL,
|
|
|
|
ALU_SR,
|
2024-02-14 17:15:04 +00:00
|
|
|
ALU_CMP,
|
|
|
|
ALU_FDIV,
|
2024-02-16 17:48:04 +00:00
|
|
|
ALU_FMUL,
|
|
|
|
ALU_FADD,
|
|
|
|
ALU_FSUB
|
2024-02-03 22:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum OP_ADDR_t {
|
|
|
|
IMMEDIATE,
|
|
|
|
REGISTER,
|
2024-02-06 21:53:42 +00:00
|
|
|
REGISTERL, //low word
|
|
|
|
REGISTERH, //high word
|
2024-02-13 22:37:36 +00:00
|
|
|
REGISTER_IND
|
2024-02-03 22:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct exec_op_t {
|
|
|
|
enum OP_ADDR_t OP_ADDR;
|
|
|
|
uint32_t data;
|
|
|
|
};
|
|
|
|
|
2024-02-06 23:14:33 +00:00
|
|
|
enum COND_t{
|
|
|
|
NONE,
|
|
|
|
ZERO,
|
|
|
|
NZERO,
|
|
|
|
CARRY,
|
|
|
|
NCARRY
|
|
|
|
};
|
2024-02-03 22:54:20 +00:00
|
|
|
|
|
|
|
struct exec_data_t {
|
|
|
|
enum EXEC_ACTION_t EXEC_ACTION;
|
|
|
|
enum ALU_OP_t ALU_OP;
|
2024-02-06 23:14:33 +00:00
|
|
|
enum COND_t COND;
|
2024-02-03 22:54:20 +00:00
|
|
|
struct exec_op_t *in_op1;
|
|
|
|
struct exec_op_t *in_op2;
|
|
|
|
struct exec_op_t *out_op;
|
2024-02-07 00:31:23 +00:00
|
|
|
uint32_t address; // used only for the gui hints (for now)
|
2024-02-03 22:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cpu_simdata_free(struct simdata_t *simdata);
|
|
|
|
int cpu_simdata_malloc(struct simdata_t *simdata);
|
|
|
|
int cpu_cycle_clock(struct simdata_t *simdata);
|
|
|
|
|
2024-02-05 21:25:00 +00:00
|
|
|
// +===================+
|
|
|
|
// | BIT | USAGE |
|
|
|
|
// |-----+-------------|
|
|
|
|
// | 0 | ZERO |
|
|
|
|
// |-----+-------------|
|
|
|
|
// | 1 | CARRY |
|
|
|
|
// |-----+-------------|
|
|
|
|
// | 2 | SIGN |
|
|
|
|
//
|
|
|
|
struct registers_t{
|
|
|
|
uint32_t GPR[8];
|
|
|
|
uint32_t FLAGS;
|
2024-02-12 14:16:41 +00:00
|
|
|
uint32_t PC;
|
|
|
|
uint32_t SP;
|
2024-02-05 21:25:00 +00:00
|
|
|
};
|
|
|
|
|
2024-02-03 22:54:20 +00:00
|
|
|
#endif
|
|
|
|
#define CPU_HEADER
|