source: soft/giet_vm/giet_python/genmap @ 729

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

Introduce application mjpeg in genmap.

  • Property svn:executable set to *
File size: 14.5 KB
RevLine 
[425]1#!/usr/bin/env python
[319]2
[539]3###################################################################################
[328]4#   file   : genmap
[319]5#   date   : april 2014
6#   author : Alain Greiner
[539]7###################################################################################
[520]8# This generic script maps one or several applications on a specific
[319]9# instance of the multi-processors/multi-clusters TSAR architecture.
10# It generates the files required for hardware and software compilation:
[520]11# 1) The "hard_config.h" file is used to generate the top.cpp file (hardware),
[539]12#    and to compile the tsar_preloader.elf, GietVM boot.elf and kernel.elf files.
[319]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.
[411]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.
[539]18###################################################################################
[319]19# The hardware parameters  are:
20#  - x_size    : number of clusters in a row
21#  - y_size    : number of clusters in a column
[453]22#  - nb_procs  : number of processors per cluster
23#  - nb_ttys   : number of TTY channels
24#  - fbf_size  : frame buffer width & heigth
[539]25###################################################################################
[319]26# The supported platforms are:
27# - tsar_generic_iob
28# - tsar_generic_leti
[520]29# - tsar_geberic_mwmr
[539]30###################################################################################
[462]31# The supported applications are:
[591]32# - classif
[462]33# - convol
[591]34# - coproc
35# - dhrystone
[462]36# - display
[500]37# - gameoflife
[729]38# - mjpeg
[591]39# - ocean
[673]40# - raycast
[591]41# - router
42# - sort
43# - shell
44# - transpose
[539]45###################################################################################
[319]46
47from optparse import OptionParser
48from mapping import *
49
50import sys
51
[539]52###################################################################################
[319]53#   define command line arguments   
[539]54###################################################################################
[319]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
[453]69parser.add_option( '--p', type = 'int', dest = 'nb_procs', 
[319]70                   default = 2,
71                   help = 'define number of processors per cluster' )
72
[453]73parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', 
74                   default = 1,
75                   help = 'define number of tty channels' )
76
[411]77parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', 
78                   default = 128,
79                   help = 'define frame buffer width and heigth' )
80
[546]81parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
82                   default = 'BDV',
[565]83                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
[546]84
[319]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
[411]92parser.add_option( '--linux', type = 'string', dest = 'linux_path', 
93                   help = 'define pathname for the linux.dts file' )
94
[319]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
[401]101parser.add_option( '--hard', type = 'string', dest = 'hard_path',
102                   help = 'define pathname for the hard_config.h file ' )
103
[319]104parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
105                   help = 'define pathname for the map.xml file' )
106
[539]107############  supported applications   ############################################
[319]108
[591]109parser.add_option( '--classif', action = 'store_true', dest = 'classif',     
[319]110                   default = False,
[591]111                   help = 'map the "classif" application for the GietVM' )
[319]112
[338]113parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
[328]114                   default = False,
115                   help = 'map the "convol" application for the GietVM' )
116
[591]117parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',     
[421]118                   default = False,
[591]119                   help = 'map the "coproc" application for the GietVM' )
[421]120
[591]121parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',     
122                   default = False,
123                   help = 'map the "dhrystone" application for the GietVM' )
124
[441]125parser.add_option( '--display', action = 'store_true', dest = 'display',     
126                   default = False,
127                   help = 'map the "display" application for the GietVM' )
128
[500]129parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',     
130                   default = False,
131                   help = 'map the "gameoflife" application for the GietVM' )
132
[729]133parser.add_option( '--mjpeg', action = 'store_true', dest = 'mjpeg',
134                   default = False,
135                   help = 'map the "mjpeg" application for the GietVM' )
136
[580]137parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',     
138                   default = False,
139                   help = 'map the "ocean" application for the GietVM' )
140
[673]141parser.add_option( '--raycast', action = 'store_true', dest = 'raycast',     
142                   default = False,
143                   help = 'map the "raycast" application for the GietVM' )
144
[591]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
[539]161###################################################################################
[319]162#   Get command line arguments
[539]163###################################################################################
[319]164
165(options,args) = parser.parse_args()
166
[500]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
[546]172ioc_type       = options.ioc_type    # ioc controller type
[319]173
[500]174verbose        = options.verbose     # report on map.bin generation if True
[319]175
[500]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
[319]181
[500]182arch_path      = options.arch_path   # path to selected architecture
[319]183
[500]184xml_path       = options.xml_path    # path for map.xml file     
[319]185
[591]186map_classif    = options.classif     # map "classif" application if True
[500]187map_convol     = options.convol      # map "convol" application if True
[591]188map_coproc     = options.coproc      # map "coproc" application if True
189map_dhrystone  = options.dhrystone   # map "dhrystone" application if True
[500]190map_display    = options.display     # map "display" application if True
191map_gameoflife = options.gameoflife  # map "gameoflife" application if True
[729]192map_mjpeg      = options.mjpeg       # map "mjpeg" application if True
[580]193map_ocean      = options.ocean       # map "ocean" application if True
[673]194map_raycast    = options.raycast     # map "raycast" application if True
[591]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
[319]199
[539]200###################################################################################
[319]201#   build empty platform (no applications yet)
[539]202###################################################################################
[319]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)
[338]212select = __import__( 'arch' )
[319]213
214# build mapping calling the function (function name)
[546]215mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type )
[328]216print '[genmap] platform %s build' % mapping.name
[319]217
[539]218###################################################################################
[591]219#   extend mapping with application(s) as required
[539]220###################################################################################
[319]221
[591]222if ( map_classif ):     
223    appli = __import__( 'classif' )
224    appli.extend( mapping )
225    print '[genmap] application "classif" will be loaded'
[319]226
[591]227if ( map_convol ):   
228    appli = __import__( 'convol' )
229    appli.extend( mapping )
[441]230    print '[genmap] application "convol" will be loaded'
[328]231
[591]232if ( map_coproc ):
233    appli = __import__( 'coproc' )
234    appli.extend( mapping )
235    print '[genmap] application "coproc" will be loaded'
[432]236
[591]237if ( map_dhrystone ):     
238    appli = __import__( 'dhrystone' )
239    appli.extend( mapping )
240    print '[genmap] application "dhrystone" will be loaded'
241
[441]242if ( map_display ):     
[591]243    appli = __import__( 'display' )
244    appli.extend( mapping )
[441]245    print '[genmap] application "display" will be loaded'
246
[500]247if ( map_gameoflife ):
[591]248    appli = __import__( 'gameoflife' )
249    appli.extend( mapping )
[500]250    print '[genmap] application "gameoflife" will be loaded'
251
[729]252if ( map_mjpeg ):
253    appli = __import__( 'mjpeg' )
254    appli.extend( mapping )
255    print '[genmap] application "mjpeg" will be loaded'
256
[580]257if ( map_ocean ):
[591]258    appli = __import__( 'ocean' )
259    appli.extend( mapping )
[580]260    print '[genmap] application "ocean" will be loaded'
261
[673]262if ( map_raycast ):     
263    appli = __import__( 'raycast' )
264    appli.extend( mapping )
265    print '[genmap] application "raycast" will be loaded'
266
[591]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
[539]287###################################################################################
[319]288#   Generate xml file if required.
289#   It can be used for debug.
[539]290###################################################################################
[319]291
292if ( xml_path != None ):
293    pathname = xml_path + '/map.xml'
294    f = open ( pathname, 'w' )
295    f.write( mapping.xml() )
[328]296    print '[genmap] %s generated for debug' % pathname
[319]297
[539]298###################################################################################
[319]299#   Generate netbsd.dts file if required.
300#   It is used for NetBSD configuration.
[539]301###################################################################################
[319]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() )
[411]307    print '[genmap] %s generated' % pathname
[319]308
[539]309###################################################################################
[411]310#   Generate linux.dts file if required.
311#   It is used for LINUX configuration.
[539]312###################################################################################
[411]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
[539]320###################################################################################
[319]321#   Generate arch.bib file if required.
322#   It is used for ALMOS configuration.
[539]323###################################################################################
[319]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() )
[328]329    print '[genmap] %s generated for almos' % pathname
[319]330
[539]331###################################################################################
[319]332#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
333#   They are used for GietVM compilation and configuration.
[539]334###################################################################################
[319]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 ) ) )
[328]341    print '[genmap] %s generated for giet_vm' % pathname
[319]342
343    pathname = giet_path + '/hard_config.h'
344    f = open ( pathname, 'w' )
345    f.write( mapping.hard_config() )
[328]346    print '[genmap] %s generated for giet_vm' % pathname
[319]347
348    pathname = giet_path + '/giet_vsegs.ld'
349    f = open ( pathname, 'w' )
350    f.write( mapping.giet_vsegs() )
[328]351    print '[genmap] %s generated for giet_vm' % pathname
[319]352
[539]353###################################################################################
[401]354#   Generate hard_config.h file if required.
[539]355###################################################################################
[401]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.