forked from cdkersey/chdl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode.h
53 lines (38 loc) · 1.41 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
// The basic node type is merely an array index to the master array of nodeimpl
// pointers. This makes it easy to copy about and also to change the underlying
// implementation. Any optimizations invalidate all still-in-use node objects,
// and must only be called after the design has been fully entered.
#ifndef __NODE_H
#define __NODE_H
#include <map>
#include <set>
#include <stdlib.h>
namespace chdl {
typedef unsigned long nodeid_t;
const nodeid_t NO_NODE(~nodeid_t(0));
nodeid_t nodecount();
class node {
public:
// Sets the default index to an improbable value so attempts to use this as
// a valid node will fail.
node();
node(nodeid_t i);
node(const node &r);
virtual ~node();
operator nodeid_t() const { return idx; }
// Our weird overloaded assignment operator can actually be const, since we
// don't directly change the idx of this object through the this pointer.
const node &operator=(const node &r) const;
node &operator=(const node &r);
void change_net(nodeid_t i);
void check() const { if (idx != NO_NODE && idx > nodecount()) abort(); }
protected:
nodeid_t idx;
};
// Get all of the nodeids of nodeimpls to which no node points.
void get_dead_nodes(std::set<nodeid_t> &s);
// Given a map from old node id to new node id, rearrange all of the nodes to
// fit.
void permute_nodes(std::map<nodeid_t, nodeid_t> x);
};
#endif