-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCGRA.cpp
More file actions
110 lines (93 loc) · 2.31 KB
/
CGRA.cpp
File metadata and controls
110 lines (93 loc) · 2.31 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "CGRA.h"
CGRA::~CGRA()
{
for (auto node : CGRAnodesList)
{
delete node;
}
}
CGRA::CGRA(int PERow, int PEColumn)
{
PENum = PERow * PEColumn;//PEA������������LSU��Ԫ
cout << PERow <<PEColumn <<endl;
int i, j, k;
for( j = 0; j < PERow; j++)//PE的行数
{
for(i = 0; i < PEColumn;i++)
{
CGRANode* node = new CGRANode();
int PeCurrent = i + j * PEColumn;
node->PElabel = PeCurrent;/* PElabel */
int PeN = i + ((j - 1 + PERow) % PERow ) * PEColumn;
int PeS = i +((j + 1) % PERow) * PEColumn;
int PeW =((i - 1) + PEColumn) % PEColumn + j * PEColumn;
int PeE =(i + 1) % PEColumn + j * PEColumn;
if(i == 0 ) //LSU第一列
{
node->PEkind = 1;
for(int m = 0;m < PEColumn -1;m++)
{
node->PENeighbors.push_back(PeCurrent + 1+m);
}
}
else//PE
{
node->PEkind = 0;
if( j == 0 || j == PERow -1)//第一行和最后一行
{
if(i == 1)//PE的第一列
{
node->PENeighbors.push_back(PeE);
}
else if(i == PEColumn-1)//PE的最后一列
{
node->PENeighbors.push_back(PeW);
}
else //PE的中间列
{
node->PENeighbors.push_back(PeW);
node->PENeighbors.push_back(PeE);
}
if(j == 0)//PE的第一行
{
node->PENeighbors.push_back(PeS);
}
if(j == PERow -1)//PE的最后一行
{
node->PENeighbors.push_back(PeN);
}
}
else//中间行
{
node->PENeighbors.push_back(PeN);
node->PENeighbors.push_back(PeS);
if(i == 1)//PE的第一列
{
node->PENeighbors.push_back(PeE);
}
else if(i == PEColumn-1)//PE的最后一列
{
node->PENeighbors.push_back(PeW);
}
else //PE的中间列
{
node->PENeighbors.push_back(PeW);
node->PENeighbors.push_back(PeE);
}
}
node->PENeighbors.push_back(j*PEColumn);
}
CGRAnodesList.push_back(node);
}
}
// for(int i = 0; i < CGRAnodesList.size(); i++)
// {
// cout<<"PElabel:"<<CGRAnodesList[i]->PElabel<<endl;
// cout<<"neighbor:";
// for(int j = 0; j < CGRAnodesList[i]->PENeighbors.size(); j ++ )
// {
// cout<<CGRAnodesList[i]->PENeighbors[j]<<" ";
// }
// cout<<endl;
// }
}