-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_clock_tree_instance_stream.py
More file actions
executable file
·68 lines (52 loc) · 1.81 KB
/
create_clock_tree_instance_stream.py
File metadata and controls
executable file
·68 lines (52 loc) · 1.81 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
#!/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
from graph.build_xml_stream import make_xml_stream_builder
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}
sink=make_xml_stream_builder(sys.stdout,require_interleave=True)
assert sink.can_interleave
nodes={}
def create(prefix, parent,depth):
node=None
if depth==0:
node=sink.add_device_instance(f"{prefix}_leaf", leafType)
sink.add_edge_instance(node,"tick_in",parent,"tick_out")
sink.add_edge_instance(parent,"ack_in",node,"ack_out")
else:
if depth==d:
node=sink.add_device_instance(prefix, rootType, properties={"fanout":b})
else:
node=sink.add_device_instance(prefix, branchType, properties={"fanout":b})
for i in range(b):
child=create(f"{prefix}_{i}", node, depth-1)
if depth!=d:
sink.add_edge_instance(node,"tick_in", parent, "tick_out")
sink.add_edge_instance(parent,"ack_in", node,"ack_out")
return node
sink.begin_graph_instance(instName, graphType, properties=properties)
root=create("root",None,d)
sink.end_device_instances()
sink.end_graph_instance()