Skip to content

Commit c961905

Browse files
committed
[fix] 给代码添加注释
1 parent c234c8a commit c961905

File tree

6 files changed

+67
-66
lines changed

6 files changed

+67
-66
lines changed

lab3/Design.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void Design::addNet(Net &net) { // 给design添加net
4545
nets.push_back(&net);
4646
}
4747

48-
bool Design::verifyRouting() { // 检查是否布线成功
48+
bool Design::verifyRouting() {
4949
// Check that each net can route successfully
5050
for(auto net : nets) {
5151
bool success = net->verifyRouting();

lab3/Design.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class Design {
1616
virtual ~Design();
1717

1818
private:
19-
vector<Net *> nets;
19+
vector<Net *> nets; // 用于存放net的数组
2020

2121
public:
22-
void addNet(Net &net);
23-
int getNumNets() { return nets.size(); }
24-
Net &getNet(int idx) { return *(nets[idx]); }
25-
vector<Net*> &getNets() { return nets; }
26-
bool verifyRouting();
22+
void addNet(Net &net); // 添加net
23+
int getNumNets() { return nets.size(); } // 获得net的数量
24+
Net &getNet(int idx) { return *(nets[idx]); } // 获得指定序号的net
25+
vector<Net*> &getNets() { return nets; } // 获得net数组
26+
bool verifyRouting(); // 检查是否布线成功
2727
};
2828

2929
#endif

lab3/FPGA.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ class FPGA{
1414
virtual ~FPGA();
1515

1616
private:
17-
int N;
18-
int W;
19-
map<int, map<int, FpgaTile *>> tileMap;
20-
vector<FpgaTile *> tiles;
17+
int N; // FPGA的大小
18+
int W; // 布线通道宽度
19+
map<int, map<int, FpgaTile *>> tileMap; // FPGA块的映射
20+
vector<FpgaTile *> tiles; // FPGA块数组
2121

2222
public:
23-
FpgaTile &getTile(int x, int y) { return *(tileMap[x][y]); }
24-
vector<FpgaTile *> &getTiles() { return tiles; }
23+
FpgaTile &getTile(int x, int y) { return *(tileMap[x][y]); } // 获得坐标为(x,y)的FPGA块
24+
vector<FpgaTile *> &getTiles() { return tiles; } // 获得FPGA块数组
2525

26-
int getN() { return N; }
27-
int getW() { return W; }
28-
int getNumSegmentsUsed();
26+
int getN() { return N; } // 获得FPGA的大小
27+
int getW() { return W; } // 获得布线通道宽度
28+
int getNumSegmentsUsed(); // 获得布线后Routing Segment的数量
2929
};
3030

3131
#endif

lab3/FpgaTile.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,50 @@ class FpgaTile{
2020
int y;
2121
int W;
2222

23+
// 指向相邻的FPGA块的指针
2324
FpgaTile *left;
2425
FpgaTile *right;
2526
FpgaTile *up;
2627
FpgaTile *down;
2728

28-
map<int, RRNode *> logicPin;
29-
vector<RRNode *> vWires;
30-
vector<RRNode *> hWires;
29+
map<int, RRNode *> logicPin; // 逻辑块引脚
30+
vector<RRNode *> vWires; // 垂直导线
31+
vector<RRNode *> hWires; // 水平导线
3132

32-
vector<RRNode *> rrNodes;
33+
vector<RRNode *> rrNodes; // 该FPGA块拥有的布线资源节点(导线或引脚)
3334

3435
public:
35-
int getX() { return x; }
36-
int getY() { return y; }
36+
int getX() { return x; } // 获得FPGA块的x坐标
37+
int getY() { return y; } // 获得FPGA块的y坐标
3738

38-
vector<RRNode *> &getRRNodes() { return rrNodes; }
39+
vector<RRNode *> &getRRNodes() { return rrNodes; } // 获得该FPGA块拥有的布线资源节点
3940

40-
FpgaTile *getDown() const { return down; }
41-
void setDown(FpgaTile *down) { this->down = down; }
41+
FpgaTile *getDown() const { return down; } // 获得该FPGA块下方的FPGA块
42+
void setDown(FpgaTile *down) { this->down = down; } // 设置该FPGA块的下方FPGA块
4243

43-
FpgaTile *getUp() const { return up; }
44-
void setUp(FpgaTile *up) { this->up = up; }
44+
FpgaTile *getUp() const { return up; } // 获得该FPGA块上方的FPGA块
45+
void setUp(FpgaTile *up) { this->up = up; } // 设置该FPGA块的上方FPGA块
4546

46-
FpgaTile *getLeft() const { return left; }
47-
void setLeft(FpgaTile *left) { this->left = left; }
47+
FpgaTile *getLeft() const { return left; } // 获得该FPGA块左边的FPGA块
48+
void setLeft(FpgaTile *left) { this->left = left; } // 设置该FPGA块的左边FPGA块
4849

49-
FpgaTile *getRight() const { return right; }
50-
void setRight(FpgaTile *right) { this->right = right; }
50+
FpgaTile *getRight() const { return right; } // 获得该FPGA块右边的FPGA块
51+
void setRight(FpgaTile *right) { this->right = right; } // 设置该FPGA块的右边FPGA块
5152

5253
void generateContents();
5354
void populateSwitchbox();
5455

55-
RRNode &getLogicPin(int idx) {
56+
RRNode &getLogicPin(int idx) { // 获得逻辑块的idx引脚
5657
assert(logicPin.find(idx) != logicPin.end());
5758
return *(logicPin[idx]);
5859
}
5960

60-
RRNode &getVWire(int idx) {
61+
RRNode &getVWire(int idx) { // 获得FPGA块的垂直导线
6162
assert((size_t) idx < vWires.size());
6263
return *(vWires[idx]);
6364
}
6465

65-
RRNode &getHWire(int idx) {
66+
RRNode &getHWire(int idx) { // 获得FPGA块的水平导线
6667
assert((size_t) idx < hWires.size());
6768
return *(hWires[idx]);
6869
}

lab3/Net.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ class Net{
1313
virtual ~Net();
1414

1515
private:
16-
RRNode &source;
17-
int idx;
18-
set<RRNode *> sinks;
19-
set<RRNode *> usedRRs;
16+
RRNode &source; // net的起始引脚
17+
int idx; // net编号
18+
set<RRNode *> sinks; // net的目标引脚数组
19+
set<RRNode *> usedRRs; // 布线的路径
2020

2121
public:
22-
void addSink(RRNode &dest);
23-
RRNode &getSource() { return source; }
24-
std::set<RRNode *> &getSinks() { return sinks; }
25-
void finalizeRouting();
26-
27-
void clearPath() { usedRRs.clear(); }
28-
void addRRToPath(RRNode &node) { usedRRs.insert(&node); }
29-
std::set<RRNode *> &getPath() { return usedRRs; }
30-
int getIdx() { return idx; }
31-
bool verifyRouting();
22+
void addSink(RRNode &dest); // 添加目标引脚
23+
RRNode &getSource() { return source; } // 获得起始引脚
24+
std::set<RRNode *> &getSinks() { return sinks; } // 获得目标引脚数组
25+
void finalizeRouting(); // 根据布线的路径设置布线资源节点所属的net
26+
27+
void clearPath() { usedRRs.clear(); } // 清空路径
28+
void addRRToPath(RRNode &node) { usedRRs.insert(&node); } // 给布线路径添加node
29+
std::set<RRNode *> &getPath() { return usedRRs; } // 获得布线路径
30+
int getIdx() { return idx; } // 获得net的编号
31+
bool verifyRouting(); // 检查布线是否成功
3232
};
3333

3434
#endif

lab3/RRNode.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@ class Net;
1212
class RRNode{
1313
public:
1414
enum rrType { H_WIRE, V_WIRE, CB_WIRE };
15-
const char *rrTypeStr[3] = {"H_WIRE", "V_WIRE", "CB_WIRE"};
15+
const char *rrTypeStr[3] = {"H_WIRE", "V_WIRE", "CB_WIRE"}; // 分别对应水平导线,垂直导线,逻辑块引脚
1616

1717
RRNode(rrType type, int x, int y, int idx);
1818
virtual ~RRNode();
1919

2020
private:
21-
vector<RRNode *> connections;
22-
rrType type;
23-
int x;
24-
int y;
25-
int idx;
26-
Net *net;
21+
vector<RRNode *> connections; // 该布线资源节点与其他布线资源节点的连接关系
22+
rrType type; // 布线资源节点类型
23+
int x; // 布线资源节点所属的FPGA块的x坐标
24+
int y; // 布线资源节点所属的FPGA块的y坐标
25+
int idx; // 布线资源节点编号
26+
Net *net; // 布线资源节点所属的net
2727

2828
public:
29-
void connect(RRNode &node);
30-
bool isConnected(RRNode &node);
31-
rrType getType() { return type; }
32-
int getX() { return x; }
33-
int getY() { return y; }
34-
int getIdx() { return idx; }
35-
36-
bool isUsed() { return net != nullptr; }
37-
void setNet(Net &net);
38-
Net *getNet() { return net; }
39-
std::vector<RRNode *> &getConnections() { return connections; }
29+
void connect(RRNode &node); // 将该布线资源节点与node连接
30+
bool isConnected(RRNode &node); // 检查该布线资源节点是否与node连接
31+
rrType getType() { return type; } // 获得布线资源节点类型
32+
int getX() { return x; } // 获得布线资源节点的x坐标
33+
int getY() { return y; } // 获得布线资源节点的y坐标
34+
int getIdx() { return idx; } // 获得布线资源节点的编号
35+
36+
bool isUsed() { return net != nullptr; } // 检查布线资源节点是否已使用
37+
void setNet(Net &net); // 设置该布线资源节点所属的net
38+
Net *getNet() { return net; } // 获得该布线资源节点所属的net
39+
std::vector<RRNode *> &getConnections() { return connections; } // 获得该布线资源节点与其他布线资源节点的连接关系
4040

4141
friend std::ostream &operator<<(std::ostream &out, RRNode const &node) {
4242
out << "RRNode (" << node.x << ", " << node.y << ")."

0 commit comments

Comments
 (0)