source: soft/giet_vm/giet_python/genmap @ 816

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