1#include <core/cpu/cpu.hpp>
51 std::cout <<
"Ignoring SW as cache is isolated.\n";
55 uint32_t offset =
ins.
imm();
77 uint32_t data_se =
ins.
imm();
81 data_se |= 0xffff0000;
111 uint32_t offset =
ins.
imm();
115 offset |= 0xffff0000;
139 uint32_t extended_imm =
ins.
imm();
141 if(extended_imm & 0x8000)
143 extended_imm |= 0xffff0000;
147 if(((extended_imm & 0x80000000) && (
get_reg(
ins.
rs()) & 0x80000000) && (((
get_reg(
ins.
rs()) + extended_imm) & 0x80000000) == 0))
148 || (((extended_imm & 0x80000000) == 0) && ((
get_reg(
ins.
rs()) & 0x80000000) == 0) && ((
get_reg(
ins.
rs()) + extended_imm) & 0x80000000)))
151 std::stringstream ss;
152 ss <<
"Signed overflow in ADDI: " << std::hex <<
ir;
153 throw std::runtime_error(ss.str());
175 uint32_t offset =
ins.
imm();
179 offset |= 0xffff0000;
205 std::cout <<
"Ignoring SH as cache is isolated.\n";
209 uint32_t offset =
ins.
imm();
213 offset |= 0xffff0000;
274 std::cout <<
"Ignoring SB as cache is isolated.\n";
278 uint32_t offset =
ins.
imm();
282 offset |= 0xffff0000;
303 uint32_t offset =
ins.
imm();
307 offset |= 0xffff0000;
310 if(data_s & 0b10000000)
312 data_s |= 0xffffff00;
331 uint32_t offset =
ins.
imm();
335 offset |= 0xffff0000;
355 uint32_t offset =
ins.
imm();
359 offset |= 0xffff0000;
379 uint32_t offset =
ins.
imm();
383 offset |= 0xffff0000;
407 uint32_t offset =
ins.
imm();
411 offset |= 0xffff0000;
460 uint32_t offset =
ins.
imm();
463 offset |= 0xffff0000;
465 uint8_t val = op1 < 0;
483 uint32_t offset =
ins.
imm();
486 offset |= 0xffff0000;
488 uint8_t val = op1 < 0;
510 uint32_t offset =
ins.
imm();
513 offset |= 0xffff0000;
515 uint8_t val = op1 >= 0;
533 uint32_t offset =
ins.
imm();
536 offset |= 0xffff0000;
538 uint8_t val = op1 >= 0;
561 uint32_t imm_se =
ins.
imm();
564 imm_se |= 0xffff0000;
566 int32_t op2 = imm_se;
uint8_t read8(uint32_t addr)
Read a 8 bit word from the bus.
void SLTIU()
Set on Less Than Immediate Unsigned.
void BEQ()
Branch on Equal.
void write16(uint32_t addr, uint16_t data)
Write a 16 bit word to the bus.
void BLGE()
Choose between BLTZAL, BGEZAL, BLTZ, BGEZ.
uint32_t read32(uint32_t addr)
Read a 32 bit word from the bus.
void LUI()
Load Upper Immediate.
void BLEZ()
Branch on Less Than or Equal to Zero.
void branch(uint32_t offset)
Branches to the given offset.
uint32_t ir
Instruction register.
void BGEZAL()
Branch on Greater Than or Equal to Zero And Link.
void SLTI()
Set on Less Than Immediate.
void LBU()
Load Byte Unsigned.
void J()
Unconditional Jump.
Instruction ins
Instruction in the form of the Instruction structure.
uint32_t cop0_status
COP0 status register.
void write8(uint32_t addr, uint8_t data)
Write a 8 bit word to the bus.
void write32(uint32_t addr, uint32_t data)
Write a 32 bit word to the bus.
void ORI()
Bitwise OR Immediate.
void BLTZAL()
Branch on Less Than Zero And Link.
uint32_t pc
Program counter.
void ADDIU()
Add Immediate Unsigned.
void BNE()
Branch on Not Equal.
void ADDI()
Add Immediate.
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.
void BGEZ()
Branch on Greater Than or Equal to Zero.
void BLTZ()
Branch on Less Than Zero.
void ANDI()
Bitwise AND Immediate.
std::queue< RegisterLoad > load_queue
Queue to store the loads to the general purpose registers.
void BGTZ()
Branch on Greater Than Zero.
uint32_t imm()
Immediate value for the instruction. Size: 16 bits [15-0].
uint32_t rt()
Target register for the instruction. Size: 5 bits [20-16].
uint32_t addr()
Address value for jump/branch instructions. Size: 26 bits [25-0].
uint32_t rs()
Source register for the instruction. Size: 5 bits [25-21].
Struture to store details of loads to the general purpose registers.