risc-v-tlm/src/Instruction.cpp

34 lines
798 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
Instruction::Instruction(sc_dt::sc_uint<32> instr) {
m_instr = instr;
2018-09-11 00:44:54 +08:00
}
2018-10-15 19:51:41 +08:00
extension_t Instruction::check_extension() {
if ((m_instr.range(6, 0) == 0b0110011)
&& (m_instr.range(31, 25) == 0b0000001)) {
return M_EXTENSION;
} else if (m_instr.range(6, 0) == 0b0101111) {
return A_EXTENSION;
} else if (m_instr.range(1, 0) == 0b11) {
return BASE_EXTENSION;
} else if (m_instr.range(1, 0) == 0b00) {
return C_EXTENSION;
} else if (m_instr.range(1, 0) == 0b01) {
return C_EXTENSION;
} else if (m_instr.range(1, 0) == 0b10) {
return C_EXTENSION;
} else {
return UNKNOWN_EXTENSION;
}
2018-10-15 19:51:41 +08:00
}