-
Notifications
You must be signed in to change notification settings - Fork 408
/
Copy pathdepth.c
50 lines (38 loc) · 843 Bytes
/
depth.c
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
#include "ace.h"
#include "depth.h"
#include "base/abc/abc.h"
int calc_depth(Abc_Obj_t * obj);
int calc_depth(Abc_Obj_t * obj) {
int i, depth;
Abc_Obj_t * fanin;
depth = 0;
switch (Abc_ObjType(obj)) {
case ABC_OBJ_NODE:
case ABC_OBJ_PO:
case ABC_OBJ_BI:
Abc_ObjForEachFanin(obj, fanin, i)
{
Ace_Obj_Info_t * fanin_info = Ace_ObjInfo(fanin);
depth = MAX(depth, fanin_info->depth);
}
return (depth + 1);
default:
return 0;
}
}
int ace_calc_network_depth(Abc_Ntk_t * ntk) {
int i, depth;
Abc_Obj_t * obj;
Vec_Ptr_t * nodes;
//nodes = Abc_NtkDfsSeq(ntk);
nodes = Abc_NtkDfs(ntk, TRUE);
depth = 0;
Vec_PtrForEachEntry(Abc_Obj_t*, nodes, obj, i)
{
Ace_Obj_Info_t * info = Ace_ObjInfo(obj);
info->depth = calc_depth(obj);
depth = MAX(depth, info->depth);
}
Vec_PtrFree(nodes);
return depth;
}