2014-11-10 14:16:45 +00:00
|
|
|
#ifndef __CPU_H__
|
|
|
|
#define __CPU_H__
|
2014-10-18 11:33:48 +00:00
|
|
|
|
2015-11-30 14:49:56 +00:00
|
|
|
#undef PC
|
|
|
|
|
2018-08-10 10:13:45 +00:00
|
|
|
class Stream;
|
|
|
|
|
2014-10-21 18:41:44 +00:00
|
|
|
class CPU: public Checkpointable {
|
2014-10-18 11:33:48 +00:00
|
|
|
public:
|
2014-11-20 08:28:01 +00:00
|
|
|
virtual void run(unsigned instructions) =0;
|
2016-01-23 21:15:14 +00:00
|
|
|
virtual void reset() =0;
|
|
|
|
virtual void raise(int level) =0;
|
2016-01-24 11:55:50 +00:00
|
|
|
virtual char *status(char *buf, size_t n, bool hdr) =0;
|
2014-10-18 11:33:48 +00:00
|
|
|
|
2014-10-21 18:41:44 +00:00
|
|
|
virtual void checkpoint(Stream &s) = 0;
|
|
|
|
virtual void restore(Stream &s) = 0;
|
|
|
|
|
2016-01-23 21:15:14 +00:00
|
|
|
inline bool halted() { return _halted; }
|
2014-10-31 08:18:15 +00:00
|
|
|
|
2014-10-18 11:33:48 +00:00
|
|
|
protected:
|
2016-01-24 11:55:50 +00:00
|
|
|
CPU(Memory &mem): _mem(mem), _halted(false) {}
|
2014-11-21 12:44:52 +00:00
|
|
|
Memory &_mem;
|
2015-11-30 14:49:56 +00:00
|
|
|
Memory::address PC;
|
2016-01-24 11:55:50 +00:00
|
|
|
bool _halted;
|
2014-10-18 11:33:48 +00:00
|
|
|
};
|
|
|
|
#endif
|