cpu.hh

来自「一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,」· HH 代码 · 共 65 行

HH
65
字号
#ifndef cpu_hh_included#define cpu_hh_included#include "inttypes.hh"#include "clock.hh"#include "module.hh"#include "simarg.hh"#include "serial.hh"#include "interruptsink.hh"// CPU adds fetch-execute loop support to Module.class CPU    : public virtual Serializable, public Module, public Clock, public InterruptSink{private:    // The scheduler information (see "sulima/cpu.cc").    static int cpu_count;    static CPU *first_cpu, *last_cpu;    CPU *next_cpu;protected:    // Timeslice of this CPU.    // Do not change or you're wreck havoc in the scheduler!!!    ClockValue timeslice;    // Minimum and maximum timeslice. Adjust these if needed.    static const ClockValue min_timeslice = 32;    static const ClockValue max_timeslice = 16*KB;public:    // An interrupt event.    class InterruptEvent	: public virtual Serializable, public Event    {    private:	static SerialType<InterruptEvent> type;	CPU* cpu;	Int8 num;    public:	InterruptEvent(Int8 n, CPU* c, ClockValue when)	    : Event(when), cpu(c), num(n) { }	explicit InterruptEvent(const SimArgs& args)	    : Event(args) { assert(UNREACHABLE); }	explicit InterruptEvent(Checkpoint& cp);	void invoke();	void checkpoint(Checkpoint& cp, bool parent = false) const;    };    // Dump state for debugging    virtual void dump_state() = 0;    // Constructors, etc.    CPU(const char *n, ClockValue f);    explicit CPU(const SimArgs &args);    explicit CPU(Checkpoint &cp);    void checkpoint(Checkpoint &cp, bool parent = false) const;    // Simulator interfaces.    virtual void run(ClockValue timeslice) = 0;    // Tcl interfaces.    static SimArg run_all(const SimArgs &args);    Int32 trace_level;};#endif // cpu_hh_included

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?