-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.h
55 lines (41 loc) · 1.2 KB
/
controller.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
//contoller class handles everything dealing with Instructions. Contains the instruction memory and instruction queue
#ifndef CONTROLLER_H_
#define CONTROLLER_H_
#include "instructions.h"
class InstructionMemory{
unsigned char * inst_memory;
public:
InstructionMemory(unsigned size);
~InstructionMemory();
unsigned char * get_mem_ptr();
Instruction* fetch(unsigned addrPtr, Pipeline * pl); //pl because instructions need it
void print(unsigned start_address, unsigned end_address);
void alert();
};
class InstructionQueue {
unsigned maxSize;
std::queue<Instruction*> q;
public:
InstructionQueue(unsigned queueSize);
void push(Instruction* inst);
void clear();
void pop();
Instruction * fetch();
bool isFull();
void alert();
};
class Controller {
Pipeline * pl;
InstructionQueue * inst_queue;
std::vector<Instruction *> running_inst;
unsigned inst_executed;
unsigned max_issue;
public:
InstructionMemory * inst_memory;
Controller(unsigned inst_queue_size, Pipeline * pl, unsigned max_issue);
void execute();
unsigned char * inst_mem_base();
void setInInstStageOrder(std::vector<Instruction *> &);//sets vector of instructions in instruction stage order
unsigned getInstExecuted();
};
#endif