-
Notifications
You must be signed in to change notification settings - Fork 47
/
diff_finder.hpp
73 lines (54 loc) · 2.5 KB
/
diff_finder.hpp
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
#ifndef DIFF_FINDER_H_
#define DIFF_FINDER_H_
#include "lgraph.hpp"
#include "invariant.hpp"
#include "bitscan/bitscan.h"
class Diff_finder {
private:
LGraph* original;
LGraph* synth;
Invariant_boundaries* boundaries;
std::string hier_sep;
class Graph_Node {
public:
LGraph* module;
Index_ID idx;
uint32_t bit;
std::string instance;
//we need to take into account PIDs for subgraphs
//for primitives, it doesn't matter since most have a single output
Port_ID pid;
Graph_Node(LGraph* module, Index_ID idx, uint32_t bit, std::string instance, Port_ID pid) :
module(module), idx(idx), bit(bit), instance(instance), pid(pid) {
}
Graph_Node() {}
bool operator< (const Graph_Node rhs) const {
return (module < rhs.module) ||
(module == rhs.module && idx < rhs.idx) ||
(module == rhs.module && idx == rhs.idx && pid < rhs.pid) ||
(module == rhs.module && idx == rhs.idx && pid == rhs.pid && bit < rhs.bit) ||
(module == rhs.module && idx == rhs.idx && pid == rhs.pid && bit == rhs.bit && instance < rhs.instance);
}
};
std::map<Graph_Node, std::set<Graph_Node>> cones;
std::map<Graph_Node, bool> different;
std::map<Graph_Node, std::set<Graph_Node> > endpoints;
std::set<Graph_Node> stack;
std::map<Graph_Node, Net_ID> synth_map;
std::map<Graph_Node, std::string> bound2net;
bool is_user_def(LGraph* current, Index_ID idx, Port_ID pid) const;
bool is_invariant(Graph_Node node);
void find_fwd_boundaries(Graph_Node start_boundary, std::set<Graph_Node>& discovered);
bool compare_cone(Graph_Node start_boundary, Graph_Node original_boundary, bool went_up = false);
auto go_up(Graph_Node boundary);
auto go_down(Graph_Node boundary, bool output);
void generate_modules(std::set<Graph_Node> different_nodes, std::string out_lgdb);
void add_ios_up(LGraph* module, Index_ID nid, std::map<std::string, LGraph*>& name2graph);
public:
//FIXME: can we remove the dependency on the synthesized graph?
Diff_finder(LGraph* original, LGraph* synth, Invariant_boundaries* boundaries, std::string hier_sep = ".") :
original(original), synth(synth), boundaries(boundaries), hier_sep(hier_sep) {
}
void generate_delta(std::string mod_lgdb, std::string out_lgdb, std::set<Net_ID>& diffs);
};
#endif