Add some comments to ProcessorHandler static functions
MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -27,19 +27,38 @@ class ProcessorHandler : public QObject {
Q_OBJECT
public:
+ /// Returns a pointer to the ProcessorHandler singleton.
static ProcessorHandler* get() {
static auto* handler = new ProcessorHandler;
return handler;
}
+ /// Returns a non-const pointer to the currently instantiated processor.
static RipesProcessor* getProcessorNonConst() { return get()->_getProcessor(); }
+
+ /// Returns a pointer to the currently instantiated processor.
static const RipesProcessor* getProcessor() { return get()->_getProcessor(); }
+
+ /// Return a pointer to the currently instantiated assembler.
static const std::shared_ptr<Assembler::AssemblerBase> getAssembler() { return get()->_getAssembler(); }
+
+ /// Returns the ID of the currently instantiated processor.
static const ProcessorID& getID() { return get()->_getID(); }
+
+ /// Returns a pointer to the currently instantiated program.
static std::shared_ptr<const Program> getProgram() { return get()->_getProgram(); }
+
+ /// Returns a pointer to the currently instantiated ISA.
static const ISAInfoBase* currentISA() { return get()->_currentISA(); }
+
+ /// Returns a reference to the system call manager.
static const SyscallManager& getSyscallManager() { return get()->_getSyscallManager(); }
+
+ /// Sets the program p as the currently instantiated program.
static void loadProgram(const std::shared_ptr<Program>& p) { get()->_loadProgram(p); }
+
+ /// Returns true if the current processor is a VSRTL-based processor. This may be used to enable VSRTL-specific
+ /// functionality, such as processor drawing.
static bool isVSRTLProcessor();
/**
@@ -113,12 +132,28 @@ public:
return get()->_getRegisterValue(rfid, idx);
}
+ /// Returns true if the processor is currently at a breakpoint. This is done through comparing the
+ /// breakpoint-triggering stages of the current processor, fetching the PC of those stages, and comparing them
+ /// against the current set of breakpoint addresses.
static bool checkBreakpoint() { return get()->_checkBreakpoint(); }
+
+ /// Set/unset the provided address as a breakpoint.
static void setBreakpoint(const AInt address, bool enabled) { get()->_setBreakpoint(address, enabled); }
+
+ /// Toggles a breakpoint at the provided address.
static void toggleBreakpoint(const AInt address) { get()->_toggleBreakpoint(address); }
+
+ /// Returns true if there exists a breakpoint at the requested address.
static bool hasBreakpoint(const AInt address) { return get()->_hasBreakpoint(address); }
+
+ /// Removes all currently set breakpoints.
static void clearBreakpoints() { get()->_clearBreakpoints(); }
+
+ /// Trigger a processor finished check. This inspect the current processor run state, and if finished, emit a finish
+ /// signal.
static void checkProcessorFinished() { get()->_checkProcessorFinished(); }
+
+ /// Returns true if the simulator is currently in "run" mode.
static bool isRunning() { return get()->_isRunning(); }
/**
@@ -187,6 +222,9 @@ private slots:
void syscallTrap();
private:
+ /// Private implementations of the ProcessorHandler singleton functions. For documentation, refer to their static
+ /// counterparts above.
+
void _loadProgram(const std::shared_ptr<Program>& p);
RipesProcessor* _getProcessor() { return m_currentProcessor.get(); }
const RipesProcessor* _getProcessor() const { return m_currentProcessor.get(); }

Add some comments to ProcessorHandler static functions