source: soft/giet_vm/giet_python/genmap @ 580

Last change on this file since 580 was 580, checked in by laurent, 9 years ago

Try

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