source: soft/giet_vm/giet_python/genmap @ 576

Last change on this file since 576 was 565, checked in by alain, 10 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
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
136###################################################################################
137#   Get command line arguments
138###################################################################################
139
140(options,args) = parser.parse_args()
141
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
147ioc_type       = options.ioc_type    # ioc controller type
148
149verbose        = options.verbose     # report on map.bin generation if True
150
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
156
157arch_path      = options.arch_path   # path to selected architecture
158
159xml_path       = options.xml_path    # path for map.xml file     
160
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
168map_coproc     = options.coproc      # map "coproc" application if True
169
170###################################################################################
171#   build empty platform (no applications yet)
172###################################################################################
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)
182select = __import__( 'arch' )
183
184# build mapping calling the function (function name)
185mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type )
186print '[genmap] platform %s build' % mapping.name
187
188###################################################################################
189#   complete mapping with application(s) as required
190###################################################################################
191
192if ( map_transpose ):
193    app = __import__( 'transpose' )
194    app.transpose( mapping )
195    print '[genmap] application "transpose" will be loaded'
196
197if ( map_sort ):     
198    app = __import__( 'sort' )
199    app.sort( mapping )
200    print '[genmap] application "sort" will be loaded'
201
202if ( map_convol ):     
203    app = __import__( 'convol' )
204    app.convol( mapping )
205    print '[genmap] application "convol" will be loaded'
206
207if ( map_router ):     
208    app = __import__( 'router' )
209    app.router( mapping )
210    print '[genmap] application "router" will be loaded'
211
212if ( map_display ):     
213    app = __import__( 'display' )
214    app.display( mapping )
215    print '[genmap] application "display" will be loaded'
216
217if ( map_classif ):     
218    app = __import__( 'classif' )
219    app.classif( mapping )
220    print '[genmap] application "classif" will be loaded'
221
222if ( map_gameoflife ):
223    app = __import__( 'gameoflife' )
224    app.gameoflife( mapping )
225    print '[genmap] application "gameoflife" will be loaded'
226
227if ( map_coproc ):
228    app = __import__( 'coproc' )
229    app.coproc( mapping )
230    print '[genmap] application "coproc" will be loaded'
231
232###################################################################################
233#   Generate xml file if required.
234#   It can be used for debug.
235###################################################################################
236
237if ( xml_path != None ):
238    pathname = xml_path + '/map.xml'
239    f = open ( pathname, 'w' )
240    f.write( mapping.xml() )
241    print '[genmap] %s generated for debug' % pathname
242
243###################################################################################
244#   Generate netbsd.dts file if required.
245#   It is used for NetBSD configuration.
246###################################################################################
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() )
252    print '[genmap] %s generated' % pathname
253
254###################################################################################
255#   Generate linux.dts file if required.
256#   It is used for LINUX configuration.
257###################################################################################
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
265###################################################################################
266#   Generate arch.bib file if required.
267#   It is used for ALMOS configuration.
268###################################################################################
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() )
274    print '[genmap] %s generated for almos' % pathname
275
276###################################################################################
277#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
278#   They are used for GietVM compilation and configuration.
279###################################################################################
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 ) ) )
286    print '[genmap] %s generated for giet_vm' % pathname
287
288    pathname = giet_path + '/hard_config.h'
289    f = open ( pathname, 'w' )
290    f.write( mapping.hard_config() )
291    print '[genmap] %s generated for giet_vm' % pathname
292
293    pathname = giet_path + '/giet_vsegs.ld'
294    f = open ( pathname, 'w' )
295    f.write( mapping.giet_vsegs() )
296    print '[genmap] %s generated for giet_vm' % pathname
297
298###################################################################################
299#   Generate hard_config.h file if required.
300###################################################################################
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.