-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtemplate.xml
More file actions
172 lines (142 loc) · 6.28 KB
/
template.xml
File metadata and controls
172 lines (142 loc) · 6.28 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@ set device_name = device.get('name', 'node')
@ set software_buffer_size = params.get('sbufsize', 1000)
<?xml version="1.0"?>
<Graphs xmlns="https://poets-project.org/schemas/virtual-graph-schema-v2">
<GraphType id="{{ type }}">
<Documentation>{{ doc }}</Documentation>
<MetaData>"native_dimension":2</MetaData>
<Properties/>
<SharedCode>
<![CDATA[
#define SOFTWARE_BUFF_SIZE {{ software_buffer_size }}
{{ include('shared.c') }}
{{ include_app('shared.c', optional=True) }}
]]>
</SharedCode>
<MessageTypes>
<MessageType id="__init__">
<Documentation>Initialize state</Documentation>
</MessageType>
@ for id, content in messages.items()
<MessageType id="{{ id }}">
<Documentation>{{ content['doc'] }}</Documentation>
<Message>
<Scalar type="uint32_t" name="src">
<Documentation>Source node id</Documentation>
</Scalar>
<Scalar type="uint32_t" name="dst">
<Documentation>Destination node id</Documentation>
</Scalar>
@ set field_items = content.get('fields', {}).items()
@ for fd_id, fd_content in field_items
@ set fd_type = fd_content.get('type', 'uint32_t')
<Scalar type="{{ fd_type }}" name="{{ fd_id }}">
@ if 'doc' in fd_content
<Documentation>
{{- fd_content['doc'] -}}
</Documentation>
@ endif
</Scalar>
@ endfor
</Message>
</MessageType>
@ endfor
</MessageTypes>
<DeviceTypes>
<!-- Generated Block -->
<DeviceType id="{{ device_name }}">
<Properties>
<Scalar name="id" type="uint32_t"></Scalar>
<Scalar name="outdegree" type="uint32_t"></Scalar>
@ set property_items = device.get('properties', {}).items()
@ for p_id, p_content in property_items
@ set p_type = p_content.get('type', 'uint32_t')
@ set p_length = get_field_length(p_content)
@ set is_array = p_length > 1
@ if is_array
<Array name="{{ p_id }}" type="{{ p_type }}" length="{{ p_length }}"></Array>
@ else
<Scalar name="{{ p_id }}" type="{{ p_type }}"></Scalar>
@ endif
@ endfor
@ for p_id, p_content in props.get(device_name, {}).items()
@ set p_type = p_content.get('type', 'uint32_t')
<Scalar name="{{ p_id }}" type="{{ p_type }}"></Scalar>
@endfor
</Properties>
<State>
<!-- Device state fields: -->
@ for s_id, s_content in device['state'].items()
@ set p_type = s_content.get('type', 'uint32_t')
@ set s_length = get_field_length(s_content)
@ set is_array = s_length > 1
@ if is_array
<Array name="{{ s_id }}" type="{{ p_type }}" length="{{ s_length }}"></Array>
@ else
<Scalar name="{{ s_id }}" type="{{ p_type }}"></Scalar>
@ endif
@ endfor
@ for id, content in messages.items()
<!-- Software buffer for (outgoing) {{ id }} messages: -->
<Array name="{{ id }}_buffer_dst" type="uint32_t" length="{{ software_buffer_size }}"></Array>
<Scalar name="{{ id }}_buffer_ptr" type="uint32_t"></Scalar>
@ set field_items = content.get('fields', {}).items()
@ for fd_id, fd_content in field_items
<Array name="{{ id }}_buffer_{{ fd_id }}" type="{{ fd_content.get('type', 'uint32_t') }}" length="{{ software_buffer_size }}"></Array>
@ endfor
@ endfor
</State>
<ReadyToSend>
<![CDATA[
{{ include('ready_to_send.c') }}
]]>
</ReadyToSend>
<InputPin messageTypeId="__init__" name="__init__">
<OnReceive>
<![CDATA[
{{ include_app('init.c', optional=True) }}
]]>
</OnReceive>
</InputPin>
@ for msg, content in messages.items()
<InputPin messageTypeId="{{ msg }}" name="{{ msg }}_in">
<OnReceive>
<![CDATA[
{{ include_app('receive_%s.c' % msg) }}
]]>
</OnReceive>
</InputPin>
<OutputPin messageTypeId="{{ msg }}" name="{{ msg }}_out">
<OnSend>
<![CDATA[
{{ include('send_handler.c', msg=msg, fields=content.get('fields', {} )) }}
]]>
</OnSend>
</OutputPin>
@ endfor
</DeviceType>
</DeviceTypes>
</GraphType>
<GraphInstance id="graph1" graphTypeId="{{ type }}">
<DeviceInstances>
@ for node in graph.nodes
<DevI id="{{ node }}" type="node">
<P>
"id": {{ loop.index0 }},
"outdegree": {{ graph.get_outdegree(node) }}
@ for p_id, p_content in props.get(device_name, {}).items()
, "{{ p_id }}": {{ p_content['values'][node] }}
@ endfor
</P>
</DevI>
@ endfor
</DeviceInstances>
<EdgeInstances>
@ for src, dst in graph.get_edge_list()
@ for msg in messages.keys()
<EdgeI path="{{ dst }}:{{ msg }}_in-{{ src }}:{{ msg }}_out"/>
@ endfor
@ endfor
</EdgeInstances>
</GraphInstance>
</Graphs>