source: soft/giet_vm/giet_python/genmap @ 740

Last change on this file since 740 was 737, checked in by alain, 10 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
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# - classif
33# - convol
34# - coproc
35# - dhrystone
36# - display
37# - gameoflife
38# - mjpeg
39# - ocean
40# - raycast
41# - router
42# - sort
43# - shell
44# - transpose
45###################################################################################
46
47from optparse import OptionParser
48from mapping import *
49
50import sys
51
52###################################################################################
53#   define command line arguments   
54###################################################################################
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
69parser.add_option( '--p', type = 'int', dest = 'nb_procs', 
70                   default = 2,
71                   help = 'define number of processors per cluster' )
72
73parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', 
74                   default = 1,
75                   help = 'define number of tty channels' )
76
77parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', 
78                   default = 128,
79                   help = 'define frame buffer width and heigth' )
80
81parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
82                   default = 'BDV',
83                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
84
85parser.add_option( '--mwr', type = 'string', dest = 'mwr_type',
86                   default = 'CPY',
87                   help = 'define type of COPROC: CPY / DCT / GCD' )
88
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
96parser.add_option( '--linux', type = 'string', dest = 'linux_path', 
97                   help = 'define pathname for the linux.dts file' )
98
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
105parser.add_option( '--hard', type = 'string', dest = 'hard_path',
106                   help = 'define pathname for the hard_config.h file ' )
107
108parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
109                   help = 'define pathname for the map.xml file' )
110
111############  supported applications   ############################################
112
113parser.add_option( '--classif', action = 'store_true', dest = 'classif',     
114                   default = False,
115                   help = 'map the "classif" application for the GietVM' )
116
117parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
118                   default = False,
119                   help = 'map the "convol" application for the GietVM' )
120
121parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',     
122                   default = False,
123                   help = 'map the "coproc" application for the GietVM' )
124
125parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',     
126                   default = False,
127                   help = 'map the "dhrystone" application for the GietVM' )
128
129parser.add_option( '--display', action = 'store_true', dest = 'display',     
130                   default = False,
131                   help = 'map the "display" application for the GietVM' )
132
133parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',     
134                   default = False,
135                   help = 'map the "gameoflife" application for the GietVM' )
136
137parser.add_option( '--mjpeg', action = 'store_true', dest = 'mjpeg',
138                   default = False,
139                   help = 'map the "mjpeg" application for the GietVM' )
140
141parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',     
142                   default = False,
143                   help = 'map the "ocean" application for the GietVM' )
144
145parser.add_option( '--raycast', action = 'store_true', dest = 'raycast',     
146                   default = False,
147                   help = 'map the "raycast" application for the GietVM' )
148
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
165###################################################################################
166#   Get command line arguments
167###################################################################################
168
169(options,args) = parser.parse_args()
170
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
176ioc_type       = options.ioc_type    # ioc controller type
177mwr_type       = options.mwr_type    # hardware coprocessor type
178
179verbose        = options.verbose     # report on map.bin generation if True
180
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
186
187arch_path      = options.arch_path   # path to selected architecture
188
189xml_path       = options.xml_path    # path for map.xml file     
190
191map_classif    = options.classif     # map "classif" application if True
192map_convol     = options.convol      # map "convol" application if True
193map_coproc     = options.coproc      # map "coproc" application if True
194map_dhrystone  = options.dhrystone   # map "dhrystone" application if True
195map_display    = options.display     # map "display" application if True
196map_gameoflife = options.gameoflife  # map "gameoflife" application if True
197map_mjpeg      = options.mjpeg       # map "mjpeg" application if True
198map_ocean      = options.ocean       # map "ocean" application if True
199map_raycast    = options.raycast     # map "raycast" application if True
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
204
205###################################################################################
206#   build empty platform (no applications yet)
207###################################################################################
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)
217select = __import__( 'arch' )
218
219# build mapping calling the function (function name)
220mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type, mwr_type )
221print '[genmap] platform %s build' % mapping.name
222
223###################################################################################
224#   extend mapping with application(s) as required
225###################################################################################
226
227if ( map_classif ):     
228    appli = __import__( 'classif' )
229    appli.extend( mapping )
230    print '[genmap] application "classif" will be loaded'
231
232if ( map_convol ):   
233    appli = __import__( 'convol' )
234    appli.extend( mapping )
235    print '[genmap] application "convol" will be loaded'
236
237if ( map_coproc ):
238    appli = __import__( 'coproc' )
239    appli.extend( mapping )
240    print '[genmap] application "coproc" will be loaded'
241
242if ( map_dhrystone ):     
243    appli = __import__( 'dhrystone' )
244    appli.extend( mapping )
245    print '[genmap] application "dhrystone" will be loaded'
246
247if ( map_display ):     
248    appli = __import__( 'display' )
249    appli.extend( mapping )
250    print '[genmap] application "display" will be loaded'
251
252if ( map_gameoflife ):
253    appli = __import__( 'gameoflife' )
254    appli.extend( mapping )
255    print '[genmap] application "gameoflife" will be loaded'
256
257if ( map_mjpeg ):
258    appli = __import__( 'mjpeg' )
259    appli.extend( mapping )
260    print '[genmap] application "mjpeg" will be loaded'
261
262if ( map_ocean ):
263    appli = __import__( 'ocean' )
264    appli.extend( mapping )
265    print '[genmap] application "ocean" will be loaded'
266
267if ( map_raycast ):     
268    appli = __import__( 'raycast' )
269    appli.extend( mapping )
270    print '[genmap] application "raycast" will be loaded'
271
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
292###################################################################################
293#   Generate xml file if required.
294#   It can be used for debug.
295###################################################################################
296
297if ( xml_path != None ):
298    pathname = xml_path + '/map.xml'
299    f = open ( pathname, 'w' )
300    f.write( mapping.xml() )
301    print '[genmap] %s generated for debug' % pathname
302
303###################################################################################
304#   Generate netbsd.dts file if required.
305#   It is used for NetBSD configuration.
306###################################################################################
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() )
312    print '[genmap] %s generated' % pathname
313
314###################################################################################
315#   Generate linux.dts file if required.
316#   It is used for LINUX configuration.
317###################################################################################
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
325###################################################################################
326#   Generate arch.bib file if required.
327#   It is used for ALMOS configuration.
328###################################################################################
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() )
334    print '[genmap] %s generated for almos' % pathname
335
336###################################################################################
337#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
338#   They are used for GietVM compilation and configuration.
339###################################################################################
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 ) ) )
346    print '[genmap] %s generated for giet_vm' % pathname
347
348    pathname = giet_path + '/hard_config.h'
349    f = open ( pathname, 'w' )
350    f.write( mapping.hard_config() )
351    print '[genmap] %s generated for giet_vm' % pathname
352
353    pathname = giet_path + '/giet_vsegs.ld'
354    f = open ( pathname, 'w' )
355    f.write( mapping.giet_vsegs() )
356    print '[genmap] %s generated for giet_vm' % pathname
357
358###################################################################################
359#   Generate hard_config.h file if required.
360###################################################################################
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.