-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPU.h
47 lines (37 loc) · 866 Bytes
/
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
#include <iostream>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
using namespace std;
class Instruction;
class CPU {
private:
int dmemory[4096]; //data memory byte addressable in little endian fashion;
unsigned long PC; //pc
int regFile[32];
public:
CPU();
unsigned long readPC();
bitset<32> Fetch(bitset<8> *instmem);
void Decode(uint32_t instr);
string operation;
int killCount;
int clockCycles;
int rTypeCount;
int insCount;
float ipc;
int ReadDataMemory(int address);
void WriteDataMemory(int address, int data);
int ReadRegFile(int reg);
void WriteRegFile(int reg, int value);
void UpdatePC(int imm);
};
class Instruction {
public:
bitset<32> instr;//instruction
CPU myCPU;
Instruction(bitset<32> fetch, CPU myCPU); // constructor
};
// add other functions and objects here