source: soft/giet_vm/giet_python/genmap @ 749

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

Modify genmap to directly control the coprocessor type
using arguments defined in the Makefile.

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