risc-v-tlm/inc/CPU.h

103 lines
2.0 KiB
C
Raw Normal View History

2018-09-11 00:44:54 +08:00
/*!
\file CPU.h
\brief Main CPU class
\author Màrius Montón
\date August 2018
*/
#ifndef CPU_BASE_H
#define CPU_BASE_H
#define SC_INCLUDE_DYNAMIC_PROCESSES
#include "systemc"
#include "tlm.h"
#include "tlm_utils/simple_initiator_socket.h"
#include "memory.h"
2018-09-21 19:05:42 +08:00
#include "Execute.h"
2018-09-11 00:44:54 +08:00
#include "Registers.h"
#include "Log.h"
2018-10-15 19:51:41 +08:00
#include "Instruction.h"
#include "C_Instruction.h"
2018-11-13 00:41:17 +08:00
#include "M_Instruction.h"
#include "A_Instruction.h"
2018-09-11 00:44:54 +08:00
using namespace sc_core;
using namespace sc_dt;
using namespace std;
/**
* @brief ISC_V CPU model
* @param name name of the module
*/
class CPU: sc_module {
public:
2019-01-22 19:43:05 +08:00
/**
* @brief Instruction Memory bus socket
* @param trans transction to perfoem
* @param delay time to annotate
*/
2018-09-11 00:44:54 +08:00
tlm_utils::simple_initiator_socket<CPU> instr_bus;
2019-01-22 19:43:05 +08:00
/**
* @brief IRQ line socket
* @param trans transction to perform (empty)
* @param delay time to annotate
*/
tlm_utils::simple_target_socket<CPU> irq_line_socket;
2018-09-11 00:44:54 +08:00
2019-01-22 19:43:05 +08:00
/**
* @brief Constructor
* @param name Module name
* @param PC Program Counter initialize value
*/
CPU(sc_module_name name, uint32_t PC);
2019-01-22 19:43:05 +08:00
/**
* @brief Destructor
*/
2018-09-11 00:44:54 +08:00
~CPU();
2018-09-21 19:05:42 +08:00
Execute *exec;
2018-09-11 00:44:54 +08:00
private:
Registers *register_bank;
Performance *perf;
Log *log;
2019-01-22 19:43:05 +08:00
bool interrupt;
2019-01-13 08:30:49 +08:00
/**
*
* @brief Process and triggers IRQ if all conditions memory_socket
* @return true if IRQ is triggered, false otherwise
*/
bool cpu_process_IRQ();
2019-01-22 19:43:05 +08:00
/**
* @brief Executes default ISA instruction
* @param inst instruction to execute
* @return true if PC is affected by instruction
*/
2018-10-15 19:51:41 +08:00
bool process_base_instruction(Instruction &inst);
bool process_c_instruction(Instruction &inst);
2018-11-13 00:41:17 +08:00
bool process_m_instruction(Instruction &inst);
bool process_a_instruction(Instruction inst);
2018-09-11 00:44:54 +08:00
void CPU_thread(void);
2019-01-22 19:43:05 +08:00
/**
* @brief callback for IRQ simple socket
* @param trans transaction to perform (empty)
* @param delay time to annotate
*/
void call_interrupt(tlm::tlm_generic_payload &trans, sc_time &delay);
2018-09-11 00:44:54 +08:00
};
#endif