-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_processor.cc
More file actions
54 lines (47 loc) · 1.21 KB
/
ft_processor.cc
File metadata and controls
54 lines (47 loc) · 1.21 KB
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
/*
* ft_processor.cc
*
* Created on: 2017年4月26日
* Author: Vincent
*/
#include "processor.h"
#include "fat_tree.h"
class FtProcessor : public Processor {
protected:
//纯虚函数,由子类实现
virtual int ppid2plid(int ppid) override;
virtual int plid2ppid(int plid) override;
virtual int getNextRouterPortP() override; //计算与processor相连的router的端口
};
Define_Module(FtProcessor);
int FtProcessor::getNextRouterPortP(){
int current_ppid=getIndex();
int plid=ppid2plid(current_ppid);
int port=plid%100;
return port; //返回和processor相连的router的端口
}
//从ppid计算plid
int FtProcessor::ppid2plid(int ppid){
int idtmp = ppid;
int idfinal = 0;
int mul = 1;
for(int i = 0; i < LevelNum - 1; i++){
idfinal = idfinal + idtmp % (PortNum / 2)*mul;
mul = mul * 100;
idtmp = (int) (idtmp / (PortNum / 2));
}
idfinal = idfinal + idtmp * mul;
return idfinal;
}
//从plid计算ppid
int FtProcessor::plid2ppid(int plid){
int tmp = plid;
int mul = 1;
int IDtmp = 0;
for(int i = 0; i < LevelNum; i++){
IDtmp = IDtmp + mul * (tmp % 100);
mul = mul * (PortNum / 2);
tmp = tmp / 100;
}
return IDtmp;
}