risc-v-tlm/inc/Instruction.h

70 lines
1.3 KiB
C
Raw Normal View History

2018-09-11 00:44:54 +08:00
/*!
\file Instruction.h
\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
#ifndef INSTRUCTION__H
#define INSTRUCTION__H
#include "systemc"
#include "extension_base.h"
2018-09-11 00:44:54 +08:00
2021-11-30 03:35:26 +08:00
namespace riscv_tlm {
typedef enum {
BASE_EXTENSION,
M_EXTENSION,
A_EXTENSION,
F_EXTENSION,
D_EXTENSION,
Q_EXTENSION,
L_EXTENSION,
C_EXTENSION,
R_EXTENSION,
J_EXTENSION,
P_EXTENSION,
V_EXTENSION,
N_EXTENSION,
UNKNOWN_EXTENSION
} extension_t;
2018-10-15 19:51:41 +08:00
2018-09-11 00:44:54 +08:00
/**
* @brief Instruction decoding and fields access
*/
2021-11-30 03:35:26 +08:00
class Instruction {
public:
Instruction(std::uint32_t instr);
2018-09-11 00:44:54 +08:00
2021-11-30 03:35:26 +08:00
/**
* @brief returns what instruction extension
* @return extension
*/
extension_t check_extension() const;
2021-11-30 03:35:26 +08:00
void setInstr(std::uint32_t p_instr) {
m_instr = p_instr;
}
2021-11-30 03:35:26 +08:00
/**
* @brief return instruction
* @return all instruction bits (31:0)
*/
std::uint32_t getInstr() {
return m_instr;
}
2021-11-30 03:35:26 +08:00
inline void dump() {
std::cout << std::hex << "0x" << m_instr << std::dec << std::endl;
}
2018-10-15 19:51:41 +08:00
2021-11-30 03:35:26 +08:00
private:
std::uint32_t m_instr;
};
}
2018-09-11 00:44:54 +08:00
#endif