source: soft/giet_vm/giet_python/genmap @ 731

Last change on this file since 731 was 729, checked in by alain, 9 years ago

Introduce application mjpeg in genmap.

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