risc-v-tlm/src/Instruction.cpp

36 lines
919 B
C++
Raw Normal View History

/*!
\file Instruction.cpp
\brief Decode instructions part of the RISC-V
\author Màrius Montón
\date August 2018
*/
// SPDX-License-Identifier: GPL-3.0-or-later
2018-09-11 00:44:54 +08:00
#include "Instruction.h"
2020-05-29 22:03:45 +08:00
2021-11-30 03:35:26 +08:00
namespace riscv_tlm {
2018-10-15 19:51:41 +08:00
2021-11-30 03:35:26 +08:00
Instruction::Instruction(std::uint32_t instr) {
m_instr = instr;
}
2021-11-30 03:35:26 +08:00
extension_t Instruction::check_extension() const {
if (((m_instr & 0x0000007F) == 0b0110011)
&& (((m_instr & 0x7F000000) >> 25) == 0b0000001)) {
return M_EXTENSION;
} else if ((m_instr & 0x0000007F) == 0b0101111) {
return A_EXTENSION;
} else if ((m_instr & 0x00000003) == 0b00) {
return C_EXTENSION;
} else if ((m_instr & 0x00000003) == 0b01) {
return C_EXTENSION;
} else if ((m_instr & 0x00000003) == 0b10) {
return C_EXTENSION;
} else {
return BASE_EXTENSION;
}
}
2021-11-30 03:35:26 +08:00
}