source: soft/giet_vm/giet_python/genmap @ 687

Last change on this file since 687 was 673, checked in by guerin, 9 years ago

raycast: initial port

Raycast is a small game that looks like Wolfenstein 3D. I created
it for my SESI project, on a Cortex M4 devboard.

Imported from
github.com/libcg/tiva-c/tree/master/boards/dk-tm4c129x/upmc_raycast

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