-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.h
126 lines (99 loc) · 3.36 KB
/
node.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef __NODE_H__
#define __NODE_H__
#include <string>
#include <algorithm>
#include "global.h"
#include "point.h"
#include "net.h"
#include <vector>
#include <iostream>
//#include "block.h"
using namespace std;
class Net;
class Circuit;
// a Node in the network
class Node{
public:
// member functions
Node();
Node(string name, Point _pt, bool flag=false, double v=0.0);
Node(const Node & nd);
Node & operator = (const Node & nd);
void set_nbr(DIRECTION dir, Net * name);
void set_nbr_pad(DIRECTION dir, Net * name);
Net * get_nbr_net(DIRECTION dir) const;
// Ting: get_nbr_node
Node * get_nbr_node(Node *node, DIRECTION dir) const;
Node get_nbr_node(Node node, DIRECTION dir) const;
Node * get_nbr_node(DIRECTION dir) const;
int get_layer() const;
bool isX() const;
bool is_candi() const;
bool is_ground() const;
double get_value() const;
void set_value(double v);
vector<size_t> & get_block_id() const;
bool inside_block(size_t block_id) const;
bool is_mergeable() const;
friend ostream & operator << (ostream & os, const Node & node);
friend class Circuit;
friend class Block;
friend class Parser;
friend class MG_Circuit;
////////////////////////////////////////////////////////////
// member variables
string name; // node name
Point pt; // coordinate
// only 2 possible cases:
// {TOP, BOTTOM, EAST, WEST}
// {TOP, BOTTOM, NORTH, SOUTH}
Net * nbr[6]; // neighboring nets
Net * nbr_pad[4]; // neighboring pad nets
size_t rid; // id in rep_list
private:
double value; // voltage
bool flag; // mark if the node is an X
size_t flag_visited;
// mark if node is a pad candidate
bool flag_candi;
bool critical; // mark if the node is a critical node for IR drop
Node * rep; // representative, if somewhere is short-circuit
vector<size_t> blocklist; // belongs to which block
vector<size_t> id_in_block; // local index inside block
Node * end[4]; // south - north (west-east) ends
double eqvr[4]; // equivalent resisotrs
double power; // power consumed
};
inline bool Node::isX() const{return flag;}
inline bool Node::is_candi() const{return flag_candi;}
//inline bool Node::is_ground() const{return name == "0";}
// use a tricky way to speed up
inline bool Node::is_ground() const{return pt.x<0;}
inline int Node::get_layer() const{ return pt.z; }
inline double Node::get_value() const{return value;}
inline void Node::set_value(double v){value = v;}
inline void Node::set_nbr(DIRECTION dir, Net * net){ nbr[dir] = net; }
inline void Node::set_nbr_pad(DIRECTION dir, Net * net){ nbr_pad[dir] = net; }
inline vector<size_t> & Node::get_block_id() const{return rep->blocklist;}
inline bool Node::inside_block(size_t block_id) const{
vector<size_t>::const_iterator it;
it = find(blocklist.begin(), blocklist.end(), block_id);
if( it == blocklist.end() ) return false;
return true;
}
inline Node * Node::get_nbr_node(DIRECTION dir) const{
if( nbr[dir] == NULL ) return NULL;
Node * nbr_node = nbr[dir]->ab[0];
return (nbr_node != this? nbr_node: nbr[dir]->ab[1]);
}
inline Net * Node::get_nbr_net(DIRECTION dir) const{
return nbr[dir];
}
inline bool Node::is_mergeable() const{
return nbr[TOP] == NULL && nbr[BOTTOM] == NULL &&
((nbr[EAST] != NULL && nbr[WEST] != NULL &&
nbr[NORTH] == NULL && nbr[SOUTH] == NULL)
||(nbr[NORTH] != NULL && nbr[SOUTH] != NULL &&
nbr[EAST] == NULL && nbr[WEST] == NULL));
}
#endif