-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_clock_tree_instance.py
More file actions
executable file
·71 lines (53 loc) · 1.96 KB
/
create_clock_tree_instance.py
File metadata and controls
executable file
·71 lines (53 loc) · 1.96 KB
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
#!/usr/bin/env python3
from graph.core import *
from graph.load_xml import load_graph_types_and_instances
from graph.save_xml_stream import save_graph
import sys
import os
import math
import os
appBase=os.path.dirname(os.path.realpath(__file__))
src=appBase+"/clock_tree_graph_type.xml"
(graphTypes,graphInstances)=load_graph_types_and_instances(src,src)
d=4
b=2
maxTicks=100
if len(sys.argv)>1:
d=int(sys.argv[1])
if len(sys.argv)>2:
b=int(sys.argv[2])
if len(sys.argv)>3:
maxTicks=int(sys.argv[3])
graphType=graphTypes["clock_tree"]
rootType=graphType.device_types["root"]
branchType=graphType.device_types["branch"]
leafType=graphType.device_types["leaf"]
#listenerType=graphType.device_types["output_listener"]
instName="clock_{}_{}".format(d,b)
properties={"max_ticks":maxTicks}
res=GraphInstance(instName, graphType, properties)
nodes={}
def create(prefix, parent,depth):
node=None
if depth==0:
node=DeviceInstance(res, "{}_leaf".format(prefix), leafType, None, None)
res.add_device_instance(node)
res.add_edge_instance(EdgeInstance(res,node,"tick_in",parent,"tick_out", None))
res.add_edge_instance(EdgeInstance(res,parent,"ack_in",node,"ack_out",None))
else:
if depth==d:
node=DeviceInstance(res, prefix, rootType, {"fanout":b}, None)
else:
node=DeviceInstance(res, prefix, branchType, {"fanout":b}, None)
res.add_device_instance(node)
for i in range(b):
child=create("{}_{}".format(prefix,i), node, depth-1)
if depth!=d:
res.add_edge_instance(EdgeInstance(res,node,"tick_in", parent, "tick_out", None))
res.add_edge_instance(EdgeInstance(res,parent,"ack_in", node,"ack_out", None))
return node
root=create("root",None,d)
#listener=DeviceInstance(res, "listener", listenerType)
#res.add_device_instance(listener)
#res.add_edge_instance(EdgeInstance(res,listener,"on_root_output",root,"output"))
save_graph(res,sys.stdout)