3#include <core/cpu/cpu.hpp>
34 ss <<
"Unhandled instruction: " << std::hex <<
ir;
35 throw std::runtime_error(ss.str());
47 uint32_t multiplied = offset << 2;
48 if((multiplied & 0x80000000) != (offset & 0x80000000))
50 std::cout <<
"MISTAKE!";
88 for(
int i = 0; i < num_loads; i++)
93 if(load.
delay == 0xffffffff)
108 std::cout <<
"Registers:\n";
109 for(
int i = 0; i < 32; i++)
111 std::cout <<
"R" << i <<
": " << std::hex <<
regs[i] <<
"\t";
115 std::cout <<
"HI: " << std::hex <<
hi <<
"\tLO: " << std::hex <<
lo <<
"\n";
std::map< uint8_t, void(CPU::*)()> lookup_op
Lookup table for instructions.
uint32_t read32(uint32_t addr)
Read a 32 bit word from the bus.
void load_next_ins()
Load the next instruction into the instruction register.
void branch(uint32_t offset)
Branches to the given offset.
uint32_t ir
Instruction register.
uint32_t ir_next
Instruction immediately after the current instruction in the memory.
Instruction ins
Instruction in the form of the Instruction structure.
void load_regs()
Loads the registers from the load queue.
uint32_t regs[32]
General purpose registers.
uint32_t pc
Program counter.
void show_regs()
Shows the values of the registers.
void decode_and_execute()
Decodes and executes the instruction in the instruction register.
void set_reg(uint8_t reg, uint32_t data)
Sets the value of the given register from the general purpose registers.
uint32_t get_reg(uint8_t reg)
Gets the value of the given register from the general purpose registers.
std::queue< RegisterLoad > load_queue
Queue to store the loads to the general purpose registers.
Structure to access different parts of an instruction by value.
uint32_t opcode()
Opcode of the instruction. Size: 6 bits [31-26].
Struture to store details of loads to the general purpose registers.
uint32_t delay
Delay in clock cycles.
uint32_t data
Data to be loaded.