source: soft/giet_vm/giet_python/genmap @ 569

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

Introduce support for a new driver sdc_driver.
There is now 5 IOC drivers: BDV / HBA / RDK / SDC / SPI.

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