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,
|
|
|
|
NOP,
|
|
|
|
HALT
|
2024-02-03 22:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ALU_OP_t {
|
|
|
|
ALU_ADD,
|
|
|
|
ALU_SUB,
|
|
|
|
ALU_SL,
|
|
|
|
ALU_SR,
|
|
|
|
ALU_CMP
|
|
|
|
};
|
|
|
|
|
|
|
|
enum OP_ADDR_t {
|
|
|
|
IMMEDIATE,
|
|
|
|
REGISTER,
|
2024-02-06 21:53:42 +00:00
|
|
|
REGISTERL, //low word
|
|
|
|
REGISTERH, //high word
|
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-03 22:54:20 +00:00
|
|
|
#endif
|
|
|
|
#define CPU_HEADER
|