-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocessor_impl.hpp
62 lines (49 loc) · 1.75 KB
/
processor_impl.hpp
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
57
58
59
60
61
62
#pragma once
#include "bus.hpp"
#include "cache.hpp"
#include "processor.hpp"
#include "protocol.hpp"
#include "request.hpp"
#include <memory>
#include <utility>
#include <vector>
using namespace std;
enum ProcessorState { FREE, LOAD, STORE, NON_MEMORY, DONE };
class ProcessorImpl : public Processor {
private:
string stringOfState();
public:
int pid;
vector<pair<unsigned int, unsigned int>> stream;
int streamIndex = 0;
shared_ptr<Protocol> protocol;
shared_ptr<Cache> cache;
shared_ptr<Bus> bus;
ProcessorState state = FREE;
unsigned int nonMemCounter = 0;
bool done = false;
// counters for statistics
unsigned int numCycles = 0;
unsigned int numComputeCycles = 0;
unsigned int numLoad = 0;
unsigned int numStore = 0;
unsigned int numIdle = 0;
unsigned int numMiss = 0;
bool execute(unsigned int type, unsigned int value);
public:
ProcessorImpl(int pid, string filepath, unsigned int cacheSize, unsigned int associativity,
unsigned int blockSize, shared_ptr<Bus> bus, shared_ptr<Protocol> protocol);
void executeCycle() override;
bool invalidateCache(unsigned int address) override;
State getState(unsigned int address) override;
bool isDone() override;
void setState(unsigned int address, State state) override;
void addCacheLine(unsigned int address, State state) override;
int getPID() override { return pid; };
void printProgressInline() override;
void printStatistics() override;
unsigned int getNumComputeCycles()override{return numComputeCycles;};
unsigned int getNumIdle()override {return numIdle;};
unsigned int getNumLoad()override{return numLoad;};
unsigned int getNumStore()override{return numStore;};
};