-
Notifications
You must be signed in to change notification settings - Fork 0
/
BranchPredictor.h
39 lines (35 loc) · 1.18 KB
/
BranchPredictor.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
#pragma once
#include"Module.h"
#include"Tech.h"
#include"Skill.h"
#include<vector>
#include<queue>
#include<cmath>
#include<memory>
namespace Design
{
// opens an independent context (registers, cache, etc) and starts computing as if that branch is taken
// if branch is not taken, it discards whole context (releases resources)
// if branch is taken, it converts context to the current context in 1-k cycles
class BranchPredictor :public Module
{
public:
// capacity: number of branches to remember
// branchPolicy: 0=by last branch, 1=by average of N branches, 2=by polynomial fit
BranchPredictor(int frequency, int lithography, int capacity, int branchPolicy, int parallelism) :
Module(parallelism, parallelism, lithography,/*numTransistors*/ 1, ModuleType::BRANCH_PREDICTOR,
/* thermalDissipationPower */ 1, frequency, /* failProbability*/ 0.0f)
{
_capacity = capacity;
}
static std::shared_ptr<Module> Create(int frequency, int lithography, int parallelism, int capacity, int branchPolicy)
{
return std::make_shared<BranchPredictor>(frequency, lithography, capacity,branchPolicy,parallelism);
}
void Compute() override
{
}
private:
int _capacity;
};
}