-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathbdd_tag.h
69 lines (58 loc) · 1.49 KB
/
bdd_tag.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
//! Implements a data structure for sets.
// TODO: Mutex, support mutiple thread
#ifndef BDD_TAG_H
#define BDD_TAG_H
#include <algorithm>
#include <stdint.h>
#include <string>
#include <vector>
#define BDD_LB_WIDTH 24
#define BDD_LEN_LB 0xF0000000
#define BDD_LB_MASK 0x0FFFFFFF
#define BDD_HAS_LEN_LB(lb) (lb >= BDD_LEN_LB)
#define BDD_CLEAR_LEN_MASK(lb) (lb = lb & BDD_LB_MASK)
#ifndef BDD_TAG_SEG
#define BDD_TAG_SEG
typedef uint32_t lb_type;
typedef uint32_t tag_off;
struct tag_seg {
bool sign;
tag_off begin;
tag_off end;
};
#endif
class TagNode {
public:
lb_type left;
lb_type right;
lb_type parent;
tag_seg seg; // offset of this segement
TagNode(lb_type p, tag_off begin, tag_off end) {
parent = p;
left = 0;
right = 0;
seg.sign = false;
seg.begin = begin;
seg.end = end;
};
unsigned int get_seg_size() { return (seg.end - seg.begin); }
};
class BDDTag {
private:
std::vector<TagNode> nodes;
void dfs_clear(TagNode *cur_node);
lb_type alloc_node(lb_type parent, tag_off begin, tag_off end);
lb_type insert_n_zeros(lb_type cur_lb, size_t num, lb_type last_one_lb);
lb_type insert_n_ones(lb_type cur_lb, size_t num, lb_type last_one_lb);
public:
BDDTag();
~BDDTag();
lb_type insert(tag_off pos);
void set_sign(lb_type lb);
bool get_sign(lb_type lb);
void set_size(lb_type lb, size_t size);
lb_type combine(lb_type lb1, lb_type lb2);
const std::vector<tag_seg> find(lb_type lb);
std::string to_string(lb_type lb);
};
#endif // LABEL_SET_H