1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | ################################################################################### |
---|
4 | # file : genmap |
---|
5 | # date : april 2014 |
---|
6 | # author : Alain Greiner |
---|
7 | ################################################################################### |
---|
8 | # This generic script maps one or several applications on a specific |
---|
9 | # instance of the multi-processors/multi-clusters TSAR architecture. |
---|
10 | # It generates the files required for hardware and software compilation: |
---|
11 | # 1) The "hard_config.h" file is used to generate the top.cpp file (hardware), |
---|
12 | # and to compile the tsar_preloader.elf, GietVM boot.elf and kernel.elf files. |
---|
13 | # 2) The optionals "map.bin" and vsegs.ld" files are used to configure the GietVM. |
---|
14 | # 3) The optional "netbsd.dts" file can be used to configure NetBSD. |
---|
15 | # 4) The optional "netbsd.dts" file can be used to configure NetBSD. |
---|
16 | # 5) The optional "arch.bib" file can be used to configure ALMOS. |
---|
17 | # 6) An optional "map.xml" file can be generated for debug. |
---|
18 | ################################################################################### |
---|
19 | # The hardware parameters are: |
---|
20 | # - x_size : number of clusters in a row |
---|
21 | # - y_size : number of clusters in a column |
---|
22 | # - nb_procs : number of processors per cluster |
---|
23 | # - nb_ttys : number of TTY channels |
---|
24 | # - fbf_size : frame buffer width & heigth |
---|
25 | ################################################################################### |
---|
26 | # The supported platforms are: |
---|
27 | # - tsar_generic_iob |
---|
28 | # - tsar_generic_leti |
---|
29 | # - tsar_geberic_mwmr |
---|
30 | ################################################################################### |
---|
31 | # The supported applications are: |
---|
32 | # - classif |
---|
33 | # - convol |
---|
34 | # - coproc |
---|
35 | # - dhrystone |
---|
36 | # - display |
---|
37 | # - gameoflife |
---|
38 | # - ocean |
---|
39 | # - raycast |
---|
40 | # - router |
---|
41 | # - sort |
---|
42 | # - shell |
---|
43 | # - transpose |
---|
44 | ################################################################################### |
---|
45 | |
---|
46 | from optparse import OptionParser |
---|
47 | from mapping import * |
---|
48 | |
---|
49 | import sys |
---|
50 | |
---|
51 | ################################################################################### |
---|
52 | # define command line arguments |
---|
53 | ################################################################################### |
---|
54 | |
---|
55 | parser = OptionParser() |
---|
56 | |
---|
57 | parser.add_option( '--arch', type = 'string', dest = 'arch_path', |
---|
58 | help = 'define pathname to architecture' ) |
---|
59 | |
---|
60 | parser.add_option( '--x', type = 'int', dest = 'x_size', |
---|
61 | default = 2, |
---|
62 | help = 'define number of clusters in a row' ) |
---|
63 | |
---|
64 | parser.add_option( '--y', type = 'int', dest = 'y_size', |
---|
65 | default = 2, |
---|
66 | help = 'define number of clusters in a column' ) |
---|
67 | |
---|
68 | parser.add_option( '--p', type = 'int', dest = 'nb_procs', |
---|
69 | default = 2, |
---|
70 | help = 'define number of processors per cluster' ) |
---|
71 | |
---|
72 | parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', |
---|
73 | default = 1, |
---|
74 | help = 'define number of tty channels' ) |
---|
75 | |
---|
76 | parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', |
---|
77 | default = 128, |
---|
78 | help = 'define frame buffer width and heigth' ) |
---|
79 | |
---|
80 | parser.add_option( '--ioc', type = 'string', dest = 'ioc_type', |
---|
81 | default = 'BDV', |
---|
82 | help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' ) |
---|
83 | |
---|
84 | parser.add_option( '--v', action = 'store_true', dest = 'verbose', |
---|
85 | default = False, |
---|
86 | help = 'display detailed report on map.bin file generation' ) |
---|
87 | |
---|
88 | parser.add_option( '--netbsd', type = 'string', dest = 'netbsd_path', |
---|
89 | help = 'define pathname for the netbsd.dts file' ) |
---|
90 | |
---|
91 | parser.add_option( '--linux', type = 'string', dest = 'linux_path', |
---|
92 | help = 'define pathname for the linux.dts file' ) |
---|
93 | |
---|
94 | parser.add_option( '--almos', type = 'string', dest = 'almos_path', |
---|
95 | help = 'define pathname for the arch.bib file' ) |
---|
96 | |
---|
97 | parser.add_option( '--giet', type = 'string', dest = 'giet_path', |
---|
98 | help = 'define pathname for the map.bin & vsegs.ld file ' ) |
---|
99 | |
---|
100 | parser.add_option( '--hard', type = 'string', dest = 'hard_path', |
---|
101 | help = 'define pathname for the hard_config.h file ' ) |
---|
102 | |
---|
103 | parser.add_option( '--xml', type = 'string', dest = 'xml_path', |
---|
104 | help = 'define pathname for the map.xml file' ) |
---|
105 | |
---|
106 | ############ supported applications ############################################ |
---|
107 | |
---|
108 | parser.add_option( '--classif', action = 'store_true', dest = 'classif', |
---|
109 | default = False, |
---|
110 | help = 'map the "classif" application for the GietVM' ) |
---|
111 | |
---|
112 | parser.add_option( '--convol', action = 'store_true', dest = 'convol', |
---|
113 | default = False, |
---|
114 | help = 'map the "convol" application for the GietVM' ) |
---|
115 | |
---|
116 | parser.add_option( '--coproc', action = 'store_true', dest = 'coproc', |
---|
117 | default = False, |
---|
118 | help = 'map the "coproc" application for the GietVM' ) |
---|
119 | |
---|
120 | parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone', |
---|
121 | default = False, |
---|
122 | help = 'map the "dhrystone" application for the GietVM' ) |
---|
123 | |
---|
124 | parser.add_option( '--display', action = 'store_true', dest = 'display', |
---|
125 | default = False, |
---|
126 | help = 'map the "display" application for the GietVM' ) |
---|
127 | |
---|
128 | parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife', |
---|
129 | default = False, |
---|
130 | help = 'map the "gameoflife" application for the GietVM' ) |
---|
131 | |
---|
132 | parser.add_option( '--ocean', action = 'store_true', dest = 'ocean', |
---|
133 | default = False, |
---|
134 | help = 'map the "ocean" application for the GietVM' ) |
---|
135 | |
---|
136 | parser.add_option( '--raycast', action = 'store_true', dest = 'raycast', |
---|
137 | default = False, |
---|
138 | help = 'map the "raycast" application for the GietVM' ) |
---|
139 | |
---|
140 | parser.add_option( '--router', action = 'store_true', dest = 'router', |
---|
141 | default = False, |
---|
142 | help = 'map the "router" application for the GietVM' ) |
---|
143 | |
---|
144 | parser.add_option( '--shell', action = 'store_true', dest = 'shell', |
---|
145 | default = False, |
---|
146 | help = 'map the "shell" application for the GietVM' ) |
---|
147 | |
---|
148 | parser.add_option( '--sort', action = 'store_true', dest = 'sort', |
---|
149 | default = False, |
---|
150 | help = 'map the "sort" application for the GietVM' ) |
---|
151 | |
---|
152 | parser.add_option( '--transpose', action = 'store_true', dest = 'transpose', |
---|
153 | default = False, |
---|
154 | help = 'map the "transpose" application for the GietVM' ) |
---|
155 | |
---|
156 | ################################################################################### |
---|
157 | # Get command line arguments |
---|
158 | ################################################################################### |
---|
159 | |
---|
160 | (options,args) = parser.parse_args() |
---|
161 | |
---|
162 | x_size = options.x_size # number of clusters in a row |
---|
163 | y_size = options.y_size # number of clusters in a column |
---|
164 | nb_procs = options.nb_procs # number of processors in a cluster |
---|
165 | nb_ttys = options.nb_ttys # number of TTY channels |
---|
166 | fbf_size = options.fbf_size # frame buffer width & heigth |
---|
167 | ioc_type = options.ioc_type # ioc controller type |
---|
168 | |
---|
169 | verbose = options.verbose # report on map.bin generation if True |
---|
170 | |
---|
171 | netbsd_path = options.netbsd_path # path for netbsd.dts file |
---|
172 | linux_path = options.linux_path # path for linux.dts file |
---|
173 | almos_path = options.almos_path # path for arch.bib file |
---|
174 | giet_path = options.giet_path # path for map.bin & vsegs.ld files |
---|
175 | hard_path = options.hard_path # path for the hard_config.h file |
---|
176 | |
---|
177 | arch_path = options.arch_path # path to selected architecture |
---|
178 | |
---|
179 | xml_path = options.xml_path # path for map.xml file |
---|
180 | |
---|
181 | map_classif = options.classif # map "classif" application if True |
---|
182 | map_convol = options.convol # map "convol" application if True |
---|
183 | map_coproc = options.coproc # map "coproc" application if True |
---|
184 | map_dhrystone = options.dhrystone # map "dhrystone" application if True |
---|
185 | map_display = options.display # map "display" application if True |
---|
186 | map_gameoflife = options.gameoflife # map "gameoflife" application if True |
---|
187 | map_ocean = options.ocean # map "ocean" application if True |
---|
188 | map_raycast = options.raycast # map "raycast" application if True |
---|
189 | map_router = options.router # map "router" application if True |
---|
190 | map_shell = options.shell # map "shell" application if True |
---|
191 | map_sort = options.sort # map "sort" application if True |
---|
192 | map_transpose = options.transpose # map "transpose" application if True |
---|
193 | |
---|
194 | ################################################################################### |
---|
195 | # build empty platform (no applications yet) |
---|
196 | ################################################################################### |
---|
197 | |
---|
198 | if ( arch_path == None ): |
---|
199 | print 'You must select a generic architecture on the command line' |
---|
200 | sys.exit(1) |
---|
201 | |
---|
202 | # dynamically append the architecture to PYTHON path (directory pathname) |
---|
203 | sys.path.append( arch_path ) |
---|
204 | |
---|
205 | # dynamically import the PYTHON mapping generator module (file name) |
---|
206 | select = __import__( 'arch' ) |
---|
207 | |
---|
208 | # build mapping calling the function (function name) |
---|
209 | mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type ) |
---|
210 | print '[genmap] platform %s build' % mapping.name |
---|
211 | |
---|
212 | ################################################################################### |
---|
213 | # extend mapping with application(s) as required |
---|
214 | ################################################################################### |
---|
215 | |
---|
216 | if ( map_classif ): |
---|
217 | appli = __import__( 'classif' ) |
---|
218 | appli.extend( mapping ) |
---|
219 | print '[genmap] application "classif" will be loaded' |
---|
220 | |
---|
221 | if ( map_convol ): |
---|
222 | appli = __import__( 'convol' ) |
---|
223 | appli.extend( mapping ) |
---|
224 | print '[genmap] application "convol" will be loaded' |
---|
225 | |
---|
226 | if ( map_coproc ): |
---|
227 | appli = __import__( 'coproc' ) |
---|
228 | appli.extend( mapping ) |
---|
229 | print '[genmap] application "coproc" will be loaded' |
---|
230 | |
---|
231 | if ( map_dhrystone ): |
---|
232 | appli = __import__( 'dhrystone' ) |
---|
233 | appli.extend( mapping ) |
---|
234 | print '[genmap] application "dhrystone" will be loaded' |
---|
235 | |
---|
236 | if ( map_display ): |
---|
237 | appli = __import__( 'display' ) |
---|
238 | appli.extend( mapping ) |
---|
239 | print '[genmap] application "display" will be loaded' |
---|
240 | |
---|
241 | if ( map_gameoflife ): |
---|
242 | appli = __import__( 'gameoflife' ) |
---|
243 | appli.extend( mapping ) |
---|
244 | print '[genmap] application "gameoflife" will be loaded' |
---|
245 | |
---|
246 | if ( map_ocean ): |
---|
247 | appli = __import__( 'ocean' ) |
---|
248 | appli.extend( mapping ) |
---|
249 | print '[genmap] application "ocean" will be loaded' |
---|
250 | |
---|
251 | if ( map_raycast ): |
---|
252 | appli = __import__( 'raycast' ) |
---|
253 | appli.extend( mapping ) |
---|
254 | print '[genmap] application "raycast" will be loaded' |
---|
255 | |
---|
256 | if ( map_router ): |
---|
257 | appli = __import__( 'router' ) |
---|
258 | appli.extend( mapping ) |
---|
259 | print '[genmap] application "router" will be loaded' |
---|
260 | |
---|
261 | if ( map_shell ): |
---|
262 | appli = __import__( 'shell' ) |
---|
263 | appli.extend( mapping ) |
---|
264 | print '[geneap] application "shell" will be loaded' |
---|
265 | |
---|
266 | if ( map_sort ): |
---|
267 | appli = __import__( 'sort' ) |
---|
268 | appli.extend( mapping ) |
---|
269 | print '[genmap] application "sort" will be loaded' |
---|
270 | |
---|
271 | if ( map_transpose ): |
---|
272 | appli = __import__( 'transpose' ) |
---|
273 | appli.extend( mapping ) |
---|
274 | print '[genmap] application "transpose" will be loaded' |
---|
275 | |
---|
276 | ################################################################################### |
---|
277 | # Generate xml file if required. |
---|
278 | # It can be used for debug. |
---|
279 | ################################################################################### |
---|
280 | |
---|
281 | if ( xml_path != None ): |
---|
282 | pathname = xml_path + '/map.xml' |
---|
283 | f = open ( pathname, 'w' ) |
---|
284 | f.write( mapping.xml() ) |
---|
285 | print '[genmap] %s generated for debug' % pathname |
---|
286 | |
---|
287 | ################################################################################### |
---|
288 | # Generate netbsd.dts file if required. |
---|
289 | # It is used for NetBSD configuration. |
---|
290 | ################################################################################### |
---|
291 | |
---|
292 | if ( (netbsd_path != None) and (arch_path != None) ): |
---|
293 | pathname = netbsd_path + '/netbsd.dts' |
---|
294 | f = open ( pathname, 'w' ) |
---|
295 | f.write( mapping.netbsd_dts() ) |
---|
296 | print '[genmap] %s generated' % pathname |
---|
297 | |
---|
298 | ################################################################################### |
---|
299 | # Generate linux.dts file if required. |
---|
300 | # It is used for LINUX configuration. |
---|
301 | ################################################################################### |
---|
302 | |
---|
303 | if ( (linux_path != None) and (arch_path != None) ): |
---|
304 | pathname = linux_path + '/linux.dts' |
---|
305 | f = open ( pathname, 'w' ) |
---|
306 | f.write( mapping.linux_dts() ) |
---|
307 | print '[genmap] %s generated' % pathname |
---|
308 | |
---|
309 | ################################################################################### |
---|
310 | # Generate arch.bib file if required. |
---|
311 | # It is used for ALMOS configuration. |
---|
312 | ################################################################################### |
---|
313 | |
---|
314 | if ( (almos_path != None) and (arch_path != None) ): |
---|
315 | pathname = almos_path + '/arch.info' |
---|
316 | f = open ( pathname, 'w' ) |
---|
317 | f.write( mapping.almos_arch() ) |
---|
318 | print '[genmap] %s generated for almos' % pathname |
---|
319 | |
---|
320 | ################################################################################### |
---|
321 | # Generate map.bin, giet_vsegs.ld, and hard_config.h files if required. |
---|
322 | # They are used for GietVM compilation and configuration. |
---|
323 | ################################################################################### |
---|
324 | |
---|
325 | if ( (giet_path != None) and (arch_path != None) ): |
---|
326 | |
---|
327 | pathname = giet_path + '/map.bin' |
---|
328 | f = open ( pathname, 'w' ) |
---|
329 | f.write( str( mapping.cbin( verbose ) ) ) |
---|
330 | print '[genmap] %s generated for giet_vm' % pathname |
---|
331 | |
---|
332 | pathname = giet_path + '/hard_config.h' |
---|
333 | f = open ( pathname, 'w' ) |
---|
334 | f.write( mapping.hard_config() ) |
---|
335 | print '[genmap] %s generated for giet_vm' % pathname |
---|
336 | |
---|
337 | pathname = giet_path + '/giet_vsegs.ld' |
---|
338 | f = open ( pathname, 'w' ) |
---|
339 | f.write( mapping.giet_vsegs() ) |
---|
340 | print '[genmap] %s generated for giet_vm' % pathname |
---|
341 | |
---|
342 | ################################################################################### |
---|
343 | # Generate hard_config.h file if required. |
---|
344 | ################################################################################### |
---|
345 | |
---|
346 | if ( hard_path != None ): |
---|
347 | |
---|
348 | pathname = hard_path + '/hard_config.h' |
---|
349 | f = open ( pathname, 'w' ) |
---|
350 | f.write( mapping.hard_config() ) |
---|
351 | print '[genmap] %s generated for %s' % (pathname, arch_path) |
---|
352 | |
---|