source: soft/giet_vm/giet_python/genmap@ 673

Last change on this file since 673 was 673, checked in by guerin, 11 years ago

raycast: initial port

Raycast is a small game that looks like Wolfenstein 3D. I created
it for my SESI project, on a Cortex M4 devboard.

Imported from
github.com/libcg/tiva-c/tree/master/boards/dk-tm4c129x/upmc_raycast

  • Property svn:executable set to *
File size: 14.1 KB
Line 
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
46from optparse import OptionParser
47from mapping import *
48
49import sys
50
51###################################################################################
52# define command line arguments
53###################################################################################
54
55parser = OptionParser()
56
57parser.add_option( '--arch', type = 'string', dest = 'arch_path',
58 help = 'define pathname to architecture' )
59
60parser.add_option( '--x', type = 'int', dest = 'x_size',
61 default = 2,
62 help = 'define number of clusters in a row' )
63
64parser.add_option( '--y', type = 'int', dest = 'y_size',
65 default = 2,
66 help = 'define number of clusters in a column' )
67
68parser.add_option( '--p', type = 'int', dest = 'nb_procs',
69 default = 2,
70 help = 'define number of processors per cluster' )
71
72parser.add_option( '--tty', type = 'int', dest = 'nb_ttys',
73 default = 1,
74 help = 'define number of tty channels' )
75
76parser.add_option( '--fbf', type = 'int', dest = 'fbf_size',
77 default = 128,
78 help = 'define frame buffer width and heigth' )
79
80parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
81 default = 'BDV',
82 help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
83
84parser.add_option( '--v', action = 'store_true', dest = 'verbose',
85 default = False,
86 help = 'display detailed report on map.bin file generation' )
87
88parser.add_option( '--netbsd', type = 'string', dest = 'netbsd_path',
89 help = 'define pathname for the netbsd.dts file' )
90
91parser.add_option( '--linux', type = 'string', dest = 'linux_path',
92 help = 'define pathname for the linux.dts file' )
93
94parser.add_option( '--almos', type = 'string', dest = 'almos_path',
95 help = 'define pathname for the arch.bib file' )
96
97parser.add_option( '--giet', type = 'string', dest = 'giet_path',
98 help = 'define pathname for the map.bin & vsegs.ld file ' )
99
100parser.add_option( '--hard', type = 'string', dest = 'hard_path',
101 help = 'define pathname for the hard_config.h file ' )
102
103parser.add_option( '--xml', type = 'string', dest = 'xml_path',
104 help = 'define pathname for the map.xml file' )
105
106############ supported applications ############################################
107
108parser.add_option( '--classif', action = 'store_true', dest = 'classif',
109 default = False,
110 help = 'map the "classif" application for the GietVM' )
111
112parser.add_option( '--convol', action = 'store_true', dest = 'convol',
113 default = False,
114 help = 'map the "convol" application for the GietVM' )
115
116parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',
117 default = False,
118 help = 'map the "coproc" application for the GietVM' )
119
120parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',
121 default = False,
122 help = 'map the "dhrystone" application for the GietVM' )
123
124parser.add_option( '--display', action = 'store_true', dest = 'display',
125 default = False,
126 help = 'map the "display" application for the GietVM' )
127
128parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',
129 default = False,
130 help = 'map the "gameoflife" application for the GietVM' )
131
132parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',
133 default = False,
134 help = 'map the "ocean" application for the GietVM' )
135
136parser.add_option( '--raycast', action = 'store_true', dest = 'raycast',
137 default = False,
138 help = 'map the "raycast" application for the GietVM' )
139
140parser.add_option( '--router', action = 'store_true', dest = 'router',
141 default = False,
142 help = 'map the "router" application for the GietVM' )
143
144parser.add_option( '--shell', action = 'store_true', dest = 'shell',
145 default = False,
146 help = 'map the "shell" application for the GietVM' )
147
148parser.add_option( '--sort', action = 'store_true', dest = 'sort',
149 default = False,
150 help = 'map the "sort" application for the GietVM' )
151
152parser.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
162x_size = options.x_size # number of clusters in a row
163y_size = options.y_size # number of clusters in a column
164nb_procs = options.nb_procs # number of processors in a cluster
165nb_ttys = options.nb_ttys # number of TTY channels
166fbf_size = options.fbf_size # frame buffer width & heigth
167ioc_type = options.ioc_type # ioc controller type
168
169verbose = options.verbose # report on map.bin generation if True
170
171netbsd_path = options.netbsd_path # path for netbsd.dts file
172linux_path = options.linux_path # path for linux.dts file
173almos_path = options.almos_path # path for arch.bib file
174giet_path = options.giet_path # path for map.bin & vsegs.ld files
175hard_path = options.hard_path # path for the hard_config.h file
176
177arch_path = options.arch_path # path to selected architecture
178
179xml_path = options.xml_path # path for map.xml file
180
181map_classif = options.classif # map "classif" application if True
182map_convol = options.convol # map "convol" application if True
183map_coproc = options.coproc # map "coproc" application if True
184map_dhrystone = options.dhrystone # map "dhrystone" application if True
185map_display = options.display # map "display" application if True
186map_gameoflife = options.gameoflife # map "gameoflife" application if True
187map_ocean = options.ocean # map "ocean" application if True
188map_raycast = options.raycast # map "raycast" application if True
189map_router = options.router # map "router" application if True
190map_shell = options.shell # map "shell" application if True
191map_sort = options.sort # map "sort" application if True
192map_transpose = options.transpose # map "transpose" application if True
193
194###################################################################################
195# build empty platform (no applications yet)
196###################################################################################
197
198if ( 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)
203sys.path.append( arch_path )
204
205# dynamically import the PYTHON mapping generator module (file name)
206select = __import__( 'arch' )
207
208# build mapping calling the function (function name)
209mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type )
210print '[genmap] platform %s build' % mapping.name
211
212###################################################################################
213# extend mapping with application(s) as required
214###################################################################################
215
216if ( map_classif ):
217 appli = __import__( 'classif' )
218 appli.extend( mapping )
219 print '[genmap] application "classif" will be loaded'
220
221if ( map_convol ):
222 appli = __import__( 'convol' )
223 appli.extend( mapping )
224 print '[genmap] application "convol" will be loaded'
225
226if ( map_coproc ):
227 appli = __import__( 'coproc' )
228 appli.extend( mapping )
229 print '[genmap] application "coproc" will be loaded'
230
231if ( map_dhrystone ):
232 appli = __import__( 'dhrystone' )
233 appli.extend( mapping )
234 print '[genmap] application "dhrystone" will be loaded'
235
236if ( map_display ):
237 appli = __import__( 'display' )
238 appli.extend( mapping )
239 print '[genmap] application "display" will be loaded'
240
241if ( map_gameoflife ):
242 appli = __import__( 'gameoflife' )
243 appli.extend( mapping )
244 print '[genmap] application "gameoflife" will be loaded'
245
246if ( map_ocean ):
247 appli = __import__( 'ocean' )
248 appli.extend( mapping )
249 print '[genmap] application "ocean" will be loaded'
250
251if ( map_raycast ):
252 appli = __import__( 'raycast' )
253 appli.extend( mapping )
254 print '[genmap] application "raycast" will be loaded'
255
256if ( map_router ):
257 appli = __import__( 'router' )
258 appli.extend( mapping )
259 print '[genmap] application "router" will be loaded'
260
261if ( map_shell ):
262 appli = __import__( 'shell' )
263 appli.extend( mapping )
264 print '[geneap] application "shell" will be loaded'
265
266if ( map_sort ):
267 appli = __import__( 'sort' )
268 appli.extend( mapping )
269 print '[genmap] application "sort" will be loaded'
270
271if ( 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
281if ( 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
292if ( (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
303if ( (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
314if ( (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
325if ( (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
346if ( 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
Note: See TracBrowser for help on using the repository browser.