-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpu.h
56 lines (49 loc) · 1.17 KB
/
cpu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef CPU_H
#define CPU_H
#include "instr.h"
#include <QObject>
#include <QThread>
const uint32_t REG_SIZE = 16;
const uint32_t MEM_SIZE = 65536;
const uint32_t DIS_WIDTH = 256;
const uint32_t DIS_HEIGHT = 128;
const uint32_t DIS_SCALE = 4;
class CPU;
class CPUExecThreads : public QThread {
public:
explicit CPUExecThreads(CPU *cpu_init) { cpu = cpu_init; };
CPU *cpu;
void run();
};
class CPU : public QObject {
Q_OBJECT
public:
explicit CPU(QObject *parent = nullptr);
~CPU();
std::string processLabels(std::string input, std::stringstream &labels);
uint32_t &readMem(uint32_t mem);
public slots:
void readInstrs(QString input);
void run();
void pause();
void stop();
void step();
void dumpStatus();
void dumpMem();
void updateDisplay();
void showMsg(QString msg);
signals:
void statusUpd(QString status);
void memUpd(QString mem);
void sendMsg(QString msg);
void displayUpd(uint32_t *mem, uint32_t width, uint32_t height,
uint32_t scale);
public:
uint32_t m_regFile[REG_SIZE] = {};
uint32_t m_mem[MEM_SIZE] = {};
uint32_t m_PC;
uint32_t m_nextPC;
uint32_t m_run;
CPUExecThreads *execThread;
};
#endif // CPU_H